[280] | 1 | // Part of BNC, a utility for retrieving decoding and
|
---|
[464] | 2 | // converting GNSS data streams from NTRIP broadcasters.
|
---|
[280] | 3 | //
|
---|
[464] | 4 | // Copyright (C) 2007
|
---|
[280] | 5 | // German Federal Agency for Cartography and Geodesy (BKG)
|
---|
| 6 | // http://www.bkg.bund.de
|
---|
[464] | 7 | // Czech Technical University Prague, Department of Geodesy
|
---|
[280] | 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.
|
---|
[35] | 24 |
|
---|
| 25 | /* -------------------------------------------------------------------------
|
---|
[93] | 26 | * BKG NTRIP Client
|
---|
[35] | 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 |
|
---|
[277] | 41 | #include <stdlib.h>
|
---|
[1044] | 42 | #include <iomanip>
|
---|
[277] | 43 |
|
---|
[35] | 44 | #include <QFile>
|
---|
| 45 | #include <QTextStream>
|
---|
| 46 | #include <QtNetwork>
|
---|
[356] | 47 | #include <QTime>
|
---|
[35] | 48 |
|
---|
| 49 | #include "bncgetthread.h"
|
---|
[192] | 50 | #include "bnctabledlg.h"
|
---|
[243] | 51 | #include "bncapp.h"
|
---|
[352] | 52 | #include "bncutils.h"
|
---|
[408] | 53 | #include "bncrinex.h"
|
---|
[423] | 54 | #include "bnczerodecoder.h"
|
---|
[65] | 55 |
|
---|
[243] | 56 | #include "RTCM/RTCM2Decoder.h"
|
---|
[297] | 57 | #include "RTCM3/RTCM3Decoder.h"
|
---|
[293] | 58 | #include "RTIGS/RTIGSDecoder.h"
|
---|
[35] | 59 |
|
---|
| 60 | using namespace std;
|
---|
| 61 |
|
---|
[1143] | 62 | // Constructor 1
|
---|
[35] | 63 | ////////////////////////////////////////////////////////////////////////////
|
---|
[1138] | 64 | bncGetThread::bncGetThread(const QByteArray& rawInpFileName,
|
---|
| 65 | const QByteArray& format) {
|
---|
| 66 |
|
---|
[1141] | 67 | _format = format;
|
---|
[1139] | 68 |
|
---|
[1159] | 69 | int iSep = rawInpFileName.lastIndexOf(QDir::separator());
|
---|
| 70 | _staID = rawInpFileName.mid(iSep+1,4);
|
---|
| 71 |
|
---|
[1139] | 72 | initialize();
|
---|
| 73 |
|
---|
| 74 | _inspSegm = 0;
|
---|
| 75 |
|
---|
[1138] | 76 | _rawInpFile = new QFile(rawInpFileName);
|
---|
| 77 | _rawInpFile->open(QIODevice::ReadOnly);
|
---|
[1147] | 78 |
|
---|
| 79 | if (!_rnx) {
|
---|
| 80 | cerr << "no RINEX path specified" << endl;
|
---|
| 81 | ::exit(0);
|
---|
| 82 | }
|
---|
[1138] | 83 | }
|
---|
| 84 |
|
---|
[1143] | 85 | // Constructor 2
|
---|
| 86 | ////////////////////////////////////////////////////////////////////////////
|
---|
[278] | 87 | bncGetThread::bncGetThread(const QUrl& mountPoint,
|
---|
[366] | 88 | const QByteArray& format,
|
---|
| 89 | const QByteArray& latitude,
|
---|
| 90 | const QByteArray& longitude,
|
---|
| 91 | const QByteArray& nmea, int iMount) {
|
---|
[605] | 92 |
|
---|
| 93 | setTerminationEnabled(true);
|
---|
| 94 |
|
---|
[350] | 95 | _mountPoint = mountPoint;
|
---|
| 96 | _staID = mountPoint.path().mid(1).toAscii();
|
---|
| 97 | _format = format;
|
---|
[366] | 98 | _latitude = latitude;
|
---|
| 99 | _longitude = longitude;
|
---|
| 100 | _nmea = nmea;
|
---|
[1139] | 101 | _iMount = iMount; // index in mountpoints array
|
---|
| 102 |
|
---|
| 103 | initialize();
|
---|
| 104 | }
|
---|
| 105 |
|
---|
[1143] | 106 | // Initialization
|
---|
| 107 | ////////////////////////////////////////////////////////////////////////////
|
---|
[1139] | 108 | void bncGetThread::initialize() {
|
---|
| 109 |
|
---|
| 110 | _decoder = 0;
|
---|
[350] | 111 | _socket = 0;
|
---|
[1139] | 112 | _timeOut = 20*1000; // 20 seconds
|
---|
| 113 | _nextSleep = 1; // 1 second
|
---|
[1138] | 114 | _rawInpFile = 0;
|
---|
[1139] | 115 | _rawOutFile = 0;
|
---|
[1143] | 116 | _staID_orig = _staID;
|
---|
[255] | 117 |
|
---|
| 118 | // Check name conflict
|
---|
| 119 | // -------------------
|
---|
| 120 | QSettings settings;
|
---|
| 121 | QListIterator<QString> it(settings.value("mountPoints").toStringList());
|
---|
| 122 | int num = 0;
|
---|
[278] | 123 | int ind = -1;
|
---|
[255] | 124 | while (it.hasNext()) {
|
---|
[278] | 125 | ++ind;
|
---|
[255] | 126 | QStringList hlp = it.next().split(" ");
|
---|
| 127 | if (hlp.size() <= 1) continue;
|
---|
| 128 | QUrl url(hlp[0]);
|
---|
| 129 | if (_mountPoint.path() == url.path()) {
|
---|
[278] | 130 | if (_iMount > ind) {
|
---|
| 131 | ++num;
|
---|
[255] | 132 | }
|
---|
| 133 | }
|
---|
| 134 | }
|
---|
[278] | 135 |
|
---|
| 136 | if (num > 0) {
|
---|
| 137 | _staID = _staID.left(_staID.length()-1) + QString("%1").arg(num).toAscii();
|
---|
[255] | 138 | }
|
---|
[408] | 139 |
|
---|
[658] | 140 | // Notice threshold
|
---|
| 141 | // ----------------
|
---|
[686] | 142 | _inspSegm = 50;
|
---|
| 143 | if ( settings.value("obsRate").toString().isEmpty() ) { _inspSegm = 0; }
|
---|
[692] | 144 | if ( settings.value("obsRate").toString().indexOf("5 Hz") != -1 ) { _inspSegm = 2; }
|
---|
[686] | 145 | if ( settings.value("obsRate").toString().indexOf("1 Hz") != -1 ) { _inspSegm = 10; }
|
---|
| 146 | if ( settings.value("obsRate").toString().indexOf("0.5 Hz") != -1 ) { _inspSegm = 20; }
|
---|
| 147 | if ( settings.value("obsRate").toString().indexOf("0.2 Hz") != -1 ) { _inspSegm = 40; }
|
---|
| 148 | if ( settings.value("obsRate").toString().indexOf("0.1 Hz") != -1 ) { _inspSegm = 50; }
|
---|
[668] | 149 | _adviseFail = settings.value("adviseFail").toInt();
|
---|
| 150 | _adviseReco = settings.value("adviseReco").toInt();
|
---|
[722] | 151 | _makePause = false;
|
---|
| 152 | if ( Qt::CheckState(settings.value("makePause").toInt()) == Qt::Checked) {_makePause = true; }
|
---|
[668] | 153 | _adviseScript = settings.value("adviseScript").toString();
|
---|
| 154 | expandEnvVar(_adviseScript);
|
---|
[658] | 155 |
|
---|
[709] | 156 | // Latency interval/average
|
---|
| 157 | // ------------------------
|
---|
[728] | 158 | _perfIntr = 86400;
|
---|
| 159 | if ( settings.value("perfIntr").toString().isEmpty() ) { _perfIntr = 0; }
|
---|
| 160 | if ( settings.value("perfIntr").toString().indexOf("1 min") != -1 ) { _perfIntr = 60; }
|
---|
| 161 | if ( settings.value("perfIntr").toString().indexOf("5 min") != -1 ) { _perfIntr = 300; }
|
---|
| 162 | if ( settings.value("perfIntr").toString().indexOf("15 min") != -1 ) { _perfIntr = 900; }
|
---|
| 163 | if ( settings.value("perfIntr").toString().indexOf("1 hour") != -1 ) { _perfIntr = 3600; }
|
---|
| 164 | if ( settings.value("perfIntr").toString().indexOf("6 hours") != -1 ) { _perfIntr = 21600; }
|
---|
| 165 | if ( settings.value("perfIntr").toString().indexOf("1 day") != -1 ) { _perfIntr = 86400; }
|
---|
[709] | 166 |
|
---|
[1030] | 167 | // RTCM message types
|
---|
| 168 | // ------------------
|
---|
| 169 | _checkMountPoint = settings.value("messTypes").toString();
|
---|
| 170 |
|
---|
[408] | 171 | // RINEX writer
|
---|
| 172 | // ------------
|
---|
| 173 | _samplingRate = settings.value("rnxSampl").toInt();
|
---|
| 174 | if ( settings.value("rnxPath").toString().isEmpty() ) {
|
---|
| 175 | _rnx = 0;
|
---|
| 176 | }
|
---|
| 177 | else {
|
---|
[1139] | 178 | _rnx = new bncRinex(_staID, _mountPoint,
|
---|
| 179 | _format, _latitude, _longitude, _nmea);
|
---|
[408] | 180 | }
|
---|
[1044] | 181 | _rnx_set_position = false;
|
---|
[408] | 182 |
|
---|
[1137] | 183 | // Raw Output
|
---|
| 184 | // ----------
|
---|
[1140] | 185 | // QByteArray rawOutFileName = "./" + _staID + ".raw";
|
---|
| 186 | // _rawOutFile = new QFile(rawOutFileName);
|
---|
| 187 | // _rawOutFile->open(QIODevice::WriteOnly);
|
---|
[1137] | 188 |
|
---|
[319] | 189 | msleep(100); //sleep 0.1 sec
|
---|
[35] | 190 | }
|
---|
| 191 |
|
---|
| 192 | // Destructor
|
---|
| 193 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 194 | bncGetThread::~bncGetThread() {
|
---|
[515] | 195 | if (_socket) {
|
---|
| 196 | _socket->close();
|
---|
[613] | 197 | #if QT_VERSION == 0x040203
|
---|
| 198 | delete _socket;
|
---|
| 199 | #else
|
---|
[612] | 200 | _socket->deleteLater();
|
---|
[613] | 201 | #endif
|
---|
[515] | 202 | }
|
---|
[617] | 203 | delete _decoder;
|
---|
[1044] | 204 | delete _rnx;
|
---|
[1138] | 205 | delete _rawInpFile;
|
---|
| 206 | delete _rawOutFile;
|
---|
[35] | 207 | }
|
---|
| 208 |
|
---|
[841] | 209 | #define AGENTVERSION "1.6"
|
---|
[35] | 210 | // Connect to Caster, send the Request (static)
|
---|
| 211 | ////////////////////////////////////////////////////////////////////////////
|
---|
[366] | 212 | QTcpSocket* bncGetThread::request(const QUrl& mountPoint,
|
---|
| 213 | QByteArray& latitude, QByteArray& longitude,
|
---|
| 214 | QByteArray& nmea, int timeOut,
|
---|
[136] | 215 | QString& msg) {
|
---|
[35] | 216 |
|
---|
[88] | 217 | // Connect the Socket
|
---|
| 218 | // ------------------
|
---|
| 219 | QSettings settings;
|
---|
| 220 | QString proxyHost = settings.value("proxyHost").toString();
|
---|
| 221 | int proxyPort = settings.value("proxyPort").toInt();
|
---|
| 222 |
|
---|
[35] | 223 | QTcpSocket* socket = new QTcpSocket();
|
---|
| 224 | if ( proxyHost.isEmpty() ) {
|
---|
[88] | 225 | socket->connectToHost(mountPoint.host(), mountPoint.port());
|
---|
[35] | 226 | }
|
---|
| 227 | else {
|
---|
| 228 | socket->connectToHost(proxyHost, proxyPort);
|
---|
| 229 | }
|
---|
| 230 | if (!socket->waitForConnected(timeOut)) {
|
---|
[82] | 231 | msg += "Connect timeout\n";
|
---|
[35] | 232 | delete socket;
|
---|
| 233 | return 0;
|
---|
| 234 | }
|
---|
| 235 |
|
---|
| 236 | // Send Request
|
---|
| 237 | // ------------
|
---|
[443] | 238 | QString uName = QUrl::fromPercentEncoding(mountPoint.userName().toAscii());
|
---|
| 239 | QString passW = QUrl::fromPercentEncoding(mountPoint.password().toAscii());
|
---|
[645] | 240 | QByteArray userAndPwd;
|
---|
[92] | 241 |
|
---|
[645] | 242 | if(!uName.isEmpty() || !passW.isEmpty())
|
---|
| 243 | {
|
---|
| 244 | userAndPwd = "Authorization: Basic " + (uName.toAscii() + ":" +
|
---|
| 245 | passW.toAscii()).toBase64() + "\r\n";
|
---|
| 246 | }
|
---|
| 247 |
|
---|
[92] | 248 | QUrl hlp;
|
---|
| 249 | hlp.setScheme("http");
|
---|
| 250 | hlp.setHost(mountPoint.host());
|
---|
| 251 | hlp.setPort(mountPoint.port());
|
---|
| 252 | hlp.setPath(mountPoint.path());
|
---|
| 253 |
|
---|
[214] | 254 | QByteArray reqStr;
|
---|
| 255 | if ( proxyHost.isEmpty() ) {
|
---|
[1020] | 256 | if (hlp.path().indexOf("/") != 0) {
|
---|
| 257 | hlp.setPath("/");
|
---|
| 258 | }
|
---|
| 259 | reqStr = "GET " + hlp.path().toAscii() + " HTTP/1.0\r\n";
|
---|
| 260 | } else {
|
---|
| 261 | reqStr = "GET " + hlp.toEncoded() + " HTTP/1.0\r\n";
|
---|
[205] | 262 | }
|
---|
[645] | 263 | reqStr += "User-Agent: NTRIP BNC/" AGENTVERSION "\r\n"
|
---|
[1020] | 264 | "Host: " + hlp.host().toAscii() + "\r\n"
|
---|
| 265 | + userAndPwd + "\r\n";
|
---|
[205] | 266 |
|
---|
[1020] | 267 | // NMEA string to handle VRS stream
|
---|
| 268 | // --------------------------------
|
---|
[356] | 269 | double lat, lon;
|
---|
[366] | 270 |
|
---|
| 271 | lat = strtod(latitude,NULL);
|
---|
| 272 | lon = strtod(longitude,NULL);
|
---|
| 273 |
|
---|
[410] | 274 | if ((nmea == "yes") && (hlp.path().length() > 2) && (hlp.path().indexOf(".skl") < 0)) {
|
---|
[356] | 275 | const char* flagN="N";
|
---|
| 276 | const char* flagE="E";
|
---|
| 277 | if (lon >180.) {lon=(lon-360.)*(-1.); flagE="W";}
|
---|
| 278 | if ((lon < 0.) && (lon >= -180.)) {lon=lon*(-1.); flagE="W";}
|
---|
| 279 | if (lon < -180.) {lon=(lon+360.); flagE="E";}
|
---|
| 280 | if (lat < 0.) {lat=lat*(-1.); flagN="S";}
|
---|
[566] | 281 | QTime ttime(QDateTime::currentDateTime().toUTC().time());
|
---|
[356] | 282 | int lat_deg = (int)lat;
|
---|
| 283 | double lat_min=(lat-lat_deg)*60.;
|
---|
| 284 | int lon_deg = (int)lon;
|
---|
| 285 | double lon_min=(lon-lon_deg)*60.;
|
---|
| 286 | int hh = 0 , mm = 0;
|
---|
| 287 | double ss = 0.0;
|
---|
| 288 | hh=ttime.hour();
|
---|
| 289 | mm=ttime.minute();
|
---|
| 290 | ss=(double)ttime.second()+0.001*ttime.msec();
|
---|
| 291 | QString gga;
|
---|
| 292 | gga += "GPGGA,";
|
---|
| 293 | gga += QString("%1%2%3,").arg((int)hh, 2, 10, QLatin1Char('0')).arg((int)mm, 2, 10, QLatin1Char('0')).arg((int)ss, 2, 10, QLatin1Char('0'));
|
---|
| 294 | gga += QString("%1%2,").arg((int)lat_deg,2, 10, QLatin1Char('0')).arg(lat_min, 7, 'f', 4, QLatin1Char('0'));
|
---|
| 295 | gga += flagN;
|
---|
| 296 | gga += QString(",%1%2,").arg((int)lon_deg,3, 10, QLatin1Char('0')).arg(lon_min, 7, 'f', 4, QLatin1Char('0'));
|
---|
| 297 | gga += flagE + QString(",1,05,1.00,+00100,M,10.000,M,,");
|
---|
| 298 | int xori;
|
---|
| 299 | char XOR = 0;
|
---|
| 300 | char *Buff =gga.toAscii().data();
|
---|
| 301 | int iLen = strlen(Buff);
|
---|
| 302 | for (xori = 0; xori < iLen; xori++) {
|
---|
| 303 | XOR ^= (char)Buff[xori];
|
---|
| 304 | }
|
---|
| 305 | gga += QString("*%1").arg(XOR, 2, 16, QLatin1Char('0'));
|
---|
| 306 | reqStr += "$";
|
---|
| 307 | reqStr += gga;
|
---|
| 308 | reqStr += "\r\n";
|
---|
| 309 | }
|
---|
| 310 |
|
---|
[82] | 311 | msg += reqStr;
|
---|
[35] | 312 |
|
---|
| 313 | socket->write(reqStr, reqStr.length());
|
---|
| 314 |
|
---|
| 315 | if (!socket->waitForBytesWritten(timeOut)) {
|
---|
[82] | 316 | msg += "Write timeout\n";
|
---|
[35] | 317 | delete socket;
|
---|
| 318 | return 0;
|
---|
| 319 | }
|
---|
| 320 |
|
---|
| 321 | return socket;
|
---|
| 322 | }
|
---|
| 323 |
|
---|
[136] | 324 | // Init Run
|
---|
[35] | 325 | ////////////////////////////////////////////////////////////////////////////
|
---|
[138] | 326 | t_irc bncGetThread::initRun() {
|
---|
[35] | 327 |
|
---|
[1138] | 328 | if (!_rawInpFile) {
|
---|
[35] | 329 |
|
---|
[1138] | 330 | // Initialize Socket
|
---|
| 331 | // -----------------
|
---|
| 332 | QString msg;
|
---|
| 333 | _socket = this->request(_mountPoint, _latitude, _longitude,
|
---|
| 334 | _nmea, _timeOut, msg);
|
---|
| 335 | if (!_socket) {
|
---|
| 336 | return failure;
|
---|
| 337 | }
|
---|
| 338 |
|
---|
| 339 | // Read Caster Response
|
---|
| 340 | // --------------------
|
---|
| 341 | _socket->waitForReadyRead(_timeOut);
|
---|
| 342 | if (_socket->canReadLine()) {
|
---|
| 343 | QString line = _socket->readLine();
|
---|
| 344 |
|
---|
| 345 | // Skip messages from proxy server
|
---|
| 346 | // -------------------------------
|
---|
| 347 | if (line.indexOf("ICY 200 OK") == -1 &&
|
---|
| 348 | line.indexOf("200 OK") != -1 ) {
|
---|
| 349 | bool proxyRespond = true;
|
---|
| 350 | while (true) {
|
---|
| 351 | if (_socket->canReadLine()) {
|
---|
| 352 | line = _socket->readLine();
|
---|
| 353 | if (!proxyRespond) {
|
---|
| 354 | break;
|
---|
| 355 | }
|
---|
| 356 | if (line.trimmed().isEmpty()) {
|
---|
| 357 | proxyRespond = false;
|
---|
| 358 | }
|
---|
[473] | 359 | }
|
---|
[1138] | 360 | else {
|
---|
| 361 | _socket->waitForReadyRead(_timeOut);
|
---|
| 362 | if (_socket->bytesAvailable() <= 0) {
|
---|
| 363 | break;
|
---|
| 364 | }
|
---|
[473] | 365 | }
|
---|
| 366 | }
|
---|
[1138] | 367 | }
|
---|
| 368 |
|
---|
| 369 | if (line.indexOf("Unauthorized") != -1) {
|
---|
| 370 | QStringList table;
|
---|
| 371 | bncTableDlg::getFullTable(_mountPoint.host(), _mountPoint.port(), table);
|
---|
| 372 | QString net;
|
---|
| 373 | QStringListIterator it(table);
|
---|
| 374 | while (it.hasNext()) {
|
---|
| 375 | QString line = it.next();
|
---|
| 376 | if (line.indexOf("STR") == 0) {
|
---|
| 377 | QStringList tags = line.split(";");
|
---|
| 378 | if (tags.at(1) == _staID_orig) {
|
---|
| 379 | net = tags.at(7);
|
---|
| 380 | break;
|
---|
| 381 | }
|
---|
[474] | 382 | }
|
---|
[473] | 383 | }
|
---|
[1138] | 384 |
|
---|
| 385 | QString reg;
|
---|
| 386 | it.toFront();
|
---|
| 387 | while (it.hasNext()) {
|
---|
| 388 | QString line = it.next();
|
---|
| 389 | if (line.indexOf("NET") == 0) {
|
---|
| 390 | QStringList tags = line.split(";");
|
---|
| 391 | if (tags.at(1) == net) {
|
---|
| 392 | reg = tags.at(7);
|
---|
| 393 | break;
|
---|
| 394 | }
|
---|
[192] | 395 | }
|
---|
| 396 | }
|
---|
[1138] | 397 | emit(newMessage((_staID + ": Caster Response: " + line +
|
---|
| 398 | " Adjust User-ID and Password Register, see"
|
---|
| 399 | "\n " + reg).toAscii()));
|
---|
| 400 | return fatal;
|
---|
[192] | 401 | }
|
---|
[1138] | 402 | if (line.indexOf("ICY 200 OK") != 0) {
|
---|
| 403 | emit(newMessage((_staID + ": Wrong Caster Response:\n" + line).toAscii()));
|
---|
| 404 | return failure;
|
---|
[192] | 405 | }
|
---|
[146] | 406 | }
|
---|
[1138] | 407 | else {
|
---|
| 408 | emit(newMessage(_staID + ": Response Timeout"));
|
---|
[144] | 409 | return failure;
|
---|
[35] | 410 | }
|
---|
| 411 | }
|
---|
| 412 |
|
---|
| 413 | // Instantiate the filter
|
---|
| 414 | // ----------------------
|
---|
[423] | 415 | if (!_decoder) {
|
---|
[136] | 416 | if (_format.indexOf("RTCM_2") != -1) {
|
---|
| 417 | emit(newMessage("Get Data: " + _staID + " in RTCM 2.x format"));
|
---|
[1044] | 418 | _decoder = new RTCM2Decoder(_staID.data());
|
---|
[136] | 419 | }
|
---|
| 420 | else if (_format.indexOf("RTCM_3") != -1) {
|
---|
[569] | 421 | emit(newMessage("Get Data: " + _staID + " in RTCM 3.x format"));
|
---|
[880] | 422 | _decoder = new RTCM3Decoder(_staID);
|
---|
[1022] | 423 | connect((RTCM3Decoder*) _decoder, SIGNAL(newMessage(QByteArray)),
|
---|
| 424 | this, SIGNAL(newMessage(QByteArray)));
|
---|
[136] | 425 | }
|
---|
| 426 | else if (_format.indexOf("RTIGS") != -1) {
|
---|
| 427 | emit(newMessage("Get Data: " + _staID + " in RTIGS format"));
|
---|
[293] | 428 | _decoder = new RTIGSDecoder();
|
---|
[136] | 429 | }
|
---|
[867] | 430 | else if (_format.indexOf("ZERO") != -1) {
|
---|
[428] | 431 | emit(newMessage("Get Data: " + _staID + " in original format"));
|
---|
[424] | 432 | _decoder = new bncZeroDecoder(_staID);
|
---|
[406] | 433 | }
|
---|
[136] | 434 | else {
|
---|
[190] | 435 | emit(newMessage(_staID + ": Unknown data format " + _format));
|
---|
[1144] | 436 | if (_rawInpFile) {
|
---|
[1145] | 437 | cerr << "Uknown data format" << endl;
|
---|
[1144] | 438 | ::exit(0);
|
---|
| 439 | }
|
---|
| 440 | else {
|
---|
| 441 | return fatal;
|
---|
| 442 | }
|
---|
[136] | 443 | }
|
---|
[60] | 444 | }
|
---|
[138] | 445 | return success;
|
---|
[136] | 446 | }
|
---|
[59] | 447 |
|
---|
[136] | 448 | // Run
|
---|
| 449 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 450 | void bncGetThread::run() {
|
---|
| 451 |
|
---|
[709] | 452 | const double maxDt = 600.0; // Check observation epoch
|
---|
[699] | 453 | bool wrongEpoch = false;
|
---|
| 454 | bool decode = true;
|
---|
| 455 | int numSucc = 0;
|
---|
| 456 | int secSucc = 0;
|
---|
| 457 | int secFail = 0;
|
---|
[709] | 458 | int initPause = 30; // Initial pause for corrupted streams
|
---|
[699] | 459 | int currPause = 0;
|
---|
| 460 | bool begCorrupt = false;
|
---|
| 461 | bool endCorrupt = false;
|
---|
[728] | 462 | bool followSec = false;
|
---|
[717] | 463 | int oldSecGPS= 0;
|
---|
| 464 | int newSecGPS = 0;
|
---|
[728] | 465 | int numGaps = 0;
|
---|
| 466 | int diffSecGPS = 0;
|
---|
[709] | 467 | int numLat = 0;
|
---|
| 468 | double sumLat = 0.;
|
---|
[1052] | 469 | double sumLatQ = 0.;
|
---|
[728] | 470 | double meanDiff = 0.;
|
---|
[709] | 471 | double minLat = maxDt;
|
---|
| 472 | double maxLat = -maxDt;
|
---|
| 473 | double curLat = 0.;
|
---|
[699] | 474 |
|
---|
| 475 | _decodeTime = QDateTime::currentDateTime();
|
---|
| 476 | _decodeSucc = QDateTime::currentDateTime();
|
---|
[229] | 477 | t_irc irc = initRun();
|
---|
| 478 |
|
---|
| 479 | if (irc == fatal) {
|
---|
[192] | 480 | QThread::exit(1);
|
---|
| 481 | return;
|
---|
| 482 | }
|
---|
[229] | 483 | else if (irc != success) {
|
---|
[190] | 484 | emit(newMessage(_staID + ": initRun failed, reconnecting"));
|
---|
[138] | 485 | tryReconnect();
|
---|
| 486 | }
|
---|
[136] | 487 |
|
---|
[658] | 488 | if (initPause < _inspSegm) {
|
---|
| 489 | initPause = _inspSegm;
|
---|
| 490 | }
|
---|
[727] | 491 | if(!_makePause) {initPause = 0;}
|
---|
[658] | 492 | currPause = initPause;
|
---|
| 493 |
|
---|
[35] | 494 | // Read Incoming Data
|
---|
| 495 | // ------------------
|
---|
| 496 | while (true) {
|
---|
[629] | 497 | try {
|
---|
[1138] | 498 | if (_socket && _socket->state() != QAbstractSocket::ConnectedState) {
|
---|
[629] | 499 | emit(newMessage(_staID + ": Socket not connected, reconnecting"));
|
---|
| 500 | tryReconnect();
|
---|
| 501 | }
|
---|
[621] | 502 |
|
---|
| 503 | QListIterator<p_obs> it(_decoder->_obsList);
|
---|
| 504 | while (it.hasNext()) {
|
---|
| 505 | delete it.next();
|
---|
| 506 | }
|
---|
| 507 | _decoder->_obsList.clear();
|
---|
| 508 |
|
---|
[1138] | 509 | qint64 nBytes = 0;
|
---|
| 510 |
|
---|
| 511 | if (_socket) {
|
---|
| 512 | _socket->waitForReadyRead(_timeOut);
|
---|
| 513 | nBytes = _socket->bytesAvailable();
|
---|
| 514 | }
|
---|
| 515 | else if (_rawInpFile) {
|
---|
[1146] | 516 | const qint64 maxBytes = 1024;
|
---|
[1138] | 517 | nBytes = maxBytes;
|
---|
| 518 | }
|
---|
| 519 |
|
---|
[249] | 520 | if (nBytes > 0) {
|
---|
[567] | 521 | emit newBytes(_staID, nBytes);
|
---|
| 522 |
|
---|
[249] | 523 | char* data = new char[nBytes];
|
---|
[406] | 524 |
|
---|
[1138] | 525 | if (_socket) {
|
---|
| 526 | _socket->read(data, nBytes);
|
---|
[1137] | 527 | }
|
---|
[1138] | 528 | else if (_rawInpFile) {
|
---|
| 529 | nBytes = _rawInpFile->read(data, nBytes);
|
---|
| 530 | if (nBytes <= 0) {
|
---|
| 531 | cout << "no more data" << endl;
|
---|
| 532 | ::exit(0);
|
---|
| 533 | }
|
---|
| 534 | }
|
---|
[1137] | 535 |
|
---|
[1138] | 536 | if (_rawOutFile) {
|
---|
| 537 | _rawOutFile->write(data, nBytes);
|
---|
| 538 | _rawOutFile->flush();
|
---|
| 539 | }
|
---|
| 540 |
|
---|
[940] | 541 | if (_inspSegm<1) {
|
---|
| 542 | _decoder->Decode(data, nBytes);
|
---|
| 543 | }
|
---|
| 544 | else {
|
---|
| 545 |
|
---|
| 546 | // Decode data
|
---|
| 547 | // -----------
|
---|
| 548 | if (!_decodePause.isValid() ||
|
---|
| 549 | _decodePause.secsTo(QDateTime::currentDateTime()) >= currPause ) {
|
---|
| 550 |
|
---|
| 551 | if (decode) {
|
---|
| 552 | if ( _decoder->Decode(data, nBytes) == success ) {
|
---|
| 553 | numSucc += 1;
|
---|
| 554 | }
|
---|
| 555 | if ( _decodeTime.secsTo(QDateTime::currentDateTime()) > _inspSegm ) {
|
---|
| 556 | decode = false;
|
---|
[658] | 557 | }
|
---|
| 558 | }
|
---|
[940] | 559 |
|
---|
| 560 | // Check - once per inspect segment
|
---|
| 561 | // --------------------------------
|
---|
| 562 | if (!decode) {
|
---|
| 563 | _decodeTime = QDateTime::currentDateTime();
|
---|
| 564 | if (numSucc>0) {
|
---|
| 565 | secSucc += _inspSegm;
|
---|
| 566 | _decodeSucc = QDateTime::currentDateTime();
|
---|
| 567 | if (secSucc > _adviseReco * 60) {
|
---|
| 568 | secSucc = _adviseReco * 60 + 1;
|
---|
| 569 | }
|
---|
| 570 | numSucc = 0;
|
---|
| 571 | currPause = initPause;
|
---|
| 572 | _decodePause.setDate(QDate());
|
---|
| 573 | _decodePause.setTime(QTime());
|
---|
[658] | 574 | }
|
---|
[940] | 575 | else {
|
---|
| 576 | secFail += _inspSegm;
|
---|
| 577 | secSucc = 0;
|
---|
| 578 | if (secFail > _adviseFail * 60) {
|
---|
| 579 | secFail = _adviseFail * 60 + 1;
|
---|
| 580 | }
|
---|
| 581 | if (!_decodePause.isValid() || !_makePause) {
|
---|
| 582 | _decodePause = QDateTime::currentDateTime();
|
---|
| 583 | }
|
---|
| 584 | else {
|
---|
| 585 | _decodePause.setDate(QDate());
|
---|
| 586 | _decodePause.setTime(QTime());
|
---|
| 587 | secFail = secFail + currPause - _inspSegm;
|
---|
| 588 | currPause = currPause * 2;
|
---|
| 589 | if (currPause > 960) {
|
---|
| 590 | currPause = 960;
|
---|
| 591 | }
|
---|
| 592 | }
|
---|
[658] | 593 | }
|
---|
[940] | 594 |
|
---|
| 595 | // End corrupt threshold
|
---|
| 596 | // ---------------------
|
---|
| 597 | if ( begCorrupt && !endCorrupt && secSucc > _adviseReco * 60 ) {
|
---|
| 598 | _endDateCor = QDateTime::currentDateTime().addSecs(- _adviseReco * 60).toUTC().date().toString("yy-MM-dd");
|
---|
| 599 | _endTimeCor = QDateTime::currentDateTime().addSecs(- _adviseReco * 60).toUTC().time().toString("hh:mm:ss");
|
---|
| 600 | emit(newMessage((_staID + ": Recovery threshold exceeded, corruption ended " + _endDateCor + " " + _endTimeCor).toAscii()));
|
---|
| 601 | callScript(("End_Corrupted " + _endDateCor + " " + _endTimeCor + " Begin was " + _begDateCor + " " + _begTimeCor).toAscii());
|
---|
| 602 | endCorrupt = true;
|
---|
| 603 | begCorrupt = false;
|
---|
| 604 | secFail = 0;
|
---|
| 605 | }
|
---|
[658] | 606 | else {
|
---|
[940] | 607 |
|
---|
| 608 | // Begin corrupt threshold
|
---|
| 609 | // -----------------------
|
---|
| 610 | if ( !begCorrupt && secFail > _adviseFail * 60 ) {
|
---|
| 611 | _begDateCor = _decodeSucc.toUTC().date().toString("yy-MM-dd");
|
---|
| 612 | _begTimeCor = _decodeSucc.toUTC().time().toString("hh:mm:ss");
|
---|
| 613 | emit(newMessage((_staID + ": Failure threshold exceeded, corrupted since " + _begDateCor + " " + _begTimeCor).toAscii()));
|
---|
| 614 | callScript(("Begin_Corrupted " + _begDateCor + " " + _begTimeCor).toAscii());
|
---|
| 615 | begCorrupt = true;
|
---|
| 616 | endCorrupt = false;
|
---|
| 617 | secSucc = 0;
|
---|
| 618 | numSucc = 0;
|
---|
[658] | 619 | }
|
---|
| 620 | }
|
---|
[940] | 621 | decode = true;
|
---|
[658] | 622 | }
|
---|
[650] | 623 | }
|
---|
| 624 | }
|
---|
[940] | 625 |
|
---|
| 626 | // End outage threshold
|
---|
| 627 | // --------------------
|
---|
| 628 | if ( _decodeStart.isValid() && _decodeStart.secsTo(QDateTime::currentDateTime()) > _adviseReco * 60 ) {
|
---|
| 629 | _decodeStart.setDate(QDate());
|
---|
| 630 | _decodeStart.setTime(QTime());
|
---|
| 631 | if (_inspSegm>0) {
|
---|
| 632 | _endDateOut = QDateTime::currentDateTime().addSecs(- _adviseReco * 60).toUTC().date().toString("yy-MM-dd");
|
---|
| 633 | _endTimeOut = QDateTime::currentDateTime().addSecs(- _adviseReco * 60).toUTC().time().toString("hh:mm:ss");
|
---|
| 634 | emit(newMessage((_staID + ": Recovery threshold exceeded, outage ended " + _endDateOut + " " + _endTimeOut).toAscii()));
|
---|
| 635 | callScript(("End_Outage " + _endDateOut + " " + _endTimeOut + " Begin was " + _begDateOut + " " + _begTimeOut).toAscii());
|
---|
| 636 | }
|
---|
[686] | 637 | }
|
---|
[658] | 638 |
|
---|
[331] | 639 | delete [] data;
|
---|
[1044] | 640 |
|
---|
[621] | 641 | QListIterator<p_obs> it(_decoder->_obsList);
|
---|
| 642 | while (it.hasNext()) {
|
---|
| 643 | p_obs obs = it.next();
|
---|
| 644 |
|
---|
[351] | 645 | // Check observation epoch
|
---|
| 646 | // -----------------------
|
---|
[1142] | 647 | if (!_rawInpFile) {
|
---|
| 648 | int week;
|
---|
| 649 | double sec;
|
---|
[1153] | 650 | currentGPSWeeks(week, sec);
|
---|
[1142] | 651 | const double secPerWeek = 7.0 * 24.0 * 3600.0;
|
---|
| 652 |
|
---|
| 653 | if (week < obs->_o.GPSWeek) {
|
---|
| 654 | week += 1;
|
---|
| 655 | sec -= secPerWeek;
|
---|
[658] | 656 | }
|
---|
[1142] | 657 | if (week > obs->_o.GPSWeek) {
|
---|
| 658 | week -= 1;
|
---|
| 659 | sec += secPerWeek;
|
---|
| 660 | }
|
---|
| 661 | double dt = fabs(sec - obs->_o.GPSWeeks);
|
---|
| 662 | if (week != obs->_o.GPSWeek || dt > maxDt) {
|
---|
| 663 | if (!wrongEpoch) {
|
---|
| 664 | emit( newMessage(_staID + ": Wrong observation epoch(s)") );
|
---|
| 665 | wrongEpoch = true;
|
---|
| 666 | }
|
---|
| 667 | delete obs;
|
---|
| 668 | continue;
|
---|
| 669 | }
|
---|
| 670 | else {
|
---|
| 671 | wrongEpoch = false;
|
---|
| 672 |
|
---|
| 673 | // Latency and completeness
|
---|
| 674 | // ------------------------
|
---|
| 675 | if (_perfIntr>0) {
|
---|
| 676 | newSecGPS = static_cast<int>(obs->_o.GPSWeeks);
|
---|
| 677 | if (newSecGPS != oldSecGPS) {
|
---|
| 678 | if (newSecGPS % _perfIntr < oldSecGPS % _perfIntr) {
|
---|
| 679 | if (numLat>0) {
|
---|
| 680 | if (meanDiff>0.) {
|
---|
| 681 | emit( newMessage(QString("%1: Mean latency %2 sec, min %3, max %4, rms %5, %6 epochs, %7 gaps")
|
---|
| 682 | .arg(_staID.data())
|
---|
| 683 | .arg(int(sumLat/numLat*100)/100.)
|
---|
| 684 | .arg(int(minLat*100)/100.)
|
---|
| 685 | .arg(int(maxLat*100)/100.)
|
---|
| 686 | .arg(int((sqrt((sumLatQ - sumLat * sumLat / numLat)/numLat))*100)/100.)
|
---|
| 687 | .arg(numLat)
|
---|
| 688 | .arg(numGaps)
|
---|
| 689 | .toAscii()) );
|
---|
| 690 | } else {
|
---|
| 691 | emit( newMessage(QString("%1: Mean latency %2 sec, min %3, max %4, rms %5, %6 epochs")
|
---|
| 692 | .arg(_staID.data())
|
---|
| 693 | .arg(int(sumLat/numLat*100)/100.)
|
---|
| 694 | .arg(int(minLat*100)/100.)
|
---|
| 695 | .arg(int(maxLat*100)/100.)
|
---|
| 696 | .arg(int((sqrt((sumLatQ - sumLat * sumLat / numLat)/numLat))*100)/100.)
|
---|
| 697 | .arg(numLat)
|
---|
| 698 | .toAscii()) );
|
---|
| 699 | }
|
---|
[728] | 700 | }
|
---|
[1142] | 701 | meanDiff = diffSecGPS/numLat;
|
---|
| 702 | diffSecGPS = 0;
|
---|
| 703 | numGaps = 0;
|
---|
| 704 | sumLat = 0.;
|
---|
| 705 | sumLatQ = 0.;
|
---|
| 706 | numLat = 0;
|
---|
| 707 | minLat = maxDt;
|
---|
| 708 | maxLat = -maxDt;
|
---|
[709] | 709 | }
|
---|
[1142] | 710 | if (followSec) {
|
---|
| 711 | diffSecGPS += newSecGPS - oldSecGPS;
|
---|
| 712 | if (meanDiff>0.) {
|
---|
| 713 | if (newSecGPS - oldSecGPS > 1.5 * meanDiff) {
|
---|
| 714 | numGaps += 1;
|
---|
| 715 | }
|
---|
[728] | 716 | }
|
---|
| 717 | }
|
---|
[1142] | 718 | curLat = sec - obs->_o.GPSWeeks;
|
---|
| 719 | sumLat += curLat;
|
---|
| 720 | sumLatQ += curLat * curLat;
|
---|
| 721 | if (curLat < minLat) minLat = curLat;
|
---|
| 722 | if (curLat >= maxLat) maxLat = curLat;
|
---|
| 723 | numLat += 1;
|
---|
| 724 | oldSecGPS = newSecGPS;
|
---|
| 725 | followSec = true;
|
---|
[728] | 726 | }
|
---|
[709] | 727 | }
|
---|
| 728 | }
|
---|
[658] | 729 | }
|
---|
[351] | 730 |
|
---|
[408] | 731 | // RINEX Output
|
---|
| 732 | // ------------
|
---|
| 733 | if (_rnx) {
|
---|
[1044] | 734 | bool dump = true;
|
---|
| 735 |
|
---|
| 736 | ////RTCM2Decoder* decoder2 = dynamic_cast<RTCM2Decoder*>(_decoder);
|
---|
| 737 | ////if ( decoder2 && !_rnx_set_position ) {
|
---|
| 738 | //// double stax, stay, staz;
|
---|
| 739 | //// if ( decoder2->getStaCrd(stax, stay, staz) == success ) {
|
---|
| 740 | //// _rnx->setApproxPos(stax, stay, staz);
|
---|
| 741 | //// _rnx_set_position = true;
|
---|
| 742 | //// }
|
---|
| 743 | //// else {
|
---|
| 744 | //// dump = false;
|
---|
| 745 | //// }
|
---|
| 746 | ////}
|
---|
| 747 |
|
---|
| 748 | if ( dump ) {
|
---|
| 749 | long iSec = long(floor(obs->_o.GPSWeeks+0.5));
|
---|
| 750 | long newTime = obs->_o.GPSWeek * 7*24*3600 + iSec;
|
---|
| 751 | if (_samplingRate == 0 || iSec % _samplingRate == 0) {
|
---|
| 752 | _rnx->deepCopy(obs);
|
---|
| 753 | }
|
---|
| 754 | _rnx->dumpEpoch(newTime);
|
---|
[1029] | 755 | }
|
---|
| 756 | }
|
---|
[408] | 757 |
|
---|
[1044] | 758 | // Emit new observation signal
|
---|
| 759 | // ---------------------------
|
---|
[621] | 760 | bool firstObs = (obs == _decoder->_obsList.first());
|
---|
[624] | 761 | obs->_status = t_obs::posted;
|
---|
[621] | 762 | emit newObs(_staID, firstObs, obs);
|
---|
[249] | 763 | }
|
---|
| 764 | _decoder->_obsList.clear();
|
---|
[1030] | 765 |
|
---|
| 766 | if ( _checkMountPoint == _staID || _checkMountPoint == "ALL" ) {
|
---|
[1130] | 767 |
|
---|
| 768 | // RTCM message types
|
---|
| 769 | // ------------------
|
---|
[1030] | 770 | if (0<_decoder->_typeList.size()) {
|
---|
| 771 | QString type;
|
---|
| 772 | for (int ii=0;ii<_decoder->_typeList.size();ii++) {
|
---|
| 773 | type = QString("%1 ").arg(_decoder->_typeList[ii]);
|
---|
[1130] | 774 | emit(newMessage(_staID + ": Received message type " + type.toAscii() ));
|
---|
[1030] | 775 | }
|
---|
| 776 | }
|
---|
[1130] | 777 | _decoder->_typeList.clear();
|
---|
| 778 |
|
---|
| 779 | // Antenna XYZ & H
|
---|
| 780 | // ---------------
|
---|
| 781 | if (0<_decoder->_antList.size()) {
|
---|
| 782 | QString ant1,ant2,ant3,ant4;
|
---|
| 783 | for (int ii=0;ii<_decoder->_antList.size();ii+=4) {
|
---|
| 784 | ant1 = QString("%1 ").arg(_decoder->_antList[ii+0]*0.0001,0,'f',4);
|
---|
| 785 | ant2 = QString("%1 ").arg(_decoder->_antList[ii+1]*0.0001,0,'f',4);
|
---|
| 786 | ant3 = QString("%1 ").arg(_decoder->_antList[ii+2]*0.0001,0,'f',4);
|
---|
| 787 | ant4 = QString("%1 ").arg(_decoder->_antList[ii+3]*0.0001,0,'f',4);
|
---|
| 788 | emit(newMessage(_staID + ": ARP (ITRF) X " + ant1.toAscii() + "m" ));
|
---|
| 789 | emit(newMessage(_staID + ": ARP (ITRF) Y " + ant2.toAscii() + "m"));
|
---|
| 790 | emit(newMessage(_staID + ": ARP (ITRF) Z " + ant3.toAscii() + "m"));
|
---|
| 791 | emit(newMessage(_staID + ": Antenna height " + ant4.toAscii() + "m"));
|
---|
| 792 | }
|
---|
| 793 | }
|
---|
| 794 | _decoder->_antList.clear();
|
---|
[1030] | 795 | }
|
---|
[249] | 796 | }
|
---|
[1030] | 797 |
|
---|
| 798 | // Timeout, reconnect
|
---|
| 799 | // ------------------
|
---|
[249] | 800 | else {
|
---|
| 801 | emit(newMessage(_staID + ": Data Timeout, reconnecting"));
|
---|
| 802 | tryReconnect();
|
---|
| 803 | }
|
---|
[35] | 804 | }
|
---|
[249] | 805 | catch (const char* msg) {
|
---|
| 806 | emit(newMessage(_staID + msg));
|
---|
[136] | 807 | tryReconnect();
|
---|
[35] | 808 | }
|
---|
| 809 | }
|
---|
| 810 | }
|
---|
| 811 |
|
---|
| 812 | // Exit
|
---|
| 813 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 814 | void bncGetThread::exit(int exitCode) {
|
---|
| 815 | if (exitCode!= 0) {
|
---|
[88] | 816 | emit error(_staID);
|
---|
[35] | 817 | }
|
---|
| 818 | QThread::exit(exitCode);
|
---|
[148] | 819 | terminate();
|
---|
[35] | 820 | }
|
---|
[82] | 821 |
|
---|
[136] | 822 | // Try Re-Connect
|
---|
| 823 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 824 | void bncGetThread::tryReconnect() {
|
---|
[408] | 825 | if (_rnx) {
|
---|
| 826 | _rnx->setReconnectFlag(true);
|
---|
| 827 | }
|
---|
[658] | 828 | if ( !_decodeStart.isValid()) {
|
---|
| 829 | _decodeStop = QDateTime::currentDateTime();
|
---|
| 830 | }
|
---|
[138] | 831 | while (1) {
|
---|
| 832 | delete _socket; _socket = 0;
|
---|
| 833 | sleep(_nextSleep);
|
---|
| 834 | if ( initRun() == success ) {
|
---|
[658] | 835 | if ( !_decodeStop.isValid()) {
|
---|
| 836 | _decodeStart = QDateTime::currentDateTime();
|
---|
| 837 | }
|
---|
[138] | 838 | break;
|
---|
| 839 | }
|
---|
| 840 | else {
|
---|
[658] | 841 |
|
---|
| 842 | // Begin outage threshold
|
---|
| 843 | // ----------------------
|
---|
[668] | 844 | if ( _decodeStop.isValid() && _decodeStop.secsTo(QDateTime::currentDateTime()) > _adviseFail * 60 ) {
|
---|
[658] | 845 | _decodeStop.setDate(QDate());
|
---|
| 846 | _decodeStop.setTime(QTime());
|
---|
[686] | 847 | if (_inspSegm>0) {
|
---|
[699] | 848 | _begDateOut = _decodeTime.toUTC().date().toString("yy-MM-dd");
|
---|
| 849 | _begTimeOut = _decodeTime.toUTC().time().toString("hh:mm:ss");
|
---|
[701] | 850 | emit(newMessage((_staID + ": Failure threshold exceeded, outage since " + _begDateOut + " " + _begTimeOut).toAscii()));
|
---|
[696] | 851 | callScript(("Begin_Outage " + _begDateOut + " " + _begTimeOut).toAscii());
|
---|
[686] | 852 | }
|
---|
[658] | 853 | }
|
---|
[138] | 854 | _nextSleep *= 2;
|
---|
[442] | 855 | if (_nextSleep > 256) {
|
---|
| 856 | _nextSleep = 256;
|
---|
[152] | 857 | }
|
---|
[277] | 858 | _nextSleep += rand() % 6;
|
---|
[138] | 859 | }
|
---|
| 860 | }
|
---|
| 861 | _nextSleep = 1;
|
---|
[136] | 862 | }
|
---|
[658] | 863 |
|
---|
[668] | 864 | // Call advisory notice script
|
---|
[658] | 865 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 866 | void bncGetThread::callScript(const char* _comment) {
|
---|
[672] | 867 | QMutexLocker locker(&_mutex);
|
---|
[668] | 868 | if (!_adviseScript.isEmpty()) {
|
---|
[672] | 869 | msleep(1);
|
---|
[658] | 870 | #ifdef WIN32
|
---|
[668] | 871 | QProcess::startDetached(_adviseScript, QStringList() << _staID << _comment) ;
|
---|
[658] | 872 | #else
|
---|
[668] | 873 | QProcess::startDetached("nohup", QStringList() << _adviseScript << _staID << _comment) ;
|
---|
[658] | 874 | #endif
|
---|
| 875 | }
|
---|
| 876 | }
|
---|
[1044] | 877 |
|
---|
| 878 | //
|
---|
| 879 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 880 | void bncGetThread::slotNewEphGPS(gpsephemeris gpseph) {
|
---|
| 881 | RTCM2Decoder* decoder = dynamic_cast<RTCM2Decoder*>(_decoder);
|
---|
| 882 |
|
---|
| 883 | if ( decoder ) {
|
---|
| 884 | QMutexLocker locker(&_mutex);
|
---|
| 885 |
|
---|
| 886 | decoder->storeEph(gpseph);
|
---|
| 887 | }
|
---|
| 888 | }
|
---|
| 889 |
|
---|