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

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