|
Open Model Railroad Network (OpenMRN)
|
A network-initialized bit is a tri-state bit implementation that starts up in the UNKNOWN state until either a local state set or a remote state set occurs. More...
#include <EventHandlerTemplates.hxx>
Public Member Functions | |
| NetworkInitializedBit (Node *node, uint64_t event_on, uint64_t event_off, bool default_local_state) | |
| Constructs a NetworkInitializedBit. | |
| Node * | node () override |
| Get a reference to the owning Node. | |
| EventState | get_current_state () override |
| Accessor from the network stack to return the current state. | |
| bool | get_local_state () |
| bool | is_network_state_known () |
| void | set_state (bool new_value) override |
| Call from the network stack (or the client before notifying the network stack) to set the state. | |
| void | toggle_state () |
| Invert the current state. | |
Public Member Functions inherited from openlcb::BitEventInterface | |
| BitEventInterface (uint64_t event_on, uint64_t event_off) | |
| virtual EventState | get_requested_state () |
| Get the requested state. | |
| uint64_t | event_on () |
| returns the event ID for representing the state transition OFF->ON. | |
| uint64_t | event_off () |
| returns the event ID for representing the state transition ON->OFF. | |
Protected Attributes | |
| Node * | node_ |
| uint8_t | isKnown_: 1 |
| true when we knowthe network state | |
| uint8_t | localState_: 1 |
| local state; either matches the network state or is the constructor-default local state. | |
A network-initialized bit is a tri-state bit implementation that starts up in the UNKNOWN state until either a local state set or a remote state set occurs.
After that transient passes the state will always be definite. The network state set typically comes from query responses or other nodes setting the state. The owner of this bit will typically want to actively send out a query upon boot or network reconnect.
Definition at line 308 of file EventHandlerTemplates.hxx.
|
inline |
Constructs a NetworkInitializedBit.
| node | the virtual node who exposes this bit. |
| event_on | event ID to set the state to true |
| event_off | event ID to set the state to false |
| default_local_state | Until there is a definite network state we return this state for a local query. Also determines what state a first local toggle() call will set to. |
Definition at line 318 of file EventHandlerTemplates.hxx.
|
inlineoverridevirtual |
Accessor from the network stack to return the current state.
Implements openlcb::BitEventInterface.
Definition at line 336 of file EventHandlerTemplates.hxx.
|
inline |
Definition at line 345 of file EventHandlerTemplates.hxx.
|
inline |
Definition at line 351 of file EventHandlerTemplates.hxx.
|
inlineoverridevirtual |
Get a reference to the owning Node.
Implements openlcb::BitEventInterface.
Definition at line 329 of file EventHandlerTemplates.hxx.
|
inlineoverridevirtual |
Call from the network stack (or the client before notifying the network stack) to set the state.
Always sets the state to definite.
| new | state value |
NOTE: this does not send any messages. The caller must use the EventHandler object after this function to send out an event.
Implements openlcb::BitEventInterface.
Definition at line 361 of file EventHandlerTemplates.hxx.
|
inline |
Invert the current state.
This also works when the network state is not yet known: in that case it sets the state to the opposite of the default state.
NOTE: this does not send any messages. The caller must use the EventHandler object after this function to send out an event.
Definition at line 373 of file EventHandlerTemplates.hxx.
|
protected |
true when we knowthe network state
Definition at line 381 of file EventHandlerTemplates.hxx.
|
protected |
local state; either matches the network state or is the constructor-default local state.
Definition at line 384 of file EventHandlerTemplates.hxx.
|
protected |
Definition at line 379 of file EventHandlerTemplates.hxx.