LibDS
Qt-based library for controlling FRC robots
Public Slots | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Slots | Private Attributes | Friends | List of all members
DS_Config Class Reference

Updates the variables shared across the LibDS classes. More...

#include <DS_Config.h>

Inheritance diagram for DS_Config:
DS_Base DS

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_ConfiggetInstance ()
 
- 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

Loggerlogger ()
 

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
 
Loggerm_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)
 

Detailed Description

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.

Member Function Documentation

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

Note
You can also use the isEnabled() function

Referenced by DriverStation::enableStatus(), and isEnabled().

DS::CommStatus DS_Config::fmsCommStatus ( ) const

Returns the current status of the FMS communications.

Note
You can also use the isConnectedToFMS() function

Referenced by DriverStation::fmsCommStatus(), and isFMSAttached().

DS_Config * DS_Config::getInstance ( )
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

Logger * DS_Config::logger ( )
protected
DS::OperationStatus DS_Config::operationStatus ( ) const

Returns the current operation status of the robot.

Note
You can also use the 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

Note
You can also use the 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

Note
You can also use the isRobotCodeRunning() function

Referenced by isRobotCodeRunning(), and DriverStation::robotCodeStatus().

DS::CommStatus DS_Config::robotCommStatus ( ) const

Returns the current status of the robot communications

Note
You can also use the isConnectedToRobot() function

Referenced by isConnectedToRobot(), and DriverStation::robotCommStatus().

void DS_Config::setBrownout ( bool  brownout)
slot

Changes the voltage brownout status and fires the appropriate signals if required.

References DS::kVoltageBrownout, DS::kVoltageNormal, and updateVoltageStatus().

void DS_Config::setEmergencyStop ( bool  estop)
slot

Changes the estop status and fires the appropriate signals if required

References DS::kEmergencyStop, DS::kNormal, and updateOperationStatus().

void DS_Config::setEnabled ( bool  enabled)
slot

Changes the enabled status and fires the appropriate signals if required

References DS::kDisabled, DS::kEnabled, and updateEnabled().

void DS_Config::setRobotCode ( bool  code)
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().

void DS_Config::updateAlliance ( Alliance  alliance)
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().

void DS_Config::updateControlMode ( ControlMode  mode)
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().

void DS_Config::updateCpuUsage ( int  usage)
slot

Changes the CPU usage and fires the appropriate signals if required

References DS_Base::cpuUsageChanged().

void DS_Config::updateDiskUsage ( int  usage)
slot

Changes the disk usage and fires the appropriate signals if required

References DS_Base::diskUsageChanged().

void DS_Config::updateElapsedTime ( )
privateslot

Calculates the elapsed time since the robot has been enabled (regardless of the operation mode).

This function is called every 100 milliseconds.

Note
This function will not run if there is no communication status with the robot or if the robot is emergency stopped
The elapsed time will be resetted when the user changes the control mode of the robot

References DS_Base::elapsedTimeChanged(), isConnectedToRobot(), and isEmergencyStopped().

void DS_Config::updateEnabled ( EnableStatus  status)
slot
void DS_Config::updateFMSCommStatus ( CommStatus  status)
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().

void DS_Config::updateLibVersion ( const QString &  version)
slot

Changes the robot library version and fires the appropriate signals if required

References DS_Base::libVersionChanged().

void DS_Config::updateOperationStatus ( OperationStatus  status)
slot
void DS_Config::updatePcmVersion ( const QString &  version)
slot

Changes the PCM version and fires the appropriate signals if required

References DS_Base::pcmVersionChanged().

void DS_Config::updatePdpVersion ( const QString &  version)
slot

Changes the PDP/PDB version and fires the appropriate signals if required

References DS_Base::pdpVersionChanged().

void DS_Config::updatePosition ( Position  position)
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().

void DS_Config::updateRadioCommStatus ( CommStatus  status)
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().

void DS_Config::updateRamUsage ( int  usage)
slot

Changes the RAM usage and fires the appropriate signals if required

References DS_Base::ramUsageChanged().

void DS_Config::updateRobotCodeStatus ( CodeStatus  status)
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().

void DS_Config::updateRobotCommStatus ( CommStatus  status)
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().

void DS_Config::updateSimulated ( bool  simulated)
slot

Changes the simulated status and fires the appropriate signals if required

References DS_Base::simulatedChanged().

Referenced by FRC_2014::interpretRobotPacket(), and DriverStation::resetRobot().

void DS_Config::updateTeam ( int  team)
slot

Changes the team number and fires the appropriate signals if required

References team(), and DS_Base::teamChanged().

Referenced by DriverStation::setTeam().

void DS_Config::updateVoltage ( qreal  voltage)
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().

void DS_Config::updateVoltageStatus ( VoltageStatus  status)
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().


The documentation for this class was generated from the following files: