Changeset 1568 in ntrip
- Timestamp:
- Feb 10, 2009, 11:37:14 AM (16 years ago)
- Location:
- trunk/BNC
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/bncgetthread.cpp
r1567 r1568 351 351 // ------------------ 352 352 if (nBytes == 0) { 353 _latencyChecker->checkReconnect(); 353 354 emit(newMessage(_staID + ": Data timeout, reconnecting", true)); 355 msleep (5000); // sleep 5 sec 354 356 continue; 355 357 } -
trunk/BNC/latencychecker.cpp
r1566 r1568 84 84 _adviseFail = settings.value("adviseFail").toInt(); 85 85 _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 }92 86 _adviseScript = settings.value("adviseScript").toString(); 93 87 expandEnvVar(_adviseScript); … … 131 125 // Initialize private members 132 126 // -------------------------- 133 _maxDt = 600.0; // Check observation epoch127 _maxDt = 1000.0; 134 128 _wrongEpoch = false; 135 _ decode = true;129 _checkSeg = false; 136 130 _numSucc = 0; 137 131 _secSucc = 0; 138 132 _secFail = 0; 139 _initPause = 30; // Initial pause for corrupted streams133 _initPause = 0; 140 134 _currPause = 0; 141 135 _begCorrupt = false; … … 154 148 _curLat = 0.0; 155 149 156 _ decodeTime = QDateTime::currentDateTime();150 _checkTime = QDateTime::currentDateTime(); 157 151 _decodeSucc = QDateTime::currentDateTime(); 152 158 153 } 159 154 … … 163 158 } 164 159 165 // Perform check for outages 160 // Perform 'Begin outage' check 161 ////////////////////////////////////////////////////////////////////////////// 162 void latencyChecker::checkReconnect() { 163 _reConnect = true; 164 } 165 166 // Perform Corrupt and 'End outage' check 166 167 ////////////////////////////////////////////////////////////////////////////// 167 168 void latencyChecker::checkOutage(bool decoded) { 168 169 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()); 194 197 } 195 198 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 } 205 217 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 236 276 // End outage threshold 237 277 // -------------------- 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 } 250 300 251 301 // Perform latency checks (observations) -
trunk/BNC/latencychecker.h
r1566 r1568 36 36 latencyChecker(QByteArray staID); 37 37 ~latencyChecker(); 38 void checkReconnect(); 38 39 void checkOutage(bool decoded); 39 40 void checkObsLatency(const QList<p_obs>& obsList); … … 59 60 int _diffSecGPS; 60 61 int _numLat; 61 bool _makePause;62 62 bool _wrongEpoch; 63 bool _ decode;63 bool _checkSeg; 64 64 bool _begCorrupt; 65 65 bool _endCorrupt; 66 66 bool _followSec; 67 bool _reConnect; 67 68 double _maxDt; 68 69 double _sumLat; … … 83 84 QString _endDateOut; 84 85 QString _endTimeOut; 85 QDateTime _ decodeTime;86 QDateTime _checkTime; 86 87 QDateTime _decodeSucc; 87 88 QDateTime _decodeFailure; 88 89 QDateTime _decodeStart; 89 90 QDateTime _decodeStop; 90 QDateTime _ decodePause;91 QDateTime _checkPause; 91 92 }; 92 93
Note:
See TracChangeset
for help on using the changeset viewer.