Class: QgsAbstractSensor¶
An abstract base class for sensors.
Added in version 3.32.
Note
This is an abstract class, with methods which must be implemented by a subclass.
The following methods must be implemented: handleConnect()
, handleDisconnect()
Class Hierarchy¶
Base classes¶
Subclasses¶
An abstract class for QIODevice-based sensors. |
Abstract Methods
Handles the connection to the sensor. |
|
Handles the disconnection from the sensor. |
Methods
Connects the sensor to its source. |
|
Returns the latest captured data from the sensor. |
|
Disconnects the sensor from its source. |
|
Returns the last error message. |
|
Returns the sensor ID. |
|
Returns the user-friendly name identifying the sensor. |
|
Restores generic sensor details from a DOM element. |
|
Sets the latest captured data from the sensor. |
|
Sets the user-friendly name identfying the sensor. |
|
Sets the current sensor status. |
|
Returns the current sensor status. |
|
Write generic sensor properties into a DOM element. |
Virtual Methods
In PyQGIS, only methods marked as virtual
can be safely overridden in a Python subclass of QgsAbstractSensor. See the FAQ for more details.
Restores specific sensor type properties from a DOM element. |
|
Returns the sensor type. |
|
Write specific sensor type properties into a DOM element. |
Signals
Emitted when the captured sensor data has changed. |
|
Emitted when an error has occurred. |
|
Emitted when the sensor name has changed. |
|
Emitted when the sensor status has changed. |
- class qgis.core.QgsAbstractSensor[source]¶
Bases:
QObject
- __init__(parent: QObject | None = None)
Constructor for an abstract sensor, bound to the specified
parent
.- Parameters:
parent (Optional[QObject] = None)
- class SensorData¶
Bases:
object
Contains details of a sensor data capture
- lastTimestamp: QDateTime¶
Timestamp of last captured sensor value
- lastValue: object¶
Last captured sensor value stored as a QVariant.
Note
The member can store multiple values if the sensor passes on a QVariantMap.
- data(self) QgsAbstractSensor.SensorData [source]¶
Returns the latest captured data from the sensor.
- Return type:
- signal errorOccurred(errorString: str)[source]¶
Emitted when an error has occurred. The
errorString
describes the error.- Parameters:
errorString (str)
- abstract handleConnect(self)[source]¶
Handles the connection to the sensor.
Note
Triggered by calling
connectSensor()
- abstract handleDisconnect(self)[source]¶
Handles the disconnection from the sensor.
Note
Triggered by calling
disconnectSensor()
- id(self) str [source]¶
Returns the sensor ID.
Note
This is a autogenerated unique string identifying an individual sensor.
- Return type:
str
- virtual readPropertiesFromElement(self, element: QDomElement, document: QDomDocument) bool [source]¶
Restores specific sensor type properties from a DOM element.
- Parameters:
element (QDomElement) – DOM node corresponding to item (e.g. ‘Sensor’ element)
document (QDomDocument) – DOM document
- Return type:
bool
- readXml(self, element: QDomElement, document: QDomDocument) bool [source]¶
Restores generic sensor details from a DOM element.
- Parameters:
element (QDomElement) – DOM node corresponding to item (e.g. ‘Sensor’ element)
document (QDomDocument) – DOM document
- Return type:
bool
- setData(self, data: QgsAbstractSensor.SensorData)[source]¶
Sets the latest captured data from the sensor.
- Parameters:
data (QgsAbstractSensor.SensorData)
- setName(self, name: str | None)[source]¶
Sets the user-friendly name identfying the sensor.
- Parameters:
name (Optional[str])
- setStatus(self, status: Qgis.DeviceConnectionStatus)[source]¶
Sets the current sensor
status
.- Parameters:
status (Qgis.DeviceConnectionStatus)
- status(self) Qgis.DeviceConnectionStatus [source]¶
Returns the current sensor status.
- Return type:
- virtual type(self) str [source]¶
Returns the sensor type. This will match the type string of the sensor class, as used by
QgsSensorRegistry
.- Return type:
str
- virtual writePropertiesToElement(self, element: QDomElement, document: QDomDocument) bool [source]¶
Write specific sensor type properties into a DOM element.
- Parameters:
element (QDomElement) – DOM node corresponding to item (e.g. ‘Sensor’ element)
document (QDomDocument) – DOM document
- Return type:
bool