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