35#ifndef _OPENLCB_TRACTIONCLIENT_HXX_
36#define _OPENLCB_TRACTIONCLIENT_HXX_
101 , expectedDst_(local_node)
114 expectedSrc_ = target_node;
115 expectedType_ = expected_type;
140 void start_listening()
143 this, openlcb::Defs::MTI_TRACTION_CONTROL_REPLY,
147 void stop_listening()
150 this, openlcb::Defs::MTI_TRACTION_CONTROL_REPLY,
162 return release_and_exit();
164 if (
nmsg()->dstNode != expectedDst_) {
166 return release_and_exit();
171 if (expectedSrc_.
id &&
nmsg()->src.id)
173 if (expectedSrc_.
id !=
nmsg()->src.id)
176 return release_and_exit();
179 else if (expectedSrc_.
alias &&
nmsg()->src.alias)
181 if (expectedSrc_.
alias !=
nmsg()->src.alias)
184 return release_and_exit();
191 DIE(
"Unable to decide whether the incoming response is coming from "
196 if (
nmsg()->payload.size() < 1) {
198 return release_and_exit();
200 if (
nmsg()->payload[0] != expectedType_) {
202 return release_and_exit();
215 uint8_t expectedType_;
Base class for all QMember types that hold data in an expandable format.
void register_handler(HandlerType *handler, ID id, ID mask)
Adds a new handler to this dispatcher.
void unregister_handler(HandlerType *handler, ID id, ID mask)
Removes a specific instance of a handler from this dispatcher.
A timer that can schedule itself to run on an executor at specified times in the future.
void trigger()
This will wakeup the timer prematurely, immediately.
Base::Action Action
Allows using Action without having StateFlowBase:: prefix in front of it.
MessageType * transfer_message()
Releases ownership of the current message.
Abstract class representing an OpenLCB Interface.
MessageDispatchFlow * dispatcher()
Base class for incoming message handler flows.
GenMessage * nmsg()
Returns the NMRAnet message we received.
Base class for NMRAnet nodes conforming to the asynchronous interface.
This class helps waiting for traction responses.
Action entry() OVERRIDE
Entry into the StateFlow activity.
void wait_for_response(NodeHandle target_node, uint8_t expected_type, ::Timer *trigger)
Starts waiting for a traction control reply from a given node with the first byte 'expected_type'.
void wait_timeout()
Call this if the timeout has expired.
Buffer< GenMessage > * response()
Caller must unref this buffer when done with it.
#define LOG(level, message...)
Conditionally write a message to the logging output.
static const int VERBOSE
Loglevel that is usually not printed, reporting debugging information.
#define OVERRIDE
Function attribute for virtual functions declaring that this funciton is overriding a funciton that s...
#define DIE(MSG)
Unconditionally terminates the current process with a message.
@ MTI_EXACT
match mask for a single MTI
Container of both a NodeID and NodeAlias.
NodeID id
48-bit NMRAnet Node ID
NodeAlias alias
alias to NMRAnet Node ID