35#ifndef _OPENLCB_TRACTIONTRAIN_HXX_
36#define _OPENLCB_TRACTIONTRAIN_HXX_
83 uint32_t fnum, uint16_t value,
Notifiable *done) = 0;
192 if (tgt == node_id())
196 auto it = consistSlaves_.begin();
197 for (; it != consistSlaves_.end(); ++it)
199 if (it->get_slave() == tgt)
201 it->set_flags(flags);
205 consistSlaves_.insert(it,
new ConsistEntry(tgt, flags));
213 for (
auto it = consistSlaves_.begin(); it != consistSlaves_.end(); ++it)
215 if (it->get_slave() == tgt)
217 auto* p = it.operator->();
218 consistSlaves_.erase(it);
231 for (
auto it = consistSlaves_.begin();
232 it != consistSlaves_.end(); ++it, ++k)
236 if (flags) *flags = it->get_flags();
237 return it->get_slave();
247 for (
auto it = consistSlaves_.begin(); it != consistSlaves_.end();
274 If *iface()
override;
387 return nodes_->is_node_registered(node);
Lightweight locking class for protecting small critical sections.
This class sends a notification in its destructor.
An object that can schedule itself on an executor to run.
Essentially a "next" pointer container.
Collection of related state machines that pend on incoming messages.
A simple, fast, type-safe single-linked queue class with non-virtual methods.
Default implementation of a train node.
TrainImpl * train() override
void set_initialized() override
Callback from the node initialization flow when the node finished initialization.
NodeHandle get_controller() override
TrainService * service_
Pointer to the traction service.
void set_controller(NodeHandle id) override
NodeHandle controllerNodeId_
Controller node that is assigned to run this train. 0 if none.
TrainImpl * train_
Pointer to the train implementation object.
unsigned isInitialized_
Node is initialized bit for startup transient.
void clear_initialized() override
Callback from the simple stack when the node has to return to uninitialized state.
bool is_initialized() override
Abstract class representing an OpenLCB Interface.
Base class for NMRAnet nodes conforming to the asynchronous interface.
Abstract base class for train implementations.
Train node class with a an OpenLCB Node ID from the DCC pool. Used for command stations.
~TrainNodeForProxy()
Destructor.
NodeID node_id() OVERRIDE
Intermediate class which is still abstract, but adds implementation for the consist management functi...
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.
void command_hook(NodeHandle src, const Payload &p) override
Invoked for every incoming traction command targeted to this node.
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.
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.
Train node class with a fixed OpenLCB Node ID.
~TrainNodeWithId()
Destructor.
NodeID node_id() OVERRIDE
NodeID nodeId_
The OpenLCB node ID.
Virtual node class for an OpenLCB train protocol node.
virtual void set_controller(NodeHandle id)=0
virtual bool add_consist(NodeID tgt, uint8_t flags)=0
Adds a node ID to the consist targets.
virtual bool remove_consist(NodeID tgt)=0
Removes a node ID from the consist targets.
virtual NodeHandle get_controller()=0
virtual bool function_policy(NodeHandle src, uint8_t command_byte, uint32_t fnum, uint16_t value, Notifiable *done)=0
Applies a policy to function change requests coming in from the OpenLCB bus.
virtual NodeID query_consist(int id, uint8_t *flags)=0
Fetch a given consist link.
virtual int query_consist_length()=0
virtual void command_hook(NodeHandle src, const Payload &p)=0
Invoked for every incoming traction command targeted to this node.
virtual TrainImpl * train()=0
Collection of control flows necessary for implementing the Traction Protocol.
void unregister_train(TrainNode *node)
Removes a train node from the local interface.
void register_train(TrainNode *node)
Registers a new train with the train service.
Impl * impl_
Implementation flows.
std::unique_ptr< NodeRegistry > nodes_
List of train nodes managed by this Service.
If * iface_
OpenLCB interface.
bool is_known_train_node(Node *node)
Checks if the a given node is a train node operated by this Traction Service.
#define OVERRIDE
Function attribute for virtual functions declaring that this funciton is overriding a funciton that s...
uint64_t NodeID
48-bit NMRAnet Node ID type
string Payload
Container that carries the data bytes in an NMRAnet message.
Linked list entry for all registered consist clients for a given train node.
void set_flags(uint8_t new_flags)
Overrides the stored flags.
uint8_t get_flags() const
ConsistEntry(NodeID s, uint8_t flags)
Creates a new consist entry storage.
uint64_t payload
Data contents.
Container of both a NodeID and NodeAlias.
Implementation structure for TrainService.