KSysGuard::Sensor

Search for usage in LXR

KSysGuard::Sensor Class Reference

#include <Sensor.h>

Inheritance diagram for KSysGuard::Sensor:

Public Types

enum  Status {
  Status::Unknown, Status::Loading, Status::Ready, Status::Error,
  Status::Removed
}
 

Properties

QString description
 
bool enabled
 
QString formattedValue
 
qreal maximum
 
qreal minimum
 
QString name
 
QString sensorId
 
QString shortName
 
Status status
 
QVariant::Type type
 
KSysGuard::Unit unit
 
uint updateInterval
 
int updateRateLimit
 
QVariant value
 
- Properties inherited from QObject
 objectName
 

Public Member Functions

 Sensor (const QString &id, QObject *parent=nullptr)
 
 Sensor (const SensorQuery &query, int index, QObject *parent=nullptr)
 
 Sensor (QObject *parent=nullptr)
 
void classBegin () override
 
void componentComplete () override
 
QString description () const
 
bool enabled () const
 
Q_SIGNAL void enabledChanged ()
 
bool event (QEvent *event) override
 
QString formattedValue () const
 
qreal maximum () const
 
Q_SIGNAL void metaDataChanged () const
 
qreal minimum () const
 
QString name () const
 
void resetUpdateRateLimit ()
 
QString sensorId () const
 
Q_SIGNAL void sensorIdChanged () const
 
void setEnabled (bool newEnabled)
 
void setSensorId (const QString &id)
 
void setUpdateRateLimit (int newUpdateRateLimit)
 
QString shortName () const
 
Status status () const
 
Q_SIGNAL void statusChanged () const
 
QVariant::Type type () const
 
KSysGuard::Unit unit () const
 
uint updateInterval () const
 
Q_SIGNAL void updateIntervalChanged ()
 
int updateRateLimit () const
 
Q_SIGNAL void updateRateLimitChanged ()
 
QVariant value () const
 
Q_SIGNAL void valueChanged () const
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo ()
 
void dumpObjectInfo () const const
 
void dumpObjectTree ()
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_DISABLE_COPY (Class)
 
 Q_DISABLE_COPY_MOVE (Class)
 
 Q_DISABLE_MOVE (Class)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
qobject_cast (const QObject *object)
 
qobject_cast (QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
QThreadthread () const const
 

Additional Inherited Members

- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
- Public Attributes inherited from QObject
typedef QObjectList
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

Detailed Description

An object encapsulating a backend sensor.

This class represents a sensor as exposed by the backend. It allows querying various metadata properties of the sensor as well as the current value.

Definition at line 33 of file Sensor.h.

Member Enumeration Documentation

◆ Status

This enum type is used to specify status of the Sensor.

Enumerator
Unknown 

The sensor has no ID assigned.

Loading 

The sensor is currently being loaded.

Ready 

The sensor has been loaded.

Error 

An error occurred or the sensor has been removed.

Removed 

Removed from backend.

Definition at line 123 of file Sensor.h.

Property Documentation

◆ description

QString Sensor::description
read

A description of the Sensor.

Definition at line 55 of file Sensor.h.

◆ enabled

bool Sensor::enabled
readwrite

Should this Sensor check for changes?

Note that if set to true, the sensor will only be enabled when the parent is also enabled.

Definition at line 97 of file Sensor.h.

◆ maximum

qreal Sensor::maximum
read

The maximum value this Sensor can have.

Definition at line 67 of file Sensor.h.

◆ minimum

qreal Sensor::minimum
read

The minimum value this Sensor can have.

Definition at line 63 of file Sensor.h.

◆ name

QString Sensor::name
read

The user-visible name of this Sensor.

Definition at line 45 of file Sensor.h.

◆ sensorId

QString Sensor::sensorId
readwrite

The path to the backend sensor this Sensor represents.

Definition at line 41 of file Sensor.h.

◆ shortName

QString Sensor::shortName
read

A shortened name that can be displayed when space is constrained.

The value is the same as name if shortName was not provided by the backend.

Definition at line 51 of file Sensor.h.

◆ status

Sensor::Status Sensor::status
read

The status of the sensor.

Due to the asynchronous nature of the underlying code, sensors are not immediately available on construction. Instead, they need to request data from the daemon and wait for it to arrive. This property reflects where in that process this sensor is.

Definition at line 82 of file Sensor.h.

◆ type

QVariant::Type Sensor::type
read

The QVariant type for this sensor.

This is used to create proper default values.

Definition at line 73 of file Sensor.h.

◆ unit

Unit Sensor::unit
read

The unit of this Sensor.

Definition at line 59 of file Sensor.h.

◆ updateInterval

uint Sensor::updateInterval
read

The time in milliseconds between each update of the sensor.

This is primarily intended to match sampling rate to the update rate of the sensor, like when used by KQuickCharts's HistorySource.

Note
Currently, the update rate of the backend is fixed and this method simply matches the value from the backend. Eventually the idea is that we can support per-sensor update rates.

Definition at line 108 of file Sensor.h.

◆ updateRateLimit

int Sensor::updateRateLimit
readwrite

The minimum time between updates, in milliseconds.

If this is set to a positive non-zero value, at least this many milliseconds need to elapse before another value update happens, otherwise it is ignored. This effectively rate-limits the updates and will prevent value updates.

Definition at line 117 of file Sensor.h.

◆ value

KSysGuard::Sensor::value
read

The current value of this sensor.

A formatted version of.

Definition at line 86 of file Sensor.h.

Constructor & Destructor Documentation

◆ Sensor()

Sensor::Sensor ( const SensorQuery query,
int  index,
QObject parent = nullptr 
)

Construct a Sensor from a SensorQuery result and index.

This avoids an extra lookup for the sensor metadata.

Definition at line 61 of file Sensor.cpp.

Member Function Documentation

◆ metaDataChanged()

Q_SIGNAL void KSysGuard::Sensor::metaDataChanged ( ) const

This signal is emitted when any of the metadata properties change.

◆ value()

QVariant KSysGuard::Sensor::value ( ) const

Returns the output of the sensor.

The returned value is the most recent sensor data received from the ksysguard daemon, it's not necessarily the actual current output value.

The client can't control how often the sensor data is sampled. The ksysguard daemon is in charge of picking the sample rate. When the Sensor receives new output value, dataChanged signal will be emitted.

See also
dataChanged

The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Feb 7 2023 04:18:49 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.