Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
openlcb::BitEventConsumer Class Reference

Event handler for a single-bit consumer, e.g. More...

#include <EventHandlerTemplates.hxx>

Inheritance diagram for openlcb::BitEventConsumer:
openlcb::BitEventHandler openlcb::SimpleEventHandler openlcb::EventHandler openlcb::BitEventPC

Public Member Functions

 BitEventConsumer (BitEventInterface *bit)
 
void SendQuery (WriteHelper *writer, BarrierNotifiable *done)
 Queries producers and acquires the current state of the bit.
 
void handle_event_report (const EventRegistryEntry &entry, EventReport *event, BarrierNotifiable *done) override
 Called on incoming EventReport messages.
 
void handle_identify_global (const EventRegistryEntry &entry, EventReport *event, BarrierNotifiable *done) override
 Called on the need of sending out identification messages.
 
void handle_identify_consumer (const EventRegistryEntry &entry, EventReport *event, BarrierNotifiable *done) override
 Called on another node sending IdentifyConsumer.
 
void handle_producer_identified (const EventRegistryEntry &entry, EventReport *event, BarrierNotifiable *done) override
 Called on another node sending ProducerIdentified for this event.
 
- Public Member Functions inherited from openlcb::BitEventHandler
 BitEventHandler (BitEventInterface *bit)
 
void SendEventReport (WriteHelper *writer, Notifiable *done)
 Requests the event associated with the current value of the bit to be produced (unconditionally): sends an event report packet ot the bus.
 
- Public Member Functions inherited from openlcb::SimpleEventHandler
 IGNOREFN (handle_event_report)
 
 IGNOREFN (handle_consumer_identified)
 
 IGNOREFN (handle_consumer_range_identified)
 
 IGNOREFN (handle_producer_identified)
 
 IGNOREFN (handle_producer_range_identified)
 
 IGNOREFN (handle_identify_consumer)
 
 IGNOREFN (handle_identify_producer)
 
- Public Member Functions inherited from openlcb::EventHandler
virtual void handle_consumer_identified (const EventRegistryEntry &registry_entry, EventReport *event, BarrierNotifiable *done)
 Called on another node sending ConsumerIdentified for this event.
 
virtual void handle_consumer_range_identified (const EventRegistryEntry &registry_entry, EventReport *event, BarrierNotifiable *done)
 Called on another node sending ConsumerRangeIdentified.
 
virtual void handle_producer_range_identified (const EventRegistryEntry &registry_entry, EventReport *event, BarrierNotifiable *done)
 Called on another node sending ProducerRangeIdentified for this event.
 
virtual void handle_identify_producer (const EventRegistryEntry &registry_entry, EventReport *event, BarrierNotifiable *done)=0
 Called on another node sending IdentifyProducer.
 

Additional Inherited Members

- Public Types inherited from openlcb::EventHandler
using EventReport = openlcb::EventReport
 
using EventRegistryEntry = openlcb::EventRegistryEntry
 
using EventId = openlcb::EventId
 
- Protected Member Functions inherited from openlcb::BitEventHandler
void register_handler (uint64_t event_on, uint64_t event_off)
 Registers this event handler with the global event manager.
 
void unregister_handler ()
 Removes this event handler from the global event manager.
 
void SendProducerIdentified (EventReport *event, BarrierNotifiable *done)
 Sends off two packets using event_write_helper{1,2} of ProducerIdentified for handling a global identify events message.
 
void SendConsumerIdentified (EventReport *event, BarrierNotifiable *done)
 Sends off two packets using event_write_helper{3,4} of ConsumerIdentified for handling a global identify events message.
 
void HandlePCIdentify (Defs::MTI mti_valid, EventReport *event, BarrierNotifiable *done)
 Checks if the event in the report is something we are interested in, and if so, sends off a {Producer|Consumer}Identified{Valid|Invalid} message depending on the current state of the hardware bit.
 
- Protected Attributes inherited from openlcb::BitEventHandler
BitEventInterfacebit_
 

Detailed Description

Event handler for a single-bit consumer, e.g.

an individual pin of GPIO output, or a turnout driver, etc. Exports two event consumers on the OpenLCB bus, one for the bit state == ON, and another for the bit state == OFF. Calls the hardware implementation when any of the defined events come on the bus.

Usage:

Implement the hardware accessor methods in a descendant of BitEventInterface. Instantiate this class by passing the pointer to it in the constructor. When the hardware state changes, call the SendEventReport method.

Definition at line 665 of file EventHandlerTemplates.hxx.

Constructor & Destructor Documentation

◆ BitEventConsumer()

openlcb::BitEventConsumer::BitEventConsumer ( BitEventInterface bit)
inline

Definition at line 668 of file EventHandlerTemplates.hxx.

◆ ~BitEventConsumer()

openlcb::BitEventConsumer::~BitEventConsumer ( )
inline

Definition at line 672 of file EventHandlerTemplates.hxx.

Member Function Documentation

◆ handle_event_report()

void openlcb::BitEventConsumer::handle_event_report ( const EventRegistryEntry registry_entry,
EventReport event,
BarrierNotifiable done 
)
overridevirtual

Called on incoming EventReport messages.

Parameters
eventstores information about the incoming message. Filled: src_node, event. Mask is always 1 (filled in). state is not filled in.
registry_entrygives the registry entry for which the current handler is being called.
donemust be notified when the processing is done.

Implements openlcb::EventHandler.

Definition at line 687 of file EventHandlerTemplates.cxx.

◆ handle_identify_consumer()

void openlcb::BitEventConsumer::handle_identify_consumer ( const EventRegistryEntry registry_entry,
EventReport event,
BarrierNotifiable done 
)
overridevirtual

Called on another node sending IdentifyConsumer.

Parameters
eventstores information about the incoming message. Filled: src_node, event, mask=1. Not filled: state.
registry_entrygives the registry entry for which the current handler is being called.
donemust be notified when the processing is done.

Implements openlcb::EventHandler.

Definition at line 731 of file EventHandlerTemplates.cxx.

◆ handle_identify_global()

void openlcb::BitEventConsumer::handle_identify_global ( const EventRegistryEntry registry_entry,
EventReport event,
BarrierNotifiable done 
)
overridevirtual

Called on the need of sending out identification messages.

Parameters
eventis NULL. This happens on startup, or when a global or addressed IdentifyGlobal message arrives. Might have destination node id!
registry_entrygives the registry entry for which the current handler is being called.
donemust be notified when the processing is done.

Implements openlcb::EventHandler.

Reimplemented in openlcb::BitEventPC.

Definition at line 737 of file EventHandlerTemplates.cxx.

◆ handle_producer_identified()

void openlcb::BitEventConsumer::handle_producer_identified ( const EventRegistryEntry registry_entry,
EventReport event,
BarrierNotifiable done 
)
overridevirtual

Called on another node sending ProducerIdentified for this event.

Parameters
eventstores information about the incoming message. Filled: event_id, mask=1, src_node, state.
registry_entrygives the registry entry for which the current handler is being called.
user_argis an opaque argument passed in from the registration.
donemust be notified when the processing is done.

Reimplemented from openlcb::EventHandler.

Definition at line 649 of file EventHandlerTemplates.cxx.

◆ SendQuery()

void openlcb::BitEventConsumer::SendQuery ( WriteHelper writer,
BarrierNotifiable done 
)

Queries producers and acquires the current state of the bit.

Definition at line 680 of file EventHandlerTemplates.cxx.


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