Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
openlcb::BitEventInterface Class Referenceabstract

Represents a bit of state using two events. More...

#include <EventHandlerTemplates.hxx>

Inheritance diagram for openlcb::BitEventInterface:
openlcb::MemoryBit< uint8_t > openlcb::DistributedBit openlcb::GPIOBit openlcb::MemoryBit< T > openlcb::NetworkInitializedBit openlcb::CallbackNetworkInitializedBit

Public Member Functions

 BitEventInterface (uint64_t event_on, uint64_t event_off)
 
virtual EventState get_current_state ()=0
 returns the current hardware state: true for ON, false for OFF.
 
virtual EventState get_requested_state ()
 Get the requested state.
 
virtual void set_state (bool new_value)=0
 Updates the hardware for the new event 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.
 
virtual Nodenode ()=0
 returns the OpenLCB virtual node from which to send the respective events when the bit changes.
 

Private Member Functions

 DISALLOW_COPY_AND_ASSIGN (BitEventInterface)
 

Private Attributes

uint64_t event_on_
 
uint64_t event_off_
 

Detailed Description

Represents a bit of state using two events.

This class is used as an implementation plugin to various event producers and consumers. It encapsulates application-specific information about the event bit:

  • which OpenLCB node this bit is represented on;
  • the event identifiers for ON and OFF events;
  • how to query the hardware for the current event state;
  • how to set the hardware to a new event state.

See BitEventProducer, BitEventConsumer, BitEventPC.

Definition at line 181 of file EventHandlerTemplates.hxx.

Constructor & Destructor Documentation

◆ BitEventInterface()

openlcb::BitEventInterface::BitEventInterface ( uint64_t  event_on,
uint64_t  event_off 
)
inline

Definition at line 184 of file EventHandlerTemplates.hxx.

Member Function Documentation

◆ event_off()

uint64_t openlcb::BitEventInterface::event_off ( )
inline

returns the event ID for representing the state transition ON->OFF.

Definition at line 213 of file EventHandlerTemplates.hxx.

◆ event_on()

uint64_t openlcb::BitEventInterface::event_on ( )
inline

returns the event ID for representing the state transition OFF->ON.

Definition at line 207 of file EventHandlerTemplates.hxx.

◆ get_current_state()

virtual EventState openlcb::BitEventInterface::get_current_state ( )
pure virtual

returns the current hardware state: true for ON, false for OFF.

Implemented in openlcb::DistributedBit, openlcb::NetworkInitializedBit, openlcb::MemoryBit< T >, openlcb::MemoryBit< uint8_t >, and openlcb::GPIOBit.

◆ get_requested_state()

virtual EventState openlcb::BitEventInterface::get_requested_state ( )
inlinevirtual

Get the requested state.

@TODO(stbaker): document the difference between requested state and current state.

Returns
requested state

Reimplemented in openlcb::DistributedBit.

Definition at line 196 of file EventHandlerTemplates.hxx.

◆ node()

virtual Node * openlcb::BitEventInterface::node ( )
pure virtual

returns the OpenLCB virtual node from which to send the respective events when the bit changes.

Implemented in openlcb::DistributedBit, openlcb::NetworkInitializedBit, openlcb::MemoryBit< T >, openlcb::MemoryBit< uint8_t >, and openlcb::GPIOBit.

◆ set_state()

virtual void openlcb::BitEventInterface::set_state ( bool  new_value)
pure virtual

Updates the hardware for the new event state.

Parameters
new_valueis true for state ON, false for state OFF.

Implemented in openlcb::DistributedBit, openlcb::NetworkInitializedBit, openlcb::CallbackNetworkInitializedBit, openlcb::MemoryBit< T >, openlcb::MemoryBit< uint8_t >, and openlcb::GPIOBit.

Member Data Documentation

◆ event_off_

uint64_t openlcb::BitEventInterface::event_off_
private

Definition at line 224 of file EventHandlerTemplates.hxx.

◆ event_on_

uint64_t openlcb::BitEventInterface::event_on_
private

Definition at line 223 of file EventHandlerTemplates.hxx.


The documentation for this class was generated from the following file: