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

State flow to request PIP information from a remote node on the OpenLCB network. More...

#include <PIPClient.hxx>

Inheritance diagram for openlcb::PIPClient:
StateFlowBase Executable Notifiable QMember Destructable

Classes

class  PIPResponseHandler
 Message handler for incoming PIP responses. More...
 

Public Types

enum  ResultCodes { OPERATION_SUCCESS = 0x10000 , OPERATION_PENDING = 0x20000 , TIMEOUT = 0x80000 , IDLE = 0xFFFF0000 }
 

Public Member Functions

 PIPClient (If *iface)
 
void request (NodeHandle dst, Node *src, Notifiable *done)
 Sends a PIP request to the specified node.
 
uint32_t error_code ()
 
uint64_t response ()
 Returns the response of the last request out, or unspecified if the last request has not succeeded.
 
- 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 Types

enum  {
  MTI_1a = Defs::MTI_TERMINATE_DUE_TO_ERROR , MTI_1b = Defs::MTI_OPTIONAL_INTERACTION_REJECTED , MASK_1 = ~(MTI_1a ^ MTI_1b) , MTI_1 = MTI_1a ,
  MTI_2 = Defs::MTI_PROTOCOL_SUPPORT_REPLY , MASK_2 = Defs::MTI_EXACT
}
 

Private Member Functions

Action request_buffer ()
 
Action write_request ()
 
void handle_response (Buffer< GenMessage > *message)
 
Action response_came ()
 
Ififace ()
 

Private Attributes

StateFlowTimer timer_ {this}
 
Nodesrc_
 
Notifiabledone_
 
NodeHandle dst_
 
uint64_t pipResponse_ {0}
 
uint32_t errorCode_ {IDLE}
 
PIPResponseHandler responseHandler_ {this}
 

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

State flow to request PIP information from a remote node on the OpenLCB network.

Usage:

Create a global or local instance of this flow. Call the request() function with the arguments, supplying as notifiable the calling flow or a sync notifiable for blocking operation on a thread. Wait for the notification. Check that error_code() == OPEATION_SUCCESS, then access the returned protocol bitmask via the response() accessor.

Definition at line 61 of file PIPClient.hxx.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private

Definition at line 114 of file PIPClient.hxx.

◆ ResultCodes

enum openlcb::PIPClient::ResultCodes

Definition at line 102 of file PIPClient.hxx.

Constructor & Destructor Documentation

◆ PIPClient()

openlcb::PIPClient::PIPClient ( If iface)
inline

Definition at line 64 of file PIPClient.hxx.

Member Function Documentation

◆ error_code()

uint32_t openlcb::PIPClient::error_code ( )
inline
Returns
the error code of the last request, or one of the internal error codes from PIPClient::ResultCodes

Definition at line 90 of file PIPClient.hxx.

◆ handle_response()

void openlcb::PIPClient::handle_response ( Buffer< GenMessage > *  message)
inlineprivate

Definition at line 150 of file PIPClient.hxx.

◆ iface()

If * openlcb::PIPClient::iface ( )
inlineprivate

Definition at line 221 of file PIPClient.hxx.

◆ request()

void openlcb::PIPClient::request ( NodeHandle  dst,
Node src,
Notifiable done 
)
inline

Sends a PIP request to the specified node.

The current

Parameters
dstis the target node to query
srcis the source node from which to send query
donewill be notified if the request succeeds or fails or timeouts)

Definition at line 78 of file PIPClient.hxx.

◆ request_buffer()

Action openlcb::PIPClient::request_buffer ( )
inlineprivate

Definition at line 125 of file PIPClient.hxx.

◆ response()

uint64_t openlcb::PIPClient::response ( )
inline

Returns the response of the last request out, or unspecified if the last request has not succeeded.

Definition at line 97 of file PIPClient.hxx.

◆ response_came()

Action openlcb::PIPClient::response_came ( )
inlineprivate

Definition at line 190 of file PIPClient.hxx.

◆ write_request()

Action openlcb::PIPClient::write_request ( )
inlineprivate

Definition at line 131 of file PIPClient.hxx.

Member Data Documentation

◆ done_

Notifiable* openlcb::PIPClient::done_
private

Definition at line 228 of file PIPClient.hxx.

◆ dst_

NodeHandle openlcb::PIPClient::dst_
private

Definition at line 229 of file PIPClient.hxx.

◆ errorCode_

uint32_t openlcb::PIPClient::errorCode_ {IDLE}
private

Definition at line 231 of file PIPClient.hxx.

◆ pipResponse_

uint64_t openlcb::PIPClient::pipResponse_ {0}
private

Definition at line 230 of file PIPClient.hxx.

◆ responseHandler_

PIPResponseHandler openlcb::PIPClient::responseHandler_ {this}
private

Definition at line 232 of file PIPClient.hxx.

◆ src_

Node* openlcb::PIPClient::src_
private

Definition at line 227 of file PIPClient.hxx.

◆ timer_

StateFlowTimer openlcb::PIPClient::timer_ {this}
private

Definition at line 226 of file PIPClient.hxx.


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