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

Base class for single-bit producer and consumer objects. More...

#include <EventHandlerTemplates.hxx>

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

Public Member Functions

 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_event_report (const EventRegistryEntry &registry_entry, EventReport *event, BarrierNotifiable *done)=0
 Called on incoming EventReport messages.
 
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_global (const EventRegistryEntry &registry_entry, EventReport *event, BarrierNotifiable *done)=0
 Called on the need of sending out identification messages.
 
virtual void handle_identify_consumer (const EventRegistryEntry &registry_entry, EventReport *event, BarrierNotifiable *done)=0
 Called on another node sending IdentifyConsumer.
 
virtual void handle_identify_producer (const EventRegistryEntry &registry_entry, EventReport *event, BarrierNotifiable *done)=0
 Called on another node sending IdentifyProducer.
 

Protected Member Functions

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

BitEventInterfacebit_
 

Private Types

enum  { EVENT_ON = 1 , EVENT_OFF = 2 , BOTH_ON_IS_ZERO = 4 , BOTH_OFF_IS_ZERO = 8 }
 Bits defined in the user_data value for the registrations in this event handler. More...
 

Private Member Functions

 DISALLOW_COPY_AND_ASSIGN (BitEventHandler)
 

Additional Inherited Members

- Public Types inherited from openlcb::EventHandler
using EventReport = openlcb::EventReport
 
using EventRegistryEntry = openlcb::EventRegistryEntry
 
using EventId = openlcb::EventId
 

Detailed Description

Base class for single-bit producer and consumer objects.

Contains helper functions for operations shared by event handlers.

Definition at line 531 of file EventHandlerTemplates.hxx.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private

Bits defined in the user_data value for the registrations in this event handler.

Enumerator
EVENT_ON 

This registration is for a single event_on.

EVENT_OFF 

This registration is for a single event_off.

BOTH_ON_IS_ZERO 

This registration is for two events, and the lower numbered is the event on.

BOTH_OFF_IS_ZERO 

This registration is for two events, and the lower numbered is the event off.

Definition at line 583 of file EventHandlerTemplates.hxx.

Constructor & Destructor Documentation

◆ BitEventHandler()

openlcb::BitEventHandler::BitEventHandler ( BitEventInterface bit)

Definition at line 542 of file EventHandlerTemplates.cxx.

Member Function Documentation

◆ HandlePCIdentify()

void openlcb::BitEventHandler::HandlePCIdentify ( Defs::MTI  mti_valid,
EventReport event,
BarrierNotifiable done 
)
protected

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.

Uses event_write_helper<1>. Notifies done.

Definition at line 619 of file EventHandlerTemplates.cxx.

◆ register_handler()

void openlcb::BitEventHandler::register_handler ( uint64_t  event_on,
uint64_t  event_off 
)
protected

Registers this event handler with the global event manager.

Call this from the constructor of the derived class.

Definition at line 546 of file EventHandlerTemplates.cxx.

◆ SendConsumerIdentified()

void openlcb::BitEventHandler::SendConsumerIdentified ( EventReport event,
BarrierNotifiable done 
)
protected

Sends off two packets using event_write_helper{3,4} of ConsumerIdentified for handling a global identify events message.

Allocates children from barrier done (but does not notify it).

@TODO: for consistency of API this function should be changed to notify the barrier. The caller should always use new_child.

Definition at line 589 of file EventHandlerTemplates.cxx.

◆ SendEventReport()

void openlcb::BitEventHandler::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.

Parameters
writeris the output flow to be used.
doneis the notification callback. If it is NULL, the writer will be invoked inline and potentially block the calling thread.

Definition at line 603 of file EventHandlerTemplates.cxx.

◆ SendProducerIdentified()

void openlcb::BitEventHandler::SendProducerIdentified ( EventReport event,
BarrierNotifiable done 
)
protected

Sends off two packets using event_write_helper{1,2} of ProducerIdentified for handling a global identify events message.

Allocates children from barrier done (but does not notify it).

@TODO: for consistency of API this function should be changed to notify the barrier. The caller should always use new_child.

Definition at line 575 of file EventHandlerTemplates.cxx.

◆ unregister_handler()

void openlcb::BitEventHandler::unregister_handler ( )
protected

Removes this event handler from the global event manager.

Call this from the destructor of the derived class.

Definition at line 570 of file EventHandlerTemplates.cxx.

Member Data Documentation

◆ bit_

BitEventInterface* openlcb::BitEventHandler::bit_
protected

Definition at line 578 of file EventHandlerTemplates.hxx.


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