16#ifndef QGSIODEVICESENSOR_H
17#define QGSIODEVICESENSOR_H
30#if defined( HAVE_QTSERIALPORT )
56 QIODevice *iODevice()
const;
71 virtual void parseData();
75 std::unique_ptr<QIODevice> mIODevice;
105 QString
type()
const override;
110 QString hostName()
const;
116 void setHostName(
const QString &hostName );
126 void setPort(
int port );
138 void socketStateChanged(
const QAbstractSocket::SocketState socketState );
139 void handleError( QAbstractSocket::SocketError error );
143 QTcpSocket *mTcpSocket =
nullptr;
176 QString
type()
const override;
181 QString hostName()
const;
187 void setHostName(
const QString &hostName );
197 void setPort(
int port );
209 void socketStateChanged(
const QAbstractSocket::SocketState socketState );
210 void handleError( QAbstractSocket::SocketError error );
214 std::unique_ptr<QUdpSocket> mUdpSocket;
215 QBuffer *mBuffer =
nullptr;
222#if defined( HAVE_QTSERIALPORT )
241 explicit QgsSerialPortSensor( QObject *parent =
nullptr );
242 ~QgsSerialPortSensor()
override =
default;
249 static QgsSerialPortSensor *create( QObject *parent )
SIP_FACTORY;
251 QString
type()
const override;
256 QString portName()
const;
262 void setPortName(
const QString &portName );
268 QSerialPort::BaudRate baudRate()
const;
275 void setBaudRate(
const QSerialPort::BaudRate &baudRate );
282 QByteArray delimiter()
const;
291 void setDelimiter(
const QByteArray &delimiter );
303 void parseData()
override;
307 void handleError( QSerialPort::SerialPortError error );
311 QSerialPort *mSerialPort =
nullptr;
314 QSerialPort::BaudRate mBaudRate = QSerialPort::Baud9600;
315 QByteArray mDelimiter;
316 bool mFirstDelimiterHit =
false;
317 QByteArray mDataBuffer;
An abstract base class for sensor classes.
virtual void handleDisconnect()=0
Handles the disconnection from the sensor.
virtual QString type() const
Returns the sensor type.
virtual bool writePropertiesToElement(QDomElement &element, QDomDocument &document) const
Write specific sensor type properties into a DOM element.
virtual void handleConnect()=0
Handles the connection to the sensor.
virtual bool readPropertiesFromElement(const QDomElement &element, const QDomDocument &document)
Restores specific sensor type properties from a DOM element.
An abstract class QIODevice-based sensor classes.
QgsIODeviceSensor(QObject *parent=nullptr)
Constructor for a abstract QIODevice-based sensor, bound to the specified parent.
A TCP socket sensor class.
~QgsTcpSocketSensor() override=default
A UDP socket sensor class.
~QgsUdpSocketSensor() override=default
#define SIP_IF_FEATURE(feature)