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