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