Skip to content

Commit 83f95b8

Browse files
committed
Add sip files for gps connection. Patch from Marcel Huber, ticket #4826
1 parent e23450e commit 83f95b8

7 files changed

+157
-0
lines changed

python/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ INCLUDE_DIRECTORIES(
2929

3030
../src/core
3131
../src/core/composer
32+
../src/core/gps
33+
../src/core/gps/qextserialport
3234
../src/core/raster
3335
../src/core/renderer
3436
../src/core/spatialindex

python/core/core.sip

+6
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,9 @@
9292
%Include qgsnetworkaccessmanager.sip
9393

9494
%Include symbology-ng-core.sip
95+
96+
%Include qgsgpsconnection.sip
97+
%Include qgsgpsconnectionregistry.sip
98+
%Include qgsgpsdconnection.sip
99+
%Include qgsnmeaconnection.sip
100+
%Include qgsgpsdetector.sip

python/core/qgsgpsconnection.sip

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
struct QgsSatelliteInfo {
2+
%TypeHeaderCode
3+
#include <qgsgpsconnection.h>
4+
%End
5+
int id;
6+
bool inUse;
7+
int elevation;
8+
int azimuth;
9+
int signal;
10+
};
11+
12+
struct QgsGPSInformation {
13+
%TypeHeaderCode
14+
#include <qgsgpsconnection.h>
15+
%End
16+
double latitude;
17+
double longitude;
18+
double elevation;
19+
double speed; //in km/h
20+
double direction;
21+
QList<QgsSatelliteInfo> satellitesInView;
22+
double pdop;
23+
double hdop;
24+
double vdop;
25+
QDateTime utcDateTime;
26+
QChar fixMode;
27+
int fixType;
28+
int quality; // from GPGGA
29+
int satellitesUsed; // from GPGGA
30+
QChar status; // from GPRMC A,V
31+
QList<int> satPrn; // list of SVs in use; needed for QgsSatelliteInfo.inUse and other uses
32+
bool satInfoComplete; // based on GPGSV sentences - to be used to determine when to graph signal and satellite position
33+
};
34+
35+
/**Abstract base class for connection to a GPS device*/
36+
class QgsGPSConnection: QObject {
37+
%TypeHeaderCode
38+
#include <qgsgpsconnection.h>
39+
%End
40+
public:
41+
enum Status {
42+
NotConnected, Connected, DataReceived, GPSDataReceived
43+
};
44+
45+
/**Constructor
46+
@param dev input device for the connection (e.g. serial device). The class takes ownership of the object
47+
@param pollIntervall update intervall in milliseconds*/
48+
QgsGPSConnection(QIODevice* dev);
49+
virtual ~QgsGPSConnection();
50+
/**Opens connection to device*/
51+
bool connect();
52+
/**Closes connection to device*/
53+
bool close();
54+
55+
/**Sets the GPS source. The class takes ownership of the device class*/
56+
void setSource(QIODevice* source);
57+
58+
/**Returns the status. Possible state are not connected, connected, data received*/
59+
Status status() const;
60+
61+
/**Returns the current gps information (lat, lon, etc.)*/
62+
QgsGPSInformation currentGPSInformation() const;
63+
64+
signals:
65+
void stateChanged( const QgsGPSInformation& info );
66+
void nmeaSentenceReceived(const QString& substring); // added to capture 'raw' data
67+
68+
protected slots:
69+
/**Parse available data source content*/
70+
virtual void parseData() = 0;
71+
};
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**A singleton class to register / unregister existing GPS connections such that the information
2+
is available to all classes and plugins*/
3+
class QgsGPSConnectionRegistry {
4+
%TypeHeaderCode
5+
#include <qgsgpsconnectionregistry.h>
6+
%End
7+
public:
8+
static QgsGPSConnectionRegistry* instance();
9+
~QgsGPSConnectionRegistry();
10+
11+
/**Inserts a connection into the registry. The connection is owned by the registry class until it is unregistered again*/
12+
void registerConnection(QgsGPSConnection* c);
13+
/**Unregisters connection. The registry does no longer own the connection*/
14+
void unregisterConnection(QgsGPSConnection* c);
15+
16+
QList<const QgsGPSConnection*> connectionList() const;
17+
18+
protected:
19+
QgsGPSConnectionRegistry();
20+
};

python/core/qgsgpsdconnection.sip

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**Evaluates NMEA sentences coming from gpsd*/
2+
class QgsGpsdConnection: QgsNMEAConnection {
3+
%TypeHeaderCode
4+
#include "qgsgpsdconnection.h"
5+
%End
6+
public:
7+
QgsGpsdConnection(QString host, qint16 port, QString device);
8+
~QgsGpsdConnection();
9+
10+
private slots:
11+
void connected();
12+
void error(QAbstractSocket::SocketError);
13+
};

python/core/qgsgpsdetector.sip

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Class to detect the GPS port
2+
class QgsGPSDetector: QObject {
3+
%TypeHeaderCode
4+
#include "qgsgpsdetector.h"
5+
%End
6+
public:
7+
QgsGPSDetector(QString portName);
8+
~QgsGPSDetector();
9+
10+
static QList<QPair<QString, QString> > availablePorts();
11+
12+
public slots:
13+
void advance();
14+
void detected(const QgsGPSInformation&);
15+
void connDestroyed(QObject *);
16+
17+
signals:
18+
void detected( QgsGPSConnection * );
19+
void detectionFailed();
20+
};

python/core/qgsnmeaconnection.sip

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**Evaluates NMEA sentences coming from a GPS device*/
2+
class QgsNMEAConnection: QgsGPSConnection {
3+
%TypeHeaderCode
4+
#include "qgsnmeaconnection.h"
5+
%End
6+
public:
7+
QgsNMEAConnection(QIODevice *dev);
8+
~QgsNMEAConnection();
9+
10+
//bool poll( QgsGPSInformation& info, int maxTime );
11+
12+
protected slots:
13+
/**Parse available data source content*/
14+
void parseData();
15+
16+
protected:
17+
/**Splits mStringBuffer into sentences and calls libnmea*/
18+
void processStringBuffer();
19+
//handle the different sentence type
20+
void processGGASentence(const char* data, int len);
21+
void processRMCSentence(const char* data, int len);
22+
void processGSVSentence(const char* data, int len);
23+
void processVTGSentence(const char* data, int len);
24+
void processGSASentence(const char* data, int len);
25+
};

0 commit comments

Comments
 (0)