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;
138 void socketStateChanged(
const QAbstractSocket::SocketState socketState );
139 void handleError( QAbstractSocket::SocketError error );
143 QTcpSocket *mTcpSocket =
nullptr;
176 QString
type()
const override;
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;
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)