16#ifndef QGSIODEVICESENSOR_H
17#define QGSIODEVICESENSOR_H
30#if defined( HAVE_QTSERIALPORT )
56 QIODevice *iODevice()
const;
70 virtual void parseData();
73 std::unique_ptr<QIODevice> mIODevice;
100 QString
type()
const override;
132 void socketStateChanged(
const QAbstractSocket::SocketState socketState );
133 void handleError( QAbstractSocket::SocketError error );
136 QTcpSocket *mTcpSocket =
nullptr;
166 QString
type()
const override;
198 void socketStateChanged(
const QAbstractSocket::SocketState socketState );
199 void handleError( QAbstractSocket::SocketError error );
202 std::unique_ptr<QUdpSocket> mUdpSocket;
203 QBuffer *mBuffer =
nullptr;
209#if defined( HAVE_QTSERIALPORT )
226 explicit QgsSerialPortSensor( QObject *parent =
nullptr );
227 ~QgsSerialPortSensor()
override =
default;
234 static QgsSerialPortSensor *create( QObject *parent )
SIP_FACTORY;
236 QString
type()
const override;
241 QString portName()
const;
247 void setPortName(
const QString &portName );
253 QSerialPort::BaudRate baudRate()
const;
260 void setBaudRate(
const QSerialPort::BaudRate &baudRate );
267 QByteArray delimiter()
const;
276 void setDelimiter(
const QByteArray &delimiter );
287 void parseData()
override;
291 void handleError( QSerialPort::SerialPortError error );
294 QSerialPort *mSerialPort =
nullptr;
297 QSerialPort::BaudRate mBaudRate = QSerialPort::Baud9600;
298 QByteArray mDelimiter;
299 bool mFirstDelimiterHit =
false;
300 QByteArray mDataBuffer;
QgsAbstractSensor(QObject *parent=nullptr)
Constructor for an abstract sensor, bound to the specified parent.
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 for QIODevice-based sensors.
QgsIODeviceSensor(QObject *parent=nullptr)
Constructor for a abstract QIODevice-based sensor, bound to the specified parent.
QgsTcpSocketSensor(QObject *parent=nullptr)
Constructor for a TCP socket sensor, bound to the specified parent.
void setHostName(const QString &hostName)
Sets the host name the socket connects to.
int port() const
Returns the port the socket connects to.
~QgsTcpSocketSensor() override=default
static QgsTcpSocketSensor * create(QObject *parent)
Returns a new TCP socket sensor.
void setPort(int port)
Sets the port the socket connects to.
QString hostName() const
Returns the host name the socket connects to.
~QgsUdpSocketSensor() override=default
static QgsUdpSocketSensor * create(QObject *parent)
Returns a new UDP socket sensor.
QgsUdpSocketSensor(QObject *parent=nullptr)
Constructor for a UDP socket sensor, bound to the specified parent.
void setHostName(const QString &hostName)
Sets the host name the socket connects to.
int port() const
Returns the port the socket connects to.
void setPort(int port)
Sets the port the socket connects to.
QString hostName() const
Returns the host name the socket connects to.
#define SIP_IF_FEATURE(feature)