28#ifndef _WITHROTTLE_SERVER_HXX_
29#define _WITHROTTLE_SERVER_HXX_
61 ,
listener((port >= 0 || port <= UINT16_MAX) ? port :
Defs::DEFAULT_PORT,
63 std::placeholders::_1))
int bind(int socket, const struct sockaddr *address, socklen_t address_len)
Bind a name to a socket.
#define STATE(_fn)
Turns a function name into an argument to be supplied to functions expecting a state.
Base class for all QMember types that hold data in an expandable format.
Type-specific implementations of the DispatchFlow methods.
Implementation the ExecutorBase with a specific number of priority bands.
Collection of related state machines that pend on incoming messages.
void shutdown()
Shuts down the socket listener.
Return type for a state flow callback.
Base class for state machines.
void start_flow(Callback c)
Resets the flow to the specified state and starts it.
Base class for NMRAnet nodes conforming to the asynchronous interface.
Interface for a single throttle for running a train node.
WiThrottle server command handler base object.
WiThrottle server command handler base object for multi, primary, and secondary locomotive.
WiThrottle server object.
void start()
Start the server.
friend class ThrottleFlow
allow access from ThrottleFlow
Server(const char *name, int port, openlcb::Node *node)
Constructor.
SocketListener listener
listen socket for new connections
openlcb::Node * node
node reference
void on_new_connection(int fd)
A new throttle connection is made.
Executor< 1 > executor
The executor that will run the WiThrottle flows.
State flow for handling a throttle instance.
StateFlowBase::Action data_sent()
Data sent successfully.
string data
agrigate pre-processed stream data
CommandDispatchFlow dispatcher
flow responsible for routing incoming messages to handlers.
Server * server
reference to parent server
void parse_multi_type()
Parse the incoming data.
void parse_multi()
Parse the incoming data.
ServerCommandLoco serverCommandLoco
handler for locomotive commands
void parse_command()
Parse the incoming data.
StateFlowBase::Action data_received()
Process read data.
StateFlowSelectHelper selectHelper
Helper for waiting on data from a file descriptor.
LocoAddress address
primary locomitve addres
bool parse()
Parse the incoming data.
void parse_train()
Parse the incoming data.
ServerState state
Current state of parsing the data.
LocoAddress secondaryAddress
secondary locomotive address
DispatchFlow< Buffer< ThrottleCommand >, 1 > CommandDispatchFlow
dispatch flow that will handle messages incoming from the cab
~ThrottleFlow()
Destructor.
size_t dataIndex
data index for parsing
int fd
socket descriptor of throttle connection
bool parse_subcommand()
Parse the incoming data.
Buffer< ThrottleCommand > * command
throttle command
char readRaw[128]
read data buffer
string name
name of throttle
StateFlowBase::Action entry()
Beginning of state flow.
void start()
Start the service.
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Removes default copy-constructor and assignment added by C++.
Use this class to read from an fd using select() in a state flow.
The interface definitions for WiThrottle.
ServerState
Server state machine commands.