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

Producer-Consumer event handler for a sequence of bits represented by a dense block of consecutive event IDs. More...

#include <EventHandlerTemplates.hxx>

Inheritance diagram for openlcb::BitRangeEventPC:
openlcb::SimpleEventHandler openlcb::EventHandler openlcb::BitRangeEventP

Public Member Functions

 BitRangeEventPC (Node *node, uint64_t event_base, uint32_t *backing_store, unsigned size)
 Creates a new bit range listener.
 
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).
 
bool Get (unsigned bit) const
 
void SendIdentified (WriteHelper *writer, BarrierNotifiable *done)
 Sends out a ProducerRangeIdentified.
 
void handle_event_report (const EventRegistryEntry &entry, EventReport *event, BarrierNotifiable *done) override
 Called on incoming EventReport messages.
 
void handle_identify_producer (const EventRegistryEntry &entry, EventReport *event, BarrierNotifiable *done) override
 Called on another node sending IdentifyProducer.
 
void handle_identify_consumer (const EventRegistryEntry &entry, EventReport *event, BarrierNotifiable *done) override
 Called on another node sending IdentifyConsumer.
 
void handle_identify_global (const EventRegistryEntry &entry, EventReport *event, BarrierNotifiable *done) override
 Called on the need of sending out identification messages.
 
unsigned size ()
 
- 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.
 

Protected Member Functions

void HandleIdentifyBase (Defs::MTI mti_valid, EventReport *event, BarrierNotifiable *done)
 
void GetBitAndMask (unsigned bit, uint32_t **data, uint32_t *mask) const
 

Protected Attributes

uint64_t event_base_
 
Nodenode_
 
uint32_t * data_
 
unsigned size_
 

Additional Inherited Members

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

Detailed Description

Producer-Consumer event handler for a sequence of bits represented by a dense block of consecutive event IDs.

Definition at line 735 of file EventHandlerTemplates.hxx.

Constructor & Destructor Documentation

◆ BitRangeEventPC()

openlcb::BitRangeEventPC::BitRangeEventPC ( Node node,
uint64_t  event_base,
uint32_t *  backing_store,
unsigned  size 
)

Creates a new bit range listener.

backing store points to memory of at least size bits (round up to multiple of 32). This class will advertise producing and consuming size * 2 events contiguous from event_base. event_base will turn bit 0 on, event_base + 1 will turn bit 0 off, event_base + 2 will turn bit 1 on, event_base + 3 will turn bit 1 off, etc.

Definition at line 65 of file EventHandlerTemplates.cxx.

◆ ~BitRangeEventPC()

openlcb::BitRangeEventPC::~BitRangeEventPC ( )
virtual

Definition at line 77 of file EventHandlerTemplates.cxx.

Member Function Documentation

◆ Get()

bool openlcb::BitRangeEventPC::Get ( unsigned  bit) const
Returns
the value of a given bit. 0 <= bit < size_.

Definition at line 92 of file EventHandlerTemplates.cxx.

◆ GetBitAndMask()

void openlcb::BitRangeEventPC::GetBitAndMask ( unsigned  bit,
uint32_t **  data,
uint32_t *  mask 
) const
protected

Definition at line 82 of file EventHandlerTemplates.cxx.

◆ handle_event_report()

void openlcb::BitRangeEventPC::handle_event_report ( const EventRegistryEntry registry_entry,
EventReport event,
BarrierNotifiable done 
)
overridevirtual

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

◆ handle_identify_consumer()

void openlcb::BitRangeEventPC::handle_identify_consumer ( const EventRegistryEntry registry_entry,
EventReport event,
BarrierNotifiable done 
)
overridevirtual

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

◆ handle_identify_global()

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

Implements openlcb::EventHandler.

Definition at line 263 of file EventHandlerTemplates.cxx.

◆ handle_identify_producer()

void openlcb::BitRangeEventPC::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 204 of file EventHandlerTemplates.cxx.

◆ HandleIdentifyBase()

void openlcb::BitRangeEventPC::HandleIdentifyBase ( Defs::MTI  mti_valid,
EventReport event,
BarrierNotifiable done 
)
protected

Definition at line 215 of file EventHandlerTemplates.cxx.

◆ SendIdentified()

void openlcb::BitRangeEventPC::SendIdentified ( WriteHelper writer,
BarrierNotifiable done 
)

Sends out a ProducerRangeIdentified.

Definition at line 280 of file EventHandlerTemplates.cxx.

◆ Set()

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

Parameters
nodespecifies the source node from which to produce the event.
bitis the offset of the bit to set (0 <= bit < size)
new_valueis the new value of the bit
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 103 of file EventHandlerTemplates.cxx.

◆ size()

unsigned openlcb::BitRangeEventPC::size ( )
inline
Returns
the number of bits maintained.

Definition at line 784 of file EventHandlerTemplates.hxx.

Member Data Documentation

◆ data_

uint32_t* openlcb::BitRangeEventPC::data_
protected

Definition at line 793 of file EventHandlerTemplates.hxx.

◆ event_base_

uint64_t openlcb::BitRangeEventPC::event_base_
protected

Definition at line 791 of file EventHandlerTemplates.hxx.

◆ node_

Node* openlcb::BitRangeEventPC::node_
protected

Definition at line 792 of file EventHandlerTemplates.hxx.

◆ size_

unsigned openlcb::BitRangeEventPC::size_
protected

Definition at line 794 of file EventHandlerTemplates.hxx.


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