KSysGuard::Sensor

Search for usage in LXR

KSysGuard::Sensor Class Reference

#include <Sensor.h>

Inheritance diagram for KSysGuard::Sensor:

Public Types

enum class  Status {
  Unknown , Loading , Ready , Error ,
  Removed
}
 
- Public Types inherited from QObject
typedef  QObjectList
 

Properties

QString description
 
bool enabled
 
QString formattedValue
 
qreal maximum
 
qreal minimum
 
QString name
 
QML_ELEMENTQString 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)
 
QBindable< QStringbindableObjectName ()
 
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 () const const
 
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 QRegularExpression &re, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isQuickItemType () const const
 
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_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_GADGET_EXPORT (EXPORT_MACRO)
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_MOC_INCLUDE Q_MOC_INCLUDE
 
 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
 
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 setObjectName (QAnyStringView name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool setProperty (const char *name, QVariant &&value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds interval, Qt::TimerType timerType)
 
QThreadthread () const const
 
- Public Member Functions inherited from QQmlParserStatus

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)
 
- 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 34 of file Sensor.h.

Member Enumeration Documentation

◆ Status

enum class KSysGuard::Sensor::Status
strong

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 125 of file Sensor.h.

Property Documentation

◆ description

QString KSysGuard::Sensor::description
read

A description of the Sensor.

Definition at line 57 of file Sensor.h.

◆ enabled

bool KSysGuard::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 99 of file Sensor.h.

◆ formattedValue

QString KSysGuard::Sensor::formattedValue
read

Definition at line 92 of file Sensor.h.

◆ maximum

qreal KSysGuard::Sensor::maximum
read

The maximum value this Sensor can have.

Definition at line 69 of file Sensor.h.

◆ minimum

qreal KSysGuard::Sensor::minimum
read

The minimum value this Sensor can have.

Definition at line 65 of file Sensor.h.

◆ name

QString KSysGuard::Sensor::name
read

The user-visible name of this Sensor.

Definition at line 47 of file Sensor.h.

◆ sensorId

QML_ELEMENTQString KSysGuard::Sensor::sensorId
readwrite

The path to the backend sensor this Sensor represents.

Definition at line 43 of file Sensor.h.

◆ shortName

QString KSysGuard::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 53 of file Sensor.h.

◆ status

Status KSysGuard::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 84 of file Sensor.h.

◆ type

QVariant::Type KSysGuard::Sensor::type
read

The QVariant type for this sensor.

This is used to create proper default values.

Definition at line 75 of file Sensor.h.

◆ unit

KSysGuard::Unit KSysGuard::Sensor::unit
read

The unit of this Sensor.

Definition at line 61 of file Sensor.h.

◆ updateInterval

uint KSysGuard::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 110 of file Sensor.h.

◆ updateRateLimit

int KSysGuard::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 119 of file Sensor.h.

◆ value

QVariant KSysGuard::Sensor::value
read

The current value of this sensor.

A formatted version of.

Definition at line 88 of file Sensor.h.

Constructor & Destructor Documentation

◆ Sensor() [1/3]

Sensor::Sensor ( QObject * parent = nullptr)
explicit

Definition at line 45 of file Sensor.cpp.

◆ Sensor() [2/3]

Sensor::Sensor ( const QString & id,
QObject * parent = nullptr )
explicit

Definition at line 50 of file Sensor.cpp.

◆ Sensor() [3/3]

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.

◆ ~Sensor()

Sensor::~Sensor ( )
override

Definition at line 85 of file Sensor.cpp.

Member Function Documentation

◆ classBegin()

void Sensor::classBegin ( )
overridevirtual

Implements QQmlParserStatus.

Definition at line 241 of file Sensor.cpp.

◆ componentComplete()

void Sensor::componentComplete ( )
overridevirtual

Implements QQmlParserStatus.

Definition at line 246 of file Sensor.cpp.

◆ description()

QString Sensor::description ( ) const

Definition at line 143 of file Sensor.cpp.

◆ enabled()

bool Sensor::enabled ( ) const

Definition at line 181 of file Sensor.cpp.

◆ event()

bool Sensor::event ( QEvent * event)
overridevirtual

Reimplemented from QObject.

Definition at line 72 of file Sensor.cpp.

◆ formattedValue()

QString Sensor::formattedValue ( ) const

Definition at line 176 of file Sensor.cpp.

◆ maximum()

qreal Sensor::maximum ( ) const

Definition at line 158 of file Sensor.cpp.

◆ metaDataChanged()

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

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

◆ minimum()

qreal Sensor::minimum ( ) const

Definition at line 153 of file Sensor.cpp.

◆ name()

QString Sensor::name ( ) const

Definition at line 129 of file Sensor.cpp.

◆ resetUpdateRateLimit()

void KSysGuard::Sensor::resetUpdateRateLimit ( )

Definition at line 236 of file Sensor.cpp.

◆ sensorId()

QString Sensor::sensorId ( ) const

Definition at line 90 of file Sensor.cpp.

◆ setEnabled()

void Sensor::setEnabled ( bool newEnabled)

Definition at line 193 of file Sensor.cpp.

◆ setSensorId()

void Sensor::setSensorId ( const QString & id)

Definition at line 95 of file Sensor.cpp.

◆ setUpdateRateLimit()

void Sensor::setUpdateRateLimit ( int newUpdateRateLimit)

Definition at line 214 of file Sensor.cpp.

◆ shortName()

QString Sensor::shortName ( ) const

Definition at line 134 of file Sensor.cpp.

◆ status()

Sensor::Status Sensor::status ( ) const

Definition at line 124 of file Sensor.cpp.

◆ type()

QVariant::Type Sensor::type ( ) const

Definition at line 163 of file Sensor.cpp.

◆ unit()

Unit Sensor::unit ( ) const

Definition at line 148 of file Sensor.cpp.

◆ updateInterval()

uint Sensor::updateInterval ( ) const

Definition at line 203 of file Sensor.cpp.

◆ updateRateLimit()

int Sensor::updateRateLimit ( ) const

Definition at line 209 of file Sensor.cpp.

◆ value()

QVariant 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

Definition at line 168 of file Sensor.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:58:30 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.