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

Handler for incoming OpenLCB messages of MTI == Traction Protocol Request. More...

Inheritance diagram for openlcb::TrainService::Impl::TractionRequestFlow:
openlcb::IncomingMessageStateFlow StateFlow< Buffer< GenMessage >, QList< 4 > > TypedStateFlow< MessageType, Base > FlowInterface< MessageType >

Public Member Functions

 TractionRequestFlow (TrainService *service)
 
- Public Member Functions inherited from openlcb::IncomingMessageStateFlow
 IncomingMessageStateFlow (If *iface)
 
Ififace ()
 
GenMessagenmsg ()
 Returns the NMRAnet message we received.
 
- 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.
 

Protected Member Functions

TrainNodetrain_node ()
 
Action maybe_alloc_response (Callback c)
 
void ensure_response_exists ()
 
Action entry () OVERRIDE
 Entry into the StateFlow activity.
 
Action handle_query ()
 
Action handle_controller_config ()
 
Action handle_consist_config ()
 
Action maybe_forward_consist ()
 
Action forward_consist ()
 
Action handle_traction_mgmt ()
 
Payloadinitialize_response ()
 Takes the allocation result of a response buffer (addressed write flow) and fills in src, dest as a response message for traction protocol.
 
Action init_and_send_response (Payload p)
 
Action send_response ()
 Sends off the response buffer to the client.
 
size_t size ()
 Returns the size of the incoming message payload.
 
const uint8_t * payload ()
 Returns the incoming message payload (bytes).
 
Action reject_permanent (uint16_t code=Defs::ERROR_PERMANENT)
 Rejects the incoming message with a permanent error.
 
Action send_reject_permanent ()
 
- 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.
 

Private Attributes

unsigned errorCode_: 16
 error code for reject_permanent().
 
unsigned nextConsistIndex_: 8
 
unsigned reserved_: 1
 1 if the voluntary lock protocol has set this train to be reserved.
 
TrainServicetrainService_
 
Buffer< GenMessage > * response_
 
BarrierNotifiable bn_
 

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.
 

Detailed Description

Handler for incoming OpenLCB messages of MTI == Traction Protocol Request.

Definition at line 121 of file TractionTrain.cxx.

Constructor & Destructor Documentation

◆ TractionRequestFlow()

openlcb::TrainService::Impl::TractionRequestFlow::TractionRequestFlow ( TrainService service)
inline

Definition at line 124 of file TractionTrain.cxx.

◆ ~TractionRequestFlow()

openlcb::TrainService::Impl::TractionRequestFlow::~TractionRequestFlow ( )
inline

Definition at line 134 of file TractionTrain.cxx.

Member Function Documentation

◆ ensure_response_exists()

void openlcb::TrainService::Impl::TractionRequestFlow::ensure_response_exists ( )
inlineprotected

Definition at line 159 of file TractionTrain.cxx.

◆ entry()

Action openlcb::TrainService::Impl::TractionRequestFlow::entry ( )
inlineprotectedvirtual

Entry into the StateFlow activity.

Pure virtual which must be defined by derived class.

Returns
function pointer to next state

@TODO(balazs.racz): This is probably not the good solution here; since this is an addressed message we should rather send a reject response.

@TODO(balazs.racz) need to validate caller of mutating functions. The mutating options should be factored into a separate flow state.

Implements TypedStateFlow< MessageType, Base >.

Definition at line 168 of file TractionTrain.cxx.

◆ forward_consist()

Action openlcb::TrainService::Impl::TractionRequestFlow::forward_consist ( )
inlineprotected

Definition at line 524 of file TractionTrain.cxx.

◆ handle_consist_config()

Action openlcb::TrainService::Impl::TractionRequestFlow::handle_consist_config ( )
inlineprotected

Definition at line 407 of file TractionTrain.cxx.

◆ handle_controller_config()

Action openlcb::TrainService::Impl::TractionRequestFlow::handle_controller_config ( )
inlineprotected

@TODO (balazs.racz): we need to implement stealing a train from the existing controller.

Definition at line 318 of file TractionTrain.cxx.

◆ handle_query()

Action openlcb::TrainService::Impl::TractionRequestFlow::handle_query ( )
inlineprotected

Definition at line 272 of file TractionTrain.cxx.

◆ handle_traction_mgmt()

Action openlcb::TrainService::Impl::TractionRequestFlow::handle_traction_mgmt ( )
inlineprotected

Definition at line 551 of file TractionTrain.cxx.

◆ init_and_send_response()

Action openlcb::TrainService::Impl::TractionRequestFlow::init_and_send_response ( Payload  p)
inlineprotected

Definition at line 604 of file TractionTrain.cxx.

◆ initialize_response()

Payload * openlcb::TrainService::Impl::TractionRequestFlow::initialize_response ( )
inlineprotected

Takes the allocation result of a response buffer (addressed write flow) and fills in src, dest as a response message for traction protocol.

The caller only needs to provide the payload.

Definition at line 595 of file TractionTrain.cxx.

◆ maybe_alloc_response()

Action openlcb::TrainService::Impl::TractionRequestFlow::maybe_alloc_response ( Callback  c)
inlineprotected

Definition at line 146 of file TractionTrain.cxx.

◆ maybe_forward_consist()

Action openlcb::TrainService::Impl::TractionRequestFlow::maybe_forward_consist ( )
inlineprotected

Definition at line 463 of file TractionTrain.cxx.

◆ payload()

const uint8_t * openlcb::TrainService::Impl::TractionRequestFlow::payload ( )
inlineprotected

Returns the incoming message payload (bytes).

Definition at line 628 of file TractionTrain.cxx.

◆ reject_permanent()

Action openlcb::TrainService::Impl::TractionRequestFlow::reject_permanent ( uint16_t  code = Defs::ERROR_PERMANENT)
inlineprotected

Rejects the incoming message with a permanent error.

Definition at line 634 of file TractionTrain.cxx.

◆ send_reject_permanent()

Action openlcb::TrainService::Impl::TractionRequestFlow::send_reject_permanent ( )
inlineprotected

Definition at line 639 of file TractionTrain.cxx.

◆ send_response()

Action openlcb::TrainService::Impl::TractionRequestFlow::send_response ( )
inlineprotected

Sends off the response buffer to the client.

Definition at line 614 of file TractionTrain.cxx.

◆ size()

size_t openlcb::TrainService::Impl::TractionRequestFlow::size ( )
inlineprotected

Returns the size of the incoming message payload.

Definition at line 622 of file TractionTrain.cxx.

◆ train_node()

TrainNode * openlcb::TrainService::Impl::TractionRequestFlow::train_node ( )
inlineprotected

Definition at line 141 of file TractionTrain.cxx.

Member Data Documentation

◆ bn_

BarrierNotifiable openlcb::TrainService::Impl::TractionRequestFlow::bn_
private

Definition at line 658 of file TractionTrain.cxx.

◆ errorCode_

unsigned openlcb::TrainService::Impl::TractionRequestFlow::errorCode_
private

error code for reject_permanent().

Definition at line 652 of file TractionTrain.cxx.

◆ nextConsistIndex_

unsigned openlcb::TrainService::Impl::TractionRequestFlow::nextConsistIndex_
private

Definition at line 653 of file TractionTrain.cxx.

◆ reserved_

unsigned openlcb::TrainService::Impl::TractionRequestFlow::reserved_
private

1 if the voluntary lock protocol has set this train to be reserved.

Definition at line 655 of file TractionTrain.cxx.

◆ response_

Buffer<GenMessage>* openlcb::TrainService::Impl::TractionRequestFlow::response_
private

Definition at line 657 of file TractionTrain.cxx.

◆ trainService_

TrainService* openlcb::TrainService::Impl::TractionRequestFlow::trainService_
private

Definition at line 656 of file TractionTrain.cxx.


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