|
QGIS API Documentation
master-59fd5e0
|
00001 /*************************************************************************** 00002 qgsgpsconnection.h - description 00003 ------------------- 00004 begin : November 30th, 2009 00005 copyright : (C) 2009 by Marco Hugentobler 00006 email : marco at hugis dot net 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 00018 #ifndef QGSGPSCONNECTION_H 00019 #define QGSGPSCONNECTION_H 00020 00021 #include <QDateTime> 00022 #include <QObject> 00023 #include <QString> 00024 00025 class QIODevice; 00026 00027 struct CORE_EXPORT QgsSatelliteInfo 00028 { 00029 int id; 00030 bool inUse; 00031 int elevation; 00032 int azimuth; 00033 int signal; 00034 }; 00035 00036 struct CORE_EXPORT QgsGPSInformation 00037 { 00038 double latitude; 00039 double longitude; 00040 double elevation; 00041 double speed; //in km/h 00042 double direction; 00043 QList<QgsSatelliteInfo> satellitesInView; 00044 double pdop; 00045 double hdop; 00046 double vdop; 00047 double hacc; //horizontal accurancy in meters 00048 double vacc; //vertical accurancy in meters 00049 QDateTime utcDateTime; 00050 QChar fixMode; 00051 int fixType; 00052 int quality; // from GPGGA 00053 int satellitesUsed; // from GPGGA 00054 QChar status; // from GPRMC A,V 00055 QList<int> satPrn; // list of SVs in use; needed for QgsSatelliteInfo.inUse and other uses 00056 bool satInfoComplete; // based on GPGSV sentences - to be used to determine when to graph signal and satellite position 00057 }; 00058 00060 class CORE_EXPORT QgsGPSConnection : public QObject 00061 { 00062 Q_OBJECT 00063 public: 00064 00065 enum Status 00066 { 00067 NotConnected, 00068 Connected, 00069 DataReceived, 00070 GPSDataReceived 00071 }; 00072 00076 QgsGPSConnection( QIODevice* dev ); 00077 virtual ~QgsGPSConnection(); 00079 bool connect(); 00081 bool close(); 00082 00084 void setSource( QIODevice* source ); 00085 00087 Status status() const { return mStatus; } 00088 00090 QgsGPSInformation currentGPSInformation() const { return mLastGPSInformation; } 00091 00092 signals: 00093 void stateChanged( const QgsGPSInformation& info ); 00094 void nmeaSentenceReceived( const QString& substring ); // added to capture 'raw' data 00095 00096 protected: 00098 QIODevice* mSource; 00100 QgsGPSInformation mLastGPSInformation; 00102 Status mStatus; 00103 00104 private: 00106 void cleanupSource(); 00107 void clearLastGPSInformation(); 00108 00109 protected slots: 00111 virtual void parseData() = 0; 00112 }; 00113 00114 #endif // QGSGPSCONNECTION_H