Changeset 1568 in ntrip


Ignore:
Timestamp:
Feb 10, 2009, 11:37:14 AM (15 years ago)
Author:
weber
Message:

* empty log message *

Location:
trunk/BNC
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/bncgetthread.cpp

    r1567 r1568  
    351351      // ------------------
    352352      if (nBytes == 0) {
     353        _latencyChecker->checkReconnect();
    353354        emit(newMessage(_staID + ": Data timeout, reconnecting", true));
     355        msleep (5000); // sleep 5 sec
    354356        continue;
    355357      }
  • trunk/BNC/latencychecker.cpp

    r1566 r1568  
    8484  _adviseFail = settings.value("adviseFail").toInt();
    8585  _adviseReco = settings.value("adviseReco").toInt();
    86   if ( Qt::CheckState(settings.value("makePause").toInt()) == Qt::Checked) {
    87     _makePause = true;
    88   }
    89   else {
    90     _makePause = false;
    91   }
    9286  _adviseScript = settings.value("adviseScript").toString();
    9387  expandEnvVar(_adviseScript);
     
    131125  // Initialize private members
    132126  // --------------------------
    133   _maxDt      = 600.0;  // Check observation epoch
     127  _maxDt      = 1000.0;
    134128  _wrongEpoch = false;
    135   _decode     = true;
     129  _checkSeg   = false;
    136130  _numSucc    = 0;
    137131  _secSucc    = 0;
    138132  _secFail    = 0;
    139   _initPause  = 30;  // Initial pause for corrupted streams
     133  _initPause  = 0;
    140134  _currPause  = 0;
    141135  _begCorrupt = false;
     
    154148  _curLat     = 0.0;
    155149
    156   _decodeTime = QDateTime::currentDateTime();
     150  _checkTime = QDateTime::currentDateTime();
    157151  _decodeSucc = QDateTime::currentDateTime();
     152
    158153}
    159154
     
    163158}
    164159
    165 // Perform check for outages
     160// Perform 'Begin outage' check
     161//////////////////////////////////////////////////////////////////////////////
     162void latencyChecker::checkReconnect() {
     163  _reConnect = true;
     164}
     165
     166// Perform Corrupt and 'End outage' check
    166167//////////////////////////////////////////////////////////////////////////////
    167168void latencyChecker::checkOutage(bool decoded) {
    168169
    169   // Check - once per inspect segment
    170   // --------------------------------
    171   if (decoded) {
    172 
    173     _decodeTime = QDateTime::currentDateTime();
    174 
    175     if (_numSucc > 0) {
    176       _secSucc += _inspSegm;
    177       _decodeSucc = QDateTime::currentDateTime();
    178       if (_secSucc > _adviseReco * 60) {
    179         _secSucc = _adviseReco * 60 + 1;
    180       }
    181       _numSucc = 0;
    182       _currPause = _initPause;
    183       _decodePause.setDate(QDate());
    184       _decodePause.setTime(QTime());
    185     }
    186     else {
    187       _secFail += _inspSegm;
    188       _secSucc = 0;
    189       if (_secFail > _adviseFail * 60) {
    190         _secFail = _adviseFail * 60 + 1;
    191       }
    192       if (!_decodePause.isValid() || !_makePause) {
    193         _decodePause = QDateTime::currentDateTime();
     170  if (_inspSegm == 0) { return;}
     171
     172  if (decoded) { _numSucc += 1; }
     173
     174  if (!_checkPause.isValid() || _checkPause.secsTo(QDateTime::currentDateTime()) >= _currPause )  {
     175    if (!_checkSeg) {
     176      if ( _checkTime.secsTo(QDateTime::currentDateTime()) > _inspSegm ) {
     177        _checkSeg = true;
     178      }
     179    }
     180
     181    // Check - once per inspect segment
     182    // --------------------------------
     183    if (_checkSeg) {
     184
     185      _checkTime = QDateTime::currentDateTime();
     186
     187      if (_numSucc > 0) {
     188        _secSucc += _inspSegm;
     189        _decodeSucc = QDateTime::currentDateTime();
     190        if (_secSucc > _adviseReco * 60) {
     191          _secSucc = _adviseReco * 60 + 1;
     192        }
     193        _numSucc = 0;
     194        _currPause = _initPause;
     195        _checkPause.setDate(QDate());
     196        _checkPause.setTime(QTime());
    194197      }
    195198      else {
    196         _decodePause.setDate(QDate());
    197         _decodePause.setTime(QTime());
    198         _secFail = _secFail + _currPause - _inspSegm;
    199         _currPause = _currPause * 2;
    200         if (_currPause > 960) {
    201           _currPause = 960;
    202         }
    203       }
    204     }
     199        _secFail += _inspSegm;
     200        _secSucc = 0;
     201        if (_secFail > _adviseFail * 60) {
     202          _secFail = _adviseFail * 60 + 1;
     203        }
     204        if (!_checkPause.isValid()) {
     205          _checkPause = QDateTime::currentDateTime();
     206        }
     207        else {
     208          _checkPause.setDate(QDate());
     209          _checkPause.setTime(QTime());
     210          _secFail = _secFail + _currPause - _inspSegm;
     211          _currPause = _currPause * 2;
     212          if (_currPause > 960) {
     213            _currPause = 960;
     214          }
     215        }
     216      }
    205217 
    206     // End corrupt threshold
    207     // ---------------------
    208     if ( _begCorrupt && !_endCorrupt && _secSucc > _adviseReco * 60 ) {
    209       _endDateCor = QDateTime::currentDateTime().addSecs(- _adviseReco * 60).toUTC().date().toString("yy-MM-dd");
    210       _endTimeCor = QDateTime::currentDateTime().addSecs(- _adviseReco * 60).toUTC().time().toString("hh:mm:ss");
    211       emit(newMessage((_staID + ": Recovery threshold exceeded, corruption ended "
    212                       + _endDateCor + " " + _endTimeCor).toAscii(), true));
    213       callScript(("End_Corrupted " + _endDateCor + " " + _endTimeCor + " Begin was " + _begDateCor + " " + _begTimeCor).toAscii());
    214       _endCorrupt = true;
    215       _begCorrupt = false;
    216       _secFail = 0;
    217     }
    218     else {
    219  
    220       // Begin corrupt threshold
    221       // -----------------------
    222       if ( !_begCorrupt && _secFail > _adviseFail * 60 ) {
    223         _begDateCor = _decodeSucc.toUTC().date().toString("yy-MM-dd");
    224         _begTimeCor = _decodeSucc.toUTC().time().toString("hh:mm:ss");
    225         emit(newMessage((_staID + ": Failure threshold exceeded, corrupted since "
    226                         + _begDateCor + " " + _begTimeCor).toAscii(), true));
    227         callScript(("Begin_Corrupted " + _begDateCor + " " + _begTimeCor).toAscii());
    228         _begCorrupt = true;
    229         _endCorrupt = false;
    230         _secSucc = 0;
    231         _numSucc = 0;
    232       }
    233     }
    234   }
    235      
     218      // End corrupt threshold
     219      // ---------------------
     220      if ( _begCorrupt && !_endCorrupt && _secSucc > _adviseReco * 60 ) {
     221        _endDateCor = QDateTime::currentDateTime()
     222                    .addSecs(- _adviseReco * 60)
     223                    .toUTC().date().toString("yy-MM-dd");
     224        _endTimeCor = QDateTime::currentDateTime()
     225                    .addSecs(- _adviseReco * 60)
     226                    .toUTC().time().toString("hh:mm:ss");
     227        emit(newMessage((_staID
     228                    + ": Recovery threshold exceeded, corruption ended "
     229                    + _endDateCor + " " + _endTimeCor).toAscii(), true));
     230        callScript(("End_Corrupted "
     231                    + _endDateCor + " " + _endTimeCor + " Begin was "
     232                    + _begDateCor + " " + _begTimeCor).toAscii());
     233        _endCorrupt = true;
     234        _begCorrupt = false;
     235        _secFail = 0;
     236      }
     237      else {
     238
     239        // Begin corrupt threshold
     240        // -----------------------
     241        if ( !_begCorrupt && _secFail > _adviseFail * 60 ) {
     242          _begDateCor = _decodeSucc.toUTC().date().toString("yy-MM-dd");
     243          _begTimeCor = _decodeSucc.toUTC().time().toString("hh:mm:ss");
     244          emit(newMessage((_staID
     245                    + ": Failure threshold exceeded, corrupted since "
     246                    + _begDateCor + " " + _begTimeCor).toAscii(), true));
     247          callScript(("Begin_Corrupted "
     248                    + _begDateCor + " " + _begTimeCor).toAscii());
     249          _begCorrupt = true;
     250          _endCorrupt = false;
     251          _secSucc = 0;
     252          _numSucc = 0;
     253        }
     254      }
     255      _checkSeg = false;
     256    }
     257  }
     258
     259  // Begin outage threshold
     260  // ----------------------
     261  if ( _decodeStop.isValid() ) {
     262    if ( _decodeStop.secsTo(QDateTime::currentDateTime()) >  _adviseFail * 60 ) {
     263      _decodeStop.setDate(QDate());
     264      _decodeStop.setTime(QTime());
     265      _begDateOut = _checkTime.toUTC().date().toString("yy-MM-dd");
     266      _begTimeOut = _checkTime.toUTC().time().toString("hh:mm:ss");
     267      emit(newMessage((_staID
     268                    + ": Failure threshold exceeded, outage since "
     269                    + _begDateOut + " " + _begTimeOut).toAscii(), true));
     270      callScript(("Begin_Outage "
     271                    + _begDateOut + " " + _begTimeOut).toAscii());
     272      _decodeStart = QDateTime::currentDateTime();
     273    }
     274  }
     275
    236276  // End outage threshold
    237277  // --------------------
    238   if ( _decodeStart.isValid() && _decodeStart.secsTo(QDateTime::currentDateTime()) > _adviseReco * 60 ) {
    239     _decodeStart.setDate(QDate());
    240     _decodeStart.setTime(QTime());
    241     if (_inspSegm > 0) {
    242       _endDateOut = QDateTime::currentDateTime().addSecs(- _adviseReco * 60).toUTC().date().toString("yy-MM-dd");
    243       _endTimeOut = QDateTime::currentDateTime().addSecs(- _adviseReco * 60).toUTC().time().toString("hh:mm:ss");
    244       emit(newMessage((_staID + ": Recovery threshold exceeded, outage ended "
    245                       + _endDateOut + " " + _endTimeOut).toAscii(), true));
    246       callScript(("End_Outage " + _endDateOut + " " + _endTimeOut + " Begin was " + _begDateOut + " " + _begTimeOut).toAscii());
    247     }
    248   }
    249 }     
     278  if ( _decodeStart.isValid() ) {
     279    if ( _decodeStart.secsTo(QDateTime::currentDateTime()) >  _adviseReco * 60 ) {
     280      _decodeStart.setDate(QDate());
     281      _decodeStart.setTime(QTime());
     282      _endDateOut = QDateTime::currentDateTime()
     283                    .addSecs(- _adviseReco * 60)
     284                    .toUTC().date().toString("yy-MM-dd");
     285      _endTimeOut = QDateTime::currentDateTime()
     286                    .addSecs(- _adviseReco * 60)
     287                    .toUTC().time().toString("hh:mm:ss");
     288      emit(newMessage((_staID
     289                    + ": Recovery threshold exceeded, outage ended "
     290                    + _endDateOut + " " + _endTimeOut).toAscii(), true));
     291      callScript(("End_Outage "
     292                    + _endDateOut + " " + _endTimeOut + " Begin was "
     293                    + _begDateOut + " " + _begTimeOut).toAscii());
     294      _decodeStop = QDateTime::currentDateTime();
     295    }
     296  }
     297  _reConnect = false;
     298
     299}
    250300
    251301// Perform latency checks (observations)
  • trunk/BNC/latencychecker.h

    r1566 r1568  
    3636  latencyChecker(QByteArray staID);
    3737  ~latencyChecker();
     38  void checkReconnect();
    3839  void checkOutage(bool decoded);
    3940  void checkObsLatency(const QList<p_obs>& obsList);
     
    5960  int        _diffSecGPS;
    6061  int        _numLat;
    61   bool       _makePause;
    6262  bool       _wrongEpoch;
    63   bool       _decode;
     63  bool       _checkSeg;
    6464  bool       _begCorrupt;
    6565  bool       _endCorrupt;
    6666  bool       _followSec;
     67  bool       _reConnect;
    6768  double     _maxDt;
    6869  double     _sumLat;
     
    8384  QString    _endDateOut;
    8485  QString    _endTimeOut;
    85   QDateTime  _decodeTime;
     86  QDateTime  _checkTime;
    8687  QDateTime  _decodeSucc;
    8788  QDateTime  _decodeFailure;
    8889  QDateTime  _decodeStart;
    8990  QDateTime  _decodeStop;
    90   QDateTime  _decodePause;
     91  QDateTime  _checkPause;
    9192};
    9293
Note: See TracChangeset for help on using the changeset viewer.