Skip to content

BiDiB State Object

Eugene edited this page Jul 19, 2021 · 5 revisions

Handling of BiDiB Communication

The sending and receiving of BiDiB messages to and from the BiDiB boards are handled by two pthreads that are forked after serial communication has been established with the BiDiB boards:

All message types are defined in include/definitions/bidib_messages.h.

State Object Updates

The BiDiB state is stored in a t_bidib_track_state_intern data structure. It is sometimes updated after an actuate command is sent to the BiDiB boards, or after a BiDiB feedback message has been received, e.g.:

Accessing the State Object

The state of specific track elements can be retrieved by calling one of the bidib_get_..._state(...) functions and providing the name of the track element (defined in the Yaml configuration files), e.g.:

These functions iterate over the state object until it finds the name of the provided track element. The index of the track element in the state object can be retrieved, so that its state can be accessed directly in constant time.

The entire BiDiB state is retrieved by calling bidib_get_state(void) from src/highlevel/bidib_highlevel_getter.c, which returns a t_bidib_track_state data structure. The index of a track element in the state object can be retrieved with one of the following functions: