1 | #ifndef EPHEMERIS_H
|
---|
2 | #define EPHEMERIS_H
|
---|
3 |
|
---|
4 | #include <newmat.h>
|
---|
5 | #include <QtCore>
|
---|
6 | #include <stdio.h>
|
---|
7 | #include <string>
|
---|
8 | #include "bnctime.h"
|
---|
9 | #include "bncconst.h"
|
---|
10 | #include "t_prn.h"
|
---|
11 | #include "gnss.h"
|
---|
12 |
|
---|
13 |
|
---|
14 | class t_orbCorr;
|
---|
15 | class t_clkCorr;
|
---|
16 |
|
---|
17 | class t_eph {
|
---|
18 | public:
|
---|
19 | enum e_type {unknown, GPS, QZSS, GLONASS, Galileo, SBAS, BDS, IRNSS};
|
---|
20 | enum e_checkState {unchecked, ok, bad, outdated, unhealthy};
|
---|
21 |
|
---|
22 | t_eph();
|
---|
23 | virtual ~t_eph();
|
---|
24 |
|
---|
25 | virtual e_type type() const = 0;
|
---|
26 | virtual QString toString(double version) const = 0;
|
---|
27 | virtual unsigned int IOD() const = 0;
|
---|
28 | virtual unsigned int isUnhealthy() const = 0;
|
---|
29 | virtual int slotNum() const {return 0;}
|
---|
30 | bncTime TOC() const {return _TOC;}
|
---|
31 | bool isNewerThan(const t_eph* eph) const {return earlierTime(eph, this);}
|
---|
32 | e_checkState checkState() const {return _checkState;}
|
---|
33 | void setCheckState(e_checkState checkState) {_checkState = checkState;}
|
---|
34 | t_prn prn() const {return _prn;}
|
---|
35 | t_irc getCrd(const bncTime& tt, ColumnVector& xc, ColumnVector& vv, bool useCorr) const;
|
---|
36 | void setOrbCorr(const t_orbCorr* orbCorr);
|
---|
37 | void setClkCorr(const t_clkCorr* clkCorr);
|
---|
38 | const QDateTime& receptDateTime() const {return _receptDateTime;}
|
---|
39 | static QString rinexDateStr(const bncTime& tt, const t_prn& prn, double version);
|
---|
40 | static QString rinexDateStr(const bncTime& tt, const QString& prnStr, double version);
|
---|
41 | static bool earlierTime(const t_eph* eph1, const t_eph* eph2) {return eph1->_TOC < eph2->_TOC;}
|
---|
42 |
|
---|
43 | protected:
|
---|
44 | virtual t_irc position(int GPSweek, double GPSweeks, double* xc, double* vv) const = 0;
|
---|
45 | t_prn _prn;
|
---|
46 | bncTime _TOC;
|
---|
47 | QDateTime _receptDateTime;
|
---|
48 | e_checkState _checkState;
|
---|
49 | t_orbCorr* _orbCorr;
|
---|
50 | t_clkCorr* _clkCorr;
|
---|
51 | };
|
---|
52 |
|
---|
53 |
|
---|
54 | class t_ephGPS : public t_eph {
|
---|
55 | friend class t_ephEncoder;
|
---|
56 | friend class RTCM3Decoder;
|
---|
57 | public:
|
---|
58 | t_ephGPS() {
|
---|
59 | _clock_bias = 0.0;
|
---|
60 | _clock_drift = 0.0;
|
---|
61 | _clock_driftrate = 0.0;
|
---|
62 | _IODE = 0.0;
|
---|
63 | _Crs = 0.0;
|
---|
64 | _Delta_n = 0.0;
|
---|
65 | _M0 = 0.0;
|
---|
66 | _Cuc = 0.0;
|
---|
67 | _e = 0.0;
|
---|
68 | _Cus = 0.0;
|
---|
69 | _sqrt_A = 0.0;
|
---|
70 | _TOEsec = 0.0;
|
---|
71 | _Cic = 0.0;
|
---|
72 | _OMEGA0 = 0.0;
|
---|
73 | _Cis = 0.0;
|
---|
74 | _i0 = 0.0;
|
---|
75 | _Crc = 0.0;
|
---|
76 | _omega = 0.0;
|
---|
77 | _OMEGADOT = 0.0;
|
---|
78 | _IDOT = 0.0;
|
---|
79 | _L2Codes = 0.0;
|
---|
80 | _TOEweek = 0.0;
|
---|
81 | _L2PFlag = 0.0;
|
---|
82 | _ura = 0.0;
|
---|
83 | _health = 0.0;
|
---|
84 | _TGD = 0.0;
|
---|
85 | _IODC = 0.0;
|
---|
86 | _TOT = 0.0;
|
---|
87 | _fitInterval = 0.0;
|
---|
88 | }
|
---|
89 | t_ephGPS(float rnxVersion, const QStringList& lines);
|
---|
90 | virtual ~t_ephGPS() {}
|
---|
91 |
|
---|
92 | virtual e_type type() const {
|
---|
93 | switch (_prn.system()) {
|
---|
94 | case 'J':
|
---|
95 | return t_eph::QZSS;
|
---|
96 | case 'I':
|
---|
97 | return t_eph::IRNSS;
|
---|
98 | };
|
---|
99 | return t_eph::GPS;
|
---|
100 | }
|
---|
101 | virtual QString toString(double version) const;
|
---|
102 | virtual unsigned int IOD() const { return static_cast<unsigned int>(_IODE); }
|
---|
103 | virtual unsigned int isUnhealthy() const { return static_cast<unsigned int>(_health); }
|
---|
104 | double TGD() const {return _TGD;} // Timing Group Delay (P1-P2 DCB)
|
---|
105 |
|
---|
106 | private:
|
---|
107 | virtual t_irc position(int GPSweek, double GPSweeks, double* xc, double* vv) const;
|
---|
108 |
|
---|
109 | double _clock_bias; // [s]
|
---|
110 | double _clock_drift; // [s/s]
|
---|
111 | double _clock_driftrate; // [s/s^2]
|
---|
112 |
|
---|
113 | double _IODE; // IODEC in case of IRNSS
|
---|
114 | double _Crs; // [m]
|
---|
115 | double _Delta_n; // [rad/s]
|
---|
116 | double _M0; // [rad]
|
---|
117 |
|
---|
118 | double _Cuc; // [rad]
|
---|
119 | double _e; //
|
---|
120 | double _Cus; // [rad]
|
---|
121 | double _sqrt_A; // [m^0.5]
|
---|
122 |
|
---|
123 | double _TOEsec; // [s]
|
---|
124 | double _Cic; // [rad]
|
---|
125 | double _OMEGA0; // [rad]
|
---|
126 | double _Cis; // [rad]
|
---|
127 |
|
---|
128 | double _i0; // [rad]
|
---|
129 | double _Crc; // [m]
|
---|
130 | double _omega; // [rad]
|
---|
131 | double _OMEGADOT; // [rad/s]
|
---|
132 |
|
---|
133 | double _IDOT; // [rad/s]
|
---|
134 | double _L2Codes; // Codes on L2 channel (not valid for IRNSS)
|
---|
135 | double _TOEweek;
|
---|
136 | double _L2PFlag; // L2 P data flag (not valid for IRNSS)
|
---|
137 |
|
---|
138 | mutable double _ura; // SV accuracy
|
---|
139 | double _health; // SV health
|
---|
140 | double _TGD; // [s]
|
---|
141 | double _IODC; // (not valid for IRNSS)
|
---|
142 |
|
---|
143 | double _TOT; // Transmisstion time
|
---|
144 | double _fitInterval; // Fit interval (not valid for IRNSS)
|
---|
145 | };
|
---|
146 |
|
---|
147 | class t_ephGlo : public t_eph {
|
---|
148 | friend class t_ephEncoder;
|
---|
149 | friend class RTCM3Decoder;
|
---|
150 | public:
|
---|
151 | t_ephGlo() {
|
---|
152 | _xv.ReSize(6);
|
---|
153 | _gps_utc = 0.0;
|
---|
154 | _tau = 0.0;
|
---|
155 | _gamma = 0.0;
|
---|
156 | _tki = 0.0;
|
---|
157 | _x_pos = 0.0;
|
---|
158 | _x_velocity = 0.0;
|
---|
159 | _x_acceleration = 0.0;
|
---|
160 | _health = 0.0;
|
---|
161 | _y_pos = 0.0;
|
---|
162 | _y_velocity = 0.0;
|
---|
163 | _y_acceleration = 0.0;
|
---|
164 | _frequency_number = 0.0;
|
---|
165 | _z_pos = 0.0;
|
---|
166 | _z_velocity = 0.0;
|
---|
167 | _z_acceleration = 0.0;
|
---|
168 | _E = 0.0;
|
---|
169 | _almanac_health = 0.0;
|
---|
170 | _almanac_health_availablility_indicator = 0.0;
|
---|
171 | _additional_data_availability = 0.0;
|
---|
172 | _tauC = 0.0;
|
---|
173 | _P1 = 0.0;
|
---|
174 | _P2 = 0.0;
|
---|
175 | _P3 = 0.0;
|
---|
176 | _NA = 0.0;
|
---|
177 | _M_P = 0.0;
|
---|
178 | _M_l3 = 0.0;
|
---|
179 | _M_delta_tau = 0.0;
|
---|
180 | _M_P4 = 0.0;
|
---|
181 | _M_FT = 0.0;
|
---|
182 | _M_NT = 0.0;
|
---|
183 | _M_M = 0.0;
|
---|
184 | _M_N4 = 0.0;
|
---|
185 | _M_tau_GPS = 0.0;
|
---|
186 | _M_l5 = 0.0;
|
---|
187 | }
|
---|
188 | t_ephGlo(float rnxVersion, const QStringList& lines);
|
---|
189 | virtual ~t_ephGlo() {}
|
---|
190 |
|
---|
191 | virtual e_type type() const {return t_eph::GLONASS;}
|
---|
192 | virtual QString toString(double version) const;
|
---|
193 | virtual unsigned int IOD() const;
|
---|
194 | virtual unsigned int isUnhealthy() const;
|
---|
195 | virtual int slotNum() const {return int(_frequency_number);}
|
---|
196 |
|
---|
197 | private:
|
---|
198 | virtual t_irc position(int GPSweek, double GPSweeks, double* xc, double* vv) const;
|
---|
199 | static ColumnVector glo_deriv(double /* tt */, const ColumnVector& xv, double* acc);
|
---|
200 |
|
---|
201 | mutable bncTime _tt; // time
|
---|
202 | mutable ColumnVector _xv; // status vector (position, velocity) at time _tt
|
---|
203 |
|
---|
204 | double _gps_utc;
|
---|
205 | double _tau; // [s]
|
---|
206 | double _gamma; // [-]
|
---|
207 | mutable double _tki; // message frame time
|
---|
208 |
|
---|
209 | double _x_pos; // [km]
|
---|
210 | double _x_velocity; // [km/s]
|
---|
211 | double _x_acceleration; // [km/s^2]
|
---|
212 | double _health; // 0 = O.K. MSB of Bn word
|
---|
213 |
|
---|
214 | double _y_pos; // [km]
|
---|
215 | double _y_velocity; // [km/s]
|
---|
216 | double _y_acceleration; // [km/s^2]
|
---|
217 | double _frequency_number; // ICD-GLONASS data position
|
---|
218 |
|
---|
219 | double _z_pos; // [km]
|
---|
220 | double _z_velocity; // [km/s]
|
---|
221 | double _z_acceleration; // [km/s^2]
|
---|
222 | double _E; // Age of Information [days]
|
---|
223 |
|
---|
224 | double _almanac_health; // Cn word
|
---|
225 | double _almanac_health_availablility_indicator;
|
---|
226 |
|
---|
227 | double _additional_data_availability; //
|
---|
228 | double _tauC; // GLONASS time scale correction to UTC(SU) time [sec]
|
---|
229 | double _P1; // flag of the immediate data updating [-]
|
---|
230 | double _P2; // flag of oddness or evenness of the value of tb for intervals 30 or 60 minutes [-]
|
---|
231 | double _P3; // flag indicating a number of satellites for which almanac is transmitted within given frame [-]
|
---|
232 | double _NA; // calendar day number within the 4-year period [days]
|
---|
233 |
|
---|
234 | double _M_P; // control segment parameter that indicates the satellite operation mode with respect of time parameters
|
---|
235 | double _M_l3; // health flag
|
---|
236 | double _M_delta_tau; // [sec]
|
---|
237 | double _M_P4; // flag to show that ephemeris parameters are present [-]
|
---|
238 | double _M_FT; // indicator for predicted satellite user range accuracy [-]
|
---|
239 | double _M_NT; // current date, calendar number of day within 4-year interval [days]
|
---|
240 | double _M_M; // type of satellite transmitting navigation signal: 0 = GLONASS, 1 = GLONASS-M satellite [-]
|
---|
241 | double _M_N4; // 4-year interval number starting from 1996
|
---|
242 | double _M_tau_GPS; // correction to GPS time relative to GLONASS time [days]
|
---|
243 | double _M_l5; // health flag
|
---|
244 | };
|
---|
245 |
|
---|
246 | class t_ephGal : public t_eph {
|
---|
247 | friend class t_ephEncoder;
|
---|
248 | friend class RTCM3Decoder;
|
---|
249 | public:
|
---|
250 | t_ephGal() {
|
---|
251 | _clock_bias = 0.0;
|
---|
252 | _clock_drift = 0.0;
|
---|
253 | _clock_driftrate = 0.0;
|
---|
254 | _IODnav = 0.0;
|
---|
255 | _Crs = 0.0;
|
---|
256 | _Delta_n = 0.0;
|
---|
257 | _M0 = 0.0;
|
---|
258 | _Cuc = 0.0;
|
---|
259 | _e = 0.0;
|
---|
260 | _Cus = 0.0;
|
---|
261 | _sqrt_A = 0.0;
|
---|
262 | _TOEsec = 0.0;
|
---|
263 | _Cic = 0.0;
|
---|
264 | _OMEGA0 = 0.0;
|
---|
265 | _Cis = 0.0;
|
---|
266 | _i0 = 0.0;
|
---|
267 | _Crc = 0.0;
|
---|
268 | _omega = 0.0;
|
---|
269 | _OMEGADOT = 0.0;
|
---|
270 | _IDOT = 0.0;
|
---|
271 | _TOEweek = 0.0;
|
---|
272 | _SISA = 0.0;
|
---|
273 | _E5aHS = 0.0;
|
---|
274 | _E5bHS = 0.0;
|
---|
275 | _E1_bHS = 0.0;
|
---|
276 | _BGD_1_5A = 0.0;
|
---|
277 | _BGD_1_5B = 0.0;
|
---|
278 | _TOT = 0.0;
|
---|
279 | };
|
---|
280 | t_ephGal(float rnxVersion, const QStringList& lines);
|
---|
281 | virtual ~t_ephGal() {}
|
---|
282 |
|
---|
283 | virtual QString toString(double version) const;
|
---|
284 | virtual e_type type() const {return t_eph::Galileo;}
|
---|
285 | virtual unsigned int IOD() const { return static_cast<unsigned long>(_IODnav); }
|
---|
286 | virtual unsigned int isUnhealthy() const;
|
---|
287 |
|
---|
288 | private:
|
---|
289 | virtual t_irc position(int GPSweek, double GPSweeks, double* xc, double* vv) const;
|
---|
290 |
|
---|
291 | double _clock_bias; // [s]
|
---|
292 | double _clock_drift; // [s/s]
|
---|
293 | double _clock_driftrate; // [s/s^2]
|
---|
294 |
|
---|
295 | double _IODnav;
|
---|
296 | double _Crs; // [m]
|
---|
297 | double _Delta_n; // [rad/s]
|
---|
298 | double _M0; // [rad]
|
---|
299 |
|
---|
300 | double _Cuc; // [rad]
|
---|
301 | double _e; //
|
---|
302 | double _Cus; // [rad]
|
---|
303 | double _sqrt_A; // [m^0.5]
|
---|
304 |
|
---|
305 | double _TOEsec; // [s]
|
---|
306 | double _Cic; // [rad]
|
---|
307 | double _OMEGA0; // [rad]
|
---|
308 | double _Cis; // [rad]
|
---|
309 |
|
---|
310 | double _i0; // [rad]
|
---|
311 | double _Crc; // [m]
|
---|
312 | double _omega; // [rad]
|
---|
313 | double _OMEGADOT; // [rad/s]
|
---|
314 |
|
---|
315 | double _IDOT; // [rad/s]
|
---|
316 | double _TOEweek;
|
---|
317 | // spare
|
---|
318 |
|
---|
319 | mutable double _SISA; // Signal In Space Accuracy
|
---|
320 | double _E5aHS; // [0..3] E5a Health Status
|
---|
321 | double _E5bHS; // [0..3] E5b Health Status
|
---|
322 | double _E1_bHS; // [0..3] E1-b Health Status
|
---|
323 | double _BGD_1_5A; // group delay [s]
|
---|
324 | double _BGD_1_5B; // group delay [s]
|
---|
325 |
|
---|
326 | double _TOT; // [s]
|
---|
327 | /** Data comes from I/NAV when <code>true</code> */
|
---|
328 | bool _inav;
|
---|
329 | /** Data comes from F/NAV when <code>true</code> */
|
---|
330 | bool _fnav;
|
---|
331 | /** EE Data is not valid */
|
---|
332 | bool _e1DataInValid;
|
---|
333 | /** E5A Data is not valid */
|
---|
334 | bool _e5aDataInValid;
|
---|
335 | /** E5B Data is not valid */
|
---|
336 | bool _e5bDataInValid;
|
---|
337 | };
|
---|
338 |
|
---|
339 | class t_ephSBAS : public t_eph {
|
---|
340 | friend class t_ephEncoder;
|
---|
341 | friend class RTCM3Decoder;
|
---|
342 | public:
|
---|
343 | t_ephSBAS() {
|
---|
344 | _IODN = 0;
|
---|
345 | _TOW = 0.0;
|
---|
346 | _agf0 = 0.0;
|
---|
347 | _agf1 = 0.0;
|
---|
348 | _x_pos = 0.0;
|
---|
349 | _x_velocity = 0.0;
|
---|
350 | _x_acceleration = 0.0;
|
---|
351 | _y_pos = 0.0;
|
---|
352 | _y_velocity = 0.0;
|
---|
353 | _y_acceleration = 0.0;
|
---|
354 | _z_pos = 0.0;
|
---|
355 | _z_velocity = 0.0;
|
---|
356 | _z_acceleration = 0.0;
|
---|
357 | _ura = 0.0;
|
---|
358 | _health = 0.0;
|
---|
359 | }
|
---|
360 | t_ephSBAS(float rnxVersion, const QStringList& lines);
|
---|
361 | virtual ~t_ephSBAS() {}
|
---|
362 |
|
---|
363 | virtual e_type type() const {return t_eph::SBAS;}
|
---|
364 | virtual unsigned int IOD() const;
|
---|
365 | virtual unsigned int isUnhealthy() const { return static_cast<unsigned int>(_health); }
|
---|
366 | virtual QString toString(double version) const;
|
---|
367 |
|
---|
368 | private:
|
---|
369 | virtual t_irc position(int GPSweek, double GPSweeks, double* xc, double* vv) const;
|
---|
370 |
|
---|
371 | int _IODN;
|
---|
372 | double _TOW; // not used (set to 0.9999e9)
|
---|
373 | double _agf0; // [s] clock correction
|
---|
374 | double _agf1; // [s/s] clock correction drift
|
---|
375 |
|
---|
376 | double _x_pos; // [m]
|
---|
377 | double _x_velocity; // [m/s]
|
---|
378 | double _x_acceleration; // [m/s^2]
|
---|
379 |
|
---|
380 | double _y_pos; // [m]
|
---|
381 | double _y_velocity; // [m/s]
|
---|
382 | double _y_acceleration; // [m/s^2]
|
---|
383 |
|
---|
384 | double _z_pos; // [m]
|
---|
385 | double _z_velocity; // [m/s]
|
---|
386 | double _z_acceleration; // [m/s^2]
|
---|
387 |
|
---|
388 | mutable double _ura;
|
---|
389 | double _health;
|
---|
390 | };
|
---|
391 |
|
---|
392 | class t_ephBDS : public t_eph {
|
---|
393 | friend class t_ephEncoder;
|
---|
394 | friend class RTCM3Decoder;
|
---|
395 | public:
|
---|
396 | t_ephBDS() : _TOEweek(-1.0) {
|
---|
397 | _TOT = 0.0;
|
---|
398 | _AODE = 0;
|
---|
399 | _AODC = 0;
|
---|
400 | _URAI = 0;
|
---|
401 | _URA = 0.0;
|
---|
402 | _clock_bias = 0.0;
|
---|
403 | _clock_drift = 0.0;
|
---|
404 | _clock_driftrate = 0.0;
|
---|
405 | _Crs = 0.0;
|
---|
406 | _Delta_n = 0.0;
|
---|
407 | _M0 = 0.0;
|
---|
408 | _Cuc = 0.0;
|
---|
409 | _e = 0.0;
|
---|
410 | _Cus = 0.0;
|
---|
411 | _sqrt_A = 0.0;
|
---|
412 | _Cic = 0.0;
|
---|
413 | _OMEGA0 = 0.0;
|
---|
414 | _Cis = 0.0;
|
---|
415 | _i0 = 0.0;
|
---|
416 | _Crc = 0.0;
|
---|
417 | _omega = 0.0;
|
---|
418 | _OMEGADOT = 0.0;
|
---|
419 | _IDOT = 0.0;
|
---|
420 | _TGD1 = 0.0;
|
---|
421 | _TGD2 = 0.0;
|
---|
422 | _SatH1 = 0.0;
|
---|
423 | _TOW = 0.0;
|
---|
424 | _TOEsec = 0.0;
|
---|
425 | _TOEweek = 0.0;
|
---|
426 | }
|
---|
427 | t_ephBDS(float rnxVersion, const QStringList& lines);
|
---|
428 | virtual ~t_ephBDS() {}
|
---|
429 |
|
---|
430 | virtual e_type type() const {return t_eph::BDS;}
|
---|
431 | virtual unsigned int IOD() const;
|
---|
432 | virtual unsigned int isUnhealthy() const { return static_cast<unsigned int>(_SatH1); }
|
---|
433 | virtual QString toString(double version) const;
|
---|
434 |
|
---|
435 | private:
|
---|
436 | virtual t_irc position(int GPSweek, double GPSweeks, double* xc, double* vv) const;
|
---|
437 |
|
---|
438 | double _TOT;
|
---|
439 | bncTime _TOE;
|
---|
440 | int _AODE;
|
---|
441 | int _AODC;
|
---|
442 | int _URAI; // [0..15] index from RTCM stream
|
---|
443 | mutable double _URA; // user range accuracy
|
---|
444 | double _clock_bias; // [s]
|
---|
445 | double _clock_drift; // [s/s]
|
---|
446 | double _clock_driftrate; // [s/s^2]
|
---|
447 | double _Crs; // [m]
|
---|
448 | double _Delta_n; // [rad/s]
|
---|
449 | double _M0; // [rad]
|
---|
450 | double _Cuc; // [rad]
|
---|
451 | double _e; //
|
---|
452 | double _Cus; // [rad]
|
---|
453 | double _sqrt_A; // [m^0.5]
|
---|
454 | double _Cic; // [rad]
|
---|
455 | double _OMEGA0; // [rad]
|
---|
456 | double _Cis; // [rad]
|
---|
457 | double _i0; // [rad]
|
---|
458 | double _Crc; // [m]
|
---|
459 | double _omega; // [rad]
|
---|
460 | double _OMEGADOT; // [rad/s]
|
---|
461 | double _IDOT; // [rad/s]
|
---|
462 | double _TGD1; // [s]
|
---|
463 | double _TGD2; // [s]
|
---|
464 | int _SatH1; //
|
---|
465 | double _TOW; // [s] of BDT week
|
---|
466 | double _TOEsec; // [s] of BDT week
|
---|
467 | double _TOEweek; // BDT week will be set only in case of RINEX file input
|
---|
468 | };
|
---|
469 | #endif
|
---|