LibDS
Qt-based library for controlling FRC robots
|
Updates the variables shared across the LibDS classes. More...
#include <DS_Config.h>
Public Slots | |
void | updateTeam (int team) |
void | setRobotCode (bool code) |
void | setEnabled (bool enabled) |
void | updateCpuUsage (int usage) |
void | updateRamUsage (int usage) |
void | updateDiskUsage (int usage) |
void | setBrownout (bool brownout) |
void | setEmergencyStop (bool estop) |
void | updateVoltage (qreal voltage) |
void | updateSimulated (bool simulated) |
void | updateAlliance (Alliance alliance) |
void | updatePosition (Position position) |
void | updateControlMode (ControlMode mode) |
void | updateLibVersion (const QString &version) |
void | updatePcmVersion (const QString &version) |
void | updatePdpVersion (const QString &version) |
void | updateEnabled (EnableStatus statusChanged) |
void | updateFMSCommStatus (CommStatus statusChanged) |
void | updateRadioCommStatus (CommStatus statusChanged) |
void | updateRobotCommStatus (CommStatus statusChanged) |
void | updateRobotCodeStatus (CodeStatus statusChanged) |
void | updateVoltageStatus (VoltageStatus statusChanged) |
void | updateOperationStatus (OperationStatus statusChanged) |
Public Member Functions | |
int | team () const |
int | cpuUsage () const |
int | ramUsage () const |
int | diskUsage () const |
qreal | voltage () const |
bool | isEnabled () const |
bool | isSimulated () const |
Alliance | alliance () const |
Position | position () const |
bool | isFMSAttached () const |
QString | libVersion () const |
QString | pcmVersion () const |
QString | pdpVersion () const |
bool | isEmergencyStopped () const |
bool | isRobotCodeRunning () const |
bool | isConnectedToRadio () const |
bool | isConnectedToRobot () const |
ControlMode | controlMode () const |
CommStatus | fmsCommStatus () const |
EnableStatus | enableStatus () const |
CommStatus | radioCommStatus () const |
CommStatus | robotCommStatus () const |
CodeStatus | robotCodeStatus () const |
VoltageStatus | voltageStatus () const |
OperationStatus | operationStatus () const |
Static Public Member Functions | |
static DS_Config * | getInstance () |
Static Public Member Functions inherited from DS | |
static QString | getStaticIP (int net, int team, int host) |
Returns a calculated IP address based on the team address. More... | |
static QString | timezone () |
Returns the current timezone as a string. | |
static QByteArray | readSocket (QUdpSocket *socket) |
Reads the datagrams received by the given UDP socket. | |
static QByteArray | readSocket (QTcpSocket *socket) |
Reads the data received by the given TCP socket. | |
Protected Member Functions | |
Logger * | logger () |
Private Slots | |
void | updateElapsedTime () |
Private Attributes | |
int | m_team |
int | m_cpuUsage |
int | m_ramUsage |
int | m_diskUsage |
qreal | m_voltage |
Alliance | m_alliance |
Position | m_position |
QString | m_libVersion |
QString | m_pcmVersion |
QString | m_pdpVersion |
CodeStatus | m_codeStatus |
ControlMode | m_controlMode |
CommStatus | m_fmsCommStatus |
EnableStatus | m_enableStatus |
CommStatus | m_radioCommStatus |
CommStatus | m_robotCommStatus |
VoltageStatus | m_voltageStatus |
OperationStatus | m_operationStatus |
bool | m_simulated |
bool | m_timerEnabled |
QElapsedTimer * | m_timer |
Logger * | m_logger |
Friends | |
class | DriverStation |
Additional Inherited Members | |
Public Types inherited from DS | |
enum | ControlMode { kControlTest, kControlAutonomous, kControlTeleoperated } |
Represents the available control modes of the robot. More... | |
enum | Alliance { kAllianceRed, kAllianceBlue } |
Represents the team alliance. More... | |
enum | Position { kPosition1, kPosition2, kPosition3 } |
Represents the different team positions for each alliance. More... | |
enum | CommStatus { kCommsWorking, kCommsFailing } |
Represents the communication status between the client and a target. More... | |
enum | CodeStatus { kCodeRunning, kCodeFailing } |
Represents the status of the robot code. More... | |
enum | EnableStatus { kEnabled, kDisabled } |
Represents the enabled state of the robot. More... | |
enum | OperationStatus { kNormal, kEmergencyStop } |
Represents the operation status of the robot. More... | |
enum | VoltageStatus { kVoltageNormal, kVoltageBrownout } |
Represents the status of the robot power supply. When the battery level is low or there are too many power spikes, the robot may report a voltage brownout. More... | |
enum | SocketType { kSocketTypeUDP, kSocketTypeTCP } |
Represents the socket types that can be used by the DS modules. More... | |
Signals inherited from DS_Base | |
void | elapsedTimeChanged (int msecs) |
void | elapsedTimeChanged (const QString &string) |
void | statusChanged (const QString &status) |
void | simulatedChanged (const bool isSimulation) |
void | enabledChanged (const EnableStatus status) |
void | allianceChanged (const Alliance alliance) |
void | positionChanged (const Position position) |
void | codeStatusChanged (const CodeStatus statusChanged) |
void | controlModeChanged (const ControlMode mode) |
void | robotAddressChanged (const QString &address) |
void | radioAddressChanged (const QString &address) |
void | fmsCommStatusChanged (const CommStatus statusChanged) |
void | robotCommStatusChanged (const CommStatus statusChanged) |
void | radioCommStatusChanged (const CommStatus statusChanged) |
void | voltageStatusChanged (const VoltageStatus statusChanged) |
void | operationStatusChanged (const OperationStatus statusChanged) |
void | pdpVersionChanged (const QString &version) |
void | pcmVersionChanged (const QString &version) |
void | libVersionChanged (const QString &version) |
void | voltageChanged (const qreal voltage) |
void | voltageChanged (const QString &voltageString) |
void | teamChanged (const int team) |
void | cpuUsageChanged (const int usage) |
void | ramUsageChanged (const int usage) |
void | diskUsageChanged (const int usage) |
Updates the variables shared across the LibDS classes.
This class updates the variables of the DriverStation
class without exposing potentionally dangerous/private functions to the client.
This class is meant to be used only by protocols, we could define these functions directly with each protocol, but this could increase memory usage and - if not managed correctly - cause a lot of issues with the event system of Qt.
DS::Alliance DS_Config::alliance | ( | ) | const |
Returns the current alliance of the robot (be it user-set or FMS-set)
Referenced by DriverStation::alliance(), and updateAlliance().
DS::ControlMode DS_Config::controlMode | ( | ) | const |
Returns the current control mode of the robot
Referenced by DriverStation::controlMode().
int DS_Config::cpuUsage | ( | ) | const |
Returns the current CPU usage of the robot (0 - 100)
Referenced by DriverStation::cpuUsage().
int DS_Config::diskUsage | ( | ) | const |
Returns the current disk usage of the robot
Referenced by DriverStation::diskUsage().
DS::EnableStatus DS_Config::enableStatus | ( | ) | const |
Returns the current enabled status of the robot
isEnabled()
function Referenced by DriverStation::enableStatus(), and isEnabled().
DS::CommStatus DS_Config::fmsCommStatus | ( | ) | const |
Returns the current status of the FMS communications.
isConnectedToFMS()
function Referenced by DriverStation::fmsCommStatus(), and isFMSAttached().
|
static |
Returns the one and only instance of
Referenced by DriverStation::config(), Protocol::config(), and DriverStation::logger().
bool DS_Config::isConnectedToRadio | ( | ) | const |
Returns true
if the Driver Station is connected to the radio. Otherwise, it returns false
References DS::kCommsWorking, and radioCommStatus().
bool DS_Config::isConnectedToRobot | ( | ) | const |
Returns true
if the Driver Station is connected to the robot. Otherwise, it returns false
References DS::kCommsWorking, and robotCommStatus().
Referenced by updateElapsedTime(), and voltage().
bool DS_Config::isEmergencyStopped | ( | ) | const |
Returns true
if the robot is emergency stopped. Otherwise, it returns false
.
References DS::kEmergencyStop, and operationStatus().
Referenced by FRC_2014::interpretRobotPacket(), and updateElapsedTime().
bool DS_Config::isEnabled | ( | ) | const |
Returns true
if the robot is enabled. Otherwise, it returns false
References enableStatus(), and DS::kEnabled.
Referenced by FRC_2014::getOperationCode().
bool DS_Config::isFMSAttached | ( | ) | const |
Returns true
if the Driver Station is connected to the Field Management System (FMS).
References fmsCommStatus(), and DS::kCommsWorking.
bool DS_Config::isRobotCodeRunning | ( | ) | const |
Returns true
if the robot code is running. Otherwise, it returns false
References DS::kCodeRunning, and robotCodeStatus().
bool DS_Config::isSimulated | ( | ) | const |
Returns true
if the robot is simulated. Otherwise, it returns false
Referenced by DriverStation::isSimulated().
QString DS_Config::libVersion | ( | ) | const |
Returns the library version of the robot
|
protected |
Returns the instance of the robot logger object
Referenced by DriverStation::availableLogs(), DriverStation::browseLogs(), DriverStation::init(), DriverStation::logger(), DriverStation::logsPath(), DriverStation::openLog(), and DriverStation::updatePacketLoss().
DS::OperationStatus DS_Config::operationStatus | ( | ) | const |
Returns the current operation status of the robot.
isEmergencyStopped()
function Referenced by isEmergencyStopped(), and DriverStation::operationStatus().
QString DS_Config::pcmVersion | ( | ) | const |
Returns the PCM version of the robot
QString DS_Config::pdpVersion | ( | ) | const |
Returns the PDP version of the robot
DS::Position DS_Config::position | ( | ) | const |
Returns the current position of the robot (be it user-set or FMS-set)
Referenced by DriverStation::position(), and updatePosition().
DS::CommStatus DS_Config::radioCommStatus | ( | ) | const |
Returns the current status of the radio communications
isConnectedToRadio()
function Referenced by isConnectedToRadio(), and DriverStation::radioCommStatus().
int DS_Config::ramUsage | ( | ) | const |
Returns the current RAM usage of the robot
Referenced by DriverStation::ramUsage().
DS::CodeStatus DS_Config::robotCodeStatus | ( | ) | const |
Returns the current status of the robot code
isRobotCodeRunning()
function Referenced by isRobotCodeRunning(), and DriverStation::robotCodeStatus().
DS::CommStatus DS_Config::robotCommStatus | ( | ) | const |
Returns the current status of the robot communications
isConnectedToRobot()
function Referenced by isConnectedToRobot(), and DriverStation::robotCommStatus().
|
slot |
Changes the voltage brownout status and fires the appropriate signals if required.
References DS::kVoltageBrownout, DS::kVoltageNormal, and updateVoltageStatus().
|
slot |
Changes the estop status and fires the appropriate signals if required
References DS::kEmergencyStop, DS::kNormal, and updateOperationStatus().
|
slot |
Changes the enabled status and fires the appropriate signals if required
References DS::kDisabled, DS::kEnabled, and updateEnabled().
|
slot |
Changes the robot code status and fires the appropriate signals if required
References DS::kCodeFailing, DS::kCodeRunning, and updateRobotCodeStatus().
Referenced by FRC_2014::interpretRobotPacket().
int DS_Config::team | ( | ) | const |
Returns the current team number
Referenced by FRC_2014::getRobotPacket(), DriverStation::team(), and updateTeam().
|
slot |
Changes the alliance and fires the appropriate signals if required
References alliance(), DS_Base::allianceChanged(), and Logger::registerAlliance().
Referenced by FRC_2014::interpretFMSPacket(), and DriverStation::setAlliance().
|
slot |
Changes the robot control mode and fires the appropriate signals if required
References DS_Base::controlModeChanged(), DriverStation::getInstance(), Logger::registerControlMode(), and DS_Base::statusChanged().
Referenced by FRC_2014::interpretFMSPacket(), and DriverStation::setControlMode().
|
slot |
Changes the CPU usage and fires the appropriate signals if required
References DS_Base::cpuUsageChanged().
|
slot |
Changes the disk usage and fires the appropriate signals if required
References DS_Base::diskUsageChanged().
|
privateslot |
Calculates the elapsed time since the robot has been enabled (regardless of the operation mode).
This function is called every 100 milliseconds.
References DS_Base::elapsedTimeChanged(), isConnectedToRobot(), and isEmergencyStopped().
|
slot |
Changes the enabled status and fires the appropriate signals if required
References DS_Base::enabledChanged(), DriverStation::getInstance(), DS::kEnabled, Logger::registerEnableStatus(), and DS_Base::statusChanged().
Referenced by FRC_2014::interpretFMSPacket(), DriverStation::resetRobot(), setEnabled(), DriverStation::setEnabled(), and updateOperationStatus().
|
slot |
Changes the FMS communication status and fires the appropriate signals if required
References DS_Base::fmsCommStatusChanged(), DriverStation::getInstance(), and DS_Base::statusChanged().
Referenced by Protocol::readFMSPacket(), and DriverStation::resetFMS().
|
slot |
Changes the robot library version and fires the appropriate signals if required
References DS_Base::libVersionChanged().
|
slot |
Changes the robot operation status and fires the appropriate signals if required
References DriverStation::getInstance(), DS::kDisabled, DS_Base::operationStatusChanged(), Logger::registerOperationStatus(), DS_Base::statusChanged(), and updateEnabled().
Referenced by FRC_2014::interpretRobotPacket(), DriverStation::resetRobot(), setEmergencyStop(), and DriverStation::setOperationStatus().
|
slot |
Changes the PCM version and fires the appropriate signals if required
References DS_Base::pcmVersionChanged().
|
slot |
Changes the PDP/PDB version and fires the appropriate signals if required
References DS_Base::pdpVersionChanged().
|
slot |
Changes the position and fires the appropriate signals if required
References position(), DS_Base::positionChanged(), and Logger::registerPosition().
Referenced by FRC_2014::interpretFMSPacket(), and DriverStation::setPosition().
|
slot |
Changes the radio communication status and fires the appropriate signals if required
References DS_Base::radioCommStatusChanged(), and Logger::registerRadioCommStatus().
Referenced by Protocol::readRadioPacket(), and DriverStation::resetRadio().
|
slot |
Changes the RAM usage and fires the appropriate signals if required
References DS_Base::ramUsageChanged().
|
slot |
Changes the robot code status and fires the appropriate signals if required
References DS_Base::codeStatusChanged(), DriverStation::getInstance(), Logger::registerCodeStatus(), and DS_Base::statusChanged().
Referenced by DriverStation::resetRobot(), and setRobotCode().
|
slot |
Changes the robot communication status and fires the appropriate signals if required
References DriverStation::getInstance(), Logger::registerRobotCommStatus(), DS_Base::robotCommStatusChanged(), and DS_Base::statusChanged().
Referenced by Protocol::readRobotPacket(), and DriverStation::resetRobot().
|
slot |
Changes the simulated status and fires the appropriate signals if required
References DS_Base::simulatedChanged().
Referenced by FRC_2014::interpretRobotPacket(), and DriverStation::resetRobot().
|
slot |
Changes the team number and fires the appropriate signals if required
References team(), and DS_Base::teamChanged().
Referenced by DriverStation::setTeam().
|
slot |
Changes the robot voltage and fires the appropriate signals if required
References DriverStation::getInstance(), DriverStation::maxBatteryVoltage(), Logger::registerVoltage(), and DS_Base::voltageChanged().
Referenced by FRC_2014::interpretRobotPacket(), and DriverStation::resetRobot().
|
slot |
Changes the voltage brownout status and fires the appropriate signals if required
References DriverStation::getInstance(), Logger::registerVoltageStatus(), DS_Base::statusChanged(), and DS_Base::voltageStatusChanged().
Referenced by DriverStation::resetRobot(), and setBrownout().
qreal DS_Config::voltage | ( | ) | const |
Returns the current voltage of the robot
References isConnectedToRobot().
Referenced by DriverStation::currentBatteryVoltage().
DS::VoltageStatus DS_Config::voltageStatus | ( | ) | const |
Returns the current voltage brownout status of the robot.
Referenced by DriverStation::voltageStatus().