37#include "openlcb/NonAuthoritativeEventProducer.hxx"
54 WriteHelper::global(),
82 bool value = (
event->event % 2) == (
eventBase_ % 2);
119 if (event->
state == EventState::VALID)
123 else if (event->
state == EventState::INVALID)
195 event->event_write_helper<1>()->WriteAsync(
node_,
240 event->event_write_helper<1>()->WriteAsync(
node_,
271 writer->
WriteAsync(
node_, Defs::MTI_EVENT_REPORT, WriteHelper::global(),
A BarrierNotifiable allows to create a number of child Notifiable and wait for all of them to finish.
void notify() override
Implementation of the barrier semantics.
void set(unsigned bit, bool new_value, WriteHelper *writer, BarrierNotifiable *done)
Requests the event associated with the current value of the bit to be produced (unconditionally).
unsigned size_
number of bits stored
void handle_identify_global(const EventRegistryEntry &entry, EventReport *event, BarrierNotifiable *done) override
Handle an incoming identify global or addressed message.
uint64_t eventBaseOn_
base event ID for "on" range
void handle_event_report(const EventRegistryEntry &entry, EventReport *event, BarrierNotifiable *done) override
Handle an incoming event.
void handle_consumer_identified(const EventRegistryEntry &entry, EventReport *event, BarrierNotifiable *done) override
Handle an incoming consumer identified message.
uint64_t eventBaseOff_
base event ID for "off" range
void handle_identify_producer(const EventRegistryEntry &entry, EventReport *event, BarrierNotifiable *done) override
Handle an incoming identify producer message.
std::function< void(unsigned, bool)> stateCallback_
Callback method that will be invoked when a consumer identified message is received with a known stat...
uint64_t eventBase_
base event ID of the full range
Node * node_
Node ID that this producer is attached to.
void send_query_consumer(unsigned bit, WriteHelper *writer, BarrierNotifiable *done)
Queries consumer and acquires the current state of the bit.
@ EVENT_BASE_ON
one unified range starting at eventBase_
@ EVENT_BASE_OFF
on range starting at eventBaseOn_
Structure used in registering event handlers.
uint32_t user_arg
Opaque user argument.
A statically allocated buffer for sending one message to the OpenLCB bus.
void WriteAsync(Node *node, Defs::MTI mti, NodeHandle dst, const payload_type &buffer, Notifiable *done)
Originates an NMRAnet message from a particular node.
#define HASSERT(x)
Checks that the value of expression x is true, else terminates the current process.
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...
Payload eventid_to_buffer(uint64_t eventid)
Converts an Event ID to a Payload suitable to be sent as an event report.
@ MTI_PRODUCER_IDENTIFIED_RANGE
producer broadcast about a range of producers
@ MTI_CONSUMER_IDENTIFY
query about consumers
@ MTI_PRODUCER_IDENTIFIED_UNKNOWN
producer broadcast, validity unknown
Shared notification structure that is assembled for each incoming event-related message,...
EventState state
For producer/consumer identified messages, specifies the state of the producer/consumer as the sender...
EventId event
The event ID from the incoming message.
Node * dst_node
nullptr for global messages; points to the specific virtual node for addressed events identify messag...