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

Intermediate class which is still abstract, but adds implementation for the consist management functions. More...

#include <TractionTrain.hxx>

Inheritance diagram for openlcb::TrainNodeWithConsist:
openlcb::TrainNode openlcb::Node openlcb::DefaultTrainNode openlcb::TrainNodeForProxy openlcb::TrainNodeWithId

Public Member Functions

bool function_policy (NodeHandle src, uint8_t command_byte, uint32_t fnum, uint16_t value, Notifiable *done) override
 Applies a policy to function change requests coming in from the OpenLCB bus.
 
void command_hook (NodeHandle src, const Payload &p) override
 Invoked for every incoming traction command targeted to this node.
 
bool add_consist (NodeID tgt, uint8_t flags) override
 Adds a node ID to the consist targets.
 
bool remove_consist (NodeID tgt) override
 Removes a node ID from the consist targets.
 
NodeID query_consist (int id, uint8_t *flags) override
 Returns the consist target with offset id, or NodeID(0) if there are fewer than id consist targets.
 
int query_consist_length () override
 Returns the number of slaves in this consist.
 
- Public Member Functions inherited from openlcb::TrainNode
virtual TrainImpltrain ()=0
 
virtual NodeHandle get_controller ()=0
 
virtual void set_controller (NodeHandle id)=0
 
- Public Member Functions inherited from openlcb::Node
virtual NodeID node_id ()=0
 
virtual Ififace ()=0
 
virtual bool is_initialized ()=0
 
virtual void set_initialized ()
 Callback from the node initialization flow when the node finished initialization.
 
virtual void clear_initialized ()=0
 Callback from the simple stack when the node has to return to uninitialized state.
 
void initialize ()
 Callback from the simple stack to start the initialization process.
 

Public Attributes

TypedQueue< ConsistEntryconsistSlaves_
 

Detailed Description

Intermediate class which is still abstract, but adds implementation for the consist management functions.

Definition at line 167 of file TractionTrain.hxx.

Constructor & Destructor Documentation

◆ ~TrainNodeWithConsist()

openlcb::TrainNodeWithConsist::~TrainNodeWithConsist ( )

Definition at line 57 of file TractionTrain.cxx.

Member Function Documentation

◆ add_consist()

bool openlcb::TrainNodeWithConsist::add_consist ( NodeID  tgt,
uint8_t  flags 
)
inlineoverridevirtual

Adds a node ID to the consist targets.

Returns
false if the node was already in the target list, true if it was newly added.

Implements openlcb::TrainNode.

Definition at line 186 of file TractionTrain.hxx.

◆ command_hook()

void openlcb::TrainNodeWithConsist::command_hook ( NodeHandle  src,
const Payload p 
)
inlineoverridevirtual

Invoked for every incoming traction command targeted to this node.

Parameters
srcwhat node sent this command
pcommand payload

Implements openlcb::TrainNode.

Definition at line 180 of file TractionTrain.hxx.

◆ function_policy()

bool openlcb::TrainNodeWithConsist::function_policy ( NodeHandle  src,
uint8_t  command_byte,
uint32_t  fnum,
uint16_t  value,
Notifiable done 
)
inlineoverridevirtual

Applies a policy to function change requests coming in from the OpenLCB bus.

If the policy returns false, the change will not be applied to the TrainImpl. This is used to implement consist function behavior.

Parameters
srcsource node where the request came from.
command_byteis the first byte of the payload (usually 0x01 or 0x81 depending on the REQ_LISTENER bit)
fnumwhich function to set
valuewhat value to set this function to
donemust be notified inline if the policy application is successful. If not notified inline, then the returned value is ignored and the call is repeated after done has been invoked by the callee.
Returns
true if the function should be applied to the TrainImpl, false if it should not be applied. The default function policy applies everything.

Implements openlcb::TrainNode.

Definition at line 173 of file TractionTrain.hxx.

◆ query_consist()

NodeID openlcb::TrainNodeWithConsist::query_consist ( int  id,
uint8_t *  flags 
)
inlineoverridevirtual

Returns the consist target with offset id, or NodeID(0) if there are fewer than id consist targets.

id is zero-based.

Implements openlcb::TrainNode.

Definition at line 228 of file TractionTrain.hxx.

◆ query_consist_length()

int openlcb::TrainNodeWithConsist::query_consist_length ( )
inlineoverridevirtual

Returns the number of slaves in this consist.

Implements openlcb::TrainNode.

Definition at line 244 of file TractionTrain.hxx.

◆ remove_consist()

bool openlcb::TrainNodeWithConsist::remove_consist ( NodeID  tgt)
inlineoverridevirtual

Removes a node ID from the consist targets.

Returns
true if the target was removed, false if the target was not on the list.

Implements openlcb::TrainNode.

Definition at line 211 of file TractionTrain.hxx.

Member Data Documentation

◆ consistSlaves_

TypedQueue<ConsistEntry> openlcb::TrainNodeWithConsist::consistSlaves_

Definition at line 254 of file TractionTrain.hxx.


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