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

Base (generic protocol) implementation of a DCC accessory consumer. More...

#include <DccAccyConsumer.hxx>

Inheritance diagram for openlcb::DccAccyConsumerBase:
openlcb::SimpleEventHandler openlcb::EventHandler openlcb::DccAccyConsumer

Protected Member Functions

 DccAccyConsumerBase (Node *node)
 Constructs a listener for DCC accessory control.
 
 ~DccAccyConsumerBase ()
 Destructor.
 
void handle_identify_global (const EventRegistryEntry &registry_entry, EventReport *event, BarrierNotifiable *done) OVERRIDE
 Called on the need of sending out identification messages.
 
void handle_event_report (const EventRegistryEntry &registry_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.
 
Nodenode_
 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 &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_identified (const EventRegistryEntry &registry_entry, EventReport *event, BarrierNotifiable *done)
 Called on another node sending ProducerIdentified for this event.
 
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.
 

Detailed Description

Base (generic protocol) implementation of a DCC accessory consumer.

Definition at line 47 of file DccAccyConsumer.hxx.

Constructor & Destructor Documentation

◆ DccAccyConsumerBase()

openlcb::DccAccyConsumerBase::DccAccyConsumerBase ( Node node)
inlineprotected

Constructs a listener for DCC accessory control.

Parameters
nodeis the virtual node that will be listening for events and responding to Identify messages.

Definition at line 53 of file DccAccyConsumer.hxx.

◆ ~DccAccyConsumerBase()

openlcb::DccAccyConsumerBase::~DccAccyConsumerBase ( )
inlineprotected

Destructor.

Definition at line 69 of file DccAccyConsumer.hxx.

Member Function Documentation

◆ handle_event_report()

void openlcb::DccAccyConsumerBase::handle_event_report ( const EventRegistryEntry registry_entry,
EventReport event,
BarrierNotifiable done 
)
inlineoverrideprotectedvirtual

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 104 of file DccAccyConsumer.hxx.

◆ handle_identify_consumer()

void openlcb::DccAccyConsumerBase::handle_identify_consumer ( const EventRegistryEntry registry_entry,
EventReport event,
BarrierNotifiable done 
)
inlineoverrideprotectedvirtual

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 126 of file DccAccyConsumer.hxx.

◆ handle_identify_global()

void openlcb::DccAccyConsumerBase::handle_identify_global ( const EventRegistryEntry registry_entry,
EventReport event,
BarrierNotifiable done 
)
inlineprotectedvirtual

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.

Definition at line 74 of file DccAccyConsumer.hxx.

◆ parse_event()

bool openlcb::DccAccyConsumerBase::parse_event ( EventId  event)
inlineprotected

Parses an event into an openlcb accessory offset.

Returns
true if the event is in the accessory range, false if this event can be ignored.
Parameters
on_offwill be set to true if this is an activate event, false if it is an inactivate event.
ofswill be set to the offset in the state_ arrays.
maskwill be set to a single bit value that marks the location in the state_ arrays.

Definition at line 175 of file DccAccyConsumer.hxx.

◆ send_accy_command()

virtual void openlcb::DccAccyConsumerBase::send_accy_command ( )
protectedpure virtual

Send the actual accessory command.

Implemented in openlcb::DccAccyConsumer.

Member Data Documentation

◆ dccAddress_

unsigned openlcb::DccAccyConsumerBase::dccAddress_
protected

Parsed event state: dcc address (0..4095) without inverting or encoding.

Definition at line 209 of file DccAccyConsumer.hxx.

◆ eventMask_

unsigned openlcb::DccAccyConsumerBase::eventMask_
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.

◆ eventOfs_

unsigned openlcb::DccAccyConsumerBase::eventOfs_
protected

Parsed event state: offset in the state_ array.

Definition at line 211 of file DccAccyConsumer.hxx.

◆ isStateKnown_

uint32_t openlcb::DccAccyConsumerBase::isStateKnown_[64]
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.

◆ lastSetState_

uint32_t openlcb::DccAccyConsumerBase::lastSetState_[64]
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.

◆ node_

Node* openlcb::DccAccyConsumerBase::node_
protected

OpenLCB node to export the consumer on.

Definition at line 225 of file DccAccyConsumer.hxx.

◆ normalReverse_

unsigned openlcb::DccAccyConsumerBase::normalReverse_
protected

Parsed event state: 1 = normal (D0=1), 0 = reversed (D0=0).

Definition at line 207 of file DccAccyConsumer.hxx.

◆ onOff_

unsigned openlcb::DccAccyConsumerBase::onOff_
protected

Parsed event state: 1 = activate (C=1), 2 = deactivate (C=0).

Definition at line 205 of file DccAccyConsumer.hxx.


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