QGIS API Documentation  3.37.0-Master (a5b4d9743e8)
qgsgpsconnection.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsgpsconnection.h - description
3  -------------------
4  begin : November 30th, 2009
5  copyright : (C) 2009 by Marco Hugentobler
6  email : marco at hugis dot net
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef QGSGPSCONNECTION_H
19 #define QGSGPSCONNECTION_H
20 
21 #include <QDateTime>
22 #include "qgis.h"
23 #include <QObject>
24 #include <QString>
25 
26 #include "qgis_core.h"
27 #include "qgspoint.h"
28 #include "qgsgpsinformation.h"
29 
30 class QIODevice;
31 
36 template<class T> class QgsSettingsEntryEnumFlag;
37 
38 
39 #ifdef SIP_RUN
40 % ModuleHeaderCode
41 #include "qgsgpsconnection.h"
42 % End
43 #endif
44 
49 class CORE_EXPORT QgsGpsConnection : public QObject
50 {
51 #ifdef SIP_RUN
52 #include <qgsgpsdconnection.h>
53 #include <qgsnmeaconnection.h>
54 #endif
55 
56 
57 #ifdef SIP_RUN
59  if ( sipCpp->inherits( "QgsGpsdConnection" ) )
60  sipType = sipType_QgsGpsdConnection;
61  else if ( sipCpp->inherits( "QgsNmeaConnection" ) )
62  sipType = sipType_QgsNmeaConnection;
63  else
64  sipType = NULL;
65  SIP_END
66 #endif
67 
68  Q_OBJECT
69  public:
70 
71  enum Status
72  {
76  GPSDataReceived
77  };
78 
79 #ifndef SIP_RUN
82 
85 
88 
91 
94 
97 
100 
103 
106 
109 
112 
115 
118 #endif
119 
124  QgsGpsConnection( QIODevice *dev SIP_TRANSFER );
125  ~QgsGpsConnection() override;
127  bool connect();
129  bool close();
130 
132  void setSource( QIODevice *source SIP_TRANSFER );
133 
135  Status status() const { return mStatus; }
136 
138  QgsGpsInformation currentGPSInformation() const { return mLastGPSInformation; }
139 
145  QgsPoint lastValidLocation() const { return mLastLocation; }
146 
147  signals:
148 
152  void stateChanged( const QgsGpsInformation &info );
153 
154  // TODO QGIS 4.0 -- move to QgsNmeaConnection, it makes no sense in the base class
155 
159  void nmeaSentenceReceived( const QString &substring );
160 
167 
175  void positionChanged( const QgsPoint &point );
176 
177  protected:
179  std::unique_ptr< QIODevice > mSource;
183  Status mStatus = NotConnected;
184 
185  private slots:
186 
187  void onStateChanged( const QgsGpsInformation &info );
188 
189  private:
191  void cleanupSource();
192  void clearLastGPSInformation();
193 
194  protected slots:
196  virtual void parseData() = 0; // cppcheck-suppress pureVirtualCall
197 
198  private:
199 
202 
204  QgsPoint mLastLocation;
205 };
206 
207 #endif // QGSGPSCONNECTION_H
GpsFixStatus
GPS fix status.
Definition: qgis.h:1457
@ NoData
No fix data available.
Abstract base class for connection to a GPS device.
Status status() const
Returns the status. Possible state are not connected, connected, data received.
static const QgsSettingsEntryString * settingsGpsSerialDevice
Settings entry GPS serial device name.
static const QgsSettingsEntryEnumFlag< Qt::TimeSpec > * settingsGpsTimeStampSpecification
Settings entry time specification for GPS time stamps.
static const QgsSettingsEntryString * settingsGpsTimeStampTimeZone
Settings entry GPS time stamp time zone.
static const QgsSettingsEntryString * settingsGpsdHostName
Settings entry GPSD host name.
QgsGpsInformation mLastGPSInformation
Last state of the gps related variables (e.g. position, time, ...)
virtual void parseData()=0
Parse available data source content.
static const QgsSettingsEntryBool * settingGpsApplyLeapSecondsCorrection
Settings entry GPS apply leap seconds correction.
static const QgsSettingsEntryInteger * settingGpsLeapSeconds
Settings entry GPS leap seconds correction amount (in seconds)
QgsPoint lastValidLocation() const
Returns the last valid location obtained by the device.
static const QgsSettingsEntryEnumFlag< Qgis::GpsConnectionType > * settingsGpsConnectionType
Settings entry GPS connection type.
void positionChanged(const QgsPoint &point)
Emitted when the GPS position changes.
void nmeaSentenceReceived(const QString &substring)
Emitted whenever the GPS device receives a raw NMEA sentence.
std::unique_ptr< QIODevice > mSource
Data source (e.g. serial device, socket, file,...)
static const QgsSettingsEntryInteger * settingsGpsTimeStampOffsetFromUtc
Settings entry GPS time offset from UTC in seconds.
void fixStatusChanged(Qgis::GpsFixStatus status)
Emitted when the GPS device fix status is changed.
static const QgsSettingsEntryBool * settingGpsBearingFromTravelDirection
Settings entry GPS calculate bearing from travel direction.
static const QgsSettingsEntryInteger * settingGpsAcquisitionInterval
Settings entry GPS track point acquisition interval.
static const QgsSettingsEntryDouble * settingGpsDistanceThreshold
Settings entry GPS track point distance threshold.
static const QgsSettingsEntryString * settingsGpsdDeviceName
Settings entry GPSD device name.
QgsGpsInformation currentGPSInformation() const
Returns the current gps information (lat, lon, etc.)
void stateChanged(const QgsGpsInformation &info)
Emitted whenever the GPS state is changed.
static const QgsSettingsEntryInteger * settingsGpsdPortNumber
Settings entry GPSD port number.
Encapsulates information relating to a GPS position fix.
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:49
A boolean settings entry.
A double settings entry.
A template class for enum and flag settings entry.
An integer settings entry.
A string settings entry.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:191
#define SIP_TRANSFER
Definition: qgis_sip.h:36
#define SIP_END
Definition: qgis_sip.h:208