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