source: ntrip/trunk/BNC/src/RTCM3/clock_and_orbit/clock_orbit.h@ 9093

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

minor changes

  • Property svn:executable set to *
File size: 25.7 KB
Line 
1#ifndef RTCM3_CLOCK_ORBIT_H
2#define RTCM3_CLOCK_ORBIT_H
3
4/* Programheader
5
6 Name: clock_orbit.h
7 Project: RTCM3
8 Version: $Id: clock_orbit_igs.h 8966 2020-07-01 07:48:35Z stuerze $
9 Authors: Dirk Stöcker, Andrea Stürze
10 Description: state space approach
11 */
12
13#include <QList>
14#include <stdint.h>
15#include <string.h>
16#include <math.h>
17#include "t_prn.h"
18
19enum IGS_NUMBERS {
20 RTCM_MESSAGE_NUMBER_IGS = 4076,
21 IGS_SSR_VERSION = 3
22};
23
24/* if some systems aren't supported at all, change the following numbers to zero
25 for these systems to save space */
26enum COR_CONSTANTS {
27 CLOCKORBIT_BUFFERSIZE = 8192,
28 CLOCKORBIT_NUMGPS = t_prn::MAXPRN_GPS,
29 CLOCKORBIT_NUMGLONASS = t_prn::MAXPRN_GLONASS,
30 CLOCKORBIT_NUMGALILEO = t_prn::MAXPRN_GALILEO,
31 CLOCKORBIT_NUMQZSS = t_prn::MAXPRN_QZSS,
32 CLOCKORBIT_NUMSBAS = t_prn::MAXPRN_SBAS,
33 CLOCKORBIT_NUMBDS = t_prn::MAXPRN_BDS,
34 CLOCKORBIT_NUMBIAS = 100,
35 CLOCKORBIT_NUMIONOLAYERS = 4,
36 CLOCKORBIT_MAXIONOORDER = 16,
37 CLOCKORBIT_MAXIONODEGREE = 16
38};
39
40enum COR_SATSYSTEM {
41 CLOCKORBIT_SATGPS = 0,
42 CLOCKORBIT_SATGLONASS,
43 CLOCKORBIT_SATGALILEO,
44 CLOCKORBIT_SATQZSS,
45 CLOCKORBIT_SATSBAS,
46 CLOCKORBIT_SATBDS,
47 CLOCKORBIT_SATNUM
48};
49
50enum COR_OFFSETS {
51 CLOCKORBIT_OFFSETGPS = 0,
52 CLOCKORBIT_OFFSETGLONASS = CLOCKORBIT_NUMGPS,
53 CLOCKORBIT_OFFSETGALILEO = CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS,
54 CLOCKORBIT_OFFSETQZSS = CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
55 + CLOCKORBIT_NUMGALILEO,
56 CLOCKORBIT_OFFSETSBAS = CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
57 + CLOCKORBIT_NUMGALILEO + CLOCKORBIT_NUMQZSS,
58 CLOCKORBIT_OFFSETBDS = CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
59 + CLOCKORBIT_NUMGALILEO + CLOCKORBIT_NUMQZSS
60 + CLOCKORBIT_NUMSBAS,
61 CLOCKORBIT_COUNTSAT = CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
62 + CLOCKORBIT_NUMGALILEO + CLOCKORBIT_NUMQZSS
63 + CLOCKORBIT_NUMSBAS + CLOCKORBIT_NUMBDS
64};
65
66enum GCOB_RETURN {
67 /* all well */
68 GCOBR_MESSAGEFOLLOWS = 1,
69 GCOBR_OK = 0,
70 /* unknown data, a warning */
71 GCOBR_UNKNOWNTYPE = -1,
72 GCOBR_UNKNOWNDATA = -2,
73 GCOBR_CRCMISMATCH = -3,
74 GCOBR_SHORTMESSAGE = -4,
75 /* failed to do the work */
76 GCOBR_NOCLOCKORBITPARAMETER = -10,
77 GCOBR_NOCODEBIASPARAMETER = -11,
78 GCOBR_NOPHASEBIASPARAMETER = -12,
79 GCOBR_NOVTECPARAMETER = -13,
80 /* data mismatch - data in storage does not match new data */
81 GCOBR_TIMEMISMATCH = -20,
82 GCOBR_DATAMISMATCH = -21,
83 /* not enough data - can decode the block completely */
84 GCOBR_SHORTBUFFER = -30,
85 GCOBR_MESSAGEEXCEEDSBUFFER = -31
86/* NOTE: When an error message has been emitted, the output structures may have been modified.
87 * Make a copy of the previous variant before calling the
88 function to have a clean state. */
89};
90
91class SsrCorr {
92
93public:
94 SsrCorr() {};
95 virtual ~SsrCorr() {};
96 virtual void setCorBase() = 0;
97 virtual void setCorOffset() = 0;
98 virtual void setCoType() = 0;
99 virtual void setCbType() = 0;
100 virtual void setPbType() = 0;
101 virtual void setVtecType() = 0;
102 virtual void setCodeType() = 0;
103
104 typedef unsigned int SatelliteReferenceDatum;
105 SatelliteReferenceDatum DATUM_ITRF;
106 SatelliteReferenceDatum DATUM_LOCAL;
107
108 typedef unsigned int CorBase;
109 CorBase COBBASE_GPS;
110 CorBase COBBASE_GLONASS;
111 CorBase COBBASE_GALILEO;
112 CorBase COBBASE_QZSS;
113 CorBase COBBASE_BDS;
114 CorBase COBBASE_SBAS;
115 CorBase COBBASE_NUM;
116
117 typedef unsigned int CorOffset;
118 CorOffset COBOFS_ORBIT;
119 CorOffset COBOFS_CLOCK;
120 CorOffset COBOFS_COMBINED;
121 CorOffset COBOFS_HR;
122 CorOffset COBOFS_CBIAS;
123 CorOffset COBOFS_PBIAS;
124 CorOffset COBOFS_URA;
125 CorOffset COBOFS_NUM;
126
127 typedef unsigned int ClockOrbitType;
128 ClockOrbitType COTYPE_GPSORBIT;
129 ClockOrbitType COTYPE_GPSCLOCK;
130 ClockOrbitType COTYPE_GPSCOMBINED;
131 ClockOrbitType COTYPE_GPSHR;
132 ClockOrbitType COTYPE_GPSURA;
133
134 ClockOrbitType COTYPE_GLONASSORBIT;
135 ClockOrbitType COTYPE_GLONASSCLOCK;
136 ClockOrbitType COTYPE_GLONASSCOMBINED;
137 ClockOrbitType COTYPE_GLONASSHR;
138 ClockOrbitType COTYPE_GLONASSURA;
139
140 ClockOrbitType COTYPE_GALILEOORBIT;
141 ClockOrbitType COTYPE_GALILEOCLOCK;
142 ClockOrbitType COTYPE_GALILEOCOMBINED;
143 ClockOrbitType COTYPE_GALILEOHR;
144 ClockOrbitType COTYPE_GALILEOURA;
145
146 ClockOrbitType COTYPE_QZSSORBIT;
147 ClockOrbitType COTYPE_QZSSCLOCK;
148 ClockOrbitType COTYPE_QZSSCOMBINED;
149 ClockOrbitType COTYPE_QZSSHR;
150 ClockOrbitType COTYPE_QZSSURA;
151
152 ClockOrbitType COTYPE_SBASORBIT;
153 ClockOrbitType COTYPE_SBASCLOCK;
154 ClockOrbitType COTYPE_SBASCOMBINED;
155 ClockOrbitType COTYPE_SBASHR;
156 ClockOrbitType COTYPE_SBASURA;
157
158 ClockOrbitType COTYPE_BDSORBIT;
159 ClockOrbitType COTYPE_BDSCLOCK;
160 ClockOrbitType COTYPE_BDSCOMBINED;
161 ClockOrbitType COTYPE_BDSHR;
162 ClockOrbitType COTYPE_BDSURA;
163
164 ClockOrbitType COTYPE_AUTO;
165
166 typedef unsigned int CodeBiasType;
167 CodeBiasType CBTYPE_GPS;
168 CodeBiasType CBTYPE_GLONASS;
169 CodeBiasType CBTYPE_GALILEO;
170 CodeBiasType CBTYPE_QZSS;
171 CodeBiasType CBTYPE_SBAS;
172 CodeBiasType CBTYPE_BDS;
173 CodeBiasType CBTYPE_AUTO;
174
175 typedef unsigned int PhaseBiasType;
176 PhaseBiasType PBTYPE_BASE;
177 PhaseBiasType PBTYPE_GPS;
178 PhaseBiasType PBTYPE_GLONASS;
179 PhaseBiasType PBTYPE_GALILEO;
180 PhaseBiasType PBTYPE_QZSS;
181 PhaseBiasType PBTYPE_SBAS;
182 PhaseBiasType PBTYPE_BDS;
183 PhaseBiasType PBTYPE_AUTO;
184
185 typedef unsigned int VtecType;
186 VtecType VTEC_BASE;
187
188 typedef unsigned int CodeType;
189 CodeType RESERVED;
190 CodeType CODETYPE_GPS_L1_CA;
191 CodeType CODETYPE_GPS_L1_P;
192 CodeType CODETYPE_GPS_L1_Z;
193 CodeType CODETYPE_GPS_L1C_D;
194 CodeType CODETYPE_GPS_L1C_P;
195 CodeType CODETYPE_GPS_L1C_DP;
196 CodeType CODETYPE_GPS_L2_CA;
197 CodeType CODETYPE_GPS_SEMI_CODELESS;
198 CodeType CODETYPE_GPS_L2C_M;
199 CodeType CODETYPE_GPS_L2C_L;
200 CodeType CODETYPE_GPS_L2C_ML;
201 CodeType CODETYPE_GPS_L2_P;
202 CodeType CODETYPE_GPS_L2_Z;
203 CodeType CODETYPE_GPS_L5_I;
204 CodeType CODETYPE_GPS_L5_Q;
205 CodeType CODETYPE_GPS_L5_IQ;
206
207 CodeType CODETYPE_GLONASS_L1_CA;
208 CodeType CODETYPE_GLONASS_L1_P;
209 CodeType CODETYPE_GLONASS_L2_CA;
210 CodeType CODETYPE_GLONASS_L2_P;
211 CodeType CODETYPE_GLONASS_L1a_OCd;
212 CodeType CODETYPE_GLONASS_L1a_OCp;
213 CodeType CODETYPE_GLONASS_L1a_OCdp;
214 CodeType CODETYPE_GLONASS_L2a_CSI;
215 CodeType CODETYPE_GLONASS_L2a_OCp;
216 CodeType CODETYPE_GLONASS_L2a_CSIOCp;
217 CodeType CODETYPE_GLONASS_L3_I;
218 CodeType CODETYPE_GLONASS_L3_Q;
219 CodeType CODETYPE_GLONASS_L3_IQ;
220
221 CodeType CODETYPE_GALILEO_E1_A;
222 CodeType CODETYPE_GALILEO_E1_B;
223 CodeType CODETYPE_GALILEO_E1_C;
224 CodeType CODETYPE_GALILEO_E1_BC;
225 CodeType CODETYPE_GALILEO_E1_ABC;
226 CodeType CODETYPE_GALILEO_E5A_I;
227 CodeType CODETYPE_GALILEO_E5A_Q;
228 CodeType CODETYPE_GALILEO_E5A_IQ;
229 CodeType CODETYPE_GALILEO_E5B_I;
230 CodeType CODETYPE_GALILEO_E5B_Q;
231 CodeType CODETYPE_GALILEO_E5B_IQ;
232 CodeType CODETYPE_GALILEO_E5_I;
233 CodeType CODETYPE_GALILEO_E5_Q;
234 CodeType CODETYPE_GALILEO_E5_IQ;
235 CodeType CODETYPE_GALILEO_E6_A;
236 CodeType CODETYPE_GALILEO_E6_B;
237 CodeType CODETYPE_GALILEO_E6_C;
238 CodeType CODETYPE_GALILEO_E6_BC;
239 CodeType CODETYPE_GALILEO_E6_ABC;
240
241 CodeType CODETYPE_QZSS_L1_CA;
242 CodeType CODETYPE_QZSS_L1C_D;
243 CodeType CODETYPE_QZSS_L1C_P;
244 CodeType CODETYPE_QZSS_L2C_M;
245 CodeType CODETYPE_QZSS_L2C_L;
246 CodeType CODETYPE_QZSS_L2C_ML;
247 CodeType CODETYPE_QZSS_L5_I;
248 CodeType CODETYPE_QZSS_L5_Q;
249 CodeType CODETYPE_QZSS_L5_IQ;
250 CodeType CODETYPE_QZSS_L6_D;
251 CodeType CODETYPE_QZSS_L6_P;
252 CodeType CODETYPE_QZSS_L6_DP;
253 CodeType CODETYPE_QZSS_L1C_DP;
254 CodeType CODETYPE_QZSS_L1_S;
255 CodeType CODETYPE_QZSS_L5_D;
256 CodeType CODETYPE_QZSS_L5_P;
257 CodeType CODETYPE_QZSS_L5_DP;
258 CodeType CODETYPE_QZSS_L6_E;
259 CodeType CODETYPE_QZSS_L6_DE;
260
261 CodeType CODETYPE_SBAS_L1_CA;
262 CodeType CODETYPE_SBAS_L5_I;
263 CodeType CODETYPE_SBAS_L5_Q;
264 CodeType CODETYPE_SBAS_L5_IQ;
265
266 CodeType CODETYPE_BDS_B1_I;
267 CodeType CODETYPE_BDS_B1_Q;
268 CodeType CODETYPE_BDS_B1_IQ;
269 CodeType CODETYPE_BDS_B3_I;
270 CodeType CODETYPE_BDS_B3_Q;
271 CodeType CODETYPE_BDS_B3_IQ;
272 CodeType CODETYPE_BDS_B2_I;
273 CodeType CODETYPE_BDS_B2_Q;
274 CodeType CODETYPE_BDS_B2_IQ;
275 CodeType CODETYPE_BDS_B1a_D;
276 CodeType CODETYPE_BDS_B1a_P;
277 CodeType CODETYPE_BDS_B1a_DP;
278 CodeType CODETYPE_BDS_B2a_D;
279 CodeType CODETYPE_BDS_B2a_P;
280 CodeType CODETYPE_BDS_B2a_DP;
281 CodeType CODETYPE_BDS_B1_A;
282 CodeType CODETYPE_BDS_B3_A;
283
284 QList<CorBase> corbase;
285 QList<unsigned int> satoffset;
286
287
288#define SSR_MAXURA 5.5 /* > 5466.5mm in meter */
289#define COBOFS_MAXNUM 7
290
291 /* satellite system data is stored with offset CLOCKORBIT_OFFSET...
292 in the data structures. So first GLONASS satellite is at
293 xxx->Sat[CLOCKORBIT_OFFSETGLONASS], first GPS satellite is
294 xxx->Sat[CLOCKORBIT_OFFSETGPS]. */
295
296 struct ClockOrbit {
297 ClockOrbitType messageType;
298 unsigned int EpochTime[CLOCKORBIT_SATNUM]; /* 0 .. system specific maximum */
299 unsigned int NumberOfSat[CLOCKORBIT_SATNUM]; /* 0 .. CLOCKORBIT_NUM... */
300 unsigned int Supplied[COBOFS_MAXNUM]; /* boolean */
301 unsigned int SSRIOD;
302 unsigned int SSRProviderID;
303 unsigned int SSRSolutionID;
304 unsigned int UpdateInterval;
305 SatelliteReferenceDatum SatRefDatum;
306 struct SatData {
307 unsigned int ID; /* all */
308 unsigned int IOD; /* all */
309 unsigned int toe; /* SBAS, BDS */
310 double UserRangeAccuracy; /* accuracy values in [m] */
311 double hrclock;
312 struct OrbitPart {
313 double DeltaRadial; /* m */
314 double DeltaAlongTrack; /* m */
315 double DeltaCrossTrack; /* m */
316 double DotDeltaRadial; /* m/s */
317 double DotDeltaAlongTrack; /* m/s */
318 double DotDeltaCrossTrack; /* m/s */
319 } Orbit;
320 struct ClockPart {
321 double DeltaA0; /* m */
322 double DeltaA1; /* m/s */
323 double DeltaA2; /* m/ss */
324 } Clock;
325 } Sat[CLOCKORBIT_COUNTSAT];
326 };
327
328 struct CodeBias {
329 CodeBiasType messageType;
330 unsigned int EpochTime[CLOCKORBIT_SATNUM]; /* 0 .. system specific maximum */
331 unsigned int NumberOfSat[CLOCKORBIT_SATNUM]; /* 0 .. CLOCKORBIT_NUM... */
332 unsigned int UpdateInterval;
333 unsigned int SSRIOD;
334 unsigned int SSRProviderID;
335 unsigned int SSRSolutionID;
336 struct BiasSat {
337 unsigned int ID; /* all */
338 unsigned int NumberOfCodeBiases;
339 struct CodeBiasEntry {
340 CodeType Type;
341 float Bias; /* m */
342 } Biases[CLOCKORBIT_NUMBIAS];
343 } Sat[CLOCKORBIT_COUNTSAT];
344 };
345
346 struct PhaseBias {
347 PhaseBiasType messageType;
348 unsigned int EpochTime[CLOCKORBIT_SATNUM]; /* 0 .. system specific maximum */
349 unsigned int NumberOfSat[CLOCKORBIT_SATNUM]; /* 0 .. CLOCKORBIT_NUM... */
350 unsigned int UpdateInterval;
351 unsigned int SSRIOD;
352 unsigned int SSRProviderID;
353 unsigned int SSRSolutionID;
354 unsigned int DispersiveBiasConsistencyIndicator;
355 unsigned int MWConsistencyIndicator;
356 struct PhaseBiasSat {
357 unsigned int ID; /* all */
358 unsigned int NumberOfPhaseBiases;
359 double YawAngle; /* radiant */
360 double YawRate; /* radiant/s */
361 struct PhaseBiasEntry {
362 CodeType Type;
363 unsigned int SignalIntegerIndicator;
364 unsigned int SignalsWideLaneIntegerIndicator;
365 unsigned int SignalDiscontinuityCounter;
366 float Bias; /* m */
367 } Biases[CLOCKORBIT_NUMBIAS];
368 } Sat[CLOCKORBIT_COUNTSAT];
369 };
370
371 struct VTEC {
372 unsigned int EpochTime; /* GPS */
373 unsigned int UpdateInterval;
374 unsigned int SSRIOD;
375 unsigned int SSRProviderID;
376 unsigned int SSRSolutionID;
377 unsigned int NumLayers; /* 1-4 */
378 double Quality;
379 struct IonoLayers {
380 double Height; /* m */
381 unsigned int Degree; /* 1-16 */
382 unsigned int Order; /* 1-16 */
383 double Sinus[CLOCKORBIT_MAXIONODEGREE][CLOCKORBIT_MAXIONOORDER];
384 double Cosinus[CLOCKORBIT_MAXIONODEGREE][CLOCKORBIT_MAXIONOORDER];
385 } Layers[CLOCKORBIT_NUMIONOLAYERS];
386 };
387
388 /* return size of resulting data or 0 in case of an error */
389 virtual size_t MakeClockOrbit(const struct ClockOrbit *co, CodeType type,
390 int moremessagesfollow, char *buffer, size_t size) = 0;
391 virtual size_t MakeCodeBias(const struct CodeBias *b, CodeBiasType type,
392 int moremessagesfollow, char *buffer, size_t size) = 0;
393 virtual size_t MakePhaseBias(const struct PhaseBias *b, CodeBiasType type,
394 int moremessagesfollow, char *buffer, size_t size) = 0;
395 virtual size_t MakeVTEC(const struct VTEC *b, int moremessagesfollow,
396 char *buffer, size_t size) = 0;
397
398 /* buffer should point to a RTCM3 block */
399 virtual enum GCOB_RETURN GetSSR(struct ClockOrbit *co, struct CodeBias *b,
400 struct VTEC *v, struct PhaseBias *pb, const char *buffer, size_t size,
401 int *bytesused) = 0;
402
403 virtual std::string codeTypeToRnxType(char system, CodeType type) = 0;
404 virtual CodeType rnxTypeToCodeType(char system, std::string type) = 0;
405
406 static uint32_t CRC24(long size, const unsigned char *buf) {
407 uint32_t crc = 0;
408 int ii;
409 while (size--) {
410 crc ^= (*buf++) << (16);
411 for (ii = 0; ii < 8; ii++) {
412 crc <<= 1;
413 if (crc & 0x1000000)
414 crc ^= 0x01864cfb;
415 }
416 }
417 return crc;
418 }
419
420//#ifndef NOENCODE
421#define STOREBITS \
422 while(numbits >= 8) { \
423 if(!size) return 0; \
424 *(buffer++) = bitbuffer>>(numbits-8); \
425 numbits -= 8; \
426 ++ressize; \
427 --size; \
428 }
429
430#define ADDBITS(a, b) { \
431 bitbuffer = (bitbuffer<<(a))|((b)&((1<<a)-1)); \
432 numbits += (a); \
433 STOREBITS \
434 }
435
436#define STARTDATA \
437 size_t ressize=0; \
438 char *blockstart; \
439 int numbits; \
440 uint64_t bitbuffer=0;
441
442#define INITBLOCK \
443 numbits = 0; \
444 blockstart = buffer; \
445 ADDBITS(8, 0xD3) \
446 ADDBITS(6, 0) \
447 ADDBITS(10, 0)
448
449#define ENDBLOCK \
450 if(numbits) { ADDBITS((8-numbits), 0) } { \
451 int len = buffer-blockstart-3; \
452 blockstart[1] |= len>>8; \
453 blockstart[2] = len; \
454 if(len > 1023) \
455 return 0; \
456 len = SsrCorr::CRC24(len+3, (const unsigned char *) blockstart); \
457 ADDBITS(24, len) \
458 }
459
460#define SCALEADDBITS(a, b, c) ADDBITS(a, (int64_t)(c > 0 ? b*c+0.5 : b*c-0.5))
461#define MPI 3.141592653589793
462
463/* GNSS macros - Header part */
464#define T_RTCM_MESSAGE_NUMBER(a) ADDBITS(12, a) /* DF002 */
465#define T_IGS_SSR_VERSION(a) ADDBITS( 3, a) /* IDF001 */
466#define T_IGS_MESSAGE_NUMBER(a) ADDBITS( 8, a) /* IDF002 */
467#define T_SSR_EPOCH_TIME(a) ADDBITS(20, a) /* DF??? IDF003 */ //T_GPS_EPOCH_TIME(a)
468#define T_GLONASS_EPOCH_TIME(a) ADDBITS(17, a) /* DF */
469
470#define T_SSR_UPDATE_INTERVAL(a) ADDBITS( 4, a) /* DF391, IDF004 */
471#define T_MULTIPLE_MESSAGE_INDICATOR(a) ADDBITS( 1, a) /* DF388, IDF005 */
472#define T_SSR_IOD(a) ADDBITS( 4, a) /* DF413, IDF007 */
473#define T_SSR_PROVIDER_ID(a) ADDBITS(16, a) /* DF414, IDF008 */
474#define T_SSR_SOLUTION_ID(a) ADDBITS( 4, a) /* DF415, IDF009 */
475#define T_SATELLITE_REFERENCE_DATUM(a) ADDBITS( 1, a) /* DF375, IDF006 */
476#define T_NO_OF_SATELLITES(a) ADDBITS( 6, a) /* DF387, IDF010 */
477
478/* GNSS macros - Satellite specific part */
479#define T_GNSS_SATELLITE_ID(a) ADDBITS( 6, a) /* IDF011 */
480#define T_GPS_SATELLITE_ID(a) ADDBITS( 6, a) /* DF068 */
481#define T_QZSS_SATELLITE_ID(a) ADDBITS( 4, a) /* DF249 */
482#define T_GLONASS_SATELLITE_ID(a) ADDBITS( 5, a) /* DF */
483#define T_GNSS_IOD(a) ADDBITS( 8, a) /* IDF012 */
484#define T_GPS_IODE(a) ADDBITS( 8, a) /* DF071 */
485#define T_GLONASS_IOD(a) ADDBITS( 8, a) /* DF239 */
486#define T_GALILEO_IOD(a) ADDBITS(10, a) /* DF459 */
487#define T_SBAS_T0MOD(a) ADDBITS( 9, (a/16)) /* DF468 */
488#define T_SBAS_IODCRC(a) ADDBITS(24, a) /* DF469 */
489#define T_BDS_TOEMOD(a) ADDBITS(10, (a/8)) /* DF470 */
490#define T_BDS_IOD(a) ADDBITS( 8, a) /* DF471 */
491
492/* Orbit Corrections */
493#define T_DELTA_RADIAL(a) SCALEADDBITS(22, 10000.0, a) /* DF365, IDF013 */
494#define T_DELTA_ALONG_TRACK(a) SCALEADDBITS(20, 2500.0, a) /* DF366, IDF014 */
495#define T_DELTA_CROSS_TRACK(a) SCALEADDBITS(20, 2500.0, a) /* DF367, IDF015 */
496#define T_DELTA_DOT_RADIAL(a) SCALEADDBITS(21, 1000000.0, a) /* DF368, IDF016 */
497#define T_DELTA_DOT_ALONG_TRACK(a) SCALEADDBITS(19, 250000.0, a) /* DF369, IDF017 */
498#define T_DELTA_DOT_CROSS_TRACK(a) SCALEADDBITS(19, 250000.0, a) /* DF370, IDF018 */
499
500/* Clock Corrections */
501#define T_DELTA_CLOCK_C0(a) SCALEADDBITS(22, 10000.0, a) /* DF376, IDF019 */
502#define T_DELTA_CLOCK_C1(a) SCALEADDBITS(21, 1000000.0, a) /* DF377, IDF020 */
503#define T_DELTA_CLOCK_C2(a) SCALEADDBITS(27, 50000000.0, a) /* DF378, IDF021 */
504#define T_HR_CLOCK_CORRECTION(a) SCALEADDBITS(22, 10000.0, a) /* DF390, IDF022 */
505
506/* Biases */
507#define T_NO_OF_BIASES(a) ADDBITS(5, a) /* DF, DF IDF023 */ //_NO_OF_CODE_BIASES(a)T_NO_OF_PHASE_BIASES(a)
508
509#define T_GNSS_SIGNAL_IDENTIFIER(a) ADDBITS(5, a) /* DF IDF024 */
510#define T_CODE_BIAS(a) SCALEADDBITS(14, 100.0, a) /* DF383, IDF025 */
511#define T_YAW_ANGLE(a) SCALEADDBITS( 9, 256.0/MPI, a) /* DF480, IDF026 */
512#define T_YAW_RATE(a) SCALEADDBITS( 8, 8192.0/MPI, a) /* DF481, IDF027 */
513#define T_PHASE_BIAS(a) SCALEADDBITS(20, 10000.0, a) /* DF482, IDF028 */
514
515/* Phase specific part of GNSS phase bias message */
516#define T_INTEGER_INDICATOR(a) ADDBITS( 1, a) /* DF483, IDF029 */
517#define T_WIDE_LANE_INDICATOR(a) ADDBITS( 2, a) /* DF484, IDF030 */
518#define T_DISCONTINUITY_COUNTER(a) ADDBITS( 4, a) /* DF485, IDF031 */
519#define T_DISPERSIVE_BIAS_INDICATOR(a) ADDBITS( 1, a) /* DF486, IDF032 */
520#define T_MW_CONSISTENCY_INDICATOR(a) ADDBITS( 1, a) /* DF487, IDF033 */
521
522/* URA */
523#define T_SSR_URA(a) ADDBITS( 6, a) /* DF389, IDF034 */
524
525/* Ionosphere */
526#define T_NO_IONO_LAYERS(a) ADDBITS( 2, a-1) /* DF472, IDF035 */
527#define T_IONO_HEIGHT(a) SCALEADDBITS( 8, 1/10000.0, a) /* DF473, IDF036 */
528#define T_IONO_DEGREE(a) ADDBITS( 4, a-1) /* DF474, IDF037 */
529#define T_IONO_ORDER(a) ADDBITS( 4, a-1) /* DF475, IDF038 */
530#define T_IONO_COEFF_C(a) SCALEADDBITS(16, 200.0, a) /* DF476, IDF039 */
531#define T_IONO_COEFF_S(a) SCALEADDBITS(16, 200.0, a) /* DF477, IDF040 */
532#define T_VTEC_QUALITY_INDICATOR(a) SCALEADDBITS( 9, 20.0, a) /* DF478, IDF041 */
533
534
535static double URAToValue(int ura) {
536 int urac, urav;
537 urac = ura >> 3;
538 urav = ura & 7;
539 if (!ura)
540 return 0;
541 else if (ura == 63)
542 return SSR_MAXURA;
543 return (pow(3, urac) * (1.0 + urav / 4.0) - 1.0) / 1000.0;
544}
545
546static int ValueToURA(double val) {
547 int ura;
548 if (!val)
549 return 0;
550 else if (val > 5.4665)
551 return 63;
552 for (ura = 1; ura < 63 && val > URAToValue(ura); ++ura)
553 ;
554 return ura;
555}
556//#endif /* NOENCODE */
557
558//#ifndef NODECODE
559#define DECODESTART \
560 int numbits=0; \
561 uint64_t bitbuffer=0;
562
563#define LOADSSRBITS(a) { \
564 while((a) > numbits) { \
565 if(!size--) return GCOBR_SHORTMESSAGE; \
566 bitbuffer = (bitbuffer<<8)|((unsigned char)*(buffer++)); \
567 numbits += 8; \
568 } \
569}
570
571/* extract bits from data stream
572 b = variable to store result, a = number of bits */
573#define GETSSRBITS(b, a) { \
574 LOADSSRBITS(a) \
575 b = (bitbuffer<<(64-numbits))>>(64-(a)); \
576 numbits -= (a); \
577}
578
579/* extract bits from data stream
580 b = variable to store result, a = number of bits */
581#define GETSSRBITSFACTOR(b, a, c) { \
582 LOADSSRBITS(a) \
583 b = ((bitbuffer<<(64-numbits))>>(64-(a)))*(c); \
584 numbits -= (a); \
585}
586
587/* extract signed floating value from data stream
588 b = variable to store result, a = number of bits */
589#define GETSSRFLOATSIGN(b, a, c) { \
590 LOADSSRBITS(a) \
591 b = ((double)(((int64_t)(bitbuffer<<(64-numbits)))>>(64-(a))))*(c); \
592 numbits -= (a); \
593}
594
595/* extract floating value from data stream
596 b = variable to store result, a = number of bits, c = scale factor */
597#define GETSSRFLOAT(b, a, c) { \
598 LOADSSRBITS(a) \
599 b = ((double)((bitbuffer<<(sizeof(bitbuffer)*8-numbits))>>(sizeof(bitbuffer)*8-(a))))*(c); \
600 numbits -= (a); \
601}
602
603#define SKIPSSRBITS(b) { LOADSSRBITS(b) numbits -= (b); }
604
605/* GPS macros also used for other systems when matching! */
606#define G_HEADER(a) GETSSRBITS(a, 8)
607#define G_RESERVEDH(a) GETSSRBITS(a, 6)
608#define G_SIZE(a) GETSSRBITS(a, 10)
609
610/* GNSS macros - Header part */
611#define G_RTCM_MESSAGE_NUMBER(a) GETSSRBITS(a, 12) /* DF002 */
612
613#define G_IGS_SSR_VERSION(a) GETSSRBITS(a, 3) /* IDF001 */
614#define G_IGS_MESSAGE_NUMBER(a) GETSSRBITS(a, 8) /* IDF002 */
615#define G_SSR_EPOCH_TIME(a) GETSSRBITS(a, 20) /*DF IDF003 */
616#define G_SSR_EPOCH_TIME_CHECK(a, b) {unsigned int temp; GETSSRBITS(temp, 20) \
617 if(b && a != temp) return GCOBR_TIMEMISMATCH; a = temp;}
618#define G_GLONASS_EPOCH_TIME(a, b) {unsigned int temp; GETSSRBITS(temp, 17) \
619 if(b && a != temp) return GCOBR_TIMEMISMATCH; a = temp;}
620
621#define G_SSR_UPDATE_INTERVAL(a) GETSSRBITS(a, 4) /* DF391, IDF004 */
622#define G_MULTIPLE_MESSAGE_INDICATOR(a) GETSSRBITS(a, 1) /* DF388, IDF005 */
623#define G_SSR_IOD(a) GETSSRBITS(a, 4) /* DF413, IDF007 */
624#define G_SSR_PROVIDER_ID(a) GETSSRBITS(a, 16) /* DF414, IDF008 */
625#define G_SSR_SOLUTION_ID(a) GETSSRBITS(a, 4) /* DF415, IDF009 */
626#define G_SATELLITE_REFERENCE_DATUM(a) GETSSRBITS(a, 1) /* DF375, IDF006 */
627#define G_NO_OF_SATELLITES(a) GETSSRBITS(a, 6) /* DF387, IDF010 */
628
629/* GNSS macros - Satellite specific part */
630#define G_GNSS_SATELLITE_ID(a) GETSSRBITS(a, 6) /* DF068, IDF011 */
631#define G_GLONASS_SATELLITE_ID(a) GETSSRBITS(a, 5) /* DF */
632#define G_QZSS_SATELLITE_ID(a) GETSSRBITS(a, 4) /* DF249 */
633
634#define G_GNSS_IOD(a) GETSSRBITS(a, 8) /*DF071, DF237,DF471 IDF012 */
635#define G_GALILEO_IOD(a) GETSSRBITS(a, 10) /* DF459 */
636#define G_SBAS_T0MOD(a) GETSSRBITSFACTOR(a, 9, 16) /* DF468 */
637#define G_SBAS_IODCRC(a) GETSSRBITS(a, 24) /* DF469 */
638#define G_BDS_TOEMOD(a) GETSSRBITSFACTOR(a, 10, 8) /* DF470 */
639
640/* Orbit Corrections */
641#define G_DELTA_RADIAL(a) GETSSRFLOATSIGN(a, 22, 1/10000.0) /* DF365, IDF013 */
642#define G_DELTA_ALONG_TRACK(a) GETSSRFLOATSIGN(a, 20, 1/2500.0) /* DF366, IDF014 */
643#define G_DELTA_CROSS_TRACK(a) GETSSRFLOATSIGN(a, 20, 1/2500.0) /* DF367, IDF015 */
644#define G_DELTA_DOT_RADIAL(a) GETSSRFLOATSIGN(a, 21, 1/1000000.0) /* DF368, IDF016 */
645#define G_DELTA_DOT_ALONG_TRACK(a) GETSSRFLOATSIGN(a, 19, 1/250000.0) /* DF369, IDF017 */
646#define G_DELTA_DOT_CROSS_TRACK(a) GETSSRFLOATSIGN(a, 19, 1/250000.0) /* DF370, IDF018 */
647
648/* Clock Corrections */
649#define G_DELTA_CLOCK_C0(a) GETSSRFLOATSIGN(a, 22, 1/10000.0) /* DF376, IDF019 */
650#define G_DELTA_CLOCK_C1(a) GETSSRFLOATSIGN(a, 21, 1/1000000.0) /* DF377, IDF020 */
651#define G_DELTA_CLOCK_C2(a) GETSSRFLOATSIGN(a, 27, 1/50000000.0) /* DF378, IDF021 */
652#define G_HR_CLOCK_CORRECTION(a) GETSSRFLOATSIGN(a, 22, 1/10000.0) /* DF390, IDF022 */
653
654/* Biases */
655#define G_NO_OF_BIASES(a) GETSSRBITS(a, 5) /* DF, DF IDF023 */
656#define G_GNSS_SIGNAL_IDENTIFIER(a) GETSSRBITS(a, 5) /* DF IDF024 */
657#define G_CODE_BIAS(a) GETSSRFLOATSIGN(a, 14, 1/100.0) /* DF383, IDF025 */
658#define G_YAW_ANGLE(a) GETSSRFLOAT (a, 9, MPI/256.0) /* DF480, IDF026 */
659#define G_YAW_RATE(a) GETSSRFLOATSIGN(a, 8, MPI/8192.0) /* DF481, IDF027 */
660#define G_PHASE_BIAS(a) GETSSRFLOATSIGN(a, 20, 1/10000.) /* DF482, IDF028 */
661
662/* Phase specific part of GNSS phase bias message */
663#define G_INTEGER_INDICATOR(a) GETSSRBITS(a, 1) /* DF483, IDF029 */
664#define G_WIDE_LANE_INDICATOR(a) GETSSRBITS(a, 2) /* DF484, IDF030 */
665#define G_DISCONTINUITY_COUNTER(a) GETSSRBITS(a, 4) /* DF485, IDF031 */
666#define G_DISPERSIVE_BIAS_INDICATOR(a) GETSSRBITS(a, 1) /* DF486, IDF032 */
667#define G_MW_CONSISTENCY_INDICATOR(a) GETSSRBITS(a, 1) /* DF487, IDF033 */
668
669/* URA */
670#define G_SSR_URA(a) {int temp; GETSSRBITS(temp, 6) \
671 (a) = URAToValue(temp);} /* DF389, IDF034 */
672
673/* Ionosphere */
674#define G_NO_IONO_LAYERS(a) {unsigned int temp; GETSSRBITS(temp, 2) a = temp+1;} /* DF472, IDF035 */
675#define G_IONO_HEIGHT(a) GETSSRFLOAT(a, 8 , 10000.0) /* DF473, IDF036 */
676#define G_IONO_DEGREE(a) {unsigned int temp; GETSSRBITS(temp, 4) a = temp+1;} /* DF474, IDF037 */
677#define G_IONO_ORDER(a) {unsigned int temp; GETSSRBITS(temp, 4) a = temp+1;} /* DF475, IDF038 */
678#define G_IONO_COEFF_C(a) GETSSRFLOATSIGN(a, 16,1/200.0) /* DF476, IDF039 */
679#define G_IONO_COEFF_S(a) GETSSRFLOATSIGN(a, 16,1/200.0) /* DF477, IDF040 */
680#define G_VTEC_QUALITY_INDICATOR(a) GETSSRFLOAT (a, 9, 1/20.0) /* DF478, IDF041 */
681
682//#endif /* NODECODE */
683
684};
685
686#endif /* RTCM3_CLOCK_ORBIT_H */
Note: See TracBrowser for help on using the repository browser.