|
Open Model Railroad Network (OpenMRN)
|
Event handler for a single-bit producer, e.g. More...
#include <EventHandlerTemplates.hxx>
Public Member Functions | |
| BitEventProducer (BitEventInterface *bit) | |
| void | Update (WriteHelper *writer, Notifiable *done) |
| Requests the event associated with the current value of the bit to be produced (unconditionally). | |
| void | SendQuery (WriteHelper *writer, BarrierNotifiable *done) |
| Queries consumers and acquires the current state of the bit. | |
| void | handle_identify_global (const EventRegistryEntry &entry, EventReport *event, BarrierNotifiable *done) override |
| Called on the need of sending out identification messages. | |
| void | handle_identify_producer (const EventRegistryEntry &entry, EventReport *event, BarrierNotifiable *done) override |
| Called on another node sending IdentifyProducer. | |
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_event_report (const EventRegistryEntry ®istry_entry, EventReport *event, BarrierNotifiable *done)=0 |
| Called on incoming EventReport messages. | |
| virtual void | handle_consumer_identified (const EventRegistryEntry ®istry_entry, EventReport *event, BarrierNotifiable *done) |
| Called on another node sending ConsumerIdentified for this event. | |
| virtual void | handle_consumer_range_identified (const EventRegistryEntry ®istry_entry, EventReport *event, BarrierNotifiable *done) |
| Called on another node sending ConsumerRangeIdentified. | |
| virtual void | handle_producer_identified (const EventRegistryEntry ®istry_entry, EventReport *event, BarrierNotifiable *done) |
| Called on another node sending ProducerIdentified for this event. | |
| virtual void | handle_producer_range_identified (const EventRegistryEntry ®istry_entry, EventReport *event, BarrierNotifiable *done) |
| Called on another node sending ProducerRangeIdentified for this event. | |
| virtual void | handle_identify_consumer (const EventRegistryEntry ®istry_entry, EventReport *event, BarrierNotifiable *done)=0 |
| Called on another node sending IdentifyConsumer. | |
Private Member Functions | |
| DISALLOW_COPY_AND_ASSIGN (BitEventProducer) | |
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 | |
| BitEventInterface * | bit_ |
Event handler for a single-bit producer, e.g.
an individual pin of GPIO input. Exports two event producers on the OpenLCB bus, one for the bit state == ON, and another for the bit state == OFF.
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 609 of file EventHandlerTemplates.hxx.
|
inline |
@TODO (balazs.racz) this should be more efficient when done from the update configuration callback.
Definition at line 612 of file EventHandlerTemplates.hxx.
|
inline |
Definition at line 618 of file EventHandlerTemplates.hxx.
|
overridevirtual |
Called on the need of sending out identification messages.
| event | is NULL. This happens on startup, or when a global or addressed IdentifyGlobal message arrives. Might have destination node id! |
| registry_entry | gives the registry entry for which the current handler is being called. |
| done | must be notified when the processing is done. |
Implements openlcb::EventHandler.
Definition at line 708 of file EventHandlerTemplates.cxx.
|
overridevirtual |
Called on another node sending IdentifyProducer.
| event | stores information about the incoming message. Filled: src_node, event, mask=1. Not filled: state. |
| registry_entry | gives the registry entry for which the current handler is being called. |
| done | must be notified when the processing is done. |
Implements openlcb::EventHandler.
Definition at line 719 of file EventHandlerTemplates.cxx.
| void openlcb::BitEventProducer::SendQuery | ( | WriteHelper * | writer, |
| BarrierNotifiable * | done | ||
| ) |
Queries consumers and acquires the current state of the bit.
Definition at line 701 of file EventHandlerTemplates.cxx.
|
inline |
Requests the event associated with the current value of the bit to be produced (unconditionally).
| writer | is the output flow to be used. |
| done | is the notification callback. If it is NULL, the writer will be invoked inline and potentially block the calling thread. |
@TODO: remove this function and change all callers to use SendEventReport instead.
Definition at line 634 of file EventHandlerTemplates.hxx.