QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
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 
28 class QIODevice;
29 
30 struct CORE_EXPORT QgsSatelliteInfo
31 {
32  int id;
33  bool inUse;
34  int elevation;
35  int azimuth;
36  int signal;
37 };
38 
39 struct CORE_EXPORT QgsGpsInformation
40 {
41 
46  enum FixStatus
47  {
51  Fix3D
52  };
53 
54  double latitude = 0;
55  double longitude = 0;
56  double elevation = 0;
57  double speed = 0; //in km/h
58  double direction = 0;
59  QList<QgsSatelliteInfo> satellitesInView;
60  double pdop = 0;
61  double hdop = 0;
62  double vdop = 0;
63  double hacc = -1; //horizontal accuracy in meters
64  double vacc = -1; //vertical accuracy in meters
65  QDateTime utcDateTime;
66  QChar fixMode;
67  int fixType = 0; // valid values: 1,2,3
68  int quality = -1; // from GPGGA, valid values: 0,1,2, maybe others
69  int satellitesUsed = 0; // from GPGGA
70  QChar status; // from GPRMC A,V
71  QList<int> satPrn; // list of SVs in use; needed for QgsSatelliteInfo.inUse and other uses
72  bool satInfoComplete = false; // based on GPGSV sentences - to be used to determine when to graph signal and satellite position
73 
78  bool isValid() const;
79 
84  FixStatus fixStatus() const;
85 };
86 
90 class CORE_EXPORT QgsGpsConnection : public QObject
91 {
92 #ifdef SIP_RUN
93 #include <qgsgpsdconnection.h>
94 #include <qgsnmeaconnection.h>
95 #endif
96 
97 
98 #ifdef SIP_RUN
100  if ( sipCpp->inherits( "QgsGpsdConnection" ) )
101  sipType = sipType_QgsGpsdConnection;
102  else if ( sipCpp->inherits( "QgsNmeaConnection" ) )
103  sipType = sipType_QgsNmeaConnection;
104  else
105  sipType = NULL;
106  SIP_END
107 #endif
108 
109  Q_OBJECT
110  public:
111 
112  enum Status
113  {
117  GPSDataReceived
118  };
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 
140  signals:
141  void stateChanged( const QgsGpsInformation &info );
142  void nmeaSentenceReceived( const QString &substring ); // added to capture 'raw' data
143 
144  protected:
146  QIODevice *mSource = nullptr;
151 
152  private:
154  void cleanupSource();
155  void clearLastGPSInformation();
156 
157  protected slots:
159  virtual void parseData() = 0;
160 };
161 
162 #endif // QGSGPSCONNECTION_H
QgsGpsInformation mLastGPSInformation
Last state of the gps related variables (e.g. position, time, ...)
QList< QgsSatelliteInfo > satellitesInView
QList< int > satPrn
#define SIP_TRANSFER
Definition: qgis_sip.h:36
#define SIP_END
Definition: qgis_sip.h:189
QgsGpsInformation currentGPSInformation() const
Returns the current gps information (lat, lon, etc.)
Status mStatus
Connection status.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:172
Status status() const
Returns the status. Possible state are not connected, connected, data received.
Abstract base class for connection to a GPS device.
FixStatus
GPS fix status.