Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
openlcb::BitEventPC Class Reference

Producer-Consumer event handler for a single bit represented by two event IDs. More...

#include <EventHandlerTemplates.hxx>

Inheritance diagram for openlcb::BitEventPC:
openlcb::BitEventConsumer openlcb::BitEventHandler openlcb::SimpleEventHandler openlcb::EventHandler

Public Member Functions

 BitEventPC (BitEventInterface *bit)
 
void SendQueryProducer (WriteHelper *writer, BarrierNotifiable *done)
 Queries producers and acquires the current state of the bit.
 
void SendQueryConsumer (WriteHelper *writer, BarrierNotifiable *done)
 Queries consumer and acquires the current state of the bit.
 
void handle_identify_producer (const EventRegistryEntry &entry, EventReport *event, BarrierNotifiable *done) override
 Called on another node sending IdentifyProducer.
 
void handle_identify_global (const EventRegistryEntry &entry, EventReport *event, BarrierNotifiable *done) override
 Called on the need of sending out identification messages.
 
void handle_consumer_identified (const EventRegistryEntry &entry, EventReport *event, BarrierNotifiable *done) override
 Called on another node sending ConsumerIdentified for this event.
 
- Public Member Functions inherited from openlcb::BitEventConsumer
 BitEventConsumer (BitEventInterface *bit)
 
void SendQuery (WriteHelper *writer, BarrierNotifiable *done)
 Queries producers and acquires the current state of the bit.
 
void handle_event_report (const EventRegistryEntry &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.
 
void handle_producer_identified (const EventRegistryEntry &entry, EventReport *event, BarrierNotifiable *done) override
 Called on another node sending ProducerIdentified for this event.
 
- Public Member Functions inherited from openlcb::BitEventHandler
 BitEventHandler (BitEventInterface *bit)
 
void SendEventReport (WriteHelper *writer, Notifiable *done)
 Requests the event associated with the current value of the bit to be produced (unconditionally): sends an event report packet ot the bus.
 
- 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_range_identified (const EventRegistryEntry &registry_entry, EventReport *event, BarrierNotifiable *done)
 Called on another node sending ConsumerRangeIdentified.
 
virtual void handle_producer_range_identified (const EventRegistryEntry &registry_entry, EventReport *event, BarrierNotifiable *done)
 Called on another node sending ProducerRangeIdentified for this event.
 

Additional Inherited Members

- Public Types inherited from openlcb::EventHandler
using EventReport = openlcb::EventReport
 
using EventRegistryEntry = openlcb::EventRegistryEntry
 
using EventId = openlcb::EventId
 
- Protected Member Functions inherited from openlcb::BitEventHandler
void register_handler (uint64_t event_on, uint64_t event_off)
 Registers this event handler with the global event manager.
 
void unregister_handler ()
 Removes this event handler from the global event manager.
 
void SendProducerIdentified (EventReport *event, BarrierNotifiable *done)
 Sends off two packets using event_write_helper{1,2} of ProducerIdentified for handling a global identify events message.
 
void SendConsumerIdentified (EventReport *event, BarrierNotifiable *done)
 Sends off two packets using event_write_helper{3,4} of ConsumerIdentified for handling a global identify events message.
 
void HandlePCIdentify (Defs::MTI mti_valid, EventReport *event, BarrierNotifiable *done)
 Checks if the event in the report is something we are interested in, and if so, sends off a {Producer|Consumer}Identified{Valid|Invalid} message depending on the current state of the hardware bit.
 
- Protected Attributes inherited from openlcb::BitEventHandler
BitEventInterfacebit_
 

Detailed Description

Producer-Consumer event handler for a single bit represented by two event IDs.

This event handler exports two events as producer and consumer from the current node. If an event report comes in, the internal bit will be flipped and the necessary setter method of the BitEventInterface will be called.

When the current state of the bit changes, the application must call SendEventReport on this object, which will produce the necessary event message to the bus.

Definition at line 704 of file EventHandlerTemplates.hxx.

Constructor & Destructor Documentation

◆ BitEventPC()

openlcb::BitEventPC::BitEventPC ( BitEventInterface bit)
inline
Parameters
bitrepresents the event bits and the getter/setter of the hardware state.

Definition at line 709 of file EventHandlerTemplates.hxx.

Member Function Documentation

◆ handle_consumer_identified()

void openlcb::BitEventPC::handle_consumer_identified ( const EventRegistryEntry registry_entry,
EventReport event,
BarrierNotifiable done 
)
overridevirtual

Called on another node sending ConsumerIdentified for this event.

Parameters
eventstores information about the incoming message. Filled: event_id, mask=1, src_node, state.
registry_entrygives the registry entry for which the current handler is being called.
donemust be notified when the processing is done.

Reimplemented from openlcb::EventHandler.

Definition at line 767 of file EventHandlerTemplates.cxx.

◆ handle_identify_global()

void openlcb::BitEventPC::handle_identify_global ( const EventRegistryEntry registry_entry,
EventReport event,
BarrierNotifiable done 
)
overridevirtual

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.

Reimplemented from openlcb::BitEventConsumer.

Definition at line 755 of file EventHandlerTemplates.cxx.

◆ handle_identify_producer()

void openlcb::BitEventPC::handle_identify_producer ( const EventRegistryEntry registry_entry,
EventReport event,
BarrierNotifiable done 
)
overridevirtual

Called on another node sending IdentifyProducer.

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 725 of file EventHandlerTemplates.cxx.

◆ SendQueryConsumer()

void openlcb::BitEventPC::SendQueryConsumer ( WriteHelper writer,
BarrierNotifiable done 
)

Queries consumer and acquires the current state of the bit.

Definition at line 748 of file EventHandlerTemplates.cxx.

◆ SendQueryProducer()

void openlcb::BitEventPC::SendQueryProducer ( WriteHelper writer,
BarrierNotifiable done 
)
inline

Queries producers and acquires the current state of the bit.

Definition at line 714 of file EventHandlerTemplates.hxx.


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