Changeset 6703 in ntrip for trunk/BNC/src
- Timestamp:
- Mar 23, 2015, 10:26:42 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/src/RTCM/RTCM2Decoder.cpp
r6443 r6703 66 66 } 67 67 68 69 68 // 70 69 t_irc RTCM2Decoder::getStaCrd(double& xx, double& yy, double& zz) { 71 if ( !_msg03.validMsg) {70 if (!_msg03.validMsg) { 72 71 return failure; 73 72 } 74 73 75 74 xx = _msg03.x + (_msg22.validMsg ? _msg22.dL1[0] : 0.0); 76 75 yy = _msg03.y + (_msg22.validMsg ? _msg22.dL1[1] : 0.0); … … 81 80 82 81 // 83 t_irc RTCM2Decoder::getStaCrd(double& xx, double& yy, double& zz, 84 double& dx1, double& dy1, double& dz1, 85 double& dx2, double& dy2, double& dz2) { 82 t_irc RTCM2Decoder::getStaCrd(double& xx, double& yy, double& zz, double& dx1, 83 double& dy1, double& dz1, double& dx2, double& dy2, double& dz2) { 86 84 xx = _msg03.x; 87 85 yy = _msg03.y; … … 99 97 } 100 98 101 102 99 // 103 100 t_irc RTCM2Decoder::Decode(char* buffer, int bufLen, vector<string>& errmsg) { … … 106 103 107 104 _buffer.append(buffer, bufLen); 108 int 105 int refWeek; 109 106 double refSecs; 110 107 currentGPSWeeks(refWeek, refSecs); 111 108 bool decoded = false; 112 109 113 while (true) {110 while (true) { 114 111 _PP.getPacket(_buffer); 115 112 if (!_PP.valid()) { … … 120 117 } 121 118 } 122 119 123 120 // Store message number 124 121 _typeList.push_back(_PP.ID()); 125 122 126 if ( _PP.ID()==18 || _PP.ID()==19 ) {123 if (_PP.ID() == 18 || _PP.ID() == 19) { 127 124 128 125 _ObsBlock.extract(_PP); … … 131 128 decoded = true; 132 129 133 int 130 int epochWeek; 134 131 double epochSecs; 135 132 _ObsBlock.resolveEpoch(refWeek, refSecs, epochWeek, epochSecs); 136 137 for (int iSat =0; iSat < _ObsBlock.nSat; iSat++) {133 134 for (int iSat = 0; iSat < _ObsBlock.nSat; iSat++) { 138 135 t_satObs obs; 139 136 if (_ObsBlock.PRN[iSat] > 100) { 140 137 obs._prn.set('R', _ObsBlock.PRN[iSat] % 100); 141 } 142 else { 138 } else { 143 139 obs._prn.set('G', _ObsBlock.PRN[iSat]); 144 } 140 } 145 141 char sys = obs._prn.system(); 146 142 obs._time.set(epochWeek, epochSecs); 143 147 144 t_frqObs* frqObs1C = new t_frqObs; 148 frqObs1C->_rnxType2ch 149 frqObs1C->_codeValid 150 frqObs1C->_code 145 frqObs1C->_rnxType2ch = "1C"; 146 frqObs1C->_codeValid = true; 147 frqObs1C->_code = _ObsBlock.rng_C1[iSat]; 151 148 obs._obs.push_back(frqObs1C); 152 149 153 150 t_frqObs* frqObs1P = new t_frqObs; 154 frqObs1P->_rnxType2ch = (sys == 'G') ? "1W" : "1P"; 155 frqObs1P->_codeValid = true; 156 frqObs1P->_code = _ObsBlock.rng_P1[iSat]; 157 obs._obs.push_back(frqObs1P); 158 frqObs1P->_phaseValid = true; 159 frqObs1P->_phase = _ObsBlock.resolvedPhase_L1(iSat); 151 frqObs1P->_rnxType2ch = (sys == 'G') ? "1W" : "1P"; 152 frqObs1P->_codeValid = true; 153 frqObs1P->_code = _ObsBlock.rng_P1[iSat]; 154 frqObs1P->_phaseValid = true; 155 frqObs1P->_phase = _ObsBlock.resolvedPhase_L1(iSat); 160 156 frqObs1P->_slipCounter = _ObsBlock.slip_L1[iSat]; 161 157 obs._obs.push_back(frqObs1P); 162 158 163 159 t_frqObs* frqObs2P = new t_frqObs; 164 frqObs2P->_rnxType2ch = (sys == 'G') ? "2W" : "2P"; 165 frqObs2P->_codeValid = true; 166 frqObs2P->_code = _ObsBlock.rng_P2[iSat]; 167 obs._obs.push_back(frqObs2P); 168 frqObs2P->_phaseValid = true; 169 frqObs2P->_phase = _ObsBlock.resolvedPhase_L2(iSat); 160 frqObs2P->_rnxType2ch = (sys == 'G') ? "2W" : "2P"; 161 frqObs2P->_codeValid = true; 162 frqObs2P->_code = _ObsBlock.rng_P2[iSat]; 163 frqObs2P->_phaseValid = true; 164 frqObs2P->_phase = _ObsBlock.resolvedPhase_L2(iSat); 170 165 frqObs2P->_slipCounter = _ObsBlock.slip_L2[iSat]; 171 166 obs._obs.push_back(frqObs2P); … … 177 172 } 178 173 179 else if ( _PP.ID() == 20 || _PP.ID() == 21) {174 else if (_PP.ID() == 20 || _PP.ID() == 21) { 180 175 _msg2021.extract(_PP); 181 176 182 177 if (_msg2021.valid()) { 183 178 decoded = true; 184 185 } 186 } 187 188 else if ( _PP.ID() == 3) {179 translateCorr2Obs(errmsg); 180 } 181 } 182 183 else if (_PP.ID() == 3) { 189 184 _msg03.extract(_PP); 190 185 } 191 186 192 else if ( _PP.ID() == 22) {187 else if (_PP.ID() == 22) { 193 188 _msg22.extract(_PP); 194 189 } 195 190 196 else if ( _PP.ID() == 23) {191 else if (_PP.ID() == 23) { 197 192 _msg23.extract(_PP); 198 193 } 199 194 200 else if ( _PP.ID() == 24) {195 else if (_PP.ID() == 24) { 201 196 _msg24.extract(_PP); 202 197 } 203 198 204 199 // Output for RTCM scan 205 if ( _PP.ID() == 3 ) { 206 if ( _msg03.validMsg ) { 207 _antList.push_back(t_antInfo()); 208 209 this->getStaCrd(_antList.back().xx, _antList.back().yy, _antList.back().zz); 210 211 _antList.back().type = t_antInfo::APC; 212 _antList.back().message = _PP.ID(); 213 } 214 } 215 else if ( _PP.ID() == 23 ) { 216 if ( _msg23.validMsg ) { 217 _antType.push_back(_msg23.antType.c_str()); 218 } 219 } 220 else if ( _PP.ID() == 24 ) { 221 if ( _msg24.validMsg ) { 222 _antList.push_back(t_antInfo()); 223 224 _antList.back().xx = _msg24.x; 225 _antList.back().yy = _msg24.y; 226 _antList.back().zz = _msg24.z; 227 228 _antList.back().height_f = true; 229 _antList.back().height = _msg24.h; 230 231 _antList.back().type = t_antInfo::ARP; 232 _antList.back().message = _PP.ID(); 200 if (_PP.ID() == 3) { 201 if (_msg03.validMsg) { 202 _antList.push_back(t_antInfo()); 203 204 this->getStaCrd(_antList.back().xx, _antList.back().yy, 205 _antList.back().zz); 206 207 _antList.back().type = t_antInfo::APC; 208 _antList.back().message = _PP.ID(); 209 } 210 } else if (_PP.ID() == 23) { 211 if (_msg23.validMsg) { 212 _antType.push_back(_msg23.antType.c_str()); 213 } 214 } else if (_PP.ID() == 24) { 215 if (_msg24.validMsg) { 216 _antList.push_back(t_antInfo()); 217 218 _antList.back().xx = _msg24.x; 219 _antList.back().yy = _msg24.y; 220 _antList.back().zz = _msg24.z; 221 222 _antList.back().height_f = true; 223 _antList.back().height = _msg24.h; 224 225 _antList.back().type = t_antInfo::ARP; 226 _antList.back().message = _PP.ID(); 233 227 } 234 228 } … … 241 235 QMutexLocker locker(&_mutex); 242 236 243 if ( !_msg03.validMsg || !_msg2021.valid()) {237 if (!_msg03.validMsg || !_msg2021.valid()) { 244 238 return; 245 239 } … … 249 243 double staz = _msg03.z + (_msg22.validMsg ? _msg22.dL1[2] : 0.0); 250 244 251 int 245 int refWeek; 252 246 double refSecs; 253 247 currentGPSWeeks(refWeek, refSecs); … … 255 249 // Resolve receiver time of measurement (see RTCM 2.3, page 4-42, Message 18, Note 1) 256 250 // ---------------------------------------------------------------------------------- 257 double hoursec_est = _msg2021.hoursec();// estimated time of measurement258 double hoursec_rcv = rint(hoursec_est * 1e2) / 1e2; // receiver clock reading at hoursec_est251 double hoursec_est = _msg2021.hoursec(); // estimated time of measurement 252 double hoursec_rcv = rint(hoursec_est * 1e2) / 1e2; // receiver clock reading at hoursec_est 259 253 double rcv_clk_bias = (hoursec_est - hoursec_rcv) * c_light; 260 254 261 int 255 int GPSWeek; 262 256 double GPSWeeks; 263 resolveEpoch(hoursec_est, refWeek, refSecs, 264 GPSWeek, GPSWeeks); 265 266 int GPSWeek_rcv; 257 resolveEpoch(hoursec_est, refWeek, refSecs, GPSWeek, GPSWeeks); 258 259 int GPSWeek_rcv; 267 260 double GPSWeeks_rcv; 268 resolveEpoch(hoursec_rcv, refWeek, refSecs, 269 GPSWeek_rcv, GPSWeeks_rcv); 261 resolveEpoch(hoursec_rcv, refWeek, refSecs, GPSWeek_rcv, GPSWeeks_rcv); 270 262 271 263 // Loop over all satellites 272 264 // ------------------------ 273 265 for (RTCM2_2021::data_iterator icorr = _msg2021.data.begin(); 274 266 icorr != _msg2021.data.end(); icorr++) { 275 267 const RTCM2_2021::HiResCorr* corr = icorr->second; 276 268 277 269 // beg test 278 if ( corr->PRN >= 200) {270 if (corr->PRN >= 200) { 279 271 continue; 280 272 } … … 282 274 283 275 QString prn; 284 char 276 char sys; 285 277 if (corr->PRN < 200) { 286 278 sys = 'G'; 287 279 prn = sys + QString("%1").arg(corr->PRN, 2, 10, QChar('0')); 288 } 289 else { 280 } else { 290 281 sys = 'R'; 291 282 prn = sys + QString("%1").arg(corr->PRN - 200, 2, 10, QChar('0')); … … 302 293 303 294 t_frqObs* frqObs1C = new t_frqObs; 304 frqObs1C->_rnxType2ch 295 frqObs1C->_rnxType2ch = "1C"; 305 296 new_obs->_obs.push_back(frqObs1C); 306 297 307 298 t_frqObs* frqObs1P = new t_frqObs; 308 frqObs1P->_rnxType2ch 299 frqObs1P->_rnxType2ch = (sys == 'G') ? "1W" : "1P"; 309 300 new_obs->_obs.push_back(frqObs1P); 310 301 311 302 t_frqObs* frqObs2P = new t_frqObs; 312 frqObs2P->_rnxType2ch 303 frqObs2P->_rnxType2ch = (sys == 'G') ? "2W" : "2P"; 313 304 new_obs->_obs.push_back(frqObs2P); 314 305 315 306 // missing IOD 316 307 vector<string> missingIOD; 317 vector<string> 308 vector<string> hasIOD; 318 309 for (unsigned ii = 0; ii < 4; ii++) { 319 int 320 double 321 const t_eph* eph 322 double* obsVal= 0;310 int IODcorr = 0; 311 double corrVal = 0; 312 const t_eph* eph = 0; 313 double* obsVal = 0; 323 314 324 315 switch (ii) { 325 case 0: // --- L1 ---326 327 328 obsVal= &L1;329 obsT= "L1";330 331 case 1: // --- L2 ---332 333 334 obsVal= &L2;335 obsT= "L2";336 337 case 2: // --- P1 ---338 339 340 obsVal= &P1;341 obsT= "P1";342 343 case 3: // --- P2 ---344 345 346 obsVal= &P2;347 obsT= "P2";348 349 default:350 316 case 0: // --- L1 --- 317 IODcorr = corr->IODp1; 318 corrVal = corr->phase1 * LAMBDA_1; 319 obsVal = &L1; 320 obsT = "L1"; 321 break; 322 case 1: // --- L2 --- 323 IODcorr = corr->IODp2; 324 corrVal = corr->phase2 * LAMBDA_2; 325 obsVal = &L2; 326 obsT = "L2"; 327 break; 328 case 2: // --- P1 --- 329 IODcorr = corr->IODr1; 330 corrVal = corr->range1; 331 obsVal = &P1; 332 obsT = "P1"; 333 break; 334 case 3: // --- P2 --- 335 IODcorr = corr->IODr2; 336 corrVal = corr->range2; 337 obsVal = &P2; 338 obsT = "P2"; 339 break; 340 default: 341 continue; 351 342 } 352 343 … … 354 345 const t_eph* ephLast = _ephUser.ephLast(prn); 355 346 const t_eph* ephPrev = _ephUser.ephPrev(prn); 356 if 347 if (ephLast && ephLast->IOD() == IODcorr) { 357 348 eph = ephLast; 358 } 359 else if (ephPrev && ephPrev->IOD() == IODcorr) { 349 } else if (ephPrev && ephPrev->IOD() == IODcorr) { 360 350 eph = ephPrev; 361 351 } 362 352 363 if ( eph) {353 if (eph) { 364 354 ostringstream msg; 365 355 msg << obsT << ':' << setw(3) << eph->IOD(); 366 356 hasIOD.push_back(msg.str()); 367 357 368 369 int GPSWeek_tot; 370 double GPSWeeks_tot; 371 double rho, xSat, ySat, zSat, clkSat; 372 cmpRho(eph, stax, stay, staz, 373 GPSWeek, GPSWeeks, 374 rho, GPSWeek_tot, GPSWeeks_tot, 375 xSat, ySat, zSat, clkSat); 376 377 *obsVal = rho - corrVal + rcv_clk_bias - clkSat; 378 379 if ( *obsVal == 0 ) *obsVal = ZEROVALUE; 380 381 // Allocate new memory 382 // ------------------- 383 if ( !new_obs ) { 384 new_obs = new t_satObs(); 358 int GPSWeek_tot; 359 double GPSWeeks_tot; 360 double rho, xSat, ySat, zSat, clkSat; 361 cmpRho(eph, stax, stay, staz, GPSWeek, GPSWeeks, rho, GPSWeek_tot, 362 GPSWeeks_tot, xSat, ySat, zSat, clkSat); 363 364 *obsVal = rho - corrVal + rcv_clk_bias - clkSat; 365 366 if (*obsVal == 0) 367 *obsVal = ZEROVALUE; 368 369 // Allocate new memory 370 // ------------------- 371 if (!new_obs) { 372 new_obs = new t_satObs(); 385 373 if (corr->PRN < 200) { 386 374 new_obs->_prn.set('G', corr->PRN); 375 } else { 376 new_obs->_prn.set('R', corr->PRN - 200); 387 377 } 388 else { 389 new_obs->_prn.set('R', corr->PRN-200); 390 } 391 new_obs->_time.set(GPSWeek_rcv, GPSWeeks_rcv); 392 } 393 394 // Store estimated measurements 395 // ---------------------------- 396 switch (ii) { 397 case 0: // --- L1 --- 398 frqObs1P->_phaseValid = true; 399 frqObs1P->_phase = *obsVal / LAMBDA_1; 400 frqObs1P->_slipCounter = corr->lock1; 401 break; 402 case 1: // --- L2 --- 403 frqObs2P->_phaseValid = true; 404 frqObs2P->_phase = *obsVal / LAMBDA_2; 405 frqObs2P->_slipCounter = corr->lock2; 406 break; 407 case 2: // --- C1 / P1 --- 408 if ( corr->Pind1 ) { 409 frqObs1P->_codeValid = true; 410 frqObs1P->_code = *obsVal; 411 } 412 else { 413 frqObs1C->_codeValid = true; 414 frqObs1C->_code = *obsVal; 415 } 416 break; 417 case 3: // --- C2 / P2 --- 418 if ( corr->Pind2 ) { 419 frqObs2P->_codeValid = true; 420 frqObs2P->_code = *obsVal; 421 } 422 break; 423 default: 424 continue; 425 } 426 } 427 else if ( IODcorr != 0 ) { 378 new_obs->_time.set(GPSWeek_rcv, GPSWeeks_rcv); 379 } 380 381 // Store estimated measurements 382 // ---------------------------- 383 switch (ii) { 384 case 0: // --- L1 --- 385 frqObs1P->_phaseValid = true; 386 frqObs1P->_phase = *obsVal / LAMBDA_1; 387 frqObs1P->_slipCounter = corr->lock1; 388 break; 389 case 1: // --- L2 --- 390 frqObs2P->_phaseValid = true; 391 frqObs2P->_phase = *obsVal / LAMBDA_2; 392 frqObs2P->_slipCounter = corr->lock2; 393 break; 394 case 2: // --- C1 / P1 --- 395 if (corr->Pind1) { 396 frqObs1P->_codeValid = true; 397 frqObs1P->_code = *obsVal; 398 } else { 399 frqObs1C->_codeValid = true; 400 frqObs1C->_code = *obsVal; 401 } 402 break; 403 case 3: // --- C2 / P2 --- 404 if (corr->Pind2) { 405 frqObs2P->_codeValid = true; 406 frqObs2P->_code = *obsVal; 407 } 408 break; 409 default: 410 continue; 411 } 412 } else if (IODcorr != 0) { 428 413 ostringstream msg; 429 414 msg << obsT << ':' << setw(3) << IODcorr; … … 431 416 } 432 417 } // loop over frequencies 433 418 434 419 // Error report 435 if ( missingIOD.size()) {420 if (missingIOD.size()) { 436 421 ostringstream missingIODstr; 437 422 438 copy(missingIOD.begin(), missingIOD.end(), ostream_iterator<string>(missingIODstr, " ")); 439 440 errmsg.push_back("missing eph for " + string(prn.toAscii().data()) + " , IODs " + missingIODstr.str()); 423 copy(missingIOD.begin(), missingIOD.end(), 424 ostream_iterator<string>(missingIODstr, " ")); 425 426 errmsg.push_back( 427 "missing eph for " + string(prn.toAscii().data()) + " , IODs " 428 + missingIODstr.str()); 441 429 } 442 430 443 431 // Store new observation 444 if ( new_obs) {432 if (new_obs) { 445 433 _obsList.push_back(*new_obs); 446 434 delete new_obs;
Note:
See TracChangeset
for help on using the changeset viewer.