16#ifndef QGSABSTRACTSENSOR_H
17#define QGSABSTRACTSENSOR_H
28using namespace Qt::StringLiterals;
46 if ( item->type() ==
"tcp_socket"_L1 &&
dynamic_cast<QgsTcpSocketSensor *
>( item ) != NULL )
48 sipType = sipType_QgsTcpSocketSensor;
50 else if ( item->type() ==
"udp_socket"_L1 &&
dynamic_cast<QgsUdpSocketSensor *
>( item ) != NULL )
52 sipType = sipType_QgsUdpSocketSensor;
54#if defined( HAVE_QTSERIALPORT )
55 else if ( item->type() ==
"serial_port"_L1 &&
dynamic_cast<QgsSerialPortSensor *
>( item ) != NULL )
57 sipType = sipType_QgsSerialPortSensor;
62 sipType = sipType_QgsAbstractSensor;
102 QString
id()
const {
return mId; }
107 virtual QString
type()
const {
return QString(); }
112 QString name()
const;
117 void setName(
const QString &name );
132 void connectSensor();
137 void disconnectSensor();
152 QString errorString()
const;
159 bool writeXml( QDomElement &parentElement, QDomDocument &document )
const;
166 bool readXml(
const QDomElement &element,
const QDomDocument &document );
173 virtual bool writePropertiesToElement( QDomElement &element, QDomDocument &document )
const;
180 virtual bool readPropertiesFromElement(
const QDomElement &element,
const QDomDocument &document );
DeviceConnectionStatus
GPS connection status.
@ Disconnected
Device is disconnected.
An abstract base class for sensors.
QString id() const
Returns the sensor ID.
QgsAbstractSensor(QObject *parent=nullptr)
Constructor for an abstract sensor, bound to the specified parent.
~QgsAbstractSensor() override=default
virtual void handleDisconnect()=0
Handles the disconnection from the sensor.
void statusChanged()
Emitted when the sensor status has changed.
virtual QString type() const
Returns the sensor type.
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.
QgsAbstractSensor::SensorData mData
QString errorString() const
Returns the last error message.
virtual void handleConnect()=0
Handles the connection to the sensor.
void dataChanged()
Emitted when the captured sensor data has changed.
A TCP socket sensor class.
A UDP socket sensor class.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Q_DECLARE_METATYPE(QgsDatabaseQueryLogEntry)
Contains details of a sensor data capture.
QVariant lastValue
Last captured sensor value stored as a QVariant.
QDateTime lastTimestamp
Timestamp of last captured sensor value.