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

This flow renders outgoing OpenLCB messages to their TCP stream representation. More...

#include <IfTcpImpl.hxx>

Inheritance diagram for openlcb::TcpSendFlow:
StateFlow< Buffer< GenMessage >, QList< 4 > > TypedStateFlow< MessageType, Base > FlowInterface< MessageType >

Public Member Functions

 TcpSendFlow (If *service, NodeID gateway_node_id, HubPortInterface *send_target, HubPortInterface *skip_member, SequenceNumberGenerator *sequence)
 Constructor.
 
NodeID get_gateway_node_id ()
 
- Public Member Functions inherited from StateFlow< Buffer< GenMessage >, QList< 4 > >
 StateFlow (Service *service)
 Constructor.
 
- Public Member Functions inherited from TypedStateFlow< MessageType, Base >
 TypedStateFlow (Service *service)
 Constructor.
 
virtual ~TypedStateFlow ()
 Destructor.
 
void send (MessageType *msg, unsigned priority=UINT_MAX) OVERRIDE
 Sends a message to the state flow for processing.
 
- Public Member Functions inherited from FlowInterface< MessageType >
virtual Poolpool ()
 
virtual MessageType * type_helper ()
 This function is never user in the code, but GDB can use it to infer the correct message types.
 
MessageType * alloc ()
 Synchronously allocates a message buffer from the pool of this flow.
 
void alloc_async (Executable *target)
 Asynchronously allocates a message buffer from the pool of this flow.
 

Private Member Functions

Action entry () override
 Handler where dequeueing of messages to be sent starts.
 
Action render_src_message ()
 Callback state after allocation succeeded.
 
GenMessagenmsg ()
 
Ififace ()
 

Private Attributes

HubPortInterfacesendTarget_
 Where to send the rendered messages to.
 
HubPortInterfaceskipMember_
 This value will be populated to the skipMember_ field.
 
NodeID gatewayId_
 Populated into the source gateway field of the outgoing messages.
 
SequenceNumberGeneratorsequenceNumberGenerator_
 Responsible for generating the sequence numbers of the outgoing messages.
 

Additional Inherited Members

- Public Types inherited from TypedStateFlow< MessageType, Base >
typedef Base::Action Action
 Allows using Action without having StateFlowBase:: prefix in front of it.
 
- Public Types inherited from FlowInterface< MessageType >
typedef MessageType message_type
 Stores the message template type for external reference.
 
- Static Public Member Functions inherited from FlowInterface< MessageType >
static MessageType * cast_alloc (QMember *entry)
 Down casts and initializes an asynchronous allocation result to the appropriate flow's buffer type.
 
- Protected Member Functions inherited from TypedStateFlow< MessageType, Base >
void release () OVERRIDE
 Unrefs the current buffer.
 
void return_buffer ()
 For state flows that are operated using invoke_subflow_and_wait this is a way to hand back the buffer to the caller.
 
MessageType * message ()
 
MessageType * transfer_message ()
 Releases ownership of the current message.
 

Detailed Description

This flow renders outgoing OpenLCB messages to their TCP stream representation.

Definition at line 281 of file IfTcpImpl.hxx.

Constructor & Destructor Documentation

◆ TcpSendFlow()

openlcb::TcpSendFlow::TcpSendFlow ( If service,
NodeID  gateway_node_id,
HubPortInterface send_target,
HubPortInterface skip_member,
SequenceNumberGenerator sequence 
)
inline

Constructor.

Parameters
servicethe owning TCP interface.
gateway_node_idour own node ID that will be put into the gateway node ID field of outgoing TCP messages.
send_targetwhere to send rendered TCP messages (this is usually either the device FD flow or a hub with the binary rendered packets).
skip_memberoutgoing packets will get their skipMember_ set to this value. Usually the matching read flow of the interface to avoid undesired echo.
sequencehow to generate sequence numbers for the outgoing packets.

Definition at line 296 of file IfTcpImpl.hxx.

Member Function Documentation

◆ entry()

Action openlcb::TcpSendFlow::entry ( )
inlineoverrideprivatevirtual

Handler where dequeueing of messages to be sent starts.

Returns
next state

Implements TypedStateFlow< MessageType, Base >.

Definition at line 316 of file IfTcpImpl.hxx.

◆ get_gateway_node_id()

NodeID openlcb::TcpSendFlow::get_gateway_node_id ( )
inline
Returns
the node ID the gateway uses to set on outgoing messages.

Definition at line 308 of file IfTcpImpl.hxx.

◆ iface()

If * openlcb::TcpSendFlow::iface ( )
inlineprivate
Returns
owning interface object.

Definition at line 361 of file IfTcpImpl.hxx.

◆ nmsg()

GenMessage * openlcb::TcpSendFlow::nmsg ( )
inlineprivate
Returns
the abstract message we are trying to send.

Definition at line 355 of file IfTcpImpl.hxx.

◆ render_src_message()

Action openlcb::TcpSendFlow::render_src_message ( )
inlineprivate

Callback state after allocation succeeded.

Renders the message to binary payload into the allocated buffer, send the message and exits the processing.

Returns
back to the base state.

Definition at line 338 of file IfTcpImpl.hxx.

Member Data Documentation

◆ gatewayId_

NodeID openlcb::TcpSendFlow::gatewayId_
private

Populated into the source gateway field of the outgoing messages.

Definition at line 371 of file IfTcpImpl.hxx.

◆ sendTarget_

HubPortInterface* openlcb::TcpSendFlow::sendTarget_
private

Where to send the rendered messages to.

Definition at line 367 of file IfTcpImpl.hxx.

◆ sequenceNumberGenerator_

SequenceNumberGenerator* openlcb::TcpSendFlow::sequenceNumberGenerator_
private

Responsible for generating the sequence numbers of the outgoing messages.

Definition at line 374 of file IfTcpImpl.hxx.

◆ skipMember_

HubPortInterface* openlcb::TcpSendFlow::skipMember_
private

This value will be populated to the skipMember_ field.

Definition at line 369 of file IfTcpImpl.hxx.


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