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

Helper object for producing an Event Identify Global message. More...

#include <EventIdentifyGlobal.hxx>

Inheritance diagram for openlcb::EventIdentifyGlobal:
StateFlowBase Atomic Executable Notifiable QMember Destructable

Public Member Functions

 EventIdentifyGlobal (Node *node)
 Constructor.
 
 ~EventIdentifyGlobal ()
 Destructor.
 
void arm (bool delete_self=false)
 Arm the EventIdentifyGlobal request.
 
- Public Member Functions inherited from StateFlowBase
void run () override
 Callback from the executor.
 
void notify () override
 Wakeup call arrived.
 
Serviceservice ()
 Return a pointer to the service I am bound to.
 
- Public Member Functions inherited from Executable
void test_deletion ()
 
- Public Member Functions inherited from QMember
void init ()
 Initiailize a QMember, in place of a public placement construction.
 

Private Member Functions

void handle_incoming_event_identify_global (Buffer< GenMessage > *msg)
 Callback upon receiving a Defs::MTI_EVENTS_IDENTIFY_GLOBAL message.
 
Action entry ()
 Entry/reset point into state machine.
 
Action timeout ()
 Will be called on the executor of the timer.
 
Action fill_buffer ()
 Fill in allocated buffer and send Event Identify Global message.
 
- Private Member Functions inherited from Atomic
void lock ()
 
void unlock ()
 

Private Attributes

MessageHandler::GenericHandler eventIdentifyGlobalHandler_
 handler for incoming messages
 
StateFlowTimer timer_
 timer object for handling the timeout
 
Nodenode_
 node to send message from
 
uint8_t aborted_: 1
 true if message received, abort need to send
 
uint8_t deleteSelf_: 1
 delete object upon state flow exit (one-shot)
 

Additional Inherited Members

- Static Public Member Functions inherited from StateFlowBase
template<class T , typename... Args>
static void invoke_subflow_and_ignore_result (FlowInterface< Buffer< T > > *target_flow, Args &&... args)
 Calls a helper flow to perform some actions.
 
- Protected Types inherited from StateFlowBase
typedef Action(StateFlowBase::* Callback) ()
 State Flow callback prototype.
 
- Protected Member Functions inherited from StateFlowBase
 StateFlowBase (Service *service)
 Constructor.
 
 ~StateFlowBase ()
 Destructor.
 
void reset_flow (Callback c)
 Resets the flow to the specified state.
 
bool is_state (Callback c)
 
bool is_terminated ()
 
void start_flow (Callback c)
 Resets the flow to the specified state and starts it.
 
Action again ()
 Call the current state again via call_immediately.
 
Action exit ()
 Terminate current StateFlow activity.
 
Action delete_this ()
 Terminates the flow and deletes *this.
 
Action set_terminated ()
 Sets the flow to terminated state.
 
Action call_immediately (Callback c)
 Imediately call the next state upon return.
 
Action wait ()
 Wait for an asynchronous call.
 
Action wait_and_call (Callback c)
 Wait for resource to become available before proceeding to next state.
 
template<class T >
Action allocate_and_call (FlowInterface< Buffer< T > > *target_flow, Callback c, Pool *pool=nullptr)
 Allocates a buffer from a pool and proceed to the next state when allocation is successful.
 
Action allocate_and_call (Callback c, QAsync *queue)
 Allocates an entry from an asynchronous queue, and transitions to a state once the allocation is complete.
 
template<class T >
Buffer< T > * full_allocation_result (FlowInterface< Buffer< T > > *target_flow)
 Takes the result of the asynchronous allocation without resetting the object.
 
template<class T >
T * full_allocation_result (TypedQAsync< T > *queue)
 Takes the result of the asynchronous allocation without resetting the object.
 
template<class T >
void cast_allocation_result (T **member)
 Takes the result of the asynchronous allocation without resetting the object.
 
template<class T >
Buffer< T > * get_allocation_result (FlowInterface< Buffer< T > > *target_flow)
 Takes the result of the asynchronous allocation.
 
Action yield_and_call (Callback c)
 Place the current flow to the back of the executor, and transition to a new state after we get the CPU again.
 
Action yield ()
 Place the current flow to the back of the executor, and re-try the current state after we get the CPU again.
 
Action sleep_and_call (::Timer *timer, long long timeout_nsec, Callback c)
 Suspends execution of this control flow for a specified time.
 
template<class T , typename... Args>
Action invoke_subflow_and_wait (FlowInterface< Buffer< T > > *target_flow, Callback c, Args &&... args)
 Calls a helper flow to perform some actions.
 
Action read_repeated (StateFlowSelectHelper *helper, int fd, void *buf, size_t size, Callback c, unsigned priority=Selectable::MAX_PRIO)
 Blocks until size bytes are read and then invokes the next state.
 
Action read_single (StateFlowSelectHelper *helper, int fd, void *buf, size_t size, Callback c, unsigned priority=Selectable::MAX_PRIO)
 Attempts to read at most size_t bytes, and blocks the caller until at least one byte is read.
 
Action read_nonblocking (StateFlowSelectHelper *helper, int fd, void *buf, size_t size, Callback c, unsigned priority=Selectable::MAX_PRIO)
 Attempts to read at most size bytes, and then invokes the next state, even if only zero bytes are available right now.
 
Action read_repeated_with_timeout (StateFlowTimedSelectHelper *helper, long long timeout_nsec, int fd, void *buf, size_t size, Callback c, unsigned priority=Selectable::MAX_PRIO)
 Blocks until size bytes are read, or a timeout expires.
 
Action internal_try_read ()
 Implementation state that gets repeatedly called upon every wakeup and tries to make progress on reading.
 
Action write_repeated (StateFlowSelectHelper *helper, int fd, const void *buf, size_t size, Callback c, unsigned priority=Selectable::MAX_PRIO)
 Writes some data into a file descriptor, repeating the operation as necessary until all bytes are written.
 
Action internal_try_write ()
 Implementation state that gets repeatedly called upon every wakeup and tries to make progress on writing.
 
- Protected Member Functions inherited from QMember
 QMember ()
 Constructor.
 
 ~QMember ()
 Destructor.
 
- Protected Attributes inherited from QMember
QMembernext
 pointer to the next member in the queue
 

Detailed Description

Helper object for producing an Event Identify Global message.

Once armed, will produce an Event Identify Global message on the node's interface at a pseudo random time between 1.500 and 2.011 seconds in the future. The randomness comes a hash of the Node ID and aids in reducing the likeliness of multiple nodes of the same design producing the same Event Identify Global message unnecessarily. If another node produces the Event Identify Global first (after arm but before timeout), then we abort the state machine early.

Definition at line 52 of file EventIdentifyGlobal.hxx.

Constructor & Destructor Documentation

◆ EventIdentifyGlobal()

openlcb::EventIdentifyGlobal::EventIdentifyGlobal ( Node node)
inline

Constructor.

Parameters
nodeNode ID associated with this object

Definition at line 57 of file EventIdentifyGlobal.hxx.

◆ ~EventIdentifyGlobal()

openlcb::EventIdentifyGlobal::~EventIdentifyGlobal ( )
inline

Destructor.

Definition at line 72 of file EventIdentifyGlobal.hxx.

Member Function Documentation

◆ arm()

void openlcb::EventIdentifyGlobal::arm ( bool  delete_self = false)
inline

Arm the EventIdentifyGlobal request.

Multi-thread safe.

Parameters
delete_selftrue if the object should delete itself on next state flow completion (one-shot).

Definition at line 82 of file EventIdentifyGlobal.hxx.

◆ entry()

Action openlcb::EventIdentifyGlobal::entry ( )
inlineprivate

Entry/reset point into state machine.

Definition at line 104 of file EventIdentifyGlobal.hxx.

◆ fill_buffer()

Action openlcb::EventIdentifyGlobal::fill_buffer ( )
inlineprivate

Fill in allocated buffer and send Event Identify Global message.

Definition at line 143 of file EventIdentifyGlobal.hxx.

◆ handle_incoming_event_identify_global()

void openlcb::EventIdentifyGlobal::handle_incoming_event_identify_global ( Buffer< GenMessage > *  msg)
inlineprivate

Callback upon receiving a Defs::MTI_EVENTS_IDENTIFY_GLOBAL message.

Parameters
msgunused, need to unref to prevent memory leak

Definition at line 96 of file EventIdentifyGlobal.hxx.

◆ timeout()

Action openlcb::EventIdentifyGlobal::timeout ( )
inlineprivate

Will be called on the executor of the timer.

Definition at line 117 of file EventIdentifyGlobal.hxx.

Member Data Documentation

◆ aborted_

uint8_t openlcb::EventIdentifyGlobal::aborted_
private

true if message received, abort need to send

Definition at line 158 of file EventIdentifyGlobal.hxx.

◆ deleteSelf_

uint8_t openlcb::EventIdentifyGlobal::deleteSelf_
private

delete object upon state flow exit (one-shot)

Definition at line 159 of file EventIdentifyGlobal.hxx.

◆ eventIdentifyGlobalHandler_

MessageHandler::GenericHandler openlcb::EventIdentifyGlobal::eventIdentifyGlobalHandler_
private

handler for incoming messages

Definition at line 155 of file EventIdentifyGlobal.hxx.

◆ node_

Node* openlcb::EventIdentifyGlobal::node_
private

node to send message from

Definition at line 157 of file EventIdentifyGlobal.hxx.

◆ timer_

StateFlowTimer openlcb::EventIdentifyGlobal::timer_
private

timer object for handling the timeout

Definition at line 156 of file EventIdentifyGlobal.hxx.


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