source: ntrip/branches/BNC_2.12/src/RTCM3/clock_and_orbit/clock_orbit_rtcm.cpp@ 9209

Last change on this file since 9209 was 9209, checked in by stuerze, 20 months ago

small re-organization of debug output

  • Property svn:executable set to *
File size: 50.5 KB
Line 
1/* Programheader
2
3 Name: clock_orbit_rtcm.c
4 Project: RTCM3
5 Version: $Id: clock_orbit_rtcm.c 8996 2020-07-22 08:29:10Z stuerze $
6 Authors: Dirk Stöcker
7 Description: state space approach: RTCM
8 */
9
10#include <math.h>
11#include <stdio.h>
12#include <string.h>
13#ifndef sparc
14#include <stdint.h>
15#else
16#include <sys/types.h>
17#endif
18#include "clock_orbit_rtcm.h"
19
20
21size_t SsrCorrRtcm::MakeClockOrbit(const struct ClockOrbit *co, ClockOrbitType type,
22 int moremessagesfollow, char *buffer, size_t size) {
23 unsigned int status[CLOCKORBIT_SATNUM][COBOFS_NUM], i, s;
24
25 memset(status, 0, sizeof(status));
26
27 STARTDATA
28
29 for (s = 0; s < CLOCKORBIT_SATNUM; ++s) {
30 for (i = 0; i < COBOFS_NUM; ++i) {
31 if (co->NumberOfSat[s] && (type == COTYPE_AUTO || type == corbase[s] + i) &&
32 (co->Supplied[i] || (i <= COBOFS_CLOCK && co->Supplied[COBOFS_COMBINED]) ||
33 (i == COBOFS_COMBINED && co->Supplied[COBOFS_ORBIT] && co->Supplied[COBOFS_CLOCK]))) {
34 status[s][i] = 1;
35 if (i == COBOFS_COMBINED) {
36 status[s][COBOFS_ORBIT] = status[s][COBOFS_CLOCK] = 0;
37 } /* disable single blocks for combined type */
38 } /* check for data */
39 } /* iterate over RTCM data types */
40 } /* iterate over satellite systems */
41
42 for (s = 0; s < CLOCKORBIT_SATNUM; ++s) {
43 if (status[s][COBOFS_ORBIT]) {
44 INITBLOCK
45 T_RTCM_MESSAGE_NUMBER(corbase[s] + COBOFS_ORBIT)
46 switch (s) {
47 case CLOCKORBIT_SATGPS:
48 case CLOCKORBIT_SATGALILEO:
49 case CLOCKORBIT_SATQZSS:
50 case CLOCKORBIT_SATSBAS:
51 case CLOCKORBIT_SATBDS:
52 T_SSR_EPOCH_TIME(co->EpochTime[s])
53 break;
54 case CLOCKORBIT_SATGLONASS:
55 T_GLONASS_EPOCH_TIME(co->EpochTime[s])
56 break;
57 }
58 T_SSR_UPDATE_INTERVAL(co->UpdateInterval)
59 T_MULTIPLE_MESSAGE_INDICATOR(moremessagesfollow ? 1 : 0)
60 T_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)
61 T_SSR_IOD(co->SSRIOD)
62 T_SSR_PROVIDER_ID(co->SSRProviderID)
63 T_SSR_SOLUTION_ID(co->SSRSolutionID)
64 T_NO_OF_SATELLITES(co->NumberOfSat[s])
65 for (i = satoffset[s]; i < satoffset[s] + co->NumberOfSat[s]; ++i) {
66 switch (s) {
67 case CLOCKORBIT_SATGPS:
68 T_GPS_SATELLITE_ID(co->Sat[i].ID)
69 T_GPS_IODE(co->Sat[i].IOD)
70 break;
71 case CLOCKORBIT_SATGLONASS:
72 T_GLONASS_SATELLITE_ID(co->Sat[i].ID)
73 T_GLONASS_IOD(co->Sat[i].IOD)
74 break;
75 case CLOCKORBIT_SATGALILEO:
76 T_GPS_SATELLITE_ID(co->Sat[i].ID)
77 T_GALILEO_IOD(co->Sat[i].IOD)
78 break;
79 case CLOCKORBIT_SATQZSS:
80 T_QZSS_SATELLITE_ID(co->Sat[i].ID)
81 T_GPS_IODE(co->Sat[i].IOD)
82 break;
83 case CLOCKORBIT_SATSBAS:
84 T_GPS_SATELLITE_ID(co->Sat[i].ID)
85 T_SBAS_T0MOD(co->Sat[i].toe)
86 T_SBAS_IODCRC(co->Sat[i].IOD)
87 break;
88 case CLOCKORBIT_SATBDS:
89 T_GPS_SATELLITE_ID(co->Sat[i].ID)
90 T_BDS_TOEMOD(co->Sat[i].toe)
91 T_BDS_IOD(co->Sat[i].IOD)
92 break;
93 }
94 T_DELTA_RADIAL(co->Sat[i].Orbit.DeltaRadial)
95 T_DELTA_ALONG_TRACK(co->Sat[i].Orbit.DeltaAlongTrack)
96 T_DELTA_CROSS_TRACK(co->Sat[i].Orbit.DeltaCrossTrack)
97 T_DELTA_DOT_RADIAL(co->Sat[i].Orbit.DotDeltaRadial)
98 T_DELTA_DOT_ALONG_TRACK(co->Sat[i].Orbit.DotDeltaAlongTrack)
99 T_DELTA_DOT_CROSS_TRACK(co->Sat[i].Orbit.DotDeltaCrossTrack)
100 }
101 ENDBLOCK
102 }
103 if (status[s][COBOFS_CLOCK]) {
104 INITBLOCK
105 T_RTCM_MESSAGE_NUMBER(corbase[s] + COBOFS_CLOCK)
106 switch (s) {
107 case CLOCKORBIT_SATGPS:
108 case CLOCKORBIT_SATGALILEO:
109 case CLOCKORBIT_SATQZSS:
110 case CLOCKORBIT_SATSBAS:
111 case CLOCKORBIT_SATBDS:
112 T_SSR_EPOCH_TIME(co->EpochTime[s])
113 break;
114 case CLOCKORBIT_SATGLONASS:
115 T_GLONASS_EPOCH_TIME(co->EpochTime[s])
116 break;
117 }
118 T_SSR_UPDATE_INTERVAL(co->UpdateInterval)
119 T_MULTIPLE_MESSAGE_INDICATOR(moremessagesfollow ? 1 : 0)
120 T_SSR_IOD(co->SSRIOD)
121 T_SSR_PROVIDER_ID(co->SSRProviderID)
122 T_SSR_SOLUTION_ID(co->SSRSolutionID)
123 T_NO_OF_SATELLITES(co->NumberOfSat[s])
124 for (i = satoffset[s]; i < satoffset[s] + co->NumberOfSat[s]; ++i) {
125 switch (s) {
126 case CLOCKORBIT_SATGPS:
127 case CLOCKORBIT_SATGALILEO:
128 case CLOCKORBIT_SATSBAS:
129 case CLOCKORBIT_SATBDS:
130 T_GPS_SATELLITE_ID(co->Sat[i].ID)
131 break;
132 case CLOCKORBIT_SATQZSS:
133 T_QZSS_SATELLITE_ID(co->Sat[i].ID)
134 break;
135 case CLOCKORBIT_SATGLONASS:
136 T_GLONASS_SATELLITE_ID(co->Sat[i].ID)
137 break;
138 }
139 T_DELTA_CLOCK_C0(co->Sat[i].Clock.DeltaA0)
140 T_DELTA_CLOCK_C1(co->Sat[i].Clock.DeltaA1)
141 T_DELTA_CLOCK_C2(co->Sat[i].Clock.DeltaA2)
142 }
143 ENDBLOCK
144 }
145 if (status[s][COBOFS_COMBINED]) {
146#ifdef SPLITBLOCK
147 int nums = co->NumberOfSat[s];
148 int left, start = satoffset[s];
149 if(nums > 28) {/* split block when more than 28 sats */
150 left = nums - 28;
151 nums = 28;
152 }
153 else {
154 left = 0;
155 }
156 while(nums) {
157#endif
158 INITBLOCK
159 T_RTCM_MESSAGE_NUMBER(corbase[s] + COBOFS_COMBINED)
160 switch (s) {
161 case CLOCKORBIT_SATGPS:
162 case CLOCKORBIT_SATGALILEO:
163 case CLOCKORBIT_SATQZSS:
164 case CLOCKORBIT_SATSBAS:
165 case CLOCKORBIT_SATBDS:
166 T_SSR_EPOCH_TIME(co->EpochTime[s])
167 break;
168 case CLOCKORBIT_SATGLONASS:
169 T_GLONASS_EPOCH_TIME(co->EpochTime[s])
170 break;
171 }
172 T_SSR_UPDATE_INTERVAL(co->UpdateInterval)
173#ifdef SPLITBLOCK
174 T_MULTIPLE_MESSAGE_INDICATOR((moremessagesfollow || left) ? 1 : 0)
175#else
176 T_MULTIPLE_MESSAGE_INDICATOR(moremessagesfollow ? 1 : 0)
177#endif
178 T_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)
179 T_SSR_IOD(co->SSRIOD)
180 T_SSR_PROVIDER_ID(co->SSRProviderID)
181 T_SSR_SOLUTION_ID(co->SSRSolutionID)
182#ifdef SPLITBLOCK
183 T_NO_OF_SATELLITES(nums)
184 for(i = start; i < start+nums; ++i)
185#else
186 T_NO_OF_SATELLITES(co->NumberOfSat[s])
187 for (i = satoffset[s]; i < satoffset[s] + co->NumberOfSat[s]; ++i)
188#endif
189 {
190 switch (s) {
191 case CLOCKORBIT_SATGPS:
192 T_GPS_SATELLITE_ID(co->Sat[i].ID)
193 T_GPS_IODE(co->Sat[i].IOD)
194 break;
195 case CLOCKORBIT_SATGLONASS:
196 T_GLONASS_SATELLITE_ID(co->Sat[i].ID)
197 T_GLONASS_IOD(co->Sat[i].IOD)
198 break;
199 case CLOCKORBIT_SATGALILEO:
200 T_GPS_SATELLITE_ID(co->Sat[i].ID)
201 T_GALILEO_IOD(co->Sat[i].IOD)
202 break;
203 case CLOCKORBIT_SATQZSS:
204 T_QZSS_SATELLITE_ID(co->Sat[i].ID)
205 T_GPS_IODE(co->Sat[i].IOD)
206 break;
207 case CLOCKORBIT_SATSBAS:
208 T_GPS_SATELLITE_ID(co->Sat[i].ID)
209 T_SBAS_T0MOD(co->Sat[i].toe)
210 T_SBAS_IODCRC(co->Sat[i].IOD)
211 break;
212 case CLOCKORBIT_SATBDS:
213 T_GPS_SATELLITE_ID(co->Sat[i].ID)
214 T_BDS_TOEMOD(co->Sat[i].toe)
215 T_BDS_IOD(co->Sat[i].IOD)
216 break;
217 }
218 T_DELTA_RADIAL(co->Sat[i].Orbit.DeltaRadial)
219 T_DELTA_ALONG_TRACK(co->Sat[i].Orbit.DeltaAlongTrack)
220 T_DELTA_CROSS_TRACK(co->Sat[i].Orbit.DeltaCrossTrack)
221 T_DELTA_DOT_RADIAL(co->Sat[i].Orbit.DotDeltaRadial)
222 T_DELTA_DOT_ALONG_TRACK(co->Sat[i].Orbit.DotDeltaAlongTrack)
223 T_DELTA_DOT_CROSS_TRACK(co->Sat[i].Orbit.DotDeltaCrossTrack)
224 T_DELTA_CLOCK_C0(co->Sat[i].Clock.DeltaA0)
225 T_DELTA_CLOCK_C1(co->Sat[i].Clock.DeltaA1)
226 T_DELTA_CLOCK_C2(co->Sat[i].Clock.DeltaA2)
227 }
228 ENDBLOCK
229#ifdef SPLITBLOCK
230 start += nums;
231 nums = left;
232 left = 0;
233 }
234#endif
235 }
236 if (status[s][COBOFS_HR]) {
237 INITBLOCK
238 T_RTCM_MESSAGE_NUMBER(corbase[s] + COBOFS_HR)
239 switch (s) {
240 case CLOCKORBIT_SATGPS:
241 case CLOCKORBIT_SATGALILEO:
242 case CLOCKORBIT_SATQZSS:
243 case CLOCKORBIT_SATSBAS:
244 case CLOCKORBIT_SATBDS:
245 T_SSR_EPOCH_TIME(co->EpochTime[s])
246 break;
247 case CLOCKORBIT_SATGLONASS:
248 T_GLONASS_EPOCH_TIME(co->EpochTime[s])
249 break;
250 }
251 T_SSR_UPDATE_INTERVAL(co->UpdateInterval)
252 T_MULTIPLE_MESSAGE_INDICATOR(moremessagesfollow ? 1 : 0)
253 T_SSR_IOD(co->SSRIOD)
254 T_SSR_PROVIDER_ID(co->SSRProviderID)
255 T_SSR_SOLUTION_ID(co->SSRSolutionID)
256 T_NO_OF_SATELLITES(co->NumberOfSat[s])
257 for (i = satoffset[s]; i < satoffset[s] + co->NumberOfSat[s]; ++i) {
258 switch (s) {
259 case CLOCKORBIT_SATGPS:
260 case CLOCKORBIT_SATGALILEO:
261 case CLOCKORBIT_SATSBAS:
262 case CLOCKORBIT_SATBDS:
263 T_GPS_SATELLITE_ID(co->Sat[i].ID)
264 break;
265 case CLOCKORBIT_SATQZSS:
266 T_QZSS_SATELLITE_ID(co->Sat[i].ID)
267 break;
268 case CLOCKORBIT_SATGLONASS:
269 T_GLONASS_SATELLITE_ID(co->Sat[i].ID)
270 break;
271 }
272 T_HR_CLOCK_CORRECTION(co->Sat[i].hrclock)
273 }
274 ENDBLOCK
275 }
276 if (status[s][COBOFS_URA]) {
277 INITBLOCK
278 T_RTCM_MESSAGE_NUMBER(corbase[s] + COBOFS_URA)
279 switch (s) {
280 case CLOCKORBIT_SATGPS:
281 case CLOCKORBIT_SATGALILEO:
282 case CLOCKORBIT_SATQZSS:
283 case CLOCKORBIT_SATSBAS:
284 case CLOCKORBIT_SATBDS:
285 T_SSR_EPOCH_TIME(co->EpochTime[s])
286 break;
287 case CLOCKORBIT_SATGLONASS:
288 T_GLONASS_EPOCH_TIME(co->EpochTime[s])
289 break;
290 }
291 T_SSR_UPDATE_INTERVAL(co->UpdateInterval)
292 T_MULTIPLE_MESSAGE_INDICATOR(moremessagesfollow ? 1 : 0)
293 T_SSR_IOD(co->SSRIOD)
294 T_SSR_PROVIDER_ID(co->SSRProviderID)
295 T_SSR_SOLUTION_ID(co->SSRSolutionID)
296 T_NO_OF_SATELLITES(co->NumberOfSat[s])
297 for (i = satoffset[s]; i < satoffset[s] + co->NumberOfSat[s]; ++i) {
298 switch (s) {
299 case CLOCKORBIT_SATGPS:
300 case CLOCKORBIT_SATGALILEO:
301 case CLOCKORBIT_SATSBAS:
302 case CLOCKORBIT_SATBDS:
303 T_GPS_SATELLITE_ID(co->Sat[i].ID)
304 break;
305 case CLOCKORBIT_SATQZSS:
306 T_QZSS_SATELLITE_ID(co->Sat[i].ID)
307 break;
308 case CLOCKORBIT_SATGLONASS:
309 T_GLONASS_SATELLITE_ID(co->Sat[i].ID)
310 break;
311 }
312 T_SSR_URA(ValueToURA(co->Sat[i].UserRangeAccuracy))
313 }
314 ENDBLOCK
315 }
316 }
317 return ressize;
318}
319
320size_t SsrCorrRtcm::MakeCodeBias(const struct CodeBias *b, CodeBiasType type,
321 int moremessagesfollow, char *buffer, size_t size) {
322 unsigned int s, i, j;
323
324 STARTDATA
325
326 for (s = 0; s < CLOCKORBIT_SATNUM; ++s) {
327 if (b->NumberOfSat[s] && (type == CBTYPE_AUTO || type == corbase[s] + COBOFS_CBIAS)) {
328 INITBLOCK
329 T_RTCM_MESSAGE_NUMBER(corbase[s] + COBOFS_CBIAS)
330 switch (s) {
331 case CLOCKORBIT_SATGPS:
332 case CLOCKORBIT_SATGALILEO:
333 case CLOCKORBIT_SATQZSS:
334 case CLOCKORBIT_SATSBAS:
335 case CLOCKORBIT_SATBDS:
336 T_SSR_EPOCH_TIME(b->EpochTime[s])
337 break;
338 case CLOCKORBIT_SATGLONASS:
339 T_GLONASS_EPOCH_TIME(b->EpochTime[s])
340 break;
341 }
342 T_SSR_UPDATE_INTERVAL(b->UpdateInterval)
343 T_MULTIPLE_MESSAGE_INDICATOR(moremessagesfollow ? 1 : 0)
344 T_SSR_IOD(b->SSRIOD)
345 T_SSR_PROVIDER_ID(b->SSRProviderID)
346 T_SSR_SOLUTION_ID(b->SSRSolutionID)
347 T_NO_OF_SATELLITES(b->NumberOfSat[s])
348 for (i = satoffset[s]; i < satoffset[s] + b->NumberOfSat[s]; ++i) {
349 switch (s) {
350 case CLOCKORBIT_SATGPS:
351 case CLOCKORBIT_SATGALILEO:
352 case CLOCKORBIT_SATSBAS:
353 case CLOCKORBIT_SATBDS:
354 T_GPS_SATELLITE_ID(b->Sat[i].ID)
355 break;
356 case CLOCKORBIT_SATQZSS:
357 T_QZSS_SATELLITE_ID(b->Sat[i].ID)
358 break;
359 case CLOCKORBIT_SATGLONASS:
360 T_GLONASS_SATELLITE_ID(b->Sat[i].ID)
361 break;
362 }
363 T_NO_OF_BIASES(b->Sat[i].NumberOfCodeBiases)
364 for (j = 0; j < b->Sat[i].NumberOfCodeBiases; ++j) {
365 T_GNSS_SIGNAL_IDENTIFIER(b->Sat[i].Biases[j].Type)
366 T_CODE_BIAS(b->Sat[i].Biases[j].Bias)
367 }
368 }
369 ENDBLOCK
370 }
371 }
372 return ressize;
373}
374
375size_t SsrCorrRtcm::MakePhaseBias(const struct PhaseBias *b, PhaseBiasType type,
376 int moremessagesfollow, char *buffer, size_t size) {
377 unsigned int s, i, j;
378
379 STARTDATA
380
381 for (s = 0; s < CLOCKORBIT_SATNUM; ++s) {
382 if (b->NumberOfSat[s] && (type == PBTYPE_AUTO || type == s + PBTYPE_BASE)) {
383 INITBLOCK
384 T_RTCM_MESSAGE_NUMBER(s + PBTYPE_BASE)
385 switch (s) {
386 case CLOCKORBIT_SATGPS:
387 case CLOCKORBIT_SATGALILEO:
388 case CLOCKORBIT_SATQZSS:
389 case CLOCKORBIT_SATSBAS:
390 case CLOCKORBIT_SATBDS:
391 T_SSR_EPOCH_TIME(b->EpochTime[s])
392 break;
393 case CLOCKORBIT_SATGLONASS:
394 T_GLONASS_EPOCH_TIME(b->EpochTime[s])
395 break;
396 }
397 T_SSR_UPDATE_INTERVAL(b->UpdateInterval)
398 T_MULTIPLE_MESSAGE_INDICATOR(moremessagesfollow ? 1 : 0)
399 T_SSR_IOD(b->SSRIOD)
400 T_SSR_PROVIDER_ID(b->SSRProviderID)
401 T_SSR_SOLUTION_ID(b->SSRSolutionID)
402 T_DISPERSIVE_BIAS_INDICATOR(b->DispersiveBiasConsistencyIndicator ? 1 : 0)
403 T_MW_CONSISTENCY_INDICATOR(b->MWConsistencyIndicator ? 1 : 0)
404 T_NO_OF_SATELLITES(b->NumberOfSat[s])
405 for (i = satoffset[s]; i < satoffset[s] + b->NumberOfSat[s]; ++i) {
406 switch (s) {
407 case CLOCKORBIT_SATGPS:
408 case CLOCKORBIT_SATGALILEO:
409 case CLOCKORBIT_SATSBAS:
410 case CLOCKORBIT_SATBDS:
411 T_GPS_SATELLITE_ID(b->Sat[i].ID)
412 break;
413 case CLOCKORBIT_SATQZSS:
414 T_QZSS_SATELLITE_ID(b->Sat[i].ID)
415 break;
416 case CLOCKORBIT_SATGLONASS:
417 T_GLONASS_SATELLITE_ID(b->Sat[i].ID)
418 break;
419 }
420 T_NO_OF_BIASES(b->Sat[i].NumberOfPhaseBiases)
421 T_YAW_ANGLE(b->Sat[i].YawAngle)
422 T_YAW_RATE(b->Sat[i].YawRate)
423 for (j = 0; j < b->Sat[i].NumberOfPhaseBiases; ++j) {
424 T_GNSS_SIGNAL_IDENTIFIER(b->Sat[i].Biases[j].Type)
425 T_INTEGER_INDICATOR(
426 b->Sat[i].Biases[j].SignalIntegerIndicator ? 1 : 0)
427 T_WIDE_LANE_INDICATOR(
428 b->Sat[i].Biases[j].SignalsWideLaneIntegerIndicator)
429 T_DISCONTINUITY_COUNTER(
430 b->Sat[i].Biases[j].SignalDiscontinuityCounter)
431 T_PHASE_BIAS(b->Sat[i].Biases[j].Bias)
432 }
433 }
434 ENDBLOCK
435 }
436 }
437 return ressize;
438}
439
440size_t SsrCorrRtcm::MakeVTEC(const struct VTEC *v, int moremessagesfollow, char *buffer, size_t size) {
441 unsigned int l, o, d;
442
443 STARTDATA
444 INITBLOCK
445 T_RTCM_MESSAGE_NUMBER(VTEC_BASE)
446 T_SSR_EPOCH_TIME(v->EpochTime)
447 T_SSR_UPDATE_INTERVAL(v->UpdateInterval)
448 T_MULTIPLE_MESSAGE_INDICATOR(moremessagesfollow ? 1 : 0)
449 T_SSR_IOD(v->SSRIOD)
450 T_SSR_PROVIDER_ID(v->SSRProviderID)
451 T_SSR_SOLUTION_ID(v->SSRSolutionID)
452 T_VTEC_QUALITY_INDICATOR(v->Quality)
453 T_NO_IONO_LAYERS(v->NumLayers)
454 for (l = 0; l < v->NumLayers; ++l) {
455 T_IONO_HEIGHT(v->Layers[l].Height)
456 T_IONO_DEGREE(v->Layers[l].Degree)
457 T_IONO_ORDER(v->Layers[l].Order)
458 for (o = 0; o <= v->Layers[l].Order; ++o) {
459 for (d = o; d <= v->Layers[l].Degree; ++d) {
460 T_IONO_COEFF_C(v->Layers[l].Cosinus[d][o])
461 }
462 }
463 for (o = 1; o <= v->Layers[l].Order; ++o) {
464 for (d = o; d <= v->Layers[l].Degree; ++d) {
465 T_IONO_COEFF_S(v->Layers[l].Sinus[d][o])
466 }
467 }
468 }
469 ENDBLOCK
470 return ressize;
471}
472
473enum GCOB_RETURN SsrCorrRtcm::GetSSR(struct ClockOrbit *co, struct CodeBias *b,struct VTEC *v,
474 struct PhaseBias *pb, const char *buffer, size_t size, int *bytesused) {
475 int mmi = 0, h, rs;
476 unsigned int type, pos, i, j, s, nums, id;
477 size_t sizeofrtcmblock;
478 const char *blockstart = buffer;
479 DECODESTART
480
481 if (size < 7)
482 return GCOBR_SHORTBUFFER;
483
484#ifdef BNC_DEBUG_SSR
485 fprintf(stderr, "GetSSR-RTCM START: size %d, numbits %d\n",(int)size, numbits);
486#endif
487
488 G_HEADER(h)
489 G_RESERVEDH(rs)
490 G_SIZE(sizeofrtcmblock);
491
492 if ((unsigned char) h != 0xD3 || rs)
493 return GCOBR_UNKNOWNDATA;
494 if (size < sizeofrtcmblock + 3) /* 3 header bytes already removed */
495 return GCOBR_MESSAGEEXCEEDSBUFFER;
496 if (CRC24(sizeofrtcmblock + 3, (const unsigned char *) blockstart) !=
497 (uint32_t) ((((unsigned char) buffer[sizeofrtcmblock]) << 16) |
498 (((unsigned char) buffer[sizeofrtcmblock + 1]) << 8) |
499 (((unsigned char) buffer[sizeofrtcmblock + 2]))))
500 return GCOBR_CRCMISMATCH;
501 size = sizeofrtcmblock; /* reduce size, so overflows are detected */
502
503 G_RTCM_MESSAGE_NUMBER(type)
504#ifdef BNC_DEBUG_SSR
505 fprintf(stderr, "type %d size %d\n",type,(int)sizeofrtcmblock);
506#endif
507 if (bytesused)
508 *bytesused = sizeofrtcmblock + 6;
509 if (type == VTEC_BASE) {
510 unsigned int l, o, d;
511 if (!v)
512 return GCOBR_NOVTECPARAMETER;
513 memset(v, 0, sizeof(*v));
514 G_SSR_EPOCH_TIME(v->EpochTime)
515 G_SSR_UPDATE_INTERVAL(v->UpdateInterval)
516 G_MULTIPLE_MESSAGE_INDICATOR(mmi)
517 G_SSR_IOD(v->SSRIOD)
518 G_SSR_PROVIDER_ID(v->SSRProviderID)
519 G_SSR_SOLUTION_ID(v->SSRSolutionID)
520 G_VTEC_QUALITY_INDICATOR(v->Quality)
521 G_NO_IONO_LAYERS(v->NumLayers)
522#ifdef BNC_DEBUG_SSR
523 fprintf(stderr, "epochTime %d ui %d mmi %d ssrIod %d providerId %d solId %d vtecQ %8.3f numLay %d \n",
524 v->EpochTime, v->UpdateInterval, mmi,
525 v->SSRIOD, v->SSRProviderID, v->SSRSolutionID, v->Quality, v->NumLayers);
526#endif
527 for (l = 0; l < v->NumLayers; ++l) {
528 G_IONO_HEIGHT(v->Layers[l].Height)
529 G_IONO_DEGREE(v->Layers[l].Degree)
530 G_IONO_ORDER(v->Layers[l].Order)
531#ifdef BNC_DEBUG_SSR
532 fprintf(stderr, "h %8.3f deg %d ord %d \n",
533 v->Layers[l].Height, v->Layers[l].Degree, v->Layers[l].Order);
534#endif
535 for (o = 0; o <= v->Layers[l].Order; ++o) {
536 for (d = o; d <= v->Layers[l].Degree; ++d) {
537 G_IONO_COEFF_C(v->Layers[l].Cosinus[d][o])
538#ifdef BNC_DEBUG_SSR
539 fprintf(stderr, "C[%02d][%02d] %8.3f \n",
540 d, o, v->Layers[l].Cosinus[d][o]);
541#endif
542 }
543 }
544 for (o = 1; o <= v->Layers[l].Order; ++o) {
545 for (d = o; d <= v->Layers[l].Degree; ++d) {
546 G_IONO_COEFF_S(v->Layers[l].Sinus[d][o])
547#ifdef BNC_DEBUG_SSR
548 fprintf(stderr, "S[%02d][%02d] %8.3f \n",
549 d, o, v->Layers[l].Sinus[d][o]);
550#endif
551 }
552 }
553 }
554#ifdef BNC_DEBUG_SSR
555 for(type = 0; type < (unsigned int)size && (unsigned char)buffer[type] != 0xD3; ++type)
556 numbits += 8;
557 fprintf(stderr, "numbits left %d\n",numbits);
558#endif
559 return mmi ? GCOBR_MESSAGEFOLLOWS : GCOBR_OK;
560 }
561 for (s = CLOCKORBIT_SATNUM; s-- > 0;) {
562 if (type == PBTYPE_BASE + s) {
563 if (!pb)
564 return GCOBR_NOPHASEBIASPARAMETER;
565 pb->messageType = type;
566 switch (s) {
567 case CLOCKORBIT_SATGPS:
568 case CLOCKORBIT_SATGALILEO:
569 case CLOCKORBIT_SATQZSS:
570 case CLOCKORBIT_SATSBAS:
571 case CLOCKORBIT_SATBDS:
572 G_SSR_EPOCH_TIME_CHECK(pb->EpochTime[s], pb->NumberOfSat[s])
573 break;
574 case CLOCKORBIT_SATGLONASS:
575 G_GLONASS_EPOCH_TIME(pb->EpochTime[s], pb->NumberOfSat[s])
576 break;
577 }
578 G_SSR_UPDATE_INTERVAL(pb->UpdateInterval)
579 G_MULTIPLE_MESSAGE_INDICATOR(mmi)
580 G_SSR_IOD(pb->SSRIOD)
581 G_SSR_PROVIDER_ID(pb->SSRProviderID)
582 G_SSR_SOLUTION_ID(pb->SSRSolutionID)
583 G_DISPERSIVE_BIAS_INDICATOR(pb->DispersiveBiasConsistencyIndicator)
584 G_MW_CONSISTENCY_INDICATOR(pb->MWConsistencyIndicator)
585 G_NO_OF_SATELLITES(nums)
586#ifdef BNC_DEBUG_SSR
587 fprintf(stderr, "epochTime %d ui %d mmi %d sats %d/%d ssrIod %d providerId %d solId %d dispInd %d mwInd %d\n",
588 pb->EpochTime[s], pb->UpdateInterval,mmi,pb->NumberOfSat[s],nums,
589 pb->SSRIOD, pb->SSRProviderID, pb->SSRSolutionID,
590 pb->DispersiveBiasConsistencyIndicator, pb->MWConsistencyIndicator);
591#endif
592 for (i = 0; i < nums; ++i) {
593 switch (s) {
594 case CLOCKORBIT_SATGPS:
595 case CLOCKORBIT_SATGALILEO:
596 case CLOCKORBIT_SATSBAS:
597 case CLOCKORBIT_SATBDS:
598 G_GNSS_SATELLITE_ID(id)
599 break;
600 case CLOCKORBIT_SATQZSS:
601 G_QZSS_SATELLITE_ID(id)
602 break;
603 case CLOCKORBIT_SATGLONASS:
604 G_GLONASS_SATELLITE_ID(id)
605 break;
606 }
607 for (pos = satoffset[s];
608 pos < satoffset[s] + pb->NumberOfSat[s] && pb->Sat[pos].ID != id;
609 ++pos)
610 ;
611 if (pos >= satoffset[s + 1])
612 return GCOBR_DATAMISMATCH;
613 else if (pos == pb->NumberOfSat[s] + satoffset[s])
614 ++pb->NumberOfSat[s];
615 pb->Sat[pos].ID = id;
616 G_NO_OF_BIASES(pb->Sat[pos].NumberOfPhaseBiases)
617 G_YAW_ANGLE(pb->Sat[pos].YawAngle)
618 G_YAW_RATE(pb->Sat[pos].YawRate)
619#ifdef BNC_DEBUG_SSR
620 fprintf(stderr, "id %2d #%d y %10.6f yr %10.6f ",
621 pb->Sat[pos].ID, pb->Sat[pos].NumberOfPhaseBiases,
622 pb->Sat[pos].YawAngle/MPI, pb->Sat[pos].YawRate/MPI);
623#endif
624 for (j = 0; j < pb->Sat[pos].NumberOfPhaseBiases; ++j) {
625 G_GNSS_SIGNAL_IDENTIFIER(pb->Sat[pos].Biases[j].Type)
626 G_INTEGER_INDICATOR(pb->Sat[pos].Biases[j].SignalIntegerIndicator)
627 G_WIDE_LANE_INDICATOR(
628 pb->Sat[pos].Biases[j].SignalsWideLaneIntegerIndicator)
629 G_DISCONTINUITY_COUNTER(
630 pb->Sat[pos].Biases[j].SignalDiscontinuityCounter)
631 G_PHASE_BIAS(pb->Sat[pos].Biases[j].Bias)
632#ifdef BNC_DEBUG_SSR
633 fprintf(stderr, "t%02d int %d wl %d disc %d b %8.4f ",
634 pb->Sat[pos].Biases[j].Type,
635 pb->Sat[pos].Biases[j].SignalIntegerIndicator,
636 pb->Sat[pos].Biases[j].SignalsWideLaneIntegerIndicator,
637 pb->Sat[pos].Biases[j].SignalDiscontinuityCounter,
638 pb->Sat[pos].Biases[j].Bias);
639#endif
640 }
641#ifdef BNC_DEBUG_SSR
642 fprintf(stderr, "\n");
643#endif
644 }
645#ifdef BNC_DEBUG_SSR
646 for(type = 0; type < (unsigned int)size && (unsigned char)buffer[type] != 0xD3; ++type)
647 numbits += 8;
648 fprintf(stderr, "numbits left %d\n",numbits);
649#endif
650 return mmi ? GCOBR_MESSAGEFOLLOWS : GCOBR_OK;
651 }
652 else if (type >= corbase[s]) {
653 unsigned int corrOffset = type - corbase[s];
654 if (corrOffset == COBOFS_ORBIT) {
655 if (!co)
656 return GCOBR_NOCLOCKORBITPARAMETER;
657 co->messageType = type;
658 switch (s) {
659 case CLOCKORBIT_SATGPS:
660 case CLOCKORBIT_SATGALILEO:
661 case CLOCKORBIT_SATQZSS:
662 case CLOCKORBIT_SATSBAS:
663 case CLOCKORBIT_SATBDS:
664 G_SSR_EPOCH_TIME_CHECK(co->EpochTime[s], co->NumberOfSat[s])
665 break;
666 case CLOCKORBIT_SATGLONASS:
667 G_GLONASS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s])
668 break;
669 }
670 G_SSR_UPDATE_INTERVAL(co->UpdateInterval)
671 G_MULTIPLE_MESSAGE_INDICATOR(mmi)
672 G_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)
673 G_SSR_IOD(co->SSRIOD)
674 G_SSR_PROVIDER_ID(co->SSRProviderID)
675 G_SSR_SOLUTION_ID(co->SSRSolutionID)
676 G_NO_OF_SATELLITES(nums)
677 co->Supplied[COBOFS_ORBIT] |= 1;
678#ifdef BNC_DEBUG_SSR
679 fprintf(stderr, "epochTime %d ui %d mmi %d sats %d/%d rd %d ssrIod %d providerId %d solId %d\n",
680 co->EpochTime[s], co->UpdateInterval,mmi,co->NumberOfSat[s],nums,
681 co->SatRefDatum, co->SSRIOD, co->SSRProviderID, co->SSRSolutionID);
682#endif
683 for (i = 0; i < nums; ++i) {
684 switch (s) {
685 case CLOCKORBIT_SATGPS:
686 case CLOCKORBIT_SATGALILEO:
687 case CLOCKORBIT_SATSBAS:
688 case CLOCKORBIT_SATBDS:
689 G_GNSS_SATELLITE_ID(id)
690 break;
691 case CLOCKORBIT_SATQZSS:
692 G_QZSS_SATELLITE_ID(id)
693 break;
694 case CLOCKORBIT_SATGLONASS:
695 G_GLONASS_SATELLITE_ID(id)
696 break;
697 }
698 for (pos = satoffset[s];
699 pos < satoffset[s] + co->NumberOfSat[s] && co->Sat[pos].ID != id;
700 ++pos)
701 ;
702 if (pos >= satoffset[s + 1])
703 return GCOBR_DATAMISMATCH;
704 else if (pos == co->NumberOfSat[s] + satoffset[s])
705 ++co->NumberOfSat[s];
706 co->Sat[pos].ID = id;
707
708 switch (s) {
709 case CLOCKORBIT_SATGPS:
710 case CLOCKORBIT_SATQZSS:
711 G_GNSS_IOD(co->Sat[pos].IOD)
712 break;
713 case CLOCKORBIT_SATGLONASS:
714 G_GNSS_IOD(co->Sat[pos].IOD)
715 break;
716 case CLOCKORBIT_SATGALILEO:
717 G_GALILEO_IOD(co->Sat[pos].IOD)
718 break;
719 case CLOCKORBIT_SATSBAS:
720 G_SBAS_T0MOD(co->Sat[pos].toe)
721 G_SBAS_IODCRC(co->Sat[pos].IOD)
722 break;
723 case CLOCKORBIT_SATBDS:
724 G_BDS_TOEMOD(co->Sat[pos].toe)
725 G_GNSS_IOD(co->Sat[pos].IOD)
726 break;
727 }
728 G_DELTA_RADIAL(co->Sat[pos].Orbit.DeltaRadial)
729 G_DELTA_ALONG_TRACK(co->Sat[pos].Orbit.DeltaAlongTrack)
730 G_DELTA_CROSS_TRACK(co->Sat[pos].Orbit.DeltaCrossTrack)
731 G_DELTA_DOT_RADIAL(co->Sat[pos].Orbit.DotDeltaRadial)
732 G_DELTA_DOT_ALONG_TRACK(co->Sat[pos].Orbit.DotDeltaAlongTrack)
733 G_DELTA_DOT_CROSS_TRACK(co->Sat[pos].Orbit.DotDeltaCrossTrack)
734#ifdef BNC_DEBUG_SSR
735 fprintf(stderr, "id %2d iod %3d dr %8.4f da %8.4f dc %8.4f dr %8.3f da %8.3f dc %8.3f\n",
736 co->Sat[pos].ID,co->Sat[pos].IOD,co->Sat[pos].Orbit.DeltaRadial,
737 co->Sat[pos].Orbit.DeltaAlongTrack,co->Sat[pos].Orbit.DeltaCrossTrack,
738 co->Sat[pos].Orbit.DotDeltaRadial,
739 co->Sat[pos].Orbit.DotDeltaAlongTrack,
740 co->Sat[pos].Orbit.DotDeltaCrossTrack);
741#endif
742 }
743 }
744 else if (corrOffset == COBOFS_CLOCK) {
745 if (!co)
746 return GCOBR_NOCLOCKORBITPARAMETER;
747 co->messageType = type;
748 switch (s) {
749 case CLOCKORBIT_SATGPS:
750 case CLOCKORBIT_SATGALILEO:
751 case CLOCKORBIT_SATQZSS:
752 case CLOCKORBIT_SATSBAS:
753 case CLOCKORBIT_SATBDS:
754 G_SSR_EPOCH_TIME_CHECK(co->EpochTime[s], co->NumberOfSat[s])
755 break;
756 case CLOCKORBIT_SATGLONASS:
757 G_GLONASS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s])
758 break;
759 }
760 G_SSR_UPDATE_INTERVAL(co->UpdateInterval)
761 G_MULTIPLE_MESSAGE_INDICATOR(mmi)
762 G_SSR_IOD(co->SSRIOD)
763 G_SSR_PROVIDER_ID(co->SSRProviderID)
764 G_SSR_SOLUTION_ID(co->SSRSolutionID)
765 G_NO_OF_SATELLITES(nums)
766 co->Supplied[COBOFS_CLOCK] |= 1;
767#ifdef BNC_DEBUG_SSR
768 fprintf(stderr, "epochTime %d ui %d mmi %d sats %d/%d ssrIod %d providerId %d solId %d\n",
769 co->EpochTime[s], co->UpdateInterval,mmi,co->NumberOfSat[s],nums,
770 co->SSRIOD, co->SSRProviderID, co->SSRSolutionID);
771#endif
772 for (i = 0; i < nums; ++i) {
773 switch (s) {
774 case CLOCKORBIT_SATGPS:
775 case CLOCKORBIT_SATGALILEO:
776 case CLOCKORBIT_SATSBAS:
777 case CLOCKORBIT_SATBDS:
778 G_GNSS_SATELLITE_ID(id)
779 break;
780 case CLOCKORBIT_SATQZSS:
781 G_QZSS_SATELLITE_ID(id)
782 break;
783 case CLOCKORBIT_SATGLONASS:
784 G_GLONASS_SATELLITE_ID(id)
785 break;
786 }
787 for (pos = satoffset[s];
788 pos < satoffset[s] + co->NumberOfSat[s] && co->Sat[pos].ID != id;
789 ++pos)
790 ;
791 if (pos >= satoffset[s + 1])
792 return GCOBR_DATAMISMATCH;
793 else if (pos == co->NumberOfSat[s] + satoffset[s])
794 ++co->NumberOfSat[s];
795 co->Sat[pos].ID = id;
796
797 G_DELTA_CLOCK_C0(co->Sat[pos].Clock.DeltaA0)
798 G_DELTA_CLOCK_C1(co->Sat[pos].Clock.DeltaA1)
799 G_DELTA_CLOCK_C2(co->Sat[pos].Clock.DeltaA2)
800#ifdef BNC_DEBUG_SSR
801 fprintf(stderr, "id %2d c0 %8.3f c1 %8.3f c2 %8.3f\n",
802 co->Sat[pos].ID, co->Sat[pos].Clock.DeltaA0, co->Sat[pos].Clock.DeltaA1,
803 co->Sat[pos].Clock.DeltaA2);
804#endif
805 }
806 }
807 else if (corrOffset == COBOFS_COMBINED) {
808 if (!co)
809 return GCOBR_NOCLOCKORBITPARAMETER;
810 co->messageType = type;
811 switch (s) {
812 case CLOCKORBIT_SATGPS:
813 case CLOCKORBIT_SATGALILEO:
814 case CLOCKORBIT_SATQZSS:
815 case CLOCKORBIT_SATSBAS:
816 case CLOCKORBIT_SATBDS:
817 G_SSR_EPOCH_TIME_CHECK(co->EpochTime[s], co->NumberOfSat[s])
818 break;
819 case CLOCKORBIT_SATGLONASS:
820 G_GLONASS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s])
821 break;
822 }
823 G_SSR_UPDATE_INTERVAL(co->UpdateInterval)
824 G_MULTIPLE_MESSAGE_INDICATOR(mmi)
825 G_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)
826 G_SSR_IOD(co->SSRIOD)
827 G_SSR_PROVIDER_ID(co->SSRProviderID)
828 G_SSR_SOLUTION_ID(co->SSRSolutionID)
829 G_NO_OF_SATELLITES(nums)
830 co->Supplied[COBOFS_ORBIT] |= 1;
831 co->Supplied[COBOFS_CLOCK] |= 1;
832#ifdef BNC_DEBUG_SSR
833 fprintf(stderr, "epochTime %d ui %d mmi %d sats %d/%d rd %d ssrIod %d providerId %d solId %d\n",
834 co->EpochTime[s], co->UpdateInterval,mmi,co->NumberOfSat[s],nums,
835 co->SatRefDatum, co->SSRIOD, co->SSRProviderID, co->SSRSolutionID);
836#endif
837 for (i = 0; i < nums; ++i) {
838 switch (s) {
839 case CLOCKORBIT_SATGPS:
840 case CLOCKORBIT_SATGALILEO:
841 case CLOCKORBIT_SATSBAS:
842 case CLOCKORBIT_SATBDS:
843 G_GNSS_SATELLITE_ID(id)
844 break;
845 case CLOCKORBIT_SATQZSS:
846 G_QZSS_SATELLITE_ID(id)
847 break;
848 case CLOCKORBIT_SATGLONASS:
849 G_GLONASS_SATELLITE_ID(id)
850 break;
851 }
852 for (pos = satoffset[s];
853 pos < satoffset[s] + co->NumberOfSat[s] && co->Sat[pos].ID != id;
854 ++pos)
855 ;
856 if (pos >= satoffset[s + 1])
857 return GCOBR_DATAMISMATCH;
858 else if (pos == co->NumberOfSat[s] + satoffset[s])
859 ++co->NumberOfSat[s];
860 co->Sat[pos].ID = id;
861
862 switch (s) {
863 case CLOCKORBIT_SATGPS:
864 case CLOCKORBIT_SATQZSS:
865 G_GNSS_IOD(co->Sat[pos].IOD)
866 break;
867 case CLOCKORBIT_SATGLONASS:
868 G_GNSS_IOD(co->Sat[pos].IOD)
869 break;
870 case CLOCKORBIT_SATGALILEO:
871 G_GALILEO_IOD(co->Sat[pos].IOD)
872 break;
873 case CLOCKORBIT_SATSBAS:
874 G_SBAS_T0MOD(co->Sat[pos].toe)
875 G_SBAS_IODCRC(co->Sat[pos].IOD)
876 break;
877 case CLOCKORBIT_SATBDS:
878 G_BDS_TOEMOD(co->Sat[pos].toe)
879 G_GNSS_IOD(co->Sat[pos].IOD)
880 break;
881 }
882 G_DELTA_RADIAL(co->Sat[pos].Orbit.DeltaRadial)
883 G_DELTA_ALONG_TRACK(co->Sat[pos].Orbit.DeltaAlongTrack)
884 G_DELTA_CROSS_TRACK(co->Sat[pos].Orbit.DeltaCrossTrack)
885 G_DELTA_DOT_RADIAL(co->Sat[pos].Orbit.DotDeltaRadial)
886 G_DELTA_DOT_ALONG_TRACK(co->Sat[pos].Orbit.DotDeltaAlongTrack)
887 G_DELTA_DOT_CROSS_TRACK(co->Sat[pos].Orbit.DotDeltaCrossTrack)
888 G_DELTA_CLOCK_C0(co->Sat[pos].Clock.DeltaA0)
889 G_DELTA_CLOCK_C1(co->Sat[pos].Clock.DeltaA1)
890 G_DELTA_CLOCK_C2(co->Sat[pos].Clock.DeltaA2)
891#ifdef BNC_DEBUG_SSR
892 fprintf(stderr, "id %2d iod %3d dr %10.6f da %10.6f dc %10.6f dr %10.6f da %10.6f dc %10.6f c0 %10.6f c1 %10.6f c2 %10.6f\n",
893 co->Sat[pos].ID,co->Sat[pos].IOD,co->Sat[pos].Orbit.DeltaRadial,
894 co->Sat[pos].Orbit.DeltaAlongTrack,co->Sat[pos].Orbit.DeltaCrossTrack,
895 co->Sat[pos].Orbit.DotDeltaRadial, co->Sat[pos].Orbit.DotDeltaAlongTrack,
896 co->Sat[pos].Orbit.DotDeltaCrossTrack,
897 co->Sat[pos].Clock.DeltaA0, co->Sat[pos].Clock.DeltaA1, co->Sat[pos].Clock.DeltaA2);
898#endif
899 }
900 }
901 else if (corrOffset == COBOFS_URA) {
902 if (!co)
903 return GCOBR_NOCLOCKORBITPARAMETER;
904 co->messageType = type;
905 switch (s) {
906 case CLOCKORBIT_SATGPS:
907 case CLOCKORBIT_SATGALILEO:
908 case CLOCKORBIT_SATQZSS:
909 case CLOCKORBIT_SATSBAS:
910 case CLOCKORBIT_SATBDS:
911 G_SSR_EPOCH_TIME_CHECK(co->EpochTime[s], co->NumberOfSat[s])
912 break;
913 case CLOCKORBIT_SATGLONASS:
914 G_GLONASS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s])
915 break;
916 }
917 G_SSR_UPDATE_INTERVAL(co->UpdateInterval)
918 G_MULTIPLE_MESSAGE_INDICATOR(mmi)
919 G_SSR_IOD(co->SSRIOD)
920 G_SSR_PROVIDER_ID(co->SSRProviderID)
921 G_SSR_SOLUTION_ID(co->SSRSolutionID)
922 G_NO_OF_SATELLITES(nums)
923 co->Supplied[COBOFS_URA] |= 1;
924#ifdef BNC_DEBUG_SSR
925 fprintf(stderr, "epochTime %d ui %d mmi %d sats %d/%d ssrIod %d providerId %d solId %d\n",
926 co->EpochTime[s], co->UpdateInterval,mmi,co->NumberOfSat[s],nums,
927 co->SSRIOD, co->SSRProviderID, co->SSRSolutionID);
928#endif
929 for (i = 0; i < nums; ++i) {
930 switch (s) {
931 case CLOCKORBIT_SATGPS:
932 case CLOCKORBIT_SATGALILEO:
933 case CLOCKORBIT_SATSBAS:
934 case CLOCKORBIT_SATBDS:
935 G_GNSS_SATELLITE_ID(id)
936 break;
937 case CLOCKORBIT_SATQZSS:
938 G_QZSS_SATELLITE_ID(id)
939 break;
940 case CLOCKORBIT_SATGLONASS:
941 G_GLONASS_SATELLITE_ID(id)
942 break;
943 }
944 for (pos = satoffset[s];
945 pos < satoffset[s] + co->NumberOfSat[s] && co->Sat[pos].ID != id;
946 ++pos)
947 ;
948 if (pos >= satoffset[s + 1])
949 return GCOBR_DATAMISMATCH;
950 else if (pos == co->NumberOfSat[s] + satoffset[s])
951 ++co->NumberOfSat[s];
952 co->Sat[pos].ID = id;
953 G_SSR_URA(co->Sat[pos].UserRangeAccuracy)
954#ifdef BNC_DEBUG_SSR
955 fprintf(stderr, "id %2d ura %8.3f \n",
956 co->Sat[pos].ID, co->Sat[pos].UserRangeAccuracy);
957#endif
958 }
959 }
960 else if (corrOffset == COBOFS_HR) {
961 if (!co)
962 return GCOBR_NOCLOCKORBITPARAMETER;
963 co->messageType = type;
964 switch (s) {
965 case CLOCKORBIT_SATGPS:/* Phase specific part of GNSS phase bias message */
966 case CLOCKORBIT_SATGALILEO:
967 case CLOCKORBIT_SATQZSS:
968 case CLOCKORBIT_SATSBAS:
969 case CLOCKORBIT_SATBDS:
970 G_SSR_EPOCH_TIME_CHECK(co->EpochTime[s], co->NumberOfSat[s])
971 break;
972 case CLOCKORBIT_SATGLONASS:
973 G_GLONASS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s])
974 break;
975 }
976 G_SSR_UPDATE_INTERVAL(co->UpdateInterval)
977 G_MULTIPLE_MESSAGE_INDICATOR(mmi)
978 G_SSR_IOD(co->SSRIOD)
979 G_SSR_PROVIDER_ID(co->SSRProviderID)
980 G_SSR_SOLUTION_ID(co->SSRSolutionID)
981 G_NO_OF_SATELLITES(nums)
982 co->Supplied[COBOFS_HR] |= 1;
983#ifdef BNC_DEBUG_SSR
984 fprintf(stderr, "epochTime %d ui %d mmi %d sats %d/%d ssrIod %d providerId %d solId %d\n",
985 co->EpochTime[s], co->UpdateInterval,mmi,co->NumberOfSat[s],nums,
986 co->SSRIOD, co->SSRProviderID, co->SSRSolutionID);
987#endif
988 for (i = 0; i < nums; ++i) {
989 switch (s) {
990 case CLOCKORBIT_SATGPS:
991 case CLOCKORBIT_SATGALILEO:
992 case CLOCKORBIT_SATSBAS:
993 case CLOCKORBIT_SATBDS:
994 G_GNSS_SATELLITE_ID(id)
995 break;
996 case CLOCKORBIT_SATQZSS:
997 G_QZSS_SATELLITE_ID(id)
998 break;
999 case CLOCKORBIT_SATGLONASS:
1000 G_GLONASS_SATELLITE_ID(id)
1001 break;
1002 }
1003 for (pos = satoffset[s];
1004 pos < satoffset[s] + co->NumberOfSat[s] && co->Sat[pos].ID != id;
1005 ++pos)
1006 ;
1007 if (pos >= satoffset[s + 1])
1008 return GCOBR_DATAMISMATCH;
1009 else if (pos == co->NumberOfSat[s] + satoffset[s])
1010 ++co->NumberOfSat[s];
1011 co->Sat[pos].ID = id;
1012 G_HR_CLOCK_CORRECTION(co->Sat[pos].hrclock)
1013#ifdef BNC_DEBUG_SSR
1014 fprintf(stderr, "id %2d hrClock %8.3f \n",
1015 co->Sat[pos].ID, co->Sat[pos].hrclock);
1016#endif
1017 }
1018 }
1019 else if (corrOffset == COBOFS_CBIAS) {
1020 if (!b)
1021 return GCOBR_NOCODEBIASPARAMETER;
1022 b->messageType = type;
1023 switch (s) {
1024 case CLOCKORBIT_SATGPS:
1025 case CLOCKORBIT_SATGALILEO:
1026 case CLOCKORBIT_SATQZSS:
1027 case CLOCKORBIT_SATSBAS:
1028 case CLOCKORBIT_SATBDS:
1029 G_SSR_EPOCH_TIME_CHECK(b->EpochTime[s], b->NumberOfSat[s])
1030 break;
1031 case CLOCKORBIT_SATGLONASS:
1032 G_GLONASS_EPOCH_TIME(b->EpochTime[s], b->NumberOfSat[s])
1033 break;
1034 }
1035 G_SSR_UPDATE_INTERVAL(b->UpdateInterval)
1036 G_MULTIPLE_MESSAGE_INDICATOR(mmi)
1037 G_SSR_IOD(b->SSRIOD)
1038 G_SSR_PROVIDER_ID(b->SSRProviderID)
1039 G_SSR_SOLUTION_ID(b->SSRSolutionID)
1040 G_NO_OF_SATELLITES(nums)
1041#ifdef BNC_DEBUG_SSR
1042 fprintf(stderr, "epochTime %d ui %d mmi %d sats %d/%d ssrIod %d providerId %d solId %d\n",
1043 b->EpochTime[s], b->UpdateInterval,mmi,b->NumberOfSat[s],nums,
1044 b->SSRIOD, b->SSRProviderID, b->SSRSolutionID);
1045#endif
1046 for (i = 0; i < nums; ++i) {
1047 switch (s) {
1048 case CLOCKORBIT_SATGPS:
1049 case CLOCKORBIT_SATGALILEO:
1050 case CLOCKORBIT_SATSBAS:
1051 case CLOCKORBIT_SATBDS:
1052 G_GNSS_SATELLITE_ID(id)
1053 break;
1054 case CLOCKORBIT_SATQZSS:
1055 G_QZSS_SATELLITE_ID(id)
1056 break;
1057 case CLOCKORBIT_SATGLONASS:
1058 G_GLONASS_SATELLITE_ID(id)
1059 break;
1060 }
1061 for (pos = satoffset[s];
1062 pos < satoffset[s] + b->NumberOfSat[s] && b->Sat[pos].ID != id;
1063 ++pos)
1064 ;
1065 if (pos >= satoffset[s + 1])
1066 return GCOBR_DATAMISMATCH;
1067 else if (pos == b->NumberOfSat[s] + satoffset[s])
1068 ++b->NumberOfSat[s];
1069 b->Sat[pos].ID = id;
1070 G_NO_OF_BIASES(b->Sat[pos].NumberOfCodeBiases)
1071#ifdef BNC_DEBUG_SSR
1072 fprintf(stderr, "id %2d #%d ",
1073 b->Sat[pos].ID, b->Sat[pos].NumberOfCodeBiases);
1074#endif
1075 for (j = 0; j < b->Sat[pos].NumberOfCodeBiases; ++j) {
1076 G_GNSS_SIGNAL_IDENTIFIER(b->Sat[pos].Biases[j].Type)
1077 G_CODE_BIAS(b->Sat[pos].Biases[j].Bias)
1078#ifdef BNC_DEBUG_SSR
1079 fprintf(stderr, "t%02d b %8.2f ",
1080 b->Sat[pos].Biases[j].Type, b->Sat[pos].Biases[j].Bias);
1081#endif
1082 }
1083#ifdef BNC_DEBUG_SSR
1084 fprintf(stderr, "\n");
1085#endif
1086 }
1087 }
1088 else {
1089 continue;
1090 }
1091#ifdef BNC_DEBUG_SSR
1092 for(type = 0; type < (unsigned int)size && (unsigned char)buffer[type] != 0xD3; ++type)
1093 numbits += 8;
1094 fprintf(stderr, "numbits left %d\n",numbits);
1095#endif
1096 return mmi ? GCOBR_MESSAGEFOLLOWS : GCOBR_OK;
1097 }
1098 }
1099 return GCOBR_UNKNOWNTYPE;
1100}
1101
1102//
1103////////////////////////////////////////////////////////////////////////////
1104std::string SsrCorrRtcm::codeTypeToRnxType(char system, CodeType type) {
1105 if (system == 'G') {
1106 if (type == CODETYPE_GPS_L1_CA) return "1C";
1107 if (type == CODETYPE_GPS_L1_P) return "1P";
1108 if (type == CODETYPE_GPS_L1_Z) return "1W";
1109
1110 if (type == CODETYPE_GPS_SEMI_CODELESS) return "2D";
1111 if (type == CODETYPE_GPS_L2_CA) return "2C";
1112 if (type == CODETYPE_GPS_L2_P) return "2P";
1113 if (type == CODETYPE_GPS_L2_Z) return "2W";
1114
1115 if (type == CODETYPE_GPS_L2C_M) return "2S";
1116 if (type == CODETYPE_GPS_L2C_L) return "2L";
1117 if (type == CODETYPE_GPS_L2C_ML) return "2X";
1118
1119 if (type == CODETYPE_GPS_L5_I) return "5I";
1120 if (type == CODETYPE_GPS_L5_Q) return "5Q";
1121 if (type == CODETYPE_GPS_L5_IQ) return "5X";
1122
1123 if (type == CODETYPE_GPS_L1C_D) return "1S";
1124 if (type == CODETYPE_GPS_L1C_P) return "1L";
1125 if (type == CODETYPE_GPS_L1C_DP) return "1X";
1126 }
1127 else if (system == 'R') {
1128 if (type == CODETYPE_GLONASS_L1_CA) return "1C";
1129 if (type == CODETYPE_GLONASS_L1_P) return "1P";
1130
1131 if (type == CODETYPE_GLONASS_L2_CA) return "2C";
1132 if (type == CODETYPE_GLONASS_L2_P) return "2P";
1133
1134 if (type == CODETYPE_GLONASS_L1a_OCd) return "4A";
1135 if (type == CODETYPE_GLONASS_L1a_OCp) return "4B";
1136 if (type == CODETYPE_GLONASS_L1a_OCdp) return "4X";
1137
1138 if (type == CODETYPE_GLONASS_L2a_CSI) return "6A";
1139 if (type == CODETYPE_GLONASS_L2a_OCp) return "6B";
1140 if (type == CODETYPE_GLONASS_L2a_CSIOCp)return "6X";
1141
1142 if (type == CODETYPE_GLONASS_L3_I) return "3I";
1143 if (type == CODETYPE_GLONASS_L3_Q) return "3Q";
1144 if (type == CODETYPE_GLONASS_L3_IQ) return "3X";
1145 }
1146 else if (system == 'E') {
1147 if (type == CODETYPE_GALILEO_E1_A) return "1A";
1148 if (type == CODETYPE_GALILEO_E1_B) return "1B";
1149 if (type == CODETYPE_GALILEO_E1_C) return "1C";
1150 if (type == CODETYPE_GALILEO_E1_BC) return "1X";
1151 if (type == CODETYPE_GALILEO_E1_ABC) return "1Z";
1152
1153 if (type == CODETYPE_GALILEO_E5A_I) return "5I";
1154 if (type == CODETYPE_GALILEO_E5A_Q) return "5Q";
1155 if (type == CODETYPE_GALILEO_E5A_IQ) return "5X";
1156
1157 if (type == CODETYPE_GALILEO_E5B_I) return "7I";
1158 if (type == CODETYPE_GALILEO_E5B_Q) return "7Q";
1159 if (type == CODETYPE_GALILEO_E5B_IQ) return "7X";
1160
1161 if (type == CODETYPE_GALILEO_E5_I) return "8I";
1162 if (type == CODETYPE_GALILEO_E5_Q) return "8Q";
1163 if (type == CODETYPE_GALILEO_E5_IQ) return "8X";
1164
1165 if (type == CODETYPE_GALILEO_E6_A) return "6A";
1166 if (type == CODETYPE_GALILEO_E6_B) return "6B";
1167 if (type == CODETYPE_GALILEO_E6_C) return "6C";
1168 if (type == CODETYPE_GALILEO_E6_BC) return "6X";
1169 if (type == CODETYPE_GALILEO_E6_ABC) return "6Z";
1170 }
1171 else if (system == 'J') {
1172 if (type == CODETYPE_QZSS_L1_CA) return "1C";
1173 if (type == CODETYPE_QZSS_L1_S) return "1Z";
1174
1175 if (type == CODETYPE_QZSS_L1C_D) return "1S";
1176 if (type == CODETYPE_QZSS_L1C_P) return "1L";
1177 if (type == CODETYPE_QZSS_L1C_DP) return "1X";
1178
1179 if (type == CODETYPE_QZSS_L2C_M) return "2S";
1180 if (type == CODETYPE_QZSS_L2C_L) return "2L";
1181 if (type == CODETYPE_QZSS_L2C_ML) return "2X";
1182
1183 if (type == CODETYPE_QZSS_L5_I) return "5I";
1184 if (type == CODETYPE_QZSS_L5_Q) return "5Q";
1185 if (type == CODETYPE_QZSS_L5_IQ) return "5X";
1186
1187 if (type == CODETYPE_QZSS_L6_D) return "6S";
1188 if (type == CODETYPE_QZSS_L6_P) return "6L";
1189 if (type == CODETYPE_QZSS_L6_DP) return "6X";
1190
1191 if (type == CODETYPE_QZSS_L5_D) return "5D";
1192 if (type == CODETYPE_QZSS_L5_P) return "5P";
1193 if (type == CODETYPE_QZSS_L5_DP) return "5Z";
1194
1195 if (type == CODETYPE_QZSS_L6_E) return "6E";
1196 if (type == CODETYPE_QZSS_L6_DE) return "6Z";
1197 }
1198 else if (system == 'C') {
1199 if (type == CODETYPE_BDS_B1_I) return "2I";
1200 if (type == CODETYPE_BDS_B1_Q) return "2Q";
1201 if (type == CODETYPE_BDS_B1_IQ) return "2X";
1202
1203 if (type == CODETYPE_BDS_B3_I) return "6I";
1204 if (type == CODETYPE_BDS_B3_Q) return "6Q";
1205 if (type == CODETYPE_BDS_B3_IQ) return "6X";
1206
1207 if (type == CODETYPE_BDS_B2_I) return "7I";
1208 if (type == CODETYPE_BDS_B2_Q) return "7Q";
1209 if (type == CODETYPE_BDS_B2_IQ) return "7X";
1210
1211 if (type == CODETYPE_BDS_B1a_D) return "1D";
1212 if (type == CODETYPE_BDS_B1a_P) return "1P";
1213 if (type == CODETYPE_BDS_B1a_DP) return "1X";
1214
1215 if (type == CODETYPE_BDS_B2a_D) return "5D";
1216 if (type == CODETYPE_BDS_B2a_P) return "5P";
1217 if (type == CODETYPE_BDS_B2a_DP) return "5X";
1218 }
1219 else if (system == 'S') {
1220 if (type == CODETYPE_SBAS_L1_CA) return "1C";
1221
1222 if (type == CODETYPE_SBAS_L5_I) return "5I";
1223 if (type == CODETYPE_SBAS_L5_Q) return "5Q";
1224 if (type == CODETYPE_SBAS_L5_IQ) return "5X";
1225 }
1226 return "";
1227}
1228
1229//
1230////////////////////////////////////////////////////////////////////////////
1231SsrCorr::CodeType SsrCorrRtcm::rnxTypeToCodeType(char system, std::string type) {
1232 if (system == 'G') {
1233 if (type.compare("1C") == 0) {return CODETYPE_GPS_L1_CA;}
1234 if (type.compare("1P") == 0) {return CODETYPE_GPS_L1_P;}
1235 if (type.compare("1W") == 0) {return CODETYPE_GPS_L1_Z;}
1236
1237 if (type.compare("2D") == 0) {return CODETYPE_GPS_SEMI_CODELESS;}
1238 if (type.compare("2C") == 0) {return CODETYPE_GPS_L2_CA;}
1239 if (type.compare("2P") == 0) {return CODETYPE_GPS_L2_P;}
1240 if (type.compare("2W") == 0) {return CODETYPE_GPS_L2_Z;}
1241 if (type.compare("2S") == 0) {return CODETYPE_GPS_L2C_M;}
1242 if (type.compare("2L") == 0) {return CODETYPE_GPS_L2C_L;}
1243 if (type.compare("2X") == 0) {return CODETYPE_GPS_L2C_ML;}
1244
1245 if (type.compare("5I") == 0) {return CODETYPE_GPS_L5_I;}
1246 if (type.compare("5Q") == 0) {return CODETYPE_GPS_L5_Q;}
1247 if (type.compare("5X") == 0) {return CODETYPE_GPS_L5_IQ;}
1248
1249 if (type.compare("1S") == 0) {return CODETYPE_GPS_L1C_D;}
1250 if (type.compare("1L") == 0) {return CODETYPE_GPS_L1C_P;}
1251 if (type.compare("1X") == 0) {return CODETYPE_GPS_L1C_DP;}
1252 }
1253 else if (system == 'R') {
1254 if (type.compare("1C") == 0) {return CODETYPE_GLONASS_L1_CA;}
1255 if (type.compare("1P") == 0) {return CODETYPE_GLONASS_L1_P;}
1256 if (type.compare("2C") == 0) {return CODETYPE_GLONASS_L2_CA;}
1257 if (type.compare("2P") == 0) {return CODETYPE_GLONASS_L2_P;}
1258
1259 if (type.compare("4A") == 0) {return CODETYPE_GLONASS_L1a_OCd;}
1260 if (type.compare("4B") == 0) {return CODETYPE_GLONASS_L1a_OCp;}
1261 if (type.compare("4X") == 0) {return CODETYPE_GLONASS_L1a_OCdp;}
1262
1263 if (type.compare("6A") == 0) {return CODETYPE_GLONASS_L2a_CSI;}
1264 if (type.compare("6B") == 0) {return CODETYPE_GLONASS_L2a_OCp;}
1265 if (type.compare("6X") == 0) {return CODETYPE_GLONASS_L2a_CSIOCp;}
1266
1267 if (type.compare("3I") == 0) {return CODETYPE_GLONASS_L3_I;}
1268 if (type.compare("3Q") == 0) {return CODETYPE_GLONASS_L3_Q;}
1269 if (type.compare("3X") == 0) {return CODETYPE_GLONASS_L3_IQ;}
1270 }
1271 else if (system == 'E') {
1272 if (type.compare("1A") == 0) {return CODETYPE_GALILEO_E1_A;}
1273 if (type.compare("1B") == 0) {return CODETYPE_GALILEO_E1_B;}
1274 if (type.compare("1C") == 0) {return CODETYPE_GALILEO_E1_C;}
1275 if (type.compare("1X") == 0) {return CODETYPE_GALILEO_E1_BC;}
1276 if (type.compare("1Z") == 0) {return CODETYPE_GALILEO_E1_ABC;}
1277
1278 if (type.compare("5I") == 0) {return CODETYPE_GALILEO_E5A_I;}
1279 if (type.compare("5Q") == 0) {return CODETYPE_GALILEO_E5A_Q;}
1280 if (type.compare("5X") == 0) {return CODETYPE_GALILEO_E5A_IQ;}
1281
1282 if (type.compare("7I") == 0) {return CODETYPE_GALILEO_E5B_I;}
1283 if (type.compare("7Q") == 0) {return CODETYPE_GALILEO_E5B_Q;}
1284 if (type.compare("7X") == 0) {return CODETYPE_GALILEO_E5B_IQ;}
1285
1286 if (type.compare("8I") == 0) {return CODETYPE_GALILEO_E5_I;}
1287 if (type.compare("8Q") == 0) {return CODETYPE_GALILEO_E5_Q;}
1288 if (type.compare("8X") == 0) {return CODETYPE_GALILEO_E5_IQ;}
1289
1290 if (type.compare("6A") == 0) {return CODETYPE_GALILEO_E6_A;}
1291 if (type.compare("6B") == 0) {return CODETYPE_GALILEO_E6_B;}
1292 if (type.compare("6C") == 0) {return CODETYPE_GALILEO_E6_C;}
1293 if (type.compare("6X") == 0) {return CODETYPE_GALILEO_E6_BC;}
1294 if (type.compare("6Z") == 0) {return CODETYPE_GALILEO_E6_ABC;}
1295 }
1296 else if (system == 'J') {
1297 if (type.compare("1C") == 0) {return CODETYPE_QZSS_L1_CA;}
1298 if (type.compare("1Z") == 0) {return CODETYPE_QZSS_L1_S;}
1299
1300 if (type.compare("1S") == 0) {return CODETYPE_QZSS_L1C_D;}
1301 if (type.compare("1L") == 0) {return CODETYPE_QZSS_L1C_P;}
1302 if (type.compare("1X") == 0) {return CODETYPE_QZSS_L1C_DP;}
1303
1304 if (type.compare("2S") == 0) {return CODETYPE_QZSS_L2C_M;}
1305 if (type.compare("2L") == 0) {return CODETYPE_QZSS_L2C_L;}
1306 if (type.compare("2X") == 0) {return CODETYPE_QZSS_L2C_ML;}
1307
1308 if (type.compare("5I") == 0) {return CODETYPE_QZSS_L5_I;}
1309 if (type.compare("5Q") == 0) {return CODETYPE_QZSS_L5_Q;}
1310 if (type.compare("5X") == 0) {return CODETYPE_QZSS_L5_IQ;}
1311
1312 if (type.compare("6S") == 0) {return CODETYPE_QZSS_L6_D;}
1313 if (type.compare("6L") == 0) {return CODETYPE_QZSS_L6_P;}
1314 if (type.compare("6X") == 0) {return CODETYPE_QZSS_L6_DP;}
1315
1316 if (type.compare("5D") == 0) {return CODETYPE_QZSS_L5_D;}
1317 if (type.compare("5P") == 0) {return CODETYPE_QZSS_L5_P;}
1318 if (type.compare("5Z") == 0) {return CODETYPE_QZSS_L5_DP;}
1319
1320 if (type.compare("6E") == 0) {return CODETYPE_QZSS_L6_E;}
1321 if (type.compare("6Z") == 0) {return CODETYPE_QZSS_L6_DE;}
1322 }
1323 else if (system == 'C') {
1324 if (type.compare("2I") == 0) {return CODETYPE_BDS_B1_I;}
1325 if (type.compare("2Q") == 0) {return CODETYPE_BDS_B1_Q;}
1326 if (type.compare("2X") == 0) {return CODETYPE_BDS_B1_IQ;}
1327
1328 if (type.compare("6I") == 0) {return CODETYPE_BDS_B3_I;}
1329 if (type.compare("6Q") == 0) {return CODETYPE_BDS_B3_Q;}
1330 if (type.compare("6X") == 0) {return CODETYPE_BDS_B3_IQ;}
1331
1332 if (type.compare("7I") == 0) {return CODETYPE_BDS_B2_I;}
1333 if (type.compare("7Q") == 0) {return CODETYPE_BDS_B2_Q;}
1334 if (type.compare("7X") == 0) {return CODETYPE_BDS_B2_IQ;}
1335
1336 if (type.compare("1D") == 0) {return CODETYPE_BDS_B1a_D;}
1337 if (type.compare("1P") == 0) {return CODETYPE_BDS_B1a_P;}
1338 if (type.compare("1X") == 0) {return CODETYPE_BDS_B1a_DP;}
1339
1340 if (type.compare("5D") == 0) {return CODETYPE_BDS_B2a_D;}
1341 if (type.compare("5P") == 0) {return CODETYPE_BDS_B2a_P;}
1342 if (type.compare("5X") == 0) {return CODETYPE_BDS_B2a_DP;}
1343 }
1344 else if (system == 'S') {
1345 if (type.compare("1C") == 0) {return CODETYPE_SBAS_L1_CA;}
1346
1347 if (type.compare("5I") == 0) {return CODETYPE_SBAS_L5_I;}
1348 if (type.compare("5Q") == 0) {return CODETYPE_SBAS_L5_Q;}
1349 if (type.compare("5X") == 0) {return CODETYPE_SBAS_L5_IQ;}
1350 }
1351 return RESERVED;
1352}
1353
Note: See TracBrowser for help on using the repository browser.