#include <srcp083_client.h>
Inherits SrcpVirtualClient.
Public Slots | |
void | setPower (const bool &power) |
void | requestNewRailState () |
void | setNewEngineState () |
Public Member Functions | |
Srcp083Client (QObject *parent=0) | |
Simple constructor. | |
~Srcp083Client () | |
Simple destructor. | |
Private Slots | |
void | srcpHandshake () |
Implement the SRCP handshake. | |
void | parseInfo (QString info) |
Srcp083::MsgCode | sendCommand (QString command) |
Srcp083::MsgCode | returnMsgCode (QString reply) |
Static Private Attributes | |
static const int | _bus = 1 |
Store the SRCP bus. |
Srcp083Client implement a SRCP 0.8.3 client, it can generate and understand the SRCP messages.
Definition at line 63 of file srcp083_client.h.
Srcp083Client::Srcp083Client | ( | QObject * | parent = 0 |
) |
Srcp083Client::~Srcp083Client | ( | ) |
void Srcp083Client::setPower | ( | const bool & | power | ) | [virtual, slot] |
Set the power in the state power on the railroad model, need to be implement in a concrete class
power | The power state to set |
Implements VirtualClient.
Definition at line 107 of file srcp083_client.cpp.
References _bus, VirtualClient::errorOccured(), Srcp083::Ok, and sendCommand().
void Srcp083Client::requestNewRailState | ( | ) | [virtual, slot] |
Send a request to the server for setting the new rail state on the railroad model, need to be implement in a concrete class. The rail is the sender of the signal.
Implements VirtualClient.
Definition at line 115 of file srcp083_client.cpp.
References _bus, Rail::address(), Rail::decoder(), Rail::delay(), VirtualClient::errorOccured(), Rail::isOpen(), Srcp083::NoData, Srcp083::Ok, and sendCommand().
void Srcp083Client::setNewEngineState | ( | ) | [virtual, slot] |
Apply the new engine state on the railroad model, need to be implement in a concrete class
Implements VirtualClient.
Definition at line 145 of file srcp083_client.cpp.
References _bus, Engine::address(), Engine::decoder(), VirtualClient::errorOccured(), Engine::f2(), Engine::f3(), Engine::f4(), Engine::isReversed(), Engine::light(), Srcp083::NoData, Srcp083::Ok, sendCommand(), and Engine::speed().
void Srcp083Client::srcpHandshake | ( | ) | [private, virtual, slot] |
Implement the SRCP handshake.
It does an handshake with the SRCP server, sets the right protocol and checks if it is supported, then it set the right connection mode (i.e command or info). After that it send the GO to the server.
Implements SrcpVirtualClient.
Definition at line 14 of file srcp083_client.cpp.
References Srcp083::ConnectionModeOk, VirtualClient::errorOccured(), Srcp083::Ok, Srcp083::ProtocolOk, returnMsgCode(), SrcpSocket::sendMsg(), SrcpVirtualClient::setConnection(), SrcpSocket::srcpReadLine(), SrcpSocket::start(), and SrcpSocket::type().
void Srcp083Client::parseInfo | ( | QString | info | ) | [private, virtual, slot] |
Parse the info received from the SRCP server
info | The info received |
Implements SrcpVirtualClient.
Definition at line 78 of file srcp083_client.cpp.
References Srcp083::Info, VirtualClient::infoReceivedEngineState(), VirtualClient::infoReceivedPower(), VirtualClient::infoReceivedRailState(), and returnMsgCode().
Srcp083::MsgCode Srcp083Client::sendCommand | ( | QString | command | ) | [private, slot] |
Send the requested command to the SRCP server
command | The command to send |
Definition at line 101 of file srcp083_client.cpp.
References SrcpVirtualClient::commandClient(), returnMsgCode(), and SrcpSocket::sendMsg().
Referenced by requestNewRailState(), setNewEngineState(), and setPower().
Srcp083::MsgCode Srcp083Client::returnMsgCode | ( | QString | reply | ) | [private, slot] |
Parse the reply and return the SRCP message code
reply | The reply received |
Definition at line 68 of file srcp083_client.cpp.
Referenced by parseInfo(), sendCommand(), and srcpHandshake().
const int Srcp083Client::_bus = 1 [static, private] |
Store the SRCP bus.
Definition at line 117 of file srcp083_client.h.
Referenced by requestNewRailState(), setNewEngineState(), and setPower().