Skip to content
Permalink
Browse files

Add sip files for gps connection. Patch from Marcel Huber, ticket #4826

  • Loading branch information
mhugent committed Feb 1, 2012
1 parent e23450e commit 83f95b8fa78c51cb502c2025029368820c831849
@@ -29,6 +29,8 @@ INCLUDE_DIRECTORIES(

../src/core
../src/core/composer
../src/core/gps
../src/core/gps/qextserialport
../src/core/raster
../src/core/renderer
../src/core/spatialindex
@@ -92,3 +92,9 @@
%Include qgsnetworkaccessmanager.sip

%Include symbology-ng-core.sip

%Include qgsgpsconnection.sip
%Include qgsgpsconnectionregistry.sip
%Include qgsgpsdconnection.sip
%Include qgsnmeaconnection.sip
%Include qgsgpsdetector.sip
@@ -0,0 +1,71 @@
struct QgsSatelliteInfo {
%TypeHeaderCode
#include <qgsgpsconnection.h>
%End
int id;
bool inUse;
int elevation;
int azimuth;
int signal;
};

struct QgsGPSInformation {
%TypeHeaderCode
#include <qgsgpsconnection.h>
%End
double latitude;
double longitude;
double elevation;
double speed; //in km/h
double direction;
QList<QgsSatelliteInfo> satellitesInView;
double pdop;
double hdop;
double vdop;
QDateTime utcDateTime;
QChar fixMode;
int fixType;
int quality; // from GPGGA
int satellitesUsed; // from GPGGA
QChar status; // from GPRMC A,V
QList<int> satPrn; // list of SVs in use; needed for QgsSatelliteInfo.inUse and other uses
bool satInfoComplete; // based on GPGSV sentences - to be used to determine when to graph signal and satellite position
};

/**Abstract base class for connection to a GPS device*/
class QgsGPSConnection: QObject {
%TypeHeaderCode
#include <qgsgpsconnection.h>
%End
public:
enum Status {
NotConnected, Connected, DataReceived, GPSDataReceived
};

/**Constructor
@param dev input device for the connection (e.g. serial device). The class takes ownership of the object
@param pollIntervall update intervall in milliseconds*/
QgsGPSConnection(QIODevice* dev);
virtual ~QgsGPSConnection();
/**Opens connection to device*/
bool connect();
/**Closes connection to device*/
bool close();

/**Sets the GPS source. The class takes ownership of the device class*/
void setSource(QIODevice* source);

/**Returns the status. Possible state are not connected, connected, data received*/
Status status() const;

/**Returns the current gps information (lat, lon, etc.)*/
QgsGPSInformation currentGPSInformation() const;

signals:
void stateChanged( const QgsGPSInformation& info );
void nmeaSentenceReceived(const QString& substring); // added to capture 'raw' data

protected slots:
/**Parse available data source content*/
virtual void parseData() = 0;
};
@@ -0,0 +1,20 @@
/**A singleton class to register / unregister existing GPS connections such that the information
is available to all classes and plugins*/
class QgsGPSConnectionRegistry {
%TypeHeaderCode
#include <qgsgpsconnectionregistry.h>
%End
public:
static QgsGPSConnectionRegistry* instance();
~QgsGPSConnectionRegistry();

/**Inserts a connection into the registry. The connection is owned by the registry class until it is unregistered again*/
void registerConnection(QgsGPSConnection* c);
/**Unregisters connection. The registry does no longer own the connection*/
void unregisterConnection(QgsGPSConnection* c);

QList<const QgsGPSConnection*> connectionList() const;

protected:
QgsGPSConnectionRegistry();
};
@@ -0,0 +1,13 @@
/**Evaluates NMEA sentences coming from gpsd*/
class QgsGpsdConnection: QgsNMEAConnection {
%TypeHeaderCode
#include "qgsgpsdconnection.h"
%End
public:
QgsGpsdConnection(QString host, qint16 port, QString device);
~QgsGpsdConnection();

private slots:
void connected();
void error(QAbstractSocket::SocketError);
};
@@ -0,0 +1,20 @@
// Class to detect the GPS port
class QgsGPSDetector: QObject {
%TypeHeaderCode
#include "qgsgpsdetector.h"
%End
public:
QgsGPSDetector(QString portName);
~QgsGPSDetector();

static QList<QPair<QString, QString> > availablePorts();

public slots:
void advance();
void detected(const QgsGPSInformation&);
void connDestroyed(QObject *);

signals:
void detected( QgsGPSConnection * );
void detectionFailed();
};
@@ -0,0 +1,25 @@
/**Evaluates NMEA sentences coming from a GPS device*/
class QgsNMEAConnection: QgsGPSConnection {
%TypeHeaderCode
#include "qgsnmeaconnection.h"
%End
public:
QgsNMEAConnection(QIODevice *dev);
~QgsNMEAConnection();

//bool poll( QgsGPSInformation& info, int maxTime );

protected slots:
/**Parse available data source content*/
void parseData();

protected:
/**Splits mStringBuffer into sentences and calls libnmea*/
void processStringBuffer();
//handle the different sentence type
void processGGASentence(const char* data, int len);
void processRMCSentence(const char* data, int len);
void processGSVSentence(const char* data, int len);
void processVTGSentence(const char* data, int len);
void processGSASentence(const char* data, int len);
};

0 comments on commit 83f95b8

Please sign in to comment.
You can’t perform that action at this time.