33 const QList<QgsAbstractSensor *>
sensors = mSensors;
65 return mSensorsData.value( name );
106 mSensors.removeAll(
sensor );
118void QgsSensorManager::handleSensorNameChanged()
127void QgsSensorManager::handleSensorStatusChanged()
141void QgsSensorManager::captureSensorData()
151void QgsSensorManager::handleSensorErrorOccurred(
const QString & )
164 QDomElement sensorsElem = element;
165 if ( element.tagName() != QLatin1String(
"Sensors" ) )
167 sensorsElem = element.firstChildElement( QStringLiteral(
"Sensors" ) );
170 QDomNodeList sensorNodes = element.elementsByTagName( QStringLiteral(
"Sensor" ) );
171 for (
int i = 0; i < sensorNodes.size(); ++i )
173 const QDomElement sensorElement = sensorNodes.at( i ).toElement();
174 const QString sensorType = sensorElement.attribute( QStringLiteral(
"type" ) );
190 QDomElement sensorsElem = document.createElement( QStringLiteral(
"Sensors" ) );
@ Disconnected
Device is disconnected.
An abstract base class for sensor classes.
QString id() const
Returns the sensor ID.
Qgis::DeviceConnectionStatus status() const
Returns the current sensor status.
QgsAbstractSensor::SensorData data() const
Returns the latest captured data from the sensor.
void statusChanged()
Emitted when the sensor status has changed.
void disconnectSensor()
Disconnects the sensor from its source.
QString name() const
Returns the user-friendly name identifying the sensor.
void errorOccurred(const QString &errorString)
Emitted when an error has occurred. The errorString describes the error.
void nameChanged()
Emitted when the sensor name has changed.
bool readXml(const QDomElement &element, const QDomDocument &document)
Restores generic sensor details from a DOM element.
void dataChanged()
Emitted when the captured sensor data has changed.
bool writeXml(QDomElement &parentElement, QDomDocument &document) const
Write generic sensor properties into a DOM element.
static QgsSensorRegistry * sensorRegistry()
Returns the application's sensor registry, used for sensor types.
void addSensor(QgsAbstractSensor *sensor)
Registers a new sensor.
void sensorRemoved(const QString &id)
Emitted when a sensor has been removed.
bool removeSensor(const QString &id)
Removes a registered sensor matching a given id.
void sensorErrorOccurred(const QString &id)
Emitted when a sensor error has occurred.
QgsSensorManager(QObject *parent=nullptr)
Constructor for QgsSensorManager, with the specified parent object.
QMap< QString, QgsAbstractSensor::SensorData > sensorsData() const
Returns the last captured data of all registered sensors.
void sensorNameChanged(const QString &id)
Emitted when a sensor name has changed.
QList< QgsAbstractSensor * > sensors() const
Returns a list of pointers to all registered sensors.
void sensorDataCaptured(const QString &id)
Emitted when newly captured data from a sensor has occurred.
QDomElement writeXml(QDomDocument &document) const
Returns a DOM element representing the state of the manager.
QgsAbstractSensor * sensor(const QString &id) const
Returns a registered sensor pointer matching a given id.
QStringList sensorNames() const
Returns a list of registered sensor names.
QgsAbstractSensor::SensorData sensorData(const QString &name) const
Returns the last captured data from a registered sensor matching a given name.
void clear()
Deregisters and removes all sensors from the manager.
void sensorAdded(const QString &id)
Emitted when a sensor has been registered.
~QgsSensorManager() override
void sensorAboutToBeRemoved(const QString &id)
Emitted when a sensor is about to be removed.
void sensorStatusChanged(const QString &id)
Emitted when a sensor status has changed.
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.
QgsAbstractSensor * createSensor(const QString &type, QObject *parent=nullptr) const
Creates a new instance of a sensor given the type.
Contains details of a sensor data capture.