Class: QgsSensorManager

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().

Added in version 3.32.

Class Hierarchy

Inheritance diagram of qgis.core.QgsSensorManager

Base classes

QObject

class qgis.core.QgsSensorManager[source]

Bases: QObject

__init__(parent: QObject | None = None)

Constructor for QgsSensorManager, with the specified parent object.

Parameters:

parent (Optional[QObject] = None)

addSensor(self, sensor: QgsAbstractSensor | None)[source]

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.

Parameters:

sensor (Optional[QgsAbstractSensor])

clear(self)[source]

Deregisters and removes all sensors from the manager.

readXml(self, element: QDomElement, document: QDomDocument) bool[source]

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

See also

writeXml()

Parameters:
  • element (QDomElement)

  • document (QDomDocument)

Return type:

bool

removeSensor(self, id: str | None) bool[source]

Removes a registered sensor matching a given id.

Return type:

bool

Returns:

True if a sensor was removed.

Parameters:

id (Optional[str])

sensor(self, id: str | None) QgsAbstractSensor | None[source]

Returns a registered sensor pointer matching a given id. If not matching sensor is found, a None will be returned.

Parameters:

id (Optional[str])

Return type:

Optional[QgsAbstractSensor]

signal sensorAboutToBeRemoved[source]

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

signal sensorAdded[source]

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

sensorData(self, name: str | None) QgsAbstractSensor.SensorData[source]

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

Parameters:

name (Optional[str])

Return type:

QgsAbstractSensor.SensorData

signal sensorDataCaptured[source]

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

signal sensorErrorOccurred[source]

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

signal sensorNameChanged[source]

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

sensorNames(self) List[str][source]

Returns a list of registered sensor names.

Return type:

List[str]

signal sensorRemoved[source]

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

signal sensorStatusChanged[source]

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

sensors(self) List[QgsAbstractSensor]

Returns a list of pointers to all registered sensors.

Return type:

List[QgsAbstractSensor]

sensorsData(self) Dict[str, QgsAbstractSensor.SensorData]

Returns the last captured data of all registered sensors.

Return type:

Dict[str, QgsAbstractSensor.SensorData]

writeXml(self, document: QDomDocument) QDomElement[source]

Returns a DOM element representing the state of the manager.

See also

readXml()

Parameters:

document (QDomDocument)

Return type:

QDomElement