LibDS
Qt-based library for controlling FRC robots
|
Creates and reads files with robot events and application logs. More...
#include <Logger.h>
Public Slots | |
void | saveLogs () |
void | closeLogs () |
void | registerInitialEvents () |
void | registerVoltage (qreal voltage) |
void | registerPacketLoss (int pktLoss) |
void | registerRobotRAMUsage (int usage) |
void | registerRobotCPUUsage (int usage) |
void | registerAlliance (DS::Alliance alliance) |
void | registerPosition (DS::Position position) |
void | registerControlMode (DS::ControlMode mode) |
void | registerCodeStatus (DS::CodeStatus status) |
void | registerEnableStatus (DS::EnableStatus status) |
void | registerRadioCommStatus (DS::CommStatus status) |
void | registerRobotCommStatus (DS::CommStatus status) |
void | registerVoltageStatus (DS::VoltageStatus status) |
void | registerNetConsoleMessage (const QString &message) |
void | registerOperationStatus (DS::OperationStatus status) |
Signals | |
void | logsSaved (const QString &file) |
Public Member Functions | |
QString | logsPath () const |
QString | extension () const |
QStringList | availableLogs () const |
QJsonDocument | openLog (const QString &name) const |
void | messageHandler (QtMsgType type, const QMessageLogContext &context, const QString &data) |
Private Slots | |
void | initializeLogger () |
Private Attributes | |
QString | m_netConsole |
QElapsedTimer * | m_timer |
bool | m_eventsRegistered |
FILE * | m_dump |
bool | m_closed |
bool | m_initialized |
QString | m_logFilePath |
QString | m_dumpFilePath |
int | m_previousRAM |
int | m_previousCPU |
int | m_previousLoss |
qreal | m_previousVoltage |
DS::CodeStatus | m_previousCodeStatus |
DS::ControlMode | m_previousControlMode |
DS::CommStatus | m_previousRadioCommStatus |
DS::CommStatus | m_previousRobotCommStatus |
DS::EnableStatus | m_previousEnabledStatus |
DS::VoltageStatus | m_previousVoltageStatus |
DS::OperationStatus | m_previousOperationStatus |
QList< QPair< qint64, int > > | m_pktLoss |
QList< QPair< qint64, int > > | m_ramUsage |
QList< QPair< qint64, int > > | m_cpuUsage |
QList< QPair< qint64, qreal > > | m_voltage |
QList< QPair< qint64, DS::CodeStatus > > | m_codeStatus |
QList< QPair< qint64, DS::ControlMode > > | m_controlMode |
QList< QPair< qint64, DS::CommStatus > > | m_radioCommStatus |
QList< QPair< qint64, DS::CommStatus > > | m_robotCommStatus |
QList< QPair< qint64, DS::EnableStatus > > | m_enabledStatus |
QList< QPair< qint64, DS::VoltageStatus > > | m_voltageStatus |
QList< QPair< qint64, DS::OperationStatus > > | m_operationStatus |
Creates and reads files with robot events and application logs.
This can be later used to diagnostic the robot or to diagnostic the QDriverStation.
QStringList Logger::availableLogs | ( | ) | const |
Returns a list with all the logs that have been created locally
References extension(), and logsPath().
Referenced by DriverStation::availableLogs().
|
slot |
Closes the console log dump file
References saveLogs().
QString Logger::extension | ( | ) | const |
Returns the extension appended to the log files
Referenced by availableLogs(), and DriverStation::browseLogs().
|
privateslot |
Creates the temporary console dump file and sets the file name of the final DS log file.
References saveLogs().
Referenced by messageHandler().
QString Logger::logsPath | ( | ) | const |
Returns the path in which log files are saved
Referenced by availableLogs(), and DriverStation::logsPath().
void Logger::messageHandler | ( | QtMsgType | type, |
const QMessageLogContext & | context, | ||
const QString & | data | ||
) |
Writes the message output to the console and to the dump file (which is dumped on the DS log file when the application exits).
References initializeLogger().
Referenced by DriverStation::logger().
QJsonDocument Logger::openLog | ( | const QString & | name | ) | const |
Opens the given log file and parses its JSON data
Referenced by DriverStation::openLog().
|
slot |
Logs the given team alliance to the console output.
Referenced by registerInitialEvents(), and DS_Config::updateAlliance().
|
slot |
Registers the given code status to the event lists.
Referenced by registerInitialEvents(), and DS_Config::updateRobotCodeStatus().
|
slot |
Registers the given control mode to the event lists.
Referenced by registerInitialEvents(), and DS_Config::updateControlMode().
|
slot |
Registers the given enable status to the event lists.
Referenced by registerInitialEvents(), and DS_Config::updateEnabled().
|
slot |
Registers the inital robot events in the event lists
References DS::kAllianceRed, DS::kCodeFailing, DS::kCommsFailing, DS::kControlTeleoperated, DS::kDisabled, DS::kNormal, DS::kVoltageNormal, registerAlliance(), registerCodeStatus(), registerControlMode(), registerEnableStatus(), registerOperationStatus(), registerPacketLoss(), registerRadioCommStatus(), registerRobotCommStatus(), registerRobotCPUUsage(), registerRobotRAMUsage(), registerVoltage(), and registerVoltageStatus().
Referenced by DriverStation::init().
|
slot |
Appends the given message to the NetConsole log
|
slot |
Registers the given operation status to the event lists.
Referenced by registerInitialEvents(), and DS_Config::updateOperationStatus().
|
slot |
Registers the given packet loss to the robot events log.
Referenced by registerInitialEvents(), and DriverStation::updatePacketLoss().
|
slot |
Logs the given team position to the console output.
Referenced by DS_Config::updatePosition().
|
slot |
Registers the given radio communication status to the event lists.
Referenced by registerInitialEvents(), and DS_Config::updateRadioCommStatus().
|
slot |
Registers the given robot communication status to the event lists.
Referenced by registerInitialEvents(), and DS_Config::updateRobotCommStatus().
|
slot |
Registers the given CPU usage to the robot events log.
Referenced by registerInitialEvents().
|
slot |
Registers the given RAM usage to the robot events log.
Referenced by registerInitialEvents().
|
slot |
Registers the given voltage to the robot events log.
Referenced by registerInitialEvents(), and DS_Config::updateVoltage().
|
slot |
Registers the given voltage status to the event lists.
Referenced by registerInitialEvents(), and DS_Config::updateVoltageStatus().
|
slot |
Saves the robot events and the application logs into a compact JSON file. This file can later be used by teams to diagnostic their robots or by the LibDS developers to fix an issue.
Referenced by closeLogs(), and initializeLogger().