QGIS API Documentation  2.7.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 class QIODevice;
26 
27 struct CORE_EXPORT QgsSatelliteInfo
28 {
29  int id;
30  bool inUse;
31  int elevation;
32  int azimuth;
33  int signal;
34 };
35 
36 struct CORE_EXPORT QgsGPSInformation
37 {
38  double latitude;
39  double longitude;
40  double elevation;
41  double speed; //in km/h
42  double direction;
43  QList<QgsSatelliteInfo> satellitesInView;
44  double pdop;
45  double hdop;
46  double vdop;
47  double hacc; //horizontal accurancy in meters
48  double vacc; //vertical accurancy in meters
49  QDateTime utcDateTime;
50  QChar fixMode;
51  int fixType;
52  int quality; // from GPGGA
53  int satellitesUsed; // from GPGGA
54  QChar status; // from GPRMC A,V
55  QList<int> satPrn; // list of SVs in use; needed for QgsSatelliteInfo.inUse and other uses
56  bool satInfoComplete; // based on GPGSV sentences - to be used to determine when to graph signal and satellite position
57 };
58 
60 class CORE_EXPORT QgsGPSConnection : public QObject
61 {
62  Q_OBJECT
63  public:
64 
65  enum Status
66  {
70  GPSDataReceived
71  };
72 
76  QgsGPSConnection( QIODevice* dev );
77  virtual ~QgsGPSConnection();
79  bool connect();
81  bool close();
82 
84  void setSource( QIODevice* source );
85 
87  Status status() const { return mStatus; }
88 
90  QgsGPSInformation currentGPSInformation() const { return mLastGPSInformation; }
91 
92  signals:
93  void stateChanged( const QgsGPSInformation& info );
94  void nmeaSentenceReceived( const QString& substring ); // added to capture 'raw' data
95 
96  protected:
98  QIODevice* mSource;
103 
104  private:
106  void cleanupSource();
107  void clearLastGPSInformation();
108 
109  protected slots:
111  virtual void parseData() = 0;
112 };
113 
114 #endif // QGSGPSCONNECTION_H
Status status() const
Returns the status.
Definition: qgsgpsconnection.h:87
QChar fixMode
Definition: qgsgpsconnection.h:50
Status mStatus
Connection status.
Definition: qgsgpsconnection.h:102
int fixType
Definition: qgsgpsconnection.h:51
double longitude
Definition: qgsgpsconnection.h:39
Definition: qgsgpsconnection.h:36
Status
Definition: qgsgpsconnection.h:65
QDateTime utcDateTime
Definition: qgsgpsconnection.h:49
double latitude
Definition: qgsgpsconnection.h:38
QList< QgsSatelliteInfo > satellitesInView
Definition: qgsgpsconnection.h:43
bool inUse
Definition: qgsgpsconnection.h:30
double hacc
Definition: qgsgpsconnection.h:47
int azimuth
Definition: qgsgpsconnection.h:32
int satellitesUsed
Definition: qgsgpsconnection.h:53
Definition: qgsgpsconnection.h:69
QList< int > satPrn
Definition: qgsgpsconnection.h:55
double pdop
Definition: qgsgpsconnection.h:44
double direction
Definition: qgsgpsconnection.h:42
Abstract base class for connection to a GPS device.
Definition: qgsgpsconnection.h:60
QgsGPSInformation mLastGPSInformation
Last state of the gps related variables (e.g.
Definition: qgsgpsconnection.h:100
int quality
Definition: qgsgpsconnection.h:52
Definition: qgsgpsconnection.h:27
double vacc
Definition: qgsgpsconnection.h:48
Definition: qgsgpsconnection.h:68
QIODevice * mSource
Data source (e.g.
Definition: qgsgpsconnection.h:98
Definition: qgsgpsconnection.h:67
int signal
Definition: qgsgpsconnection.h:33
int elevation
Definition: qgsgpsconnection.h:31
QgsGPSInformation currentGPSInformation() const
Returns the current gps information (lat, lon, etc.)
Definition: qgsgpsconnection.h:90
double hdop
Definition: qgsgpsconnection.h:45
QChar status
Definition: qgsgpsconnection.h:54
double speed
Definition: qgsgpsconnection.h:41
double elevation
Definition: qgsgpsconnection.h:40
int id
Definition: qgsgpsconnection.h:29
double vdop
Definition: qgsgpsconnection.h:46
bool satInfoComplete
Definition: qgsgpsconnection.h:56