|
Open Model Railroad Network (OpenMRN)
|
Base (generic protocol) implementation of a DCC accessory consumer. More...
#include <DccAccyConsumer.hxx>
Protected Member Functions | |
| DccAccyConsumerBase (Node *node) | |
| Constructs a listener for DCC accessory control. | |
| ~DccAccyConsumerBase () | |
| Destructor. | |
| void | handle_identify_global (const EventRegistryEntry ®istry_entry, EventReport *event, BarrierNotifiable *done) OVERRIDE |
| Called on the need of sending out identification messages. | |
| void | handle_event_report (const EventRegistryEntry ®istry_entry, EventReport *event, BarrierNotifiable *done) override |
| Called on incoming EventReport messages. | |
| void | handle_identify_consumer (const EventRegistryEntry &entry, EventReport *event, BarrierNotifiable *done) override |
| Called on another node sending IdentifyConsumer. | |
| virtual void | send_accy_command ()=0 |
| Send the actual accessory command. | |
| bool | parse_event (EventId event) |
| Parses an event into an openlcb accessory offset. | |
Protected Attributes | |
| unsigned | onOff_: 1 |
| Parsed event state: 1 = activate (C=1), 2 = deactivate (C=0). | |
| unsigned | normalReverse_: 1 |
| Parsed event state: 1 = normal (D0=1), 0 = reversed (D0=0). | |
| unsigned | dccAddress_: 12 |
| Parsed event state: dcc address (0..4095) without inverting or encoding. | |
| unsigned | eventOfs_: 6 |
| Parsed event state: offset in the state_ array. | |
| unsigned | eventMask_: 5 |
| Parsed event state: bit index (0..31) in the uint32 in the state_ array entry pointed to by eventOfs_. | |
| uint32_t | lastSetState_ [64] |
| each bit determines what the last command sent to the accessory address was. | |
| uint32_t | isStateKnown_ [64] |
| each bit determines whether we've sent a command to that accessory address yet or not. | |
| Node * | node_ |
| OpenLCB node to export the consumer on. | |
Additional Inherited Members | |
Public Types inherited from openlcb::EventHandler | |
| using | EventReport = openlcb::EventReport |
| using | EventRegistryEntry = openlcb::EventRegistryEntry |
| using | EventId = openlcb::EventId |
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 ®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. | |
Base (generic protocol) implementation of a DCC accessory consumer.
Definition at line 47 of file DccAccyConsumer.hxx.
|
inlineprotected |
Constructs a listener for DCC accessory control.
| node | is the virtual node that will be listening for events and responding to Identify messages. |
Definition at line 53 of file DccAccyConsumer.hxx.
|
inlineprotected |
Destructor.
Definition at line 69 of file DccAccyConsumer.hxx.
|
inlineoverrideprotectedvirtual |
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 104 of file DccAccyConsumer.hxx.
|
inlineoverrideprotectedvirtual |
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 126 of file DccAccyConsumer.hxx.
|
inlineprotectedvirtual |
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 74 of file DccAccyConsumer.hxx.
|
inlineprotected |
Parses an event into an openlcb accessory offset.
| on_off | will be set to true if this is an activate event, false if it is an inactivate event. |
| ofs | will be set to the offset in the state_ arrays. |
| mask | will be set to a single bit value that marks the location in the state_ arrays. |
Definition at line 175 of file DccAccyConsumer.hxx.
|
protectedpure virtual |
Send the actual accessory command.
Implemented in openlcb::DccAccyConsumer.
|
protected |
Parsed event state: dcc address (0..4095) without inverting or encoding.
Definition at line 209 of file DccAccyConsumer.hxx.
|
protected |
Parsed event state: bit index (0..31) in the uint32 in the state_ array entry pointed to by eventOfs_.
Definition at line 214 of file DccAccyConsumer.hxx.
|
protected |
Parsed event state: offset in the state_ array.
Definition at line 211 of file DccAccyConsumer.hxx.
|
protected |
each bit determines whether we've sent a command to that accessory address yet or not.
bit==0 means unknown state, bit==1 means state is known.
Definition at line 222 of file DccAccyConsumer.hxx.
|
protected |
each bit determines what the last command sent to the accessory address was.
bit==0 is reverse. bit==1 is normal.
Definition at line 218 of file DccAccyConsumer.hxx.
|
protected |
OpenLCB node to export the consumer on.
Definition at line 225 of file DccAccyConsumer.hxx.
|
protected |
Parsed event state: 1 = normal (D0=1), 0 = reversed (D0=0).
Definition at line 207 of file DccAccyConsumer.hxx.
|
protected |
Parsed event state: 1 = activate (C=1), 2 = deactivate (C=0).
Definition at line 205 of file DccAccyConsumer.hxx.