QGIS API Documentation  3.4.15-Madeira (e83d02e274)
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  double latitude;
42  double longitude;
43  double elevation;
44  double speed; //in km/h
45  double direction;
46  QList<QgsSatelliteInfo> satellitesInView;
47  double pdop;
48  double hdop;
49  double vdop;
50  double hacc; //horizontal accuracy in meters
51  double vacc; //vertical accuracy in meters
52  QDateTime utcDateTime;
53  QChar fixMode;
54  int fixType;
55  int quality; // from GPGGA
56  int satellitesUsed; // from GPGGA
57  QChar status; // from GPRMC A,V
58  QList<int> satPrn; // list of SVs in use; needed for QgsSatelliteInfo.inUse and other uses
59  bool satInfoComplete; // based on GPGSV sentences - to be used to determine when to graph signal and satellite position
60 };
61 
65 class CORE_EXPORT QgsGpsConnection : public QObject
66 {
67 #ifdef SIP_RUN
68 #include <qgsgpsdconnection.h>
69 #include <qgsnmeaconnection.h>
70 #endif
71 
72 
73 #ifdef SIP_RUN
75  if ( sipCpp->inherits( "QgsGpsdConnection" ) )
76  sipType = sipType_QgsGpsdConnection;
77  else if ( sipCpp->inherits( "QgsNmeaConnection" ) )
78  sipType = sipType_QgsNmeaConnection;
79  else
80  sipType = NULL;
81  SIP_END
82 #endif
83 
84  Q_OBJECT
85  public:
86 
87  enum Status
88  {
92  GPSDataReceived
93  };
94 
99  QgsGpsConnection( QIODevice *dev SIP_TRANSFER );
100  ~QgsGpsConnection() override;
102  bool connect();
104  bool close();
105 
107  void setSource( QIODevice *source SIP_TRANSFER );
108 
110  Status status() const { return mStatus; }
111 
113  QgsGpsInformation currentGPSInformation() const { return mLastGPSInformation; }
114 
115  signals:
116  void stateChanged( const QgsGpsInformation &info );
117  void nmeaSentenceReceived( const QString &substring ); // added to capture 'raw' data
118 
119  protected:
121  QIODevice *mSource = nullptr;
126 
127  private:
129  void cleanupSource();
130  void clearLastGPSInformation();
131 
132  protected slots:
134  virtual void parseData() = 0;
135 };
136 
137 #endif // QGSGPSCONNECTION_H
QgsGpsInformation mLastGPSInformation
Last state of the gps related variables (e.g. position, time, ...)
QgsGpsInformation currentGPSInformation() const
Returns the current gps information (lat, lon, etc.)
QList< QgsSatelliteInfo > satellitesInView
QList< int > satPrn
#define SIP_TRANSFER
Definition: qgis_sip.h:36
#define SIP_END
Definition: qgis_sip.h:182
Status mStatus
Connection status.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:165
Abstract base class for connection to a GPS device.
Status status() const
Returns the status. Possible state are not connected, connected, data received.