36#ifndef _OPENLCB_DCCACCYCONSUMER_HXX_
37#define _OPENLCB_DCCACCYCONSUMER_HXX_
78 if (event->dst_node && event->dst_node !=
node_)
82 if (registry_entry.event ==
85 event->event_write_helper<1>()->WriteAsync(
node_,
92 if (registry_entry.event ==
95 event->event_write_helper<2>()->WriteAsync(
node_,
141 s = EventState::VALID;
146 s = EventState::INVALID;
156 s = EventState::UNKNOWN;
159 event->event_write_helper<1>()->WriteAsync(
node_, mti,
255 pkt->
data()->packet_header.rept_count = 3;
298 if (event->dst_node && event->dst_node !=
node_)
302 event->event_write_helper<1>()->WriteAsync(
node_,
328 event->event_write_helper<1>()->WriteAsync(
node_,
398 pkt->
data()->packet_header.rept_count = 3;
DynamicPool * mainBufferPool
main buffer pool instance
This class sends a notification in its destructor.
A BarrierNotifiable allows to create a number of child Notifiable and wait for all of them to finish.
BarrierNotifiable * new_child()
Call this for each child task.
Base class for all QMember types that hold data in an expandable format.
T * data()
get a pointer to the start of the data.
virtual void send(MessageType *message, unsigned priority=UINT_MAX)=0
Entry point to the flow.
void alloc(Buffer< BufferType > **result, Executable *flow=NULL)
Get a free item out of the pool.
static EventRegistry * instance()
Base (generic protocol) implementation of a DCC accessory consumer.
unsigned onOff_
Parsed event state: 1 = activate (C=1), 2 = deactivate (C=0).
virtual void send_accy_command()=0
Send the actual accessory command.
uint32_t isStateKnown_[64]
each bit determines whether we've sent a command to that accessory address yet or not.
unsigned eventMask_
Parsed event state: bit index (0..31) in the uint32 in the state_ array entry pointed to by eventOfs_...
unsigned eventOfs_
Parsed event state: offset in the state_ array.
DccAccyConsumerBase(Node *node)
Constructs a listener for DCC accessory control.
unsigned dccAddress_
Parsed event state: dcc address (0..4095) without inverting or encoding.
unsigned normalReverse_
Parsed event state: 1 = normal (D0=1), 0 = reversed (D0=0).
void handle_identify_consumer(const EventRegistryEntry &entry, EventReport *event, BarrierNotifiable *done) override
Called on another node sending IdentifyConsumer.
uint32_t lastSetState_[64]
each bit determines what the last command sent to the accessory address was.
bool parse_event(EventId event)
Parses an event into an openlcb accessory offset.
void handle_event_report(const EventRegistryEntry ®istry_entry, EventReport *event, BarrierNotifiable *done) override
Called on incoming EventReport messages.
Node * node_
OpenLCB node to export the consumer on.
~DccAccyConsumerBase()
Destructor.
void handle_identify_global(const EventRegistryEntry ®istry_entry, EventReport *event, BarrierNotifiable *done) OVERRIDE
Called on the need of sending out identification messages.
Specialized (DCC protocol) implementation of a DCC accessory consumer.
~DccAccyConsumer()
Destructor.
dcc::TrackIf * track_
Track to send DCC packets to.
DccAccyConsumer(Node *node, dcc::TrackIf *track)
Constructs a listener for DCC accessory control.
void send_accy_command() override
Send the actual accessory command.
Base (generic protocol) implementation of the DCC extended accessory consumer.
static constexpr unsigned NUM_ADDRESS
How may addresses are there for extended accessories.
void handle_event_report(const EventRegistryEntry ®istry_entry, EventReport *event, BarrierNotifiable *done) override
Called on incoming EventReport messages.
static constexpr unsigned NUM_ASPECT
How may aspects are supported per accessory.
void handle_identify_global(const EventRegistryEntry ®istry_entry, EventReport *event, BarrierNotifiable *done) OVERRIDE
Called on the need of sending out identification messages.
~DccExtAccyConsumerBase()
Destructor.
void handle_identify_consumer(const EventRegistryEntry &entry, EventReport *event, BarrierNotifiable *done) override
Called on another node sending IdentifyConsumer.
static constexpr unsigned NUM_EVENT
Total number of events we are listening for.
unsigned aspect_
Parsed event state: the aspect commanded.
Node * node_
OpenLCB node to export the consumer on.
unsigned dccAddress_
Parsed event state: dcc address (0..2047) without inverting or encoding.
DccExtAccyConsumerBase(Node *node)
Constructs a listener for DCC extended accessory control.
virtual void send_accy_command()=0
Send the actual accessory command.
bool parse_event(EventId event)
Parses an event into an openlcb accessory offset.
Specialized (DCC protocol) implementation of a DCC extended accessory consumer.
DccExtAccyConsumer(Node *node, dcc::TrackIf *track)
Constructs a listener for DCC accessory control.
~DccExtAccyConsumer()
Destructor.
dcc::TrackIf * track_
Track to send DCC packets to.
void send_accy_command() override
Send the actual accessory command.
Structure used in registering event handlers.
Base class for NMRAnet nodes conforming to the asynchronous interface.
SimpleEventHandler ignores all non-essential callbacks.
#define OVERRIDE
Function attribute for virtual functions declaring that this funciton is overriding a funciton that s...
uint64_t EncodeRange(uint64_t begin, unsigned size)
Creates a single encoded event range from the beginning of the range and the number fo events to cove...
EventState invert_event_state(EventState state)
Returns the inverted event state, switching valid and invalid, but not changing unknown and reserved.
EventState
Allowed states of producers and consumers.
Payload eventid_to_buffer(uint64_t eventid)
Converts an Event ID to a Payload suitable to be sent as an event report.
MTI
Known Message type indicators.
@ MTI_CONSUMER_IDENTIFIED_UNKNOWN
consumer broadcast, validity unknown
@ MTI_CONSUMER_IDENTIFIED_VALID
consumer broadcast, valid state
@ MTI_CONSUMER_IDENTIFIED_RANGE
consumer broadcast about a range of consumers
Shared notification structure that is assembled for each incoming event-related message,...
EventId event
The event ID from the incoming message.
static constexpr uint64_t INACTIVATE_BASIC_DCC_ACCESSORY_EVENT_BASE
Base address of DCC accessory decoder well-known event range (inactive)
static constexpr uint64_t EXT_DCC_ACCESSORY_EVENT_BASE
Base address of DCC extended accessory decoder well-known event range.
static constexpr uint64_t ACTIVATE_BASIC_DCC_ACCESSORY_EVENT_BASE
Base address of DCC accessory decoder well-known event range (active)