Changeset 8987 in ntrip for branches/BNC_2.12/src/RTCM3/clock_and_orbit
- Timestamp:
- Jul 20, 2020, 3:54:44 PM (4 years ago)
- Location:
- branches/BNC_2.12/src/RTCM3/clock_and_orbit
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/BNC_2.12/src/RTCM3/clock_and_orbit/clock_orbit_rtcm.c
r8942 r8987 18 18 #include "clock_orbit_rtcm.h" 19 19 20 static uint32_t CRC24(long size, const unsigned char *buf) 21 { 20 static uint32_t CRC24(long size, const unsigned char *buf) { 22 21 uint32_t crc = 0; 23 22 int i; 24 23 25 while(size--) 26 { 24 while (size--) { 27 25 crc ^= (*buf++) << (16); 28 for (i = 0; i < 8; i++)29 {26 for (i = 0; i < 8; i++) 27 { 30 28 crc <<= 1; 31 if (crc & 0x1000000)29 if (crc & 0x1000000) 32 30 crc ^= 0x01864cfb; 33 31 } … … 37 35 38 36 /* NOTE: These defines are interlinked with below functions and directly modify 39 the values. This may not be optimized in terms of final program code size but40 should be optimized in terms of speed.41 42 modified variables are:43 - everything defined in STARTDATA (only use ressize outside of the defines,44 45 - buffer46 - size47 */37 the values. This may not be optimized in terms of final program code size but 38 should be optimized in terms of speed. 39 40 modified variables are: 41 - everything defined in STARTDATA (only use ressize outside of the defines, 42 others are private) 43 - buffer 44 - size 45 */ 48 46 49 47 #ifndef NOENCODE 50 48 #define STOREBITS \ 51 while(numbits >= 8) \ 52 { \ 49 while(numbits >= 8) { \ 53 50 if(!size) return 0; \ 54 51 *(buffer++) = bitbuffer>>(numbits-8); \ … … 58 55 } 59 56 60 #define ADDBITS(a, b) \ 61 { \ 57 #define ADDBITS(a, b) { \ 62 58 bitbuffer = (bitbuffer<<(a))|((b)&((1<<a)-1)); \ 63 59 numbits += (a); \ … … 79 75 80 76 #define ENDBLOCK \ 81 if(numbits) { ADDBITS((8-numbits), 0) } \ 82 { \ 77 if(numbits) { ADDBITS((8-numbits), 0) } { \ 83 78 int len = buffer-blockstart-3; \ 84 79 blockstart[1] |= len>>8; \ … … 95 90 96 91 /* 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) /* DF239 */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_IOD(a) ADDBITS( 8, a) /* DF471 */92 #define T_RTCM_MESSAGE_NUMBER(a) ADDBITS(12, a) /* DF002 */ 93 #define T_GPS_SATELLITE_ID(a) ADDBITS( 6, a) /* DF068 */ 94 #define T_QZSS_SATELLITE_ID(a) ADDBITS( 4, a) /* DF249 */ 95 #define T_GLONASS_SATELLITE_ID(a) ADDBITS( 5, a) 96 97 #define T_GPS_IODE(a) ADDBITS( 8, a) /* DF071 */ 98 #define T_GLONASS_IOD(a) ADDBITS( 8, a) /* DF239 */ 99 #define T_GALILEO_IOD(a) ADDBITS(10, a) /* DF459 */ 100 #define T_SBAS_T0MOD(a) ADDBITS( 9, (a/16)) /* DF468 */ 101 #define T_SBAS_IODCRC(a) ADDBITS(24, a) /* DF469 */ 102 #define T_BDS_TOEMOD(a) ADDBITS(10, (a/8)) /* DF470 */ 103 #define T_BDS_IOD(a) ADDBITS( 8, a) /* DF471 */ 109 104 110 105 #define T_DELTA_RADIAL(a) SCALEADDBITS(22, 10000.0, a) … … 119 114 #define T_DELTA_CLOCK_C1(a) SCALEADDBITS(21, 1000000.0, a) 120 115 #define T_DELTA_CLOCK_C2(a) SCALEADDBITS(27, 50000000.0, a) 121 #define T_NO_OF_CODE_BIASES(a) ADDBITS( 5, a)122 #define T_NO_OF_PHASE_BIASES(a) ADDBITS( 5, a)123 #define T_SIGNAL_IDENTIFIER(a) ADDBITS( 5, a)116 #define T_NO_OF_CODE_BIASES(a) ADDBITS( 5, a) 117 #define T_NO_OF_PHASE_BIASES(a) ADDBITS( 5, a) 118 #define T_SIGNAL_IDENTIFIER(a) ADDBITS( 5, a) 124 119 #define T_CODE_BIAS(a) SCALEADDBITS(14, 100.0, 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)120 #define T_YAW_ANGLE(a) SCALEADDBITS( 9, 256.0/MPI, a) 121 #define T_YAW_RATE(a) SCALEADDBITS( 8, 8192.0/MPI, a) 127 122 #define T_PHASE_BIAS(a) SCALEADDBITS(20, 10000.0, a) 128 123 129 124 #define T_GPS_EPOCH_TIME(a) ADDBITS(20, a) 130 125 #define T_GLONASS_EPOCH_TIME(a) ADDBITS(17, a) 131 #define T_NO_OF_SATELLITES(a) ADDBITS( 6, a)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( 2, a)137 #define T_DISCONTINUITY_COUNTER(a) ADDBITS( 4, a)138 #define T_SSR_URA(a) ADDBITS( 6, a)126 #define T_NO_OF_SATELLITES(a) ADDBITS( 6, a) 127 #define T_MULTIPLE_MESSAGE_INDICATOR(a) ADDBITS( 1, a) 128 #define T_DISPERSIVE_BIAS_INDICATOR(a) ADDBITS( 1, a) 129 #define T_MW_CONSISTENCY_INDICATOR(a) ADDBITS( 1, a) 130 #define T_INTEGER_INDICATOR(a) ADDBITS( 1, a) 131 #define T_WIDE_LANE_INDICATOR(a) ADDBITS( 2, a) 132 #define T_DISCONTINUITY_COUNTER(a) ADDBITS( 4, a) 133 #define T_SSR_URA(a) ADDBITS( 6, a) 139 134 #define T_HR_CLOCK_CORRECTION(a) SCALEADDBITS(22, 10000.0, a) 140 #define T_SSR_UPDATE_INTERVAL(a) ADDBITS( 4, a)141 142 #define T_SSR_IOD(a) ADDBITS( 4, a)135 #define T_SSR_UPDATE_INTERVAL(a) ADDBITS( 4, a) 136 137 #define T_SSR_IOD(a) ADDBITS( 4, a) 143 138 #define T_SSR_PROVIDER_ID(a) ADDBITS(16, a) 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)139 #define T_SSR_SOLUTION_ID(a) ADDBITS( 4, a) 140 141 #define T_NO_IONO_LAYERS(a) ADDBITS( 2, a-1) 142 #define T_VTEC_QUALITY_INDICATOR(a) SCALEADDBITS( 9, 20.0, a) 148 143 #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) 152 153 static double URAToValue(int ura) 154 { 144 #define T_IONO_DEGREE(a) ADDBITS( 4, a-1) 145 #define T_IONO_ORDER(a) ADDBITS( 4, a-1) 146 #define T_IONO_HEIGHT(a) SCALEADDBITS( 8, 1/10000.0, a) 147 148 static double URAToValue(int ura) { 155 149 int urac, urav; 156 150 urac = ura >> 3; 157 151 urav = ura & 7; 158 if (!ura)152 if (!ura) 159 153 return 0; 160 else if (ura == 63)154 else if (ura == 63) 161 155 return SSR_MAXURA; 162 return (pow(3, urac)*(1.0+urav/4.0)-1.0)/1000.0;156 return (pow(3, urac) * (1.0 + urav / 4.0) - 1.0) / 1000.0; 163 157 } 164 158 165 static int ValueToURA(double val) 166 { 159 static int ValueToURA(double val) { 167 160 int ura; 168 if (!val)161 if (!val) 169 162 return 0; 170 else if (val > 5.4665)163 else if (val > 5.4665) 171 164 return 63; 172 for (ura = 1; ura < 63 && val > URAToValue(ura); ++ura)165 for (ura = 1; ura < 63 && val > URAToValue(ura); ++ura) 173 166 ; 174 167 return ura; 175 168 } 176 169 177 static const enum ClockOrbitType corbase[CLOCKORBIT_SATNUM] = 178 { 179 (int) COBBASE_GPS, (int) COBBASE_GLONASS, (int) COBBASE_GALILEO, 180 (int) COBBASE_QZSS, (int) COBBASE_SBAS, (int) COBBASE_BDS 170 static const enum ClockOrbitType corbase[CLOCKORBIT_SATNUM] = { 171 (int) COBBASE_GPS, 172 (int) COBBASE_GLONASS, 173 (int) COBBASE_GALILEO, 174 (int) COBBASE_QZSS, 175 (int) COBBASE_SBAS, 176 (int) COBBASE_BDS 181 177 }; 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, 178 179 static const enum COR_OFFSETS satoffset[CLOCKORBIT_SATNUM + 1] = { 180 CLOCKORBIT_OFFSETGPS, 181 CLOCKORBIT_OFFSETGLONASS, 182 CLOCKORBIT_OFFSETGALILEO, 183 CLOCKORBIT_OFFSETQZSS, 184 CLOCKORBIT_OFFSETSBAS, 185 CLOCKORBIT_OFFSETBDS, 186 186 CLOCKORBIT_COUNTSAT 187 187 }; 188 188 189 189 size_t MakeClockOrbit(const struct ClockOrbit *co, enum ClockOrbitType type, 190 int moremessagesfollow, char *buffer, size_t size) 191 { 190 int moremessagesfollow, char *buffer, size_t size) { 192 191 unsigned int status[CLOCKORBIT_SATNUM][COBOFS_NUM], i, s; 193 192 194 193 memset(status, 0, sizeof(status)); 194 195 195 STARTDATA 196 196 197 for(s = 0; s < CLOCKORBIT_SATNUM; ++s) 198 { 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 { 197 for (s = 0; s < CLOCKORBIT_SATNUM; ++s) { 198 for (i = 0; i < COBOFS_NUM; ++i) { 199 if (co->NumberOfSat[s] && (type == COTYPE_AUTO || type == corbase[s] + i) && 200 (co->Supplied[i] || (i <= COBOFS_CLOCK && co->Supplied[COBOFS_COMBINED]) || 201 (i == COBOFS_COMBINED && co->Supplied[COBOFS_ORBIT] && co->Supplied[COBOFS_CLOCK]))) { 206 202 status[s][i] = 1; 207 if(i == COBOFS_COMBINED) 208 { 203 if (i == COBOFS_COMBINED) { 209 204 status[s][COBOFS_ORBIT] = status[s][COBOFS_CLOCK] = 0; 210 205 } /* disable single blocks for combined type */ … … 213 208 } /* iterate over satellite systems */ 214 209 215 for(s = 0; s < CLOCKORBIT_SATNUM; ++s) 216 { 217 if(status[s][COBOFS_ORBIT]) 218 { 210 for (s = 0; s < CLOCKORBIT_SATNUM; ++s) { 211 if (status[s][COBOFS_ORBIT]) { 219 212 INITBLOCK 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; 213 T_RTCM_MESSAGE_NUMBER(corbase[s] + COBOFS_ORBIT) 214 switch (s) { 215 case CLOCKORBIT_SATGPS: 216 case CLOCKORBIT_SATGALILEO: 217 case CLOCKORBIT_SATQZSS: 218 case CLOCKORBIT_SATSBAS: 219 case CLOCKORBIT_SATBDS: 220 T_GPS_EPOCH_TIME(co->EpochTime[s]) 221 break; 222 case CLOCKORBIT_SATGLONASS: 223 T_GLONASS_EPOCH_TIME(co->EpochTime[s]) 224 break; 231 225 } 232 226 T_SSR_UPDATE_INTERVAL(co->UpdateInterval) … … 237 231 T_SSR_SOLUTION_ID(co->SSRSolutionID) 238 232 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_IOD(co->Sat[i].IOD) 268 break; 233 for (i = satoffset[s]; i < satoffset[s] + co->NumberOfSat[s]; ++i) { 234 switch (s) { 235 case CLOCKORBIT_SATGPS: 236 T_GPS_SATELLITE_ID(co->Sat[i].ID) 237 T_GPS_IODE(co->Sat[i].IOD) 238 break; 239 case CLOCKORBIT_SATGLONASS: 240 T_GLONASS_SATELLITE_ID(co->Sat[i].ID) 241 T_GLONASS_IOD(co->Sat[i].IOD) 242 break; 243 case CLOCKORBIT_SATGALILEO: 244 T_GPS_SATELLITE_ID(co->Sat[i].ID) 245 T_GALILEO_IOD(co->Sat[i].IOD) 246 break; 247 case CLOCKORBIT_SATQZSS: 248 T_QZSS_SATELLITE_ID(co->Sat[i].ID) 249 T_GPS_IODE(co->Sat[i].IOD) 250 break; 251 case CLOCKORBIT_SATSBAS: 252 T_GPS_SATELLITE_ID(co->Sat[i].ID) 253 T_SBAS_T0MOD(co->Sat[i].toe) 254 T_SBAS_IODCRC(co->Sat[i].IOD) 255 break; 256 case CLOCKORBIT_SATBDS: 257 T_GPS_SATELLITE_ID(co->Sat[i].ID) 258 T_BDS_TOEMOD(co->Sat[i].toe) 259 T_BDS_IOD(co->Sat[i].IOD) 260 break; 269 261 } 270 262 T_DELTA_RADIAL(co->Sat[i].Orbit.DeltaRadial) … … 277 269 ENDBLOCK 278 270 } 279 if(status[s][COBOFS_CLOCK]) 280 { 271 if (status[s][COBOFS_CLOCK]) { 281 272 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; 273 T_RTCM_MESSAGE_NUMBER(corbase[s] + COBOFS_CLOCK) 274 switch (s) { 275 case CLOCKORBIT_SATGPS: 276 case CLOCKORBIT_SATGALILEO: 277 case CLOCKORBIT_SATQZSS: 278 case CLOCKORBIT_SATSBAS: 279 case CLOCKORBIT_SATBDS: 280 T_GPS_EPOCH_TIME(co->EpochTime[s]) 281 break; 282 case CLOCKORBIT_SATGLONASS: 283 T_GLONASS_EPOCH_TIME(co->EpochTime[s]) 284 break; 293 285 } 294 286 T_SSR_UPDATE_INTERVAL(co->UpdateInterval) … … 298 290 T_SSR_SOLUTION_ID(co->SSRSolutionID) 299 291 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;292 for (i = satoffset[s]; i < satoffset[s] + co->NumberOfSat[s]; ++i) { 293 switch (s) { 294 case CLOCKORBIT_SATGPS: 295 case CLOCKORBIT_SATGALILEO: 296 case CLOCKORBIT_SATSBAS: 297 case CLOCKORBIT_SATBDS: 298 T_GPS_SATELLITE_ID(co->Sat[i].ID) 299 break; 300 case CLOCKORBIT_SATQZSS: 301 T_QZSS_SATELLITE_ID(co->Sat[i].ID) 302 break; 303 case CLOCKORBIT_SATGLONASS: 304 T_GLONASS_SATELLITE_ID(co->Sat[i].ID) 305 break; 314 306 } 315 307 T_DELTA_CLOCK_C0(co->Sat[i].Clock.DeltaA0) … … 319 311 ENDBLOCK 320 312 } 321 if(status[s][COBOFS_COMBINED]) 322 { 313 if (status[s][COBOFS_COMBINED]) { 323 314 #ifdef SPLITBLOCK 324 315 int nums = co->NumberOfSat[s]; 325 316 int left, start = satoffset[s]; 326 if(nums > 28) /* split block when more than 28 sats */ 327 { 317 if(nums > 28) {/* split block when more than 28 sats */ 328 318 left = nums - 28; 329 319 nums = 28; 330 320 } 331 else 332 { 321 else { 333 322 left = 0; 334 323 } 335 while(nums) 336 { 337 #endif 338 INITBLOCK339 T_MESSAGE_NUMBER(corbase[s]+COBOFS_COMBINED)340 switch(s)341 {342 case CLOCKORBIT_SAT GPS: case CLOCKORBIT_SATGALILEO:343 case CLOCKORBIT_SAT QZSS: case CLOCKORBIT_SATSBAS:324 while(nums) { 325 #endif 326 INITBLOCK 327 T_RTCM_MESSAGE_NUMBER(corbase[s] + COBOFS_COMBINED) 328 switch (s) { 329 case CLOCKORBIT_SATGPS: 330 case CLOCKORBIT_SATGALILEO: 331 case CLOCKORBIT_SATQZSS: 332 case CLOCKORBIT_SATSBAS: 344 333 case CLOCKORBIT_SATBDS: 345 334 T_GPS_EPOCH_TIME(co->EpochTime[s]) … … 348 337 T_GLONASS_EPOCH_TIME(co->EpochTime[s]) 349 338 break; 350 351 339 } 340 T_SSR_UPDATE_INTERVAL(co->UpdateInterval) 352 341 #ifdef SPLITBLOCK 353 342 T_MULTIPLE_MESSAGE_INDICATOR((moremessagesfollow || left) ? 1 : 0) 354 343 #else 355 356 #endif 357 358 359 360 344 T_MULTIPLE_MESSAGE_INDICATOR(moremessagesfollow ? 1 : 0) 345 #endif 346 T_SATELLITE_REFERENCE_DATUM(co->SatRefDatum) 347 T_SSR_IOD(co->SSRIOD) 348 T_SSR_PROVIDER_ID(co->SSRProviderID) 349 T_SSR_SOLUTION_ID(co->SSRSolutionID) 361 350 #ifdef SPLITBLOCK 362 363 351 T_NO_OF_SATELLITES(nums) 352 for(i = start; i < start+nums; ++i) 364 353 #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 { 354 T_NO_OF_SATELLITES(co->NumberOfSat[s]) 355 for (i = satoffset[s]; i < satoffset[s] + co->NumberOfSat[s]; ++i) 356 #endif 357 { 358 switch (s) { 371 359 case CLOCKORBIT_SATGPS: 372 360 T_GPS_SATELLITE_ID(co->Sat[i].ID) … … 395 383 T_BDS_IOD(co->Sat[i].IOD) 396 384 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 385 } 408 ENDBLOCK 386 T_DELTA_RADIAL(co->Sat[i].Orbit.DeltaRadial) 387 T_DELTA_ALONG_TRACK(co->Sat[i].Orbit.DeltaAlongTrack) 388 T_DELTA_CROSS_TRACK(co->Sat[i].Orbit.DeltaCrossTrack) 389 T_DELTA_DOT_RADIAL(co->Sat[i].Orbit.DotDeltaRadial) 390 T_DELTA_DOT_ALONG_TRACK(co->Sat[i].Orbit.DotDeltaAlongTrack) 391 T_DELTA_DOT_CROSS_TRACK(co->Sat[i].Orbit.DotDeltaCrossTrack) 392 T_DELTA_CLOCK_C0(co->Sat[i].Clock.DeltaA0) 393 T_DELTA_CLOCK_C1(co->Sat[i].Clock.DeltaA1) 394 T_DELTA_CLOCK_C2(co->Sat[i].Clock.DeltaA2) 395 } 396 ENDBLOCK 409 397 #ifdef SPLITBLOCK 410 start += nums; 411 nums = left; 412 left = 0; 413 } 414 #endif 398 start += nums; 399 nums = left; 400 left = 0; 415 401 } 416 if(status[s][COBOFS_HR]) 417 { 402 #endif 403 } 404 if (status[s][COBOFS_HR]) { 418 405 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; 406 T_RTCM_MESSAGE_NUMBER(corbase[s] + COBOFS_HR) 407 switch (s) { 408 case CLOCKORBIT_SATGPS: 409 case CLOCKORBIT_SATGALILEO: 410 case CLOCKORBIT_SATQZSS: 411 case CLOCKORBIT_SATSBAS: 412 case CLOCKORBIT_SATBDS: 413 T_GPS_EPOCH_TIME(co->EpochTime[s]) 414 break; 415 case CLOCKORBIT_SATGLONASS: 416 T_GLONASS_EPOCH_TIME(co->EpochTime[s]) 417 break; 430 418 } 431 419 T_SSR_UPDATE_INTERVAL(co->UpdateInterval) … … 435 423 T_SSR_SOLUTION_ID(co->SSRSolutionID) 436 424 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;425 for (i = satoffset[s]; i < satoffset[s] + co->NumberOfSat[s]; ++i) { 426 switch (s) { 427 case CLOCKORBIT_SATGPS: 428 case CLOCKORBIT_SATGALILEO: 429 case CLOCKORBIT_SATSBAS: 430 case CLOCKORBIT_SATBDS: 431 T_GPS_SATELLITE_ID(co->Sat[i].ID) 432 break; 433 case CLOCKORBIT_SATQZSS: 434 T_QZSS_SATELLITE_ID(co->Sat[i].ID) 435 break; 436 case CLOCKORBIT_SATGLONASS: 437 T_GLONASS_SATELLITE_ID(co->Sat[i].ID) 438 break; 451 439 } 452 440 T_HR_CLOCK_CORRECTION(co->Sat[i].hrclock) … … 454 442 ENDBLOCK 455 443 } 456 if(status[s][COBOFS_URA]) 457 { 444 if (status[s][COBOFS_URA]) { 458 445 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; 446 T_RTCM_MESSAGE_NUMBER(corbase[s] + COBOFS_URA) 447 switch (s) { 448 case CLOCKORBIT_SATGPS: 449 case CLOCKORBIT_SATGALILEO: 450 case CLOCKORBIT_SATQZSS: 451 case CLOCKORBIT_SATSBAS: 452 case CLOCKORBIT_SATBDS: 453 T_GPS_EPOCH_TIME(co->EpochTime[s]) 454 break; 455 case CLOCKORBIT_SATGLONASS: 456 T_GLONASS_EPOCH_TIME(co->EpochTime[s]) 457 break; 470 458 } 471 459 T_SSR_UPDATE_INTERVAL(co->UpdateInterval) … … 475 463 T_SSR_SOLUTION_ID(co->SSRSolutionID) 476 464 T_NO_OF_SATELLITES(co->NumberOfSat[s]) 477 for (i = satoffset[s]; i < satoffset[s]+co->NumberOfSat[s]; ++i)478 {479 switch(s)480 {481 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO:482 case CLOCKORBIT_SATSBAS:case CLOCKORBIT_SATBDS:483 T_GPS_SATELLITE_ID(co->Sat[i].ID)484 break;485 case CLOCKORBIT_SATQZSS:486 T_QZSS_SATELLITE_ID(co->Sat[i].ID)487 break;488 case CLOCKORBIT_SATGLONASS:489 T_GLONASS_SATELLITE_ID(co->Sat[i].ID)490 break;465 for (i = satoffset[s]; i < satoffset[s] + co->NumberOfSat[s]; ++i) { 466 switch (s) { 467 case CLOCKORBIT_SATGPS: 468 case CLOCKORBIT_SATGALILEO: 469 case CLOCKORBIT_SATSBAS: 470 case CLOCKORBIT_SATBDS: 471 T_GPS_SATELLITE_ID(co->Sat[i].ID) 472 break; 473 case CLOCKORBIT_SATQZSS: 474 T_QZSS_SATELLITE_ID(co->Sat[i].ID) 475 break; 476 case CLOCKORBIT_SATGLONASS: 477 T_GLONASS_SATELLITE_ID(co->Sat[i].ID) 478 break; 491 479 } 492 480 T_SSR_URA(ValueToURA(co->Sat[i].UserRangeAccuracy)) … … 499 487 500 488 size_t MakeCodeBias(const struct CodeBias *b, enum CodeBiasType type, 501 int moremessagesfollow, char *buffer, size_t size) 502 { 489 int moremessagesfollow, char *buffer, size_t size) { 503 490 unsigned int s, i, j; 504 491 505 492 STARTDATA 506 493 507 for(s = 0; s < CLOCKORBIT_SATNUM; ++s) 508 { 509 if(b->NumberOfSat[s] && (type == BTYPE_AUTO || type == corbase[s]+COBOFS_BIAS)) 510 { 494 for (s = 0; s < CLOCKORBIT_SATNUM; ++s) { 495 if (b->NumberOfSat[s] && (type == CBTYPE_AUTO || type == corbase[s] + COBOFS_CBIAS)) { 511 496 INITBLOCK 512 T_MESSAGE_NUMBER(corbase[s]+COBOFS_BIAS) 513 switch(s) 514 { 515 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO: 516 case CLOCKORBIT_SATQZSS: case CLOCKORBIT_SATSBAS: 517 case CLOCKORBIT_SATBDS: 518 T_GPS_EPOCH_TIME(b->EpochTime[s]) 519 break; 520 case CLOCKORBIT_SATGLONASS: 521 T_GLONASS_EPOCH_TIME(b->EpochTime[s]) 522 break; 497 T_RTCM_MESSAGE_NUMBER(corbase[s] + COBOFS_CBIAS) 498 switch (s) { 499 case CLOCKORBIT_SATGPS: 500 case CLOCKORBIT_SATGALILEO: 501 case CLOCKORBIT_SATQZSS: 502 case CLOCKORBIT_SATSBAS: 503 case CLOCKORBIT_SATBDS: 504 T_GPS_EPOCH_TIME(b->EpochTime[s]) 505 break; 506 case CLOCKORBIT_SATGLONASS: 507 T_GLONASS_EPOCH_TIME(b->EpochTime[s]) 508 break; 523 509 } 524 510 T_SSR_UPDATE_INTERVAL(b->UpdateInterval) … … 528 514 T_SSR_SOLUTION_ID(b->SSRSolutionID) 529 515 T_NO_OF_SATELLITES(b->NumberOfSat[s]) 530 for (i = satoffset[s]; i < satoffset[s]+b->NumberOfSat[s]; ++i)531 {532 switch(s)533 {534 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO:535 case CLOCKORBIT_SATSBAS:case CLOCKORBIT_SATBDS:536 T_GPS_SATELLITE_ID(b->Sat[i].ID)537 break;538 case CLOCKORBIT_SATQZSS:539 T_QZSS_SATELLITE_ID(b->Sat[i].ID)540 break;541 case CLOCKORBIT_SATGLONASS:542 T_GLONASS_SATELLITE_ID(b->Sat[i].ID)543 break;516 for (i = satoffset[s]; i < satoffset[s] + b->NumberOfSat[s]; ++i) { 517 switch (s) { 518 case CLOCKORBIT_SATGPS: 519 case CLOCKORBIT_SATGALILEO: 520 case CLOCKORBIT_SATSBAS: 521 case CLOCKORBIT_SATBDS: 522 T_GPS_SATELLITE_ID(b->Sat[i].ID) 523 break; 524 case CLOCKORBIT_SATQZSS: 525 T_QZSS_SATELLITE_ID(b->Sat[i].ID) 526 break; 527 case CLOCKORBIT_SATGLONASS: 528 T_GLONASS_SATELLITE_ID(b->Sat[i].ID) 529 break; 544 530 } 545 531 T_NO_OF_CODE_BIASES(b->Sat[i].NumberOfCodeBiases) 546 for(j = 0; j < b->Sat[i].NumberOfCodeBiases; ++j) 547 { 532 for (j = 0; j < b->Sat[i].NumberOfCodeBiases; ++j) { 548 533 T_SIGNAL_IDENTIFIER(b->Sat[i].Biases[j].Type) 549 534 T_CODE_BIAS(b->Sat[i].Biases[j].Bias) … … 557 542 558 543 size_t MakePhaseBias(const struct PhaseBias *b, enum PhaseBiasType type, 559 int moremessagesfollow, char *buffer, size_t size) 560 { 544 int moremessagesfollow, char *buffer, size_t size) { 561 545 unsigned int s, i, j; 562 546 563 547 STARTDATA 564 548 565 for(s = 0; s < CLOCKORBIT_SATNUM; ++s) 566 { 567 if(b->NumberOfSat[s] && (type == PBTYPE_AUTO || type == s+PBTYPE_BASE)) 568 { 549 for (s = 0; s < CLOCKORBIT_SATNUM; ++s) { 550 if (b->NumberOfSat[s] && (type == PBTYPE_AUTO || type == s + PBTYPE_BASE)) { 569 551 INITBLOCK 570 T_MESSAGE_NUMBER(s+PBTYPE_BASE) 571 switch(s) 572 { 573 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO: 574 case CLOCKORBIT_SATQZSS: case CLOCKORBIT_SATSBAS: 575 case CLOCKORBIT_SATBDS: 576 T_GPS_EPOCH_TIME(b->EpochTime[s]) 577 break; 578 case CLOCKORBIT_SATGLONASS: 579 T_GLONASS_EPOCH_TIME(b->EpochTime[s]) 580 break; 552 T_RTCM_MESSAGE_NUMBER(s + PBTYPE_BASE) 553 switch (s) { 554 case CLOCKORBIT_SATGPS: 555 case CLOCKORBIT_SATGALILEO: 556 case CLOCKORBIT_SATQZSS: 557 case CLOCKORBIT_SATSBAS: 558 case CLOCKORBIT_SATBDS: 559 T_GPS_EPOCH_TIME(b->EpochTime[s]) 560 break; 561 case CLOCKORBIT_SATGLONASS: 562 T_GLONASS_EPOCH_TIME(b->EpochTime[s]) 563 break; 581 564 } 582 565 T_SSR_UPDATE_INTERVAL(b->UpdateInterval) … … 588 571 T_MW_CONSISTENCY_INDICATOR(b->MWConsistencyIndicator ? 1 : 0) 589 572 T_NO_OF_SATELLITES(b->NumberOfSat[s]) 590 for (i = satoffset[s]; i < satoffset[s]+b->NumberOfSat[s]; ++i)591 {592 switch(s)593 {594 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO:595 case CLOCKORBIT_SATSBAS:case CLOCKORBIT_SATBDS:596 T_GPS_SATELLITE_ID(b->Sat[i].ID)597 break;598 case CLOCKORBIT_SATQZSS:599 T_QZSS_SATELLITE_ID(b->Sat[i].ID)600 break;601 case CLOCKORBIT_SATGLONASS:602 T_GLONASS_SATELLITE_ID(b->Sat[i].ID)603 break;573 for (i = satoffset[s]; i < satoffset[s] + b->NumberOfSat[s]; ++i) { 574 switch (s) { 575 case CLOCKORBIT_SATGPS: 576 case CLOCKORBIT_SATGALILEO: 577 case CLOCKORBIT_SATSBAS: 578 case CLOCKORBIT_SATBDS: 579 T_GPS_SATELLITE_ID(b->Sat[i].ID) 580 break; 581 case CLOCKORBIT_SATQZSS: 582 T_QZSS_SATELLITE_ID(b->Sat[i].ID) 583 break; 584 case CLOCKORBIT_SATGLONASS: 585 T_GLONASS_SATELLITE_ID(b->Sat[i].ID) 586 break; 604 587 } 605 588 T_NO_OF_PHASE_BIASES(b->Sat[i].NumberOfPhaseBiases) 606 589 T_YAW_ANGLE(b->Sat[i].YawAngle) 607 590 T_YAW_RATE(b->Sat[i].YawRate) 608 for(j = 0; j < b->Sat[i].NumberOfPhaseBiases; ++j) 609 { 591 for (j = 0; j < b->Sat[i].NumberOfPhaseBiases; ++j) { 610 592 T_SIGNAL_IDENTIFIER(b->Sat[i].Biases[j].Type) 611 T_INTEGER_INDICATOR(b->Sat[i].Biases[j].SignalIntegerIndicator ? 1 : 0) 612 T_WIDE_LANE_INDICATOR(b->Sat[i].Biases[j].SignalsWideLaneIntegerIndicator) 613 T_DISCONTINUITY_COUNTER(b->Sat[i].Biases[j].SignalDiscontinuityCounter) 593 T_INTEGER_INDICATOR( 594 b->Sat[i].Biases[j].SignalIntegerIndicator ? 1 : 0) 595 T_WIDE_LANE_INDICATOR( 596 b->Sat[i].Biases[j].SignalsWideLaneIntegerIndicator) 597 T_DISCONTINUITY_COUNTER( 598 b->Sat[i].Biases[j].SignalDiscontinuityCounter) 614 599 T_PHASE_BIAS(b->Sat[i].Biases[j].Bias) 615 600 } … … 621 606 } 622 607 623 size_t MakeVTEC(const struct VTEC *v, int moremessagesfollow, char *buffer, 624 size_t size) 625 { 608 size_t MakeVTEC(const struct VTEC *v, int moremessagesfollow, char *buffer, size_t size) { 626 609 unsigned int l, o, d; 627 610 628 611 STARTDATA 629 INITBLOCK630 T_ MESSAGE_NUMBER(VTEC_BASE)612 INITBLOCK 613 T_RTCM_MESSAGE_NUMBER(VTEC_BASE) 631 614 632 615 T_GPS_EPOCH_TIME(v->EpochTime) … … 638 621 T_VTEC_QUALITY_INDICATOR(v->Quality) 639 622 T_NO_IONO_LAYERS(v->NumLayers) 640 for(l = 0; l < v->NumLayers; ++l) 641 { 623 for (l = 0; l < v->NumLayers; ++l) { 642 624 T_IONO_HEIGHT(v->Layers[l].Height) 643 625 T_IONO_DEGREE(v->Layers[l].Degree) 644 626 T_IONO_ORDER(v->Layers[l].Order) 645 for(o = 0; o <= v->Layers[l].Order; ++o) 646 { 647 for(d = o; d <= v->Layers[l].Degree; ++d) 648 { 627 for (o = 0; o <= v->Layers[l].Order; ++o) { 628 for (d = o; d <= v->Layers[l].Degree; ++d) { 649 629 T_IONO_COEFF(v->Layers[l].Cosinus[d][o]) 650 630 } 651 631 } 652 for(o = 1; o <= v->Layers[l].Order; ++o) 653 { 654 for(d = o; d <= v->Layers[l].Degree; ++d) 655 { 632 for (o = 1; o <= v->Layers[l].Order; ++o) { 633 for (d = o; d <= v->Layers[l].Degree; ++d) { 656 634 T_IONO_COEFF(v->Layers[l].Sinus[d][o]) 657 635 } … … 669 647 uint64_t bitbuffer=0; 670 648 671 #define LOADBITS(a) \ 672 { \ 649 #define LOADBITS(a) { \ 673 650 while((a) > numbits) \ 674 651 { \ … … 680 657 681 658 /* extract bits from data stream 682 b = variable to store result, a = number of bits */ 683 #define GETBITS(b, a) \ 684 { \ 659 b = variable to store result, a = number of bits */ 660 #define GETBITS(b, a) { \ 685 661 LOADBITS(a) \ 686 662 b = (bitbuffer<<(64-numbits))>>(64-(a)); \ … … 689 665 690 666 /* extract bits from data stream 691 b = variable to store result, a = number of bits */ 692 #define GETBITSFACTOR(b, a, c) \ 693 { \ 667 b = variable to store result, a = number of bits */ 668 #define GETBITSFACTOR(b, a, c) { \ 694 669 LOADBITS(a) \ 695 670 b = ((bitbuffer<<(64-numbits))>>(64-(a)))*(c); \ … … 698 673 699 674 /* extract signed floating value from data stream 700 b = variable to store result, a = number of bits */ 701 #define GETFLOATSIGN(b, a, c) \ 702 { \ 675 b = variable to store result, a = number of bits */ 676 #define GETFLOATSIGN(b, a, c) { \ 703 677 LOADBITS(a) \ 704 678 b = ((double)(((int64_t)(bitbuffer<<(64-numbits)))>>(64-(a))))*(c); \ … … 707 681 708 682 /* extract floating value from data stream 709 b = variable to store result, a = number of bits, c = scale factor */ 710 #define GETFLOAT(b, a, c) \ 711 { \ 683 b = variable to store result, a = number of bits, c = scale factor */ 684 #define GETFLOAT(b, a, c) { \ 712 685 LOADBITS(a) \ 713 686 b = ((double)((bitbuffer<<(sizeof(bitbuffer)*8-numbits))>>(sizeof(bitbuffer)*8-(a))))*(c); \ … … 721 694 #define G_RESERVEDH(a) GETBITS(a,6) 722 695 #define G_SIZE(a) GETBITS(a, 10) 723 #define G_ MESSAGE_NUMBER(a)GETBITS(a, 12) /* DF002 */696 #define G_RTCM_MESSAGE_NUMBER(a) GETBITS(a, 12) /* DF002 */ 724 697 #define G_GPS_SATELLITE_ID(a) GETBITS(a, 6) /* DF068 */ 725 698 #define G_QZSS_SATELLITE_ID(a) GETBITS(a, 4) /* DF249 */ … … 782 755 #define G_IONO_HEIGHT(a) GETFLOAT(a, 8 , 10000.0) 783 756 784 enum GCOB_RETURN GetSSR(struct ClockOrbit *co, struct CodeBias *b, struct VTEC *v, 785 struct PhaseBias *pb, const char *buffer, size_t size, int *bytesused) 786 { 787 int mmi=0, h, rs; 757 enum GCOB_RETURN GetSSR(struct ClockOrbit *co, struct CodeBias *b,struct VTEC *v, 758 struct PhaseBias *pb, const char *buffer, size_t size, int *bytesused) { 759 int mmi = 0, h, rs; 788 760 unsigned int type, pos, i, j, s, nums, id; 789 761 size_t sizeofrtcmblock; … … 791 763 DECODESTART 792 764 793 if (size < 7)765 if (size < 7) 794 766 return GCOBR_SHORTBUFFER; 795 767 796 #ifdef DEBUG797 fprintf(stderr, "Get ClockOrbitBias START: size %d, numbits %d\n",size, numbits);768 #ifdef BNC_DEBUG 769 fprintf(stderr, "GetSSR START: size %d, numbits %d\n",(int)size, numbits); 798 770 #endif 799 771 … … 802 774 G_SIZE(sizeofrtcmblock); 803 775 804 if ((unsigned char)h != 0xD3 || rs)776 if ((unsigned char) h != 0xD3 || rs) 805 777 return GCOBR_UNKNOWNDATA; 806 if (size < sizeofrtcmblock + 3) /* 3 header bytes already removed */778 if (size < sizeofrtcmblock + 3) /* 3 header bytes already removed */ 807 779 return GCOBR_MESSAGEEXCEEDSBUFFER; 808 if (CRC24(sizeofrtcmblock+3, (const unsigned char *) blockstart) !=809 (uint32_t)((((unsigned char)buffer[sizeofrtcmblock])<<16)|810 (((unsigned char)buffer[sizeofrtcmblock+1])<<8)|811 (((unsigned char)buffer[sizeofrtcmblock+2]))))780 if (CRC24(sizeofrtcmblock + 3, (const unsigned char *) blockstart) != 781 (uint32_t) ((((unsigned char) buffer[sizeofrtcmblock]) << 16) | 782 (((unsigned char) buffer[sizeofrtcmblock + 1]) << 8) | 783 (((unsigned char) buffer[sizeofrtcmblock + 2])))) 812 784 return GCOBR_CRCMISMATCH; 813 785 size = sizeofrtcmblock; /* reduce size, so overflows are detected */ 814 786 815 G_MESSAGE_NUMBER(type) 816 #ifdef DEBUG 817 fprintf(stderr, "type %d size %d\n",type,sizeofrtcmblock); 818 #endif 819 if(bytesused) 820 *bytesused = sizeofrtcmblock+6; 821 if(type == VTEC_BASE) 822 { 787 G_RTCM_MESSAGE_NUMBER(type) 788 #ifdef BNC_DEBUG 789 fprintf(stderr, "type %d size %d\n",type,(int)sizeofrtcmblock); 790 #endif 791 if (bytesused) 792 *bytesused = sizeofrtcmblock + 6; 793 if (type == VTEC_BASE) { 823 794 unsigned int l, o, d; 824 if(!v) return GCOBR_NOVTECPARAMETER; 795 if (!v) 796 return GCOBR_NOVTECPARAMETER; 825 797 memset(v, 0, sizeof(*v)); 826 798 G_EPOCH_TIME(v->EpochTime) … … 832 804 G_VTEC_QUALITY_INDICATOR(v->Quality) 833 805 G_NO_IONO_LAYERS(v->NumLayers) 834 for(l = 0; l < v->NumLayers; ++l) 835 { 806 #ifdef BNC_DEBUG 807 fprintf(stderr, "epochTime %d ui %d mmi %d ssrIod %d providerId %d solId %d vtecQ %8.3f numLay %d \n", 808 v->EpochTime, v->UpdateInterval, mmi, 809 v->SSRIOD, v->SSRProviderID, v->SSRSolutionID, v->Quality, v->NumLayers); 810 #endif 811 for (l = 0; l < v->NumLayers; ++l) { 836 812 G_IONO_HEIGHT(v->Layers[l].Height) 837 813 G_IONO_DEGREE(v->Layers[l].Degree) 838 814 G_IONO_ORDER(v->Layers[l].Order) 839 for(o = 0; o <= v->Layers[l].Order; ++o) 840 { 841 for(d = o; d <= v->Layers[l].Degree; ++d) 842 { 815 #ifdef BNC_DEBUG 816 fprintf(stderr, "h %8.3f deg %d ord %d \n", 817 v->Layers[l].Height, v->Layers[l].Degree, v->Layers[l].Order); 818 #endif 819 for (o = 0; o <= v->Layers[l].Order; ++o) { 820 for (d = o; d <= v->Layers[l].Degree; ++d) { 843 821 G_IONO_COEFF(v->Layers[l].Cosinus[d][o]) 822 #ifdef BNC_DEBUG 823 fprintf(stderr, "C[%02d][%02d] %8.3f \n", 824 d, o, v->Layers[l].Cosinus[d][o]); 825 #endif 844 826 } 845 827 } 846 for(o = 1; o <= v->Layers[l].Order; ++o) 847 { 848 for(d = o; d <= v->Layers[l].Degree; ++d) 849 { 828 for (o = 1; o <= v->Layers[l].Order; ++o) { 829 for (d = o; d <= v->Layers[l].Degree; ++d) { 850 830 G_IONO_COEFF(v->Layers[l].Sinus[d][o]) 831 #ifdef BNC_DEBUG 832 fprintf(stderr, "S[%02d][%02d] %8.3f \n", 833 d, o, v->Layers[l].Sinus[d][o]); 834 #endif 851 835 } 852 836 } 853 837 } 854 #ifdef DEBUG855 for(type = 0; type < ( int)size && (unsigned char)buffer[type] != 0xD3; ++type)856 838 #ifdef BNC_DEBUG 839 for(type = 0; type < (unsigned int)size && (unsigned char)buffer[type] != 0xD3; ++type) 840 numbits += 8; 857 841 fprintf(stderr, "numbits left %d\n",numbits); 858 842 #endif 859 843 return mmi ? GCOBR_MESSAGEFOLLOWS : GCOBR_OK; 860 844 } 861 for(s = CLOCKORBIT_SATNUM; s-- > 0;) 862 { 863 if(type == PBTYPE_BASE+s) 864 { 865 if(!pb) return GCOBR_NOPHASEBIASPARAMETER; 845 for (s = CLOCKORBIT_SATNUM; s-- > 0;) { 846 if (type == PBTYPE_BASE + s) { 847 if (!pb) 848 return GCOBR_NOPHASEBIASPARAMETER; 866 849 pb->messageType = type; 867 switch(s) 868 { 869 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO: 870 case CLOCKORBIT_SATQZSS: case CLOCKORBIT_SATSBAS: 871 case CLOCKORBIT_SATBDS: 872 G_GPS_EPOCH_TIME(pb->EpochTime[s], pb->NumberOfSat[s]) 873 break; 874 case CLOCKORBIT_SATGLONASS: 875 G_GLONASS_EPOCH_TIME(pb->EpochTime[s], pb->NumberOfSat[s]) 876 break; 850 switch (s) { 851 case CLOCKORBIT_SATGPS: 852 case CLOCKORBIT_SATGALILEO: 853 case CLOCKORBIT_SATQZSS: 854 case CLOCKORBIT_SATSBAS: 855 case CLOCKORBIT_SATBDS: 856 G_GPS_EPOCH_TIME(pb->EpochTime[s], pb->NumberOfSat[s]) 857 break; 858 case CLOCKORBIT_SATGLONASS: 859 G_GLONASS_EPOCH_TIME(pb->EpochTime[s], pb->NumberOfSat[s]) 860 break; 877 861 } 878 862 G_SSR_UPDATE_INTERVAL(pb->UpdateInterval) … … 884 868 G_MW_CONSISTENCY_INDICATOR(pb->MWConsistencyIndicator) 885 869 G_NO_OF_SATELLITES(nums) 886 for(i = 0; i < nums; ++i) 887 { 888 switch(s) 889 { 890 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO: 891 case CLOCKORBIT_SATSBAS: case CLOCKORBIT_SATBDS: 892 G_GPS_SATELLITE_ID(id) 893 break; 894 case CLOCKORBIT_SATQZSS: 895 G_QZSS_SATELLITE_ID(id) 896 break; 897 case CLOCKORBIT_SATGLONASS: 898 G_GLONASS_SATELLITE_ID(id) 899 break; 870 #ifdef BNC_DEBUG 871 fprintf(stderr, "epochTime %d ui %d mmi %d sats %d/%d ssrIod %d providerId %d solId %d dispInd %d mwInd %d\n", 872 pb->EpochTime[s], pb->UpdateInterval,mmi,pb->NumberOfSat[s],nums, 873 pb->SSRIOD, pb->SSRProviderID, pb->SSRSolutionID, 874 pb->DispersiveBiasConsistencyIndicator, pb->MWConsistencyIndicator); 875 #endif 876 for (i = 0; i < nums; ++i) { 877 switch (s) { 878 case CLOCKORBIT_SATGPS: 879 case CLOCKORBIT_SATGALILEO: 880 case CLOCKORBIT_SATSBAS: 881 case CLOCKORBIT_SATBDS: 882 G_GPS_SATELLITE_ID(id) 883 break; 884 case CLOCKORBIT_SATQZSS: 885 G_QZSS_SATELLITE_ID(id) 886 break; 887 case CLOCKORBIT_SATGLONASS: 888 G_GLONASS_SATELLITE_ID(id) 889 break; 900 890 } 901 for(pos = satoffset[s]; pos < satoffset[s]+pb->NumberOfSat[s] && pb->Sat[pos].ID != id; ++pos) 891 for (pos = satoffset[s]; 892 pos < satoffset[s] + pb->NumberOfSat[s] && pb->Sat[pos].ID != id; 893 ++pos) 902 894 ; 903 if(pos >= satoffset[s+1]) return GCOBR_DATAMISMATCH; 904 else if(pos == pb->NumberOfSat[s] + satoffset[s]) ++pb->NumberOfSat[s]; 895 if (pos >= satoffset[s + 1]) 896 return GCOBR_DATAMISMATCH; 897 else if (pos == pb->NumberOfSat[s] + satoffset[s]) 898 ++pb->NumberOfSat[s]; 905 899 pb->Sat[pos].ID = id; 906 907 900 G_NO_OF_PHASE_BIASES(pb->Sat[pos].NumberOfPhaseBiases) 908 901 G_YAW_ANGLE(pb->Sat[pos].YawAngle) 909 902 G_YAW_RATE(pb->Sat[pos].YawRate) 910 for(j = 0; j < pb->Sat[pos].NumberOfPhaseBiases; ++j) 911 { 903 #ifdef BNC_DEBUG 904 fprintf(stderr, "id %2d #%d y %10.6f yr %10.6f ", 905 pb->Sat[pos].ID, pb->Sat[pos].NumberOfPhaseBiases, 906 pb->Sat[pos].YawAngle/MPI, pb->Sat[pos].YawRate/MPI); 907 #endif 908 for (j = 0; j < pb->Sat[pos].NumberOfPhaseBiases; ++j) { 912 909 G_SIGNAL_IDENTIFIER(pb->Sat[pos].Biases[j].Type) 913 910 G_INTEGER_INDICATOR(pb->Sat[pos].Biases[j].SignalIntegerIndicator) 914 G_WIDE_LANE_INDICATOR(pb->Sat[pos].Biases[j].SignalsWideLaneIntegerIndicator) 915 G_DISCONTINUITY_COUNTER(pb->Sat[pos].Biases[j].SignalDiscontinuityCounter) 911 G_WIDE_LANE_INDICATOR( 912 pb->Sat[pos].Biases[j].SignalsWideLaneIntegerIndicator) 913 G_DISCONTINUITY_COUNTER( 914 pb->Sat[pos].Biases[j].SignalDiscontinuityCounter) 916 915 G_PHASE_BIAS(pb->Sat[pos].Biases[j].Bias) 916 #ifdef BNC_DEBUG 917 fprintf(stderr, "t%02d int %d wl %d disc %d b %8.4f ", 918 pb->Sat[pos].Biases[j].Type, 919 pb->Sat[pos].Biases[j].SignalIntegerIndicator, 920 pb->Sat[pos].Biases[j].SignalsWideLaneIntegerIndicator, 921 pb->Sat[pos].Biases[j].SignalDiscontinuityCounter, 922 pb->Sat[pos].Biases[j].Bias); 923 #endif 917 924 } 918 } 919 #ifdef DEBUG 920 for(type = 0; type < (int)size && (unsigned char)buffer[type] != 0xD3; ++type) 921 numbits += 8; 925 #ifdef BNC_DEBUG 926 fprintf(stderr, "\n"); 927 #endif 928 } 929 #ifdef BNC_DEBUG 930 for(type = 0; type < (unsigned int)size && (unsigned char)buffer[type] != 0xD3; ++type) 931 numbits += 8; 922 932 fprintf(stderr, "numbits left %d\n",numbits); 923 933 #endif 924 934 return mmi ? GCOBR_MESSAGEFOLLOWS : GCOBR_OK; 925 935 } 926 else if(type >= corbase[s]) 927 { 928 switch(type-corbase[s]) 929 { 930 case COBOFS_ORBIT: 931 if(!co) return GCOBR_NOCLOCKORBITPARAMETER; 932 co->messageType = type; 933 switch(s) 934 { 935 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO: 936 case CLOCKORBIT_SATQZSS: case CLOCKORBIT_SATSBAS: 937 case CLOCKORBIT_SATBDS: 938 G_GPS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s]) 939 break; 940 case CLOCKORBIT_SATGLONASS: 941 G_GLONASS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s]) 942 break; 943 } 944 G_SSR_UPDATE_INTERVAL(co->UpdateInterval) 945 G_MULTIPLE_MESSAGE_INDICATOR(mmi) 946 G_SATELLITE_REFERENCE_DATUM(co->SatRefDatum) 947 G_SSR_IOD(co->SSRIOD) 948 G_SSR_PROVIDER_ID(co->SSRProviderID) 949 G_SSR_SOLUTION_ID(co->SSRSolutionID) 950 G_NO_OF_SATELLITES(nums) 951 co->Supplied[COBOFS_ORBIT] |= 1; 952 #ifdef DEBUG 953 fprintf(stderr, "epochtime %d ui %d mmi %d sats %d/%d rd %d\n",co->EpochTime[s], 954 co->UpdateInterval,mmi,co->NumberOfSat[s],nums, co->SatRefDatum); 955 #endif 956 for(i = 0; i < nums; ++i) 957 { 958 switch(s) 959 { 960 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO: 961 case CLOCKORBIT_SATSBAS: case CLOCKORBIT_SATBDS: 962 G_GPS_SATELLITE_ID(id) 963 break; 964 case CLOCKORBIT_SATQZSS: 965 G_QZSS_SATELLITE_ID(id) 966 break; 967 case CLOCKORBIT_SATGLONASS: 968 G_GLONASS_SATELLITE_ID(id) 969 break; 936 else if (type >= corbase[s]) { 937 switch (type - corbase[s]) { 938 case COBOFS_ORBIT: 939 if (!co) 940 return GCOBR_NOCLOCKORBITPARAMETER; 941 co->messageType = type; 942 switch (s) { 943 case CLOCKORBIT_SATGPS: 944 case CLOCKORBIT_SATGALILEO: 945 case CLOCKORBIT_SATQZSS: 946 case CLOCKORBIT_SATSBAS: 947 case CLOCKORBIT_SATBDS: 948 G_GPS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s]) 949 break; 950 case CLOCKORBIT_SATGLONASS: 951 G_GLONASS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s]) 952 break; 970 953 } 971 for(pos = satoffset[s]; pos < satoffset[s]+co->NumberOfSat[s] && co->Sat[pos].ID != id; ++pos) 972 ; 973 if(pos >= satoffset[s+1]) return GCOBR_DATAMISMATCH; 974 else if(pos == co->NumberOfSat[s] + satoffset[s]) ++co->NumberOfSat[s]; 975 co->Sat[pos].ID = id; 976 977 switch(s) 978 { 979 case CLOCKORBIT_SATGPS: 980 case CLOCKORBIT_SATQZSS: 981 G_GPS_IODE(co->Sat[pos].IOD) 982 break; 983 case CLOCKORBIT_SATGLONASS: 984 G_GLONASS_IOD(co->Sat[pos].IOD) 985 break; 986 case CLOCKORBIT_SATGALILEO: 987 G_GALILEO_IOD(co->Sat[pos].IOD) 988 break; 989 case CLOCKORBIT_SATSBAS: 990 G_SBAS_T0MOD(co->Sat[pos].toe) 991 G_SBAS_IODCRC(co->Sat[pos].IOD) 992 break; 993 case CLOCKORBIT_SATBDS: 994 G_BDS_TOEMOD(co->Sat[pos].toe) 995 G_BDS_IOD(co->Sat[pos].IOD) 996 break; 954 G_SSR_UPDATE_INTERVAL(co->UpdateInterval) 955 G_MULTIPLE_MESSAGE_INDICATOR(mmi) 956 G_SATELLITE_REFERENCE_DATUM(co->SatRefDatum) 957 G_SSR_IOD(co->SSRIOD) 958 G_SSR_PROVIDER_ID(co->SSRProviderID) 959 G_SSR_SOLUTION_ID(co->SSRSolutionID) 960 G_NO_OF_SATELLITES(nums) 961 co->Supplied[COBOFS_ORBIT] |= 1; 962 #ifdef BNC_DEBUG 963 fprintf(stderr, "epochTime %d ui %d mmi %d sats %d/%d rd %d ssrIod %d providerId %d solId %d\n", 964 co->EpochTime[s], co->UpdateInterval,mmi,co->NumberOfSat[s],nums, 965 co->SatRefDatum, co->SSRIOD, co->SSRProviderID, co->SSRSolutionID); 966 #endif 967 for (i = 0; i < nums; ++i) { 968 switch (s) { 969 case CLOCKORBIT_SATGPS: 970 case CLOCKORBIT_SATGALILEO: 971 case CLOCKORBIT_SATSBAS: 972 case CLOCKORBIT_SATBDS: 973 G_GPS_SATELLITE_ID(id) 974 break; 975 case CLOCKORBIT_SATQZSS: 976 G_QZSS_SATELLITE_ID(id) 977 break; 978 case CLOCKORBIT_SATGLONASS: 979 G_GLONASS_SATELLITE_ID(id) 980 break; 981 } 982 for (pos = satoffset[s]; 983 pos < satoffset[s] + co->NumberOfSat[s] && co->Sat[pos].ID != id; 984 ++pos) 985 ; 986 if (pos >= satoffset[s + 1]) 987 return GCOBR_DATAMISMATCH; 988 else if (pos == co->NumberOfSat[s] + satoffset[s]) 989 ++co->NumberOfSat[s]; 990 co->Sat[pos].ID = id; 991 992 switch (s) { 993 case CLOCKORBIT_SATGPS: 994 case CLOCKORBIT_SATQZSS: 995 G_GPS_IODE(co->Sat[pos].IOD) 996 break; 997 case CLOCKORBIT_SATGLONASS: 998 G_GLONASS_IOD(co->Sat[pos].IOD) 999 break; 1000 case CLOCKORBIT_SATGALILEO: 1001 G_GALILEO_IOD(co->Sat[pos].IOD) 1002 break; 1003 case CLOCKORBIT_SATSBAS: 1004 G_SBAS_T0MOD(co->Sat[pos].toe) 1005 G_SBAS_IODCRC(co->Sat[pos].IOD) 1006 break; 1007 case CLOCKORBIT_SATBDS: 1008 G_BDS_TOEMOD(co->Sat[pos].toe) 1009 G_BDS_IOD(co->Sat[pos].IOD) 1010 break; 1011 } 1012 G_DELTA_RADIAL(co->Sat[pos].Orbit.DeltaRadial) 1013 G_DELTA_ALONG_TRACK(co->Sat[pos].Orbit.DeltaAlongTrack) 1014 G_DELTA_CROSS_TRACK(co->Sat[pos].Orbit.DeltaCrossTrack) 1015 G_DELTA_DOT_RADIAL(co->Sat[pos].Orbit.DotDeltaRadial) 1016 G_DELTA_DOT_ALONG_TRACK(co->Sat[pos].Orbit.DotDeltaAlongTrack) 1017 G_DELTA_DOT_CROSS_TRACK(co->Sat[pos].Orbit.DotDeltaCrossTrack) 1018 #ifdef BNC_DEBUG 1019 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", 1020 co->Sat[pos].ID,co->Sat[pos].IOD,co->Sat[pos].Orbit.DeltaRadial, 1021 co->Sat[pos].Orbit.DeltaAlongTrack,co->Sat[pos].Orbit.DeltaCrossTrack, 1022 co->Sat[pos].Orbit.DotDeltaRadial, 1023 co->Sat[pos].Orbit.DotDeltaAlongTrack, 1024 co->Sat[pos].Orbit.DotDeltaCrossTrack); 1025 #endif 997 1026 } 998 G_DELTA_RADIAL(co->Sat[pos].Orbit.DeltaRadial) 999 G_DELTA_ALONG_TRACK(co->Sat[pos].Orbit.DeltaAlongTrack) 1000 G_DELTA_CROSS_TRACK(co->Sat[pos].Orbit.DeltaCrossTrack) 1001 G_DELTA_DOT_RADIAL(co->Sat[pos].Orbit.DotDeltaRadial) 1002 G_DELTA_DOT_ALONG_TRACK(co->Sat[pos].Orbit.DotDeltaAlongTrack) 1003 G_DELTA_DOT_CROSS_TRACK(co->Sat[pos].Orbit.DotDeltaCrossTrack) 1004 #ifdef DEBUG 1005 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", 1006 co->Sat[pos].ID,co->Sat[pos].IOD,co->Sat[pos].Orbit.DeltaRadial, 1007 co->Sat[pos].Orbit.DeltaAlongTrack,co->Sat[pos].Orbit.DeltaCrossTrack, 1008 co->Sat[pos].Orbit.DotDeltaRadial, 1009 co->Sat[pos].Orbit.DotDeltaAlongTrack, 1010 co->Sat[pos].Orbit.DotDeltaCrossTrack); 1011 #endif 1012 } 1013 break; 1014 case COBOFS_CLOCK: 1015 if(!co) return GCOBR_NOCLOCKORBITPARAMETER; 1016 co->messageType = type; 1017 switch(s) 1018 { 1019 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO: 1020 case CLOCKORBIT_SATQZSS: case CLOCKORBIT_SATSBAS: 1021 case CLOCKORBIT_SATBDS: 1022 G_GPS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s]) 1023 break; 1024 case CLOCKORBIT_SATGLONASS: 1025 G_GLONASS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s]) 1026 break; 1027 } 1028 G_SSR_UPDATE_INTERVAL(co->UpdateInterval) 1029 G_MULTIPLE_MESSAGE_INDICATOR(mmi) 1030 G_SSR_IOD(co->SSRIOD) 1031 G_SSR_PROVIDER_ID(co->SSRProviderID) 1032 G_SSR_SOLUTION_ID(co->SSRSolutionID) 1033 G_NO_OF_SATELLITES(nums) 1034 co->Supplied[COBOFS_CLOCK] |= 1; 1035 #ifdef DEBUG 1036 fprintf(stderr, "epochtime %d ui %d mmi %d sats %d/%d\n",co->EpochTime[s], 1037 co->UpdateInterval,mmi,co->NumberOfSat[s],nums); 1038 #endif 1039 for(i = 0; i < nums; ++i) 1040 { 1041 switch(s) 1042 { 1043 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO: 1044 case CLOCKORBIT_SATSBAS: case CLOCKORBIT_SATBDS: 1045 G_GPS_SATELLITE_ID(id) 1046 break; 1047 case CLOCKORBIT_SATQZSS: 1048 G_QZSS_SATELLITE_ID(id) 1049 break; 1050 case CLOCKORBIT_SATGLONASS: 1051 G_GLONASS_SATELLITE_ID(id) 1052 break; 1027 break; 1028 case COBOFS_CLOCK: 1029 if (!co) 1030 return GCOBR_NOCLOCKORBITPARAMETER; 1031 co->messageType = type; 1032 switch (s) { 1033 case CLOCKORBIT_SATGPS: 1034 case CLOCKORBIT_SATGALILEO: 1035 case CLOCKORBIT_SATQZSS: 1036 case CLOCKORBIT_SATSBAS: 1037 case CLOCKORBIT_SATBDS: 1038 G_GPS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s]) 1039 break; 1040 case CLOCKORBIT_SATGLONASS: 1041 G_GLONASS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s]) 1042 break; 1053 1043 } 1054 for(pos = satoffset[s]; pos < satoffset[s]+co->NumberOfSat[s] && co->Sat[pos].ID != id; ++pos) 1055 ; 1056 if(pos >= satoffset[s+1]) return GCOBR_DATAMISMATCH; 1057 else if(pos == co->NumberOfSat[s] + satoffset[s]) ++co->NumberOfSat[s]; 1058 co->Sat[pos].ID = id; 1059 1060 G_DELTA_CLOCK_C0(co->Sat[pos].Clock.DeltaA0) 1061 G_DELTA_CLOCK_C1(co->Sat[pos].Clock.DeltaA1) 1062 G_DELTA_CLOCK_C2(co->Sat[pos].Clock.DeltaA2) 1063 #ifdef DEBUG 1064 fprintf(stderr, "id %2d c0 %8.3f c1 %8.3f c2 %8.3f\n", 1065 co->Sat[pos].ID, co->Sat[pos].Clock.DeltaA0, co->Sat[pos].Clock.DeltaA1, 1066 co->Sat[pos].Clock.DeltaA2); 1067 #endif 1068 } 1069 break; 1070 case COBOFS_COMBINED: 1071 if(!co) return GCOBR_NOCLOCKORBITPARAMETER; 1072 co->messageType = type; 1073 switch(s) 1074 { 1075 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO: 1076 case CLOCKORBIT_SATQZSS: case CLOCKORBIT_SATSBAS: 1077 case CLOCKORBIT_SATBDS: 1078 G_GPS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s]) 1079 break; 1080 case CLOCKORBIT_SATGLONASS: 1081 G_GLONASS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s]) 1082 break; 1083 } 1084 G_SSR_UPDATE_INTERVAL(co->UpdateInterval) 1085 G_MULTIPLE_MESSAGE_INDICATOR(mmi) 1086 G_SATELLITE_REFERENCE_DATUM(co->SatRefDatum) 1087 G_SSR_IOD(co->SSRIOD) 1088 G_SSR_PROVIDER_ID(co->SSRProviderID) 1089 G_SSR_SOLUTION_ID(co->SSRSolutionID) 1090 G_NO_OF_SATELLITES(nums) 1091 co->Supplied[COBOFS_ORBIT] |= 1; 1092 co->Supplied[COBOFS_CLOCK] |= 1; 1093 for(i = 0; i < nums; ++i) 1094 { 1095 switch(s) 1096 { 1097 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO: 1098 case CLOCKORBIT_SATSBAS: case CLOCKORBIT_SATBDS: 1099 G_GPS_SATELLITE_ID(id) 1100 break; 1101 case CLOCKORBIT_SATQZSS: 1102 G_QZSS_SATELLITE_ID(id) 1103 break; 1104 case CLOCKORBIT_SATGLONASS: 1105 G_GLONASS_SATELLITE_ID(id) 1106 break; 1044 G_SSR_UPDATE_INTERVAL(co->UpdateInterval) 1045 G_MULTIPLE_MESSAGE_INDICATOR(mmi) 1046 G_SSR_IOD(co->SSRIOD) 1047 G_SSR_PROVIDER_ID(co->SSRProviderID) 1048 G_SSR_SOLUTION_ID(co->SSRSolutionID) 1049 G_NO_OF_SATELLITES(nums) 1050 co->Supplied[COBOFS_CLOCK] |= 1; 1051 #ifdef BNC_DEBUG 1052 fprintf(stderr, "epochTime %d ui %d mmi %d sats %d/%d ssrIod %d providerId %d solId %d\n", 1053 co->EpochTime[s], co->UpdateInterval,mmi,co->NumberOfSat[s],nums, 1054 co->SSRIOD, co->SSRProviderID, co->SSRSolutionID); 1055 #endif 1056 for (i = 0; i < nums; ++i) { 1057 switch (s) { 1058 case CLOCKORBIT_SATGPS: 1059 case CLOCKORBIT_SATGALILEO: 1060 case CLOCKORBIT_SATSBAS: 1061 case CLOCKORBIT_SATBDS: 1062 G_GPS_SATELLITE_ID(id) 1063 break; 1064 case CLOCKORBIT_SATQZSS: 1065 G_QZSS_SATELLITE_ID(id) 1066 break; 1067 case CLOCKORBIT_SATGLONASS: 1068 G_GLONASS_SATELLITE_ID(id) 1069 break; 1070 } 1071 for (pos = satoffset[s]; 1072 pos < satoffset[s] + co->NumberOfSat[s] && co->Sat[pos].ID != id; 1073 ++pos) 1074 ; 1075 if (pos >= satoffset[s + 1]) 1076 return GCOBR_DATAMISMATCH; 1077 else if (pos == co->NumberOfSat[s] + satoffset[s]) 1078 ++co->NumberOfSat[s]; 1079 co->Sat[pos].ID = id; 1080 1081 G_DELTA_CLOCK_C0(co->Sat[pos].Clock.DeltaA0) 1082 G_DELTA_CLOCK_C1(co->Sat[pos].Clock.DeltaA1) 1083 G_DELTA_CLOCK_C2(co->Sat[pos].Clock.DeltaA2) 1084 #ifdef BNC_DEBUG 1085 fprintf(stderr, "id %2d c0 %8.3f c1 %8.3f c2 %8.3f\n", 1086 co->Sat[pos].ID, co->Sat[pos].Clock.DeltaA0, co->Sat[pos].Clock.DeltaA1, 1087 co->Sat[pos].Clock.DeltaA2); 1088 #endif 1107 1089 } 1108 for(pos = satoffset[s]; pos < satoffset[s]+co->NumberOfSat[s] && co->Sat[pos].ID != id; ++pos) 1109 ; 1110 if(pos >= satoffset[s+1]) return GCOBR_DATAMISMATCH; 1111 else if(pos == co->NumberOfSat[s] + satoffset[s]) ++co->NumberOfSat[s]; 1112 co->Sat[pos].ID = id; 1113 1114 switch(s) 1115 { 1116 case CLOCKORBIT_SATGPS: 1117 case CLOCKORBIT_SATQZSS: 1118 G_GPS_IODE(co->Sat[pos].IOD) 1119 break; 1120 case CLOCKORBIT_SATGLONASS: 1121 G_GLONASS_IOD(co->Sat[pos].IOD) 1122 break; 1123 case CLOCKORBIT_SATGALILEO: 1124 G_GALILEO_IOD(co->Sat[pos].IOD) 1125 break; 1126 case CLOCKORBIT_SATSBAS: 1127 G_SBAS_T0MOD(co->Sat[pos].toe) 1128 G_SBAS_IODCRC(co->Sat[pos].IOD) 1129 break; 1130 case CLOCKORBIT_SATBDS: 1131 G_BDS_TOEMOD(co->Sat[pos].toe) 1132 G_BDS_IOD(co->Sat[pos].IOD) 1133 break; 1090 break; 1091 case COBOFS_COMBINED: 1092 if (!co) 1093 return GCOBR_NOCLOCKORBITPARAMETER; 1094 co->messageType = type; 1095 switch (s) { 1096 case CLOCKORBIT_SATGPS: 1097 case CLOCKORBIT_SATGALILEO: 1098 case CLOCKORBIT_SATQZSS: 1099 case CLOCKORBIT_SATSBAS: 1100 case CLOCKORBIT_SATBDS: 1101 G_GPS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s]) 1102 break; 1103 case CLOCKORBIT_SATGLONASS: 1104 G_GLONASS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s]) 1105 break; 1134 1106 } 1135 G_DELTA_RADIAL(co->Sat[pos].Orbit.DeltaRadial) 1136 G_DELTA_ALONG_TRACK(co->Sat[pos].Orbit.DeltaAlongTrack) 1137 G_DELTA_CROSS_TRACK(co->Sat[pos].Orbit.DeltaCrossTrack) 1138 G_DELTA_DOT_RADIAL(co->Sat[pos].Orbit.DotDeltaRadial) 1139 G_DELTA_DOT_ALONG_TRACK(co->Sat[pos].Orbit.DotDeltaAlongTrack) 1140 G_DELTA_DOT_CROSS_TRACK(co->Sat[pos].Orbit.DotDeltaCrossTrack) 1141 G_DELTA_CLOCK_C0(co->Sat[pos].Clock.DeltaA0) 1142 G_DELTA_CLOCK_C1(co->Sat[pos].Clock.DeltaA1) 1143 G_DELTA_CLOCK_C2(co->Sat[pos].Clock.DeltaA2) 1144 } 1145 break; 1146 case COBOFS_URA: 1147 if(!co) return GCOBR_NOCLOCKORBITPARAMETER; 1148 co->messageType = type; 1149 switch(s) 1150 { 1151 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO: 1152 case CLOCKORBIT_SATQZSS: case CLOCKORBIT_SATSBAS: 1153 case CLOCKORBIT_SATBDS: 1154 G_GPS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s]) 1155 break; 1156 case CLOCKORBIT_SATGLONASS: 1157 G_GLONASS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s]) 1158 break; 1159 } 1160 G_SSR_UPDATE_INTERVAL(co->UpdateInterval) 1161 G_MULTIPLE_MESSAGE_INDICATOR(mmi) 1162 G_SSR_IOD(co->SSRIOD) 1163 G_SSR_PROVIDER_ID(co->SSRProviderID) 1164 G_SSR_SOLUTION_ID(co->SSRSolutionID) 1165 G_NO_OF_SATELLITES(nums) 1166 co->Supplied[COBOFS_URA] |= 1; 1167 for(i = 0; i < nums; ++i) 1168 { 1169 switch(s) 1170 { 1171 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO: 1172 case CLOCKORBIT_SATSBAS: case CLOCKORBIT_SATBDS: 1173 G_GPS_SATELLITE_ID(id) 1174 break; 1175 case CLOCKORBIT_SATQZSS: 1176 G_QZSS_SATELLITE_ID(id) 1177 break; 1178 case CLOCKORBIT_SATGLONASS: 1179 G_GLONASS_SATELLITE_ID(id) 1180 break; 1107 G_SSR_UPDATE_INTERVAL(co->UpdateInterval) 1108 G_MULTIPLE_MESSAGE_INDICATOR(mmi) 1109 G_SATELLITE_REFERENCE_DATUM(co->SatRefDatum) 1110 G_SSR_IOD(co->SSRIOD) 1111 G_SSR_PROVIDER_ID(co->SSRProviderID) 1112 G_SSR_SOLUTION_ID(co->SSRSolutionID) 1113 G_NO_OF_SATELLITES(nums) 1114 co->Supplied[COBOFS_ORBIT] |= 1; 1115 co->Supplied[COBOFS_CLOCK] |= 1; 1116 #ifdef BNC_DEBUG 1117 fprintf(stderr, "epochTime %d ui %d mmi %d sats %d/%d rd %d ssrIod %d providerId %d solId %d\n", 1118 co->EpochTime[s], co->UpdateInterval,mmi,co->NumberOfSat[s],nums, 1119 co->SatRefDatum, co->SSRIOD, co->SSRProviderID, co->SSRSolutionID); 1120 #endif 1121 for (i = 0; i < nums; ++i) { 1122 switch (s) { 1123 case CLOCKORBIT_SATGPS: 1124 case CLOCKORBIT_SATGALILEO: 1125 case CLOCKORBIT_SATSBAS: 1126 case CLOCKORBIT_SATBDS: 1127 G_GPS_SATELLITE_ID(id) 1128 break; 1129 case CLOCKORBIT_SATQZSS: 1130 G_QZSS_SATELLITE_ID(id) 1131 break; 1132 case CLOCKORBIT_SATGLONASS: 1133 G_GLONASS_SATELLITE_ID(id) 1134 break; 1135 } 1136 for (pos = satoffset[s]; 1137 pos < satoffset[s] + co->NumberOfSat[s] && co->Sat[pos].ID != id; 1138 ++pos) 1139 ; 1140 if (pos >= satoffset[s + 1]) 1141 return GCOBR_DATAMISMATCH; 1142 else if (pos == co->NumberOfSat[s] + satoffset[s]) 1143 ++co->NumberOfSat[s]; 1144 co->Sat[pos].ID = id; 1145 1146 switch (s) { 1147 case CLOCKORBIT_SATGPS: 1148 case CLOCKORBIT_SATQZSS: 1149 G_GPS_IODE(co->Sat[pos].IOD) 1150 break; 1151 case CLOCKORBIT_SATGLONASS: 1152 G_GLONASS_IOD(co->Sat[pos].IOD) 1153 break; 1154 case CLOCKORBIT_SATGALILEO: 1155 G_GALILEO_IOD(co->Sat[pos].IOD) 1156 break; 1157 case CLOCKORBIT_SATSBAS: 1158 G_SBAS_T0MOD(co->Sat[pos].toe) 1159 G_SBAS_IODCRC(co->Sat[pos].IOD) 1160 break; 1161 case CLOCKORBIT_SATBDS: 1162 G_BDS_TOEMOD(co->Sat[pos].toe) 1163 G_BDS_IOD(co->Sat[pos].IOD) 1164 break; 1165 } 1166 G_DELTA_RADIAL(co->Sat[pos].Orbit.DeltaRadial) 1167 G_DELTA_ALONG_TRACK(co->Sat[pos].Orbit.DeltaAlongTrack) 1168 G_DELTA_CROSS_TRACK(co->Sat[pos].Orbit.DeltaCrossTrack) 1169 G_DELTA_DOT_RADIAL(co->Sat[pos].Orbit.DotDeltaRadial) 1170 G_DELTA_DOT_ALONG_TRACK(co->Sat[pos].Orbit.DotDeltaAlongTrack) 1171 G_DELTA_DOT_CROSS_TRACK(co->Sat[pos].Orbit.DotDeltaCrossTrack) 1172 G_DELTA_CLOCK_C0(co->Sat[pos].Clock.DeltaA0) 1173 G_DELTA_CLOCK_C1(co->Sat[pos].Clock.DeltaA1) 1174 G_DELTA_CLOCK_C2(co->Sat[pos].Clock.DeltaA2) 1175 #ifdef BNC_DEBUG 1176 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", 1177 co->Sat[pos].ID,co->Sat[pos].IOD,co->Sat[pos].Orbit.DeltaRadial, 1178 co->Sat[pos].Orbit.DeltaAlongTrack,co->Sat[pos].Orbit.DeltaCrossTrack, 1179 co->Sat[pos].Orbit.DotDeltaRadial, co->Sat[pos].Orbit.DotDeltaAlongTrack, 1180 co->Sat[pos].Orbit.DotDeltaCrossTrack, 1181 co->Sat[pos].Clock.DeltaA0, co->Sat[pos].Clock.DeltaA1, co->Sat[pos].Clock.DeltaA2); 1182 #endif 1181 1183 } 1182 for(pos = satoffset[s]; pos < satoffset[s]+co->NumberOfSat[s] && co->Sat[pos].ID != id; ++pos) 1183 ; 1184 if(pos >= satoffset[s+1]) return GCOBR_DATAMISMATCH; 1185 else if(pos == co->NumberOfSat[s] + satoffset[s]) ++co->NumberOfSat[s]; 1186 co->Sat[pos].ID = id; 1187 1188 G_SSR_URA(co->Sat[pos].UserRangeAccuracy) 1189 } 1190 break; 1191 case COBOFS_HR: 1192 if(!co) return GCOBR_NOCLOCKORBITPARAMETER; 1193 co->messageType = type; 1194 switch(s) 1195 { 1196 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO: 1197 case CLOCKORBIT_SATQZSS: case CLOCKORBIT_SATSBAS: 1198 case CLOCKORBIT_SATBDS: 1199 G_GPS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s]) 1200 break; 1201 case CLOCKORBIT_SATGLONASS: 1202 G_GLONASS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s]) 1203 break; 1204 } 1205 G_SSR_UPDATE_INTERVAL(co->UpdateInterval) 1206 G_MULTIPLE_MESSAGE_INDICATOR(mmi) 1207 G_SSR_IOD(co->SSRIOD) 1208 G_SSR_PROVIDER_ID(co->SSRProviderID) 1209 G_SSR_SOLUTION_ID(co->SSRSolutionID) 1210 G_NO_OF_SATELLITES(nums) 1211 co->Supplied[COBOFS_HR] |= 1; 1212 for(i = 0; i < nums; ++i) 1213 { 1214 switch(s) 1215 { 1216 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO: 1217 case CLOCKORBIT_SATSBAS: case CLOCKORBIT_SATBDS: 1218 G_GPS_SATELLITE_ID(id) 1219 break; 1220 case CLOCKORBIT_SATQZSS: 1221 G_QZSS_SATELLITE_ID(id) 1222 break; 1223 case CLOCKORBIT_SATGLONASS: 1224 G_GLONASS_SATELLITE_ID(id) 1225 break; 1184 break; 1185 case COBOFS_URA: 1186 if (!co) 1187 return GCOBR_NOCLOCKORBITPARAMETER; 1188 co->messageType = type; 1189 switch (s) { 1190 case CLOCKORBIT_SATGPS: 1191 case CLOCKORBIT_SATGALILEO: 1192 case CLOCKORBIT_SATQZSS: 1193 case CLOCKORBIT_SATSBAS: 1194 case CLOCKORBIT_SATBDS: 1195 G_GPS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s]) 1196 break; 1197 case CLOCKORBIT_SATGLONASS: 1198 G_GLONASS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s]) 1199 break; 1226 1200 } 1227 for(pos = satoffset[s]; pos < satoffset[s]+co->NumberOfSat[s] && co->Sat[pos].ID != id; ++pos) 1228 ; 1229 if(pos >= satoffset[s+1]) return GCOBR_DATAMISMATCH; 1230 else if(pos == co->NumberOfSat[s] + satoffset[s]) ++co->NumberOfSat[s]; 1231 co->Sat[pos].ID = id; 1232 1233 G_HR_CLOCK_CORRECTION(co->Sat[pos].hrclock) 1234 } 1235 break; 1236 case COBOFS_BIAS: 1237 if(!b) return GCOBR_NOCODEBIASPARAMETER; 1238 b->messageType = type; 1239 switch(s) 1240 { 1241 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO: 1242 case CLOCKORBIT_SATQZSS: case CLOCKORBIT_SATSBAS: 1243 case CLOCKORBIT_SATBDS: 1244 G_GPS_EPOCH_TIME(b->EpochTime[s], b->NumberOfSat[s]) 1245 break; 1246 case CLOCKORBIT_SATGLONASS: 1247 G_GLONASS_EPOCH_TIME(b->EpochTime[s], b->NumberOfSat[s]) 1248 break; 1249 } 1250 G_SSR_UPDATE_INTERVAL(b->UpdateInterval) 1251 G_MULTIPLE_MESSAGE_INDICATOR(mmi) 1252 G_SSR_IOD(b->SSRIOD) 1253 G_SSR_PROVIDER_ID(b->SSRProviderID) 1254 G_SSR_SOLUTION_ID(b->SSRSolutionID) 1255 G_NO_OF_SATELLITES(nums) 1256 for(i = 0; i < nums; ++i) 1257 { 1258 switch(s) 1259 { 1260 case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO: 1261 case CLOCKORBIT_SATSBAS: case CLOCKORBIT_SATBDS: 1262 G_GPS_SATELLITE_ID(id) 1263 break; 1264 case CLOCKORBIT_SATQZSS: 1265 G_QZSS_SATELLITE_ID(id) 1266 break; 1267 case CLOCKORBIT_SATGLONASS: 1268 G_GLONASS_SATELLITE_ID(id) 1269 break; 1201 G_SSR_UPDATE_INTERVAL(co->UpdateInterval) 1202 G_MULTIPLE_MESSAGE_INDICATOR(mmi) 1203 G_SSR_IOD(co->SSRIOD) 1204 G_SSR_PROVIDER_ID(co->SSRProviderID) 1205 G_SSR_SOLUTION_ID(co->SSRSolutionID) 1206 G_NO_OF_SATELLITES(nums) 1207 co->Supplied[COBOFS_URA] |= 1; 1208 #ifdef BNC_DEBUG 1209 fprintf(stderr, "epochTime %d ui %d mmi %d sats %d/%d ssrIod %d providerId %d solId %d\n", 1210 co->EpochTime[s], co->UpdateInterval,mmi,co->NumberOfSat[s],nums, 1211 co->SSRIOD, co->SSRProviderID, co->SSRSolutionID); 1212 #endif 1213 for (i = 0; i < nums; ++i) { 1214 switch (s) { 1215 case CLOCKORBIT_SATGPS: 1216 case CLOCKORBIT_SATGALILEO: 1217 case CLOCKORBIT_SATSBAS: 1218 case CLOCKORBIT_SATBDS: 1219 G_GPS_SATELLITE_ID(id) 1220 break; 1221 case CLOCKORBIT_SATQZSS: 1222 G_QZSS_SATELLITE_ID(id) 1223 break; 1224 case CLOCKORBIT_SATGLONASS: 1225 G_GLONASS_SATELLITE_ID(id) 1226 break; 1227 } 1228 for (pos = satoffset[s]; 1229 pos < satoffset[s] + co->NumberOfSat[s] && co->Sat[pos].ID != id; 1230 ++pos) 1231 ; 1232 if (pos >= satoffset[s + 1]) 1233 return GCOBR_DATAMISMATCH; 1234 else if (pos == co->NumberOfSat[s] + satoffset[s]) 1235 ++co->NumberOfSat[s]; 1236 co->Sat[pos].ID = id; 1237 G_SSR_URA(co->Sat[pos].UserRangeAccuracy) 1238 #ifdef BNC_DEBUG 1239 fprintf(stderr, "id %2d ura %8.3f \n", 1240 co->Sat[pos].ID, co->Sat[pos].UserRangeAccuracy); 1241 #endif 1270 1242 } 1271 for(pos = satoffset[s]; pos < satoffset[s]+b->NumberOfSat[s] && b->Sat[pos].ID != id; ++pos) 1272 ; 1273 if(pos >= satoffset[s+1]) return GCOBR_DATAMISMATCH; 1274 else if(pos == b->NumberOfSat[s] + satoffset[s]) ++b->NumberOfSat[s]; 1275 b->Sat[pos].ID = id; 1276 1277 G_NO_OF_CODE_BIASES(b->Sat[pos].NumberOfCodeBiases) 1278 for(j = 0; j < b->Sat[pos].NumberOfCodeBiases; ++j) 1279 { 1280 G_SIGNAL_IDENTIFIER(b->Sat[pos].Biases[j].Type) 1281 G_CODE_BIAS(b->Sat[pos].Biases[j].Bias) 1243 break; 1244 case COBOFS_HR: 1245 if (!co) 1246 return GCOBR_NOCLOCKORBITPARAMETER; 1247 co->messageType = type; 1248 switch (s) { 1249 case CLOCKORBIT_SATGPS: 1250 case CLOCKORBIT_SATGALILEO: 1251 case CLOCKORBIT_SATQZSS: 1252 case CLOCKORBIT_SATSBAS: 1253 case CLOCKORBIT_SATBDS: 1254 G_GPS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s]) 1255 break; 1256 case CLOCKORBIT_SATGLONASS: 1257 G_GLONASS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s]) 1258 break; 1282 1259 } 1283 } 1284 break; 1285 default: 1286 continue; 1287 } 1288 #ifdef COR_LATENCY 1289 if(s == CLOCKORBIT_SATGPS && type-corbase[s] != COBOFS_BIAS) 1290 { 1291 co->epochGPS[co->epochSize] = co->EpochTime[s]; 1292 if(co->epochSize < COR_LATENCYCOUNT) 1293 ++co->epochSize; 1294 } 1295 #endif 1296 #ifdef DEBUG 1297 for(type = 0; type < (int)size && (unsigned char)buffer[type] != 0xD3; ++type) 1298 numbits += 8; 1260 G_SSR_UPDATE_INTERVAL(co->UpdateInterval) 1261 G_MULTIPLE_MESSAGE_INDICATOR(mmi) 1262 G_SSR_IOD(co->SSRIOD) 1263 G_SSR_PROVIDER_ID(co->SSRProviderID) 1264 G_SSR_SOLUTION_ID(co->SSRSolutionID) 1265 G_NO_OF_SATELLITES(nums) 1266 co->Supplied[COBOFS_HR] |= 1; 1267 #ifdef BNC_DEBUG 1268 fprintf(stderr, "epochTime %d ui %d mmi %d sats %d/%d ssrIod %d providerId %d solId %d\n", 1269 co->EpochTime[s], co->UpdateInterval,mmi,co->NumberOfSat[s],nums, 1270 co->SSRIOD, co->SSRProviderID, co->SSRSolutionID); 1271 #endif 1272 for (i = 0; i < nums; ++i) { 1273 switch (s) { 1274 case CLOCKORBIT_SATGPS: 1275 case CLOCKORBIT_SATGALILEO: 1276 case CLOCKORBIT_SATSBAS: 1277 case CLOCKORBIT_SATBDS: 1278 G_GPS_SATELLITE_ID(id) 1279 break; 1280 case CLOCKORBIT_SATQZSS: 1281 G_QZSS_SATELLITE_ID(id) 1282 break; 1283 case CLOCKORBIT_SATGLONASS: 1284 G_GLONASS_SATELLITE_ID(id) 1285 break; 1286 } 1287 for (pos = satoffset[s]; 1288 pos < satoffset[s] + co->NumberOfSat[s] && co->Sat[pos].ID != id; 1289 ++pos) 1290 ; 1291 if (pos >= satoffset[s + 1]) 1292 return GCOBR_DATAMISMATCH; 1293 else if (pos == co->NumberOfSat[s] + satoffset[s]) 1294 ++co->NumberOfSat[s]; 1295 co->Sat[pos].ID = id; 1296 G_HR_CLOCK_CORRECTION(co->Sat[pos].hrclock) 1297 #ifdef BNC_DEBUG 1298 fprintf(stderr, "id %2d hrClock %8.3f \n", 1299 co->Sat[pos].ID, co->Sat[pos].hrclock); 1300 #endif 1301 } 1302 break; 1303 case COBOFS_CBIAS: 1304 if (!b) 1305 return GCOBR_NOCODEBIASPARAMETER; 1306 b->messageType = type; 1307 switch (s) { 1308 case CLOCKORBIT_SATGPS: 1309 case CLOCKORBIT_SATGALILEO: 1310 case CLOCKORBIT_SATQZSS: 1311 case CLOCKORBIT_SATSBAS: 1312 case CLOCKORBIT_SATBDS: 1313 G_GPS_EPOCH_TIME(b->EpochTime[s], b->NumberOfSat[s]) 1314 break; 1315 case CLOCKORBIT_SATGLONASS: 1316 G_GLONASS_EPOCH_TIME(b->EpochTime[s], b->NumberOfSat[s]) 1317 break; 1318 } 1319 G_SSR_UPDATE_INTERVAL(b->UpdateInterval) 1320 G_MULTIPLE_MESSAGE_INDICATOR(mmi) 1321 G_SSR_IOD(b->SSRIOD) 1322 G_SSR_PROVIDER_ID(b->SSRProviderID) 1323 G_SSR_SOLUTION_ID(b->SSRSolutionID) 1324 G_NO_OF_SATELLITES(nums) 1325 #ifdef BNC_DEBUG 1326 fprintf(stderr, "epochTime %d ui %d mmi %d sats %d/%d ssrIod %d providerId %d solId %d\n", 1327 b->EpochTime[s], b->UpdateInterval,mmi,b->NumberOfSat[s],nums, 1328 b->SSRIOD, b->SSRProviderID, b->SSRSolutionID); 1329 #endif 1330 for (i = 0; i < nums; ++i) { 1331 switch (s) { 1332 case CLOCKORBIT_SATGPS: 1333 case CLOCKORBIT_SATGALILEO: 1334 case CLOCKORBIT_SATSBAS: 1335 case CLOCKORBIT_SATBDS: 1336 G_GPS_SATELLITE_ID(id) 1337 break; 1338 case CLOCKORBIT_SATQZSS: 1339 G_QZSS_SATELLITE_ID(id) 1340 break; 1341 case CLOCKORBIT_SATGLONASS: 1342 G_GLONASS_SATELLITE_ID(id) 1343 break; 1344 } 1345 for (pos = satoffset[s]; 1346 pos < satoffset[s] + b->NumberOfSat[s] && b->Sat[pos].ID != id; 1347 ++pos) 1348 ; 1349 if (pos >= satoffset[s + 1]) 1350 return GCOBR_DATAMISMATCH; 1351 else if (pos == b->NumberOfSat[s] + satoffset[s]) 1352 ++b->NumberOfSat[s]; 1353 b->Sat[pos].ID = id; 1354 G_NO_OF_CODE_BIASES(b->Sat[pos].NumberOfCodeBiases) 1355 #ifdef BNC_DEBUG 1356 fprintf(stderr, "id %2d #%d ", 1357 b->Sat[pos].ID, b->Sat[pos].NumberOfCodeBiases); 1358 #endif 1359 for (j = 0; j < b->Sat[pos].NumberOfCodeBiases; ++j) { 1360 G_SIGNAL_IDENTIFIER(b->Sat[pos].Biases[j].Type) 1361 G_CODE_BIAS(b->Sat[pos].Biases[j].Bias) 1362 #ifdef BNC_DEBUG 1363 fprintf(stderr, "t%02d b %8.2f ", 1364 b->Sat[pos].Biases[j].Type, b->Sat[pos].Biases[j].Bias); 1365 #endif 1366 } 1367 #ifdef BNC_DEBUG 1368 fprintf(stderr, "\n"); 1369 #endif 1370 } 1371 break; 1372 default: 1373 continue; 1374 } 1375 #ifdef BNC_DEBUG 1376 for(type = 0; type < (unsigned int)size && (unsigned char)buffer[type] != 0xD3; ++type) 1377 numbits += 8; 1299 1378 fprintf(stderr, "numbits left %d\n",numbits); 1300 1379 #endif -
branches/BNC_2.12/src/RTCM3/clock_and_orbit/clock_orbit_rtcm.h
r8943 r8987 13 13 #include <string.h> 14 14 15 enum SatelliteReferenceDatum { DATUM_ITRF=0, DATUM_LOCAL=1 }; 15 16 17 18 19 20 enum SatelliteReferenceDatum { 21 DATUM_ITRF = 0, 22 DATUM_LOCAL = 1 23 }; 16 24 17 25 enum COR_BASE { 18 COBBASE_GPS = 1057,26 COBBASE_GPS = 1057, 19 27 COBBASE_GLONASS = 1063, 20 28 COBBASE_GALILEO = 1240, 21 COBBASE_QZSS = 1246, 22 COBBASE_SBAS = 1252, 23 COBBASE_BDS = 1258, 29 COBBASE_QZSS = 1246, 30 COBBASE_SBAS = 1252, 31 COBBASE_BDS = 1258, 32 COBBASE_NUM 24 33 }; 25 34 … … 27 36 COBOFS_ORBIT = 0, 28 37 COBOFS_CLOCK, 29 COBOFS_ BIAS,38 COBOFS_CBIAS, 30 39 COBOFS_COMBINED, 31 40 COBOFS_URA, … … 35 44 36 45 enum ClockOrbitType { 37 COTYPE_GPSORBIT = COBBASE_GPS+ COBOFS_ORBIT,46 COTYPE_GPSORBIT = COBBASE_GPS + COBOFS_ORBIT, 38 47 COTYPE_GPSCLOCK, 39 COTYPE_GPSCOMBINED = COBBASE_GPS+ COBOFS_COMBINED,48 COTYPE_GPSCOMBINED = COBBASE_GPS + COBOFS_COMBINED, 40 49 COTYPE_GPSURA, 41 50 COTYPE_GPSHR, 42 51 43 COTYPE_GLONASSORBIT = COBBASE_GLONASS + COBOFS_ORBIT,52 COTYPE_GLONASSORBIT = COBBASE_GLONASS + COBOFS_ORBIT, 44 53 COTYPE_GLONASSCLOCK, 45 54 COTYPE_GLONASSCOMBINED = COBBASE_GLONASS + COBOFS_COMBINED, … … 47 56 COTYPE_GLONASSHR, 48 57 49 COTYPE_GALILEOORBIT = COBBASE_GALILEO + COBOFS_ORBIT,58 COTYPE_GALILEOORBIT = COBBASE_GALILEO + COBOFS_ORBIT, 50 59 COTYPE_GALILEOCLOCK, 51 60 COTYPE_GALILEOCOMBINED = COBBASE_GALILEO + COBOFS_COMBINED, … … 53 62 COTYPE_GALILEOHR, 54 63 55 COTYPE_QZSSORBIT = COBBASE_QZSS+ COBOFS_ORBIT,64 COTYPE_QZSSORBIT = COBBASE_QZSS + COBOFS_ORBIT, 56 65 COTYPE_QZSSCLOCK, 57 COTYPE_QZSSCOMBINED = COBBASE_QZSS+ COBOFS_COMBINED,66 COTYPE_QZSSCOMBINED = COBBASE_QZSS + COBOFS_COMBINED, 58 67 COTYPE_QZSSURA, 59 68 COTYPE_QZSSHR, 60 69 61 COTYPE_SBASORBIT = COBBASE_SBAS+ COBOFS_ORBIT,70 COTYPE_SBASORBIT = COBBASE_SBAS + COBOFS_ORBIT, 62 71 COTYPE_SBASCLOCK, 63 COTYPE_SBASCOMBINED = COBBASE_SBAS+ COBOFS_COMBINED,72 COTYPE_SBASCOMBINED = COBBASE_SBAS + COBOFS_COMBINED, 64 73 COTYPE_SBASURA, 65 74 COTYPE_SBASHR, 66 75 67 COTYPE_BDSORBIT = COBBASE_BDS+ COBOFS_ORBIT,76 COTYPE_BDSORBIT = COBBASE_BDS + COBOFS_ORBIT, 68 77 COTYPE_BDSCLOCK, 69 COTYPE_BDSCOMBINED = COBBASE_BDS + COBOFS_COMBINED,78 COTYPE_BDSCOMBINED = COBBASE_BDS + COBOFS_COMBINED, 70 79 COTYPE_BDSURA, 71 80 COTYPE_BDSHR, … … 75 84 76 85 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_SBAS + COBOFS_BIAS,82 BTYPE_BDS = COBBASE_BDS + COBOFS_BIAS,83 BTYPE_AUTO= 084 }; 85 86 enum PhaseBiasType 87 PBTYPE_BASE = 1265,88 PBTYPE_GPS = PBTYPE_BASE,86 CBTYPE_GPS = COBBASE_GPS + COBOFS_CBIAS, 87 CBTYPE_GLONASS = COBBASE_GLONASS + COBOFS_CBIAS, 88 CBTYPE_GALILEO = COBBASE_GALILEO + COBOFS_CBIAS, 89 CBTYPE_QZSS = COBBASE_QZSS + COBOFS_CBIAS, 90 CBTYPE_SBAS = COBBASE_SBAS + COBOFS_CBIAS, 91 CBTYPE_BDS = COBBASE_BDS + COBOFS_CBIAS, 92 CBTYPE_AUTO = 0 93 }; 94 95 enum PhaseBiasType{ 96 PBTYPE_BASE = 1265, 97 PBTYPE_GPS = PBTYPE_BASE, 89 98 PBTYPE_GLONASS, 90 99 PBTYPE_GALILEO, … … 92 101 PBTYPE_SBAS, 93 102 PBTYPE_BDS, 94 PBTYPE_AUTO = 0103 PBTYPE_AUTO = 0 95 104 }; 96 105 … … 102 111 for these systems to save space */ 103 112 enum COR_CONSTANTS { 104 CLOCKORBIT_BUFFERSIZE =8192,105 CLOCKORBIT_NUMGPS =32,106 CLOCKORBIT_NUMGLONASS =26,107 CLOCKORBIT_NUMGALILEO =36,108 CLOCKORBIT_NUMQZSS =10,109 CLOCKORBIT_NUMSBAS =38,110 CLOCKORBIT_NUMBDS =65,111 CLOCKORBIT_NUMBIAS =100,112 CLOCKORBIT_NUMIONOLAYERS =4,113 CLOCKORBIT_MAXIONOORDER =16,114 CLOCKORBIT_MAXIONODEGREE =16113 CLOCKORBIT_BUFFERSIZE = 8192, 114 CLOCKORBIT_NUMGPS = 32, 115 CLOCKORBIT_NUMGLONASS = 26, 116 CLOCKORBIT_NUMGALILEO = 36, 117 CLOCKORBIT_NUMQZSS = 10, 118 CLOCKORBIT_NUMSBAS = 38, 119 CLOCKORBIT_NUMBDS = 65, 120 CLOCKORBIT_NUMBIAS = 100, 121 CLOCKORBIT_NUMIONOLAYERS = 4, 122 CLOCKORBIT_MAXIONOORDER = 16, 123 CLOCKORBIT_MAXIONODEGREE = 16 115 124 }; 116 125 … … 126 135 127 136 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 137 CLOCKORBIT_OFFSETGPS = 0, 138 CLOCKORBIT_OFFSETGLONASS = CLOCKORBIT_NUMGPS, 139 CLOCKORBIT_OFFSETGALILEO = CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS, 140 CLOCKORBIT_OFFSETQZSS = CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS + CLOCKORBIT_NUMGALILEO, 141 CLOCKORBIT_OFFSETSBAS = CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS + CLOCKORBIT_NUMGALILEO 142 + CLOCKORBIT_NUMQZSS, 143 CLOCKORBIT_OFFSETBDS = CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS + CLOCKORBIT_NUMGALILEO 144 + CLOCKORBIT_NUMQZSS + CLOCKORBIT_NUMSBAS, 145 CLOCKORBIT_COUNTSAT = CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS + CLOCKORBIT_NUMGALILEO 146 + CLOCKORBIT_NUMQZSS + CLOCKORBIT_NUMSBAS + CLOCKORBIT_NUMBDS 140 147 }; 141 148 … … 220 227 CODETYPE_SBAS_L5_Q = 2, 221 228 CODETYPE_SBAS_L5_IQ = 3, 229 222 230 CODETYPE_BDS_B1_I = 0, 223 231 CODETYPE_BDS_B1_Q = 1, … … 234 242 CODETYPE_BDS_B2a_D = 12, 235 243 CODETYPE_BDS_B2a_P = 13, 236 CODETYPE_BDS_B2a_DP = 14, 237 238 CODETYPE_IRNSS_S_SPS = 8, 239 CODETYPE_IRNSS_L5_SPS = 22 244 CODETYPE_BDS_B2a_DP = 14 240 245 }; 241 246 … … 247 252 xxx->Sat[CLOCKORBIT_OFFSETGPS]. */ 248 253 249 #ifdef COR_LEGACY 250 /* old names */ 251 #define NumberOfGPSSat NumberOfSat[CLOCKORBIT_SATGPS] 252 #define NumberOfGLONASSSat NumberOfSat[CLOCKORBIT_SATGLONASS] 253 #define GPSEpochTime EpochTime[CLOCKORBIT_SATGPS] /* 0 .. 604799 s */ 254 #define GLONASSEpochTime EpochTime[CLOCKORBIT_SATGLONASS] /* 0 .. 86399 s (86400 for leap second) */ 255 #define ClockDataSupplied Supplied[COBOFS_CLOCK] 256 #define HRDataSupplied Supplied[COBOFS_HR] 257 #define OrbitDataSupplied Supplied[COBOFS_ORBIT] 258 #define URADataSupplied Supplied[COBOFS_URA] 259 #define GetClockOrbitBias(a,b,c,d,e) GetSSR(a,b,0,0,c,d,e) 260 #endif /* COR_LEGACY */ 261 262 /* latency check code, disabled by default */ 263 #ifdef COR_LATENCY 264 #define COR_LATENCYCOUNT 100 265 #endif 266 267 struct ClockOrbit 268 { 254 struct ClockOrbit { 269 255 enum ClockOrbitType messageType; 270 256 unsigned int EpochTime[CLOCKORBIT_SATNUM]; /* 0 .. system specific maximum */ 271 257 unsigned int NumberOfSat[CLOCKORBIT_SATNUM]; /* 0 .. CLOCKORBIT_NUM... */ 272 273 258 unsigned int Supplied[COBOFS_NUM]; /* boolean */ 274 #ifdef COR_LATENCY275 unsigned int epochGPS[COR_LATENCYCOUNT+1]; /* Weber, for latency */276 unsigned int epochSize; /* Weber, for latency */277 #endif278 259 unsigned int SSRIOD; 279 260 unsigned int SSRProviderID; … … 287 268 double UserRangeAccuracy; /* accuracy values in [m] */ 288 269 double hrclock; 289 struct OrbitPart 290 { 270 struct OrbitPart { 291 271 double DeltaRadial; /* m */ 292 272 double DeltaAlongTrack; /* m */ … … 296 276 double DotDeltaCrossTrack; /* m/s */ 297 277 } Orbit; 298 struct ClockPart 299 { 278 struct ClockPart { 300 279 double DeltaA0; /* m */ 301 280 double DeltaA1; /* m/s */ … … 305 284 }; 306 285 307 struct CodeBias 308 { 286 struct CodeBias { 309 287 enum CodeBiasType messageType; 310 288 unsigned int EpochTime[CLOCKORBIT_SATNUM]; /* 0 .. system specific maximum */ … … 314 292 unsigned int SSRProviderID; 315 293 unsigned int SSRSolutionID; 316 struct BiasSat 317 { 294 struct BiasSat { 318 295 unsigned int ID; /* all */ 319 296 unsigned int NumberOfCodeBiases; 320 struct CodeBiasEntry 321 { 297 struct CodeBiasEntry { 322 298 enum CodeType Type; 323 299 float Bias; /* m */ … … 326 302 }; 327 303 328 struct PhaseBias 329 { 304 struct PhaseBias { 330 305 enum PhaseBiasType messageType; 331 306 unsigned int EpochTime[CLOCKORBIT_SATNUM]; /* 0 .. system specific maximum */ … … 337 312 unsigned int DispersiveBiasConsistencyIndicator; 338 313 unsigned int MWConsistencyIndicator; 339 struct PhaseBiasSat 340 { 314 struct PhaseBiasSat { 341 315 unsigned int ID; /* all */ 342 316 unsigned int NumberOfPhaseBiases; 343 317 double YawAngle; /* radiant */ 344 318 double YawRate; /* radiant/s */ 345 struct PhaseBiasEntry 346 { 319 struct PhaseBiasEntry { 347 320 enum CodeType Type; 348 321 unsigned int SignalIntegerIndicator; … … 354 327 }; 355 328 356 struct VTEC 357 { 329 struct VTEC { 358 330 unsigned int EpochTime; /* GPS */ 359 331 unsigned int UpdateInterval; … … 384 356 enum GCOB_RETURN { 385 357 /* all well */ 386 GCOBR_MESSAGEFOLLOWS =1,387 GCOBR_OK =0,358 GCOBR_MESSAGEFOLLOWS = 1, 359 GCOBR_OK = 0, 388 360 /* unknown data, a warning */ 389 GCOBR_UNKNOWNTYPE = -1,390 GCOBR_UNKNOWNDATA = -2,391 GCOBR_CRCMISMATCH = -3,392 GCOBR_SHORTMESSAGE = -4,361 GCOBR_UNKNOWNTYPE = -1, 362 GCOBR_UNKNOWNDATA = -2, 363 GCOBR_CRCMISMATCH = -3, 364 GCOBR_SHORTMESSAGE = -4, 393 365 /* failed to do the work */ 394 366 GCOBR_NOCLOCKORBITPARAMETER = -10, 395 GCOBR_NOCODEBIASPARAMETER = -11,396 GCOBR_NOPHASEBIASPARAMETER = -12,397 GCOBR_NOVTECPARAMETER = -13,367 GCOBR_NOCODEBIASPARAMETER = -11, 368 GCOBR_NOPHASEBIASPARAMETER = -12, 369 GCOBR_NOVTECPARAMETER = -13, 398 370 /* data mismatch - data in storage does not match new data */ 399 GCOBR_TIMEMISMATCH = -20,400 GCOBR_DATAMISMATCH = -21,371 GCOBR_TIMEMISMATCH = -20, 372 GCOBR_DATAMISMATCH = -21, 401 373 /* not enough data - can decode the block completely */ 402 GCOBR_SHORTBUFFER = -30,403 GCOBR_MESSAGEEXCEEDSBUFFER = -31};374 GCOBR_SHORTBUFFER = -30, 375 GCOBR_MESSAGEEXCEEDSBUFFER = -31}; 404 376 405 377 /* NOTE: When an error message has been emitted, the output structures may have been modified. Make a copy of the previous variant before calling the
Note:
See TracChangeset
for help on using the changeset viewer.