Changeset 8082 in ntrip for trunk/BNC/src/latencychecker.cpp


Ignore:
Timestamp:
Mar 9, 2017, 12:31:17 PM (7 years ago)
Author:
stuerze
Message:

the latency checker is now able to check ssr data streams with messages containing different update rates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/src/latencychecker.cpp

    r8011 r8082  
    130130  // Initialize private members
    131131  // --------------------------
    132   _maxDt      = 1000.0;
    133132  _wrongEpoch = false;
    134133  _checkSeg   = false;
     
    138137  _initPause  = 0;
    139138  _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;
    152142
    153143  _checkTime = QDateTime::currentDateTime();
     
    162152  _begDateTimeCorr = QDateTime::currentDateTime();
    163153  _endDateTimeCorr = QDateTime::currentDateTime();
    164 
    165154}
    166155
     
    332321
    333322  if (_miscIntr > 0 ) {
    334 
     323    t_latency& l = _lObs; l._type =  "Observations";
    335324    QListIterator<t_satObs> it(obsList);
    336325    while (it.hasNext()) {
    337326      const t_satObs& obs = it.next();
    338327      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) {
    344333              if ( _checkMountPoint == _staID || _checkMountPoint == "ALL" ) {
    345                 emit( newMessage(QString("%1: Mean latency %2 sec, min %3, max %4, rms %5, %6 epochs, %7 gaps")
     334                emit( newMessage(QString("%1 %2: Mean latency %3 sec, min %4, max %5, rms %6, %7 epochs, %8 gaps")
    346335                  .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)
    353343                  .toAscii(), true) );
    354344              }
    355345            } else {
    356346              if ( _checkMountPoint == _staID || _checkMountPoint == "ALL" ) {
    357                 emit( newMessage(QString("%1: Mean latency %2 sec, min %3, max %4, rms %5, %6 epochs")
     347                emit( newMessage(QString("%1 %2: Mean latency %3 sec, min %4, max %5, rms %6, %7 epochs")
    358348                  .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)
    364355                  .toAscii(), true) );
    365356              }
    366357            }
    367358          }
    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;
    382367            }
    383368          }
     
    398383          sec  += secPerWeek;
    399384        }
    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);
    414401  }
    415402}
     
    417404// Perform latency checks (corrections)
    418405//////////////////////////////////////////////////////////////////////////////
    419 void latencyChecker::checkCorrLatency(int corrGPSEpochTime) {
    420 
     406void latencyChecker::checkCorrLatency(int corrGPSEpochTime, int type) {
    421407  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;
    423438  }
    424439
    425440  if (_miscIntr > 0) {
    426 
    427     _newSecGPS = corrGPSEpochTime;
    428 
     441    l._newSec = corrGPSEpochTime;
    429442    int week;
    430443    double sec;
    431444    currentGPSWeeks(week, sec);
    432     double dt = fabs(sec - _newSecGPS);
     445    double dt = fabs(sec - l._newSec);
    433446    const double secPerWeek = 7.0 * 24.0 * 3600.0;
    434447    if (dt > 0.5 * secPerWeek) {
    435       if (sec > _newSecGPS) {
     448      if (sec > l._newSec) {
    436449        sec  -= secPerWeek;
    437450      } else {
     
    439452      }
    440453    }
    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) {
    444457          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);
    453467            if ( _checkMountPoint == _staID || _checkMountPoint == "ALL" ) {
    454468              emit(newMessage(QString(_staID + late ).toAscii(), true) );
     
    456470          }
    457471          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);
    464479            if ( _checkMountPoint == _staID || _checkMountPoint == "ALL" ) {
    465480            emit(newMessage(QString(_staID + late ).toAscii(), true) );
     
    467482          }
    468483        }
    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     }
     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     }
    499536  }
    500537}
Note: See TracChangeset for help on using the changeset viewer.