QGIS API Documentation  2.99.0-Master (283d45a)
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 <QObject>
23 #include <QString>
24 
25 #include "qgis_core.h"
26 
27 class QIODevice;
28 
29 struct CORE_EXPORT QgsSatelliteInfo
30 {
31  int id;
32  bool inUse;
33  int elevation;
34  int azimuth;
35  int signal;
36 };
37 
38 struct CORE_EXPORT QgsGPSInformation
39 {
40  double latitude;
41  double longitude;
42  double elevation;
43  double speed; //in km/h
44  double direction;
45  QList<QgsSatelliteInfo> satellitesInView;
46  double pdop;
47  double hdop;
48  double vdop;
49  double hacc; //horizontal accurancy in meters
50  double vacc; //vertical accurancy in meters
51  QDateTime utcDateTime;
52  QChar fixMode;
53  int fixType;
54  int quality; // from GPGGA
55  int satellitesUsed; // from GPGGA
56  QChar status; // from GPRMC A,V
57  QList<int> satPrn; // list of SVs in use; needed for QgsSatelliteInfo.inUse and other uses
58  bool satInfoComplete; // based on GPGSV sentences - to be used to determine when to graph signal and satellite position
59 };
60 
63 class CORE_EXPORT QgsGPSConnection : public QObject
64 {
65  Q_OBJECT
66  public:
67 
68  enum Status
69  {
73  GPSDataReceived
74  };
75 
79  QgsGPSConnection( QIODevice* dev );
80  virtual ~QgsGPSConnection();
82  bool connect();
84  bool close();
85 
87  void setSource( QIODevice* source );
88 
90  Status status() const { return mStatus; }
91 
93  QgsGPSInformation currentGPSInformation() const { return mLastGPSInformation; }
94 
95  signals:
96  void stateChanged( const QgsGPSInformation& info );
97  void nmeaSentenceReceived( const QString& substring ); // added to capture 'raw' data
98 
99  protected:
101  QIODevice* mSource;
106 
107  private:
109  void cleanupSource();
110  void clearLastGPSInformation();
111 
112  protected slots:
114  virtual void parseData() = 0;
115 };
116 
117 #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, ...)
QgsGPSInformation currentGPSInformation() const
Returns the current gps information (lat, lon, etc.)
QIODevice * mSource
Data source (e.g. serial device, socket, file,...)
Status status() const
Returns the status. Possible state are not connected, connected, data received.