QGIS API Documentation  2.99.0-Master (d55fa22)
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 
64 class CORE_EXPORT QgsGPSConnection : public QObject
65 {
66  Q_OBJECT
67  public:
68 
69  enum Status
70  {
74  GPSDataReceived
75  };
76 
80  QgsGPSConnection( QIODevice *dev SIP_TRANSFER );
81  virtual ~QgsGPSConnection();
83  bool connect();
85  bool close();
86 
88  void setSource( QIODevice *source SIP_TRANSFER );
89 
91  Status status() const { return mStatus; }
92 
94  QgsGPSInformation currentGPSInformation() const { return mLastGPSInformation; }
95 
96  signals:
97  void stateChanged( const QgsGPSInformation &info );
98  void nmeaSentenceReceived( const QString &substring ); // added to capture 'raw' data
99 
100  protected:
102  QIODevice *mSource = nullptr;
107 
108  private:
110  void cleanupSource();
111  void clearLastGPSInformation();
112 
113  protected slots:
115  virtual void parseData() = 0;
116 };
117 
118 #endif // QGSGPSCONNECTION_H
Status mStatus
Connection status.
QList< QgsSatelliteInfo > satellitesInView
QList< int > satPrn
Abstract base class for connection to a GPS device.
QgsGPSInformation mLastGPSInformation
Last state of the gps related variables (e.g. position, time, ...)
#define SIP_TRANSFER
Definition: qgis_sip.h:24
QgsGPSInformation currentGPSInformation() const
Returns the current gps information (lat, lon, etc.)
Status status() const
Returns the status. Possible state are not connected, connected, data received.