Class: QgsSensorManager

class qgis.core.QgsSensorManager

Bases: PyQt5.QtCore.QObject

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.

QgsSensorManager(parent: Optional[QObject] = None) Constructor for QgsSensorManager, with the specified parent object.

Methods

addSensor

Registers a new sensor.

childEvent

clear

Deregisters and removes all sensors from the manager.

connectNotify

customEvent

disconnectNotify

isSignalConnected

readXml

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

receivers

removeSensor

Removes a registered sensor matching a given id.

sender

senderSignalIndex

sensor

Returns a registered sensor pointer matching a given id.

sensorData

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

sensorNames

Returns a list of registered sensor names.

sensors

Returns a list of pointers to all registered sensors.

sensorsData

Returns the last captured data of all registered sensors.

timerEvent

writeXml

Returns a DOM element representing the state of the manager.

Signals

sensorAboutToBeRemoved

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

sensorAdded

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

sensorDataCaptured

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

sensorErrorOccurred

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

sensorNameChanged

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

sensorRemoved

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

sensorStatusChanged

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

addSensor(self, sensor: QgsAbstractSensor | None)

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])

childEvent(self, a0: QChildEvent | None)
clear(self)

Deregisters and removes all sensors from the manager.

connectNotify(self, signal: QMetaMethod)
customEvent(self, a0: QEvent | None)
disconnectNotify(self, signal: QMetaMethod)
isSignalConnected(self, signal: QMetaMethod) bool
readXml(self, element: QDomElement, document: QDomDocument) bool

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

receivers(self, signal: PYQT_SIGNAL) int
removeSensor(self, id: str | None) bool

Removes a registered sensor matching a given id.

Return type:

bool

Returns:

True if a sensor was removed.

Parameters:

id (Optional[str])

sender(self) QObject | None
senderSignalIndex(self) int
sensor(self, id: str | None) QgsAbstractSensor | None

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]

sensorAboutToBeRemoved

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.

Parameters:
  • name (str = ...)

  • revision (int = ...)

  • arguments (Sequence = ...)

Return type:

PYQT_SIGNAL

sensorAdded

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.

Parameters:
  • name (str = ...)

  • revision (int = ...)

  • arguments (Sequence = ...)

Return type:

PYQT_SIGNAL

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

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

Parameters:

name (Optional[str])

Return type:

QgsAbstractSensor.SensorData

sensorDataCaptured

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.

Parameters:
  • name (str = ...)

  • revision (int = ...)

  • arguments (Sequence = ...)

Return type:

PYQT_SIGNAL

sensorErrorOccurred

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.

Parameters:
  • name (str = ...)

  • revision (int = ...)

  • arguments (Sequence = ...)

Return type:

PYQT_SIGNAL

sensorNameChanged

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.

Parameters:
  • name (str = ...)

  • revision (int = ...)

  • arguments (Sequence = ...)

Return type:

PYQT_SIGNAL

sensorNames(self) List[str]

Returns a list of registered sensor names.

Return type:

List[str]

sensorRemoved

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.

Parameters:
  • name (str = ...)

  • revision (int = ...)

  • arguments (Sequence = ...)

Return type:

PYQT_SIGNAL

sensorStatusChanged

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.

Parameters:
  • name (str = ...)

  • revision (int = ...)

  • arguments (Sequence = ...)

Return type:

PYQT_SIGNAL

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]

timerEvent(self, a0: QTimerEvent | None)
writeXml(self, document: QDomDocument) QDomElement

Returns a DOM element representing the state of the manager.

See also

readXml()

Parameters:

document (QDomDocument)

Return type:

QDomElement