[1558] | 1 | // Part of BNC, a utility for retrieving decoding and
|
---|
| 2 | // converting GNSS data streams from NTRIP broadcasters.
|
---|
| 3 | //
|
---|
| 4 | // Copyright (C) 2007
|
---|
| 5 | // German Federal Agency for Cartography and Geodesy (BKG)
|
---|
| 6 | // http://www.bkg.bund.de
|
---|
| 7 | // Czech Technical University Prague, Department of Geodesy
|
---|
| 8 | // http://www.fsv.cvut.cz
|
---|
| 9 | //
|
---|
| 10 | // Email: euref-ip@bkg.bund.de
|
---|
| 11 | //
|
---|
| 12 | // This program is free software; you can redistribute it and/or
|
---|
| 13 | // modify it under the terms of the GNU General Public License
|
---|
| 14 | // as published by the Free Software Foundation, version 2.
|
---|
| 15 | //
|
---|
| 16 | // This program is distributed in the hope that it will be useful,
|
---|
| 17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 19 | // GNU General Public License for more details.
|
---|
| 20 | //
|
---|
| 21 | // You should have received a copy of the GNU General Public License
|
---|
| 22 | // along with this program; if not, write to the Free Software
|
---|
| 23 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
---|
| 24 |
|
---|
| 25 | /* -------------------------------------------------------------------------
|
---|
| 26 | * BKG NTRIP Client
|
---|
| 27 | * -------------------------------------------------------------------------
|
---|
| 28 | *
|
---|
| 29 | * Class: latencyChecker
|
---|
| 30 | *
|
---|
| 31 | * Purpose: Check incoming GNSS data for latencies, gaps etc.
|
---|
| 32 | *
|
---|
| 33 | * Author: G. Weber
|
---|
| 34 | *
|
---|
| 35 | * Created: 02-Feb-2009
|
---|
| 36 | *
|
---|
| 37 | * Changes:
|
---|
| 38 | *
|
---|
| 39 | * -----------------------------------------------------------------------*/
|
---|
| 40 |
|
---|
[1564] | 41 | #include <iostream>
|
---|
[1578] | 42 |
|
---|
[1577] | 43 | #ifdef WIN32
|
---|
| 44 | #include <windows.h>
|
---|
[1578] | 45 | #else
|
---|
| 46 | #include <unistd.h>
|
---|
[1577] | 47 | #endif
|
---|
[1564] | 48 |
|
---|
[1558] | 49 | #include "latencychecker.h"
|
---|
[5070] | 50 | #include "bnccore.h"
|
---|
[1558] | 51 | #include "bncutils.h"
|
---|
| 52 | #include "bncsettings.h"
|
---|
| 53 |
|
---|
[1564] | 54 | using namespace std;
|
---|
| 55 |
|
---|
[1558] | 56 | // Constructor
|
---|
| 57 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 58 | latencyChecker::latencyChecker(QByteArray staID) {
|
---|
| 59 |
|
---|
| 60 | _staID = staID;
|
---|
| 61 |
|
---|
| 62 | connect(this, SIGNAL(newMessage(QByteArray,bool)),
|
---|
[5068] | 63 | BNC_CORE, SLOT(slotMessage(const QByteArray,bool)));
|
---|
[1558] | 64 |
|
---|
| 65 | bncSettings settings;
|
---|
| 66 |
|
---|
| 67 | // Notice threshold
|
---|
| 68 | // ----------------
|
---|
| 69 | QString obsRate = settings.value("obsRate").toString();
|
---|
| 70 | _inspSegm = 0;
|
---|
| 71 | if ( obsRate.isEmpty() ) {
|
---|
| 72 | _inspSegm = 0;
|
---|
| 73 | }
|
---|
| 74 | else if ( obsRate.indexOf("5 Hz") != -1 ) {
|
---|
| 75 | _inspSegm = 20;
|
---|
| 76 | }
|
---|
| 77 | else if ( obsRate.indexOf("1 Hz") != -1 ) {
|
---|
| 78 | _inspSegm = 10;
|
---|
| 79 | }
|
---|
| 80 | else if ( obsRate.indexOf("0.5 Hz") != -1 ) {
|
---|
| 81 | _inspSegm = 20;
|
---|
| 82 | }
|
---|
| 83 | else if ( obsRate.indexOf("0.2 Hz") != -1 ) {
|
---|
| 84 | _inspSegm = 40;
|
---|
| 85 | }
|
---|
| 86 | else if ( obsRate.indexOf("0.1 Hz") != -1 ) {
|
---|
| 87 | _inspSegm = 50;
|
---|
| 88 | }
|
---|
| 89 | _adviseFail = settings.value("adviseFail").toInt();
|
---|
| 90 | _adviseReco = settings.value("adviseReco").toInt();
|
---|
| 91 | _adviseScript = settings.value("adviseScript").toString();
|
---|
| 92 | expandEnvVar(_adviseScript);
|
---|
| 93 |
|
---|
| 94 | // Latency interval/average
|
---|
| 95 | // ------------------------
|
---|
[1983] | 96 | _perfIntr = 1;
|
---|
[1558] | 97 | QString perfIntr = settings.value("perfIntr").toString();
|
---|
| 98 | if ( perfIntr.isEmpty() ) {
|
---|
[1983] | 99 | _perfIntr = 1;
|
---|
[1558] | 100 | }
|
---|
| 101 | else if ( perfIntr.indexOf("2 sec") != -1 ) {
|
---|
| 102 | _perfIntr = 2;
|
---|
| 103 | }
|
---|
| 104 | else if ( perfIntr.indexOf("10 sec") != -1 ) {
|
---|
| 105 | _perfIntr = 10;
|
---|
| 106 | }
|
---|
| 107 | else if ( perfIntr.indexOf("1 min") != -1 ) {
|
---|
| 108 | _perfIntr = 60;
|
---|
| 109 | }
|
---|
[2485] | 110 | else if ( perfIntr.left(5).indexOf("5 min") != -1 ) {
|
---|
[1558] | 111 | _perfIntr = 300;
|
---|
| 112 | }
|
---|
| 113 | else if ( perfIntr.indexOf("15 min") != -1 ) {
|
---|
| 114 | _perfIntr = 900;
|
---|
| 115 | }
|
---|
| 116 | else if ( perfIntr.indexOf("1 hour") != -1 ) {
|
---|
| 117 | _perfIntr = 3600;
|
---|
| 118 | }
|
---|
| 119 | else if ( perfIntr.indexOf("6 hours") != -1 ) {
|
---|
| 120 | _perfIntr = 21600;
|
---|
| 121 | }
|
---|
| 122 | else if ( perfIntr.indexOf("1 day") != -1 ) {
|
---|
| 123 | _perfIntr = 86400;
|
---|
| 124 | }
|
---|
| 125 |
|
---|
| 126 | // RTCM message types
|
---|
| 127 | // ------------------
|
---|
| 128 | _checkMountPoint = settings.value("miscMount").toString();
|
---|
| 129 |
|
---|
| 130 | // Initialize private members
|
---|
| 131 | // --------------------------
|
---|
[1568] | 132 | _maxDt = 1000.0;
|
---|
[1558] | 133 | _wrongEpoch = false;
|
---|
[1568] | 134 | _checkSeg = false;
|
---|
[1558] | 135 | _numSucc = 0;
|
---|
| 136 | _secSucc = 0;
|
---|
| 137 | _secFail = 0;
|
---|
[1568] | 138 | _initPause = 0;
|
---|
[1558] | 139 | _currPause = 0;
|
---|
| 140 | _begCorrupt = false;
|
---|
| 141 | _endCorrupt = false;
|
---|
| 142 | _followSec = false;
|
---|
| 143 | _oldSecGPS = 0;
|
---|
| 144 | _newSecGPS = 0;
|
---|
| 145 | _numGaps = 0;
|
---|
| 146 | _diffSecGPS = 0;
|
---|
| 147 | _numLat = 0;
|
---|
| 148 | _sumLat = 0.0;
|
---|
| 149 | _sumLatQ = 0.0;
|
---|
| 150 | _meanDiff = 0.0;
|
---|
| 151 | _minLat = _maxDt;
|
---|
| 152 | _maxLat = -_maxDt;
|
---|
| 153 | _curLat = 0.0;
|
---|
| 154 |
|
---|
[1568] | 155 | _checkTime = QDateTime::currentDateTime();
|
---|
[6805] | 156 | _decodeSucc = QDateTime::currentDateTime();
|
---|
[6769] | 157 |
|
---|
[6805] | 158 | _decodeStop = QDateTime::currentDateTime();
|
---|
[6769] | 159 |
|
---|
[6805] | 160 | _begDateTimeOut = QDateTime::currentDateTime();
|
---|
| 161 | _endDateTimeOut = QDateTime::currentDateTime();
|
---|
[1568] | 162 |
|
---|
[6805] | 163 | _fromReconnect = false;
|
---|
[6638] | 164 |
|
---|
[1558] | 165 | }
|
---|
| 166 |
|
---|
| 167 | // Destructor
|
---|
| 168 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 169 | latencyChecker::~latencyChecker() {
|
---|
| 170 | }
|
---|
| 171 |
|
---|
[1568] | 172 | // Perform 'Begin outage' check
|
---|
[1558] | 173 | //////////////////////////////////////////////////////////////////////////////
|
---|
[1568] | 174 | void latencyChecker::checkReconnect() {
|
---|
[1572] | 175 |
|
---|
[6768] | 176 | if (_inspSegm == 0) { return;}
|
---|
[6758] | 177 |
|
---|
[1572] | 178 | // Begin outage threshold
|
---|
| 179 | // ----------------------
|
---|
[6805] | 180 | if (!_fromReconnect) {
|
---|
| 181 | _endDateTimeOut = QDateTime::currentDateTime();
|
---|
| 182 | }
|
---|
| 183 | _fromReconnect = true;
|
---|
| 184 |
|
---|
[1572] | 185 | if ( _decodeStop.isValid() ) {
|
---|
[6805] | 186 | _begDateTimeOut = QDateTime::currentDateTime();
|
---|
| 187 | if ( _endDateTimeOut.secsTo(QDateTime::currentDateTime()) > _adviseFail * 60 ) {
|
---|
| 188 | _begDateOut = _endDateTimeOut.toUTC().date().toString("yy-MM-dd");
|
---|
| 189 | _begTimeOut = _endDateTimeOut.toUTC().time().toString("hh:mm:ss");
|
---|
| 190 | emit(newMessage((_staID + ": Failure threshold exceeded, outage since "
|
---|
| 191 | + _begDateOut + " " + _begTimeOut + " UTC").toAscii(), true));
|
---|
[6807] | 192 | callScript(("Begin_Outage "
|
---|
[6805] | 193 | + _begDateOut + " " + _begTimeOut + " UTC").toAscii());
|
---|
[1572] | 194 | _decodeStop.setDate(QDate());
|
---|
| 195 | _decodeStop.setTime(QTime());
|
---|
[6805] | 196 | _decodeStart = QDateTime::currentDateTime();
|
---|
[1572] | 197 | }
|
---|
| 198 | }
|
---|
[1568] | 199 | }
|
---|
| 200 |
|
---|
| 201 | // Perform Corrupt and 'End outage' check
|
---|
| 202 | //////////////////////////////////////////////////////////////////////////////
|
---|
[1562] | 203 | void latencyChecker::checkOutage(bool decoded) {
|
---|
[1558] | 204 |
|
---|
[1568] | 205 | if (_inspSegm == 0) { return;}
|
---|
[1558] | 206 |
|
---|
[1568] | 207 | if (decoded) { _numSucc += 1; }
|
---|
[1558] | 208 |
|
---|
[1568] | 209 | if (!_checkPause.isValid() || _checkPause.secsTo(QDateTime::currentDateTime()) >= _currPause ) {
|
---|
| 210 | if (!_checkSeg) {
|
---|
| 211 | if ( _checkTime.secsTo(QDateTime::currentDateTime()) > _inspSegm ) {
|
---|
| 212 | _checkSeg = true;
|
---|
[1558] | 213 | }
|
---|
| 214 | }
|
---|
[1568] | 215 |
|
---|
| 216 | // Check - once per inspect segment
|
---|
| 217 | // --------------------------------
|
---|
| 218 | if (_checkSeg) {
|
---|
| 219 |
|
---|
| 220 | _checkTime = QDateTime::currentDateTime();
|
---|
| 221 |
|
---|
| 222 | if (_numSucc > 0) {
|
---|
| 223 | _secSucc += _inspSegm;
|
---|
| 224 | _decodeSucc = QDateTime::currentDateTime();
|
---|
| 225 | if (_secSucc > _adviseReco * 60) {
|
---|
| 226 | _secSucc = _adviseReco * 60 + 1;
|
---|
| 227 | }
|
---|
| 228 | _numSucc = 0;
|
---|
| 229 | _currPause = _initPause;
|
---|
| 230 | _checkPause.setDate(QDate());
|
---|
| 231 | _checkPause.setTime(QTime());
|
---|
[1558] | 232 | }
|
---|
| 233 | else {
|
---|
[1568] | 234 | _secFail += _inspSegm;
|
---|
| 235 | _secSucc = 0;
|
---|
[6805] | 236 | if (_secFail > _adviseFail * 60) {
|
---|
[1568] | 237 | _secFail = _adviseFail * 60 + 1;
|
---|
[1558] | 238 | }
|
---|
[1568] | 239 | if (!_checkPause.isValid()) {
|
---|
| 240 | _checkPause = QDateTime::currentDateTime();
|
---|
| 241 | }
|
---|
| 242 | else {
|
---|
| 243 | _checkPause.setDate(QDate());
|
---|
| 244 | _checkPause.setTime(QTime());
|
---|
| 245 | _secFail = _secFail + _currPause - _inspSegm;
|
---|
| 246 | _currPause = _currPause * 2;
|
---|
| 247 | if (_currPause > 960) {
|
---|
| 248 | _currPause = 960;
|
---|
| 249 | }
|
---|
| 250 | }
|
---|
[1558] | 251 | }
|
---|
[6805] | 252 |
|
---|
[1568] | 253 | // End corrupt threshold
|
---|
| 254 | // ---------------------
|
---|
| 255 | if ( _begCorrupt && !_endCorrupt && _secSucc > _adviseReco * 60 ) {
|
---|
| 256 | _endDateCor = QDateTime::currentDateTime()
|
---|
| 257 | .addSecs(- _adviseReco * 60)
|
---|
| 258 | .toUTC().date().toString("yy-MM-dd");
|
---|
| 259 | _endTimeCor = QDateTime::currentDateTime()
|
---|
| 260 | .addSecs(- _adviseReco * 60)
|
---|
| 261 | .toUTC().time().toString("hh:mm:ss");
|
---|
[6805] | 262 | emit(newMessage((_staID
|
---|
| 263 | + ": Recovery threshold exceeded, corruption ended "
|
---|
| 264 | + _endDateCor + " " + _endTimeCor + " UTC").toAscii(), true));
|
---|
| 265 | callScript(("End_Corrupted "
|
---|
| 266 | + _endDateCor + " " + _endTimeCor + " UTC Begin was "
|
---|
| 267 | + _begDateCor + " " + _begTimeCor + " UTC").toAscii());
|
---|
[1568] | 268 | _endCorrupt = true;
|
---|
| 269 | _begCorrupt = false;
|
---|
| 270 | _secFail = 0;
|
---|
[6805] | 271 | }
|
---|
[1568] | 272 | else {
|
---|
| 273 |
|
---|
| 274 | // Begin corrupt threshold
|
---|
| 275 | // -----------------------
|
---|
| 276 | if ( !_begCorrupt && _secFail > _adviseFail * 60 ) {
|
---|
| 277 | _begDateCor = _decodeSucc.toUTC().date().toString("yy-MM-dd");
|
---|
| 278 | _begTimeCor = _decodeSucc.toUTC().time().toString("hh:mm:ss");
|
---|
[6805] | 279 | emit(newMessage((_staID
|
---|
| 280 | + ": Failure threshold exceeded, corrupted since "
|
---|
| 281 | + _begDateCor + " " + _begTimeCor + " UTC").toAscii(), true));
|
---|
| 282 | callScript(("Begin_Corrupted "
|
---|
| 283 | + _begDateCor + " " + _begTimeCor + " UTC").toAscii());
|
---|
[1568] | 284 | _begCorrupt = true;
|
---|
| 285 | _endCorrupt = false;
|
---|
| 286 | _secSucc = 0;
|
---|
| 287 | _numSucc = 0;
|
---|
| 288 | }
|
---|
[1558] | 289 | }
|
---|
[1568] | 290 | _checkSeg = false;
|
---|
[1558] | 291 | }
|
---|
| 292 | }
|
---|
[1568] | 293 |
|
---|
[6805] | 294 | // End outage threshold
|
---|
| 295 | // --------------------
|
---|
[6758] | 296 | if (_fromReconnect) {
|
---|
[6805] | 297 | _begDateTimeOut = QDateTime::currentDateTime();
|
---|
[6758] | 298 | }
|
---|
[6805] | 299 | _fromReconnect = false;
|
---|
[6758] | 300 |
|
---|
[1568] | 301 | if ( _decodeStart.isValid() ) {
|
---|
[6805] | 302 | _endDateTimeOut = QDateTime::currentDateTime();
|
---|
| 303 | if ( _begDateTimeOut.secsTo(QDateTime::currentDateTime()) > _adviseReco * 60 ) {
|
---|
| 304 | _endDateOut = _begDateTimeOut.toUTC().date().toString("yy-MM-dd");
|
---|
| 305 | _endTimeOut = _begDateTimeOut.toUTC().time().toString("hh:mm:ss");
|
---|
| 306 | emit(newMessage((_staID + ": Recovery threshold exceeded, outage ended "
|
---|
| 307 | + _endDateOut + " " + _endTimeOut + " UTC").toAscii(), true));
|
---|
| 308 | callScript(("End_Outage "
|
---|
| 309 | + _endDateOut + " " + _endTimeOut + " UTC Begin was "
|
---|
| 310 | + _begDateOut + " " + _begTimeOut + " UTC").toAscii());
|
---|
[1568] | 311 | _decodeStart.setDate(QDate());
|
---|
| 312 | _decodeStart.setTime(QTime());
|
---|
[6805] | 313 | _decodeStop = QDateTime::currentDateTime();
|
---|
[1558] | 314 | }
|
---|
| 315 | }
|
---|
[1568] | 316 | }
|
---|
| 317 |
|
---|
[1562] | 318 | // Perform latency checks (observations)
|
---|
| 319 | //////////////////////////////////////////////////////////////////////////////
|
---|
[6137] | 320 | void latencyChecker::checkObsLatency(const QList<t_satObs>& obsList) {
|
---|
[1562] | 321 |
|
---|
[1978] | 322 | if (_perfIntr > 0 ) {
|
---|
[1558] | 323 |
|
---|
[6137] | 324 | QListIterator<t_satObs> it(obsList);
|
---|
[1978] | 325 | while (it.hasNext()) {
|
---|
[6137] | 326 | const t_satObs& obs = it.next();
|
---|
[1558] | 327 |
|
---|
[6137] | 328 | _newSecGPS = static_cast<int>(obs._time.gpssec());
|
---|
[1978] | 329 | if (_newSecGPS != _oldSecGPS) {
|
---|
| 330 | if (_newSecGPS % _perfIntr < _oldSecGPS % _perfIntr) {
|
---|
| 331 | if (_numLat > 0) {
|
---|
| 332 | if (_meanDiff > 0.0) {
|
---|
| 333 | if ( _checkMountPoint == _staID || _checkMountPoint == "ALL" ) {
|
---|
[1558] | 334 | emit( newMessage(QString("%1: Mean latency %2 sec, min %3, max %4, rms %5, %6 epochs, %7 gaps")
|
---|
| 335 | .arg(_staID.data())
|
---|
| 336 | .arg(int(_sumLat/_numLat*100)/100.)
|
---|
| 337 | .arg(int(_minLat*100)/100.)
|
---|
| 338 | .arg(int(_maxLat*100)/100.)
|
---|
| 339 | .arg(int((sqrt((_sumLatQ - _sumLat * _sumLat / _numLat)/_numLat))*100)/100.)
|
---|
| 340 | .arg(_numLat)
|
---|
| 341 | .arg(_numGaps)
|
---|
| 342 | .toAscii(), true) );
|
---|
[1978] | 343 | }
|
---|
| 344 | } else {
|
---|
| 345 | if ( _checkMountPoint == _staID || _checkMountPoint == "ALL" ) {
|
---|
[1558] | 346 | emit( newMessage(QString("%1: Mean latency %2 sec, min %3, max %4, rms %5, %6 epochs")
|
---|
| 347 | .arg(_staID.data())
|
---|
| 348 | .arg(int(_sumLat/_numLat*100)/100.)
|
---|
| 349 | .arg(int(_minLat*100)/100.)
|
---|
| 350 | .arg(int(_maxLat*100)/100.)
|
---|
| 351 | .arg(int((sqrt((_sumLatQ - _sumLat * _sumLat / _numLat)/_numLat))*100)/100.)
|
---|
| 352 | .arg(_numLat)
|
---|
| 353 | .toAscii(), true) );
|
---|
| 354 | }
|
---|
| 355 | }
|
---|
| 356 | }
|
---|
[1978] | 357 | _meanDiff = _diffSecGPS / _numLat;
|
---|
| 358 | _diffSecGPS = 0;
|
---|
| 359 | _numGaps = 0;
|
---|
| 360 | _sumLat = 0.0;
|
---|
| 361 | _sumLatQ = 0.0;
|
---|
| 362 | _numLat = 0;
|
---|
| 363 | _minLat = _maxDt;
|
---|
| 364 | _maxLat = -_maxDt;
|
---|
| 365 | }
|
---|
| 366 | if (_followSec) {
|
---|
| 367 | _diffSecGPS += _newSecGPS - _oldSecGPS;
|
---|
| 368 | if (_meanDiff>0.) {
|
---|
| 369 | if (_newSecGPS - _oldSecGPS > 1.5 * _meanDiff) {
|
---|
| 370 | _numGaps += 1;
|
---|
[1558] | 371 | }
|
---|
| 372 | }
|
---|
[1978] | 373 | }
|
---|
[1558] | 374 |
|
---|
[1978] | 375 | // Compute the observations latency
|
---|
| 376 | // --------------------------------
|
---|
[6137] | 377 | int week;
|
---|
| 378 | double sec;
|
---|
[1978] | 379 | currentGPSWeeks(week, sec);
|
---|
| 380 | const double secPerWeek = 7.0 * 24.0 * 3600.0;
|
---|
[6137] | 381 | if (week < int(obs._time.gpsw())) {
|
---|
[1978] | 382 | week += 1;
|
---|
| 383 | sec -= secPerWeek;
|
---|
[1558] | 384 | }
|
---|
[6137] | 385 | if (week > int(obs._time.gpsw())) {
|
---|
[1978] | 386 | week -= 1;
|
---|
| 387 | sec += secPerWeek;
|
---|
| 388 | }
|
---|
[6137] | 389 | _curLat = sec - obs._time.gpssec();
|
---|
[1978] | 390 | _sumLat += _curLat;
|
---|
| 391 | _sumLatQ += _curLat * _curLat;
|
---|
| 392 | if (_curLat < _minLat) {
|
---|
| 393 | _minLat = _curLat;
|
---|
| 394 | }
|
---|
| 395 | if (_curLat >= _maxLat) {
|
---|
| 396 | _maxLat = _curLat;
|
---|
| 397 | }
|
---|
| 398 | _numLat += 1;
|
---|
| 399 | _oldSecGPS = _newSecGPS;
|
---|
| 400 | _followSec = true;
|
---|
[1558] | 401 | }
|
---|
| 402 | }
|
---|
| 403 | }
|
---|
| 404 | }
|
---|
| 405 |
|
---|
[1562] | 406 | // Perform latency checks (corrections)
|
---|
| 407 | //////////////////////////////////////////////////////////////////////////////
|
---|
[1566] | 408 | void latencyChecker::checkCorrLatency(int corrGPSEpochTime) {
|
---|
[1562] | 409 |
|
---|
[1566] | 410 | if (corrGPSEpochTime < 0) {
|
---|
[1562] | 411 | return;
|
---|
| 412 | }
|
---|
| 413 |
|
---|
[1978] | 414 | if (_perfIntr > 0) {
|
---|
[1564] | 415 |
|
---|
[1978] | 416 | _newSecGPS = corrGPSEpochTime;
|
---|
[1564] | 417 |
|
---|
[1978] | 418 | int week;
|
---|
| 419 | double sec;
|
---|
| 420 | currentGPSWeeks(week, sec);
|
---|
| 421 | double dt = fabs(sec - _newSecGPS);
|
---|
| 422 | const double secPerWeek = 7.0 * 24.0 * 3600.0;
|
---|
| 423 | if (dt > 0.5 * secPerWeek) {
|
---|
| 424 | if (sec > _newSecGPS) {
|
---|
| 425 | sec -= secPerWeek;
|
---|
| 426 | } else {
|
---|
| 427 | sec += secPerWeek;
|
---|
[1566] | 428 | }
|
---|
[1978] | 429 | }
|
---|
| 430 | if (_newSecGPS != _oldSecGPS) {
|
---|
| 431 | if (int(_newSecGPS) % _perfIntr < int(_oldSecGPS) % _perfIntr) {
|
---|
| 432 | if (_numLat>0) {
|
---|
| 433 | QString late;
|
---|
| 434 | if (_meanDiff>0.) {
|
---|
| 435 | late = QString(": Mean latency %1 sec, min %2, max %3, rms %4, %5 epochs, %6 gaps")
|
---|
| 436 | .arg(int(_sumLat/_numLat*100)/100.)
|
---|
| 437 | .arg(int(_minLat*100)/100.)
|
---|
| 438 | .arg(int(_maxLat*100)/100.)
|
---|
| 439 | .arg(int((sqrt((_sumLatQ - _sumLat * _sumLat / _numLat)/_numLat))*100)/100.)
|
---|
| 440 | .arg(_numLat)
|
---|
| 441 | .arg(_numGaps);
|
---|
| 442 | if ( _checkMountPoint == _staID || _checkMountPoint == "ALL" ) {
|
---|
[1566] | 443 | emit(newMessage(QString(_staID + late ).toAscii(), true) );
|
---|
[1562] | 444 | }
|
---|
[1978] | 445 | }
|
---|
| 446 | else {
|
---|
| 447 | late = QString(": Mean latency %1 sec, min %2, max %3, rms %4, %5 epochs")
|
---|
| 448 | .arg(int(_sumLat/_numLat*100)/100.)
|
---|
| 449 | .arg(int(_minLat*100)/100.)
|
---|
| 450 | .arg(int(_maxLat*100)/100.)
|
---|
| 451 | .arg(int((sqrt((_sumLatQ - _sumLat * _sumLat / _numLat)/_numLat))*100)/100.)
|
---|
| 452 | .arg(_numLat);
|
---|
| 453 | if ( _checkMountPoint == _staID || _checkMountPoint == "ALL" ) {
|
---|
| 454 | emit(newMessage(QString(_staID + late ).toAscii(), true) );
|
---|
| 455 | }
|
---|
[1564] | 456 | }
|
---|
[1566] | 457 | }
|
---|
[1978] | 458 | _meanDiff = int(_diffSecGPS)/_numLat;
|
---|
| 459 | _diffSecGPS = 0;
|
---|
| 460 | _numGaps = 0;
|
---|
| 461 | _sumLat = 0.0;
|
---|
| 462 | _sumLatQ = 0.0;
|
---|
| 463 | _numLat = 0;
|
---|
| 464 | _minLat = 1000.;
|
---|
| 465 | _maxLat = -1000.;
|
---|
| 466 | }
|
---|
| 467 | if (_followSec) {
|
---|
| 468 | _diffSecGPS += _newSecGPS - _oldSecGPS;
|
---|
| 469 | if (_meanDiff>0.) {
|
---|
| 470 | if (_newSecGPS - _oldSecGPS > 1.5 * _meanDiff) {
|
---|
| 471 | _numGaps += 1;
|
---|
[1562] | 472 | }
|
---|
| 473 | }
|
---|
| 474 | }
|
---|
[1978] | 475 | _curLat = sec - _newSecGPS;
|
---|
| 476 | _sumLat += _curLat;
|
---|
| 477 | _sumLatQ += _curLat * _curLat;
|
---|
| 478 | if (_curLat < _minLat) {
|
---|
| 479 | _minLat = _curLat;
|
---|
| 480 | }
|
---|
| 481 | if (_curLat >= _maxLat) {
|
---|
| 482 | _maxLat = _curLat;
|
---|
| 483 | }
|
---|
| 484 | _numLat += 1;
|
---|
| 485 | _oldSecGPS = _newSecGPS;
|
---|
| 486 | _followSec = true;
|
---|
[1562] | 487 | }
|
---|
| 488 | }
|
---|
| 489 | }
|
---|
| 490 |
|
---|
[1558] | 491 | // Call advisory notice script
|
---|
| 492 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 493 | void latencyChecker::callScript(const char* comment) {
|
---|
| 494 | if (!_adviseScript.isEmpty()) {
|
---|
| 495 | #ifdef WIN32
|
---|
[1577] | 496 | Sleep(1);
|
---|
[1558] | 497 | QProcess::startDetached(_adviseScript, QStringList() << _staID << comment) ;
|
---|
| 498 | #else
|
---|
[1577] | 499 | sleep(1);
|
---|
[1558] | 500 | QProcess::startDetached("nohup", QStringList() << _adviseScript << _staID << comment) ;
|
---|
| 501 | #endif
|
---|
| 502 | }
|
---|
| 503 | }
|
---|