QDriverStation
The free, cross-platform FRC Driver Station
Public Slots | Public Member Functions | Private Slots | Private Attributes | List of all members
Utilities Class Reference

Provides CPU and Battery information to the QML interface. More...

#include <utilities.h>

Inheritance diagram for Utilities:

Public Slots

void copy (const QVariant &data)
 
void setAutoScaleEnabled (const bool enabled)
 

Public Member Functions

 Utilities ()
 
Q_INVOKABLE int cpuUsage ()
 
Q_INVOKABLE int batteryLevel ()
 
Q_INVOKABLE qreal scaleRatio ()
 
Q_INVOKABLE bool isConnectedToAC ()
 

Private Slots

void updateCpuUsage ()
 
void updateBatteryLevel ()
 
void updateConnectedToAC ()
 
void calculateScaleRatio ()
 
void readCpuUsageProcess (int exit_code=0)
 
void readBatteryLevelProcess (int exit_code=0)
 
void readConnectedToACProcess (int exit_code=0)
 

Private Attributes

qreal m_ratio
 
int m_cpuUsage
 
int m_batteryLevel
 
bool m_connectedToAC
 
QSettings * m_settings
 
QProcess m_cpuProcess
 
QProcess m_batteryLevelProcess
 
QProcess m_connectedToACProcess
 

Detailed Description

Provides CPU and Battery information to the QML interface.

Constructor & Destructor Documentation

Utilities::Utilities ( )
explicit

Configures the class and nitializes the CPU querying process under Windows.

References readBatteryLevelProcess(), readConnectedToACProcess(), readCpuUsageProcess(), updateBatteryLevel(), updateConnectedToAC(), and updateCpuUsage().

Member Function Documentation

int Utilities::batteryLevel ( )

Returns the current battery level (from 0 to 100)

void Utilities::calculateScaleRatio ( )
privateslot

Calculates the scale factor to apply to the UI.

Note
This function uses different procedures depending on the OS

Referenced by scaleRatio().

void Utilities::copy ( const QVariant &  data)
slot

Copies the given data to the system clipboard

int Utilities::cpuUsage ( )

Returns the current CPU usage (from 0 to 100)

bool Utilities::isConnectedToAC ( )

Returns true if the computer is connected to a power source or the battery is not discharging.

void Utilities::readBatteryLevelProcess ( int  exit_code = 0)
privateslot

Reads the output of the process launched to get the battery level

Referenced by Utilities().

void Utilities::readConnectedToACProcess ( int  exit_code = 0)
privateslot

Reads the output of the process launched to get the AC power source status

Referenced by Utilities().

void Utilities::readCpuUsageProcess ( int  exit_code = 0)
privateslot

Reads the output of the process launched to get the CPU usage

Referenced by Utilities().

qreal Utilities::scaleRatio ( )

Returns the auto-calculates scale ratio

References calculateScaleRatio().

void Utilities::setAutoScaleEnabled ( const bool  enabled)
slot

Enables or disables the autoscale feature.

Note
The application must be restarted for changes to take effect
void Utilities::updateBatteryLevel ( )
privateslot

Queries for the current battery level

Referenced by Utilities().

void Utilities::updateConnectedToAC ( )
privateslot

Queries for the current AC power source status

Referenced by Utilities().

void Utilities::updateCpuUsage ( )
privateslot

Queries for the current CPU usage

Referenced by Utilities().


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