source: ntrip/trunk/BNC/src/ephemeris.h@ 10574

Last change on this file since 10574 was 10533, checked in by stuerze, 7 weeks ago

Service and RTCM CRS encoding and decoding as well as Helmert parameter decoding added + some re-organisation

File size: 18.2 KB
Line 
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
13class t_orbCorr;
14class t_clkCorr;
15
16class t_eph {
17 public:
18 enum e_type {unknown, GPS, QZSS, GLONASS, Galileo, SBAS, BDS, IRNSS};
19 enum e_checkState {unchecked, ok, bad, outdated, unhealthy};
20 enum e_navType {undefined, LNAV, FDMA, FNAV, INAF, D1, D2, SBASL1, CNAV, CNV1, CNV2, CNV3};
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 void setCheckState(e_checkState checkState) {_checkState = checkState;}
33 e_checkState checkState() const {return _checkState;}
34 QString checkStateToString() {
35 switch (_checkState) {
36 case unchecked: return "unchecked";
37 case ok: return "ok";
38 case bad: return "bad";
39 case outdated: return "outdated";
40 case unhealthy: return "unhealthy";
41 default: return "unknown";
42 }
43 }
44 e_navType navType() const {return _navType;}
45 t_irc setNavType(QString navTypeStr);
46
47 t_prn prn() const {return _prn;}
48 t_irc getCrd(const bncTime& tt, ColumnVector& xc, ColumnVector& vv, bool useCorr) const;
49 void setOrbCorr(const t_orbCorr* orbCorr);
50 void setClkCorr(const t_clkCorr* clkCorr);
51 const QDateTime& receptDateTime() const {return _receptDateTime;}
52 const QString receptStaID() const {return _receptStaID;}
53 static QString rinexDateStr(const bncTime& tt, const t_prn& prn, double version);
54 static QString rinexDateStr(const bncTime& tt, const QString& prnStr, double version);
55 static QString navTypeString(e_navType navType, const t_prn& prn, double version);
56 static bool earlierTime(const t_eph* eph1, const t_eph* eph2) {return eph1->_TOC < eph2->_TOC;}
57 static bool prnSort(const t_eph* eph1, const t_eph* eph2) {return eph1->prn() < eph2->prn();}
58
59 protected:
60 virtual t_irc position(int GPSweek, double GPSweeks, double* xc, double* vv) const = 0;
61 t_prn _prn;
62 bncTime _TOC;
63 QDateTime _receptDateTime;
64 QString _receptStaID;
65 e_checkState _checkState;
66 e_navType _navType; // defined in RINEX 4
67 t_orbCorr* _orbCorr;
68 t_clkCorr* _clkCorr;
69};
70
71class t_ephGPS : public t_eph {
72 friend class t_ephEncoder;
73 friend class RTCM3Decoder;
74 public:
75 t_ephGPS() {
76 _clock_bias = 0.0;
77 _clock_drift = 0.0;
78 _clock_driftrate = 0.0;
79 _IODE = 0.0;
80 _Crs = 0.0;
81 _Delta_n = 0.0;
82 _M0 = 0.0;
83 _Cuc = 0.0;
84 _e = 0.0;
85 _Cus = 0.0;
86 _sqrt_A = 0.0;
87 _TOEsec = 0.0;
88 _Cic = 0.0;
89 _OMEGA0 = 0.0;
90 _Cis = 0.0;
91 _i0 = 0.0;
92 _Crc = 0.0;
93 _omega = 0.0;
94 _OMEGADOT = 0.0;
95 _IDOT = 0.0;
96 _L2Codes = 0.0;
97 _TOEweek = 0.0;
98 _L2PFlag = 0.0;
99 _ura = 0.0;
100 _health = 0.0;
101 _TGD = 0.0;
102 _IODC = 0.0;
103 _TOT = 0.0;
104 _fitInterval = 0.0;
105 _ADOT = 0.0;
106 _top = 0.0;
107 _Delta_n_dot = 0.0;
108 _URAI_NED0 = 0.0;
109 _URAI_NED1 = 0.0;
110 _URAI_NED2 = 0.0;
111 _URAI_ED = 0.0;
112 _ISC_L1CA = 0.0;
113 _ISC_L2C = 0.0;
114 _ISC_L5I5 = 0.0;
115 _ISC_L5Q5 = 0.0;
116 _ISC_L1Cd = 0.0;
117 _ISC_L1Cp = 0.0;
118 _wnop = 0.0;
119 _receptStaID = "";
120 }
121 t_ephGPS(double rnxVersion, const QStringList& lines);
122 virtual ~t_ephGPS() {}
123
124 virtual e_type type() const {
125 switch (_prn.system()) {
126 case 'J':
127 return t_eph::QZSS;
128 case 'I':
129 return t_eph::IRNSS;
130 };
131 return t_eph::GPS;
132 }
133 virtual QString toString(double version) const;
134 virtual unsigned int IOD() const { return static_cast<unsigned int>(_IODE); }
135 virtual unsigned int isUnhealthy() const { return static_cast<unsigned int>(_health); }
136 double TGD() const {return _TGD;} // Timing Group Delay (P1-P2 DCB)
137
138 private:
139 virtual t_irc position(int GPSweek, double GPSweeks, double* xc, double* vv) const;
140
141 double _clock_bias; // [s]
142 double _clock_drift; // [s/s]
143 double _clock_driftrate; // [s/s^2]
144
145 double _IODE; // IODEC in case of IRNSS
146 double _Crs; // [m]
147 double _Delta_n; // [rad/s]
148 double _M0; // [rad]
149
150 double _Cuc; // [rad]
151 double _e; // []
152 double _Cus; // [rad]
153 double _sqrt_A; // [m^0.5]
154
155 double _TOEsec; // [s of GPS week]
156 double _Cic; // [rad]
157 double _OMEGA0; // [rad]
158 double _Cis; // [rad]
159
160 double _i0; // [rad]
161 double _Crc; // [m]
162 double _omega; // [rad]
163 double _OMEGADOT; // [rad/s]
164
165 double _IDOT; // [rad/s]
166 double _L2Codes; // Codes on L2 channel (not valid for IRNSS)
167 double _TOEweek; // GPS week # to go with TOE, cont. number, not mode 1024
168 double _L2PFlag; // L2 P data flag (not valid for IRNSS and QZSS)
169
170 mutable double _ura; // SV accuracy [m]
171 double _health; // SV health
172 double _TGD; // [s]
173 double _IODC; // (not valid for IRNSS)
174
175 double _TOT; // Transmission time
176 double _fitInterval; // Fit interval in hours (not valid for IRNSS)
177
178 double _ADOT; // [m/s]
179 double _top; // [s]
180 double _Delta_n_dot; // [rad/s^2]
181
182 double _URAI_NED0; // []
183 double _URAI_NED1; // []
184 double _URAI_NED2; // []
185 double _URAI_ED; // []
186
187 double _ISC_L1CA; // [s]
188 double _ISC_L2C; // [s]
189 double _ISC_L5I5; // [s]
190 double _ISC_L5Q5; // [s]
191 double _ISC_L1Cd; // [s]
192 double _ISC_L1Cp; // [s]
193
194 double _wnop; // GPS continuous week number with the ambiguity resolved
195};
196
197class t_ephGlo : public t_eph {
198 friend class t_ephEncoder;
199 friend class RTCM3Decoder;
200 public:
201 t_ephGlo() {
202 _xv.ReSize(6); _xv = 0.0;
203 _gps_utc = 0.0;
204 _tau = 0.0;
205 _gamma = 0.0;
206 _tki = 0.0;
207 _x_pos = 0.0;
208 _x_velocity = 0.0;
209 _x_acceleration = 0.0;
210 _health = 0.0;
211 _y_pos = 0.0;
212 _y_velocity = 0.0;
213 _y_acceleration = 0.0;
214 _frequency_number = 0.0;
215 _z_pos = 0.0;
216 _z_velocity = 0.0;
217 _z_acceleration = 0.0;
218 _E = 0.0;
219 _almanac_health = 0.0;
220 _almanac_health_availablility_indicator = 0.0;
221 _additional_data_availability = 0.0;
222 _tauC = 0.0;
223 _P1 = 0.0;
224 _P2 = 0.0;
225 _P3 = 0.0;
226 _NA = 0.0;
227 _M_P = 0.0;
228 _M_l3 = 0.0;
229 _M_delta_tau = 0.0;
230 _M_P4 = 0.0;
231 _M_FT = 0.0;
232 _M_NT = 0.0;
233 _M_M = 0.0;
234 _M_N4 = 0.0;
235 _M_tau_GPS = 0.0;
236 _M_l5 = 0.0;
237 _receptStaID = "";
238 _flags_unknown = true;
239 }
240 t_ephGlo(double rnxVersion, const QStringList& lines);
241 virtual ~t_ephGlo() {}
242
243 virtual e_type type() const {return t_eph::GLONASS;}
244 virtual QString toString(double version) const;
245 virtual unsigned int IOD() const;
246 virtual unsigned int isUnhealthy() const;
247 virtual int slotNum() const {return int(_frequency_number);}
248
249 private:
250 virtual t_irc position(int GPSweek, double GPSweeks, double* xc, double* vv) const;
251 static ColumnVector glo_deriv(double /* tt */, const ColumnVector& xv, double* acc);
252
253 mutable bncTime _tt; // time
254 mutable ColumnVector _xv; // status vector (position, velocity) at time _tt
255
256 double _gps_utc;
257 double _tau; // [s]
258 double _gamma; // [-]
259 mutable double _tki; // message frame time
260
261 double _x_pos; // [km]
262 double _x_velocity; // [km/s]
263 double _x_acceleration; // [km/s^2]
264 double _health; // 0 = O.K. MSB of Bn word
265
266 double _y_pos; // [km]
267 double _y_velocity; // [km/s]
268 double _y_acceleration; // [km/s^2]
269 double _frequency_number; // ICD-GLONASS data position
270
271 double _z_pos; // [km]
272 double _z_velocity; // [km/s]
273 double _z_acceleration; // [km/s^2]
274 double _E; // Age of Information [days]
275
276 double _almanac_health; // Cn word
277 double _almanac_health_availablility_indicator;
278
279 double _additional_data_availability; //
280 double _tauC; // GLONASS time scale correction to UTC(SU) time [sec]
281 double _P1; // flag of the immediate data updating [-]
282 double _P2; // flag of oddness or evenness of the value of tb for intervals 30 or 60 minutes [-]
283 double _P3; // flag indicating a number of satellites for which almanac is transmitted within given frame [-]
284 double _NA; // calendar day number within the 4-year period [days]
285
286 double _M_P; // control segment parameter that indicates the satellite operation mode with respect of time parameters
287 double _M_l3; // health flag
288 double _M_delta_tau; // [sec]
289 double _M_P4; // flag to show that ephemeris parameters are present [-]
290 double _M_FT; // Indicator for predicted satellite User Range Accuracy (URAI) [-]
291 double _M_NT; // current date, calendar number of day within 4-year interval [days]
292 double _M_M; // type of satellite transmitting navigation signal: 0 = GLONASS, 1 = GLONASS-M satellite [-]
293 double _M_N4; // 4-year interval number starting from 1996
294 double _M_tau_GPS; // correction to GPS time relative to GLONASS time [days]
295 double _M_l5; // health flag
296 bool _flags_unknown; // status and health flags are unknown (rnx version < 3.05) or known (rnx version >= 3.05)
297};
298
299class t_ephGal : public t_eph {
300 friend class t_ephEncoder;
301 friend class RTCM3Decoder;
302 public:
303 t_ephGal() {
304 _clock_bias = 0.0;
305 _clock_drift = 0.0;
306 _clock_driftrate = 0.0;
307 _IODnav = 0.0;
308 _Crs = 0.0;
309 _Delta_n = 0.0;
310 _M0 = 0.0;
311 _Cuc = 0.0;
312 _e = 0.0;
313 _Cus = 0.0;
314 _sqrt_A = 0.0;
315 _TOEsec = 0.0;
316 _Cic = 0.0;
317 _OMEGA0 = 0.0;
318 _Cis = 0.0;
319 _i0 = 0.0;
320 _Crc = 0.0;
321 _omega = 0.0;
322 _OMEGADOT = 0.0;
323 _IDOT = 0.0;
324 _TOEweek = 0.0;
325 _SISA = 0.0;
326 _E5aHS = 0.0;
327 _E5bHS = 0.0;
328 _E1_bHS = 0.0;
329 _BGD_1_5A = 0.0;
330 _BGD_1_5B = 0.0;
331 _TOT = 0.0;
332 _receptStaID = "";
333 };
334 t_ephGal(double rnxVersion, const QStringList& lines);
335 virtual ~t_ephGal() {}
336
337 virtual QString toString(double version) const;
338 virtual e_type type() const {return t_eph::Galileo;}
339 virtual unsigned int IOD() const { return static_cast<unsigned long>(_IODnav); }
340 virtual unsigned int isUnhealthy() const;
341
342 private:
343 virtual t_irc position(int GPSweek, double GPSweeks, double* xc, double* vv) const;
344
345 double _clock_bias; // [s]
346 double _clock_drift; // [s/s]
347 double _clock_driftrate; // [s/s^2]
348
349 double _IODnav;
350 double _Crs; // [m]
351 double _Delta_n; // [rad/s]
352 double _M0; // [rad]
353
354 double _Cuc; // [rad]
355 double _e; //
356 double _Cus; // [rad]
357 double _sqrt_A; // [m^0.5]
358
359 double _TOEsec; // [s]
360 double _Cic; // [rad]
361 double _OMEGA0; // [rad]
362 double _Cis; // [rad]
363
364 double _i0; // [rad]
365 double _Crc; // [m]
366 double _omega; // [rad]
367 double _OMEGADOT; // [rad/s]
368
369 double _IDOT; // [rad/s]
370 double _TOEweek;
371 // spare
372
373 mutable double _SISA; // Signal In Space Accuracy
374 double _E5aHS; // [0..3] E5a Health Status
375 double _E5bHS; // [0..3] E5b Health Status
376 double _E1_bHS; // [0..3] E1-b Health Status
377 double _BGD_1_5A; // group delay [s]
378 double _BGD_1_5B; // group delay [s]
379
380 double _TOT; // [s]
381 /** Data comes from I/NAV when <code>true</code> */
382 bool _inav;
383 /** Data comes from F/NAV when <code>true</code> */
384 bool _fnav;
385 /** E1 Data is not valid */
386 bool _e1DataInValid;
387 /** E5A Data is not valid */
388 bool _e5aDataInValid;
389 /** E5B Data is not valid */
390 bool _e5bDataInValid;
391};
392
393class t_ephSBAS : public t_eph {
394 friend class t_ephEncoder;
395 friend class RTCM3Decoder;
396 public:
397 t_ephSBAS() {
398 _IODN = 0;
399 _TOT = 0.0;
400 _agf0 = 0.0;
401 _agf1 = 0.0;
402 _x_pos = 0.0;
403 _x_velocity = 0.0;
404 _x_acceleration = 0.0;
405 _y_pos = 0.0;
406 _y_velocity = 0.0;
407 _y_acceleration = 0.0;
408 _z_pos = 0.0;
409 _z_velocity = 0.0;
410 _z_acceleration = 0.0;
411 _ura = 0.0;
412 _health = 0.0;
413 _receptStaID = "";
414 }
415 t_ephSBAS(double rnxVersion, const QStringList& lines);
416 virtual ~t_ephSBAS() {}
417
418 virtual e_type type() const {return t_eph::SBAS;}
419 virtual unsigned int IOD() const;
420 virtual unsigned int isUnhealthy() const;
421 virtual QString toString(double version) const;
422
423 private:
424 virtual t_irc position(int GPSweek, double GPSweeks, double* xc, double* vv) const;
425
426 int _IODN;
427 double _TOT; // not used (set to 0.9999e9)
428 double _agf0; // [s] clock correction
429 double _agf1; // [s/s] clock correction drift
430
431 double _x_pos; // [m]
432 double _x_velocity; // [m/s]
433 double _x_acceleration; // [m/s^2]
434
435 double _y_pos; // [m]
436 double _y_velocity; // [m/s]
437 double _y_acceleration; // [m/s^2]
438
439 double _z_pos; // [m]
440 double _z_velocity; // [m/s]
441 double _z_acceleration; // [m/s^2]
442
443 mutable double _ura;
444 double _health;
445};
446
447class t_ephBDS : public t_eph {
448 friend class t_ephEncoder;
449 friend class RTCM3Decoder;
450 public:
451 t_ephBDS() {
452 _TOT = 0.0;
453 _AODE = 0;
454 _AODC = 0;
455 _URAI = 0;
456 _URA = 0.0;
457 _clock_bias = 0.0;
458 _clock_drift = 0.0;
459 _clock_driftrate = 0.0;
460 _Crs = 0.0;
461 _Delta_n = 0.0;
462 _M0 = 0.0;
463 _Cuc = 0.0;
464 _e = 0.0;
465 _Cus = 0.0;
466 _sqrt_A = 0.0;
467 _Cic = 0.0;
468 _OMEGA0 = 0.0;
469 _Cis = 0.0;
470 _i0 = 0.0;
471 _Crc = 0.0;
472 _omega = 0.0;
473 _OMEGADOT = 0.0;
474 _IDOT = 0.0;
475 _TOEsec = 0.0;
476 _BDTweek = 0.0;
477 _Delta_n_dot = 0.0;
478 _satType = 0.0;
479 _top = 0.0;
480 _SISAI_oe = 0.0;
481 _SISAI_ocb = 0.0;
482 _SISAI_oc1 = 0.0;
483 _SISAI_oc2 = 0.0;
484 _ISC_B1Cd = 0.0;
485 _ISC_B2ad = 0.0;
486 _TGD1 = 0.0;
487 _TGD2 = 0.0;
488 _TGD_B1Cp = 0.0;
489 _TGD_B2ap = 0.0;
490 _TGD_B2bI = 0.0;
491 _SISMAI = 0.0;
492 _SatH1 = 0;
493 _health = 0;
494 _INTEGRITYF_B1C = 0.0;
495 _INTEGRITYF_B2aB1C = 0.0;
496 _INTEGRITYF_B2b = 0.0;
497 _IODC = 0.0;
498 _IODE = 0.0;
499 _receptStaID = "";
500 }
501 t_ephBDS(double rnxVersion, const QStringList& lines);
502 virtual ~t_ephBDS() {}
503
504 virtual e_type type() const {return t_eph::BDS;}
505 virtual unsigned int IOD() const;
506 virtual unsigned int isUnhealthy() const;
507 virtual QString toString(double version) const;
508
509 private:
510 virtual t_irc position(int GPSweek, double GPSweeks, double* xc, double* vv) const;
511
512 double _TOT; // [s] of BDT week
513 bncTime _TOE;
514 int _AODE;
515 int _AODC;
516 int _URAI; // [0..15] index from RTCM stream
517 mutable double _URA; // user range accuracy [m]
518 double _clock_bias; // [s]
519 double _clock_drift; // [s/s]
520 double _clock_driftrate; // [s/s^2]
521 double _Crs; // [m]
522 double _Delta_n; // [rad/s]
523 double _M0; // [rad]
524 double _Cuc; // [rad]
525 double _e; //
526 double _Cus; // [rad]
527 double _sqrt_A; // [m^0.5]
528 double _Cic; // [rad]
529 double _OMEGA0; // [rad]
530 double _Cis; // [rad]
531 double _i0; // [rad]
532 double _Crc; // [m]
533 double _omega; // [rad]
534 double _OMEGADOT; // [rad/s]
535 double _IDOT; // [rad/s]
536 double _TOEsec; // [s] of BDT week
537 double _BDTweek; // BDT week
538
539 double _Delta_n_dot; // [rad/s^2]
540 double _satType; // 0..reserved, 1..GEO, 2..IGSO, 3..MEO
541 double _top; // [s]
542
543 double _SISAI_oe; // []
544 double _SISAI_ocb; // []
545 double _SISAI_oc1; // []
546 double _SISAI_oc2; // []
547
548 double _ISC_B1Cd; // [s]
549 double _ISC_B2ad; // [s]
550
551 double _TGD1; // [s]
552 double _TGD2; // [s]
553 double _TGD_B1Cp; // [s]
554 double _TGD_B2ap; // [s]
555 double _TGD_B2bI; // [s]
556
557 double _SISMAI; // []
558
559 int _SatH1; //
560 int _health; //
561
562 double _INTEGRITYF_B1C; // 3 bits word from sf 3
563 double _INTEGRITYF_B2aB1C;// 6 bits word with integrity bits in msg 10-11, 30.34 or 40
564 double _INTEGRITYF_B2b; // 3 bits word from msg 10
565
566 double _IODC; // []
567 double _IODE; // [] IODE are the same as the 8 LSBs of IODC
568
569};
570
571#endif
Note: See TracBrowser for help on using the repository browser.