QGIS API Documentation 3.41.0-Master (cea29feecf2)
|
Manages sensors. More...
#include <qgssensormanager.h>
Signals | |
void | sensorAboutToBeRemoved (const QString &id) |
Emitted when a sensor is about to be removed. | |
void | sensorAdded (const QString &id) |
Emitted when a sensor has been registered. | |
void | sensorDataCaptured (const QString &id) |
Emitted when newly captured data from a sensor has occurred. | |
void | sensorErrorOccurred (const QString &id) |
Emitted when a sensor error has occurred. | |
void | sensorNameChanged (const QString &id) |
Emitted when a sensor name has changed. | |
void | sensorRemoved (const QString &id) |
Emitted when a sensor has been removed. | |
void | sensorStatusChanged (const QString &id) |
Emitted when a sensor status has changed. | |
Public Member Functions | |
QgsSensorManager (QObject *parent=nullptr) | |
Constructor for QgsSensorManager, with the specified parent object. | |
~QgsSensorManager () override | |
void | addSensor (QgsAbstractSensor *sensor) |
Registers a new sensor. | |
void | clear () |
Deregisters and removes all sensors from the manager. | |
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. | |
bool | removeSensor (const QString &id) |
Removes a registered sensor matching a given id. | |
QgsAbstractSensor * | sensor (const QString &id) const |
Returns a registered sensor pointer matching a given id. | |
QgsAbstractSensor::SensorData | sensorData (const QString &name) const |
Returns the last captured data from a registered sensor matching a given name. | |
QStringList | sensorNames () const |
Returns a list of registered sensor names. | |
QList< QgsAbstractSensor * > | sensors () const |
Returns a list of pointers to all registered sensors. | |
QMap< QString, QgsAbstractSensor::SensorData > | sensorsData () const |
Returns the last captured data of all registered sensors. | |
QDomElement | writeXml (QDomDocument &document) const |
Returns a DOM element representing the state of the manager. | |
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 22 of file qgssensormanager.cpp.
|
override |
Definition at line 27 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 84 of file qgssensormanager.cpp.
void QgsSensorManager::clear | ( | ) |
Deregisters and removes all sensors from the manager.
Definition at line 32 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 161 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 100 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 51 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 64 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 74 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 46 of file qgssensormanager.cpp.
QMap< QString, QgsAbstractSensor::SensorData > QgsSensorManager::sensorsData | ( | ) | const |
Returns the last captured data of all registered sensors.
Definition at line 69 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 189 of file qgssensormanager.cpp.