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