Changeset 8083 in ntrip for branches/BNC_2.12/src/latencychecker.cpp
- Timestamp:
- Mar 9, 2017, 12:32:12 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/BNC_2.12/src/latencychecker.cpp
r8012 r8083 35 35 * Created: 02-Feb-2009 36 36 * 37 * Changes: 37 * Changes: 38 38 * 39 39 * -----------------------------------------------------------------------*/ … … 60 60 _staID = staID; 61 61 62 connect(this, SIGNAL(newMessage(QByteArray,bool)), 62 connect(this, SIGNAL(newMessage(QByteArray,bool)), 63 63 BNC_CORE, SLOT(slotMessage(const QByteArray,bool))); 64 64 … … 69 69 QString adviseObsRate = settings.value("adviseObsRate").toString(); 70 70 _inspSegm = 0; 71 if ( adviseObsRate.isEmpty() ) { 72 _inspSegm = 0; 73 } 74 else if ( adviseObsRate.indexOf("5 Hz") != -1 ) { 75 _inspSegm = 20; 76 } 77 else if ( adviseObsRate.indexOf("1 Hz") != -1 ) { 78 _inspSegm = 10; 79 } 80 else if ( adviseObsRate.indexOf("0.5 Hz") != -1 ) { 81 _inspSegm = 20; 82 } 83 else if ( adviseObsRate.indexOf("0.2 Hz") != -1 ) { 84 _inspSegm = 40; 85 } 86 else if ( adviseObsRate.indexOf("0.1 Hz") != -1 ) { 87 _inspSegm = 50; 71 if ( adviseObsRate.isEmpty() ) { 72 _inspSegm = 0; 73 } 74 else if ( adviseObsRate.indexOf("5 Hz") != -1 ) { 75 _inspSegm = 20; 76 } 77 else if ( adviseObsRate.indexOf("1 Hz") != -1 ) { 78 _inspSegm = 10; 79 } 80 else if ( adviseObsRate.indexOf("0.5 Hz") != -1 ) { 81 _inspSegm = 20; 82 } 83 else if ( adviseObsRate.indexOf("0.2 Hz") != -1 ) { 84 _inspSegm = 40; 85 } 86 else if ( adviseObsRate.indexOf("0.1 Hz") != -1 ) { 87 _inspSegm = 50; 88 88 } 89 89 _adviseFail = settings.value("adviseFail").toInt(); … … 96 96 _miscIntr = 1; 97 97 QString miscIntr = settings.value("miscIntr").toString(); 98 if ( miscIntr.isEmpty() ) { 99 _miscIntr = 1; 100 } 101 else if ( miscIntr.indexOf("2 sec") != -1 ) { 102 _miscIntr = 2; 103 } 104 else if ( miscIntr.indexOf("10 sec") != -1 ) { 105 _miscIntr = 10; 106 } 107 else if ( miscIntr.indexOf("1 min") != -1 ) { 108 _miscIntr = 60; 109 } 110 else if ( miscIntr.left(5).indexOf("5 min") != -1 ) { 111 _miscIntr = 300; 112 } 113 else if ( miscIntr.indexOf("15 min") != -1 ) { 114 _miscIntr = 900; 115 } 116 else if ( miscIntr.indexOf("1 hour") != -1 ) { 117 _miscIntr = 3600; 118 } 119 else if ( miscIntr.indexOf("6 hours") != -1 ) { 120 _miscIntr = 21600; 121 } 122 else if ( miscIntr.indexOf("1 day") != -1 ) { 123 _miscIntr = 86400; 98 if ( miscIntr.isEmpty() ) { 99 _miscIntr = 1; 100 } 101 else if ( miscIntr.indexOf("2 sec") != -1 ) { 102 _miscIntr = 2; 103 } 104 else if ( miscIntr.indexOf("10 sec") != -1 ) { 105 _miscIntr = 10; 106 } 107 else if ( miscIntr.indexOf("1 min") != -1 ) { 108 _miscIntr = 60; 109 } 110 else if ( miscIntr.left(5).indexOf("5 min") != -1 ) { 111 _miscIntr = 300; 112 } 113 else if ( miscIntr.indexOf("15 min") != -1 ) { 114 _miscIntr = 900; 115 } 116 else if ( miscIntr.indexOf("1 hour") != -1 ) { 117 _miscIntr = 3600; 118 } 119 else if ( miscIntr.indexOf("6 hours") != -1 ) { 120 _miscIntr = 21600; 121 } 122 else if ( miscIntr.indexOf("1 day") != -1 ) { 123 _miscIntr = 86400; 124 124 } 125 125 … … 130 130 // Initialize private members 131 131 // -------------------------- 132 _maxDt = 1000.0;133 132 _wrongEpoch = false; 134 133 _checkSeg = false; … … 138 137 _initPause = 0; 139 138 _currPause = 0; 140 _followSec = false; 141 _oldSecGPS = 0; 142 _newSecGPS = 0; 143 _numGaps = 0; 144 _diffSecGPS = 0; 145 _numLat = 0; 146 _sumLat = 0.0; 147 _sumLatQ = 0.0; 148 _meanDiff = 0.0; 149 _minLat = _maxDt; 150 _maxLat = -_maxDt; 151 _curLat = 0.0; 139 _endCorrupt = false; 140 _begCorrupt = false; 141 _fromCorrupt = false; 152 142 153 143 _checkTime = QDateTime::currentDateTime(); … … 162 152 _begDateTimeCorr = QDateTime::currentDateTime(); 163 153 _endDateTimeCorr = QDateTime::currentDateTime(); 164 165 154 } 166 155 … … 180 169 if (!_fromReconnect) { 181 170 _endDateTimeOut = QDateTime::currentDateTime(); 182 } 171 } 183 172 _fromReconnect = true; 184 173 … … 277 266 _decodeStartCorr = QDateTime::currentDateTime(); 278 267 } 279 } 268 } 280 269 else { 281 270 … … 307 296 if (_fromReconnect) { 308 297 _begDateTimeOut = QDateTime::currentDateTime(); 309 } 298 } 310 299 _fromReconnect = false; 311 300 … … 332 321 333 322 if (_miscIntr > 0 ) { 334 323 t_latency& l = _lObs; l._type = "Observations"; 335 324 QListIterator<t_satObs> it(obsList); 336 325 while (it.hasNext()) { 337 326 const t_satObs& obs = it.next(); 338 327 bool wrongObservationEpoch = checkForWrongObsEpoch(obs._time); 339 _newSecGPS= static_cast<int>(obs._time.gpssec());340 if ( _newSecGPS != _oldSecGPS&& !wrongObservationEpoch) {341 if ( _newSecGPS % _miscIntr < _oldSecGPS% _miscIntr) {342 if ( _numLat > 0) {343 if ( _meanDiff > 0.0) {328 l._newSec = static_cast<int>(obs._time.gpssec()); 329 if (l._newSec > l._oldSec && !wrongObservationEpoch) { 330 if (l._newSec % _miscIntr < l._oldSec % _miscIntr) { 331 if (l._numLat > 0) { 332 if (l._meanDiff > 0.0) { 344 333 if ( _checkMountPoint == _staID || _checkMountPoint == "ALL" ) { 345 emit( newMessage(QString("%1 : Mean latency %2 sec, min %3, max %4, rms %5, %6 epochs, %7gaps")334 emit( newMessage(QString("%1 %2: Mean latency %3 sec, min %4, max %5, rms %6, %7 epochs, %8 gaps") 346 335 .arg(_staID.data()) 347 .arg(int(_sumLat/_numLat*100)/100.) 348 .arg(int(_minLat*100)/100.) 349 .arg(int(_maxLat*100)/100.) 350 .arg(int((sqrt((_sumLatQ - _sumLat * _sumLat / _numLat)/_numLat))*100)/100.) 351 .arg(_numLat) 352 .arg(_numGaps) 336 .arg(l._type.data()) 337 .arg(int(l._sumLat/l._numLat*100)/100.) 338 .arg(int(l._minLat*100)/100.) 339 .arg(int(l._maxLat*100)/100.) 340 .arg(int((sqrt((l._sumLatQ - l._sumLat * l._sumLat / l._numLat)/l._numLat))*100)/100.) 341 .arg(l._numLat) 342 .arg(l._numGaps) 353 343 .toAscii(), true) ); 354 344 } 355 345 } else { 356 346 if ( _checkMountPoint == _staID || _checkMountPoint == "ALL" ) { 357 emit( newMessage(QString("%1 : Mean latency %2 sec, min %3, max %4, rms %5, %6epochs")347 emit( newMessage(QString("%1 %2: Mean latency %3 sec, min %4, max %5, rms %6, %7 epochs") 358 348 .arg(_staID.data()) 359 .arg(int(_sumLat/_numLat*100)/100.) 360 .arg(int(_minLat*100)/100.) 361 .arg(int(_maxLat*100)/100.) 362 .arg(int((sqrt((_sumLatQ - _sumLat * _sumLat / _numLat)/_numLat))*100)/100.) 363 .arg(_numLat) 349 .arg(l._type.data()) 350 .arg(int(l._sumLat/l._numLat*100)/100.) 351 .arg(int(l._minLat*100)/100.) 352 .arg(int(l._maxLat*100)/100.) 353 .arg(int((sqrt((l._sumLatQ - l._sumLat * l._sumLat / l._numLat)/l._numLat))*100)/100.) 354 .arg(l._numLat) 364 355 .toAscii(), true) ); 365 356 } 366 357 } 367 358 } 368 _meanDiff = _diffSecGPS / _numLat; 369 _diffSecGPS = 0; 370 _numGaps = 0; 371 _sumLat = 0.0; 372 _sumLatQ = 0.0; 373 _numLat = 0; 374 _minLat = _maxDt; 375 _maxLat = -_maxDt; 376 } 377 if (_followSec) { 378 _diffSecGPS += _newSecGPS - _oldSecGPS; 379 if (_meanDiff>0.) { 380 if (_newSecGPS - _oldSecGPS > 1.5 * _meanDiff) { 381 _numGaps += 1; 359 l._meanDiff = l._diffSec / l._numLat; 360 l.init(); 361 } 362 if (l._followSec) { 363 l._diffSec += l._newSec - l._oldSec; 364 if (l._meanDiff>0.) { 365 if (l._newSec - l._oldSec > 1.5 * l._meanDiff) { 366 l._numGaps += 1; 382 367 } 383 368 } … … 398 383 sec += secPerWeek; 399 384 } 400 _curLat = sec - obs._time.gpssec(); 401 _sumLat += _curLat; 402 _sumLatQ += _curLat * _curLat; 403 if (_curLat < _minLat) { 404 _minLat = _curLat; 405 } 406 if (_curLat >= _maxLat) { 407 _maxLat = _curLat; 408 } 409 _numLat += 1; 410 _oldSecGPS = _newSecGPS; 411 _followSec = true; 412 } 413 } 385 l._curLat = sec - obs._time.gpssec(); 386 l._sumLat += l._curLat; 387 l._sumLatQ += l._curLat * l._curLat; 388 if (l._curLat < l._minLat) { 389 l._minLat = l._curLat; 390 } 391 if (l._curLat >= l._maxLat) { 392 l._maxLat = l._curLat; 393 } 394 l._numLat += 1; 395 l._oldSec = l._newSec; 396 l._followSec = true; 397 } 398 } 399 _lObs = l; 400 setCurrentLatency(l._curLat); 414 401 } 415 402 } … … 417 404 // Perform latency checks (corrections) 418 405 ////////////////////////////////////////////////////////////////////////////// 419 void latencyChecker::checkCorrLatency(int corrGPSEpochTime) { 420 406 void latencyChecker::checkCorrLatency(int corrGPSEpochTime, int type) { 421 407 if (corrGPSEpochTime < 0) { 422 return; 408 return ; 409 } 410 t_latency& l = _lOrb; // init 411 switch (type) { 412 case 1057: case 1063: case 1240: case 1246: case 1252: case 1258: 413 l = _lOrb; l._type = "Orbit"; 414 break; 415 case 1058: case 1064: case 1241: case 1247: case 1253: case 1259: 416 l = _lClk; l._type = "Clock"; 417 break; 418 case 1060: case 1066: case 1243: case 1249: case 1255: case 1261: 419 l = _lClkOrb; l._type = "Clock&Orbit"; 420 break; 421 case 1059: case 1065: case 1242: case 1248: case 1254: case 1260: 422 l = _lCb; l._type = "Code Biases"; 423 break; 424 case 1265: case 1266: case 1267: case 1268: case 1269: case 1270: 425 l = _lPb; l._type = "Phase Biases"; 426 break; 427 case 1264: 428 l = _lVtec; l._type = "VTEC"; 429 break; 430 case 1061: case 1067: case 1244: case 1250: case 1256: case 1262: 431 l = _lUra; l._type = "URA"; 432 break; 433 case 1062: case 1068: case 1245: case 1251: case 1257: case 1263: 434 l = _lHr; l._type = "Hr Clock"; 435 break; 436 default: 437 return; 423 438 } 424 439 425 440 if (_miscIntr > 0) { 426 427 _newSecGPS = corrGPSEpochTime; 428 441 l._newSec = corrGPSEpochTime; 429 442 int week; 430 443 double sec; 431 444 currentGPSWeeks(week, sec); 432 double dt = fabs(sec - _newSecGPS);445 double dt = fabs(sec - l._newSec); 433 446 const double secPerWeek = 7.0 * 24.0 * 3600.0; 434 447 if (dt > 0.5 * secPerWeek) { 435 if (sec > _newSecGPS) {448 if (sec > l._newSec) { 436 449 sec -= secPerWeek; 437 450 } else { … … 439 452 } 440 453 } 441 if ( _newSecGPS != _oldSecGPS) {442 if (int( _newSecGPS) % _miscIntr < int(_oldSecGPS) % _miscIntr) {443 if ( _numLat>0) {454 if (l._newSec > l._oldSec) { 455 if (int(l._newSec) % _miscIntr < int(l._oldSec) % _miscIntr) { 456 if (l._numLat>0) { 444 457 QString late; 445 if (_meanDiff>0.) { 446 late = QString(": Mean latency %1 sec, min %2, max %3, rms %4, %5 epochs, %6 gaps") 447 .arg(int(_sumLat/_numLat*100)/100.) 448 .arg(int(_minLat*100)/100.) 449 .arg(int(_maxLat*100)/100.) 450 .arg(int((sqrt((_sumLatQ - _sumLat * _sumLat / _numLat)/_numLat))*100)/100.) 451 .arg(_numLat) 452 .arg(_numGaps); 458 if (l._meanDiff>0.) { 459 late = QString(" %1: Mean latency %2 sec, min %3, max %4, rms %5, %6 epochs, %7 gaps") 460 .arg(l._type.data()) 461 .arg(int(l._sumLat/l._numLat*100)/100.) 462 .arg(int(l._minLat*100)/100.) 463 .arg(int(l._maxLat*100)/100.) 464 .arg(int((sqrt((l._sumLatQ - l._sumLat * l._sumLat / l._numLat)/l._numLat))*100)/100.) 465 .arg(l._numLat) 466 .arg(l._numGaps); 453 467 if ( _checkMountPoint == _staID || _checkMountPoint == "ALL" ) { 454 468 emit(newMessage(QString(_staID + late ).toAscii(), true) ); 455 469 } 456 } 470 } 457 471 else { 458 late = QString(": Mean latency %1 sec, min %2, max %3, rms %4, %5 epochs") 459 .arg(int(_sumLat/_numLat*100)/100.) 460 .arg(int(_minLat*100)/100.) 461 .arg(int(_maxLat*100)/100.) 462 .arg(int((sqrt((_sumLatQ - _sumLat * _sumLat / _numLat)/_numLat))*100)/100.) 463 .arg(_numLat); 472 late = QString(" %1: Mean latency %2 sec, min %3, max %4, rms %5, %6 epochs") 473 .arg(l._type.data()) 474 .arg(int(l._sumLat/l._numLat*100)/100.) 475 .arg(int(l._minLat*100)/100.) 476 .arg(int(l._maxLat*100)/100.) 477 .arg(int((sqrt((l._sumLatQ - l._sumLat * l._sumLat / l._numLat)/l._numLat))*100)/100.) 478 .arg(l._numLat); 464 479 if ( _checkMountPoint == _staID || _checkMountPoint == "ALL" ) { 465 480 emit(newMessage(QString(_staID + late ).toAscii(), true) ); … … 467 482 } 468 483 } 469 _meanDiff = int(_diffSecGPS)/_numLat; 470 _diffSecGPS = 0; 471 _numGaps = 0; 472 _sumLat = 0.0; 473 _sumLatQ = 0.0; 474 _numLat = 0; 475 _minLat = 1000.; 476 _maxLat = -1000.; 477 } 478 if (_followSec) { 479 _diffSecGPS += _newSecGPS - _oldSecGPS; 480 if (_meanDiff>0.) { 481 if (_newSecGPS - _oldSecGPS > 1.5 * _meanDiff) { 482 _numGaps += 1; 483 } 484 } 485 } 486 _curLat = sec - _newSecGPS; 487 _sumLat += _curLat; 488 _sumLatQ += _curLat * _curLat; 489 if (_curLat < _minLat) { 490 _minLat = _curLat; 491 } 492 if (_curLat >= _maxLat) { 493 _maxLat = _curLat; 494 } 495 _numLat += 1; 496 _oldSecGPS = _newSecGPS; 497 _followSec = true; 498 } 499 } 500 } 501 502 // Call advisory notice script 484 l._meanDiff = int(l._diffSec)/l._numLat; 485 l.init(); 486 } 487 488 if (l._followSec) { 489 l._diffSec += l._newSec - l._oldSec; 490 if (l._meanDiff>0.) { 491 if (l._newSec - l._oldSec > 1.5 * l._meanDiff) { 492 l._numGaps += 1; 493 } 494 } 495 } 496 l._curLat = sec - l._newSec; 497 l._sumLat += l._curLat; 498 l._sumLatQ += l._curLat * l._curLat; 499 if (l._curLat < l._minLat) { 500 l._minLat = l._curLat; 501 } 502 if (l._curLat >= l._maxLat) { 503 l._maxLat = l._curLat; 504 } 505 l._numLat += 1; 506 l._oldSec = l._newSec; 507 l._followSec = true; 508 setCurrentLatency(l._curLat); 509 } 510 switch (type) { 511 case 1057: case 1063: case 1240: case 1246: case 1252: case 1258: 512 _lOrb = l; 513 break; 514 case 1058: case 1064: case 1241: case 1247: case 1253: case 1259: 515 _lClk = l; 516 break; 517 case 1060: case 1066: case 1243: case 1249: case 1255: case 1261: 518 _lClkOrb = l; 519 break; 520 case 1059: case 1065: case 1242: case 1248: case 1254: case 1260: 521 _lCb = l; 522 break; 523 case 1265: case 1266: case 1267: case 1268: case 1269: case 1270: 524 _lPb = l; 525 break; 526 case 1264: 527 _lVtec = l; 528 break; 529 case 1061: case 1067: case 1244: case 1250: case 1256: case 1262: 530 _lUra = l; 531 break; 532 case 1062: case 1068: case 1245: case 1251: case 1257: case 1263: 533 _lHr = l; 534 break; 535 } 536 } 537 } 538 539 // Call advisory notice script 503 540 //////////////////////////////////////////////////////////////////////////// 504 541 void latencyChecker::callScript(const char* comment) {
Note:
See TracChangeset
for help on using the changeset viewer.