QGIS API Documentation 3.32.0-Lima (311a8cb8a6)
Signals | Public Member Functions | List of all members
QgsSensorManager Class Reference

Manages sensors. More...

#include <qgssensormanager.h>

Inheritance diagram for QgsSensorManager:
Inheritance graph
[legend]

Signals

void sensorAboutToBeRemoved (const QString &id)
 Emitted when a sensor is about to be removed. More...
 
void sensorAdded (const QString &id)
 Emitted when a sensor has been registered. More...
 
void sensorDataCaptured (const QString &id)
 Emitted when newly captured data from a sensor has occurred. More...
 
void sensorErrorOccurred (const QString &id)
 Emitted when a sensor error has occurred. More...
 
void sensorNameChanged (const QString &id)
 Emitted when a sensor name has changed. More...
 
void sensorRemoved (const QString &id)
 Emitted when a sensor has been removed. More...
 
void sensorStatusChanged (const QString &id)
 Emitted when a sensor status has changed. More...
 

Public Member Functions

 QgsSensorManager (QObject *parent=nullptr)
 Constructor for QgsSensorManager, with the specified parent object. More...
 
 ~QgsSensorManager () override
 
void addSensor (QgsAbstractSensor *sensor)
 Registers a new sensor. More...
 
void clear ()
 Deregisters and removes all sensors from the manager. More...
 
bool readXml (const QDomElement &element, const QDomDocument &document)
 Reads the manager's state from a DOM element, restoring all sensors present in the XML document. More...
 
bool removeSensor (const QString &id)
 Removes a registered sensor matching a given id. More...
 
QgsAbstractSensorsensor (const QString &id) const
 Returns a registered sensor pointer matching a given id. More...
 
QgsAbstractSensor::SensorData sensorData (const QString &name) const
 Returns the last captured data from a registered sensor matching a given name. More...
 
QStringList sensorNames () const
 Returns a list of registered sensor names. More...
 
QList< QgsAbstractSensor * > sensors () const
 Returns a list of pointers to all registered sensors. More...
 
QMap< QString, QgsAbstractSensor::SensorDatasensorsData () const
 Returns the last captured data of all registered sensors. More...
 
QDomElement writeXml (QDomDocument &document) const
 Returns a DOM element representing the state of the manager. More...
 

Detailed Description

Manages sensors.

QgsSensorManager handles the storage, serializing and deserializing of sensors. Usually this class is not constructed directly, but rather accessed through a QgsProject via QgsProject::sensorManager().

Since
QGIS 3.32

Definition at line 41 of file qgssensormanager.h.

Constructor & Destructor Documentation

◆ QgsSensorManager()

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

Constructor for QgsSensorManager, with the specified parent object.

Definition at line 21 of file qgssensormanager.cpp.

◆ ~QgsSensorManager()

QgsSensorManager::~QgsSensorManager ( )
override

Definition at line 26 of file qgssensormanager.cpp.

Member Function Documentation

◆ addSensor()

void QgsSensorManager::addSensor ( QgsAbstractSensor sensor)

Registers a new sensor.

The sensor name does not require uniqueness; sensors will the same name will store their data in the same sensor name key, allowing for registration of sensors to cover multiple devices (e.g. two serial port sensors with alternative port name to cover two machines).

Note
Takes ownership of the sensor.

Definition at line 83 of file qgssensormanager.cpp.

◆ clear()

void QgsSensorManager::clear ( )

Deregisters and removes all sensors from the manager.

Definition at line 31 of file qgssensormanager.cpp.

◆ readXml()

bool QgsSensorManager::readXml ( const QDomElement &  element,
const QDomDocument &  document 
)

Reads the manager's state from a DOM element, restoring all sensors present in the XML document.

See also
writeXml()

Definition at line 160 of file qgssensormanager.cpp.

◆ removeSensor()

bool QgsSensorManager::removeSensor ( const QString &  id)

Removes a registered sensor matching a given id.

Returns
true if a sensor was removed.

Definition at line 99 of file qgssensormanager.cpp.

◆ sensor()

QgsAbstractSensor * QgsSensorManager::sensor ( const QString &  id) const

Returns a registered sensor pointer matching a given id.

If not matching sensor is found, a nullptr will be returned.

Definition at line 50 of file qgssensormanager.cpp.

◆ sensorAboutToBeRemoved

void QgsSensorManager::sensorAboutToBeRemoved ( const QString &  id)
signal

Emitted when a sensor is about to be removed.

◆ sensorAdded

void QgsSensorManager::sensorAdded ( const QString &  id)
signal

Emitted when a sensor has been registered.

◆ sensorData()

QgsAbstractSensor::SensorData QgsSensorManager::sensorData ( const QString &  name) const

Returns the last captured data from a registered sensor matching a given name.

Definition at line 63 of file qgssensormanager.cpp.

◆ sensorDataCaptured

void QgsSensorManager::sensorDataCaptured ( const QString &  id)
signal

Emitted when newly captured data from a sensor has occurred.

◆ sensorErrorOccurred

void QgsSensorManager::sensorErrorOccurred ( const QString &  id)
signal

Emitted when a sensor error has occurred.

◆ sensorNameChanged

void QgsSensorManager::sensorNameChanged ( const QString &  id)
signal

Emitted when a sensor name has changed.

◆ sensorNames()

QStringList QgsSensorManager::sensorNames ( ) const

Returns a list of registered sensor names.

Definition at line 73 of file qgssensormanager.cpp.

◆ sensorRemoved

void QgsSensorManager::sensorRemoved ( const QString &  id)
signal

Emitted when a sensor has been removed.

◆ sensors()

QList< QgsAbstractSensor * > QgsSensorManager::sensors ( ) const

Returns a list of pointers to all registered sensors.

Definition at line 45 of file qgssensormanager.cpp.

◆ sensorsData()

QMap< QString, QgsAbstractSensor::SensorData > QgsSensorManager::sensorsData ( ) const

Returns the last captured data of all registered sensors.

Definition at line 68 of file qgssensormanager.cpp.

◆ sensorStatusChanged

void QgsSensorManager::sensorStatusChanged ( const QString &  id)
signal

Emitted when a sensor status has changed.

◆ writeXml()

QDomElement QgsSensorManager::writeXml ( QDomDocument &  document) const

Returns a DOM element representing the state of the manager.

See also
readXml()

Definition at line 188 of file qgssensormanager.cpp.


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