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

Last change on this file since 9673 was 9673, checked in by stuerze, 2 years ago

minor changes

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