QGIS API Documentation 3.32.0-Lima (311a8cb8a6)
|
Manages sensors. More...
#include <qgssensormanager.h>
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... | |
QgsAbstractSensor * | sensor (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::SensorData > | sensorsData () 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... | |
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().
Definition at line 41 of file qgssensormanager.h.
|
explicit |
Constructor for QgsSensorManager, with the specified parent object.
Definition at line 21 of file qgssensormanager.cpp.
|
override |
Definition at line 26 of file qgssensormanager.cpp.
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).
Definition at line 83 of file qgssensormanager.cpp.
void QgsSensorManager::clear | ( | ) |
Deregisters and removes all sensors from the manager.
Definition at line 31 of file qgssensormanager.cpp.
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.
Definition at line 160 of file qgssensormanager.cpp.
bool QgsSensorManager::removeSensor | ( | const QString & | id | ) |
Removes a registered sensor matching a given id.
true
if a sensor was removed. Definition at line 99 of file qgssensormanager.cpp.
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.
|
signal |
Emitted when a sensor is about to be removed.
|
signal |
Emitted when a sensor has been registered.
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.
|
signal |
Emitted when newly captured data from a sensor has occurred.
|
signal |
Emitted when a sensor error has occurred.
|
signal |
Emitted when a sensor name has changed.
QStringList QgsSensorManager::sensorNames | ( | ) | const |
Returns a list of registered sensor names.
Definition at line 73 of file qgssensormanager.cpp.
|
signal |
Emitted when a sensor has been removed.
QList< QgsAbstractSensor * > QgsSensorManager::sensors | ( | ) | const |
Returns a list of pointers to all registered sensors.
Definition at line 45 of file qgssensormanager.cpp.
QMap< QString, QgsAbstractSensor::SensorData > QgsSensorManager::sensorsData | ( | ) | const |
Returns the last captured data of all registered sensors.
Definition at line 68 of file qgssensormanager.cpp.
|
signal |
Emitted when a sensor status has changed.
QDomElement QgsSensorManager::writeXml | ( | QDomDocument & | document | ) | const |
Returns a DOM element representing the state of the manager.
Definition at line 188 of file qgssensormanager.cpp.