|
Open Model Railroad Network (OpenMRN)
|
OpenLCB Consumer class integrating a simple CDI-based configuration for a single event IDs, and an output GPIO object that will be turned on for a short period of time when the incoming event notifications arrives. More...
#include <ConfiguredConsumer.hxx>
Public Member Functions | |
| template<class HW > | |
| ConfiguredPulseConsumer (Node *node, const PulseConsumerConfig &cfg, const HW &, const Gpio *g=HW::instance()) | |
| ConfiguredPulseConsumer (Node *node, const PulseConsumerConfig &cfg, const Gpio *gpio) | |
| UpdateAction | apply_configuration (int fd, bool initial_load, BarrierNotifiable *done) OVERRIDE |
| Notifies the component that there is new configuration available for loading. | |
| void | factory_reset (int fd) OVERRIDE |
| Clears configuration file and resets the configuration settings to factory value. | |
Public Member Functions inherited from QMember | |
| void | init () |
| Initiailize a QMember, in place of a public placement construction. | |
Private Member Functions | |
| void | do_register () |
| Registers the event handler with the global event registry. | |
| void | do_unregister () |
| Removed registration of this event handler from the global event registry. | |
| void | handle_identify_global (const EventRegistryEntry ®istry_entry, EventReport *event, BarrierNotifiable *done) OVERRIDE |
| Called on the need of sending out identification messages. | |
| void | SendConsumerIdentified (EventReport *event, BarrierNotifiable *done) |
| void | handle_identify_consumer (const EventRegistryEntry ®istry_entry, EventReport *event, BarrierNotifiable *done) OVERRIDE |
| Called on another node sending IdentifyConsumer. | |
| void | handle_event_report (const EventRegistryEntry ®istry_entry, EventReport *event, BarrierNotifiable *done) OVERRIDE |
| Called on incoming EventReport messages. | |
| void | poll_33hz (WriteHelper *helper, Notifiable *done) OVERRIDE |
| This function will be called approximately 33 times per second by the refresh loop. | |
Private 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) | |
Private Member Functions inherited from openlcb::EventHandler | |
| 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_producer (const EventRegistryEntry ®istry_entry, EventReport *event, BarrierNotifiable *done)=0 |
| Called on another node sending IdentifyProducer. | |
Private Attributes | |
| Node * | node_ |
| const Gpio * | gpio_ |
| EventId | event_ {0} |
| const PulseConsumerConfig | cfg_ |
| uint8_t | pulseLength_ {1} |
| uint8_t | pulseRemaining_ {0} |
Additional Inherited Members | |
Public Types inherited from ConfigUpdateListener | |
| enum | UpdateAction { UPDATED = 0 , REINIT_NEEDED , REBOOT_NEEDED } |
| Specifies what additional steps are needed to apply the new configuration. More... | |
Protected Member Functions inherited from QMember | |
| QMember () | |
| Constructor. | |
| ~QMember () | |
| Destructor. | |
Protected Attributes inherited from QMember | |
| QMember * | next |
| pointer to the next member in the queue | |
Private Types inherited from openlcb::EventHandler | |
| using | EventReport = openlcb::EventReport |
| using | EventRegistryEntry = openlcb::EventRegistryEntry |
| using | EventId = openlcb::EventId |
OpenLCB Consumer class integrating a simple CDI-based configuration for a single event IDs, and an output GPIO object that will be turned on for a short period of time when the incoming event notifications arrives.
Useful for driving magnetic coil-based turnouts and signals.
Definition at line 147 of file ConfiguredConsumer.hxx.
|
inline |
Definition at line 153 of file ConfiguredConsumer.hxx.
|
inline |
Definition at line 162 of file ConfiguredConsumer.hxx.
|
inline |
Definition at line 171 of file ConfiguredConsumer.hxx.
|
inlinevirtual |
Notifies the component that there is new configuration available for loading.
The call is made on the main executor, so the call must not block. Reading the given EEPROM device should be fine. Asynchronous operations may be implemented by using a special return status RETRY: the runner will call the same method on the same component once more after the done callback is invoked. This allows implementing state machines.
| fd | is the file descriptor for the EEPROM file. The current offset in this file is unspecified, callees must do lseek. |
| initial_load | is true if this is the first load upon starting the binary. |
| done | must be notified when the call and its dependent actions are complete. No other configuration component will be called until the done callback is invoked. |
Implements ConfigUpdateListener.
Definition at line 177 of file ConfiguredConsumer.hxx.
|
inlineprivate |
Registers the event handler with the global event registry.
Definition at line 202 of file ConfiguredConsumer.hxx.
|
inlineprivate |
Removed registration of this event handler from the global event registry.
Definition at line 210 of file ConfiguredConsumer.hxx.
|
inlinevirtual |
Clears configuration file and resets the configuration settings to factory value.
| fd | is the file descriptor for the EEPROM file. The current offset in this file is unspecified, callees must do lseek. |
Implements ConfigUpdateListener.
Definition at line 194 of file ConfiguredConsumer.hxx.
|
inlineprivatevirtual |
Called on incoming EventReport messages.
| event | stores information about the incoming message. Filled: src_node, event. Mask is always 1 (filled in). state is not filled in. |
| 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 249 of file ConfiguredConsumer.hxx.
|
inlineprivatevirtual |
Called on another node sending IdentifyConsumer.
| 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 239 of file ConfiguredConsumer.hxx.
|
inlineprivatevirtual |
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 217 of file ConfiguredConsumer.hxx.
|
inlineprivatevirtual |
This function will be called approximately 33 times per second by the refresh loop.
It must notify done when it is finished using the writehelper.
Implements openlcb::Polling.
Definition at line 260 of file ConfiguredConsumer.hxx.
|
inlineprivate |
Definition at line 228 of file ConfiguredConsumer.hxx.
|
private |
Definition at line 277 of file ConfiguredConsumer.hxx.
|
private |
Definition at line 276 of file ConfiguredConsumer.hxx.
|
private |
Definition at line 275 of file ConfiguredConsumer.hxx.
|
private |
Definition at line 274 of file ConfiguredConsumer.hxx.
|
private |
Definition at line 278 of file ConfiguredConsumer.hxx.
|
private |
Definition at line 279 of file ConfiguredConsumer.hxx.