Changeset 5664 in ntrip
- Timestamp:
- May 26, 2014, 5:09:28 PM (10 years ago)
- Location:
- trunk/clock_and_orbit
- Files:
-
- 8 added
- 2 edited
- 1 copied
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/clock_and_orbit/lib/clock_orbit_rtcm.c
r4981 r5664 90 90 } 91 91 92 #define SCALEADDBITS(a, b, c) ADDBITS(a, (int64_t)(b*c)) 93 94 /* standard values */ 95 #define T_MESSAGE_NUMBER(a) ADDBITS(12, a) /* DF002 */ 96 #define T_GPS_SATELLITE_ID(a) ADDBITS(6, a) /* DF068 */ 97 #define T_GPS_IODE(a) ADDBITS(8, a) /* DF071 */ 98 #define T_GLONASS_IOD(a) ADDBITS(8, a) /* DF237 */ 99 100 /* defined values */ 92 #define SCALEADDBITS(a, b, c) ADDBITS(a, (int64_t)(c > 0 ? b*c+0.5 : b*c-0.5)) 93 94 #define MPI 3.141592653589793 95 96 /* GPS macros also used for other systems when matching! */ 97 #define T_MESSAGE_NUMBER(a) ADDBITS(12, a) /* DF002 */ 98 #define T_GPS_SATELLITE_ID(a) ADDBITS(6, a) /* DF068 */ 99 #define T_QZSS_SATELLITE_ID(a) ADDBITS(4, a) /* DF249 */ 100 #define T_GLONASS_SATELLITE_ID(a) ADDBITS(5, a) 101 102 #define T_GPS_IODE(a) ADDBITS(8, a) /* DF071 */ 103 #define T_GLONASS_IOD(a) ADDBITS(8, a) /* DF237 */ 104 #define T_GALILEO_IOD(a) ADDBITS(10, a) /* DF459 */ 105 #define T_SBAS_T0MOD(a) ADDBITS(9, (a/16)) /* DF468 */ 106 #define T_SBAS_IODCRC(a) ADDBITS(24, a) /* DF469 */ 107 #define T_BDS_TOEMOD(a) ADDBITS(10, (a/8)) /* DF470 */ 108 #define T_BDS_IODCRC(a) ADDBITS(24, a) /* DF471 */ 109 101 110 #define T_DELTA_RADIAL(a) SCALEADDBITS(22, 10000.0, a) 102 111 #define T_DELTA_ALONG_TRACK(a) SCALEADDBITS(20, 2500.0, a) … … 111 120 #define T_DELTA_CLOCK_C2(a) SCALEADDBITS(27, 50000000.0, a) 112 121 #define T_NO_OF_CODE_BIASES(a) ADDBITS(5, a) 113 #define T_ GPS_SIGNAL_IDENTIFIER(a)ADDBITS(5, a)114 #define T_ GLONASS_SIGNAL_IDENTIFIER(a)ADDBITS(5, a)122 #define T_NO_OF_PHASE_BIASES(a) ADDBITS(5, a) 123 #define T_SIGNAL_IDENTIFIER(a) ADDBITS(5, a) 115 124 #define T_CODE_BIAS(a) SCALEADDBITS(14, 100.0, a) 116 #define T_GLONASS_SATELLITE_ID(a) ADDBITS(5, a) 125 #define T_YAW_ANGLE(a) SCALEADDBITS(9, 256.0/MPI, a) 126 #define T_YAW_RATE(a) SCALEADDBITS(8, 8192.0/MPI, a) 127 #define T_PHASE_BIAS(a) SCALEADDBITS(20, 10000.0, a) 117 128 118 129 #define T_GPS_EPOCH_TIME(a) ADDBITS(20, a) … … 120 131 #define T_NO_OF_SATELLITES(a) ADDBITS(6, a) 121 132 #define T_MULTIPLE_MESSAGE_INDICATOR(a) ADDBITS(1, a) 133 #define T_DISPERSIVE_BIAS_INDICATOR(a) ADDBITS(1, a) 134 #define T_MW_CONSISTENCY_INDICATOR(a) ADDBITS(1, a) 135 #define T_INTEGER_INDICATOR(a) ADDBITS(1, a) 136 #define T_WIDE_LANE_INDICATOR(a) ADDBITS(1, a) 137 #define T_DISCONTINUITY_COUNTER(a) ADDBITS(4, a) 122 138 #define T_SSR_URA(a) ADDBITS(6, a) 123 139 #define T_HR_CLOCK_CORRECTION(a) SCALEADDBITS(22, 10000.0, a) … … 127 143 #define T_SSR_PROVIDER_ID(a) ADDBITS(16, a) 128 144 #define T_SSR_SOLUTION_ID(a) ADDBITS(4, a) 145 146 #define T_NO_IONO_LAYERS(a) ADDBITS(2, a-1) 147 #define T_VTEC_QUALITY_INDICATOR(a) SCALEADDBITS(9, 20.0, a) 148 #define T_IONO_COEFF(a) SCALEADDBITS(16, 200.0, a) 149 #define T_IONO_DEGREE(a) ADDBITS(4, a-1) 150 #define T_IONO_ORDER(a) ADDBITS(4, a-1) 151 #define T_IONO_HEIGHT(a) SCALEADDBITS(8, 1/10000.0, a) 129 152 130 153 static double URAToValue(int ura) … … 152 175 } 153 176 177 static const enum ClockOrbitType corbase[CLOCKORBIT_SATNUM] = 178 { 179 COBBASE_GPS, COBBASE_GLONASS, COBBASE_GALILEO, COBBASE_QZSS, COBBASE_SBAS, 180 COBBASE_BDS 181 }; 182 static const enum COR_OFFSETS satoffset[CLOCKORBIT_SATNUM+1] = 183 { 184 CLOCKORBIT_OFFSETGPS, CLOCKORBIT_OFFSETGLONASS, CLOCKORBIT_OFFSETGALILEO, 185 CLOCKORBIT_OFFSETQZSS, CLOCKORBIT_OFFSETSBAS, CLOCKORBIT_OFFSETBDS, 186 CLOCKORBIT_COUNTSAT 187 }; 188 154 189 size_t MakeClockOrbit(const struct ClockOrbit *co, enum ClockOrbitType type, 155 190 int moremessagesfollow, char *buffer, size_t size) 156 191 { 157 int gpshr=0, gpsur=0, gpsor=0, gpscl=0, gpsco=0, glohr=0, glour=0, gloor=0,158 glocl=0, gloco=0, mmi, i; 159 192 unsigned int status[CLOCKORBIT_SATNUM][COBOFS_NUM], i, s; 193 194 memset(status, 0, sizeof(status)); 160 195 STARTDATA 161 196 162 if(co->NumberOfGPSSat && co->HRDataSupplied 163 && (type == COTYPE_AUTO || type == COTYPE_GPSHR)) 164 gpshr = 1; 165 if(co->NumberOfGPSSat && co->URADataSupplied 166 && (type == COTYPE_AUTO || type == COTYPE_GPSURA)) 167 gpsur = 1; 168 if(co->NumberOfGPSSat && co->OrbitDataSupplied 169 && (type == COTYPE_AUTO || type == COTYPE_GPSORBIT)) 170 gpsor = 1; 171 if(co->NumberOfGPSSat && co->ClockDataSupplied 172 && (type == COTYPE_AUTO || type == COTYPE_GPSCLOCK)) 173 gpscl = 1; 174 if(co->NumberOfGPSSat && co->ClockDataSupplied && co->OrbitDataSupplied 175 && (type == COTYPE_AUTO || type == COTYPE_GPSCOMBINED) 176 /*&& co->NumberOfGPSSat <= 28*/) 197 for(s = 0; s < CLOCKORBIT_SATNUM; ++s) 177 198 { 178 gpsco = 1; gpsor = 0; gpscl = 0; 179 } 180 if(co->NumberOfGLONASSSat && co->HRDataSupplied 181 && (type == COTYPE_AUTO || type == COTYPE_GLONASSHR)) 182 glohr = 1; 183 if(co->NumberOfGLONASSSat && co->URADataSupplied 184 && (type == COTYPE_AUTO || type == COTYPE_GLONASSURA)) 185 glour = 1; 186 if(co->NumberOfGLONASSSat && co->OrbitDataSupplied 187 && (type == COTYPE_AUTO || type == COTYPE_GLONASSORBIT)) 188 gloor = 1; 189 if(co->NumberOfGLONASSSat && co->ClockDataSupplied 190 && (type == COTYPE_AUTO || type == COTYPE_GLONASSCLOCK)) 191 glocl = 1; 192 if(co->NumberOfGLONASSSat && co->ClockDataSupplied && co->OrbitDataSupplied 193 && (type == COTYPE_AUTO || type == COTYPE_GLONASSCOMBINED)) 199 for(i = 0; i < COBOFS_NUM; ++i) 200 { 201 if(co->NumberOfSat[s] && (type == COTYPE_AUTO 202 || type == corbase[s]+i) && (co->Supplied[i] || (i <= COBOFS_CLOCK 203 && co->Supplied[COBOFS_COMBINED]) || (i == COBOFS_COMBINED 204 && co->Supplied[COBOFS_ORBIT] && co->Supplied[COBOFS_CLOCK]))) 205 { 206 status[s][i] = 1; 207 if(i == COBOFS_COMBINED) 208 { 209 status[s][COBOFS_ORBIT] = status[s][COBOFS_CLOCK] = 0; 210 } /* disable single blocks for combined type */ 211 } /* check for data */ 212 } /* iterate over RTCM data types */ 213 } /* iterate over satellite systems */ 214 215 for(s = 0; s < CLOCKORBIT_SATNUM; ++s) 194 216 { 195 gloco = 1; gloor = 0; glocl = 0; 196 } 197 198 mmi = gpshr+gpsur+gpsor+gpscl+gpsco+glohr+glour+gloor+glocl+gloco; /* required for multimessage */ 199 if(!moremessagesfollow) --mmi; 200 201 if(gpsor) 202 { 203 INITBLOCK 204 T_MESSAGE_NUMBER(COTYPE_GPSORBIT) 205 T_GPS_EPOCH_TIME(co->GPSEpochTime) 206 T_SSR_UPDATE_INTERVAL(co->UpdateInterval) 207 T_MULTIPLE_MESSAGE_INDICATOR(/*mmi ? 1 :*/0) 208 --mmi; 209 T_SATELLITE_REFERENCE_DATUM(co->SatRefDatum) 210 T_SSR_IOD(co->SSRIOD) 211 T_SSR_PROVIDER_ID(co->SSRProviderID) 212 T_SSR_SOLUTION_ID(co->SSRSolutionID) 213 T_NO_OF_SATELLITES(co->NumberOfGPSSat) 214 for(i = 0; i < co->NumberOfGPSSat; ++i) 215 { 216 T_GPS_SATELLITE_ID(co->Sat[i].ID) 217 T_GPS_IODE(co->Sat[i].IOD) 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 } 225 ENDBLOCK 226 } 227 if(gpscl) 228 { 229 INITBLOCK 230 T_MESSAGE_NUMBER(COTYPE_GPSCLOCK) 231 T_GPS_EPOCH_TIME(co->GPSEpochTime) 232 T_SSR_UPDATE_INTERVAL(co->UpdateInterval) 233 T_MULTIPLE_MESSAGE_INDICATOR(/*mmi ? 1 :*/0) 234 --mmi; 235 T_SSR_IOD(co->SSRIOD) 236 T_SSR_PROVIDER_ID(co->SSRProviderID) 237 T_SSR_SOLUTION_ID(co->SSRSolutionID) 238 T_NO_OF_SATELLITES(co->NumberOfGPSSat) 239 for(i = 0; i < co->NumberOfGPSSat; ++i) 240 { 241 T_GPS_SATELLITE_ID(co->Sat[i].ID) 242 T_DELTA_CLOCK_C0(co->Sat[i].Clock.DeltaA0) 243 T_DELTA_CLOCK_C1(co->Sat[i].Clock.DeltaA1) 244 T_DELTA_CLOCK_C2(co->Sat[i].Clock.DeltaA2) 245 } 246 ENDBLOCK 247 } 248 if(gpsco) 249 { 250 #ifdef SPLITBLOCK 251 int nums = co->NumberOfGPSSat; 252 int left, start = 0; 253 if(nums > 28) /* split block when more than 28 sats */ 254 { 255 left = nums - 28; 256 nums = 28; 257 } 258 else 259 { 260 left = 0; 261 } 262 while(nums) 263 { 264 #endif 217 if(status[s][COBOFS_ORBIT]) 218 { 265 219 INITBLOCK 266 T_MESSAGE_NUMBER(COTYPE_GPSCOMBINED) 267 T_GPS_EPOCH_TIME(co->GPSEpochTime) 220 T_MESSAGE_NUMBER(corbase[s]+COBOFS_ORBIT) 221 switch(s) 222 { 223 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO: 224 case CLOCKORBIT_SATQZSS: case CLOCKORBIT_SATSBAS: 225 case CLOCKORBIT_SATBDS: 226 T_GPS_EPOCH_TIME(co->EpochTime[s]) 227 break; 228 case CLOCKORBIT_SATGLONASS: 229 T_GLONASS_EPOCH_TIME(co->EpochTime[s]) 230 break; 231 } 268 232 T_SSR_UPDATE_INTERVAL(co->UpdateInterval) 269 #ifdef SPLITBLOCK 270 T_MULTIPLE_MESSAGE_INDICATOR(/*mmi || */ left ? 1 : 0) 271 #else 272 T_MULTIPLE_MESSAGE_INDICATOR(/*mmi || */ 0) 273 #endif 274 --mmi; 233 T_MULTIPLE_MESSAGE_INDICATOR(moremessagesfollow ? 1 : 0) 275 234 T_SATELLITE_REFERENCE_DATUM(co->SatRefDatum) 276 235 T_SSR_IOD(co->SSRIOD) 277 236 T_SSR_PROVIDER_ID(co->SSRProviderID) 278 237 T_SSR_SOLUTION_ID(co->SSRSolutionID) 279 #ifdef SPLITBLOCK 280 T_NO_OF_SATELLITES(nums) 281 for(i = start; i < start+nums; ++i) 282 #else 283 T_NO_OF_SATELLITES(co->NumberOfGPSSat) 284 for(i = 0; i < co->NumberOfGPSSat; ++i) 285 #endif 286 { 287 T_GPS_SATELLITE_ID(co->Sat[i].ID) 288 T_GPS_IODE(co->Sat[i].IOD) 238 T_NO_OF_SATELLITES(co->NumberOfSat[s]) 239 for(i = satoffset[s]; i < satoffset[s]+co->NumberOfSat[s]; ++i) 240 { 241 switch(s) 242 { 243 case CLOCKORBIT_SATGPS: 244 T_GPS_SATELLITE_ID(co->Sat[i].ID) 245 T_GPS_IODE(co->Sat[i].IOD) 246 break; 247 case CLOCKORBIT_SATGLONASS: 248 T_GLONASS_SATELLITE_ID(co->Sat[i].ID) 249 T_GLONASS_IOD(co->Sat[i].IOD) 250 break; 251 case CLOCKORBIT_SATGALILEO: 252 T_GPS_SATELLITE_ID(co->Sat[i].ID) 253 T_GALILEO_IOD(co->Sat[i].IOD) 254 break; 255 case CLOCKORBIT_SATQZSS: 256 T_QZSS_SATELLITE_ID(co->Sat[i].ID) 257 T_GPS_IODE(co->Sat[i].IOD) 258 break; 259 case CLOCKORBIT_SATSBAS: 260 T_GPS_SATELLITE_ID(co->Sat[i].ID) 261 T_SBAS_T0MOD(co->Sat[i].toe) 262 T_SBAS_IODCRC(co->Sat[i].IOD) 263 break; 264 case CLOCKORBIT_SATBDS: 265 T_GPS_SATELLITE_ID(co->Sat[i].ID) 266 T_BDS_TOEMOD(co->Sat[i].toe) 267 T_BDS_IODCRC(co->Sat[i].IOD) 268 break; 269 } 289 270 T_DELTA_RADIAL(co->Sat[i].Orbit.DeltaRadial) 290 271 T_DELTA_ALONG_TRACK(co->Sat[i].Orbit.DeltaAlongTrack) … … 293 274 T_DELTA_DOT_ALONG_TRACK(co->Sat[i].Orbit.DotDeltaAlongTrack) 294 275 T_DELTA_DOT_CROSS_TRACK(co->Sat[i].Orbit.DotDeltaCrossTrack) 276 } 277 ENDBLOCK 278 } 279 if(status[s][COBOFS_CLOCK]) 280 { 281 INITBLOCK 282 T_MESSAGE_NUMBER(corbase[s]+COBOFS_CLOCK) 283 switch(s) 284 { 285 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO: 286 case CLOCKORBIT_SATQZSS: case CLOCKORBIT_SATSBAS: 287 case CLOCKORBIT_SATBDS: 288 T_GPS_EPOCH_TIME(co->EpochTime[s]) 289 break; 290 case CLOCKORBIT_SATGLONASS: 291 T_GLONASS_EPOCH_TIME(co->EpochTime[s]) 292 break; 293 } 294 T_SSR_UPDATE_INTERVAL(co->UpdateInterval) 295 T_MULTIPLE_MESSAGE_INDICATOR(moremessagesfollow ? 1 : 0) 296 T_SSR_IOD(co->SSRIOD) 297 T_SSR_PROVIDER_ID(co->SSRProviderID) 298 T_SSR_SOLUTION_ID(co->SSRSolutionID) 299 T_NO_OF_SATELLITES(co->NumberOfSat[s]) 300 for(i = satoffset[s]; i < satoffset[s]+co->NumberOfSat[s]; ++i) 301 { 302 switch(s) 303 { 304 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO: 305 case CLOCKORBIT_SATSBAS: case CLOCKORBIT_SATBDS: 306 T_GPS_SATELLITE_ID(co->Sat[i].ID) 307 break; 308 case CLOCKORBIT_SATQZSS: 309 T_QZSS_SATELLITE_ID(co->Sat[i].ID) 310 break; 311 case CLOCKORBIT_SATGLONASS: 312 T_GLONASS_SATELLITE_ID(co->Sat[i].ID) 313 break; 314 } 295 315 T_DELTA_CLOCK_C0(co->Sat[i].Clock.DeltaA0) 296 316 T_DELTA_CLOCK_C1(co->Sat[i].Clock.DeltaA1) … … 298 318 } 299 319 ENDBLOCK 320 } 321 if(status[s][COBOFS_COMBINED]) 322 { 300 323 #ifdef SPLITBLOCK 301 start += nums; 302 nums = left; 303 left = 0; 324 int nums = co->NumberOfSat[s]; 325 int left, start = satoffset[s]; 326 if(nums > 28) /* split block when more than 28 sats */ 327 { 328 left = nums - 28; 329 nums = 28; 330 } 331 else 332 { 333 left = 0; 334 } 335 while(nums) 336 { 337 #endif 338 INITBLOCK 339 T_MESSAGE_NUMBER(corbase[s]+COBOFS_COMBINED) 340 switch(s) 341 { 342 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO: 343 case CLOCKORBIT_SATQZSS: case CLOCKORBIT_SATSBAS: 344 case CLOCKORBIT_SATBDS: 345 T_GPS_EPOCH_TIME(co->EpochTime[s]) 346 break; 347 case CLOCKORBIT_SATGLONASS: 348 T_GLONASS_EPOCH_TIME(co->EpochTime[s]) 349 break; 350 } 351 T_SSR_UPDATE_INTERVAL(co->UpdateInterval) 352 #ifdef SPLITBLOCK 353 T_MULTIPLE_MESSAGE_INDICATOR((moremessagesfollow || left) ? 1 : 0) 354 #else 355 T_MULTIPLE_MESSAGE_INDICATOR(moremessagesfollow ? 1 : 0) 356 #endif 357 T_SATELLITE_REFERENCE_DATUM(co->SatRefDatum) 358 T_SSR_IOD(co->SSRIOD) 359 T_SSR_PROVIDER_ID(co->SSRProviderID) 360 T_SSR_SOLUTION_ID(co->SSRSolutionID) 361 #ifdef SPLITBLOCK 362 T_NO_OF_SATELLITES(nums) 363 for(i = start; i < start+nums; ++i) 364 #else 365 T_NO_OF_SATELLITES(co->NumberOfSat[s]) 366 for(i = satoffset[s]; i < satoffset[s]+co->NumberOfSat[s]; ++i) 367 #endif 368 { 369 switch(s) 370 { 371 case CLOCKORBIT_SATGPS: 372 T_GPS_SATELLITE_ID(co->Sat[i].ID) 373 T_GPS_IODE(co->Sat[i].IOD) 374 break; 375 case CLOCKORBIT_SATGLONASS: 376 T_GLONASS_SATELLITE_ID(co->Sat[i].ID) 377 T_GLONASS_IOD(co->Sat[i].IOD) 378 break; 379 case CLOCKORBIT_SATGALILEO: 380 T_GPS_SATELLITE_ID(co->Sat[i].ID) 381 T_GALILEO_IOD(co->Sat[i].IOD) 382 break; 383 case CLOCKORBIT_SATQZSS: 384 T_QZSS_SATELLITE_ID(co->Sat[i].ID) 385 T_GPS_IODE(co->Sat[i].IOD) 386 break; 387 case CLOCKORBIT_SATSBAS: 388 T_GPS_SATELLITE_ID(co->Sat[i].ID) 389 T_SBAS_T0MOD(co->Sat[i].toe) 390 T_SBAS_IODCRC(co->Sat[i].IOD) 391 break; 392 case CLOCKORBIT_SATBDS: 393 T_GPS_SATELLITE_ID(co->Sat[i].ID) 394 T_BDS_TOEMOD(co->Sat[i].toe) 395 T_BDS_IODCRC(co->Sat[i].IOD) 396 break; 397 } 398 T_DELTA_RADIAL(co->Sat[i].Orbit.DeltaRadial) 399 T_DELTA_ALONG_TRACK(co->Sat[i].Orbit.DeltaAlongTrack) 400 T_DELTA_CROSS_TRACK(co->Sat[i].Orbit.DeltaCrossTrack) 401 T_DELTA_DOT_RADIAL(co->Sat[i].Orbit.DotDeltaRadial) 402 T_DELTA_DOT_ALONG_TRACK(co->Sat[i].Orbit.DotDeltaAlongTrack) 403 T_DELTA_DOT_CROSS_TRACK(co->Sat[i].Orbit.DotDeltaCrossTrack) 404 T_DELTA_CLOCK_C0(co->Sat[i].Clock.DeltaA0) 405 T_DELTA_CLOCK_C1(co->Sat[i].Clock.DeltaA1) 406 T_DELTA_CLOCK_C2(co->Sat[i].Clock.DeltaA2) 407 } 408 ENDBLOCK 409 #ifdef SPLITBLOCK 410 start += nums; 411 nums = left; 412 left = 0; 413 } 414 #endif 304 415 } 305 #endif 416 if(status[s][COBOFS_HR]) 417 { 418 INITBLOCK 419 T_MESSAGE_NUMBER(corbase[s]+COBOFS_HR) 420 switch(s) 421 { 422 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO: 423 case CLOCKORBIT_SATQZSS: case CLOCKORBIT_SATSBAS: 424 case CLOCKORBIT_SATBDS: 425 T_GPS_EPOCH_TIME(co->EpochTime[s]) 426 break; 427 case CLOCKORBIT_SATGLONASS: 428 T_GLONASS_EPOCH_TIME(co->EpochTime[s]) 429 break; 430 } 431 T_SSR_UPDATE_INTERVAL(co->UpdateInterval) 432 T_MULTIPLE_MESSAGE_INDICATOR(moremessagesfollow ? 1 : 0) 433 T_SSR_IOD(co->SSRIOD) 434 T_SSR_PROVIDER_ID(co->SSRProviderID) 435 T_SSR_SOLUTION_ID(co->SSRSolutionID) 436 T_NO_OF_SATELLITES(co->NumberOfSat[s]) 437 for(i = satoffset[s]; i < satoffset[s]+co->NumberOfSat[s]; ++i) 438 { 439 switch(s) 440 { 441 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO: 442 case CLOCKORBIT_SATSBAS: case CLOCKORBIT_SATBDS: 443 T_GPS_SATELLITE_ID(co->Sat[i].ID) 444 break; 445 case CLOCKORBIT_SATQZSS: 446 T_QZSS_SATELLITE_ID(co->Sat[i].ID) 447 break; 448 case CLOCKORBIT_SATGLONASS: 449 T_GLONASS_SATELLITE_ID(co->Sat[i].ID) 450 break; 451 } 452 T_HR_CLOCK_CORRECTION(co->Sat[i].hrclock) 453 } 454 ENDBLOCK 455 } 456 if(status[s][COBOFS_URA]) 457 { 458 INITBLOCK 459 T_MESSAGE_NUMBER(corbase[s]+COBOFS_URA) 460 switch(s) 461 { 462 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO: 463 case CLOCKORBIT_SATQZSS: case CLOCKORBIT_SATSBAS: 464 case CLOCKORBIT_SATBDS: 465 T_GPS_EPOCH_TIME(co->EpochTime[s]) 466 break; 467 case CLOCKORBIT_SATGLONASS: 468 T_GLONASS_EPOCH_TIME(co->EpochTime[s]) 469 break; 470 } 471 T_MULTIPLE_MESSAGE_INDICATOR(moremessagesfollow ? 1 : 0) 472 T_SSR_IOD(co->SSRIOD) 473 T_SSR_PROVIDER_ID(co->SSRProviderID) 474 T_SSR_SOLUTION_ID(co->SSRSolutionID) 475 T_NO_OF_SATELLITES(co->NumberOfSat[s]) 476 for(i = satoffset[s]; i < satoffset[s]+co->NumberOfSat[s]; ++i) 477 { 478 switch(s) 479 { 480 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO: 481 case CLOCKORBIT_SATSBAS: case CLOCKORBIT_SATBDS: 482 T_GPS_SATELLITE_ID(co->Sat[i].ID) 483 break; 484 case CLOCKORBIT_SATQZSS: 485 T_QZSS_SATELLITE_ID(co->Sat[i].ID) 486 break; 487 case CLOCKORBIT_SATGLONASS: 488 T_GLONASS_SATELLITE_ID(co->Sat[i].ID) 489 break; 490 } 491 T_SSR_URA(ValueToURA(co->Sat[i].UserRangeAccuracy)) 492 } 493 ENDBLOCK 494 } 306 495 } 307 if(gpshr)308 {309 INITBLOCK310 T_MESSAGE_NUMBER(COTYPE_GPSHR)311 T_GPS_EPOCH_TIME(co->GPSEpochTime)312 T_SSR_UPDATE_INTERVAL(co->UpdateInterval)313 T_MULTIPLE_MESSAGE_INDICATOR(/*mmi ? 1 :*/0)314 --mmi;315 T_SSR_IOD(co->SSRIOD)316 T_SSR_PROVIDER_ID(co->SSRProviderID)317 T_SSR_SOLUTION_ID(co->SSRSolutionID)318 T_NO_OF_SATELLITES(co->NumberOfGPSSat)319 for(i = 0; i < co->NumberOfGPSSat; ++i)320 {321 T_GPS_SATELLITE_ID(co->Sat[i].ID)322 T_HR_CLOCK_CORRECTION(co->Sat[i].hrclock)323 }324 ENDBLOCK325 }326 if(gpsur)327 {328 INITBLOCK329 T_MESSAGE_NUMBER(COTYPE_GPSURA)330 T_GPS_EPOCH_TIME(co->GPSEpochTime)331 T_MULTIPLE_MESSAGE_INDICATOR(/*mmi ? 1 :*/0)332 --mmi;333 T_SSR_IOD(co->SSRIOD)334 T_SSR_PROVIDER_ID(co->SSRProviderID)335 T_SSR_SOLUTION_ID(co->SSRSolutionID)336 T_NO_OF_SATELLITES(co->NumberOfGPSSat)337 for(i = 0; i < co->NumberOfGPSSat; ++i)338 {339 T_GPS_SATELLITE_ID(co->Sat[i].ID)340 T_SSR_URA(ValueToURA(co->Sat[i].UserRangeAccuracy))341 }342 ENDBLOCK343 }344 if(gloor)345 {346 INITBLOCK347 T_MESSAGE_NUMBER(COTYPE_GLONASSORBIT)348 T_GLONASS_EPOCH_TIME(co->GLONASSEpochTime)349 T_SSR_UPDATE_INTERVAL(co->UpdateInterval)350 T_MULTIPLE_MESSAGE_INDICATOR(/*mmi ? 1 :*/0)351 --mmi;352 T_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)353 T_SSR_IOD(co->SSRIOD)354 T_SSR_PROVIDER_ID(co->SSRProviderID)355 T_SSR_SOLUTION_ID(co->SSRSolutionID)356 T_NO_OF_SATELLITES(co->NumberOfGLONASSSat)357 for(i = CLOCKORBIT_NUMGPS;358 i < CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat; ++i)359 {360 T_GLONASS_SATELLITE_ID(co->Sat[i].ID)361 T_GLONASS_IOD(co->Sat[i].IOD)362 T_DELTA_RADIAL(co->Sat[i].Orbit.DeltaRadial)363 T_DELTA_ALONG_TRACK(co->Sat[i].Orbit.DeltaAlongTrack)364 T_DELTA_CROSS_TRACK(co->Sat[i].Orbit.DeltaCrossTrack)365 T_DELTA_DOT_RADIAL(co->Sat[i].Orbit.DotDeltaRadial)366 T_DELTA_DOT_ALONG_TRACK(co->Sat[i].Orbit.DotDeltaAlongTrack)367 T_DELTA_DOT_CROSS_TRACK(co->Sat[i].Orbit.DotDeltaCrossTrack)368 }369 ENDBLOCK370 }371 if(glocl)372 {373 INITBLOCK374 T_MESSAGE_NUMBER(COTYPE_GLONASSCLOCK)375 T_GLONASS_EPOCH_TIME(co->GLONASSEpochTime)376 T_SSR_UPDATE_INTERVAL(co->UpdateInterval)377 T_MULTIPLE_MESSAGE_INDICATOR(/*mmi ? 1 :*/0)378 --mmi;379 T_SSR_IOD(co->SSRIOD)380 T_SSR_PROVIDER_ID(co->SSRProviderID)381 T_SSR_SOLUTION_ID(co->SSRSolutionID)382 T_NO_OF_SATELLITES(co->NumberOfGLONASSSat)383 for(i = CLOCKORBIT_NUMGPS;384 i < CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat; ++i)385 {386 T_GLONASS_SATELLITE_ID(co->Sat[i].ID)387 T_DELTA_CLOCK_C0(co->Sat[i].Clock.DeltaA0)388 T_DELTA_CLOCK_C1(co->Sat[i].Clock.DeltaA1)389 T_DELTA_CLOCK_C2(co->Sat[i].Clock.DeltaA2)390 }391 ENDBLOCK392 }393 if(gloco)394 {395 INITBLOCK396 T_MESSAGE_NUMBER(COTYPE_GLONASSCOMBINED)397 T_GLONASS_EPOCH_TIME(co->GLONASSEpochTime)398 T_SSR_UPDATE_INTERVAL(co->UpdateInterval)399 T_MULTIPLE_MESSAGE_INDICATOR(/*mmi ? 1 :*/0)400 --mmi;401 T_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)402 T_SSR_IOD(co->SSRIOD)403 T_SSR_PROVIDER_ID(co->SSRProviderID)404 T_SSR_SOLUTION_ID(co->SSRSolutionID)405 T_NO_OF_SATELLITES(co->NumberOfGLONASSSat)406 for(i = CLOCKORBIT_NUMGPS;407 i < CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat; ++i)408 {409 T_GLONASS_SATELLITE_ID(co->Sat[i].ID)410 T_GLONASS_IOD(co->Sat[i].IOD)411 T_DELTA_RADIAL(co->Sat[i].Orbit.DeltaRadial)412 T_DELTA_ALONG_TRACK(co->Sat[i].Orbit.DeltaAlongTrack)413 T_DELTA_CROSS_TRACK(co->Sat[i].Orbit.DeltaCrossTrack)414 T_DELTA_DOT_RADIAL(co->Sat[i].Orbit.DotDeltaRadial)415 T_DELTA_DOT_ALONG_TRACK(co->Sat[i].Orbit.DotDeltaAlongTrack)416 T_DELTA_DOT_CROSS_TRACK(co->Sat[i].Orbit.DotDeltaCrossTrack)417 T_DELTA_CLOCK_C0(co->Sat[i].Clock.DeltaA0)418 T_DELTA_CLOCK_C1(co->Sat[i].Clock.DeltaA1)419 T_DELTA_CLOCK_C2(co->Sat[i].Clock.DeltaA2)420 }421 ENDBLOCK422 }423 if(glohr)424 {425 INITBLOCK426 T_MESSAGE_NUMBER(COTYPE_GLONASSHR)427 T_GLONASS_EPOCH_TIME(co->GLONASSEpochTime)428 T_SSR_UPDATE_INTERVAL(co->UpdateInterval)429 T_MULTIPLE_MESSAGE_INDICATOR(/*mmi ? 1 :*/0)430 --mmi;431 T_SSR_IOD(co->SSRIOD)432 T_SSR_PROVIDER_ID(co->SSRProviderID)433 T_SSR_SOLUTION_ID(co->SSRSolutionID)434 T_NO_OF_SATELLITES(co->NumberOfGLONASSSat)435 for(i = CLOCKORBIT_NUMGPS;436 i < CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat; ++i)437 {438 T_GPS_SATELLITE_ID(co->Sat[i].ID)439 T_HR_CLOCK_CORRECTION(co->Sat[i].hrclock)440 }441 ENDBLOCK442 }443 if(glour)444 {445 INITBLOCK446 T_MESSAGE_NUMBER(COTYPE_GLONASSURA)447 T_GLONASS_EPOCH_TIME(co->GLONASSEpochTime)448 T_MULTIPLE_MESSAGE_INDICATOR(/*mmi ? 1 :*/0)449 --mmi;450 T_SSR_IOD(co->SSRIOD)451 T_SSR_PROVIDER_ID(co->SSRProviderID)452 T_SSR_SOLUTION_ID(co->SSRSolutionID)453 T_NO_OF_SATELLITES(co->NumberOfGLONASSSat)454 for(i = CLOCKORBIT_NUMGPS;455 i < CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat; ++i)456 {457 T_GPS_SATELLITE_ID(co->Sat[i].ID)458 T_SSR_URA(ValueToURA(co->Sat[i].UserRangeAccuracy))459 }460 ENDBLOCK461 }462 463 496 return ressize; 464 497 } 465 498 466 size_t Make Bias(const struct Bias *b, enumBiasType type,499 size_t MakeCodeBias(const struct CodeBias *b, enum CodeBiasType type, 467 500 int moremessagesfollow, char *buffer, size_t size) 468 501 { 469 int gps=0, glo=0, mmi, i, j;502 unsigned int s, i, j; 470 503 471 504 STARTDATA 472 505 473 if(b->NumberOfGPSSat && (type == BTYPE_AUTO || type == BTYPE_GPS)) 474 gps = 1; 475 if(b->NumberOfGLONASSSat && (type == BTYPE_AUTO || type == BTYPE_GLONASS)) 476 glo = 1; 477 478 mmi = gps+glo; /* required for multimessage */ 479 if(!moremessagesfollow) --mmi; 480 481 if(gps) 506 for(s = 0; s < CLOCKORBIT_SATNUM; ++s) 482 507 { 483 INITBLOCK 484 T_MESSAGE_NUMBER(BTYPE_GPS) 485 T_GPS_EPOCH_TIME(b->GPSEpochTime) 486 T_SSR_UPDATE_INTERVAL(b->UpdateInterval) 487 T_MULTIPLE_MESSAGE_INDICATOR(/*mmi ? 1 :*/0) 488 --mmi; 489 T_SSR_IOD(b->SSRIOD) 490 T_SSR_PROVIDER_ID(b->SSRProviderID) 491 T_SSR_SOLUTION_ID(b->SSRSolutionID) 492 T_NO_OF_SATELLITES(b->NumberOfGPSSat) 493 for(i = 0; i < b->NumberOfGPSSat; ++i) 494 { 495 T_GPS_SATELLITE_ID(b->Sat[i].ID) 496 T_NO_OF_CODE_BIASES(b->Sat[i].NumberOfCodeBiases) 497 for(j = 0; j < b->Sat[i].NumberOfCodeBiases; ++j) 498 { 499 T_GPS_SIGNAL_IDENTIFIER(b->Sat[i].Biases[j].Type) 500 T_CODE_BIAS(b->Sat[i].Biases[j].Bias) 501 } 508 if(b->NumberOfSat[s] && (type == BTYPE_AUTO || type == corbase[s]+COBOFS_BIAS)) 509 { 510 INITBLOCK 511 T_MESSAGE_NUMBER(corbase[s]+COBOFS_BIAS) 512 switch(s) 513 { 514 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO: 515 case CLOCKORBIT_SATQZSS: case CLOCKORBIT_SATSBAS: 516 case CLOCKORBIT_SATBDS: 517 T_GPS_EPOCH_TIME(b->EpochTime[s]) 518 break; 519 case CLOCKORBIT_SATGLONASS: 520 T_GLONASS_EPOCH_TIME(b->EpochTime[s]) 521 break; 522 } 523 T_SSR_UPDATE_INTERVAL(b->UpdateInterval) 524 T_MULTIPLE_MESSAGE_INDICATOR(moremessagesfollow ? 1 : 0) 525 T_SSR_IOD(b->SSRIOD) 526 T_SSR_PROVIDER_ID(b->SSRProviderID) 527 T_SSR_SOLUTION_ID(b->SSRSolutionID) 528 T_NO_OF_SATELLITES(b->NumberOfSat[s]) 529 for(i = satoffset[s]; i < satoffset[s]+b->NumberOfSat[s]; ++i) 530 { 531 switch(s) 532 { 533 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO: 534 case CLOCKORBIT_SATSBAS: case CLOCKORBIT_SATBDS: 535 T_GPS_SATELLITE_ID(b->Sat[i].ID) 536 break; 537 case CLOCKORBIT_SATQZSS: 538 T_QZSS_SATELLITE_ID(b->Sat[i].ID) 539 break; 540 case CLOCKORBIT_SATGLONASS: 541 T_GLONASS_SATELLITE_ID(b->Sat[i].ID) 542 break; 543 } 544 T_NO_OF_CODE_BIASES(b->Sat[i].NumberOfCodeBiases) 545 for(j = 0; j < b->Sat[i].NumberOfCodeBiases; ++j) 546 { 547 T_SIGNAL_IDENTIFIER(b->Sat[i].Biases[j].Type) 548 T_CODE_BIAS(b->Sat[i].Biases[j].Bias) 549 } 550 } 551 ENDBLOCK 502 552 } 503 ENDBLOCK504 553 } 505 if(glo)506 {507 INITBLOCK508 T_MESSAGE_NUMBER(BTYPE_GLONASS)509 T_GLONASS_EPOCH_TIME(b->GLONASSEpochTime)510 T_SSR_UPDATE_INTERVAL(b->UpdateInterval)511 T_MULTIPLE_MESSAGE_INDICATOR(/*mmi ? 1 :*/0)512 --mmi;513 T_SSR_IOD(b->SSRIOD)514 T_SSR_PROVIDER_ID(b->SSRProviderID)515 T_SSR_SOLUTION_ID(b->SSRSolutionID)516 T_NO_OF_SATELLITES(b->NumberOfGLONASSSat)517 for(i = CLOCKORBIT_NUMGPS;518 i < CLOCKORBIT_NUMGPS+b->NumberOfGLONASSSat; ++i)519 {520 T_GLONASS_SATELLITE_ID(b->Sat[i].ID)521 T_NO_OF_CODE_BIASES(b->Sat[i].NumberOfCodeBiases)522 for(j = 0; j < b->Sat[i].NumberOfCodeBiases; ++j)523 {524 T_GLONASS_SIGNAL_IDENTIFIER(b->Sat[i].Biases[j].Type)525 T_CODE_BIAS(b->Sat[i].Biases[j].Bias)526 }527 }528 ENDBLOCK529 }530 531 554 return ressize; 532 555 } 533 556 557 size_t MakePhaseBias(const struct PhaseBias *b, enum PhaseBiasType type, 558 int moremessagesfollow, char *buffer, size_t size) 559 { 560 unsigned int s, i, j; 561 562 STARTDATA 563 564 for(s = 0; s < CLOCKORBIT_SATNUM; ++s) 565 { 566 if(b->NumberOfSat[s] && (type == PBTYPE_AUTO || type == corbase[s]+COBOFS_BIAS)) 567 { 568 INITBLOCK 569 T_MESSAGE_NUMBER(corbase[s]+COBOFS_BIAS) 570 switch(s) 571 { 572 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO: 573 case CLOCKORBIT_SATQZSS: case CLOCKORBIT_SATSBAS: 574 case CLOCKORBIT_SATBDS: 575 T_GPS_EPOCH_TIME(b->EpochTime[s]) 576 break; 577 case CLOCKORBIT_SATGLONASS: 578 T_GLONASS_EPOCH_TIME(b->EpochTime[s]) 579 break; 580 } 581 T_SSR_UPDATE_INTERVAL(b->UpdateInterval) 582 T_MULTIPLE_MESSAGE_INDICATOR(moremessagesfollow ? 1 : 0) 583 T_SSR_IOD(b->SSRIOD) 584 T_SSR_PROVIDER_ID(b->SSRProviderID) 585 T_SSR_SOLUTION_ID(b->SSRSolutionID) 586 T_DISPERSIVE_BIAS_INDICATOR(b->DispersiveBiasConsistencyIndicator ? 1 : 0) 587 T_MW_CONSISTENCY_INDICATOR(b->MWConsistencyIndicator ? 1 : 0) 588 T_NO_OF_SATELLITES(b->NumberOfSat[CLOCKORBIT_SATGPS]) 589 for(i = satoffset[s]; i < satoffset[s]+b->NumberOfSat[s]; ++i) 590 { 591 switch(s) 592 { 593 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO: 594 case CLOCKORBIT_SATSBAS: case CLOCKORBIT_SATBDS: 595 T_GPS_SATELLITE_ID(b->Sat[i].ID) 596 break; 597 case CLOCKORBIT_SATQZSS: 598 T_QZSS_SATELLITE_ID(b->Sat[i].ID) 599 break; 600 case CLOCKORBIT_SATGLONASS: 601 T_GLONASS_SATELLITE_ID(b->Sat[i].ID) 602 break; 603 } 604 T_NO_OF_CODE_BIASES(b->Sat[i].NumberOfPhaseBiases) 605 T_YAW_ANGLE(b->Sat[i].YawAngle) 606 T_YAW_RATE(b->Sat[i].YawRate) 607 for(j = 0; j < b->Sat[i].NumberOfPhaseBiases; ++j) 608 { 609 T_SIGNAL_IDENTIFIER(b->Sat[i].Biases[j].Type) 610 T_INTEGER_INDICATOR(b->Sat[i].Biases[j].SignalIntegerIndicator ? 1 : 0) 611 T_WIDE_LANE_INDICATOR(b->Sat[i].Biases[j].SignalsWideLaneIntegerIndicator ? 1 : 0) 612 T_DISCONTINUITY_COUNTER(b->Sat[i].Biases[j].SignalDiscontinuityCounter) 613 T_PHASE_BIAS(b->Sat[i].Biases[j].Bias) 614 } 615 } 616 ENDBLOCK 617 } 618 } 619 return ressize; 620 } 621 622 size_t MakeVTEC(const struct VTEC *v, int moremessagesfollow, char *buffer, 623 size_t size) 624 { 625 unsigned int l, o, d; 626 627 STARTDATA 628 INITBLOCK 629 T_MESSAGE_NUMBER(VTEC_BASE) 630 631 T_GPS_EPOCH_TIME(v->EpochTime) 632 T_SSR_UPDATE_INTERVAL(v->UpdateInterval) 633 T_MULTIPLE_MESSAGE_INDICATOR(moremessagesfollow ? 1 : 0) 634 T_SSR_IOD(v->SSRIOD) 635 T_SSR_PROVIDER_ID(v->SSRProviderID) 636 T_SSR_SOLUTION_ID(v->SSRSolutionID) 637 T_VTEC_QUALITY_INDICATOR(v->Quality) 638 T_NO_IONO_LAYERS(v->NumLayers) 639 for(l = 0; l < v->NumLayers; ++l) 640 { 641 T_IONO_HEIGHT(v->Layers[l].Height) 642 T_IONO_DEGREE(v->Layers[l].Degree) 643 T_IONO_ORDER(v->Layers[l].Order) 644 for(o = 0; o <= v->Layers[l].Order; ++o) 645 { 646 for(d = o; d <= v->Layers[l].Degree; ++d) 647 { 648 T_IONO_COEFF(v->Layers[l].Cosinus[d][o]) 649 } 650 } 651 for(o = 1; o <= v->Layers[l].Order; ++o) 652 { 653 for(d = o; d <= v->Layers[l].Degree; ++d) 654 { 655 T_IONO_COEFF(v->Layers[l].Sinus[d][o]) 656 } 657 } 658 } 659 ENDBLOCK 660 return ressize; 661 } 534 662 #endif /* NOENCODE */ 535 663 … … 559 687 } 560 688 689 /* extract bits from data stream 690 b = variable to store result, a = number of bits */ 691 #define GETBITSFACTOR(b, a, c) \ 692 { \ 693 LOADBITS(a) \ 694 b = ((bitbuffer<<(64-numbits))>>(64-(a)))*(c); \ 695 numbits -= (a); \ 696 } 697 561 698 /* extract signed floating value from data stream 562 699 b = variable to store result, a = number of bits */ … … 568 705 } 569 706 707 /* extract floating value from data stream 708 b = variable to store result, a = number of bits, c = scale factor */ 709 #define GETFLOAT(b, a, c) \ 710 { \ 711 LOADBITS(a) \ 712 b = ((double)((bitbuffer<<(sizeof(bitbuffer)*8-numbits))>>(sizeof(bitbuffer)*8-(a))))*(c); \ 713 numbits -= (a); \ 714 } 715 570 716 #define SKIPBITS(b) { LOADBITS(b) numbits -= (b); } 571 717 572 /* standard values*/718 /* GPS macros also used for other systems when matching! */ 573 719 #define G_HEADER(a) GETBITS(a,8) 574 720 #define G_RESERVEDH(a) GETBITS(a,6) 575 721 #define G_SIZE(a) GETBITS(a, 10) 576 #define G_MESSAGE_NUMBER(a) GETBITS(a, 12) /* DF002 */ 577 #define G_GPS_SATELLITE_ID(a) GETBITS(a, 6) /* DF068 */ 578 #define G_GPS_IODE(a) GETBITS(a, 8) /* DF071 */ 579 #define G_GLONASS_IOD(a) GETBITS(a, 8) /* DF237 */ 722 #define G_MESSAGE_NUMBER(a) GETBITS(a, 12) /* DF002 */ 723 #define G_GPS_SATELLITE_ID(a) GETBITS(a, 6) /* DF068 */ 724 #define G_QZSS_SATELLITE_ID(a) GETBITS(a, 4) /* DF249 */ 725 #define G_GLONASS_SATELLITE_ID(a) GETBITS(a, 5) 726 727 #define G_GPS_IODE(a) GETBITS(a, 8) /* DF071 */ 728 #define G_GLONASS_IOD(a) GETBITS(a, 8) /* DF237 */ 729 #define G_GALILEO_IOD(a) GETBITS(a, 10) /* DF459 */ 730 #define G_SBAS_T0MOD(a) GETBITSFACTOR(a, 9, 16) /* DF468 */ 731 #define G_SBAS_IODCRC(a) GETBITS(a, 24) /* DF469 */ 732 #define G_BDS_TOEMOD(a) GETBITSFACTOR(a, 10, 8) /* DF470 */ 733 #define G_BDS_IODCRC(a) GETBITS(a, 24) /* DF471 */ 580 734 581 735 /* defined values */ … … 592 746 #define G_DELTA_CLOCK_C2(a) GETFLOATSIGN(a, 27, 1/50000000.0) 593 747 #define G_NO_OF_CODE_BIASES(a) GETBITS(a, 5) 594 #define G_ GPS_SIGNAL_IDENTIFIER(a)GETBITS(a, 5)595 #define G_ GLONASS_SIGNAL_IDENTIFIER(a)GETBITS(a, 5)748 #define G_NO_OF_PHASE_BIASES(a) GETBITS(a, 5) 749 #define G_SIGNAL_IDENTIFIER(a) GETBITS(a, 5) 596 750 #define G_CODE_BIAS(a) GETFLOATSIGN(a, 14, 1/100.0) 597 #define G_GLONASS_SATELLITE_ID(a) GETBITS(a, 5) 598 599 #define G_GPS_EPOCH_TIME(a, b) {int temp; GETBITS(temp, 20) \ 751 #define G_YAW_ANGLE(a) GETFLOAT(a, 9, MPI/256.0) 752 #define G_YAW_RATE(a) GETFLOATSIGN(a, 8, MPI/8192.0) 753 #define G_PHASE_BIAS(a) GETFLOATSIGN(a, 20, 1/10000.0) 754 755 #define G_GPS_EPOCH_TIME(a, b) {unsigned int temp; GETBITS(temp, 20) \ 600 756 if(b && a != temp) return GCOBR_TIMEMISMATCH; a = temp;} 601 #define G_GLONASS_EPOCH_TIME(a, b) { int temp; GETBITS(temp, 17) \757 #define G_GLONASS_EPOCH_TIME(a, b) {unsigned int temp; GETBITS(temp, 17) \ 602 758 if(b && a != temp) return GCOBR_TIMEMISMATCH; a = temp;} 759 #define G_EPOCH_TIME(a) GETBITS(a, 20) 603 760 #define G_NO_OF_SATELLITES(a) GETBITS(a, 6) 604 761 #define G_MULTIPLE_MESSAGE_INDICATOR(a) GETBITS(a, 1) 762 #define G_DISPERSIVE_BIAS_INDICATOR(a) GETBITS(a, 1) 763 #define G_MW_CONSISTENCY_INDICATOR(a) GETBITS(a, 1) 764 #define G_INTEGER_INDICATOR(a) GETBITS(a, 1) 765 #define G_WIDE_LANE_INDICATOR(a) GETBITS(a, 1) 766 #define G_DISCONTINUITY_COUNTER(a) GETBITS(a, 4) 605 767 #define G_SSR_URA(a) {int temp; GETBITS(temp, 6) \ 606 768 (a) = URAToValue(temp);} … … 612 774 #define G_SSR_SOLUTION_ID(a) GETBITS(a, 4) 613 775 614 enum GCOB_RETURN GetClockOrbitBias(struct ClockOrbit *co, struct Bias *b, 615 const char *buffer, size_t size, int *bytesused) 776 #define G_NO_IONO_LAYERS(a) {unsigned int temp; GETBITS(temp, 2) a = temp+1; } 777 #define G_VTEC_QUALITY_INDICATOR(a) GETFLOAT(a, 9, 1/20.0) 778 #define G_IONO_COEFF(a) GETFLOATSIGN(a, 16,1/200.0) 779 #define G_IONO_DEGREE(a) {unsigned int temp; GETBITS(temp, 4) a = temp+1; } 780 #define G_IONO_ORDER(a) {unsigned int temp; GETBITS(temp, 4) a = temp+1; } 781 #define G_IONO_HEIGHT(a) GETFLOAT(a, 8 , 10000.0) 782 783 enum GCOB_RETURN GetSSR(struct ClockOrbit *co, struct CodeBias *b, struct VTEC *v, 784 struct PhaseBias *pb, const char *buffer, size_t size, int *bytesused) 616 785 { 617 int type, mmi=0, i, j, h, rs, nums, pos, id; 786 int mmi=0, h, rs; 787 unsigned int type, pos, i, j, s, nums, id; 618 788 size_t sizeofrtcmblock; 619 789 const char *blockstart = buffer; … … 624 794 625 795 #ifdef DEBUG 626 fprintf(stderr, "GetClockOrbitBias START: size %d, numbits %d\n",size, numbits);796 fprintf(stderr, "GetClockOrbitBias START: size %d, numbits %d\n",size, numbits); 627 797 #endif 628 798 … … 637 807 if(CRC24(sizeofrtcmblock+3, (const unsigned char *) blockstart) != 638 808 (uint32_t)((((unsigned char)buffer[sizeofrtcmblock])<<16)| 639 640 809 (((unsigned char)buffer[sizeofrtcmblock+1])<<8)| 810 (((unsigned char)buffer[sizeofrtcmblock+2])))) 641 811 return GCOBR_CRCMISMATCH; 642 812 size = sizeofrtcmblock; /* reduce size, so overflows are detected */ … … 646 816 fprintf(stderr, "type %d size %d\n",type,sizeofrtcmblock); 647 817 #endif 648 switch(type)649 {650 case COTYPE_GPSORBIT:651 if(!co) return GCOBR_NOCLOCKORBITPARAMETER;652 co->messageType = COTYPE_GPSORBIT;653 G_GPS_EPOCH_TIME(co->GPSEpochTime, co->NumberOfGPSSat)654 co->epochGPS[co->epochSize] = co->GPSEpochTime; /* Weber, for latency */655 if(co->epochSize < 100) {co->epochSize += 1;} /* Weber, for latency */656 G_SSR_UPDATE_INTERVAL(co->UpdateInterval)657 G_MULTIPLE_MESSAGE_INDICATOR(mmi)658 G_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)659 G_SSR_IOD(co->SSRIOD)660 G_SSR_PROVIDER_ID(co->SSRProviderID)661 G_SSR_SOLUTION_ID(co->SSRSolutionID)662 G_NO_OF_SATELLITES(nums)663 co->OrbitDataSupplied |= 1;664 #ifdef DEBUG665 fprintf(stderr, "epochtime %d ui %d mmi %d sats %d/%d rd %d\n",co->GPSEpochTime,666 co->UpdateInterval,mmi,co->NumberOfGPSSat,nums, co->SatRefDatum);667 #endif668 for(i = 0; i < nums; ++i)669 {670 G_GPS_SATELLITE_ID(id)671 for(pos = 0; pos < co->NumberOfGPSSat && co->Sat[pos].ID != id; ++pos)672 ;673 if(pos >= CLOCKORBIT_NUMGPS) return GCOBR_DATAMISMATCH;674 else if(pos == co->NumberOfGPSSat) ++co->NumberOfGPSSat;675 co->Sat[pos].ID = id;676 677 G_GPS_IODE(co->Sat[pos].IOD)678 G_DELTA_RADIAL(co->Sat[pos].Orbit.DeltaRadial)679 G_DELTA_ALONG_TRACK(co->Sat[pos].Orbit.DeltaAlongTrack)680 G_DELTA_CROSS_TRACK(co->Sat[pos].Orbit.DeltaCrossTrack)681 G_DELTA_DOT_RADIAL(co->Sat[pos].Orbit.DotDeltaRadial)682 G_DELTA_DOT_ALONG_TRACK(co->Sat[pos].Orbit.DotDeltaAlongTrack)683 G_DELTA_DOT_CROSS_TRACK(co->Sat[pos].Orbit.DotDeltaCrossTrack)684 #ifdef DEBUG685 fprintf(stderr, "id %2d iod %3d dr %8.3f da %8.3f dc %8.3f dr %8.3f da %8.3f dc %8.3f\n",686 co->Sat[pos].ID,co->Sat[pos].IOD,co->Sat[pos].Orbit.DeltaRadial,687 co->Sat[pos].Orbit.DeltaAlongTrack,co->Sat[pos].Orbit.DeltaCrossTrack,688 co->Sat[pos].Orbit.DotDeltaRadial,689 co->Sat[pos].Orbit.DotDeltaAlongTrack,690 co->Sat[pos].Orbit.DotDeltaCrossTrack);691 #endif692 }693 break;694 case COTYPE_GPSCLOCK:695 if(!co) return GCOBR_NOCLOCKORBITPARAMETER;696 co->messageType = COTYPE_GPSCLOCK;697 G_GPS_EPOCH_TIME(co->GPSEpochTime, co->NumberOfGPSSat)698 co->epochGPS[co->epochSize] = co->GPSEpochTime; /* Weber, for latency */699 if(co->epochSize < 100) {co->epochSize += 1;} /* Weber, for latency */700 G_SSR_UPDATE_INTERVAL(co->UpdateInterval)701 G_MULTIPLE_MESSAGE_INDICATOR(mmi)702 G_SSR_IOD(co->SSRIOD)703 G_SSR_PROVIDER_ID(co->SSRProviderID)704 G_SSR_SOLUTION_ID(co->SSRSolutionID)705 G_NO_OF_SATELLITES(nums)706 co->ClockDataSupplied |= 1;707 #ifdef DEBUG708 fprintf(stderr, "epochtime %d ui %d mmi %d sats %d/%d\n",co->GPSEpochTime,709 co->UpdateInterval,mmi,co->NumberOfGPSSat,nums);710 #endif711 for(i = 0; i < nums; ++i)712 {713 G_GPS_SATELLITE_ID(id)714 for(pos = 0; pos < co->NumberOfGPSSat && co->Sat[pos].ID != id; ++pos)715 ;716 if(pos >= CLOCKORBIT_NUMGPS) return GCOBR_DATAMISMATCH;717 else if(pos == co->NumberOfGPSSat) ++co->NumberOfGPSSat;718 co->Sat[pos].ID = id;719 720 G_DELTA_CLOCK_C0(co->Sat[pos].Clock.DeltaA0)721 G_DELTA_CLOCK_C1(co->Sat[pos].Clock.DeltaA1)722 G_DELTA_CLOCK_C2(co->Sat[pos].Clock.DeltaA2)723 #ifdef DEBUG724 fprintf(stderr, "id %2d c0 %8.3f c1 %8.3f c2 %8.3f\n",725 co->Sat[pos].ID, co->Sat[pos].Clock.DeltaA0, co->Sat[pos].Clock.DeltaA1,726 co->Sat[pos].Clock.DeltaA2);727 #endif728 }729 break;730 case COTYPE_GPSCOMBINED:731 if(!co) return GCOBR_NOCLOCKORBITPARAMETER;732 co->messageType = COTYPE_GPSCOMBINED;733 G_GPS_EPOCH_TIME(co->GPSEpochTime, co->NumberOfGPSSat)734 co->epochGPS[co->epochSize] = co->GPSEpochTime; /* Weber, for latency */735 if(co->epochSize < 100) {co->epochSize += 1;} /* Weber, for latency */736 G_SSR_UPDATE_INTERVAL(co->UpdateInterval)737 G_MULTIPLE_MESSAGE_INDICATOR(mmi)738 G_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)739 G_SSR_IOD(co->SSRIOD)740 G_SSR_PROVIDER_ID(co->SSRProviderID)741 G_SSR_SOLUTION_ID(co->SSRSolutionID)742 G_NO_OF_SATELLITES(nums)743 co->OrbitDataSupplied |= 1;744 co->ClockDataSupplied |= 1;745 for(i = 0; i < nums; ++i)746 {747 G_GPS_SATELLITE_ID(id)748 for(pos = 0; pos < co->NumberOfGPSSat && co->Sat[pos].ID != id; ++pos)749 ;750 if(pos >= CLOCKORBIT_NUMGPS) return GCOBR_DATAMISMATCH;751 else if(pos == co->NumberOfGPSSat) ++co->NumberOfGPSSat;752 co->Sat[pos].ID = id;753 754 G_GPS_IODE(co->Sat[pos].IOD)755 G_DELTA_RADIAL(co->Sat[pos].Orbit.DeltaRadial)756 G_DELTA_ALONG_TRACK(co->Sat[pos].Orbit.DeltaAlongTrack)757 G_DELTA_CROSS_TRACK(co->Sat[pos].Orbit.DeltaCrossTrack)758 G_DELTA_DOT_RADIAL(co->Sat[pos].Orbit.DotDeltaRadial)759 G_DELTA_DOT_ALONG_TRACK(co->Sat[pos].Orbit.DotDeltaAlongTrack)760 G_DELTA_DOT_CROSS_TRACK(co->Sat[pos].Orbit.DotDeltaCrossTrack)761 G_DELTA_CLOCK_C0(co->Sat[pos].Clock.DeltaA0)762 G_DELTA_CLOCK_C1(co->Sat[pos].Clock.DeltaA1)763 G_DELTA_CLOCK_C2(co->Sat[pos].Clock.DeltaA2)764 }765 break;766 case COTYPE_GPSURA:767 if(!co) return GCOBR_NOCLOCKORBITPARAMETER;768 co->messageType = COTYPE_GPSURA;769 G_GPS_EPOCH_TIME(co->GPSEpochTime, co->NumberOfGPSSat)770 co->epochGPS[co->epochSize] = co->GPSEpochTime; /* Weber, for latency */771 if(co->epochSize < 100) {co->epochSize += 1;} /* Weber, for latency */772 G_MULTIPLE_MESSAGE_INDICATOR(mmi)773 G_SSR_IOD(co->SSRIOD)774 G_SSR_PROVIDER_ID(co->SSRProviderID)775 G_SSR_SOLUTION_ID(co->SSRSolutionID)776 G_NO_OF_SATELLITES(nums)777 co->URADataSupplied |= 1;778 for(i = 0; i < nums; ++i)779 {780 G_GPS_SATELLITE_ID(id)781 for(pos = 0; pos < co->NumberOfGPSSat && co->Sat[pos].ID != id; ++pos)782 ;783 if(pos >= CLOCKORBIT_NUMGPS) return GCOBR_DATAMISMATCH;784 else if(pos == co->NumberOfGPSSat) ++co->NumberOfGPSSat;785 co->Sat[pos].ID = id;786 787 G_SSR_URA(co->Sat[pos].UserRangeAccuracy)788 }789 break;790 case COTYPE_GPSHR:791 if(!co) return GCOBR_NOCLOCKORBITPARAMETER;792 co->messageType = COTYPE_GPSHR;793 G_GPS_EPOCH_TIME(co->GPSEpochTime, co->NumberOfGPSSat)794 co->epochGPS[co->epochSize] = co->GPSEpochTime; /* Weber, for latency */795 if(co->epochSize < 100) {co->epochSize += 1;} /* Weber, for latency */796 G_SSR_UPDATE_INTERVAL(co->UpdateInterval)797 G_MULTIPLE_MESSAGE_INDICATOR(mmi)798 G_SSR_IOD(co->SSRIOD)799 G_SSR_PROVIDER_ID(co->SSRProviderID)800 G_SSR_SOLUTION_ID(co->SSRSolutionID)801 G_NO_OF_SATELLITES(nums)802 co->HRDataSupplied |= 1;803 for(i = 0; i < nums; ++i)804 {805 G_GPS_SATELLITE_ID(id)806 for(pos = 0; pos < co->NumberOfGPSSat && co->Sat[pos].ID != id; ++pos)807 ;808 if(pos >= CLOCKORBIT_NUMGPS) return GCOBR_DATAMISMATCH;809 else if(pos == co->NumberOfGPSSat) ++co->NumberOfGPSSat;810 co->Sat[pos].ID = id;811 812 G_HR_CLOCK_CORRECTION(co->Sat[pos].hrclock)813 }814 break;815 case COTYPE_GLONASSORBIT:816 if(!co) return GCOBR_NOCLOCKORBITPARAMETER;817 co->messageType = COTYPE_GLONASSORBIT;818 G_GLONASS_EPOCH_TIME(co->GLONASSEpochTime, co->NumberOfGLONASSSat)819 G_SSR_UPDATE_INTERVAL(co->UpdateInterval)820 G_MULTIPLE_MESSAGE_INDICATOR(mmi)821 G_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)822 G_SSR_IOD(co->SSRIOD)823 G_SSR_PROVIDER_ID(co->SSRProviderID)824 G_SSR_SOLUTION_ID(co->SSRSolutionID)825 G_NO_OF_SATELLITES(nums)826 co->OrbitDataSupplied |= 2;827 #ifdef DEBUG828 fprintf(stderr, "epochtime %d ui %d mmi %d sats %d/%d rd %d\n",co->GLONASSEpochTime,829 co->UpdateInterval,mmi,co->NumberOfGLONASSSat,nums, co->SatRefDatum);830 #endif831 for(i = 0; i < nums; ++i)832 {833 G_GLONASS_SATELLITE_ID(id)834 for(pos = CLOCKORBIT_NUMGPS; pos < CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat && co->Sat[pos].ID != id; ++pos)835 ;836 if(pos >= CLOCKORBIT_NUMGPS+CLOCKORBIT_NUMGLONASS) return GCOBR_DATAMISMATCH;837 else if(pos == CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat) ++co->NumberOfGLONASSSat;838 co->Sat[pos].ID = id;839 840 G_GLONASS_IOD(co->Sat[pos].IOD)841 G_DELTA_RADIAL(co->Sat[pos].Orbit.DeltaRadial)842 G_DELTA_ALONG_TRACK(co->Sat[pos].Orbit.DeltaAlongTrack)843 G_DELTA_CROSS_TRACK(co->Sat[pos].Orbit.DeltaCrossTrack)844 G_DELTA_DOT_RADIAL(co->Sat[pos].Orbit.DotDeltaRadial)845 G_DELTA_DOT_ALONG_TRACK(co->Sat[pos].Orbit.DotDeltaAlongTrack)846 G_DELTA_DOT_CROSS_TRACK(co->Sat[pos].Orbit.DotDeltaCrossTrack)847 #ifdef DEBUG848 fprintf(stderr, "id %2d iod %3d dr %8.3f da %8.3f dc %8.3f dr %8.3f da %8.3f dc %8.3f\n",849 co->Sat[pos].ID,co->Sat[pos].IOD,co->Sat[pos].Orbit.DeltaRadial,850 co->Sat[pos].Orbit.DeltaAlongTrack,co->Sat[pos].Orbit.DeltaCrossTrack,851 co->Sat[pos].Orbit.DotDeltaRadial,852 co->Sat[pos].Orbit.DotDeltaAlongTrack,853 co->Sat[pos].Orbit.DotDeltaCrossTrack);854 #endif855 }856 break;857 case COTYPE_GLONASSCLOCK:858 if(!co) return GCOBR_NOCLOCKORBITPARAMETER;859 co->messageType = COTYPE_GLONASSCLOCK;860 G_GLONASS_EPOCH_TIME(co->GLONASSEpochTime, co->NumberOfGLONASSSat)861 G_SSR_UPDATE_INTERVAL(co->UpdateInterval)862 G_MULTIPLE_MESSAGE_INDICATOR(mmi)863 G_SSR_IOD(co->SSRIOD)864 G_SSR_PROVIDER_ID(co->SSRProviderID)865 G_SSR_SOLUTION_ID(co->SSRSolutionID)866 G_NO_OF_SATELLITES(nums)867 co->ClockDataSupplied |= 2;868 #ifdef DEBUG869 fprintf(stderr, "epochtime %d ui %d mmi %d sats %d/%d\n",co->GLONASSEpochTime,870 co->UpdateInterval,mmi,co->NumberOfGLONASSSat,nums);871 #endif872 for(i = 0; i < nums; ++i)873 {874 G_GLONASS_SATELLITE_ID(id)875 for(pos = CLOCKORBIT_NUMGPS; pos < CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat && co->Sat[pos].ID != id; ++pos)876 ;877 if(pos >= CLOCKORBIT_NUMGPS+CLOCKORBIT_NUMGLONASS) return GCOBR_DATAMISMATCH;878 else if(pos == CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat) ++co->NumberOfGLONASSSat;879 co->Sat[pos].ID = id;880 881 G_DELTA_CLOCK_C0(co->Sat[pos].Clock.DeltaA0)882 G_DELTA_CLOCK_C1(co->Sat[pos].Clock.DeltaA1)883 G_DELTA_CLOCK_C2(co->Sat[pos].Clock.DeltaA2)884 #ifdef DEBUG885 fprintf(stderr, "id %2d c0 %8.3f c1 %8.3f c2 %8.3f\n",886 co->Sat[pos].ID, co->Sat[pos].Clock.DeltaA0, co->Sat[pos].Clock.DeltaA1,887 co->Sat[pos].Clock.DeltaA2);888 #endif889 }890 break;891 case COTYPE_GLONASSCOMBINED:892 if(!co) return GCOBR_NOCLOCKORBITPARAMETER;893 co->messageType = COTYPE_GLONASSCOMBINED;894 G_GLONASS_EPOCH_TIME(co->GLONASSEpochTime, co->NumberOfGLONASSSat)895 G_SSR_UPDATE_INTERVAL(co->UpdateInterval)896 G_MULTIPLE_MESSAGE_INDICATOR(mmi)897 G_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)898 G_SSR_IOD(co->SSRIOD)899 G_SSR_PROVIDER_ID(co->SSRProviderID)900 G_SSR_SOLUTION_ID(co->SSRSolutionID)901 G_NO_OF_SATELLITES(nums)902 co->OrbitDataSupplied |= 2;903 co->ClockDataSupplied |= 2;904 for(i = 0; i < nums; ++i)905 {906 G_GLONASS_SATELLITE_ID(id)907 for(pos = CLOCKORBIT_NUMGPS; pos < CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat && co->Sat[pos].ID != id; ++pos)908 ;909 if(pos >= CLOCKORBIT_NUMGPS+CLOCKORBIT_NUMGLONASS) return GCOBR_DATAMISMATCH;910 else if(pos == CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat) ++co->NumberOfGLONASSSat;911 co->Sat[pos].ID = id;912 913 G_GLONASS_IOD(co->Sat[pos].IOD)914 G_DELTA_RADIAL(co->Sat[pos].Orbit.DeltaRadial)915 G_DELTA_ALONG_TRACK(co->Sat[pos].Orbit.DeltaAlongTrack)916 G_DELTA_CROSS_TRACK(co->Sat[pos].Orbit.DeltaCrossTrack)917 G_DELTA_DOT_RADIAL(co->Sat[pos].Orbit.DotDeltaRadial)918 G_DELTA_DOT_ALONG_TRACK(co->Sat[pos].Orbit.DotDeltaAlongTrack)919 G_DELTA_DOT_CROSS_TRACK(co->Sat[pos].Orbit.DotDeltaCrossTrack)920 G_DELTA_CLOCK_C0(co->Sat[pos].Clock.DeltaA0)921 G_DELTA_CLOCK_C1(co->Sat[pos].Clock.DeltaA1)922 G_DELTA_CLOCK_C2(co->Sat[pos].Clock.DeltaA2)923 }924 break;925 case COTYPE_GLONASSURA:926 if(!co) return GCOBR_NOCLOCKORBITPARAMETER;927 co->messageType = COTYPE_GLONASSURA;928 G_GLONASS_EPOCH_TIME(co->GLONASSEpochTime, co->NumberOfGLONASSSat)929 G_MULTIPLE_MESSAGE_INDICATOR(mmi)930 G_SSR_IOD(co->SSRIOD)931 G_SSR_PROVIDER_ID(co->SSRProviderID)932 G_SSR_SOLUTION_ID(co->SSRSolutionID)933 G_NO_OF_SATELLITES(nums)934 co->URADataSupplied |= 2;935 for(i = 0; i < nums; ++i)936 {937 G_GLONASS_SATELLITE_ID(id)938 for(pos = CLOCKORBIT_NUMGPS; pos < CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat && co->Sat[pos].ID != id; ++pos)939 ;940 if(pos >= CLOCKORBIT_NUMGPS+CLOCKORBIT_NUMGLONASS) return GCOBR_DATAMISMATCH;941 else if(pos == CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat) ++co->NumberOfGLONASSSat;942 co->Sat[pos].ID = id;943 944 G_SSR_URA(co->Sat[pos].UserRangeAccuracy)945 }946 break;947 case COTYPE_GLONASSHR:948 if(!co) return GCOBR_NOCLOCKORBITPARAMETER;949 co->messageType = COTYPE_GLONASSHR;950 G_GLONASS_EPOCH_TIME(co->GLONASSEpochTime, co->NumberOfGLONASSSat)951 G_SSR_UPDATE_INTERVAL(co->UpdateInterval)952 G_MULTIPLE_MESSAGE_INDICATOR(mmi)953 G_SSR_IOD(co->SSRIOD)954 G_SSR_PROVIDER_ID(co->SSRProviderID)955 G_SSR_SOLUTION_ID(co->SSRSolutionID)956 G_NO_OF_SATELLITES(nums)957 co->HRDataSupplied |= 2;958 for(i = 0; i < nums; ++i)959 {960 G_GLONASS_SATELLITE_ID(id)961 for(pos = CLOCKORBIT_NUMGPS; pos < CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat && co->Sat[pos].ID != id; ++pos)962 ;963 if(pos >= CLOCKORBIT_NUMGPS+CLOCKORBIT_NUMGLONASS) return GCOBR_DATAMISMATCH;964 else if(pos == CLOCKORBIT_NUMGPS+co->NumberOfGLONASSSat) ++co->NumberOfGLONASSSat;965 co->Sat[pos].ID = id;966 967 G_HR_CLOCK_CORRECTION(co->Sat[pos].hrclock)968 }969 break;970 case BTYPE_GPS:971 if(!b) return GCOBR_NOBIASPARAMETER;972 b->messageType = BTYPE_GPS;973 G_GPS_EPOCH_TIME(b->GPSEpochTime, b->NumberOfGPSSat)974 G_SSR_UPDATE_INTERVAL(b->UpdateInterval)975 G_MULTIPLE_MESSAGE_INDICATOR(mmi)976 G_SSR_IOD(b->SSRIOD)977 G_SSR_PROVIDER_ID(b->SSRProviderID)978 G_SSR_SOLUTION_ID(b->SSRSolutionID)979 G_NO_OF_SATELLITES(nums)980 for(i = 0; i < nums; ++i)981 {982 G_GPS_SATELLITE_ID(id)983 for(pos = 0; pos < b->NumberOfGPSSat && b->Sat[pos].ID != id; ++pos)984 ;985 if(pos >= CLOCKORBIT_NUMGPS) return GCOBR_DATAMISMATCH;986 else if(pos == b->NumberOfGPSSat) ++b->NumberOfGPSSat;987 b->Sat[pos].ID = id;988 989 G_NO_OF_CODE_BIASES(b->Sat[pos].NumberOfCodeBiases)990 for(j = 0; j < b->Sat[pos].NumberOfCodeBiases; ++j)991 {992 G_GPS_SIGNAL_IDENTIFIER(b->Sat[pos].Biases[j].Type)993 G_CODE_BIAS(b->Sat[pos].Biases[j].Bias)994 }995 }996 break;997 case BTYPE_GLONASS:998 if(!b) return GCOBR_NOBIASPARAMETER;999 b->messageType = BTYPE_GLONASS;1000 G_GLONASS_EPOCH_TIME(b->GLONASSEpochTime, b->NumberOfGLONASSSat)1001 G_SSR_UPDATE_INTERVAL(b->UpdateInterval)1002 G_MULTIPLE_MESSAGE_INDICATOR(mmi)1003 G_SSR_IOD(b->SSRIOD)1004 G_SSR_PROVIDER_ID(b->SSRProviderID)1005 G_SSR_SOLUTION_ID(b->SSRSolutionID)1006 G_NO_OF_SATELLITES(nums)1007 for(i = 0; i < nums; ++i)1008 {1009 G_GLONASS_SATELLITE_ID(id)1010 for(pos = CLOCKORBIT_NUMGPS; pos < CLOCKORBIT_NUMGPS+b->NumberOfGLONASSSat && b->Sat[pos].ID != id; ++pos)1011 ;1012 if(pos >= CLOCKORBIT_NUMGPS+CLOCKORBIT_NUMGLONASS) return GCOBR_DATAMISMATCH;1013 else if(pos == CLOCKORBIT_NUMGPS+b->NumberOfGLONASSSat) ++b->NumberOfGLONASSSat;1014 b->Sat[pos].ID = id;1015 1016 G_NO_OF_CODE_BIASES(b->Sat[pos].NumberOfCodeBiases)1017 for(j = 0; j < b->Sat[pos].NumberOfCodeBiases; ++j)1018 {1019 G_GLONASS_SIGNAL_IDENTIFIER(b->Sat[pos].Biases[j].Type)1020 G_CODE_BIAS(b->Sat[pos].Biases[j].Bias)1021 }1022 }1023 break;1024 default:1025 if(bytesused)1026 *bytesused = sizeofrtcmblock+6;1027 return GCOBR_UNKNOWNTYPE;1028 }1029 #ifdef DEBUG1030 for(type = 0; type < (int)size && (unsigned char)buffer[type] != 0xD3; ++type)1031 numbits += 8;1032 fprintf(stderr, "numbits left %d\n",numbits);1033 #endif1034 818 if(bytesused) 1035 819 *bytesused = sizeofrtcmblock+6; 1036 return mmi ? GCOBR_MESSAGEFOLLOWS : GCOBR_OK; 820 if(type == VTEC_BASE) 821 { 822 unsigned int l, o, d; 823 if(!v) return GCOBR_NOVTECPARAMETER; 824 memset(v, 0, sizeof(*v)); 825 G_EPOCH_TIME(v->EpochTime) 826 G_SSR_UPDATE_INTERVAL(v->UpdateInterval) 827 G_MULTIPLE_MESSAGE_INDICATOR(mmi) 828 G_SSR_IOD(v->SSRIOD) 829 G_SSR_PROVIDER_ID(v->SSRProviderID) 830 G_SSR_SOLUTION_ID(v->SSRSolutionID) 831 G_VTEC_QUALITY_INDICATOR(v->Quality) 832 G_NO_IONO_LAYERS(v->NumLayers) 833 for(l = 0; l < v->NumLayers; ++l) 834 { 835 G_IONO_HEIGHT(v->Layers[l].Height) 836 G_IONO_DEGREE(v->Layers[l].Degree) 837 G_IONO_ORDER(v->Layers[l].Order) 838 for(o = 0; o <= v->Layers[l].Order; ++o) 839 { 840 for(d = o; d <= v->Layers[l].Degree; ++d) 841 { 842 G_IONO_COEFF(v->Layers[l].Cosinus[d][o]) 843 } 844 } 845 for(o = 1; o <= v->Layers[l].Order; ++o) 846 { 847 for(d = o; d <= v->Layers[l].Degree; ++d) 848 { 849 G_IONO_COEFF(v->Layers[l].Sinus[d][o]) 850 } 851 } 852 } 853 #ifdef DEBUG 854 for(type = 0; type < (int)size && (unsigned char)buffer[type] != 0xD3; ++type) 855 numbits += 8; 856 fprintf(stderr, "numbits left %d\n",numbits); 857 #endif 858 return mmi ? GCOBR_MESSAGEFOLLOWS : GCOBR_OK; 859 } 860 for(s = CLOCKORBIT_SATNUM; s-- > 0;) 861 { 862 if(type == PBTYPE_BASE+s) 863 { 864 if(!pb) return GCOBR_NOPHASEBIASPARAMETER; 865 pb->messageType = type; 866 switch(s) 867 { 868 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO: 869 case CLOCKORBIT_SATQZSS: case CLOCKORBIT_SATSBAS: 870 case CLOCKORBIT_SATBDS: 871 G_GPS_EPOCH_TIME(pb->EpochTime[s], pb->NumberOfSat[s]) 872 break; 873 case CLOCKORBIT_SATGLONASS: 874 G_GLONASS_EPOCH_TIME(pb->EpochTime[s], pb->NumberOfSat[s]) 875 break; 876 } 877 G_SSR_UPDATE_INTERVAL(pb->UpdateInterval) 878 G_MULTIPLE_MESSAGE_INDICATOR(mmi) 879 G_SSR_IOD(pb->SSRIOD) 880 G_SSR_PROVIDER_ID(pb->SSRProviderID) 881 G_SSR_SOLUTION_ID(pb->SSRSolutionID) 882 G_DISPERSIVE_BIAS_INDICATOR(pb->DispersiveBiasConsistencyIndicator) 883 G_MW_CONSISTENCY_INDICATOR(pb->MWConsistencyIndicator) 884 G_NO_OF_SATELLITES(nums) 885 for(i = 0; i < nums; ++i) 886 { 887 switch(s) 888 { 889 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO: 890 case CLOCKORBIT_SATSBAS: case CLOCKORBIT_SATBDS: 891 G_GPS_SATELLITE_ID(id) 892 break; 893 case CLOCKORBIT_SATQZSS: 894 G_QZSS_SATELLITE_ID(id) 895 break; 896 case CLOCKORBIT_SATGLONASS: 897 G_GLONASS_SATELLITE_ID(id) 898 break; 899 } 900 for(pos = satoffset[s]; pos < satoffset[s]+pb->NumberOfSat[s] && pb->Sat[pos].ID != id; ++pos) 901 ; 902 if(pos >= satoffset[s+1]) return GCOBR_DATAMISMATCH; 903 else if(pos == pb->NumberOfSat[s] + satoffset[s]) ++pb->NumberOfSat[s]; 904 pb->Sat[pos].ID = id; 905 906 G_NO_OF_PHASE_BIASES(pb->Sat[pos].NumberOfPhaseBiases) 907 G_YAW_ANGLE(pb->Sat[pos].YawAngle) 908 G_YAW_RATE(pb->Sat[pos].YawRate) 909 for(j = 0; j < pb->Sat[pos].NumberOfPhaseBiases; ++j) 910 { 911 G_SIGNAL_IDENTIFIER(pb->Sat[pos].Biases[j].Type) 912 G_INTEGER_INDICATOR(pb->Sat[pos].Biases[j].SignalIntegerIndicator) 913 G_WIDE_LANE_INDICATOR(pb->Sat[pos].Biases[j].SignalsWideLaneIntegerIndicator) 914 G_DISCONTINUITY_COUNTER(pb->Sat[pos].Biases[j].SignalDiscontinuityCounter) 915 G_PHASE_BIAS(pb->Sat[pos].Biases[j].Bias) 916 } 917 } 918 } 919 else if(type >= corbase[s]) 920 { 921 switch(type-corbase[s]) 922 { 923 case COBOFS_ORBIT: 924 if(!co) return GCOBR_NOCLOCKORBITPARAMETER; 925 co->messageType = type; 926 switch(s) 927 { 928 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO: 929 case CLOCKORBIT_SATQZSS: case CLOCKORBIT_SATSBAS: 930 case CLOCKORBIT_SATBDS: 931 G_GPS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s]) 932 break; 933 case CLOCKORBIT_SATGLONASS: 934 G_GLONASS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s]) 935 break; 936 } 937 G_SSR_UPDATE_INTERVAL(co->UpdateInterval) 938 G_MULTIPLE_MESSAGE_INDICATOR(mmi) 939 G_SATELLITE_REFERENCE_DATUM(co->SatRefDatum) 940 G_SSR_IOD(co->SSRIOD) 941 G_SSR_PROVIDER_ID(co->SSRProviderID) 942 G_SSR_SOLUTION_ID(co->SSRSolutionID) 943 G_NO_OF_SATELLITES(nums) 944 co->Supplied[COBOFS_ORBIT] |= 1; 945 #ifdef DEBUG 946 fprintf(stderr, "epochtime %d ui %d mmi %d sats %d/%d rd %d\n",co->EpochTime[s], 947 co->UpdateInterval,mmi,co->NumberOfSat[s],nums, co->SatRefDatum); 948 #endif 949 for(i = 0; i < nums; ++i) 950 { 951 switch(s) 952 { 953 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO: 954 case CLOCKORBIT_SATSBAS: case CLOCKORBIT_SATBDS: 955 G_GPS_SATELLITE_ID(id) 956 break; 957 case CLOCKORBIT_SATQZSS: 958 G_QZSS_SATELLITE_ID(id) 959 break; 960 case CLOCKORBIT_SATGLONASS: 961 G_GLONASS_SATELLITE_ID(id) 962 break; 963 } 964 for(pos = satoffset[s]; pos < satoffset[s]+co->NumberOfSat[s] && co->Sat[pos].ID != id; ++pos) 965 ; 966 if(pos >= satoffset[s+1]) return GCOBR_DATAMISMATCH; 967 else if(pos == co->NumberOfSat[s] + satoffset[s]) ++co->NumberOfSat[s]; 968 co->Sat[pos].ID = id; 969 970 switch(s) 971 { 972 case CLOCKORBIT_SATGPS: 973 case CLOCKORBIT_SATQZSS: 974 G_GPS_IODE(co->Sat[pos].IOD) 975 break; 976 case CLOCKORBIT_SATGLONASS: 977 G_GLONASS_IOD(co->Sat[pos].IOD) 978 break; 979 case CLOCKORBIT_SATGALILEO: 980 G_GALILEO_IOD(co->Sat[pos].IOD) 981 break; 982 case CLOCKORBIT_SATSBAS: 983 G_SBAS_T0MOD(co->Sat[pos].toe) 984 G_SBAS_IODCRC(co->Sat[pos].IOD) 985 break; 986 case CLOCKORBIT_SATBDS: 987 G_BDS_TOEMOD(co->Sat[pos].toe) 988 G_BDS_IODCRC(co->Sat[pos].IOD) 989 break; 990 } 991 G_DELTA_RADIAL(co->Sat[pos].Orbit.DeltaRadial) 992 G_DELTA_ALONG_TRACK(co->Sat[pos].Orbit.DeltaAlongTrack) 993 G_DELTA_CROSS_TRACK(co->Sat[pos].Orbit.DeltaCrossTrack) 994 G_DELTA_DOT_RADIAL(co->Sat[pos].Orbit.DotDeltaRadial) 995 G_DELTA_DOT_ALONG_TRACK(co->Sat[pos].Orbit.DotDeltaAlongTrack) 996 G_DELTA_DOT_CROSS_TRACK(co->Sat[pos].Orbit.DotDeltaCrossTrack) 997 #ifdef DEBUG 998 fprintf(stderr, "id %2d iod %3d dr %8.3f da %8.3f dc %8.3f dr %8.3f da %8.3f dc %8.3f\n", 999 co->Sat[pos].ID,co->Sat[pos].IOD,co->Sat[pos].Orbit.DeltaRadial, 1000 co->Sat[pos].Orbit.DeltaAlongTrack,co->Sat[pos].Orbit.DeltaCrossTrack, 1001 co->Sat[pos].Orbit.DotDeltaRadial, 1002 co->Sat[pos].Orbit.DotDeltaAlongTrack, 1003 co->Sat[pos].Orbit.DotDeltaCrossTrack); 1004 #endif 1005 } 1006 break; 1007 case COBOFS_CLOCK: 1008 if(!co) return GCOBR_NOCLOCKORBITPARAMETER; 1009 co->messageType = type; 1010 switch(s) 1011 { 1012 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO: 1013 case CLOCKORBIT_SATQZSS: case CLOCKORBIT_SATSBAS: 1014 case CLOCKORBIT_SATBDS: 1015 G_GPS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s]) 1016 break; 1017 case CLOCKORBIT_SATGLONASS: 1018 G_GLONASS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s]) 1019 break; 1020 } 1021 G_SSR_UPDATE_INTERVAL(co->UpdateInterval) 1022 G_MULTIPLE_MESSAGE_INDICATOR(mmi) 1023 G_SSR_IOD(co->SSRIOD) 1024 G_SSR_PROVIDER_ID(co->SSRProviderID) 1025 G_SSR_SOLUTION_ID(co->SSRSolutionID) 1026 G_NO_OF_SATELLITES(nums) 1027 co->Supplied[COBOFS_CLOCK] |= 1; 1028 #ifdef DEBUG 1029 fprintf(stderr, "epochtime %d ui %d mmi %d sats %d/%d\n",co->EpochTime[s], 1030 co->UpdateInterval,mmi,co->NumberOfSat[s],nums); 1031 #endif 1032 for(i = 0; i < nums; ++i) 1033 { 1034 switch(s) 1035 { 1036 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO: 1037 case CLOCKORBIT_SATSBAS: case CLOCKORBIT_SATBDS: 1038 G_GPS_SATELLITE_ID(id) 1039 break; 1040 case CLOCKORBIT_SATQZSS: 1041 G_QZSS_SATELLITE_ID(id) 1042 break; 1043 case CLOCKORBIT_SATGLONASS: 1044 G_GLONASS_SATELLITE_ID(id) 1045 break; 1046 } 1047 for(pos = satoffset[s]; pos < satoffset[s]+co->NumberOfSat[s] && co->Sat[pos].ID != id; ++pos) 1048 ; 1049 if(pos >= satoffset[s+1]) return GCOBR_DATAMISMATCH; 1050 else if(pos == co->NumberOfSat[s] + satoffset[s]) ++co->NumberOfSat[s]; 1051 co->Sat[pos].ID = id; 1052 1053 G_DELTA_CLOCK_C0(co->Sat[pos].Clock.DeltaA0) 1054 G_DELTA_CLOCK_C1(co->Sat[pos].Clock.DeltaA1) 1055 G_DELTA_CLOCK_C2(co->Sat[pos].Clock.DeltaA2) 1056 #ifdef DEBUG 1057 fprintf(stderr, "id %2d c0 %8.3f c1 %8.3f c2 %8.3f\n", 1058 co->Sat[pos].ID, co->Sat[pos].Clock.DeltaA0, co->Sat[pos].Clock.DeltaA1, 1059 co->Sat[pos].Clock.DeltaA2); 1060 #endif 1061 } 1062 break; 1063 case COBOFS_COMBINED: 1064 if(!co) return GCOBR_NOCLOCKORBITPARAMETER; 1065 co->messageType = type; 1066 switch(s) 1067 { 1068 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO: 1069 case CLOCKORBIT_SATQZSS: case CLOCKORBIT_SATSBAS: 1070 case CLOCKORBIT_SATBDS: 1071 G_GPS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s]) 1072 break; 1073 case CLOCKORBIT_SATGLONASS: 1074 G_GLONASS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s]) 1075 break; 1076 } 1077 G_SSR_UPDATE_INTERVAL(co->UpdateInterval) 1078 G_MULTIPLE_MESSAGE_INDICATOR(mmi) 1079 G_SATELLITE_REFERENCE_DATUM(co->SatRefDatum) 1080 G_SSR_IOD(co->SSRIOD) 1081 G_SSR_PROVIDER_ID(co->SSRProviderID) 1082 G_SSR_SOLUTION_ID(co->SSRSolutionID) 1083 G_NO_OF_SATELLITES(nums) 1084 co->Supplied[COBOFS_ORBIT] |= 1; 1085 co->Supplied[COBOFS_CLOCK] |= 1; 1086 for(i = 0; i < nums; ++i) 1087 { 1088 switch(s) 1089 { 1090 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO: 1091 case CLOCKORBIT_SATSBAS: case CLOCKORBIT_SATBDS: 1092 G_GPS_SATELLITE_ID(id) 1093 break; 1094 case CLOCKORBIT_SATQZSS: 1095 G_QZSS_SATELLITE_ID(id) 1096 break; 1097 case CLOCKORBIT_SATGLONASS: 1098 G_GLONASS_SATELLITE_ID(id) 1099 break; 1100 } 1101 for(pos = satoffset[s]; pos < satoffset[s]+co->NumberOfSat[s] && co->Sat[pos].ID != id; ++pos) 1102 ; 1103 if(pos >= satoffset[s+1]) return GCOBR_DATAMISMATCH; 1104 else if(pos == co->NumberOfSat[s] + satoffset[s]) ++co->NumberOfSat[s]; 1105 co->Sat[pos].ID = id; 1106 1107 switch(s) 1108 { 1109 case CLOCKORBIT_SATGPS: 1110 case CLOCKORBIT_SATQZSS: 1111 G_GPS_IODE(co->Sat[pos].IOD) 1112 break; 1113 case CLOCKORBIT_SATGLONASS: 1114 G_GLONASS_IOD(co->Sat[pos].IOD) 1115 break; 1116 case CLOCKORBIT_SATGALILEO: 1117 G_GALILEO_IOD(co->Sat[pos].IOD) 1118 break; 1119 case CLOCKORBIT_SATSBAS: 1120 G_SBAS_T0MOD(co->Sat[pos].toe) 1121 G_SBAS_IODCRC(co->Sat[pos].IOD) 1122 break; 1123 case CLOCKORBIT_SATBDS: 1124 G_BDS_TOEMOD(co->Sat[pos].toe) 1125 G_BDS_IODCRC(co->Sat[pos].IOD) 1126 break; 1127 } 1128 G_DELTA_RADIAL(co->Sat[pos].Orbit.DeltaRadial) 1129 G_DELTA_ALONG_TRACK(co->Sat[pos].Orbit.DeltaAlongTrack) 1130 G_DELTA_CROSS_TRACK(co->Sat[pos].Orbit.DeltaCrossTrack) 1131 G_DELTA_DOT_RADIAL(co->Sat[pos].Orbit.DotDeltaRadial) 1132 G_DELTA_DOT_ALONG_TRACK(co->Sat[pos].Orbit.DotDeltaAlongTrack) 1133 G_DELTA_DOT_CROSS_TRACK(co->Sat[pos].Orbit.DotDeltaCrossTrack) 1134 G_DELTA_CLOCK_C0(co->Sat[pos].Clock.DeltaA0) 1135 G_DELTA_CLOCK_C1(co->Sat[pos].Clock.DeltaA1) 1136 G_DELTA_CLOCK_C2(co->Sat[pos].Clock.DeltaA2) 1137 } 1138 break; 1139 case COBOFS_URA: 1140 if(!co) return GCOBR_NOCLOCKORBITPARAMETER; 1141 co->messageType = type; 1142 switch(s) 1143 { 1144 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO: 1145 case CLOCKORBIT_SATQZSS: case CLOCKORBIT_SATSBAS: 1146 case CLOCKORBIT_SATBDS: 1147 G_GPS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s]) 1148 break; 1149 case CLOCKORBIT_SATGLONASS: 1150 G_GLONASS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s]) 1151 break; 1152 } 1153 G_MULTIPLE_MESSAGE_INDICATOR(mmi) 1154 G_SSR_IOD(co->SSRIOD) 1155 G_SSR_PROVIDER_ID(co->SSRProviderID) 1156 G_SSR_SOLUTION_ID(co->SSRSolutionID) 1157 G_NO_OF_SATELLITES(nums) 1158 co->Supplied[COBOFS_URA] |= 1; 1159 for(i = 0; i < nums; ++i) 1160 { 1161 switch(s) 1162 { 1163 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO: 1164 case CLOCKORBIT_SATSBAS: case CLOCKORBIT_SATBDS: 1165 G_GPS_SATELLITE_ID(id) 1166 break; 1167 case CLOCKORBIT_SATQZSS: 1168 G_QZSS_SATELLITE_ID(id) 1169 break; 1170 case CLOCKORBIT_SATGLONASS: 1171 G_GLONASS_SATELLITE_ID(id) 1172 break; 1173 } 1174 for(pos = satoffset[s]; pos < satoffset[s]+co->NumberOfSat[s] && co->Sat[pos].ID != id; ++pos) 1175 ; 1176 if(pos >= satoffset[s+1]) return GCOBR_DATAMISMATCH; 1177 else if(pos == co->NumberOfSat[s] + satoffset[s]) ++co->NumberOfSat[s]; 1178 co->Sat[pos].ID = id; 1179 1180 G_SSR_URA(co->Sat[pos].UserRangeAccuracy) 1181 } 1182 break; 1183 case COBOFS_HR: 1184 if(!co) return GCOBR_NOCLOCKORBITPARAMETER; 1185 co->messageType = type; 1186 switch(s) 1187 { 1188 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO: 1189 case CLOCKORBIT_SATQZSS: case CLOCKORBIT_SATSBAS: 1190 case CLOCKORBIT_SATBDS: 1191 G_GPS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s]) 1192 break; 1193 case CLOCKORBIT_SATGLONASS: 1194 G_GLONASS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s]) 1195 break; 1196 } 1197 G_SSR_UPDATE_INTERVAL(co->UpdateInterval) 1198 G_MULTIPLE_MESSAGE_INDICATOR(mmi) 1199 G_SSR_IOD(co->SSRIOD) 1200 G_SSR_PROVIDER_ID(co->SSRProviderID) 1201 G_SSR_SOLUTION_ID(co->SSRSolutionID) 1202 G_NO_OF_SATELLITES(nums) 1203 co->Supplied[COBOFS_HR] |= 1; 1204 for(i = 0; i < nums; ++i) 1205 { 1206 switch(s) 1207 { 1208 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO: 1209 case CLOCKORBIT_SATSBAS: case CLOCKORBIT_SATBDS: 1210 G_GPS_SATELLITE_ID(id) 1211 break; 1212 case CLOCKORBIT_SATQZSS: 1213 G_QZSS_SATELLITE_ID(id) 1214 break; 1215 case CLOCKORBIT_SATGLONASS: 1216 G_GLONASS_SATELLITE_ID(id) 1217 break; 1218 } 1219 for(pos = satoffset[s]; pos < satoffset[s]+co->NumberOfSat[s] && co->Sat[pos].ID != id; ++pos) 1220 ; 1221 if(pos >= satoffset[s+1]) return GCOBR_DATAMISMATCH; 1222 else if(pos == co->NumberOfSat[s] + satoffset[s]) ++co->NumberOfSat[s]; 1223 co->Sat[pos].ID = id; 1224 1225 G_HR_CLOCK_CORRECTION(co->Sat[pos].hrclock) 1226 } 1227 break; 1228 case COBOFS_BIAS: 1229 if(!b) return GCOBR_NOCODEBIASPARAMETER; 1230 b->messageType = type; 1231 switch(s) 1232 { 1233 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO: 1234 case CLOCKORBIT_SATQZSS: case CLOCKORBIT_SATSBAS: 1235 case CLOCKORBIT_SATBDS: 1236 G_GPS_EPOCH_TIME(b->EpochTime[s], b->NumberOfSat[s]) 1237 break; 1238 case CLOCKORBIT_SATGLONASS: 1239 G_GLONASS_EPOCH_TIME(b->EpochTime[s], b->NumberOfSat[s]) 1240 break; 1241 } 1242 G_SSR_UPDATE_INTERVAL(b->UpdateInterval) 1243 G_MULTIPLE_MESSAGE_INDICATOR(mmi) 1244 G_SSR_IOD(b->SSRIOD) 1245 G_SSR_PROVIDER_ID(b->SSRProviderID) 1246 G_SSR_SOLUTION_ID(b->SSRSolutionID) 1247 G_NO_OF_SATELLITES(nums) 1248 for(i = 0; i < nums; ++i) 1249 { 1250 switch(s) 1251 { 1252 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO: 1253 case CLOCKORBIT_SATSBAS: case CLOCKORBIT_SATBDS: 1254 G_GPS_SATELLITE_ID(id) 1255 break; 1256 case CLOCKORBIT_SATQZSS: 1257 G_QZSS_SATELLITE_ID(id) 1258 break; 1259 case CLOCKORBIT_SATGLONASS: 1260 G_GLONASS_SATELLITE_ID(id) 1261 break; 1262 } 1263 for(pos = satoffset[s]; pos < satoffset[s]+b->NumberOfSat[s] && b->Sat[pos].ID != id; ++pos) 1264 ; 1265 if(pos >= satoffset[s+1]) return GCOBR_DATAMISMATCH; 1266 else if(pos == b->NumberOfSat[s] + satoffset[s]) ++b->NumberOfSat[s]; 1267 b->Sat[pos].ID = id; 1268 1269 G_NO_OF_CODE_BIASES(b->Sat[pos].NumberOfCodeBiases) 1270 for(j = 0; j < b->Sat[pos].NumberOfCodeBiases; ++j) 1271 { 1272 G_SIGNAL_IDENTIFIER(b->Sat[pos].Biases[j].Type) 1273 G_CODE_BIAS(b->Sat[pos].Biases[j].Bias) 1274 } 1275 } 1276 break; 1277 default: 1278 return GCOBR_UNKNOWNTYPE; 1279 } 1280 #ifdef COR_LATENCY 1281 if(s == CLOCKORBIT_SATGPS && type-corbase[s] != COBOFS_BIAS) 1282 { 1283 co->epochGPS[co->epochSize] = co->EpochTime[s]; 1284 if(co->epochSize < COR_LATENCYCOUNT) 1285 ++co->epochSize; 1286 } 1287 #endif 1288 #ifdef DEBUG 1289 for(type = 0; type < (int)size && (unsigned char)buffer[type] != 0xD3; ++type) 1290 numbits += 8; 1291 fprintf(stderr, "numbits left %d\n",numbits); 1292 #endif 1293 return mmi ? GCOBR_MESSAGEFOLLOWS : GCOBR_OK; 1294 } 1295 } 1296 return GCOBR_UNKNOWNTYPE; 1037 1297 } 1038 1298 #endif /* NODECODE */ -
trunk/clock_and_orbit/lib/clock_orbit_rtcm.h
r4241 r5664 14 14 15 15 enum SatelliteReferenceDatum { DATUM_ITRF=0, DATUM_LOCAL=1 }; 16 17 enum COR_BASE { 18 COBBASE_GPS = 1057, 19 COBBASE_GLONASS = 1063, 20 COBBASE_GALILEO = 1240, 21 COBBASE_QZSS = 1246, 22 COBBASE_SBAS = 1252, 23 COBBASE_BDS = 1258, 24 }; 25 26 enum COR_OFFSET { 27 COBOFS_ORBIT = 0, 28 COBOFS_CLOCK, 29 COBOFS_BIAS, 30 COBOFS_COMBINED, 31 COBOFS_URA, 32 COBOFS_HR, 33 COBOFS_NUM 34 }; 35 16 36 enum ClockOrbitType { 17 COTYPE_GPSORBIT=1057, COTYPE_GPSCLOCK=1058, 18 COTYPE_GPSCOMBINED=1060, COTYPE_GPSURA=1061, COTYPE_GPSHR=1062, 19 20 COTYPE_GLONASSORBIT=1063, COTYPE_GLONASSCLOCK=1064, 21 COTYPE_GLONASSCOMBINED=1066, COTYPE_GLONASSURA=1067, COTYPE_GLONASSHR=1068, 22 23 COTYPE_AUTO=0 }; 24 enum BiasType { BTYPE_GPS=1059, BTYPE_GLONASS=1065, BTYPE_AUTO = 0 }; 25 37 COTYPE_GPSORBIT = COBBASE_GPS + COBOFS_ORBIT, 38 COTYPE_GPSCLOCK, 39 COTYPE_GPSCOMBINED = COBBASE_GPS + COBOFS_COMBINED, 40 COTYPE_GPSURA, 41 COTYPE_GPSHR, 42 43 COTYPE_GLONASSORBIT = COBBASE_GLONASS + COBOFS_ORBIT, 44 COTYPE_GLONASSCLOCK, 45 COTYPE_GLONASSCOMBINED = COBBASE_GLONASS + COBOFS_COMBINED, 46 COTYPE_GLONASSURA, 47 COTYPE_GLONASSHR, 48 49 COTYPE_GALILEOORBIT = COBBASE_GALILEO + COBOFS_ORBIT, 50 COTYPE_GALILEOCLOCK, 51 COTYPE_GALILEOCOMBINED = COBBASE_GALILEO + COBOFS_COMBINED, 52 COTYPE_GALILEOURA, 53 COTYPE_GALILEOHR, 54 55 COTYPE_QZSSORBIT = COBBASE_QZSS + COBOFS_ORBIT, 56 COTYPE_QZSSCLOCK, 57 COTYPE_QZSSCOMBINED = COBBASE_QZSS + COBOFS_COMBINED, 58 COTYPE_QZSSURA, 59 COTYPE_QZSSHR, 60 61 COTYPE_SBASORBIT = COBBASE_SBAS + COBOFS_ORBIT, 62 COTYPE_SBASCLOCK, 63 COTYPE_SBASCOMBINED = COBBASE_QZSS + COBOFS_COMBINED, 64 COTYPE_SBASURA, 65 COTYPE_SBASHR, 66 67 COTYPE_BDSORBIT = COBBASE_BDS + COBOFS_ORBIT, 68 COTYPE_BDSCLOCK, 69 COTYPE_BDSCOMBINED = COBBASE_BDS + COBOFS_COMBINED, 70 COTYPE_BDSURA, 71 COTYPE_BDSHR, 72 73 COTYPE_AUTO = 0, 74 }; 75 76 enum CodeBiasType { 77 BTYPE_GPS = COBBASE_GPS + COBOFS_BIAS, 78 BTYPE_GLONASS = COBBASE_GLONASS + COBOFS_BIAS, 79 BTYPE_GALILEO = COBBASE_GALILEO + COBOFS_BIAS, 80 BTYPE_QZSS = COBBASE_QZSS + COBOFS_BIAS, 81 BTYPE_SBAS = COBBASE_QZSS + COBOFS_BIAS, 82 BTYPE_BDS = COBBASE_BDS + COBOFS_BIAS, 83 BTYPE_AUTO = 0 84 }; 85 86 enum PhaseBiasType { 87 PBTYPE_BASE = 1265, 88 PBTYPE_GPS = PBTYPE_BASE, 89 PBTYPE_GLONASS, 90 PBTYPE_GALILEO, 91 PBTYPE_QZSS, 92 PBTYPE_SBAS, 93 PBTYPE_BDS, 94 PBTYPE_AUTO = 0 95 }; 96 97 enum VTECType { 98 VTEC_BASE = 1264 99 }; 100 101 /* if some systems aren't supported at all, change the following numbers to zero 102 for these systems to save space */ 26 103 enum COR_CONSTANTS { 27 104 CLOCKORBIT_BUFFERSIZE=2048, 28 105 CLOCKORBIT_NUMGPS=32, 29 106 CLOCKORBIT_NUMGLONASS=24, 30 CLOCKORBIT_NUMBIAS=10 107 CLOCKORBIT_NUMGALILEO=36, 108 CLOCKORBIT_NUMQZSS=10, 109 CLOCKORBIT_NUMSBAS=38, 110 CLOCKORBIT_NUMBDS=37, 111 CLOCKORBIT_NUMBIAS=10, 112 CLOCKORBIT_NUMIONOLAYERS=4, 113 CLOCKORBIT_MAXIONOORDER=8, 114 CLOCKORBIT_MAXIONODEGREE=8 115 }; 116 117 enum COR_SATSYSTEM { 118 CLOCKORBIT_SATGPS=0, 119 CLOCKORBIT_SATGLONASS, 120 CLOCKORBIT_SATGALILEO, 121 CLOCKORBIT_SATQZSS, 122 CLOCKORBIT_SATSBAS, 123 CLOCKORBIT_SATBDS, 124 CLOCKORBIT_SATNUM 125 }; 126 127 enum COR_OFFSETS { 128 CLOCKORBIT_OFFSETGPS=0, 129 CLOCKORBIT_OFFSETGLONASS=CLOCKORBIT_NUMGPS, 130 CLOCKORBIT_OFFSETGALILEO=CLOCKORBIT_NUMGPS+CLOCKORBIT_NUMGLONASS, 131 CLOCKORBIT_OFFSETQZSS=CLOCKORBIT_NUMGPS+CLOCKORBIT_NUMGLONASS 132 +CLOCKORBIT_NUMGALILEO, 133 CLOCKORBIT_OFFSETSBAS=CLOCKORBIT_NUMGPS+CLOCKORBIT_NUMGLONASS 134 +CLOCKORBIT_NUMGALILEO+CLOCKORBIT_NUMQZSS, 135 CLOCKORBIT_OFFSETBDS=CLOCKORBIT_NUMGPS+CLOCKORBIT_NUMGLONASS 136 +CLOCKORBIT_NUMGALILEO+CLOCKORBIT_NUMQZSS+CLOCKORBIT_NUMSBAS, 137 CLOCKORBIT_COUNTSAT=CLOCKORBIT_NUMGPS+CLOCKORBIT_NUMGLONASS 138 +CLOCKORBIT_NUMGALILEO+CLOCKORBIT_NUMQZSS+CLOCKORBIT_NUMSBAS 139 +CLOCKORBIT_NUMBDS 31 140 }; 32 141 … … 54 163 CODETYPEGLONASS_L2_CA = 2, 55 164 CODETYPEGLONASS_L2_P = 3, 165 166 CODETYPEGALILEO_E1_A = 0, 167 CODETYPEGALILEO_E1_B = 1, 168 CODETYPEGALILEO_E1_C = 2, 169 CODETYPEGALILEO_E5A_I = 5, 170 CODETYPEGALILEO_E5A_Q = 6, 171 CODETYPEGALILEO_E5B_I = 8, 172 CODETYPEGALILEO_E5B_Q = 9, 173 CODETYPEGALILEO_E5_I = 11, 174 CODETYPEGALILEO_E5_Q = 12, 175 CODETYPEGALILEO_E6_A = 14, 176 CODETYPEGALILEO_E6_B = 15, 177 CODETYPEGALILEO_E6_C = 16, 178 179 CODETYPEQZSS_L1_CA = 0, 180 CODETYPEQZSS_L1C_D = 1, 181 CODETYPEQZSS_L1C_P = 2, 182 CODETYPEQZSS_L2_CM = 3, 183 CODETYPEQZSS_L2_CL = 4, 184 CODETYPEQZSS_L2_CML = 5, 185 CODETYPEQZSS_L5_I = 6, 186 CODETYPEQZSS_L5_Q = 7, 187 CODETYPEQZSS_L5_IQ = 8, 188 CODETYPEQZSS_LEX_S = 9, 189 CODETYPEQZSS_LEX_L = 10, 190 CODETYPEQZSS_LEX_SL = 11, 191 CODETYPEQZSS_L1C_DP = 12, 192 193 CODETYPE_SBAS_L1_CA = 0, 194 CODETYPE_SBAS_L5_I = 1, 195 CODETYPE_SBAS_L5_Q = 2, 196 CODETYPE_SBAS_L5_IQ = 3, 197 198 CODETYPE_BDS_B1_I = 0, 199 CODETYPE_BDS_B1_Q = 1, 200 CODETYPE_BDS_B1_IQ = 2, 201 CODETYPE_BDS_B3_I = 3, 202 CODETYPE_BDS_B3_Q = 4, 203 CODETYPE_BDS_B3_IQ = 5, 204 CODETYPE_BDS_B2_I = 6, 205 CODETYPE_BDS_B2_Q = 7, 206 CODETYPE_BDS_B2_IQ = 8, 56 207 }; 57 208 58 209 #define SSR_MAXURA 5.5 /* > 5466.5mm in meter */ 59 210 60 /* GLONASS data is stored with offset CLOCKORBIT_NUMGPS in the data structures. 61 So first GLONASS satellite is at xxx->Sat[CLOCKORBIT_NUMGPS], first 62 GPS satellite is xxx->Sat[0]. */ 211 /* satellite system data data is stored with offset CLOCKORBIT_OFFSET... 212 in the data structures. So first GLONASS satellite is at 213 xxx->Sat[CLOCKORBIT_OFFSETGLONASS], first GPS satellite is 214 xxx->Sat[CLOCKORBIT_OFFSETGPS]. */ 215 216 #ifdef COR_LEGACY 217 /* old names */ 218 #define NumberOfGPSSat NumberOfSat[CLOCKORBIT_SATGPS] 219 #define NumberOfGLONASSSat NumberOfSat[CLOCKORBIT_SATGLONASS] 220 #define GPSEpochTime EpochTime[CLOCKORBIT_SATGPS] /* 0 .. 604799 s */ 221 #define GLONASSEpochTime EpochTime[CLOCKORBIT_SATGLONASS] /* 0 .. 86399 s (86400 for leap second) */ 222 #define ClockDataSupplied Supplied[COBOFS_CLOCK] 223 #define HRDataSupplied Supplied[COBOFS_HR] 224 #define OrbitDataSupplied Supplied[COBOFS_ORBIT] 225 #define URADataSupplied Supplied[COBOFS_URA] 226 #define GetClockOrbitBias(a,b,c,d,e) GetSSR(a,b,0,0,c,d,e) 227 #endif /* COR_LEGACY */ 228 229 /* latency check code, disabled by default */ 230 #ifdef COR_LATENCY 231 #define COR_LATENCYCOUNT 100 232 #endif 63 233 64 234 struct ClockOrbit 65 235 { 66 236 enum ClockOrbitType messageType; 67 int GPSEpochTime; /* 0 .. 604799 s */ 68 int GLONASSEpochTime; /* 0 .. 86399 s (86400 for leap second) */ 69 int NumberOfGPSSat; /* 0 .. 32 */ 70 int NumberOfGLONASSSat; /* 0 .. 24 */ 71 int ClockDataSupplied; /* boolean */ 72 int HRDataSupplied; /* boolean */ 73 int OrbitDataSupplied; /* boolean */ 74 int URADataSupplied; /* boolean */ 75 int epochGPS[101]; /* Weber, for latency */ 76 int epochSize; /* Weber, for latency */ 77 int SSRIOD; 78 int SSRProviderID; 79 int SSRSolutionID; 80 int UpdateInterval; 237 unsigned int EpochTime[CLOCKORBIT_SATNUM]; /* 0 .. system specific maximum */ 238 unsigned int NumberOfSat[CLOCKORBIT_SATNUM]; /* 0 .. CLOCKORBIT_NUM... */ 239 240 unsigned int Supplied[COBOFS_NUM]; /* boolean */ 241 #ifdef COR_LATENCY 242 unsigned int epochGPS[COR_LATENCYCOUNT+1]; /* Weber, for latency */ 243 unsigned int epochSize; /* Weber, for latency */ 244 #endif 245 unsigned int SSRIOD; 246 unsigned int SSRProviderID; 247 unsigned int SSRSolutionID; 248 unsigned int UpdateInterval; 81 249 enum SatelliteReferenceDatum SatRefDatum; 82 250 struct SatData { 83 int ID; /* GPS or GLONASS */ 84 int IOD; /* GPS or GLONASS */ 251 unsigned int ID; /* all */ 252 unsigned int IOD; /* all */ 253 unsigned int toe; /* SBAS, BDS */ 85 254 double UserRangeAccuracy; /* accuracy values in [m] */ 86 255 double hrclock; … … 100 269 double DeltaA2; /* m/ss */ 101 270 } Clock; 102 } Sat[CLOCKORBIT_ NUMGPS+CLOCKORBIT_NUMGLONASS];103 }; 104 105 struct Bias271 } Sat[CLOCKORBIT_COUNTSAT]; 272 }; 273 274 struct CodeBias 106 275 { 107 enum BiasType messageType; 108 int GPSEpochTime; /* 0 .. 604799 s */ 109 int GLONASSEpochTime; /* 0 .. 86399 s (86400 for leap second) */ 110 int NumberOfGPSSat; /* 0 .. 32 */ 111 int NumberOfGLONASSSat; /* 0 .. 24 */ 112 int UpdateInterval; 113 int SSRIOD; 114 int SSRProviderID; 115 int SSRSolutionID; 276 enum CodeBiasType messageType; 277 unsigned int EpochTime[CLOCKORBIT_SATNUM]; /* 0 .. system specific maximum */ 278 unsigned int NumberOfSat[CLOCKORBIT_SATNUM]; /* 0 .. CLOCKORBIT_NUM... */ 279 unsigned int UpdateInterval; 280 unsigned int SSRIOD; 281 unsigned int SSRProviderID; 282 unsigned int SSRSolutionID; 116 283 struct BiasSat 117 284 { 118 int ID; /* GPS or GLONASS*/119 int NumberOfCodeBiases;120 struct CodeBias 285 unsigned int ID; /* all */ 286 unsigned int NumberOfCodeBiases; 287 struct CodeBiasEntry 121 288 { 122 289 enum CodeType Type; 123 290 float Bias; /* m */ 124 291 } Biases[CLOCKORBIT_NUMBIAS]; 125 } Sat[CLOCKORBIT_NUMGPS+CLOCKORBIT_NUMGLONASS]; 292 } Sat[CLOCKORBIT_COUNTSAT]; 293 }; 294 295 struct PhaseBias 296 { 297 enum PhaseBiasType messageType; 298 unsigned int EpochTime[CLOCKORBIT_SATNUM]; /* 0 .. system specific maximum */ 299 unsigned int NumberOfSat[CLOCKORBIT_SATNUM]; /* 0 .. CLOCKORBIT_NUM... */ 300 unsigned int UpdateInterval; 301 unsigned int SSRIOD; 302 unsigned int SSRProviderID; 303 unsigned int SSRSolutionID; 304 unsigned int DispersiveBiasConsistencyIndicator; 305 unsigned int MWConsistencyIndicator; 306 struct PhaseBiasSat 307 { 308 unsigned int ID; /* all */ 309 unsigned int NumberOfPhaseBiases; 310 double YawAngle; /* radiant */ 311 double YawRate; /* radiant/s */ 312 struct PhaseBiasEntry 313 { 314 enum CodeType Type; 315 unsigned int SignalIntegerIndicator; 316 unsigned int SignalsWideLaneIntegerIndicator; 317 unsigned int SignalDiscontinuityCounter; 318 float Bias; /* m */ 319 } Biases[CLOCKORBIT_NUMBIAS]; 320 } Sat[CLOCKORBIT_COUNTSAT]; 321 }; 322 323 struct VTEC 324 { 325 unsigned int EpochTime; /* GPS */ 326 unsigned int UpdateInterval; 327 unsigned int SSRIOD; 328 unsigned int SSRProviderID; 329 unsigned int SSRSolutionID; 330 unsigned int NumLayers; /* 1-4 */ 331 double Quality; 332 struct IonoLayers { 333 double Height; /* m */ 334 unsigned int Degree; /* 1-8 */ 335 unsigned int Order; /* 1-8 */ 336 double Sinus[CLOCKORBIT_MAXIONODEGREE][CLOCKORBIT_MAXIONOORDER]; 337 double Cosinus[CLOCKORBIT_MAXIONODEGREE][CLOCKORBIT_MAXIONOORDER]; 338 } Layers[CLOCKORBIT_NUMIONOLAYERS]; 126 339 }; 127 340 … … 129 342 size_t MakeClockOrbit(const struct ClockOrbit *co, enum ClockOrbitType type, 130 343 int moremessagesfollow, char *buffer, size_t size); 131 size_t Make Bias(const struct Bias *b, enumBiasType type,344 size_t MakeCodeBias(const struct CodeBias *b, enum CodeBiasType type, 132 345 int moremessagesfollow, char *buffer, size_t size); 346 size_t MakePhaseBias(const struct PhaseBias *b, enum PhaseBiasType type, 347 int moremessagesfollow, char *buffer, size_t size); 348 size_t MakeVTEC(const struct VTEC *b, int moremessagesfollow, char *buffer, 349 size_t size); 133 350 134 351 enum GCOB_RETURN { … … 143 360 /* failed to do the work */ 144 361 GCOBR_NOCLOCKORBITPARAMETER = -10, 145 GCOBR_NOBIASPARAMETER = -11, 362 GCOBR_NOCODEBIASPARAMETER = -11, 363 GCOBR_NOPHASEBIASPARAMETER = -12, 364 GCOBR_NOVTECPARAMETER = -13, 146 365 /* data mismatch - data in storage does not match new data */ 147 366 GCOBR_TIMEMISMATCH = -20, … … 155 374 156 375 /* buffer should point to a RTCM3 block */ 157 enum GCOB_RETURN Get ClockOrbitBias(struct ClockOrbit *co, struct Bias *b,158 const char *buffer, size_t size, int *bytesused);376 enum GCOB_RETURN GetSSR(struct ClockOrbit *co, struct CodeBias *b, struct VTEC *v, 377 struct PhaseBias *pb, const char *buffer, size_t size, int *bytesused); 159 378 160 379 #endif /* RTCM3_CLOCK_ORBIT_RTCM_H */ -
trunk/clock_and_orbit/readcoold.c
- Property svn:executable deleted
r5661 r5664 3 3 4 4 #include <stdio.h> 5 #include <stdlib.h> 5 6 6 7 /* prototype, don't use any of this code in a final application */ … … 11 12 int main(void) 12 13 { 13 char buffer[4096]; 14 char * buffer = 0; 15 size_t len = 0; 14 16 char obuffer[CLOCKORBIT_BUFFERSIZE]; 15 17 16 while(get s(buffer))18 while(getline(&buffer, &len, stdin) > 0) 17 19 { 18 20 char type; … … 28 30 if(lasttow >= 0) 29 31 { 32 FILE *f; 30 33 int l = MakeClockOrbit(&co, COTYPE_AUTO, 0, obuffer, sizeof(obuffer)); 31 34 if(!l) fprintf(stderr, "BUILD ERROR\n"); … … 35 38 struct ClockOrbit c; 36 39 37 // fwrite(obuffer, l, 1, stdout); 40 if((f = fopen("outfile.raw", "ab+"))) 41 { 42 fwrite(obuffer, l, 1, f); 43 fclose(f); 44 } 45 else fprintf(stderr, "SAVE ERROR\n"); 46 //fwrite(obuffer, l, 1, stdout); 38 47 memset(&c, 0, sizeof(c)); 39 nl = Get ClockOrbitBias(&c, 0, obuffer, l, &ns);48 nl = GetSSR(&c, 0, 0, 0, obuffer, l, &ns); 40 49 if(nl < 0) fprintf(stderr, "EXTRACT ERROR %d\n", nl); 41 50 else if(nl > 0) fprintf(stderr, "MULTIBLOCK UNSUPPORTED IN TEST\n"); … … 44 53 { 45 54 int i; 46 for(i = 0; i < c.NumberOf GPSSat; ++i)55 for(i = 0; i < c.NumberOfSat[CLOCKORBIT_SATGPS]; ++i) 47 56 { 48 printf("%d G% d %d %f %f %f %f\n", c.GPSEpochTime,57 printf("%d G%02d %d %f %f %f %f\n", c.EpochTime[CLOCKORBIT_SATGPS], 49 58 c.Sat[i].ID, co.Sat[i].IOD, c.Sat[i].Clock.DeltaA0, 50 59 c.Sat[i].Orbit.DeltaRadial, c.Sat[i].Orbit.DeltaAlongTrack, … … 56 65 memset(&co, 0, sizeof(co)); 57 66 lasttow = tow; 58 co. GPSEpochTime= (int)tow;67 co.EpochTime[CLOCKORBIT_SATGPS] = (int)tow; 59 68 /* co.GLONASSEpochTime = 0; */ 60 co. ClockDataSupplied= 1;61 co. OrbitDataSupplied= 1;69 co.Supplied[COBOFS_CLOCK] = 1; 70 co.Supplied[COBOFS_ORBIT] = 1; 62 71 co.SatRefDatum = DATUM_ITRF; 63 72 } 64 73 65 sd = co.Sat + co.NumberOf GPSSat;74 sd = co.Sat + co.NumberOfSat[CLOCKORBIT_SATGPS]; 66 75 sd->ID = prn; 67 76 sd->IOD = iode; … … 70 79 sd->Orbit.DeltaAlongTrack = along; 71 80 sd->Orbit.DeltaCrossTrack = outofplane; 72 printf("%d %d/%f %c %d %d %d %f %f %f %f\n",num, week, tow, type, prn,81 printf("%d %d/%f %c%02d %d %d %f %f %f %f\n",num, week, tow, type, prn, 73 82 iodc, iode, clock, radial, along, outofplane); 74 ++co.NumberOf GPSSat;83 ++co.NumberOfSat[CLOCKORBIT_SATGPS]; 75 84 } 76 85 } 86 { 87 struct VTEC v; 88 memset(&v, 0, sizeof(v)); 89 v.EpochTime = 218764; 90 v.NumLayers = 1; 91 v.UpdateInterval = 1; 92 v.Layers[0].Height = 450000; 93 v.Layers[0].Degree = 4; 94 v.Layers[0].Order = 4; 95 v.Layers[0].Cosinus[0][0] = 24.435; 96 v.Layers[0].Cosinus[1][0] = 4.495; 97 v.Layers[0].Cosinus[2][0] = -7.805; 98 v.Layers[0].Cosinus[3][0] = -1.900; 99 v.Layers[0].Cosinus[4][0] = 2.045; 100 v.Layers[0].Cosinus[1][1] = -9.960; 101 v.Layers[0].Cosinus[2][1] = 0.845; 102 v.Layers[0].Cosinus[3][1] = 2.260; 103 v.Layers[0].Cosinus[4][1] = -0.315; 104 v.Layers[0].Cosinus[2][2] = 3.730; 105 v.Layers[0].Cosinus[3][2] = -0.780; 106 v.Layers[0].Cosinus[4][2] = -0.055; 107 v.Layers[0].Cosinus[3][3] = -0.020; 108 v.Layers[0].Cosinus[4][3] = 1.150; 109 v.Layers[0].Cosinus[4][4] = 0.990; 110 111 v.Layers[0].Sinus[1][1] = -6.070; 112 v.Layers[0].Sinus[2][1] = -3.105; 113 v.Layers[0].Sinus[3][1] = 1.310; 114 v.Layers[0].Sinus[4][1] = 1.545; 115 v.Layers[0].Sinus[2][2] = 0.325; 116 v.Layers[0].Sinus[3][2] = -1.050; 117 v.Layers[0].Sinus[4][2] = -0.750; 118 v.Layers[0].Sinus[3][3] = 0.170; 119 v.Layers[0].Sinus[4][3] = -0.690; 120 v.Layers[0].Sinus[4][4] = -0.705; 121 FILE *f; 122 int l = MakeVTEC(&v, 0, obuffer, sizeof(obuffer)); 123 if(!l) fprintf(stderr, "BUILD ERROR\n"); 124 else 125 { 126 int nl, ns; 127 struct VTEC vv; 128 129 if((f = fopen("outfile.raw", "ab+"))) 130 { 131 fwrite(obuffer, l, 1, f); 132 fclose(f); 133 } 134 else fprintf(stderr, "SAVE ERROR\n"); 135 //fwrite(obuffer, l, 1, stdout); 136 memset(&vv, 0, sizeof(vv)); 137 nl = GetSSR(0, 0, &vv, 0, obuffer, l, &ns); 138 if(nl < 0) fprintf(stderr, "EXTRACT ERROR %d\n", nl); 139 else if(nl > 0) fprintf(stderr, "MULTIBLOCK UNSUPPORTED IN TEST\n"); 140 else if(ns != l) fprintf(stderr, "SIZE MISMATCH (%d/%d)\n", ns,l); 141 else 142 { 143 int i, j, k; 144 for(i = 0; i < vv.NumLayers; ++i) 145 { 146 printf("%d layer %d height %f degree %d order %d\n", vv.EpochTime, 147 i, vv.Layers[i].Height, vv.Layers[i].Degree, vv.Layers[i].Order); 148 for(j = 0; j <= vv.Layers[i].Degree; ++j) 149 { 150 printf("Cn%d ",j); 151 for(k = 0; k <= vv.Layers[i].Order; ++k) 152 { 153 printf(" %7.3f",vv.Layers[i].Cosinus[k][j]); 154 } 155 printf("\n"); 156 } 157 for(j = 0; j <= vv.Layers[i].Degree; ++j) 158 { 159 printf("Sn%d ",j); 160 for(k = 0; k <= vv.Layers[i].Order; ++k) 161 { 162 printf(" %7.3f",vv.Layers[i].Sinus[k][j]); 163 } 164 printf("\n"); 165 } 166 } 167 } 168 } 169 } 170 free(buffer); 77 171 return 0; 78 172 }
Note:
See TracChangeset
for help on using the changeset viewer.