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

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

#include <DccAccyConsumer.hxx>

Inheritance diagram for openlcb::DccExtAccyConsumerBase:
openlcb::SimpleEventHandler openlcb::EventHandler openlcb::DccExtAccyConsumer

Protected Member Functions

 DccExtAccyConsumerBase (Node *node)
 Constructs a listener for DCC extended accessory control.
 
 ~DccExtAccyConsumerBase ()
 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 dccAddress_: 11
 Parsed event state: dcc address (0..2047) without inverting or encoding.
 
unsigned aspect_: 8
 Parsed event state: the aspect commanded.
 
Nodenode_
 OpenLCB node to export the consumer on.
 

Static Protected Attributes

static constexpr unsigned NUM_ADDRESS = 2048
 How may addresses are there for extended accessories.
 
static constexpr unsigned NUM_ASPECT = 256
 How may aspects are supported per accessory.
 
static constexpr unsigned NUM_EVENT = NUM_ASPECT * NUM_ADDRESS
 Total number of events we are listening for.
 

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 the DCC extended accessory consumer.

Unlike the basic accessory version, this one does not remember the last set state.

Definition at line 266 of file DccAccyConsumer.hxx.

Constructor & Destructor Documentation

◆ DccExtAccyConsumerBase()

openlcb::DccExtAccyConsumerBase::DccExtAccyConsumerBase ( Node node)
inlineprotected

Constructs a listener for DCC extended accessory control.

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

Definition at line 279 of file DccAccyConsumer.hxx.

◆ ~DccExtAccyConsumerBase()

openlcb::DccExtAccyConsumerBase::~DccExtAccyConsumerBase ( )
inlineprotected

Destructor.

Definition at line 289 of file DccAccyConsumer.hxx.

Member Function Documentation

◆ handle_event_report()

void openlcb::DccExtAccyConsumerBase::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 309 of file DccAccyConsumer.hxx.

◆ handle_identify_consumer()

void openlcb::DccExtAccyConsumerBase::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 320 of file DccAccyConsumer.hxx.

◆ handle_identify_global()

void openlcb::DccExtAccyConsumerBase::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 294 of file DccAccyConsumer.hxx.

◆ parse_event()

bool openlcb::DccExtAccyConsumerBase::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 344 of file DccAccyConsumer.hxx.

◆ send_accy_command()

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

Send the actual accessory command.

Implemented in openlcb::DccExtAccyConsumer.

Member Data Documentation

◆ aspect_

unsigned openlcb::DccExtAccyConsumerBase::aspect_
protected

Parsed event state: the aspect commanded.

Definition at line 364 of file DccAccyConsumer.hxx.

◆ dccAddress_

unsigned openlcb::DccExtAccyConsumerBase::dccAddress_
protected

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

Definition at line 362 of file DccAccyConsumer.hxx.

◆ node_

Node* openlcb::DccExtAccyConsumerBase::node_
protected

OpenLCB node to export the consumer on.

Definition at line 367 of file DccAccyConsumer.hxx.

◆ NUM_ADDRESS

constexpr unsigned openlcb::DccExtAccyConsumerBase::NUM_ADDRESS = 2048
staticconstexprprotected

How may addresses are there for extended accessories.

Definition at line 270 of file DccAccyConsumer.hxx.

◆ NUM_ASPECT

constexpr unsigned openlcb::DccExtAccyConsumerBase::NUM_ASPECT = 256
staticconstexprprotected

How may aspects are supported per accessory.

Definition at line 272 of file DccAccyConsumer.hxx.

◆ NUM_EVENT

constexpr unsigned openlcb::DccExtAccyConsumerBase::NUM_EVENT = NUM_ASPECT * NUM_ADDRESS
staticconstexprprotected

Total number of events we are listening for.

Definition at line 274 of file DccAccyConsumer.hxx.


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