[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();
|
---|
[1558] | 156 | _decodeSucc = QDateTime::currentDateTime();
|
---|
[1568] | 157 |
|
---|
[6758] | 158 | _decodeStart = QDateTime::currentDateTime();
|
---|
[1572] | 159 | _decodeStop = QDateTime::currentDateTime();
|
---|
[6638] | 160 |
|
---|
[1558] | 161 | }
|
---|
| 162 |
|
---|
| 163 | // Destructor
|
---|
| 164 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 165 | latencyChecker::~latencyChecker() {
|
---|
| 166 | }
|
---|
| 167 |
|
---|
[1568] | 168 | // Perform 'Begin outage' check
|
---|
[1558] | 169 | //////////////////////////////////////////////////////////////////////////////
|
---|
[1568] | 170 | void latencyChecker::checkReconnect() {
|
---|
[1572] | 171 |
|
---|
[6758] | 172 | if (_inspSegm == 0) { return;} // weber
|
---|
| 173 |
|
---|
[1572] | 174 | // Begin outage threshold
|
---|
| 175 | // ----------------------
|
---|
| 176 | if ( _decodeStop.isValid() ) {
|
---|
| 177 | if ( _decodeStop.secsTo(QDateTime::currentDateTime()) > _adviseFail * 60 ) {
|
---|
| 178 | _decodeStop.setDate(QDate());
|
---|
| 179 | _decodeStop.setTime(QTime());
|
---|
| 180 | _begDateOut = _checkTime.toUTC().date().toString("yy-MM-dd");
|
---|
| 181 | _begTimeOut = _checkTime.toUTC().time().toString("hh:mm:ss");
|
---|
| 182 | emit(newMessage((_staID
|
---|
| 183 | + ": Failure threshold exceeded, outage since "
|
---|
| 184 | + _begDateOut + " " + _begTimeOut).toAscii(), true));
|
---|
| 185 | callScript(("Begin_Outage "
|
---|
| 186 | + _begDateOut + " " + _begTimeOut).toAscii());
|
---|
| 187 | }
|
---|
| 188 | }
|
---|
[6758] | 189 | _fromReconnect = true;
|
---|
| 190 | _decodeStart = QDateTime::currentDateTime();
|
---|
[1568] | 191 | }
|
---|
| 192 |
|
---|
| 193 | // Perform Corrupt and 'End outage' check
|
---|
| 194 | //////////////////////////////////////////////////////////////////////////////
|
---|
[1562] | 195 | void latencyChecker::checkOutage(bool decoded) {
|
---|
[1558] | 196 |
|
---|
[1568] | 197 | if (_inspSegm == 0) { return;}
|
---|
[1558] | 198 |
|
---|
[1568] | 199 | if (decoded) { _numSucc += 1; }
|
---|
[1558] | 200 |
|
---|
[1568] | 201 | if (!_checkPause.isValid() || _checkPause.secsTo(QDateTime::currentDateTime()) >= _currPause ) {
|
---|
| 202 | if (!_checkSeg) {
|
---|
| 203 | if ( _checkTime.secsTo(QDateTime::currentDateTime()) > _inspSegm ) {
|
---|
| 204 | _checkSeg = true;
|
---|
[1558] | 205 | }
|
---|
| 206 | }
|
---|
[1568] | 207 |
|
---|
| 208 | // Check - once per inspect segment
|
---|
| 209 | // --------------------------------
|
---|
| 210 | if (_checkSeg) {
|
---|
| 211 |
|
---|
| 212 | _checkTime = QDateTime::currentDateTime();
|
---|
| 213 |
|
---|
| 214 | if (_numSucc > 0) {
|
---|
| 215 | _secSucc += _inspSegm;
|
---|
| 216 | _decodeSucc = QDateTime::currentDateTime();
|
---|
| 217 | if (_secSucc > _adviseReco * 60) {
|
---|
| 218 | _secSucc = _adviseReco * 60 + 1;
|
---|
| 219 | }
|
---|
| 220 | _numSucc = 0;
|
---|
| 221 | _currPause = _initPause;
|
---|
| 222 | _checkPause.setDate(QDate());
|
---|
| 223 | _checkPause.setTime(QTime());
|
---|
[1558] | 224 | }
|
---|
| 225 | else {
|
---|
[1568] | 226 | _secFail += _inspSegm;
|
---|
| 227 | _secSucc = 0;
|
---|
| 228 | if (_secFail > _adviseFail * 60) {
|
---|
| 229 | _secFail = _adviseFail * 60 + 1;
|
---|
[1558] | 230 | }
|
---|
[1568] | 231 | if (!_checkPause.isValid()) {
|
---|
| 232 | _checkPause = QDateTime::currentDateTime();
|
---|
| 233 | }
|
---|
| 234 | else {
|
---|
| 235 | _checkPause.setDate(QDate());
|
---|
| 236 | _checkPause.setTime(QTime());
|
---|
| 237 | _secFail = _secFail + _currPause - _inspSegm;
|
---|
| 238 | _currPause = _currPause * 2;
|
---|
| 239 | if (_currPause > 960) {
|
---|
| 240 | _currPause = 960;
|
---|
| 241 | }
|
---|
| 242 | }
|
---|
[1558] | 243 | }
|
---|
| 244 |
|
---|
[1568] | 245 | // End corrupt threshold
|
---|
| 246 | // ---------------------
|
---|
| 247 | if ( _begCorrupt && !_endCorrupt && _secSucc > _adviseReco * 60 ) {
|
---|
| 248 | _endDateCor = QDateTime::currentDateTime()
|
---|
| 249 | .addSecs(- _adviseReco * 60)
|
---|
| 250 | .toUTC().date().toString("yy-MM-dd");
|
---|
| 251 | _endTimeCor = QDateTime::currentDateTime()
|
---|
| 252 | .addSecs(- _adviseReco * 60)
|
---|
| 253 | .toUTC().time().toString("hh:mm:ss");
|
---|
| 254 | emit(newMessage((_staID
|
---|
| 255 | + ": Recovery threshold exceeded, corruption ended "
|
---|
| 256 | + _endDateCor + " " + _endTimeCor).toAscii(), true));
|
---|
| 257 | callScript(("End_Corrupted "
|
---|
| 258 | + _endDateCor + " " + _endTimeCor + " Begin was "
|
---|
| 259 | + _begDateCor + " " + _begTimeCor).toAscii());
|
---|
| 260 | _endCorrupt = true;
|
---|
| 261 | _begCorrupt = false;
|
---|
| 262 | _secFail = 0;
|
---|
| 263 | }
|
---|
| 264 | else {
|
---|
| 265 |
|
---|
| 266 | // Begin corrupt threshold
|
---|
| 267 | // -----------------------
|
---|
| 268 | if ( !_begCorrupt && _secFail > _adviseFail * 60 ) {
|
---|
| 269 | _begDateCor = _decodeSucc.toUTC().date().toString("yy-MM-dd");
|
---|
| 270 | _begTimeCor = _decodeSucc.toUTC().time().toString("hh:mm:ss");
|
---|
| 271 | emit(newMessage((_staID
|
---|
| 272 | + ": Failure threshold exceeded, corrupted since "
|
---|
| 273 | + _begDateCor + " " + _begTimeCor).toAscii(), true));
|
---|
| 274 | callScript(("Begin_Corrupted "
|
---|
| 275 | + _begDateCor + " " + _begTimeCor).toAscii());
|
---|
| 276 | _begCorrupt = true;
|
---|
| 277 | _endCorrupt = false;
|
---|
| 278 | _secSucc = 0;
|
---|
| 279 | _numSucc = 0;
|
---|
| 280 | }
|
---|
[1558] | 281 | }
|
---|
[1568] | 282 | _checkSeg = false;
|
---|
[1558] | 283 | }
|
---|
| 284 | }
|
---|
[1568] | 285 |
|
---|
[6758] | 286 | if (_fromReconnect) {
|
---|
| 287 | _decodeStart = QDateTime::currentDateTime();
|
---|
| 288 | }
|
---|
| 289 |
|
---|
[1558] | 290 | // End outage threshold
|
---|
| 291 | // --------------------
|
---|
[1568] | 292 | if ( _decodeStart.isValid() ) {
|
---|
| 293 | if ( _decodeStart.secsTo(QDateTime::currentDateTime()) > _adviseReco * 60 ) {
|
---|
| 294 | _decodeStart.setDate(QDate());
|
---|
| 295 | _decodeStart.setTime(QTime());
|
---|
| 296 | _endDateOut = QDateTime::currentDateTime()
|
---|
| 297 | .addSecs(- _adviseReco * 60)
|
---|
| 298 | .toUTC().date().toString("yy-MM-dd");
|
---|
| 299 | _endTimeOut = QDateTime::currentDateTime()
|
---|
| 300 | .addSecs(- _adviseReco * 60)
|
---|
| 301 | .toUTC().time().toString("hh:mm:ss");
|
---|
| 302 | emit(newMessage((_staID
|
---|
| 303 | + ": Recovery threshold exceeded, outage ended "
|
---|
| 304 | + _endDateOut + " " + _endTimeOut).toAscii(), true));
|
---|
| 305 | callScript(("End_Outage "
|
---|
| 306 | + _endDateOut + " " + _endTimeOut + " Begin was "
|
---|
| 307 | + _begDateOut + " " + _begTimeOut).toAscii());
|
---|
[1558] | 308 | }
|
---|
| 309 | }
|
---|
[6758] | 310 | _fromReconnect = false;
|
---|
[6638] | 311 | _decodeStop = QDateTime::currentDateTime();
|
---|
[1568] | 312 | }
|
---|
| 313 |
|
---|
[1562] | 314 | // Perform latency checks (observations)
|
---|
| 315 | //////////////////////////////////////////////////////////////////////////////
|
---|
[6137] | 316 | void latencyChecker::checkObsLatency(const QList<t_satObs>& obsList) {
|
---|
[1562] | 317 |
|
---|
[1978] | 318 | if (_perfIntr > 0 ) {
|
---|
[1558] | 319 |
|
---|
[6137] | 320 | QListIterator<t_satObs> it(obsList);
|
---|
[1978] | 321 | while (it.hasNext()) {
|
---|
[6137] | 322 | const t_satObs& obs = it.next();
|
---|
[1558] | 323 |
|
---|
[6137] | 324 | _newSecGPS = static_cast<int>(obs._time.gpssec());
|
---|
[1978] | 325 | if (_newSecGPS != _oldSecGPS) {
|
---|
| 326 | if (_newSecGPS % _perfIntr < _oldSecGPS % _perfIntr) {
|
---|
| 327 | if (_numLat > 0) {
|
---|
| 328 | if (_meanDiff > 0.0) {
|
---|
| 329 | if ( _checkMountPoint == _staID || _checkMountPoint == "ALL" ) {
|
---|
[1558] | 330 | emit( newMessage(QString("%1: Mean latency %2 sec, min %3, max %4, rms %5, %6 epochs, %7 gaps")
|
---|
| 331 | .arg(_staID.data())
|
---|
| 332 | .arg(int(_sumLat/_numLat*100)/100.)
|
---|
| 333 | .arg(int(_minLat*100)/100.)
|
---|
| 334 | .arg(int(_maxLat*100)/100.)
|
---|
| 335 | .arg(int((sqrt((_sumLatQ - _sumLat * _sumLat / _numLat)/_numLat))*100)/100.)
|
---|
| 336 | .arg(_numLat)
|
---|
| 337 | .arg(_numGaps)
|
---|
| 338 | .toAscii(), true) );
|
---|
[1978] | 339 | }
|
---|
| 340 | } else {
|
---|
| 341 | if ( _checkMountPoint == _staID || _checkMountPoint == "ALL" ) {
|
---|
[1558] | 342 | emit( newMessage(QString("%1: Mean latency %2 sec, min %3, max %4, rms %5, %6 epochs")
|
---|
| 343 | .arg(_staID.data())
|
---|
| 344 | .arg(int(_sumLat/_numLat*100)/100.)
|
---|
| 345 | .arg(int(_minLat*100)/100.)
|
---|
| 346 | .arg(int(_maxLat*100)/100.)
|
---|
| 347 | .arg(int((sqrt((_sumLatQ - _sumLat * _sumLat / _numLat)/_numLat))*100)/100.)
|
---|
| 348 | .arg(_numLat)
|
---|
| 349 | .toAscii(), true) );
|
---|
| 350 | }
|
---|
| 351 | }
|
---|
| 352 | }
|
---|
[1978] | 353 | _meanDiff = _diffSecGPS / _numLat;
|
---|
| 354 | _diffSecGPS = 0;
|
---|
| 355 | _numGaps = 0;
|
---|
| 356 | _sumLat = 0.0;
|
---|
| 357 | _sumLatQ = 0.0;
|
---|
| 358 | _numLat = 0;
|
---|
| 359 | _minLat = _maxDt;
|
---|
| 360 | _maxLat = -_maxDt;
|
---|
| 361 | }
|
---|
| 362 | if (_followSec) {
|
---|
| 363 | _diffSecGPS += _newSecGPS - _oldSecGPS;
|
---|
| 364 | if (_meanDiff>0.) {
|
---|
| 365 | if (_newSecGPS - _oldSecGPS > 1.5 * _meanDiff) {
|
---|
| 366 | _numGaps += 1;
|
---|
[1558] | 367 | }
|
---|
| 368 | }
|
---|
[1978] | 369 | }
|
---|
[1558] | 370 |
|
---|
[1978] | 371 | // Compute the observations latency
|
---|
| 372 | // --------------------------------
|
---|
[6137] | 373 | int week;
|
---|
| 374 | double sec;
|
---|
[1978] | 375 | currentGPSWeeks(week, sec);
|
---|
| 376 | const double secPerWeek = 7.0 * 24.0 * 3600.0;
|
---|
[6137] | 377 | if (week < int(obs._time.gpsw())) {
|
---|
[1978] | 378 | week += 1;
|
---|
| 379 | sec -= secPerWeek;
|
---|
[1558] | 380 | }
|
---|
[6137] | 381 | if (week > int(obs._time.gpsw())) {
|
---|
[1978] | 382 | week -= 1;
|
---|
| 383 | sec += secPerWeek;
|
---|
| 384 | }
|
---|
[6137] | 385 | _curLat = sec - obs._time.gpssec();
|
---|
[1978] | 386 | _sumLat += _curLat;
|
---|
| 387 | _sumLatQ += _curLat * _curLat;
|
---|
| 388 | if (_curLat < _minLat) {
|
---|
| 389 | _minLat = _curLat;
|
---|
| 390 | }
|
---|
| 391 | if (_curLat >= _maxLat) {
|
---|
| 392 | _maxLat = _curLat;
|
---|
| 393 | }
|
---|
| 394 | _numLat += 1;
|
---|
| 395 | _oldSecGPS = _newSecGPS;
|
---|
| 396 | _followSec = true;
|
---|
[1558] | 397 | }
|
---|
| 398 | }
|
---|
| 399 | }
|
---|
| 400 | }
|
---|
| 401 |
|
---|
[1562] | 402 | // Perform latency checks (corrections)
|
---|
| 403 | //////////////////////////////////////////////////////////////////////////////
|
---|
[1566] | 404 | void latencyChecker::checkCorrLatency(int corrGPSEpochTime) {
|
---|
[1562] | 405 |
|
---|
[1566] | 406 | if (corrGPSEpochTime < 0) {
|
---|
[1562] | 407 | return;
|
---|
| 408 | }
|
---|
| 409 |
|
---|
[1978] | 410 | if (_perfIntr > 0) {
|
---|
[1564] | 411 |
|
---|
[1978] | 412 | _newSecGPS = corrGPSEpochTime;
|
---|
[1564] | 413 |
|
---|
[1978] | 414 | int week;
|
---|
| 415 | double sec;
|
---|
| 416 | currentGPSWeeks(week, sec);
|
---|
| 417 | double dt = fabs(sec - _newSecGPS);
|
---|
| 418 | const double secPerWeek = 7.0 * 24.0 * 3600.0;
|
---|
| 419 | if (dt > 0.5 * secPerWeek) {
|
---|
| 420 | if (sec > _newSecGPS) {
|
---|
| 421 | sec -= secPerWeek;
|
---|
| 422 | } else {
|
---|
| 423 | sec += secPerWeek;
|
---|
[1566] | 424 | }
|
---|
[1978] | 425 | }
|
---|
| 426 | if (_newSecGPS != _oldSecGPS) {
|
---|
| 427 | if (int(_newSecGPS) % _perfIntr < int(_oldSecGPS) % _perfIntr) {
|
---|
| 428 | if (_numLat>0) {
|
---|
| 429 | QString late;
|
---|
| 430 | if (_meanDiff>0.) {
|
---|
| 431 | late = QString(": Mean latency %1 sec, min %2, max %3, rms %4, %5 epochs, %6 gaps")
|
---|
| 432 | .arg(int(_sumLat/_numLat*100)/100.)
|
---|
| 433 | .arg(int(_minLat*100)/100.)
|
---|
| 434 | .arg(int(_maxLat*100)/100.)
|
---|
| 435 | .arg(int((sqrt((_sumLatQ - _sumLat * _sumLat / _numLat)/_numLat))*100)/100.)
|
---|
| 436 | .arg(_numLat)
|
---|
| 437 | .arg(_numGaps);
|
---|
| 438 | if ( _checkMountPoint == _staID || _checkMountPoint == "ALL" ) {
|
---|
[1566] | 439 | emit(newMessage(QString(_staID + late ).toAscii(), true) );
|
---|
[1562] | 440 | }
|
---|
[1978] | 441 | }
|
---|
| 442 | else {
|
---|
| 443 | late = QString(": Mean latency %1 sec, min %2, max %3, rms %4, %5 epochs")
|
---|
| 444 | .arg(int(_sumLat/_numLat*100)/100.)
|
---|
| 445 | .arg(int(_minLat*100)/100.)
|
---|
| 446 | .arg(int(_maxLat*100)/100.)
|
---|
| 447 | .arg(int((sqrt((_sumLatQ - _sumLat * _sumLat / _numLat)/_numLat))*100)/100.)
|
---|
| 448 | .arg(_numLat);
|
---|
| 449 | if ( _checkMountPoint == _staID || _checkMountPoint == "ALL" ) {
|
---|
| 450 | emit(newMessage(QString(_staID + late ).toAscii(), true) );
|
---|
| 451 | }
|
---|
[1564] | 452 | }
|
---|
[1566] | 453 | }
|
---|
[1978] | 454 | _meanDiff = int(_diffSecGPS)/_numLat;
|
---|
| 455 | _diffSecGPS = 0;
|
---|
| 456 | _numGaps = 0;
|
---|
| 457 | _sumLat = 0.0;
|
---|
| 458 | _sumLatQ = 0.0;
|
---|
| 459 | _numLat = 0;
|
---|
| 460 | _minLat = 1000.;
|
---|
| 461 | _maxLat = -1000.;
|
---|
| 462 | }
|
---|
| 463 | if (_followSec) {
|
---|
| 464 | _diffSecGPS += _newSecGPS - _oldSecGPS;
|
---|
| 465 | if (_meanDiff>0.) {
|
---|
| 466 | if (_newSecGPS - _oldSecGPS > 1.5 * _meanDiff) {
|
---|
| 467 | _numGaps += 1;
|
---|
[1562] | 468 | }
|
---|
| 469 | }
|
---|
| 470 | }
|
---|
[1978] | 471 | _curLat = sec - _newSecGPS;
|
---|
| 472 | _sumLat += _curLat;
|
---|
| 473 | _sumLatQ += _curLat * _curLat;
|
---|
| 474 | if (_curLat < _minLat) {
|
---|
| 475 | _minLat = _curLat;
|
---|
| 476 | }
|
---|
| 477 | if (_curLat >= _maxLat) {
|
---|
| 478 | _maxLat = _curLat;
|
---|
| 479 | }
|
---|
| 480 | _numLat += 1;
|
---|
| 481 | _oldSecGPS = _newSecGPS;
|
---|
| 482 | _followSec = true;
|
---|
[1562] | 483 | }
|
---|
| 484 | }
|
---|
| 485 | }
|
---|
| 486 |
|
---|
[1558] | 487 | // Call advisory notice script
|
---|
| 488 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 489 | void latencyChecker::callScript(const char* comment) {
|
---|
| 490 | if (!_adviseScript.isEmpty()) {
|
---|
| 491 | #ifdef WIN32
|
---|
[1577] | 492 | Sleep(1);
|
---|
[1558] | 493 | QProcess::startDetached(_adviseScript, QStringList() << _staID << comment) ;
|
---|
| 494 | #else
|
---|
[1577] | 495 | sleep(1);
|
---|
[1558] | 496 | QProcess::startDetached("nohup", QStringList() << _adviseScript << _staID << comment) ;
|
---|
| 497 | #endif
|
---|
| 498 | }
|
---|
| 499 | }
|
---|