[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>
|
---|
[1218] | 43 | #include <sstream>
|
---|
[277] | 44 |
|
---|
[35] | 45 | #include <QFile>
|
---|
| 46 | #include <QTextStream>
|
---|
| 47 | #include <QtNetwork>
|
---|
[356] | 48 | #include <QTime>
|
---|
[35] | 49 |
|
---|
| 50 | #include "bncgetthread.h"
|
---|
[192] | 51 | #include "bnctabledlg.h"
|
---|
[243] | 52 | #include "bncapp.h"
|
---|
[352] | 53 | #include "bncutils.h"
|
---|
[408] | 54 | #include "bncrinex.h"
|
---|
[423] | 55 | #include "bnczerodecoder.h"
|
---|
[1387] | 56 | #include "bncnetqueryv1.h"
|
---|
| 57 | #include "bncnetqueryv2.h"
|
---|
[1410] | 58 | #include "bncnetqueryrtp.h"
|
---|
[1535] | 59 | #include "bncsettings.h"
|
---|
[1558] | 60 | #include "latencychecker.h"
|
---|
[65] | 61 |
|
---|
[243] | 62 | #include "RTCM/RTCM2Decoder.h"
|
---|
[297] | 63 | #include "RTCM3/RTCM3Decoder.h"
|
---|
[293] | 64 | #include "RTIGS/RTIGSDecoder.h"
|
---|
[1310] | 65 | #include "GPSS/gpssDecoder.h"
|
---|
[1318] | 66 | #include "serial/qextserialport.h"
|
---|
[35] | 67 |
|
---|
| 68 | using namespace std;
|
---|
| 69 |
|
---|
[1143] | 70 | // Constructor 1
|
---|
[35] | 71 | ////////////////////////////////////////////////////////////////////////////
|
---|
[1138] | 72 | bncGetThread::bncGetThread(const QByteArray& rawInpFileName,
|
---|
| 73 | const QByteArray& format) {
|
---|
| 74 |
|
---|
| 75 | _rawInpFile = new QFile(rawInpFileName);
|
---|
| 76 | _rawInpFile->open(QIODevice::ReadOnly);
|
---|
[1555] | 77 | _format = format;
|
---|
| 78 | _staID = rawInpFileName.mid(
|
---|
| 79 | rawInpFileName.lastIndexOf(QDir::separator())+1,4);
|
---|
[1147] | 80 |
|
---|
[1555] | 81 | initialize();
|
---|
[1138] | 82 | }
|
---|
| 83 |
|
---|
[1143] | 84 | // Constructor 2
|
---|
| 85 | ////////////////////////////////////////////////////////////////////////////
|
---|
[278] | 86 | bncGetThread::bncGetThread(const QUrl& mountPoint,
|
---|
[366] | 87 | const QByteArray& format,
|
---|
| 88 | const QByteArray& latitude,
|
---|
| 89 | const QByteArray& longitude,
|
---|
[1353] | 90 | const QByteArray& nmea,
|
---|
| 91 | const QByteArray& ntripVersion, int iMount) {
|
---|
[1555] | 92 | _rawInpFile = 0;
|
---|
| 93 | _mountPoint = mountPoint;
|
---|
| 94 | _staID = mountPoint.path().mid(1).toAscii();
|
---|
| 95 | _format = format;
|
---|
| 96 | _latitude = latitude;
|
---|
| 97 | _longitude = longitude;
|
---|
| 98 | _nmea = nmea;
|
---|
[1353] | 99 | _ntripVersion = ntripVersion;
|
---|
[1555] | 100 | _iMount = iMount; // index in mountpoints array
|
---|
[1139] | 101 |
|
---|
| 102 | initialize();
|
---|
| 103 | }
|
---|
| 104 |
|
---|
[1555] | 105 | // Initialization (common part of the constructor)
|
---|
[1143] | 106 | ////////////////////////////////////////////////////////////////////////////
|
---|
[1139] | 107 | void bncGetThread::initialize() {
|
---|
| 108 |
|
---|
[1555] | 109 | setTerminationEnabled(true);
|
---|
| 110 |
|
---|
[1225] | 111 | bncApp* app = (bncApp*) qApp;
|
---|
| 112 |
|
---|
[1555] | 113 | connect(this, SIGNAL(newMessage(QByteArray,bool)),
|
---|
| 114 | app, SLOT(slotMessage(const QByteArray,bool)));
|
---|
| 115 |
|
---|
[1525] | 116 | _isToBeDeleted = false;
|
---|
[1555] | 117 | _decoder = 0;
|
---|
| 118 | _query = 0;
|
---|
| 119 | _nextSleep = 0;
|
---|
| 120 | _rawOutFile = 0;
|
---|
| 121 | _staID_orig = _staID;
|
---|
[255] | 122 |
|
---|
| 123 | // Check name conflict
|
---|
| 124 | // -------------------
|
---|
[1535] | 125 | bncSettings settings;
|
---|
[255] | 126 | QListIterator<QString> it(settings.value("mountPoints").toStringList());
|
---|
| 127 | int num = 0;
|
---|
[278] | 128 | int ind = -1;
|
---|
[255] | 129 | while (it.hasNext()) {
|
---|
[278] | 130 | ++ind;
|
---|
[255] | 131 | QStringList hlp = it.next().split(" ");
|
---|
| 132 | if (hlp.size() <= 1) continue;
|
---|
| 133 | QUrl url(hlp[0]);
|
---|
| 134 | if (_mountPoint.path() == url.path()) {
|
---|
[1162] | 135 | if (_iMount > ind || _iMount < 0) {
|
---|
[278] | 136 | ++num;
|
---|
[255] | 137 | }
|
---|
| 138 | }
|
---|
| 139 | }
|
---|
[278] | 140 |
|
---|
| 141 | if (num > 0) {
|
---|
| 142 | _staID = _staID.left(_staID.length()-1) + QString("%1").arg(num).toAscii();
|
---|
[255] | 143 | }
|
---|
[408] | 144 |
|
---|
| 145 | // RINEX writer
|
---|
| 146 | // ------------
|
---|
| 147 | _samplingRate = settings.value("rnxSampl").toInt();
|
---|
| 148 | if ( settings.value("rnxPath").toString().isEmpty() ) {
|
---|
| 149 | _rnx = 0;
|
---|
[1555] | 150 | if (_rawInpFile) {
|
---|
| 151 | cerr << "no RINEX path specified" << endl;
|
---|
| 152 | ::exit(1);
|
---|
| 153 | }
|
---|
[408] | 154 | }
|
---|
| 155 | else {
|
---|
[1353] | 156 | _rnx = new bncRinex(_staID, _mountPoint, _format, _latitude,
|
---|
[1387] | 157 | _longitude, _nmea);
|
---|
[408] | 158 | }
|
---|
| 159 |
|
---|
[1555] | 160 | // Serial Port
|
---|
| 161 | // -----------
|
---|
[1327] | 162 | if (settings.value("serialMountPoint").toString() == _staID) {
|
---|
| 163 | _serialPort = new QextSerialPort(
|
---|
| 164 | settings.value("serialPortName").toString() );
|
---|
[1330] | 165 | QString hlp = settings.value("serialBaudRate").toString();
|
---|
| 166 | if (hlp == "110") {
|
---|
| 167 | _serialPort->setBaudRate(BAUD110);
|
---|
| 168 | }
|
---|
| 169 | else if (hlp == "300") {
|
---|
| 170 | _serialPort->setBaudRate(BAUD300);
|
---|
| 171 | }
|
---|
| 172 | else if (hlp == "600") {
|
---|
| 173 | _serialPort->setBaudRate(BAUD600);
|
---|
| 174 | }
|
---|
| 175 | else if (hlp == "1200") {
|
---|
| 176 | _serialPort->setBaudRate(BAUD1200);
|
---|
| 177 | }
|
---|
| 178 | else if (hlp == "2400") {
|
---|
| 179 | _serialPort->setBaudRate(BAUD2400);
|
---|
| 180 | }
|
---|
| 181 | else if (hlp == "4800") {
|
---|
| 182 | _serialPort->setBaudRate(BAUD4800);
|
---|
| 183 | }
|
---|
| 184 | else if (hlp == "9600") {
|
---|
| 185 | _serialPort->setBaudRate(BAUD9600);
|
---|
| 186 | }
|
---|
| 187 | else if (hlp == "19200") {
|
---|
| 188 | _serialPort->setBaudRate(BAUD19200);
|
---|
| 189 | }
|
---|
| 190 | else if (hlp == "38400") {
|
---|
| 191 | _serialPort->setBaudRate(BAUD38400);
|
---|
| 192 | }
|
---|
| 193 | else if (hlp == "57600") {
|
---|
| 194 | _serialPort->setBaudRate(BAUD57600);
|
---|
| 195 | }
|
---|
| 196 | else if (hlp == "115200") {
|
---|
| 197 | _serialPort->setBaudRate(BAUD115200);
|
---|
| 198 | }
|
---|
| 199 | hlp = settings.value("serialParity").toString();
|
---|
| 200 | if (hlp == "NONE") {
|
---|
| 201 | _serialPort->setParity(PAR_NONE);
|
---|
| 202 | }
|
---|
| 203 | else if (hlp == "ODD") {
|
---|
| 204 | _serialPort->setParity(PAR_ODD);
|
---|
| 205 | }
|
---|
| 206 | else if (hlp == "EVEN") {
|
---|
| 207 | _serialPort->setParity(PAR_EVEN);
|
---|
| 208 | }
|
---|
| 209 | else if (hlp == "SPACE") {
|
---|
| 210 | _serialPort->setParity(PAR_SPACE);
|
---|
| 211 | }
|
---|
| 212 | hlp = settings.value("serialDataBits").toString();
|
---|
| 213 | if (hlp == "5") {
|
---|
| 214 | _serialPort->setDataBits(DATA_5);
|
---|
| 215 | }
|
---|
| 216 | else if (hlp == "6") {
|
---|
| 217 | _serialPort->setDataBits(DATA_6);
|
---|
| 218 | }
|
---|
| 219 | else if (hlp == "7") {
|
---|
| 220 | _serialPort->setDataBits(DATA_7);
|
---|
| 221 | }
|
---|
| 222 | else if (hlp == "8") {
|
---|
| 223 | _serialPort->setDataBits(DATA_8);
|
---|
| 224 | }
|
---|
| 225 | hlp = settings.value("serialStopBits").toString();
|
---|
| 226 | if (hlp == "1") {
|
---|
| 227 | _serialPort->setStopBits(STOP_1);
|
---|
| 228 | }
|
---|
| 229 | else if (hlp == "2") {
|
---|
| 230 | _serialPort->setStopBits(STOP_2);
|
---|
| 231 | }
|
---|
[1326] | 232 | _serialPort->open(QIODevice::ReadWrite|QIODevice::Unbuffered);
|
---|
[1331] | 233 | if (!_serialPort->isOpen()) {
|
---|
| 234 | delete _serialPort;
|
---|
| 235 | _serialPort = 0;
|
---|
[1451] | 236 | emit(newMessage((_staID + ": Cannot open serial port\n"), true));
|
---|
[1331] | 237 | }
|
---|
[1318] | 238 | }
|
---|
| 239 | else {
|
---|
| 240 | _serialPort = 0;
|
---|
| 241 | }
|
---|
| 242 |
|
---|
[1137] | 243 | // Raw Output
|
---|
| 244 | // ----------
|
---|
[1140] | 245 | // QByteArray rawOutFileName = "./" + _staID + ".raw";
|
---|
| 246 | // _rawOutFile = new QFile(rawOutFileName);
|
---|
| 247 | // _rawOutFile->open(QIODevice::WriteOnly);
|
---|
[1137] | 248 |
|
---|
[1555] | 249 |
|
---|
| 250 | // Instantiate the decoder
|
---|
| 251 | // -----------------------
|
---|
| 252 | if (_format.indexOf("RTCM_2") != -1) {
|
---|
| 253 | emit(newMessage(_staID + ": Get data in RTCM 2.x format", true));
|
---|
| 254 | _decoder = new RTCM2Decoder(_staID.data());
|
---|
| 255 | }
|
---|
| 256 | else if (_format.indexOf("RTCM_3") != -1) {
|
---|
| 257 | emit(newMessage(_staID + ": Get data in RTCM 3.x format", true));
|
---|
| 258 | _decoder = new RTCM3Decoder(_staID);
|
---|
| 259 | connect((RTCM3Decoder*) _decoder, SIGNAL(newMessage(QByteArray,bool)),
|
---|
| 260 | this, SIGNAL(newMessage(QByteArray,bool)));
|
---|
| 261 | }
|
---|
| 262 | else if (_format.indexOf("RTIGS") != -1) {
|
---|
| 263 | emit(newMessage(_staID + ": Get data in RTIGS format", true));
|
---|
| 264 | _decoder = new RTIGSDecoder();
|
---|
| 265 | }
|
---|
| 266 | else if (_format.indexOf("GPSS") != -1 || _format.indexOf("BNC") != -1) {
|
---|
| 267 | emit(newMessage(_staID + ": Get Data in GPSS format", true));
|
---|
| 268 | _decoder = new gpssDecoder();
|
---|
| 269 | }
|
---|
| 270 | else if (_format.indexOf("ZERO") != -1) {
|
---|
| 271 | emit(newMessage(_staID + ": Get data in original format", true));
|
---|
| 272 | _decoder = new bncZeroDecoder(_staID);
|
---|
| 273 | }
|
---|
| 274 | else {
|
---|
| 275 | emit(newMessage(_staID + ": Unknown data format " + _format, true));
|
---|
| 276 | _isToBeDeleted = true;
|
---|
| 277 | delete this;
|
---|
| 278 | }
|
---|
| 279 |
|
---|
[1558] | 280 | _latencyChecker = new latencyChecker(_staID);
|
---|
[1557] | 281 |
|
---|
[319] | 282 | msleep(100); //sleep 0.1 sec
|
---|
[35] | 283 | }
|
---|
| 284 |
|
---|
| 285 | // Destructor
|
---|
| 286 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 287 | bncGetThread::~bncGetThread() {
|
---|
[1527] | 288 | if (_query) {
|
---|
| 289 | _query->stop();
|
---|
| 290 | delete _query;
|
---|
| 291 | }
|
---|
[617] | 292 | delete _decoder;
|
---|
[1044] | 293 | delete _rnx;
|
---|
[1138] | 294 | delete _rawInpFile;
|
---|
| 295 | delete _rawOutFile;
|
---|
[1328] | 296 | delete _serialPort;
|
---|
[1557] | 297 | delete _latencyChecker;
|
---|
[1556] | 298 | emit getThreadFinished(_staID);
|
---|
[35] | 299 | }
|
---|
| 300 |
|
---|
[1390] | 301 | //
|
---|
| 302 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 303 | void bncGetThread::terminate() {
|
---|
[1525] | 304 | _isToBeDeleted = true;
|
---|
[1390] | 305 | }
|
---|
| 306 |
|
---|
[136] | 307 | // Run
|
---|
| 308 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 309 | void bncGetThread::run() {
|
---|
| 310 |
|
---|
[35] | 311 | while (true) {
|
---|
[629] | 312 | try {
|
---|
[1555] | 313 | if (_isToBeDeleted) {
|
---|
| 314 | QThread::exit(0);
|
---|
| 315 | this->deleteLater();
|
---|
| 316 | return;
|
---|
[629] | 317 | }
|
---|
[621] | 318 |
|
---|
[1555] | 319 | if (tryReconnect() != success) {
|
---|
| 320 | continue;
|
---|
[621] | 321 | }
|
---|
[1555] | 322 |
|
---|
| 323 | // Delete old observations
|
---|
| 324 | // -----------------------
|
---|
| 325 | QListIterator<p_obs> itOld(_decoder->_obsList);
|
---|
| 326 | while (itOld.hasNext()) {
|
---|
| 327 | delete itOld.next();
|
---|
| 328 | }
|
---|
[621] | 329 | _decoder->_obsList.clear();
|
---|
| 330 |
|
---|
[1555] | 331 | // Read Data
|
---|
| 332 | // ---------
|
---|
[1377] | 333 | QByteArray data;
|
---|
| 334 | if (_query) {
|
---|
| 335 | _query->waitForReadyRead(data);
|
---|
[1138] | 336 | }
|
---|
| 337 | else if (_rawInpFile) {
|
---|
[1146] | 338 | const qint64 maxBytes = 1024;
|
---|
[1555] | 339 | data = _rawInpFile->read(maxBytes);
|
---|
| 340 | if (data.isEmpty()) {
|
---|
| 341 | cout << "no more data" << endl;
|
---|
| 342 | ::exit(0);
|
---|
| 343 | }
|
---|
[1138] | 344 | }
|
---|
[1555] | 345 | qint64 nBytes = data.size();
|
---|
[1138] | 346 |
|
---|
[1555] | 347 | // Timeout, reconnect
|
---|
| 348 | // ------------------
|
---|
| 349 | if (nBytes == 0) {
|
---|
| 350 | emit(newMessage(_staID + ": Data timeout, reconnecting", true));
|
---|
| 351 | continue;
|
---|
| 352 | }
|
---|
| 353 | else {
|
---|
[567] | 354 | emit newBytes(_staID, nBytes);
|
---|
[1555] | 355 | }
|
---|
[567] | 356 |
|
---|
[1555] | 357 | // Output Data
|
---|
| 358 | // -----------
|
---|
| 359 | if (_rawOutFile) {
|
---|
| 360 | _rawOutFile->write(data);
|
---|
| 361 | _rawOutFile->flush();
|
---|
| 362 | }
|
---|
| 363 | if (_serialPort) {
|
---|
| 364 | _serialPort->write(data);
|
---|
| 365 | }
|
---|
| 366 |
|
---|
| 367 | // Decode Data
|
---|
| 368 | // -----------
|
---|
| 369 | vector<string> errmsg;
|
---|
| 370 | _decoder->Decode(data.data(), data.size(), errmsg);
|
---|
[1137] | 371 |
|
---|
[1555] | 372 | // Perform various scans and checks
|
---|
| 373 | // --------------------------------
|
---|
| 374 | scanRTCM();
|
---|
[1557] | 375 | _latencyChecker->check(_decoder);
|
---|
[1138] | 376 |
|
---|
[1555] | 377 | // Loop over all observations (observations output)
|
---|
| 378 | // ------------------------------------------------
|
---|
| 379 | QListIterator<p_obs> it(_decoder->_obsList);
|
---|
| 380 | while (it.hasNext()) {
|
---|
| 381 | p_obs obs = it.next();
|
---|
| 382 |
|
---|
| 383 | // Check observation epoch
|
---|
| 384 | // -----------------------
|
---|
| 385 | if (!_rawInpFile && !dynamic_cast<gpssDecoder*>(_decoder)) {
|
---|
| 386 | int week;
|
---|
| 387 | double sec;
|
---|
| 388 | currentGPSWeeks(week, sec);
|
---|
| 389 | const double secPerWeek = 7.0 * 24.0 * 3600.0;
|
---|
| 390 |
|
---|
| 391 | if (week < obs->_o.GPSWeek) {
|
---|
| 392 | week += 1;
|
---|
| 393 | sec -= secPerWeek;
|
---|
[1218] | 394 | }
|
---|
[1555] | 395 | if (week > obs->_o.GPSWeek) {
|
---|
| 396 | week -= 1;
|
---|
| 397 | sec += secPerWeek;
|
---|
[650] | 398 | }
|
---|
[1555] | 399 | double dt = fabs(sec - obs->_o.GPSWeeks);
|
---|
| 400 | const double maxDt = 600.0;
|
---|
| 401 | if (week != obs->_o.GPSWeek || dt > maxDt) {
|
---|
| 402 | emit( newMessage(_staID + ": Wrong observation epoch(s)", true) );
|
---|
| 403 | delete obs;
|
---|
| 404 | continue;
|
---|
[940] | 405 | }
|
---|
[686] | 406 | }
|
---|
[1555] | 407 |
|
---|
| 408 | // RINEX Output
|
---|
| 409 | // ------------
|
---|
| 410 | if (_rnx) {
|
---|
| 411 | long iSec = long(floor(obs->_o.GPSWeeks+0.5));
|
---|
| 412 | long newTime = obs->_o.GPSWeek * 7*24*3600 + iSec;
|
---|
| 413 | if (_samplingRate == 0 || iSec % _samplingRate == 0) {
|
---|
| 414 | _rnx->deepCopy(obs);
|
---|
[1271] | 415 | }
|
---|
[1555] | 416 | _rnx->dumpEpoch(newTime);
|
---|
[1271] | 417 | }
|
---|
[1555] | 418 |
|
---|
| 419 | // Emit new observation signal
|
---|
| 420 | // ---------------------------
|
---|
| 421 | bool firstObs = (obs == _decoder->_obsList.first());
|
---|
| 422 | obs->_status = t_obs::posted;
|
---|
| 423 | emit newObs(_staID, firstObs, obs);
|
---|
[249] | 424 | }
|
---|
[1555] | 425 | _decoder->_obsList.clear();
|
---|
[35] | 426 | }
|
---|
[249] | 427 | catch (const char* msg) {
|
---|
[1299] | 428 | emit(newMessage(_staID + msg, true));
|
---|
[136] | 429 | tryReconnect();
|
---|
[35] | 430 | }
|
---|
[1555] | 431 | catch (...) {
|
---|
| 432 | emit(newMessage(_staID + "unknown exception", true));
|
---|
| 433 | tryReconnect();
|
---|
| 434 | }
|
---|
[35] | 435 | }
|
---|
| 436 | }
|
---|
| 437 |
|
---|
[136] | 438 | // Try Re-Connect
|
---|
| 439 | ////////////////////////////////////////////////////////////////////////////
|
---|
[1555] | 440 | t_irc bncGetThread::tryReconnect() {
|
---|
| 441 |
|
---|
| 442 | // Easy Return
|
---|
| 443 | // -----------
|
---|
| 444 | if (_query && _query->status() == bncNetQuery::running) {
|
---|
| 445 | _nextSleep = 0;
|
---|
| 446 | return success;
|
---|
[408] | 447 | }
|
---|
[1555] | 448 |
|
---|
| 449 | // Start a new query
|
---|
| 450 | // -----------------
|
---|
| 451 | if (!_rawInpFile) {
|
---|
| 452 |
|
---|
[138] | 453 | sleep(_nextSleep);
|
---|
[1555] | 454 | if (_nextSleep == 0) {
|
---|
| 455 | _nextSleep = 1;
|
---|
[138] | 456 | }
|
---|
| 457 | else {
|
---|
[1555] | 458 | _nextSleep = 2 * _nextSleep;
|
---|
[442] | 459 | if (_nextSleep > 256) {
|
---|
| 460 | _nextSleep = 256;
|
---|
[152] | 461 | }
|
---|
[138] | 462 | }
|
---|
[1555] | 463 |
|
---|
| 464 | delete _query;
|
---|
| 465 | if (_ntripVersion == "R") {
|
---|
| 466 | _query = new bncNetQueryRtp();
|
---|
| 467 | }
|
---|
| 468 | else if (_ntripVersion == "2") {
|
---|
| 469 | _query = new bncNetQueryV2();
|
---|
| 470 | }
|
---|
| 471 | else {
|
---|
| 472 | _query = new bncNetQueryV1();
|
---|
| 473 | }
|
---|
| 474 | if (_nmea == "yes") {
|
---|
| 475 | QByteArray gga = ggaString(_latitude, _longitude);
|
---|
| 476 | _query->startRequest(_mountPoint, gga);
|
---|
| 477 | }
|
---|
| 478 | else {
|
---|
| 479 | _query->startRequest(_mountPoint, "");
|
---|
| 480 | }
|
---|
| 481 | if (_query->status() != bncNetQuery::running) {
|
---|
| 482 | return failure;
|
---|
| 483 | }
|
---|
[138] | 484 | }
|
---|
[658] | 485 |
|
---|
[1555] | 486 | if (_rnx) {
|
---|
| 487 | _rnx->setReconnectFlag(true);
|
---|
[658] | 488 | }
|
---|
[1555] | 489 |
|
---|
| 490 | return success;
|
---|
[658] | 491 | }
|
---|
[1044] | 492 |
|
---|
[1555] | 493 | // RTCM scan output
|
---|
[1044] | 494 | //////////////////////////////////////////////////////////////////////////////
|
---|
[1555] | 495 | void bncGetThread::scanRTCM() {
|
---|
[1044] | 496 |
|
---|
[1555] | 497 | bncSettings settings;
|
---|
| 498 | if ( Qt::CheckState(settings.value("scanRTCM").toInt()) == Qt::Checked) {
|
---|
[1044] | 499 |
|
---|
[1555] | 500 | // RTCMv3 message types
|
---|
| 501 | // --------------------
|
---|
| 502 | for (int ii = 0; ii <_decoder->_typeList.size(); ii++) {
|
---|
| 503 | QString type = QString("%1 ").arg(_decoder->_typeList[ii]);
|
---|
| 504 | emit(newMessage(_staID + ": Received message type " + type.toAscii(), true));
|
---|
| 505 | }
|
---|
| 506 |
|
---|
| 507 | // RTCMv3 antenna descriptor
|
---|
| 508 | // -------------------------
|
---|
| 509 | for (int ii=0;ii<_decoder->_antType.size();ii++) {
|
---|
| 510 | QString ant1 = QString("%1 ").arg(_decoder->_antType[ii]);
|
---|
| 511 | emit(newMessage(_staID + ": Antenna descriptor " + ant1.toAscii(), true));
|
---|
| 512 | }
|
---|
| 513 |
|
---|
| 514 | // Antenna Coordinates
|
---|
| 515 | // -------------------
|
---|
| 516 | for (int ii=0; ii <_decoder->_antList.size(); ii++) {
|
---|
| 517 | QByteArray antT;
|
---|
| 518 | if (_decoder->_antList[ii].type == GPSDecoder::t_antInfo::ARP) {
|
---|
| 519 | antT = "ARP";
|
---|
[1218] | 520 | }
|
---|
[1555] | 521 | else if (_decoder->_antList[ii].type == GPSDecoder::t_antInfo::APC) {
|
---|
| 522 | antT = "APC";
|
---|
| 523 | }
|
---|
| 524 | emit(newAntCrd(_staID, _decoder->_antList[ii].xx,
|
---|
| 525 | _decoder->_antList[ii].yy, _decoder->_antList[ii].zz,
|
---|
| 526 | antT));
|
---|
[1218] | 527 | }
|
---|
[1044] | 528 | }
|
---|
[1555] | 529 |
|
---|
| 530 | _decoder->_typeList.clear();
|
---|
| 531 | _decoder->_antType.clear();
|
---|
| 532 | _decoder->_antList.clear();
|
---|
[1044] | 533 | }
|
---|
[1555] | 534 |
|
---|