CANpie FD
CAN programming interface environment - Version 3.08
|
The QCanServerSettings provides the functionality to test the current state of a QCanServer, its version number and the number of supported CAN networks. Communication between an instance of the QCanServer class and the QCanServerSettings class is done via WebSockets using JSON.
The following code shows an example how to establish a connection to a local QCanServer:
Connection to a QCanServer running on a different machine is only possible if remote access was granted by calling QCanServer::setServerAddress().
A state change of the QCanServer class is signalled via stateChanged(). Data from the QCanServer class is in JSON format, new data can be inspected via objectReceived().
Inherits QObject.
Public Types | |
enum | State_e { eSTATE_UNKNOWN = -1, eSTATE_INACTIVE = 0, eSTATE_CLOSED = 1, eSTATE_ACTIVE = 2 } |
Signals | |
void | stateChanged (enum QCanServerSettings::State_e teStateV) |
void | objectReceived (QJsonObject clServerSettingsV) |
Public Member Functions | |
QCanServerSettings (QObject *pclParentV=Q_NULLPTR) | |
void | connectToServer (const QHostAddress clServerAddressV=QHostAddress::LocalHost, const uint16_t uwPortV=QCAN_WEB_SOCKET_DEFAULT_PORT, const QString &clOriginR="", const uint32_t flags=0) |
bool | isValid (void) |
int32_t | networkCount (void) |
State_e | state (void) |
QString | stateString (void) |
int32_t | versionBuild (void) |
int32_t | versionMajor (void) |
int32_t | versionMinor (void) |
QCanServerSettings::QCanServerSettings | ( | QObject * | pclParentV = Q_NULLPTR | ) |
[in] | pclParentV | - Pointer to QObject parent class |
Construct a QCanServerSettings object
void QCanServerSettings::connectToServer | ( | const QHostAddress | clServerAddressV = QHostAddress::LocalHost , |
const uint16_t | uwPortV = QCAN_WEB_SOCKET_DEFAULT_PORT , |
||
const QString & | clOriginR = "" , |
||
const uint32_t | flags = 0 |
||
) |
[in] | clServerAddressV | - IPv4 or IPv6 address of QCanServer class |
[in] | uwPortV | - port number of QCanServer class |
[in] | clOriginR | - origin of the client |
[in] | flags | - reserved |
The method opens a WebSocket connection to a QCanServer class defined by clServerAddressV and uwPortV.
The origin of the client defined by clOriginR is as specified in RFC 6454. The origin is not required for non-web browser clients (see RFC 6455). The origin may not contain new line characters, otherwise the connection will be aborted immediately during the handshake phase.
bool QCanServerSettings::isValid | ( | void | ) |
True
if valid data availableThe function returns True
if a connection has been established to a QCanServer and the received JSON data has a vaild format.
int32_t QCanServerSettings::networkCount | ( | void | ) |
Return the number of networks (i.e. QCanNetwork) managed by the QCanServer class.
|
signal |
[in] | clServerSettingsV | - JSON data |
This signal is emitted after a new object was received from an active QCanServer. The JSON data has the following format:
State_e QCanServerSettings::state | ( | void | ) |
Return the state of a local QCanServer, possible values are listed by QCanServerSettings::State_e.
|
signal |
[in] | teStateV | - Server state |
This signal is emitted after a state change from a QCanServer.
QString QCanServerSettings::stateString | ( | void | ) |
Return the state of a local QCanServer as a QString object.
int32_t QCanServerSettings::versionBuild | ( | void | ) |
Return the build version of the active QCanServer. A return value of -1 denotes that either no connection could be establed to a QCanServer or the received JSON object was not valid.
int32_t QCanServerSettings::versionMajor | ( | void | ) |
Return the major version of the active QCanServer. A return value of -1 denotes that either no connection could be establed to a QCanServer or the received JSON object was not valid.
int32_t QCanServerSettings::versionMinor | ( | void | ) |
Return the minor version of the active QCanServer. A return value of -1 denotes that either no connection could be establed to a QCanServer or the received JSON object was not valid.