Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[sensors] Fix building when WITH_SERIALPORT is false
  • Loading branch information
nirvn committed Mar 30, 2023
1 parent 95c57b1 commit f2b7751
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions python/core/auto_generated/sensor/qgsiodevicesensor.sip.in
Expand Up @@ -8,6 +8,8 @@





class QgsIODeviceSensor : QgsAbstractSensor
{
%Docstring(signature="appended")
Expand Down Expand Up @@ -182,6 +184,7 @@ Sets the ``port`` the socket connects to.

};


class QgsSerialPortSensor : QgsIODeviceSensor
{
%Docstring(signature="appended")
Expand Down
2 changes: 2 additions & 0 deletions src/core/sensor/qgsiodevicesensor.cpp
Expand Up @@ -274,6 +274,7 @@ bool QgsUdpSocketSensor::readPropertiesFromElement( const QDomElement &element,

//--------------

#if defined( HAVE_QTSERIALPORT )
QgsSerialPortSensor::QgsSerialPortSensor( QObject *parent )
: QgsIODeviceSensor( parent )
, mSerialPort( new QSerialPort() )
Expand Down Expand Up @@ -336,3 +337,4 @@ bool QgsSerialPortSensor::readPropertiesFromElement( const QDomElement &element,

return true;
}
#endif
10 changes: 9 additions & 1 deletion src/core/sensor/qgsiodevicesensor.h
Expand Up @@ -16,16 +16,21 @@
#ifndef QGSIODEVICESENSOR_H
#define QGSIODEVICESENSOR_H

#include "qgsconfig.h"

#include "qgis_core.h"
#include "qgis_sip.h"
#include "qgsabstractsensor.h"

#include <QBuffer>
#include <QDomElement>
#include <QSerialPort>
#include <QTcpSocket>
#include <QUdpSocket>

#if defined( HAVE_QTSERIALPORT )
#include <QSerialPort>
#endif

/**
* \ingroup core
* \class QgsIODeviceSensor
Expand Down Expand Up @@ -212,6 +217,8 @@ class CORE_EXPORT QgsUdpSocketSensor : public QgsIODeviceSensor

};

#if defined( HAVE_QTSERIALPORT )

/**
* \ingroup core
* \class QgsSerialPortSensor
Expand Down Expand Up @@ -266,6 +273,7 @@ class CORE_EXPORT QgsSerialPortSensor : public QgsIODeviceSensor
QString mPortName;

};
#endif

#endif //QGSIODEVICESENSOR_H

Expand Down
4 changes: 4 additions & 0 deletions src/core/sensor/qgssensorregistry.cpp
Expand Up @@ -14,6 +14,8 @@
* *
***************************************************************************/

#include "qgsconfig.h"

#include "qgssensorregistry.h"
#include "qgsiodevicesensor.h"
#include "qgsproject.h"
Expand All @@ -36,7 +38,9 @@ bool QgsSensorRegistry::populate()

addSensorType( new QgsSensorMetadata( QLatin1String( "tcp_socket" ), QObject::tr( "TCP socket sensor" ), QgsTcpSocketSensor::create ) );
addSensorType( new QgsSensorMetadata( QLatin1String( "udp_socket" ), QObject::tr( "UDP socket sensor" ), QgsUdpSocketSensor::create ) );
#if defined( HAVE_QTSERIALPORT )
addSensorType( new QgsSensorMetadata( QLatin1String( "serial_port" ), QObject::tr( "Serial port sensor" ), QgsSerialPortSensor::create ) );
#endif

return true;
}
Expand Down

0 comments on commit f2b7751

Please sign in to comment.