LibDS
Qt-based library for controlling FRC robots
|
Sends and receives data from the FMS, radio and robot targets. More...
#include <Sockets.h>
Public Slots | |
void | performLookups () |
void | setFMSInputPort (int port) |
void | setFMSOutputPort (int port) |
void | setRadioInputPort (int port) |
void | setRobotInputPort (int port) |
void | setRadioOutputPort (int port) |
void | setRobotOutputPort (int port) |
void | sendToFMS (const QByteArray &data) |
void | sendToRobot (const QByteArray &data) |
void | sendToRadio (const QByteArray &data) |
void | setFMSSocketType (DS::SocketType type) |
void | setRadioSocketType (DS::SocketType type) |
void | setRobotSocketType (DS::SocketType type) |
void | setFMSAddress (const QString &address) |
void | setRadioAddress (const QString &address) |
void | setRobotAddress (const QString &address) |
void | setFMSAddress (const QHostAddress &address) |
void | setRadioAddress (const QHostAddress &address) |
void | setRobotAddress (const QHostAddress &address) |
Signals | |
void | fmsPacketReceived (const QByteArray &data) |
void | radioPacketReceived (const QByteArray &data) |
void | robotPacketReceived (const QByteArray &data) |
Public Member Functions | |
QHostAddress | fmsAddress () const |
QHostAddress | radioAddress () const |
QHostAddress | robotAddress () const |
Private Slots | |
void | readFMSSocket () |
void | readRadioSocket () |
void | readRobotSocket () |
void | onFMSLookupFinished (const QString &name, const QHostAddress &address) |
void | onRadioLookupFinished (const QString &name, const QHostAddress &address) |
void | onRobotLookupFinished (const QString &name, const QHostAddress &address) |
Private Attributes | |
int | m_robotIterator |
int | m_fmsOutputPort |
int | m_radioOutputPort |
int | m_robotOutputPort |
int | m_fmsLookupId |
int | m_radioLookupId |
int | m_robotLookupId |
QHostAddress | m_fmsAddress |
QHostAddress | m_robotAddress |
QHostAddress | m_radioAddress |
Lookup * | m_fmsLookup |
Lookup * | m_radioLookup |
Lookup * | m_robotLookup |
DriverStation * | m_driverStation |
QUdpSocket * | m_udpFmsSender |
QTcpSocket * | m_tcpFmsSender |
QUdpSocket * | m_udpRadioSender |
QTcpSocket * | m_tcpRadioSender |
QUdpSocket * | m_udpRobotSender |
QTcpSocket * | m_tcpRobotSender |
QUdpSocket * | m_udpFmsReceiver |
QTcpSocket * | m_tcpFmsReceiver |
QUdpSocket * | m_udpRadioReceiver |
QTcpSocket * | m_tcpRadioReceiver |
QUdpSocket * | m_udpRobotReceiver |
QTcpSocket * | m_tcpRobotReceiver |
Sends and receives data from the FMS, radio and robot targets.
This class also performs the host lookup processes for each target if it is required (for example, when using mDNS targets). As a rule of thumb, this class will broadcast generated packets if we do not know the target IP.
This class is controlled directly by the DriverStation
, which acts as a man-in-the-middle between the loaded Protocol
and the Sockets
class.
QHostAddress Sockets::fmsAddress | ( | ) | const |
Returns the FMS address.
Referenced by sendToFMS().
|
privateslot |
Assigns the found FMS IP
References DriverStation::fmsAddress(), and setFMSAddress().
|
privateslot |
Assigns the found radio IP
References DriverStation::radioAddress(), and setRadioAddress().
|
privateslot |
Assigns the found robot IP
References DriverStation::robotAddress(), and setRobotAddress().
|
slot |
If any of the IPs used during the communications is not known, this function will ensure that the DS performs a lookup periodically until all addresses are known.
This is especially useful when we are dealing with dynamic IPs, such as when the robot uses a mDNS address.
References DriverStation::fmsAddress(), DriverStation::getInstance(), DriverStation::isConnectedToFMS(), DriverStation::isConnectedToRadio(), DriverStation::isConnectedToRobot(), Lookup::lookup(), DriverStation::radioAddress(), and DriverStation::robotAddress().
QHostAddress Sockets::radioAddress | ( | ) | const |
Returns the radio address.
Referenced by sendToRadio().
|
privateslot |
Called when we receive data from the FMS
References DS::readSocket(), and setFMSAddress().
Referenced by setFMSSocketType().
|
privateslot |
Called when we receive data from the radio
References DS::readSocket(), and setRadioAddress().
Referenced by setRadioSocketType().
|
privateslot |
Called when we receive data from the robot
References DS::readSocket(), and setRobotAddress().
Referenced by setRobotSocketType().
QHostAddress Sockets::robotAddress | ( | ) | const |
Returns the robot address. If the robot address is not known, this function will return the local IP of the computer (e.g for simulations).
Referenced by sendToRobot().
|
slot |
Sends the given data to the FMS
References fmsAddress().
Referenced by DriverStation::sendFMSPacket().
|
slot |
Sends the given data to the radio
References radioAddress().
Referenced by DriverStation::sendRadioPacket().
|
slot |
Sends the given data to the robot
References robotAddress().
Referenced by DriverStation::sendRobotPacket().
|
slot |
Changes the FMS address. If the FMS address is set to an invalid value, then this class will broadcast the data.
Referenced by onFMSLookupFinished(), readFMSSocket(), DriverStation::setCustomFMSAddress(), and DriverStation::updateAddresses().
|
slot |
Changes the FMS address to the given address
|
slot |
Changes the port in which we receive data from the FMS
Referenced by DriverStation::setProtocol().
|
slot |
Changes the FMS destination port
Referenced by DriverStation::setProtocol().
|
slot |
Changes the set of sockets that will be used for FMS communications
References DS::kSocketTypeTCP, and readFMSSocket().
Referenced by DriverStation::setProtocol().
|
slot |
Changes the radio address. If the radio address is set to an invalid value, then this class will broadcast the data.
Referenced by onRadioLookupFinished(), readRadioSocket(), DriverStation::setCustomRadioAddress(), and DriverStation::updateAddresses().
|
slot |
Changes the radio address to the given address
|
slot |
Changes the port in which we receive data from the radio
Referenced by DriverStation::setProtocol().
|
slot |
Changes the radio destination robot
Referenced by DriverStation::setProtocol().
|
slot |
Changes the set of sockets that will be used for radio communications
References DS::kSocketTypeTCP, and readRadioSocket().
Referenced by DriverStation::setProtocol().
|
slot |
Changes the robot address. If the robot address is set to an invalid value, then this class will broadcast the data.
Referenced by onRobotLookupFinished(), readRobotSocket(), DriverStation::setCustomRobotAddress(), and DriverStation::updateAddresses().
|
slot |
Changes the robot address to the given address
|
slot |
Changes the port in which we receive data from the robot
Referenced by DriverStation::setProtocol().
|
slot |
Changes the robot destination robot
Referenced by DriverStation::setProtocol().
|
slot |
Changes the set of sockets that will be used for robot communications
References DS::kSocketTypeTCP, and readRobotSocket().
Referenced by DriverStation::setProtocol().