| 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: bncGetThread
|
|---|
| 30 | *
|
|---|
| 31 | * Purpose: Thread that retrieves data from NTRIP caster
|
|---|
| 32 | *
|
|---|
| 33 | * Author: L. Mervart
|
|---|
| 34 | *
|
|---|
| 35 | * Created: 24-Dec-2005
|
|---|
| 36 | *
|
|---|
| 37 | * Changes:
|
|---|
| 38 | *
|
|---|
| 39 | * -----------------------------------------------------------------------*/
|
|---|
| 40 |
|
|---|
| 41 | #include <stdlib.h>
|
|---|
| 42 | #include <iomanip>
|
|---|
| 43 | #include <sstream>
|
|---|
| 44 |
|
|---|
| 45 | #include <QFile>
|
|---|
| 46 | #include <QTextStream>
|
|---|
| 47 | #include <QtNetwork>
|
|---|
| 48 | #include <QTime>
|
|---|
| 49 |
|
|---|
| 50 | #include "bncgetthread.h"
|
|---|
| 51 | #include "bnctabledlg.h"
|
|---|
| 52 | #include "bncapp.h"
|
|---|
| 53 | #include "bncutils.h"
|
|---|
| 54 | #include "bncrinex.h"
|
|---|
| 55 | #include "bnczerodecoder.h"
|
|---|
| 56 | #include "bncnetqueryv1.h"
|
|---|
| 57 | #include "bncnetqueryv2.h"
|
|---|
| 58 | #include "bncnetqueryrtp.h"
|
|---|
| 59 |
|
|---|
| 60 | #include "RTCM/RTCM2Decoder.h"
|
|---|
| 61 | #include "RTCM3/RTCM3Decoder.h"
|
|---|
| 62 | #include "RTIGS/RTIGSDecoder.h"
|
|---|
| 63 | #include "GPSS/gpssDecoder.h"
|
|---|
| 64 | #include "serial/qextserialport.h"
|
|---|
| 65 |
|
|---|
| 66 | using namespace std;
|
|---|
| 67 |
|
|---|
| 68 | // Constructor 1
|
|---|
| 69 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 70 | bncGetThread::bncGetThread(const QByteArray& rawInpFileName,
|
|---|
| 71 | const QByteArray& format) {
|
|---|
| 72 |
|
|---|
| 73 | _format = format;
|
|---|
| 74 |
|
|---|
| 75 | int iSep = rawInpFileName.lastIndexOf(QDir::separator());
|
|---|
| 76 | _staID = rawInpFileName.mid(iSep+1,4);
|
|---|
| 77 |
|
|---|
| 78 | initialize();
|
|---|
| 79 |
|
|---|
| 80 | _inspSegm = 0;
|
|---|
| 81 |
|
|---|
| 82 | _rawInpFile = new QFile(rawInpFileName);
|
|---|
| 83 | _rawInpFile->open(QIODevice::ReadOnly);
|
|---|
| 84 |
|
|---|
| 85 | if (!_rnx) {
|
|---|
| 86 | cerr << "no RINEX path specified" << endl;
|
|---|
| 87 | ::exit(0);
|
|---|
| 88 | }
|
|---|
| 89 | }
|
|---|
| 90 |
|
|---|
| 91 | // Constructor 2
|
|---|
| 92 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 93 | bncGetThread::bncGetThread(const QUrl& mountPoint,
|
|---|
| 94 | const QByteArray& format,
|
|---|
| 95 | const QByteArray& latitude,
|
|---|
| 96 | const QByteArray& longitude,
|
|---|
| 97 | const QByteArray& nmea,
|
|---|
| 98 | const QByteArray& ntripVersion, int iMount) {
|
|---|
| 99 |
|
|---|
| 100 | setTerminationEnabled(true);
|
|---|
| 101 |
|
|---|
| 102 | _mountPoint = mountPoint;
|
|---|
| 103 | _staID = mountPoint.path().mid(1).toAscii();
|
|---|
| 104 | _format = format;
|
|---|
| 105 | _latitude = latitude;
|
|---|
| 106 | _longitude = longitude;
|
|---|
| 107 | _nmea = nmea;
|
|---|
| 108 | _ntripVersion = ntripVersion;
|
|---|
| 109 | _iMount = iMount; // index in mountpoints array
|
|---|
| 110 |
|
|---|
| 111 | initialize();
|
|---|
| 112 | }
|
|---|
| 113 |
|
|---|
| 114 | // Initialization
|
|---|
| 115 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 116 | void bncGetThread::initialize() {
|
|---|
| 117 |
|
|---|
| 118 |
|
|---|
| 119 | bncApp* app = (bncApp*) qApp;
|
|---|
| 120 | app->connect(this, SIGNAL(newMessage(QByteArray,bool)),
|
|---|
| 121 | app, SLOT(slotMessage(const QByteArray,bool)));
|
|---|
| 122 |
|
|---|
| 123 | _decoder = 0;
|
|---|
| 124 | _query = 0;
|
|---|
| 125 | _timeOut = 20*1000; // 20 seconds
|
|---|
| 126 | _nextSleep = 1; // 1 second
|
|---|
| 127 | _rawInpFile = 0;
|
|---|
| 128 | _rawOutFile = 0;
|
|---|
| 129 | _staID_orig = _staID;
|
|---|
| 130 |
|
|---|
| 131 | // Check name conflict
|
|---|
| 132 | // -------------------
|
|---|
| 133 | QSettings settings;
|
|---|
| 134 | QListIterator<QString> it(settings.value("mountPoints").toStringList());
|
|---|
| 135 | int num = 0;
|
|---|
| 136 | int ind = -1;
|
|---|
| 137 | while (it.hasNext()) {
|
|---|
| 138 | ++ind;
|
|---|
| 139 | QStringList hlp = it.next().split(" ");
|
|---|
| 140 | if (hlp.size() <= 1) continue;
|
|---|
| 141 | QUrl url(hlp[0]);
|
|---|
| 142 | if (_mountPoint.path() == url.path()) {
|
|---|
| 143 | if (_iMount > ind || _iMount < 0) {
|
|---|
| 144 | ++num;
|
|---|
| 145 | }
|
|---|
| 146 | }
|
|---|
| 147 | }
|
|---|
| 148 |
|
|---|
| 149 | if (num > 0) {
|
|---|
| 150 | _staID = _staID.left(_staID.length()-1) + QString("%1").arg(num).toAscii();
|
|---|
| 151 | }
|
|---|
| 152 |
|
|---|
| 153 | // Notice threshold
|
|---|
| 154 | // ----------------
|
|---|
| 155 | _inspSegm = 50;
|
|---|
| 156 | if ( settings.value("obsRate").toString().isEmpty() ) { _inspSegm = 0; }
|
|---|
| 157 | if ( settings.value("obsRate").toString().indexOf("5 Hz") != -1 ) { _inspSegm = 2; }
|
|---|
| 158 | if ( settings.value("obsRate").toString().indexOf("1 Hz") != -1 ) { _inspSegm = 10; }
|
|---|
| 159 | if ( settings.value("obsRate").toString().indexOf("0.5 Hz") != -1 ) { _inspSegm = 20; }
|
|---|
| 160 | if ( settings.value("obsRate").toString().indexOf("0.2 Hz") != -1 ) { _inspSegm = 40; }
|
|---|
| 161 | if ( settings.value("obsRate").toString().indexOf("0.1 Hz") != -1 ) { _inspSegm = 50; }
|
|---|
| 162 | _adviseFail = settings.value("adviseFail").toInt();
|
|---|
| 163 | _adviseReco = settings.value("adviseReco").toInt();
|
|---|
| 164 | _makePause = false;
|
|---|
| 165 | if ( Qt::CheckState(settings.value("makePause").toInt()) == Qt::Checked) {_makePause = true; }
|
|---|
| 166 | _adviseScript = settings.value("adviseScript").toString();
|
|---|
| 167 | expandEnvVar(_adviseScript);
|
|---|
| 168 |
|
|---|
| 169 | // Latency interval/average
|
|---|
| 170 | // ------------------------
|
|---|
| 171 | _perfIntr = 86400;
|
|---|
| 172 | if ( settings.value("perfIntr").toString().isEmpty() ) { _perfIntr = 0; }
|
|---|
| 173 | if ( settings.value("perfIntr").toString().indexOf("1 min") != -1 ) { _perfIntr = 60; }
|
|---|
| 174 | if ( settings.value("perfIntr").toString().indexOf("5 min") != -1 ) { _perfIntr = 300; }
|
|---|
| 175 | if ( settings.value("perfIntr").toString().indexOf("15 min") != -1 ) { _perfIntr = 900; }
|
|---|
| 176 | if ( settings.value("perfIntr").toString().indexOf("1 hour") != -1 ) { _perfIntr = 3600; }
|
|---|
| 177 | if ( settings.value("perfIntr").toString().indexOf("6 hours") != -1 ) { _perfIntr = 21600; }
|
|---|
| 178 | if ( settings.value("perfIntr").toString().indexOf("1 day") != -1 ) { _perfIntr = 86400; }
|
|---|
| 179 |
|
|---|
| 180 | // RTCM message types
|
|---|
| 181 | // ------------------
|
|---|
| 182 | _checkMountPoint = settings.value("miscMount").toString();
|
|---|
| 183 |
|
|---|
| 184 | // RINEX writer
|
|---|
| 185 | // ------------
|
|---|
| 186 | _samplingRate = settings.value("rnxSampl").toInt();
|
|---|
| 187 | if ( settings.value("rnxPath").toString().isEmpty() ) {
|
|---|
| 188 | _rnx = 0;
|
|---|
| 189 | }
|
|---|
| 190 | else {
|
|---|
| 191 | _rnx = new bncRinex(_staID, _mountPoint, _format, _latitude,
|
|---|
| 192 | _longitude, _nmea);
|
|---|
| 193 | }
|
|---|
| 194 | _rnx_set_position = false;
|
|---|
| 195 |
|
|---|
| 196 | connect(((bncApp*)qApp), SIGNAL(newEphGPS(gpsephemeris)),
|
|---|
| 197 | this, SLOT(slotNewEphGPS(gpsephemeris)));
|
|---|
| 198 |
|
|---|
| 199 | if (settings.value("serialMountPoint").toString() == _staID) {
|
|---|
| 200 | _serialPort = new QextSerialPort(
|
|---|
| 201 | settings.value("serialPortName").toString() );
|
|---|
| 202 | QString hlp = settings.value("serialBaudRate").toString();
|
|---|
| 203 | if (hlp == "110") {
|
|---|
| 204 | _serialPort->setBaudRate(BAUD110);
|
|---|
| 205 | }
|
|---|
| 206 | else if (hlp == "300") {
|
|---|
| 207 | _serialPort->setBaudRate(BAUD300);
|
|---|
| 208 | }
|
|---|
| 209 | else if (hlp == "600") {
|
|---|
| 210 | _serialPort->setBaudRate(BAUD600);
|
|---|
| 211 | }
|
|---|
| 212 | else if (hlp == "1200") {
|
|---|
| 213 | _serialPort->setBaudRate(BAUD1200);
|
|---|
| 214 | }
|
|---|
| 215 | else if (hlp == "2400") {
|
|---|
| 216 | _serialPort->setBaudRate(BAUD2400);
|
|---|
| 217 | }
|
|---|
| 218 | else if (hlp == "4800") {
|
|---|
| 219 | _serialPort->setBaudRate(BAUD4800);
|
|---|
| 220 | }
|
|---|
| 221 | else if (hlp == "9600") {
|
|---|
| 222 | _serialPort->setBaudRate(BAUD9600);
|
|---|
| 223 | }
|
|---|
| 224 | else if (hlp == "19200") {
|
|---|
| 225 | _serialPort->setBaudRate(BAUD19200);
|
|---|
| 226 | }
|
|---|
| 227 | else if (hlp == "38400") {
|
|---|
| 228 | _serialPort->setBaudRate(BAUD38400);
|
|---|
| 229 | }
|
|---|
| 230 | else if (hlp == "57600") {
|
|---|
| 231 | _serialPort->setBaudRate(BAUD57600);
|
|---|
| 232 | }
|
|---|
| 233 | else if (hlp == "115200") {
|
|---|
| 234 | _serialPort->setBaudRate(BAUD115200);
|
|---|
| 235 | }
|
|---|
| 236 | hlp = settings.value("serialParity").toString();
|
|---|
| 237 | if (hlp == "NONE") {
|
|---|
| 238 | _serialPort->setParity(PAR_NONE);
|
|---|
| 239 | }
|
|---|
| 240 | else if (hlp == "ODD") {
|
|---|
| 241 | _serialPort->setParity(PAR_ODD);
|
|---|
| 242 | }
|
|---|
| 243 | else if (hlp == "EVEN") {
|
|---|
| 244 | _serialPort->setParity(PAR_EVEN);
|
|---|
| 245 | }
|
|---|
| 246 | else if (hlp == "SPACE") {
|
|---|
| 247 | _serialPort->setParity(PAR_SPACE);
|
|---|
| 248 | }
|
|---|
| 249 | hlp = settings.value("serialDataBits").toString();
|
|---|
| 250 | if (hlp == "5") {
|
|---|
| 251 | _serialPort->setDataBits(DATA_5);
|
|---|
| 252 | }
|
|---|
| 253 | else if (hlp == "6") {
|
|---|
| 254 | _serialPort->setDataBits(DATA_6);
|
|---|
| 255 | }
|
|---|
| 256 | else if (hlp == "7") {
|
|---|
| 257 | _serialPort->setDataBits(DATA_7);
|
|---|
| 258 | }
|
|---|
| 259 | else if (hlp == "8") {
|
|---|
| 260 | _serialPort->setDataBits(DATA_8);
|
|---|
| 261 | }
|
|---|
| 262 | hlp = settings.value("serialStopBits").toString();
|
|---|
| 263 | if (hlp == "1") {
|
|---|
| 264 | _serialPort->setStopBits(STOP_1);
|
|---|
| 265 | }
|
|---|
| 266 | else if (hlp == "2") {
|
|---|
| 267 | _serialPort->setStopBits(STOP_2);
|
|---|
| 268 | }
|
|---|
| 269 | _serialPort->open(QIODevice::ReadWrite|QIODevice::Unbuffered);
|
|---|
| 270 | if (!_serialPort->isOpen()) {
|
|---|
| 271 | delete _serialPort;
|
|---|
| 272 | _serialPort = 0;
|
|---|
| 273 | emit(newMessage((_staID + ": Cannot Open Serial Port\n"), true));
|
|---|
| 274 | }
|
|---|
| 275 | }
|
|---|
| 276 | else {
|
|---|
| 277 | _serialPort = 0;
|
|---|
| 278 | }
|
|---|
| 279 |
|
|---|
| 280 | // Raw Output
|
|---|
| 281 | // ----------
|
|---|
| 282 | // QByteArray rawOutFileName = "./" + _staID + ".raw";
|
|---|
| 283 | // _rawOutFile = new QFile(rawOutFileName);
|
|---|
| 284 | // _rawOutFile->open(QIODevice::WriteOnly);
|
|---|
| 285 |
|
|---|
| 286 | msleep(100); //sleep 0.1 sec
|
|---|
| 287 | }
|
|---|
| 288 |
|
|---|
| 289 | // Destructor
|
|---|
| 290 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 291 | bncGetThread::~bncGetThread() {
|
|---|
| 292 | if (_query) {
|
|---|
| 293 | _query->deleteLater();
|
|---|
| 294 | }
|
|---|
| 295 | delete _decoder;
|
|---|
| 296 | delete _rnx;
|
|---|
| 297 | delete _rawInpFile;
|
|---|
| 298 | delete _rawOutFile;
|
|---|
| 299 | delete _serialPort;
|
|---|
| 300 | }
|
|---|
| 301 |
|
|---|
| 302 | //
|
|---|
| 303 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 304 | void bncGetThread::terminate() {
|
|---|
| 305 | if (_query) {
|
|---|
| 306 | _query->stop();
|
|---|
| 307 | }
|
|---|
| 308 | QThread::terminate();
|
|---|
| 309 | wait(2000);
|
|---|
| 310 | }
|
|---|
| 311 |
|
|---|
| 312 | // Init Run
|
|---|
| 313 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 314 | t_irc bncGetThread::initRun() {
|
|---|
| 315 |
|
|---|
| 316 | if (!_rawInpFile) {
|
|---|
| 317 | delete _query;
|
|---|
| 318 | if (_ntripVersion == "R") {
|
|---|
| 319 | _query = new bncNetQueryRtp();
|
|---|
| 320 | }
|
|---|
| 321 | else if (_ntripVersion == "2") {
|
|---|
| 322 | _query = new bncNetQueryV2();
|
|---|
| 323 | }
|
|---|
| 324 | else {
|
|---|
| 325 | _query = new bncNetQueryV1();
|
|---|
| 326 | }
|
|---|
| 327 | if (_nmea == "yes") {
|
|---|
| 328 | QByteArray gga = ggaString(_latitude, _longitude);
|
|---|
| 329 | _query->startRequest(_mountPoint, gga);
|
|---|
| 330 | }
|
|---|
| 331 | else {
|
|---|
| 332 | _query->startRequest(_mountPoint, "");
|
|---|
| 333 | }
|
|---|
| 334 | }
|
|---|
| 335 |
|
|---|
| 336 | // Instantiate the filter
|
|---|
| 337 | // ----------------------
|
|---|
| 338 | if (!_decoder) {
|
|---|
| 339 | if (_format.indexOf("RTCM_2") != -1) {
|
|---|
| 340 | emit(newMessage("Get Data: " + _staID + " in RTCM 2.x format", true));
|
|---|
| 341 | _decoder = new RTCM2Decoder(_staID.data());
|
|---|
| 342 | }
|
|---|
| 343 | else if (_format.indexOf("RTCM_3") != -1) {
|
|---|
| 344 | emit(newMessage("Get Data: " + _staID + " in RTCM 3.x format", true));
|
|---|
| 345 | _decoder = new RTCM3Decoder(_staID);
|
|---|
| 346 | connect((RTCM3Decoder*) _decoder, SIGNAL(newMessage(QByteArray,bool)),
|
|---|
| 347 | this, SIGNAL(newMessage(QByteArray,bool)));
|
|---|
| 348 | }
|
|---|
| 349 | else if (_format.indexOf("RTIGS") != -1) {
|
|---|
| 350 | emit(newMessage("Get Data: " + _staID + " in RTIGS format", true));
|
|---|
| 351 | _decoder = new RTIGSDecoder();
|
|---|
| 352 | }
|
|---|
| 353 | else if (_format.indexOf("GPSS") != -1 || _format.indexOf("BNC") != -1) {
|
|---|
| 354 | emit(newMessage("Get Data: " + _staID + " in GPSS format", true));
|
|---|
| 355 | _decoder = new gpssDecoder();
|
|---|
| 356 | }
|
|---|
| 357 | else if (_format.indexOf("ZERO") != -1) {
|
|---|
| 358 | emit(newMessage("Get Data: " + _staID + " in original format", true));
|
|---|
| 359 | _decoder = new bncZeroDecoder(_staID);
|
|---|
| 360 | }
|
|---|
| 361 | else {
|
|---|
| 362 | emit(newMessage(_staID + ": Unknown data format " + _format, true));
|
|---|
| 363 | if (_rawInpFile) {
|
|---|
| 364 | cerr << "Uknown data format" << endl;
|
|---|
| 365 | ::exit(0);
|
|---|
| 366 | }
|
|---|
| 367 | else {
|
|---|
| 368 | return fatal;
|
|---|
| 369 | }
|
|---|
| 370 | }
|
|---|
| 371 | }
|
|---|
| 372 | return success;
|
|---|
| 373 | }
|
|---|
| 374 |
|
|---|
| 375 | // Run
|
|---|
| 376 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 377 | void bncGetThread::run() {
|
|---|
| 378 |
|
|---|
| 379 | const double maxDt = 600.0; // Check observation epoch
|
|---|
| 380 | bool wrongEpoch = false;
|
|---|
| 381 | bool decode = true;
|
|---|
| 382 | int numSucc = 0;
|
|---|
| 383 | int secSucc = 0;
|
|---|
| 384 | int secFail = 0;
|
|---|
| 385 | int initPause = 30; // Initial pause for corrupted streams
|
|---|
| 386 | int currPause = 0;
|
|---|
| 387 | bool begCorrupt = false;
|
|---|
| 388 | bool endCorrupt = false;
|
|---|
| 389 | bool followSec = false;
|
|---|
| 390 | int oldSecGPS= 0;
|
|---|
| 391 | int newSecGPS = 0;
|
|---|
| 392 | int numGaps = 0;
|
|---|
| 393 | int diffSecGPS = 0;
|
|---|
| 394 | int numLat = 0;
|
|---|
| 395 | double sumLat = 0.;
|
|---|
| 396 | double sumLatQ = 0.;
|
|---|
| 397 | double meanDiff = 0.;
|
|---|
| 398 | double minLat = maxDt;
|
|---|
| 399 | double maxLat = -maxDt;
|
|---|
| 400 | double curLat = 0.;
|
|---|
| 401 |
|
|---|
| 402 | _decodeTime = QDateTime::currentDateTime();
|
|---|
| 403 | _decodeSucc = QDateTime::currentDateTime();
|
|---|
| 404 | t_irc irc = initRun();
|
|---|
| 405 |
|
|---|
| 406 | if (irc == fatal) {
|
|---|
| 407 | QThread::exit(1);
|
|---|
| 408 | return;
|
|---|
| 409 | }
|
|---|
| 410 | else if (irc != success) {
|
|---|
| 411 | emit(newMessage(_staID + ": initRun failed, reconnecting", true));
|
|---|
| 412 | tryReconnect();
|
|---|
| 413 | }
|
|---|
| 414 |
|
|---|
| 415 | if (initPause < _inspSegm) {
|
|---|
| 416 | initPause = _inspSegm;
|
|---|
| 417 | }
|
|---|
| 418 | if(!_makePause) {initPause = 0;}
|
|---|
| 419 | currPause = initPause;
|
|---|
| 420 |
|
|---|
| 421 | // Read Incoming Data
|
|---|
| 422 | // ------------------
|
|---|
| 423 | while (true) {
|
|---|
| 424 | try {
|
|---|
| 425 | if (_query && _query->status() != bncNetQuery::running) {
|
|---|
| 426 | emit(newMessage(_staID + ": Internet query not running, reconnecting", true));
|
|---|
| 427 | tryReconnect();
|
|---|
| 428 | }
|
|---|
| 429 |
|
|---|
| 430 | QListIterator<p_obs> it(_decoder->_obsList);
|
|---|
| 431 | while (it.hasNext()) {
|
|---|
| 432 | delete it.next();
|
|---|
| 433 | }
|
|---|
| 434 | _decoder->_obsList.clear();
|
|---|
| 435 |
|
|---|
| 436 | qint64 nBytes = 0;
|
|---|
| 437 |
|
|---|
| 438 | QByteArray data;
|
|---|
| 439 |
|
|---|
| 440 | if (_query) {
|
|---|
| 441 | _query->waitForReadyRead(data);
|
|---|
| 442 | nBytes = data.size();
|
|---|
| 443 | }
|
|---|
| 444 | else if (_rawInpFile) {
|
|---|
| 445 | const qint64 maxBytes = 1024;
|
|---|
| 446 | nBytes = maxBytes;
|
|---|
| 447 | }
|
|---|
| 448 |
|
|---|
| 449 | if (nBytes > 0) {
|
|---|
| 450 | emit newBytes(_staID, nBytes);
|
|---|
| 451 |
|
|---|
| 452 | if (_rawInpFile) {
|
|---|
| 453 | data = _rawInpFile->read(nBytes);
|
|---|
| 454 | if (data.isEmpty()) {
|
|---|
| 455 | cout << "no more data" << endl;
|
|---|
| 456 | ::exit(0);
|
|---|
| 457 | }
|
|---|
| 458 | }
|
|---|
| 459 |
|
|---|
| 460 | if (_rawOutFile) {
|
|---|
| 461 | _rawOutFile->write(data);
|
|---|
| 462 | _rawOutFile->flush();
|
|---|
| 463 | }
|
|---|
| 464 |
|
|---|
| 465 | if (_serialPort) {
|
|---|
| 466 | _serialPort->write(data);
|
|---|
| 467 | }
|
|---|
| 468 |
|
|---|
| 469 | if (_inspSegm<1) {
|
|---|
| 470 | vector<string> errmsg;
|
|---|
| 471 | _decoder->Decode(data.data(), data.size(), errmsg);
|
|---|
| 472 | #ifdef DEBUG_RTCM2_2021
|
|---|
| 473 | for (unsigned ii = 0; ii < errmsg.size(); ii++) {
|
|---|
| 474 | emit newMessage(_staID + ": " + errmsg[ii].c_str(), false);
|
|---|
| 475 | }
|
|---|
| 476 | #endif
|
|---|
| 477 | }
|
|---|
| 478 | else {
|
|---|
| 479 |
|
|---|
| 480 | // Decode data
|
|---|
| 481 | // -----------
|
|---|
| 482 | if (!_decodePause.isValid() ||
|
|---|
| 483 | _decodePause.secsTo(QDateTime::currentDateTime()) >= currPause ) {
|
|---|
| 484 |
|
|---|
| 485 | if (decode) {
|
|---|
| 486 | vector<string> errmsg;
|
|---|
| 487 | if ( _decoder->Decode(data.data(), data.size(), errmsg) == success ) {
|
|---|
| 488 | numSucc += 1;
|
|---|
| 489 | }
|
|---|
| 490 | if ( _decodeTime.secsTo(QDateTime::currentDateTime()) > _inspSegm ) {
|
|---|
| 491 | decode = false;
|
|---|
| 492 | }
|
|---|
| 493 | #ifdef DEBUG_RTCM2_2021
|
|---|
| 494 | for (unsigned ii = 0; ii < errmsg.size(); ii++) {
|
|---|
| 495 | emit newMessage(_staID + ": " + errmsg[ii].c_str(), false);
|
|---|
| 496 | }
|
|---|
| 497 | #endif
|
|---|
| 498 | }
|
|---|
| 499 |
|
|---|
| 500 | // Check - once per inspect segment
|
|---|
| 501 | // --------------------------------
|
|---|
| 502 | if (!decode) {
|
|---|
| 503 | _decodeTime = QDateTime::currentDateTime();
|
|---|
| 504 | if (numSucc>0) {
|
|---|
| 505 | secSucc += _inspSegm;
|
|---|
| 506 | _decodeSucc = QDateTime::currentDateTime();
|
|---|
| 507 | if (secSucc > _adviseReco * 60) {
|
|---|
| 508 | secSucc = _adviseReco * 60 + 1;
|
|---|
| 509 | }
|
|---|
| 510 | numSucc = 0;
|
|---|
| 511 | currPause = initPause;
|
|---|
| 512 | _decodePause.setDate(QDate());
|
|---|
| 513 | _decodePause.setTime(QTime());
|
|---|
| 514 | }
|
|---|
| 515 | else {
|
|---|
| 516 | secFail += _inspSegm;
|
|---|
| 517 | secSucc = 0;
|
|---|
| 518 | if (secFail > _adviseFail * 60) {
|
|---|
| 519 | secFail = _adviseFail * 60 + 1;
|
|---|
| 520 | }
|
|---|
| 521 | if (!_decodePause.isValid() || !_makePause) {
|
|---|
| 522 | _decodePause = QDateTime::currentDateTime();
|
|---|
| 523 | }
|
|---|
| 524 | else {
|
|---|
| 525 | _decodePause.setDate(QDate());
|
|---|
| 526 | _decodePause.setTime(QTime());
|
|---|
| 527 | secFail = secFail + currPause - _inspSegm;
|
|---|
| 528 | currPause = currPause * 2;
|
|---|
| 529 | if (currPause > 960) {
|
|---|
| 530 | currPause = 960;
|
|---|
| 531 | }
|
|---|
| 532 | }
|
|---|
| 533 | }
|
|---|
| 534 |
|
|---|
| 535 | // End corrupt threshold
|
|---|
| 536 | // ---------------------
|
|---|
| 537 | if ( begCorrupt && !endCorrupt && secSucc > _adviseReco * 60 ) {
|
|---|
| 538 | _endDateCor = QDateTime::currentDateTime().addSecs(- _adviseReco * 60).toUTC().date().toString("yy-MM-dd");
|
|---|
| 539 | _endTimeCor = QDateTime::currentDateTime().addSecs(- _adviseReco * 60).toUTC().time().toString("hh:mm:ss");
|
|---|
| 540 | emit(newMessage((_staID + ": Recovery threshold exceeded, corruption ended "
|
|---|
| 541 | + _endDateCor + " " + _endTimeCor).toAscii(), true));
|
|---|
| 542 | callScript(("End_Corrupted " + _endDateCor + " " + _endTimeCor + " Begin was " + _begDateCor + " " + _begTimeCor).toAscii());
|
|---|
| 543 | endCorrupt = true;
|
|---|
| 544 | begCorrupt = false;
|
|---|
| 545 | secFail = 0;
|
|---|
| 546 | }
|
|---|
| 547 | else {
|
|---|
| 548 |
|
|---|
| 549 | // Begin corrupt threshold
|
|---|
| 550 | // -----------------------
|
|---|
| 551 | if ( !begCorrupt && secFail > _adviseFail * 60 ) {
|
|---|
| 552 | _begDateCor = _decodeSucc.toUTC().date().toString("yy-MM-dd");
|
|---|
| 553 | _begTimeCor = _decodeSucc.toUTC().time().toString("hh:mm:ss");
|
|---|
| 554 | emit(newMessage((_staID + ": Failure threshold exceeded, corrupted since "
|
|---|
| 555 | + _begDateCor + " " + _begTimeCor).toAscii(), true));
|
|---|
| 556 | callScript(("Begin_Corrupted " + _begDateCor + " " + _begTimeCor).toAscii());
|
|---|
| 557 | begCorrupt = true;
|
|---|
| 558 | endCorrupt = false;
|
|---|
| 559 | secSucc = 0;
|
|---|
| 560 | numSucc = 0;
|
|---|
| 561 | }
|
|---|
| 562 | }
|
|---|
| 563 | decode = true;
|
|---|
| 564 | }
|
|---|
| 565 | }
|
|---|
| 566 | }
|
|---|
| 567 |
|
|---|
| 568 | // End outage threshold
|
|---|
| 569 | // --------------------
|
|---|
| 570 | if ( _decodeStart.isValid() && _decodeStart.secsTo(QDateTime::currentDateTime()) > _adviseReco * 60 ) {
|
|---|
| 571 | _decodeStart.setDate(QDate());
|
|---|
| 572 | _decodeStart.setTime(QTime());
|
|---|
| 573 | if (_inspSegm>0) {
|
|---|
| 574 | _endDateOut = QDateTime::currentDateTime().addSecs(- _adviseReco * 60).toUTC().date().toString("yy-MM-dd");
|
|---|
| 575 | _endTimeOut = QDateTime::currentDateTime().addSecs(- _adviseReco * 60).toUTC().time().toString("hh:mm:ss");
|
|---|
| 576 | emit(newMessage((_staID + ": Recovery threshold exceeded, outage ended "
|
|---|
| 577 | + _endDateOut + " " + _endTimeOut).toAscii(), true));
|
|---|
| 578 | callScript(("End_Outage " + _endDateOut + " " + _endTimeOut + " Begin was " + _begDateOut + " " + _begTimeOut).toAscii());
|
|---|
| 579 | }
|
|---|
| 580 | }
|
|---|
| 581 |
|
|---|
| 582 | // RTCM scan output
|
|---|
| 583 | // ----------------
|
|---|
| 584 | if ( _checkMountPoint == _staID || _checkMountPoint == "ALL" ) {
|
|---|
| 585 | QSettings settings;
|
|---|
| 586 | if ( Qt::CheckState(settings.value("scanRTCM").toInt()) == Qt::Checked) {
|
|---|
| 587 |
|
|---|
| 588 | // RTCMv3 message types
|
|---|
| 589 | // --------------------
|
|---|
| 590 | if (0<_decoder->_typeList.size()) {
|
|---|
| 591 | QString type;
|
|---|
| 592 | for (int ii=0;ii<_decoder->_typeList.size();ii++) {
|
|---|
| 593 | type = QString("%1 ").arg(_decoder->_typeList[ii]);
|
|---|
| 594 | emit(newMessage(_staID + ": Received message type " + type.toAscii(), true));
|
|---|
| 595 | }
|
|---|
| 596 | }
|
|---|
| 597 |
|
|---|
| 598 | // RTCMv3 antenna descriptor
|
|---|
| 599 | // -------------------------
|
|---|
| 600 | if (0<_decoder->_antType.size()) {
|
|---|
| 601 | QString ant1;
|
|---|
| 602 | for (int ii=0;ii<_decoder->_antType.size();ii++) {
|
|---|
| 603 | ant1 = QString("%1 ").arg(_decoder->_antType[ii]);
|
|---|
| 604 | emit(newMessage(_staID + ": Antenna descriptor " + ant1.toAscii(), true));
|
|---|
| 605 | }
|
|---|
| 606 | }
|
|---|
| 607 | }
|
|---|
| 608 | }
|
|---|
| 609 |
|
|---|
| 610 | // Antenna Coordinates
|
|---|
| 611 | // -------------------
|
|---|
| 612 | for (int ii=0; ii <_decoder->_antList.size(); ii++) {
|
|---|
| 613 | QByteArray antT;
|
|---|
| 614 | if (_decoder->_antList[ii].type == GPSDecoder::t_antInfo::ARP) {
|
|---|
| 615 | antT = "ARP";
|
|---|
| 616 | }
|
|---|
| 617 | else if (_decoder->_antList[ii].type == GPSDecoder::t_antInfo::APC) {
|
|---|
| 618 | antT = "APC";
|
|---|
| 619 | }
|
|---|
| 620 | emit(newAntCrd(_staID, _decoder->_antList[ii].xx,
|
|---|
| 621 | _decoder->_antList[ii].yy, _decoder->_antList[ii].zz,
|
|---|
| 622 | antT));
|
|---|
| 623 | }
|
|---|
| 624 |
|
|---|
| 625 | _decoder->_typeList.clear();
|
|---|
| 626 | _decoder->_antType.clear();
|
|---|
| 627 | _decoder->_antList.clear();
|
|---|
| 628 |
|
|---|
| 629 | // Loop over all observations (observations output)
|
|---|
| 630 | // ------------------------------------------------
|
|---|
| 631 | QListIterator<p_obs> it(_decoder->_obsList);
|
|---|
| 632 | while (it.hasNext()) {
|
|---|
| 633 | p_obs obs = it.next();
|
|---|
| 634 |
|
|---|
| 635 | // Check observation epoch
|
|---|
| 636 | // -----------------------
|
|---|
| 637 | if (!_rawInpFile && !dynamic_cast<gpssDecoder*>(_decoder)) {
|
|---|
| 638 | int week;
|
|---|
| 639 | double sec;
|
|---|
| 640 | currentGPSWeeks(week, sec);
|
|---|
| 641 | const double secPerWeek = 7.0 * 24.0 * 3600.0;
|
|---|
| 642 |
|
|---|
| 643 | if (week < obs->_o.GPSWeek) {
|
|---|
| 644 | week += 1;
|
|---|
| 645 | sec -= secPerWeek;
|
|---|
| 646 | }
|
|---|
| 647 | if (week > obs->_o.GPSWeek) {
|
|---|
| 648 | week -= 1;
|
|---|
| 649 | sec += secPerWeek;
|
|---|
| 650 | }
|
|---|
| 651 | double dt = fabs(sec - obs->_o.GPSWeeks);
|
|---|
| 652 | if (week != obs->_o.GPSWeek || dt > maxDt) {
|
|---|
| 653 | if (!wrongEpoch) {
|
|---|
| 654 | emit( newMessage(_staID + ": Wrong observation epoch(s)", true) );
|
|---|
| 655 | wrongEpoch = true;
|
|---|
| 656 | }
|
|---|
| 657 | delete obs;
|
|---|
| 658 | continue;
|
|---|
| 659 | }
|
|---|
| 660 | else {
|
|---|
| 661 | wrongEpoch = false;
|
|---|
| 662 |
|
|---|
| 663 | // Latency and completeness
|
|---|
| 664 | // ------------------------
|
|---|
| 665 | if (_perfIntr>0) {
|
|---|
| 666 | if ( _checkMountPoint == _staID || _checkMountPoint == "ALL" ) {
|
|---|
| 667 | newSecGPS = static_cast<int>(obs->_o.GPSWeeks);
|
|---|
| 668 | if (newSecGPS != oldSecGPS) {
|
|---|
| 669 | if (newSecGPS % _perfIntr < oldSecGPS % _perfIntr) {
|
|---|
| 670 | if (numLat>0) {
|
|---|
| 671 | if (meanDiff>0.) {
|
|---|
| 672 | emit( newMessage(QString("%1: Mean latency %2 sec, min %3, max %4, rms %5, %6 epochs, %7 gaps")
|
|---|
| 673 | .arg(_staID.data())
|
|---|
| 674 | .arg(int(sumLat/numLat*100)/100.)
|
|---|
| 675 | .arg(int(minLat*100)/100.)
|
|---|
| 676 | .arg(int(maxLat*100)/100.)
|
|---|
| 677 | .arg(int((sqrt((sumLatQ - sumLat * sumLat / numLat)/numLat))*100)/100.)
|
|---|
| 678 | .arg(numLat)
|
|---|
| 679 | .arg(numGaps)
|
|---|
| 680 | .toAscii(), true) );
|
|---|
| 681 | } else {
|
|---|
| 682 | emit( newMessage(QString("%1: Mean latency %2 sec, min %3, max %4, rms %5, %6 epochs")
|
|---|
| 683 | .arg(_staID.data())
|
|---|
| 684 | .arg(int(sumLat/numLat*100)/100.)
|
|---|
| 685 | .arg(int(minLat*100)/100.)
|
|---|
| 686 | .arg(int(maxLat*100)/100.)
|
|---|
| 687 | .arg(int((sqrt((sumLatQ - sumLat * sumLat / numLat)/numLat))*100)/100.)
|
|---|
| 688 | .arg(numLat)
|
|---|
| 689 | .toAscii(), true) );
|
|---|
| 690 | }
|
|---|
| 691 | }
|
|---|
| 692 | meanDiff = diffSecGPS/numLat;
|
|---|
| 693 | diffSecGPS = 0;
|
|---|
| 694 | numGaps = 0;
|
|---|
| 695 | sumLat = 0.;
|
|---|
| 696 | sumLatQ = 0.;
|
|---|
| 697 | numLat = 0;
|
|---|
| 698 | minLat = maxDt;
|
|---|
| 699 | maxLat = -maxDt;
|
|---|
| 700 | }
|
|---|
| 701 | if (followSec) {
|
|---|
| 702 | diffSecGPS += newSecGPS - oldSecGPS;
|
|---|
| 703 | if (meanDiff>0.) {
|
|---|
| 704 | if (newSecGPS - oldSecGPS > 1.5 * meanDiff) {
|
|---|
| 705 | numGaps += 1;
|
|---|
| 706 | }
|
|---|
| 707 | }
|
|---|
| 708 | }
|
|---|
| 709 | curLat = sec - obs->_o.GPSWeeks;
|
|---|
| 710 | sumLat += curLat;
|
|---|
| 711 | sumLatQ += curLat * curLat;
|
|---|
| 712 | if (curLat < minLat) minLat = curLat;
|
|---|
| 713 | if (curLat >= maxLat) maxLat = curLat;
|
|---|
| 714 | numLat += 1;
|
|---|
| 715 | oldSecGPS = newSecGPS;
|
|---|
| 716 | followSec = true;
|
|---|
| 717 | }
|
|---|
| 718 | }
|
|---|
| 719 | }
|
|---|
| 720 | }
|
|---|
| 721 | }
|
|---|
| 722 |
|
|---|
| 723 | // RINEX Output
|
|---|
| 724 | // ------------
|
|---|
| 725 | if (_rnx) {
|
|---|
| 726 | bool dump = true;
|
|---|
| 727 |
|
|---|
| 728 | //// // RTCMv2 XYZ
|
|---|
| 729 | //// // ----------
|
|---|
| 730 | //// RTCM2Decoder* decoder2 = dynamic_cast<RTCM2Decoder*>(_decoder);
|
|---|
| 731 | //// if ( decoder2 && !_rnx_set_position ) {
|
|---|
| 732 | //// double stax, stay, staz;
|
|---|
| 733 | //// double dL1[3], dL2[3];
|
|---|
| 734 | //// if ( decoder2->getStaCrd(stax, stay, staz,
|
|---|
| 735 | //// dL1[0], dL1[1], dL1[2],
|
|---|
| 736 | //// dL2[0], dL2[1], dL2[2]) == success ) {
|
|---|
| 737 | ////
|
|---|
| 738 | //// if ( _checkMountPoint == _staID || _checkMountPoint == "ALL" ) {
|
|---|
| 739 | //// QString ant1;
|
|---|
| 740 | //// ant1 = QString("%1 ").arg(stax,0,'f',4);
|
|---|
| 741 | //// emit(newMessage(_staID + ": ARP X " + ant1.toAscii() + "m" ));
|
|---|
| 742 | //// ant1 = QString("%1 ").arg(stay,0,'f',4);
|
|---|
| 743 | //// emit(newMessage(_staID + ": ARP Y " + ant1.toAscii() + "m" ));
|
|---|
| 744 | //// ant1 = QString("%1 ").arg(staz,0,'f',4);
|
|---|
| 745 | //// emit(newMessage(_staID + ": ARP Z " + ant1.toAscii() + "m" ));
|
|---|
| 746 | //// ant1 = QString("%1 ").arg(dL1[0],0,'f',4);
|
|---|
| 747 | //// emit(newMessage(_staID + ": L1 APC DX " + ant1.toAscii() + "m" ));
|
|---|
| 748 | //// ant1 = QString("%1 ").arg(dL1[1],0,'f',4);
|
|---|
| 749 | //// emit(newMessage(_staID + ": L1 APC DY " + ant1.toAscii() + "m" ));
|
|---|
| 750 | //// ant1 = QString("%1 ").arg(dL1[2],0,'f',4);
|
|---|
| 751 | //// emit(newMessage(_staID + ": L1 APC DZ " + ant1.toAscii() + "m" ));
|
|---|
| 752 | //// ant1 = QString("%1 ").arg(dL2[0],0,'f',4);
|
|---|
| 753 | //// emit(newMessage(_staID + ": L2 APC DX " + ant1.toAscii() + "m" ));
|
|---|
| 754 | //// ant1 = QString("%1 ").arg(dL2[1],0,'f',4);
|
|---|
| 755 | //// emit(newMessage(_staID + ": L2 APC DY " + ant1.toAscii() + "m" ));
|
|---|
| 756 | //// ant1 = QString("%1 ").arg(dL2[2],0,'f',4);
|
|---|
| 757 | //// emit(newMessage(_staID + ": L2 APC DZ " + ant1.toAscii() + "m" ));
|
|---|
| 758 | //// }
|
|---|
| 759 | //// _rnx_set_position = true;
|
|---|
| 760 | //// }
|
|---|
| 761 | //// }
|
|---|
| 762 |
|
|---|
| 763 | if ( dump ) {
|
|---|
| 764 | long iSec = long(floor(obs->_o.GPSWeeks+0.5));
|
|---|
| 765 | long newTime = obs->_o.GPSWeek * 7*24*3600 + iSec;
|
|---|
| 766 | if (_samplingRate == 0 || iSec % _samplingRate == 0) {
|
|---|
| 767 | _rnx->deepCopy(obs);
|
|---|
| 768 | }
|
|---|
| 769 | _rnx->dumpEpoch(newTime);
|
|---|
| 770 | }
|
|---|
| 771 | }
|
|---|
| 772 |
|
|---|
| 773 | // Emit new observation signal
|
|---|
| 774 | // ---------------------------
|
|---|
| 775 | bool firstObs = (obs == _decoder->_obsList.first());
|
|---|
| 776 | obs->_status = t_obs::posted;
|
|---|
| 777 | emit newObs(_staID, firstObs, obs);
|
|---|
| 778 | }
|
|---|
| 779 | _decoder->_obsList.clear();
|
|---|
| 780 |
|
|---|
| 781 | }
|
|---|
| 782 |
|
|---|
| 783 | // Timeout, reconnect
|
|---|
| 784 | // ------------------
|
|---|
| 785 | else {
|
|---|
| 786 | emit(newMessage(_staID + ": Data Timeout, reconnecting", true));
|
|---|
| 787 | tryReconnect();
|
|---|
| 788 | }
|
|---|
| 789 | }
|
|---|
| 790 | catch (const char* msg) {
|
|---|
| 791 | emit(newMessage(_staID + msg, true));
|
|---|
| 792 | tryReconnect();
|
|---|
| 793 | }
|
|---|
| 794 | }
|
|---|
| 795 | }
|
|---|
| 796 |
|
|---|
| 797 | // Exit
|
|---|
| 798 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 799 | void bncGetThread::exit(int exitCode) {
|
|---|
| 800 | if (exitCode!= 0) {
|
|---|
| 801 | emit error(_staID);
|
|---|
| 802 | }
|
|---|
| 803 | QThread::exit(exitCode);
|
|---|
| 804 | terminate();
|
|---|
| 805 | }
|
|---|
| 806 |
|
|---|
| 807 | // Try Re-Connect
|
|---|
| 808 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 809 | void bncGetThread::tryReconnect() {
|
|---|
| 810 | if (_rnx) {
|
|---|
| 811 | _rnx->setReconnectFlag(true);
|
|---|
| 812 | }
|
|---|
| 813 | if ( !_decodeStart.isValid()) {
|
|---|
| 814 | _decodeStop = QDateTime::currentDateTime();
|
|---|
| 815 | }
|
|---|
| 816 | while (1) {
|
|---|
| 817 | sleep(_nextSleep);
|
|---|
| 818 | if ( initRun() == success ) {
|
|---|
| 819 | if ( !_decodeStop.isValid()) {
|
|---|
| 820 | _decodeStart = QDateTime::currentDateTime();
|
|---|
| 821 | }
|
|---|
| 822 | break;
|
|---|
| 823 | }
|
|---|
| 824 | else {
|
|---|
| 825 |
|
|---|
| 826 | // Begin outage threshold
|
|---|
| 827 | // ----------------------
|
|---|
| 828 | if ( _decodeStop.isValid() && _decodeStop.secsTo(QDateTime::currentDateTime()) > _adviseFail * 60 ) {
|
|---|
| 829 | _decodeStop.setDate(QDate());
|
|---|
| 830 | _decodeStop.setTime(QTime());
|
|---|
| 831 | if (_inspSegm>0) {
|
|---|
| 832 | _begDateOut = _decodeTime.toUTC().date().toString("yy-MM-dd");
|
|---|
| 833 | _begTimeOut = _decodeTime.toUTC().time().toString("hh:mm:ss");
|
|---|
| 834 | emit(newMessage((_staID + ": Failure threshold exceeded, outage since "
|
|---|
| 835 | + _begDateOut + " " + _begTimeOut).toAscii(), true));
|
|---|
| 836 | callScript(("Begin_Outage " + _begDateOut + " " + _begTimeOut).toAscii());
|
|---|
| 837 | }
|
|---|
| 838 | }
|
|---|
| 839 | _nextSleep *= 2;
|
|---|
| 840 | if (_nextSleep > 256) {
|
|---|
| 841 | _nextSleep = 256;
|
|---|
| 842 | }
|
|---|
| 843 | _nextSleep += rand() % 6;
|
|---|
| 844 | }
|
|---|
| 845 | }
|
|---|
| 846 | _nextSleep = 1;
|
|---|
| 847 | }
|
|---|
| 848 |
|
|---|
| 849 | // Call advisory notice script
|
|---|
| 850 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 851 | void bncGetThread::callScript(const char* _comment) {
|
|---|
| 852 | QMutexLocker locker(&_mutex);
|
|---|
| 853 | if (!_adviseScript.isEmpty()) {
|
|---|
| 854 | msleep(1);
|
|---|
| 855 | #ifdef WIN32
|
|---|
| 856 | QProcess::startDetached(_adviseScript, QStringList() << _staID << _comment) ;
|
|---|
| 857 | #else
|
|---|
| 858 | QProcess::startDetached("nohup", QStringList() << _adviseScript << _staID << _comment) ;
|
|---|
| 859 | #endif
|
|---|
| 860 | }
|
|---|
| 861 | }
|
|---|
| 862 |
|
|---|
| 863 | //
|
|---|
| 864 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 865 | void bncGetThread::slotNewEphGPS(gpsephemeris gpseph) {
|
|---|
| 866 | RTCM2Decoder* decoder = dynamic_cast<RTCM2Decoder*>(_decoder);
|
|---|
| 867 |
|
|---|
| 868 | if ( decoder ) {
|
|---|
| 869 | QMutexLocker locker(&_mutex);
|
|---|
| 870 |
|
|---|
| 871 | string storedPRN;
|
|---|
| 872 | vector<int> IODs;
|
|---|
| 873 |
|
|---|
| 874 | if ( decoder->storeEph(gpseph, storedPRN, IODs) ) {
|
|---|
| 875 | #ifdef DEBUG_RTCM2_2021
|
|---|
| 876 | QString msg = _staID + QString(": stored eph %1 IODs").arg(storedPRN.c_str());
|
|---|
| 877 |
|
|---|
| 878 | for (unsigned ii = 0; ii < IODs.size(); ii++) {
|
|---|
| 879 | msg += QString(" %1").arg(IODs[ii],4);
|
|---|
| 880 | }
|
|---|
| 881 |
|
|---|
| 882 | emit(newMessage(msg.toAscii(), false));
|
|---|
| 883 | #endif
|
|---|
| 884 | }
|
|---|
| 885 | }
|
|---|
| 886 | }
|
|---|