| 1 | #ifndef BNSEPH_H
|
|---|
| 2 | #define BNSEPH_H
|
|---|
| 3 |
|
|---|
| 4 | #include <math.h>
|
|---|
| 5 | #include <newmat.h>
|
|---|
| 6 |
|
|---|
| 7 | #include <QtCore>
|
|---|
| 8 | #include <QThread>
|
|---|
| 9 | #include <QtNetwork>
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 | class t_eph {
|
|---|
| 13 | public:
|
|---|
| 14 | virtual ~t_eph() {};
|
|---|
| 15 |
|
|---|
| 16 | bool isNewerThan(const t_eph* eph) const;
|
|---|
| 17 | QString prn() const {return _prn;}
|
|---|
| 18 |
|
|---|
| 19 | virtual void position(int GPSweek, double GPSweeks, ColumnVector& xc,
|
|---|
| 20 | ColumnVector& vv) const = 0;
|
|---|
| 21 | virtual void read(const QStringList& lines) = 0;
|
|---|
| 22 | virtual int IOD() const = 0;
|
|---|
| 23 | virtual int RTCM3(unsigned char *) = 0;
|
|---|
| 24 | protected:
|
|---|
| 25 | QString _prn;
|
|---|
| 26 | int _GPSweek;
|
|---|
| 27 | double _GPSweeks;
|
|---|
| 28 | };
|
|---|
| 29 |
|
|---|
| 30 | class t_ephGlo : public t_eph {
|
|---|
| 31 | public:
|
|---|
| 32 | t_ephGlo() {
|
|---|
| 33 | _gps_utc = 0.0;
|
|---|
| 34 | _xv.ReSize(6);
|
|---|
| 35 | };
|
|---|
| 36 | virtual ~t_ephGlo() {};
|
|---|
| 37 | virtual void read(const QStringList& lines);
|
|---|
| 38 | virtual void position(int GPSweek, double GPSweeks, ColumnVector& xc,
|
|---|
| 39 | ColumnVector& vv) const;
|
|---|
| 40 | virtual int IOD() const;
|
|---|
| 41 | virtual int RTCM3(unsigned char *);
|
|---|
| 42 | private:
|
|---|
| 43 | static ColumnVector glo_deriv(double /* tt */, const ColumnVector& xv);
|
|---|
| 44 | mutable double _tt; // time in seconds of GPSweek
|
|---|
| 45 | mutable ColumnVector _xv; // status vector (position, velocity) at time _tt
|
|---|
| 46 | double _gps_utc; // GPS - UTC in seconds
|
|---|
| 47 |
|
|---|
| 48 | double _E; // [days]
|
|---|
| 49 | double _tau; // [s]
|
|---|
| 50 | double _gamma; //
|
|---|
| 51 | double _x_pos; // [km]
|
|---|
| 52 | double _x_velocity; // [km/s]
|
|---|
| 53 | double _x_acceleration; // [km/s^2]
|
|---|
| 54 | double _y_pos; // [km]
|
|---|
| 55 | double _y_velocity; // [km/s]
|
|---|
| 56 | double _y_acceleration; // [km/s^2]
|
|---|
| 57 | double _z_pos; // [km]
|
|---|
| 58 | double _z_velocity; // [km/s]
|
|---|
| 59 | double _z_acceleration; // [km/s^2]
|
|---|
| 60 | double _health; // 0 = O.K.
|
|---|
| 61 | double _frequency_number; // ICD-GLONASS data position
|
|---|
| 62 | double _tki; // message frame time
|
|---|
| 63 | };
|
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 | class t_ephGPS : public t_eph {
|
|---|
| 67 | public:
|
|---|
| 68 | t_ephGPS() {};
|
|---|
| 69 | virtual ~t_ephGPS() {};
|
|---|
| 70 | virtual void read(const QStringList& lines);
|
|---|
| 71 | virtual void position(int GPSweek, double GPSweeks, ColumnVector& xc,
|
|---|
| 72 | ColumnVector& vv) const;
|
|---|
| 73 | virtual int IOD() const {return int(_IODE);}
|
|---|
| 74 | virtual int RTCM3(unsigned char *);
|
|---|
| 75 | private:
|
|---|
| 76 | double _TOW; // [s]
|
|---|
| 77 | double _TOC; // [s]
|
|---|
| 78 | double _TOE; // [s]
|
|---|
| 79 | double _IODE;
|
|---|
| 80 | double _IODC;
|
|---|
| 81 |
|
|---|
| 82 | double _clock_bias; // [s]
|
|---|
| 83 | double _clock_drift; // [s/s]
|
|---|
| 84 | double _clock_driftrate; // [s/s^2]
|
|---|
| 85 |
|
|---|
| 86 | double _Crs; // [m]
|
|---|
| 87 | double _Delta_n; // [rad/s]
|
|---|
| 88 | double _M0; // [rad]
|
|---|
| 89 | double _Cuc; // [rad]
|
|---|
| 90 | double _e; //
|
|---|
| 91 | double _Cus; // [rad]
|
|---|
| 92 | double _sqrt_A; // [m^0.5]
|
|---|
| 93 | double _Cic; // [rad]
|
|---|
| 94 | double _OMEGA0; // [rad]
|
|---|
| 95 | double _Cis; // [rad]
|
|---|
| 96 | double _i0; // [rad]
|
|---|
| 97 | double _Crc; // [m]
|
|---|
| 98 | double _omega; // [rad]
|
|---|
| 99 | double _OMEGADOT; // [rad/s]
|
|---|
| 100 | double _IDOT; // [rad/s]
|
|---|
| 101 |
|
|---|
| 102 | double _TGD; // [s]
|
|---|
| 103 | double _health; // SV health
|
|---|
| 104 | double _ura; // SV accuracy
|
|---|
| 105 | double _L2PFlag; // L2 P data flag
|
|---|
| 106 | double _L2Codes; // Codes on L2 channel
|
|---|
| 107 | };
|
|---|
| 108 |
|
|---|
| 109 | class t_bnseph : public QThread {
|
|---|
| 110 | Q_OBJECT
|
|---|
| 111 | public:
|
|---|
| 112 | t_bnseph(QObject* parent = 0);
|
|---|
| 113 | virtual ~t_bnseph();
|
|---|
| 114 | virtual void run();
|
|---|
| 115 |
|
|---|
| 116 | signals:
|
|---|
| 117 | void newEph(t_eph* eph, int nBytes);
|
|---|
| 118 | void newMessage(const QByteArray msg);
|
|---|
| 119 | void error(const QByteArray msg);
|
|---|
| 120 |
|
|---|
| 121 | private:
|
|---|
| 122 | void reconnect();
|
|---|
| 123 | void readEph();
|
|---|
| 124 | QTcpSocket* _socket;
|
|---|
| 125 | QFile* _echoFile;
|
|---|
| 126 | QTextStream* _echoStream;
|
|---|
| 127 | };
|
|---|
| 128 | #endif
|
|---|