source: ntrip/trunk/BNC/src/RTCM3/clock_and_orbit/clock_orbit_rtcm.cpp@ 9962

Last change on this file since 9962 was 9962, checked in by stuerze, 17 months ago

minor changes to be msvc compatible

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