QGIS API Documentation  2.3.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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.
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.
QIODevice * mSource
Data source (e.g.
QgsGPSInformation currentGPSInformation() const
Returns the current gps information (lat, lon, etc.)