[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 | *
|
---|
[7486] | 37 | * Changes:
|
---|
[35] | 38 | *
|
---|
| 39 | * -----------------------------------------------------------------------*/
|
---|
| 40 |
|
---|
[277] | 41 | #include <stdlib.h>
|
---|
[1044] | 42 | #include <iomanip>
|
---|
[1218] | 43 | #include <sstream>
|
---|
[277] | 44 |
|
---|
[8127] | 45 | #include <QComboBox>
|
---|
| 46 | #include <QDialog>
|
---|
[35] | 47 | #include <QFile>
|
---|
| 48 | #include <QTextStream>
|
---|
[5524] | 49 | #include <QMutex>
|
---|
[8127] | 50 | #include <QPushButton>
|
---|
| 51 | #include <QTableWidget>
|
---|
[356] | 52 | #include <QTime>
|
---|
[35] | 53 |
|
---|
| 54 | #include "bncgetthread.h"
|
---|
[192] | 55 | #include "bnctabledlg.h"
|
---|
[5070] | 56 | #include "bnccore.h"
|
---|
[352] | 57 | #include "bncutils.h"
|
---|
[8417] | 58 | #include "bnctime.h"
|
---|
[423] | 59 | #include "bnczerodecoder.h"
|
---|
[1621] | 60 | #include "bncnetqueryv0.h"
|
---|
[1387] | 61 | #include "bncnetqueryv1.h"
|
---|
| 62 | #include "bncnetqueryv2.h"
|
---|
[1410] | 63 | #include "bncnetqueryrtp.h"
|
---|
[1721] | 64 | #include "bncnetqueryudp.h"
|
---|
[1779] | 65 | #include "bncnetqueryudp0.h"
|
---|
[1753] | 66 | #include "bncnetquerys.h"
|
---|
[1535] | 67 | #include "bncsettings.h"
|
---|
[1558] | 68 | #include "latencychecker.h"
|
---|
[3168] | 69 | #include "upload/bncrtnetdecoder.h"
|
---|
[243] | 70 | #include "RTCM/RTCM2Decoder.h"
|
---|
[297] | 71 | #include "RTCM3/RTCM3Decoder.h"
|
---|
[1318] | 72 | #include "serial/qextserialport.h"
|
---|
[35] | 73 |
|
---|
| 74 | using namespace std;
|
---|
| 75 |
|
---|
[1143] | 76 | // Constructor 1
|
---|
[35] | 77 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2519] | 78 | bncGetThread::bncGetThread(bncRawFile* rawFile) {
|
---|
[1138] | 79 |
|
---|
[8082] | 80 | _rawFile = rawFile;
|
---|
| 81 | _format = rawFile->format();
|
---|
| 82 | _staID = rawFile->staID();
|
---|
| 83 | _rawOutput = false;
|
---|
[2390] | 84 | _ntripVersion = "N";
|
---|
| 85 |
|
---|
[1555] | 86 | initialize();
|
---|
[1138] | 87 | }
|
---|
| 88 |
|
---|
[1143] | 89 | // Constructor 2
|
---|
| 90 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8082] | 91 | bncGetThread::bncGetThread(const QUrl& mountPoint, const QByteArray& format,
|
---|
| 92 | const QByteArray& latitude, const QByteArray& longitude,
|
---|
| 93 | const QByteArray& nmea, const QByteArray& ntripVersion) {
|
---|
| 94 | _rawFile = 0;
|
---|
| 95 | _mountPoint = mountPoint;
|
---|
[8127] | 96 | _staID = mountPoint.path().mid(1).toLatin1();
|
---|
[8082] | 97 | _format = format;
|
---|
| 98 | _latitude = latitude;
|
---|
| 99 | _longitude = longitude;
|
---|
| 100 | _nmea = nmea;
|
---|
[1353] | 101 | _ntripVersion = ntripVersion;
|
---|
[1139] | 102 |
|
---|
[2386] | 103 | bncSettings settings;
|
---|
| 104 | if (!settings.value("rawOutFile").toString().isEmpty()) {
|
---|
| 105 | _rawOutput = true;
|
---|
[8271] | 106 | }
|
---|
| 107 | else {
|
---|
[3734] | 108 | _rawOutput = false;
|
---|
[2386] | 109 | }
|
---|
[8271] | 110 | if (!settings.value("miscMount").toString().isEmpty()) {
|
---|
| 111 | _latencycheck = true;
|
---|
| 112 | }
|
---|
| 113 | else {
|
---|
| 114 | _latencycheck = false;
|
---|
| 115 | }
|
---|
[1139] | 116 | initialize();
|
---|
[3523] | 117 | initDecoder();
|
---|
[1139] | 118 | }
|
---|
| 119 |
|
---|
[1555] | 120 | // Initialization (common part of the constructor)
|
---|
[1143] | 121 | ////////////////////////////////////////////////////////////////////////////
|
---|
[1139] | 122 | void bncGetThread::initialize() {
|
---|
| 123 |
|
---|
[3528] | 124 | bncSettings settings;
|
---|
| 125 |
|
---|
[1555] | 126 | setTerminationEnabled(true);
|
---|
| 127 |
|
---|
[7486] | 128 | connect(this, SIGNAL(newMessage(QByteArray,bool)),
|
---|
[8082] | 129 | BNC_CORE, SLOT(slotMessage(const QByteArray,bool)));
|
---|
[1555] | 130 |
|
---|
[1525] | 131 | _isToBeDeleted = false;
|
---|
[8082] | 132 | _query = 0;
|
---|
| 133 | _nextSleep = 0;
|
---|
| 134 | _miscMount = settings.value("miscMount").toString();
|
---|
| 135 | _decoder = 0;
|
---|
[255] | 136 |
|
---|
[7180] | 137 | // NMEA Port
|
---|
| 138 | // -----------
|
---|
| 139 | QListIterator<QString> iSta(settings.value("PPP/staTable").toStringList());
|
---|
| 140 | int nmeaPort = 0;
|
---|
| 141 | while (iSta.hasNext()) {
|
---|
| 142 | QStringList hlp = iSta.next().split(",");
|
---|
[8082] | 143 | if (hlp.size() < 10) {
|
---|
| 144 | continue;
|
---|
| 145 | }
|
---|
[8127] | 146 | QByteArray mp = hlp[0].toLatin1();
|
---|
[7180] | 147 | if (_staID == mp) {
|
---|
| 148 | nmeaPort = hlp[9].toInt();
|
---|
| 149 | }
|
---|
| 150 | }
|
---|
| 151 | if (nmeaPort != 0) {
|
---|
| 152 | _nmeaServer = new QTcpServer;
|
---|
[8082] | 153 | if (!_nmeaServer->listen(QHostAddress::Any, nmeaPort)) {
|
---|
[7180] | 154 | emit newMessage("bncCaster: Cannot listen on port", true);
|
---|
[8082] | 155 | } else {
|
---|
| 156 | connect(_nmeaServer, SIGNAL(newConnection()), this,
|
---|
| 157 | SLOT(slotNewNMEAConnection()));
|
---|
| 158 | connect(BNC_CORE, SIGNAL(newNMEAstr(QByteArray, QByteArray)), this,
|
---|
| 159 | SLOT(slotNewNMEAstr(QByteArray, QByteArray)));
|
---|
[7180] | 160 | _nmeaSockets = new QList<QTcpSocket*>;
|
---|
| 161 | _nmeaPortsMap[_staID] = nmeaPort;
|
---|
| 162 | }
|
---|
| 163 | } else {
|
---|
| 164 | _nmeaServer = 0;
|
---|
| 165 | _nmeaSockets = 0;
|
---|
| 166 | }
|
---|
| 167 |
|
---|
[1555] | 168 | // Serial Port
|
---|
| 169 | // -----------
|
---|
[8082] | 170 | _serialNMEA = NO_NMEA;
|
---|
[1710] | 171 | _serialOutFile = 0;
|
---|
[8082] | 172 | _serialPort = 0;
|
---|
[1710] | 173 |
|
---|
[8082] | 174 | if (!_staID.isEmpty()
|
---|
| 175 | && settings.value("serialMountPoint").toString() == _staID) {
|
---|
| 176 | _serialPort = new QextSerialPort(
|
---|
| 177 | settings.value("serialPortName").toString());
|
---|
| 178 | _serialPort->setTimeout(0, 100);
|
---|
[1710] | 179 |
|
---|
| 180 | // Baud Rate
|
---|
| 181 | // ---------
|
---|
[1330] | 182 | QString hlp = settings.value("serialBaudRate").toString();
|
---|
[8082] | 183 | if (hlp == "110") {
|
---|
[7486] | 184 | _serialPort->setBaudRate(BAUD110);
|
---|
[8082] | 185 | } else if (hlp == "300") {
|
---|
[7486] | 186 | _serialPort->setBaudRate(BAUD300);
|
---|
[8082] | 187 | } else if (hlp == "600") {
|
---|
[7486] | 188 | _serialPort->setBaudRate(BAUD600);
|
---|
[8082] | 189 | } else if (hlp == "1200") {
|
---|
[7486] | 190 | _serialPort->setBaudRate(BAUD1200);
|
---|
[8082] | 191 | } else if (hlp == "2400") {
|
---|
[7486] | 192 | _serialPort->setBaudRate(BAUD2400);
|
---|
[8082] | 193 | } else if (hlp == "4800") {
|
---|
[7486] | 194 | _serialPort->setBaudRate(BAUD4800);
|
---|
[8082] | 195 | } else if (hlp == "9600") {
|
---|
[7486] | 196 | _serialPort->setBaudRate(BAUD9600);
|
---|
[8082] | 197 | } else if (hlp == "19200") {
|
---|
[7486] | 198 | _serialPort->setBaudRate(BAUD19200);
|
---|
[8082] | 199 | } else if (hlp == "38400") {
|
---|
[7486] | 200 | _serialPort->setBaudRate(BAUD38400);
|
---|
[8082] | 201 | } else if (hlp == "57600") {
|
---|
[7486] | 202 | _serialPort->setBaudRate(BAUD57600);
|
---|
[8082] | 203 | } else if (hlp == "115200") {
|
---|
[7486] | 204 | _serialPort->setBaudRate(BAUD115200);
|
---|
[1330] | 205 | }
|
---|
[1710] | 206 |
|
---|
| 207 | // Parity
|
---|
| 208 | // ------
|
---|
[1330] | 209 | hlp = settings.value("serialParity").toString();
|
---|
[8082] | 210 | if (hlp == "NONE") {
|
---|
[7486] | 211 | _serialPort->setParity(PAR_NONE);
|
---|
[8082] | 212 | } else if (hlp == "ODD") {
|
---|
[7486] | 213 | _serialPort->setParity(PAR_ODD);
|
---|
[8082] | 214 | } else if (hlp == "EVEN") {
|
---|
[7486] | 215 | _serialPort->setParity(PAR_EVEN);
|
---|
[8082] | 216 | } else if (hlp == "SPACE") {
|
---|
[7486] | 217 | _serialPort->setParity(PAR_SPACE);
|
---|
[1330] | 218 | }
|
---|
[1710] | 219 |
|
---|
| 220 | // Data Bits
|
---|
| 221 | // ---------
|
---|
[1330] | 222 | hlp = settings.value("serialDataBits").toString();
|
---|
[8082] | 223 | if (hlp == "5") {
|
---|
[7486] | 224 | _serialPort->setDataBits(DATA_5);
|
---|
[8082] | 225 | } else if (hlp == "6") {
|
---|
[7486] | 226 | _serialPort->setDataBits(DATA_6);
|
---|
[8082] | 227 | } else if (hlp == "7") {
|
---|
[7486] | 228 | _serialPort->setDataBits(DATA_7);
|
---|
[8082] | 229 | } else if (hlp == "8") {
|
---|
[7486] | 230 | _serialPort->setDataBits(DATA_8);
|
---|
[1330] | 231 | }
|
---|
| 232 | hlp = settings.value("serialStopBits").toString();
|
---|
[8082] | 233 | if (hlp == "1") {
|
---|
[7486] | 234 | _serialPort->setStopBits(STOP_1);
|
---|
[8082] | 235 | } else if (hlp == "2") {
|
---|
[7486] | 236 | _serialPort->setStopBits(STOP_2);
|
---|
[1330] | 237 | }
|
---|
[1710] | 238 |
|
---|
| 239 | // Flow Control
|
---|
| 240 | // ------------
|
---|
| 241 | hlp = settings.value("serialFlowControl").toString();
|
---|
[1711] | 242 | if (hlp == "XONXOFF") {
|
---|
[7486] | 243 | _serialPort->setFlowControl(FLOW_XONXOFF);
|
---|
[8082] | 244 | } else if (hlp == "HARDWARE") {
|
---|
[7486] | 245 | _serialPort->setFlowControl(FLOW_HARDWARE);
|
---|
[8082] | 246 | } else {
|
---|
[7486] | 247 | _serialPort->setFlowControl(FLOW_OFF);
|
---|
[1711] | 248 | }
|
---|
[1710] | 249 |
|
---|
| 250 | // Open Serial Port
|
---|
| 251 | // ----------------
|
---|
[8082] | 252 | _serialPort->open(QIODevice::ReadWrite | QIODevice::Unbuffered);
|
---|
[1331] | 253 | if (!_serialPort->isOpen()) {
|
---|
| 254 | delete _serialPort;
|
---|
| 255 | _serialPort = 0;
|
---|
[1451] | 256 | emit(newMessage((_staID + ": Cannot open serial port\n"), true));
|
---|
[1331] | 257 | }
|
---|
[8082] | 258 | connect(_serialPort, SIGNAL(readyRead()), this,
|
---|
| 259 | SLOT(slotSerialReadyRead()));
|
---|
[1606] | 260 |
|
---|
[1710] | 261 | // Automatic NMEA
|
---|
| 262 | // --------------
|
---|
[6785] | 263 | QString nmeaMode = settings.value("serialAutoNMEA").toString();
|
---|
| 264 | if (nmeaMode == "Auto") {
|
---|
[1710] | 265 | _serialNMEA = AUTO_NMEA;
|
---|
| 266 | QString fName = settings.value("serialFileNMEA").toString();
|
---|
| 267 | if (!fName.isEmpty()) {
|
---|
| 268 | _serialOutFile = new QFile(fName);
|
---|
[8082] | 269 | if (Qt::CheckState(settings.value("rnxAppend").toInt())
|
---|
| 270 | == Qt::Checked) {
|
---|
[1710] | 271 | _serialOutFile->open(QIODevice::WriteOnly | QIODevice::Append);
|
---|
[8082] | 272 | } else {
|
---|
[1710] | 273 | _serialOutFile->open(QIODevice::WriteOnly);
|
---|
| 274 | }
|
---|
[1634] | 275 | }
|
---|
[1606] | 276 | }
|
---|
[1710] | 277 | // Manual NMEA
|
---|
| 278 | // -----------
|
---|
[8082] | 279 | if ((nmeaMode == "Manual GPGGA") || (nmeaMode == "Manual GNGGA")) {
|
---|
[1710] | 280 | _serialNMEA = MANUAL_NMEA;
|
---|
[6751] | 281 | bncSettings settings;
|
---|
| 282 | _manualNMEASampl = settings.value("serialManualNMEASampling").toInt();
|
---|
[8082] | 283 | QString hlp = settings.value("serialHeightNMEA").toString();
|
---|
[6751] | 284 | if (hlp.isEmpty()) {
|
---|
| 285 | hlp = "0.0";
|
---|
| 286 | }
|
---|
[8127] | 287 | QByteArray _serialHeightNMEA = hlp.toLatin1();
|
---|
[8082] | 288 | _manualNMEAString = ggaString(_latitude, _longitude, _serialHeightNMEA,
|
---|
| 289 | nmeaMode);
|
---|
[1636] | 290 | }
|
---|
[1318] | 291 | }
|
---|
| 292 |
|
---|
[8271] | 293 | if (!_staID.isEmpty() && _latencycheck) {
|
---|
[3532] | 294 | _latencyChecker = new latencyChecker(_staID);
|
---|
[8082] | 295 | obs = false;
|
---|
| 296 | ssrOrb = false;
|
---|
| 297 | ssrClk = false;
|
---|
| 298 | ssrOrbClk = false;
|
---|
| 299 | ssrCbi = false;
|
---|
| 300 | ssrPbi = false;
|
---|
| 301 | ssrVtec = false;
|
---|
| 302 | ssrUra = false;
|
---|
| 303 | ssrHr = false;
|
---|
| 304 | _oldSsrEpoch = 0;
|
---|
| 305 | _ssrEpoch = 0;
|
---|
| 306 | } else {
|
---|
[3532] | 307 | _latencyChecker = 0;
|
---|
| 308 | }
|
---|
[3523] | 309 | }
|
---|
| 310 |
|
---|
| 311 | // Instantiate the decoder
|
---|
| 312 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 313 | t_irc bncGetThread::initDecoder() {
|
---|
| 314 |
|
---|
[3560] | 315 | _decoder = 0;
|
---|
| 316 |
|
---|
[8082] | 317 | if (_format.indexOf("RTCM_2") != -1 || _format.indexOf("RTCM2") != -1
|
---|
| 318 | || _format.indexOf("RTCM 2") != -1) {
|
---|
[1555] | 319 | emit(newMessage(_staID + ": Get data in RTCM 2.x format", true));
|
---|
[3560] | 320 | _decoder = new RTCM2Decoder(_staID.data());
|
---|
[8082] | 321 | } else if (_format.indexOf("RTCM_3") != -1 || _format.indexOf("RTCM3") != -1
|
---|
| 322 | || _format.indexOf("RTCM 3") != -1) {
|
---|
[1555] | 323 | emit(newMessage(_staID + ": Get data in RTCM 3.x format", true));
|
---|
[3558] | 324 | RTCM3Decoder* newDecoder = new RTCM3Decoder(_staID, _rawFile);
|
---|
[3560] | 325 | _decoder = newDecoder;
|
---|
[7486] | 326 | connect((RTCM3Decoder*) newDecoder, SIGNAL(newMessage(QByteArray,bool)),
|
---|
[8082] | 327 | this, SIGNAL(newMessage(QByteArray,bool)));
|
---|
| 328 | } else if (_format.indexOf("ZERO") != -1) {
|
---|
[1555] | 329 | emit(newMessage(_staID + ": Get data in original format", true));
|
---|
[3560] | 330 | _decoder = new bncZeroDecoder(_staID);
|
---|
[8082] | 331 | } else if (_format.indexOf("RTNET") != -1) {
|
---|
[3168] | 332 | emit(newMessage(_staID + ": Get data in RTNet format", true));
|
---|
[3560] | 333 | _decoder = new bncRtnetDecoder();
|
---|
[8082] | 334 | } else {
|
---|
[1555] | 335 | emit(newMessage(_staID + ": Unknown data format " + _format, true));
|
---|
| 336 | _isToBeDeleted = true;
|
---|
[3523] | 337 | return failure;
|
---|
[1555] | 338 | }
|
---|
| 339 |
|
---|
[319] | 340 | msleep(100); //sleep 0.1 sec
|
---|
[7486] | 341 |
|
---|
[8082] | 342 | _decoder->initRinex(_staID, _mountPoint, _latitude, _longitude, _nmea,
|
---|
| 343 | _ntripVersion);
|
---|
[3560] | 344 |
|
---|
| 345 | if (_rawFile) {
|
---|
| 346 | _decodersRaw[_staID] = _decoder;
|
---|
[3530] | 347 | }
|
---|
| 348 |
|
---|
[3523] | 349 | return success;
|
---|
[35] | 350 | }
|
---|
| 351 |
|
---|
[3523] | 352 | // Current decoder in use
|
---|
| 353 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 354 | GPSDecoder* bncGetThread::decoder() {
|
---|
[3560] | 355 | if (!_rawFile) {
|
---|
| 356 | return _decoder;
|
---|
[8082] | 357 | } else {
|
---|
[3560] | 358 | if (_decodersRaw.contains(_staID) || initDecoder() == success) {
|
---|
| 359 | return _decodersRaw[_staID];
|
---|
| 360 | }
|
---|
[3523] | 361 | }
|
---|
[3560] | 362 | return 0;
|
---|
[3523] | 363 | }
|
---|
| 364 |
|
---|
[35] | 365 | // Destructor
|
---|
| 366 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 367 | bncGetThread::~bncGetThread() {
|
---|
[1928] | 368 | if (isRunning()) {
|
---|
| 369 | wait();
|
---|
| 370 | }
|
---|
[1527] | 371 | if (_query) {
|
---|
| 372 | _query->stop();
|
---|
[1708] | 373 | _query->deleteLater();
|
---|
[1527] | 374 | }
|
---|
[3560] | 375 | if (_rawFile) {
|
---|
| 376 | QMapIterator<QString, GPSDecoder*> it(_decodersRaw);
|
---|
| 377 | while (it.hasNext()) {
|
---|
| 378 | it.next();
|
---|
| 379 | delete it.value();
|
---|
| 380 | }
|
---|
[8082] | 381 | } else {
|
---|
[3560] | 382 | delete _decoder;
|
---|
| 383 | }
|
---|
[2519] | 384 | delete _rawFile;
|
---|
[1607] | 385 | delete _serialOutFile;
|
---|
[1328] | 386 | delete _serialPort;
|
---|
[1557] | 387 | delete _latencyChecker;
|
---|
[1556] | 388 | emit getThreadFinished(_staID);
|
---|
[35] | 389 | }
|
---|
| 390 |
|
---|
[7486] | 391 | //
|
---|
[1390] | 392 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 393 | void bncGetThread::terminate() {
|
---|
[1525] | 394 | _isToBeDeleted = true;
|
---|
[7854] | 395 |
|
---|
[8082] | 396 | if (_nmeaPortsMap.contains(_staID)) {
|
---|
[7854] | 397 | _nmeaPortsMap.remove(_staID);
|
---|
[1559] | 398 | }
|
---|
[7854] | 399 | if (_nmeaServer) {
|
---|
| 400 | delete _nmeaServer;
|
---|
| 401 | }
|
---|
| 402 | if (_nmeaSockets) {
|
---|
| 403 | delete _nmeaSockets;
|
---|
| 404 | }
|
---|
[7858] | 405 |
|
---|
| 406 | #ifdef BNC_DEBUG
|
---|
[7859] | 407 | if (BNC_CORE->mode() != t_bncCore::interactive) {
|
---|
[8082] | 408 | while (!isFinished()) {
|
---|
| 409 | wait();
|
---|
| 410 | }
|
---|
[7859] | 411 | delete this;
|
---|
[8082] | 412 | } else {
|
---|
| 413 | if (!isRunning()) {
|
---|
| 414 | delete this;
|
---|
| 415 | }
|
---|
[7858] | 416 | }
|
---|
| 417 | #else
|
---|
[8082] | 418 | if (!isRunning()) {delete this;}
|
---|
[7858] | 419 | #endif
|
---|
| 420 |
|
---|
[1390] | 421 | }
|
---|
| 422 |
|
---|
[136] | 423 | // Run
|
---|
| 424 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 425 | void bncGetThread::run() {
|
---|
| 426 |
|
---|
[35] | 427 | while (true) {
|
---|
[629] | 428 | try {
|
---|
[1555] | 429 | if (_isToBeDeleted) {
|
---|
| 430 | QThread::exit(0);
|
---|
| 431 | this->deleteLater();
|
---|
| 432 | return;
|
---|
[629] | 433 | }
|
---|
[621] | 434 |
|
---|
[1555] | 435 | if (tryReconnect() != success) {
|
---|
[3532] | 436 | if (_latencyChecker) {
|
---|
| 437 | _latencyChecker->checkReconnect();
|
---|
| 438 | }
|
---|
[1555] | 439 | continue;
|
---|
[621] | 440 | }
|
---|
[1555] | 441 |
|
---|
| 442 | // Delete old observations
|
---|
| 443 | // -----------------------
|
---|
[3560] | 444 | if (_rawFile) {
|
---|
| 445 | QMapIterator<QString, GPSDecoder*> itDec(_decodersRaw);
|
---|
| 446 | while (itDec.hasNext()) {
|
---|
| 447 | itDec.next();
|
---|
| 448 | GPSDecoder* decoder = itDec.value();
|
---|
| 449 | decoder->_obsList.clear();
|
---|
| 450 | }
|
---|
[8082] | 451 | } else {
|
---|
[3560] | 452 | _decoder->_obsList.clear();
|
---|
| 453 | }
|
---|
[621] | 454 |
|
---|
[1555] | 455 | // Read Data
|
---|
| 456 | // ---------
|
---|
[1377] | 457 | QByteArray data;
|
---|
[8082] | 458 | if (_query) {
|
---|
[1377] | 459 | _query->waitForReadyRead(data);
|
---|
[8082] | 460 | } else if (_rawFile) {
|
---|
[2527] | 461 | data = _rawFile->readChunk();
|
---|
[3523] | 462 | _format = _rawFile->format();
|
---|
[8082] | 463 | _staID = _rawFile->staID();
|
---|
[2388] | 464 |
|
---|
[5903] | 465 | QCoreApplication::processEvents();
|
---|
| 466 |
|
---|
[7976] | 467 | if (data.isEmpty() || BNC_CORE->sigintReceived) {
|
---|
| 468 | cout << "no more data or Ctrl-C received" << endl;
|
---|
[5068] | 469 | BNC_CORE->stopCombination();
|
---|
[5900] | 470 | BNC_CORE->stopPPP();
|
---|
[5903] | 471 | ::exit(0);
|
---|
[1555] | 472 | }
|
---|
[1138] | 473 | }
|
---|
[8123] | 474 |
|
---|
[1555] | 475 | qint64 nBytes = data.size();
|
---|
[1138] | 476 |
|
---|
[1555] | 477 | // Timeout, reconnect
|
---|
| 478 | // ------------------
|
---|
| 479 | if (nBytes == 0) {
|
---|
[3532] | 480 | if (_latencyChecker) {
|
---|
| 481 | _latencyChecker->checkReconnect();
|
---|
| 482 | }
|
---|
[1555] | 483 | emit(newMessage(_staID + ": Data timeout, reconnecting", true));
|
---|
[2355] | 484 | msleep(10000); //sleep 10 sec, G. Weber
|
---|
[1555] | 485 | continue;
|
---|
[8082] | 486 | } else {
|
---|
[567] | 487 | emit newBytes(_staID, nBytes);
|
---|
[5648] | 488 | emit newRawData(_staID, data);
|
---|
[1555] | 489 | }
|
---|
[567] | 490 |
|
---|
[1555] | 491 | // Output Data
|
---|
| 492 | // -----------
|
---|
[2386] | 493 | if (_rawOutput) {
|
---|
[7486] | 494 | BNC_CORE->writeRawData(data, _staID, _format);
|
---|
[2386] | 495 | }
|
---|
[2385] | 496 |
|
---|
[1555] | 497 | if (_serialPort) {
|
---|
[1633] | 498 | slotSerialReadyRead();
|
---|
[1555] | 499 | _serialPort->write(data);
|
---|
| 500 | }
|
---|
[7486] | 501 |
|
---|
[1555] | 502 | // Decode Data
|
---|
| 503 | // -----------
|
---|
| 504 | vector<string> errmsg;
|
---|
[3526] | 505 | if (!decoder()) {
|
---|
| 506 | _isToBeDeleted = true;
|
---|
| 507 | continue;
|
---|
| 508 | }
|
---|
[7753] | 509 |
|
---|
[3523] | 510 | t_irc irc = decoder()->Decode(data.data(), data.size(), errmsg);
|
---|
[1137] | 511 |
|
---|
[7753] | 512 | if (irc != success) {
|
---|
| 513 | continue;
|
---|
| 514 | }
|
---|
[1555] | 515 | // Perform various scans and checks
|
---|
| 516 | // --------------------------------
|
---|
[3532] | 517 | if (_latencyChecker) {
|
---|
[8271] | 518 | _latencyChecker->checkOutage(irc);
|
---|
[8082] | 519 | QListIterator<int> it(decoder()->_typeList);
|
---|
[8271] | 520 | _ssrEpoch = static_cast<int>(decoder()->corrGPSEpochTime());
|
---|
| 521 | if (_oldSsrEpoch != -1 && _ssrEpoch != _oldSsrEpoch) {
|
---|
[8082] | 522 | if (ssrOrb) {
|
---|
| 523 | _latencyChecker->checkCorrLatency(_oldSsrEpoch, 1057);
|
---|
| 524 | ssrOrb = false;
|
---|
| 525 | }
|
---|
| 526 | if (ssrClk) {
|
---|
| 527 | _latencyChecker->checkCorrLatency(_oldSsrEpoch, 1058);
|
---|
| 528 | ssrClk = false;
|
---|
| 529 | }
|
---|
| 530 | if (ssrOrbClk) {
|
---|
| 531 | _latencyChecker->checkCorrLatency(_oldSsrEpoch, 1060);
|
---|
| 532 | ssrOrbClk = false;
|
---|
| 533 | }
|
---|
| 534 | if (ssrCbi) {
|
---|
| 535 | _latencyChecker->checkCorrLatency(_oldSsrEpoch, 1059);
|
---|
| 536 | ssrCbi = false;
|
---|
| 537 | }
|
---|
| 538 | if (ssrPbi) {
|
---|
| 539 | _latencyChecker->checkCorrLatency(_oldSsrEpoch, 1265);
|
---|
| 540 | ssrPbi = false;
|
---|
| 541 | }
|
---|
| 542 | if (ssrVtec) {
|
---|
| 543 | _latencyChecker->checkCorrLatency(_oldSsrEpoch, 1264);
|
---|
| 544 | ssrVtec = false;
|
---|
| 545 | }
|
---|
| 546 | if (ssrUra) {
|
---|
| 547 | _latencyChecker->checkCorrLatency(_oldSsrEpoch, 1061);
|
---|
| 548 | ssrUra = false;
|
---|
| 549 | }
|
---|
| 550 | if (ssrHr) {
|
---|
| 551 | _latencyChecker->checkCorrLatency(_oldSsrEpoch, 1062);
|
---|
| 552 | ssrHr = false;
|
---|
| 553 | }
|
---|
| 554 | }
|
---|
| 555 | while (it.hasNext()) {
|
---|
| 556 | int rtcmType = it.next();
|
---|
| 557 | if ((rtcmType >= 1001 && rtcmType <= 1004) || // legacy RTCM OBS
|
---|
| 558 | (rtcmType >= 1009 && rtcmType <= 1012) || // legacy RTCM OBS
|
---|
| 559 | (rtcmType >= 1071 && rtcmType <= 1127)) { // MSM RTCM OBS
|
---|
| 560 | obs = true;
|
---|
| 561 | } else if ((rtcmType >= 1057 && rtcmType <= 1068) ||
|
---|
| 562 | (rtcmType >= 1240 && rtcmType <= 1270)) {
|
---|
| 563 | switch (rtcmType) {
|
---|
| 564 | case 1057: case 1063: case 1240: case 1246: case 1252: case 1258:
|
---|
| 565 | ssrOrb = true;
|
---|
| 566 | break;
|
---|
| 567 | case 1058: case 1064: case 1241: case 1247: case 1253: case 1259:
|
---|
| 568 | ssrClk = true;
|
---|
| 569 | break;
|
---|
| 570 | case 1060: case 1066: case 1243: case 1249: case 1255: case 1261:
|
---|
| 571 | ssrOrbClk = true;
|
---|
| 572 | break;
|
---|
[8271] | 573 | case 1059: case 1065: case 1242: case 1248: case 1254: case 1260:
|
---|
[8082] | 574 | ssrCbi = true;
|
---|
| 575 | break;
|
---|
| 576 | case 1265: case 1266: case 1267: case 1268: case 1269: case 1270:
|
---|
| 577 | ssrPbi = true;
|
---|
| 578 | break;
|
---|
| 579 | case 1264:
|
---|
| 580 | ssrVtec = true;
|
---|
| 581 | break;
|
---|
| 582 | case 1061: case 1067: case 1244: case 1250: case 1256: case 1262:
|
---|
| 583 | ssrUra = true;
|
---|
| 584 | break;
|
---|
| 585 | case 1062: case 1068: case 1245: case 1251: case 1257: case 1263:
|
---|
| 586 | ssrHr = true;
|
---|
| 587 | break;
|
---|
| 588 | }
|
---|
| 589 | }
|
---|
| 590 | }
|
---|
| 591 | if (obs) {
|
---|
| 592 | _latencyChecker->checkObsLatency(decoder()->_obsList);
|
---|
| 593 | }
|
---|
[8271] | 594 | if (_ssrEpoch != -1) {
|
---|
| 595 | _oldSsrEpoch = _ssrEpoch;
|
---|
| 596 | }
|
---|
[3532] | 597 | emit newLatency(_staID, _latencyChecker->currentLatency());
|
---|
| 598 | }
|
---|
[7753] | 599 | miscScanRTCM();
|
---|
[1138] | 600 |
|
---|
[1555] | 601 | // Loop over all observations (observations output)
|
---|
| 602 | // ------------------------------------------------
|
---|
[6137] | 603 | QListIterator<t_satObs> it(decoder()->_obsList);
|
---|
[5524] | 604 |
|
---|
[6137] | 605 | QList<t_satObs> obsListHlp;
|
---|
[5524] | 606 |
|
---|
[1555] | 607 | while (it.hasNext()) {
|
---|
[6137] | 608 | const t_satObs& obs = it.next();
|
---|
[2711] | 609 |
|
---|
[1555] | 610 | // Check observation epoch
|
---|
| 611 | // -----------------------
|
---|
[5739] | 612 | if (!_rawFile) {
|
---|
[8011] | 613 | bool wrongObservationEpoch = checkForWrongObsEpoch(obs._time);
|
---|
| 614 | if (wrongObservationEpoch) {
|
---|
[8021] | 615 | QString prn(obs._prn.toString().c_str());
|
---|
[8082] | 616 | emit(newMessage(
|
---|
[8127] | 617 | _staID + " (" + prn.toLatin1() + ")"
|
---|
[8082] | 618 | + ": Wrong observation epoch(s)", false));
|
---|
[1555] | 619 | continue;
|
---|
[940] | 620 | }
|
---|
[686] | 621 | }
|
---|
[6812] | 622 |
|
---|
[3305] | 623 | // Check observations coming twice (e.g. KOUR0 Problem)
|
---|
| 624 | // ----------------------------------------------------
|
---|
[3535] | 625 | if (!_rawFile) {
|
---|
[8011] | 626 | QString prn(obs._prn.toString().c_str());
|
---|
[8417] | 627 | bncTime obsTime = obs._time;
|
---|
| 628 | QMap<QString, bncTime>::const_iterator it = _prnLastEpo.find(prn);
|
---|
[3535] | 629 | if (it != _prnLastEpo.end()) {
|
---|
[8417] | 630 | bncTime oldTime = it.value();
|
---|
[8082] | 631 | if (obsTime < oldTime) {
|
---|
[8417] | 632 | emit(newMessage(_staID + ": old observation " + prn.toLatin1(), false));
|
---|
[3535] | 633 | continue;
|
---|
[8082] | 634 | } else if (obsTime == oldTime) {
|
---|
[8417] | 635 | emit(newMessage(_staID + ": observation coming more than once "
|
---|
| 636 | + prn.toLatin1(), false));
|
---|
[3535] | 637 | continue;
|
---|
| 638 | }
|
---|
[3302] | 639 | }
|
---|
[3535] | 640 | _prnLastEpo[prn] = obsTime;
|
---|
[3301] | 641 | }
|
---|
| 642 |
|
---|
[3528] | 643 | decoder()->dumpRinexEpoch(obs, _format);
|
---|
| 644 |
|
---|
[5524] | 645 | // Save observations
|
---|
| 646 | // -----------------
|
---|
| 647 | obsListHlp.append(obs);
|
---|
| 648 | }
|
---|
[2030] | 649 |
|
---|
[5524] | 650 | // Emit signal
|
---|
| 651 | // -----------
|
---|
| 652 | if (!_isToBeDeleted && obsListHlp.size() > 0) {
|
---|
| 653 | emit newObs(_staID, obsListHlp);
|
---|
[249] | 654 | }
|
---|
[5524] | 655 |
|
---|
[8082] | 656 | } catch (Exception& exc) {
|
---|
[3311] | 657 | emit(newMessage(_staID + " " + exc.what(), true));
|
---|
| 658 | _isToBeDeleted = true;
|
---|
[8082] | 659 | } catch (...) {
|
---|
[3311] | 660 | emit(newMessage(_staID + " bncGetThread exception", true));
|
---|
[1559] | 661 | _isToBeDeleted = true;
|
---|
[1555] | 662 | }
|
---|
[35] | 663 | }
|
---|
| 664 | }
|
---|
| 665 |
|
---|
[7486] | 666 | // Try Re-Connect
|
---|
[136] | 667 | ////////////////////////////////////////////////////////////////////////////
|
---|
[1555] | 668 | t_irc bncGetThread::tryReconnect() {
|
---|
| 669 |
|
---|
| 670 | // Easy Return
|
---|
| 671 | // -----------
|
---|
| 672 | if (_query && _query->status() == bncNetQuery::running) {
|
---|
| 673 | _nextSleep = 0;
|
---|
[3560] | 674 | if (_rawFile) {
|
---|
| 675 | QMapIterator<QString, GPSDecoder*> itDec(_decodersRaw);
|
---|
| 676 | while (itDec.hasNext()) {
|
---|
| 677 | itDec.next();
|
---|
| 678 | GPSDecoder* decoder = itDec.value();
|
---|
| 679 | decoder->setRinexReconnectFlag(false);
|
---|
| 680 | }
|
---|
[8082] | 681 | } else {
|
---|
[3560] | 682 | _decoder->setRinexReconnectFlag(false);
|
---|
| 683 | }
|
---|
[1555] | 684 | return success;
|
---|
[408] | 685 | }
|
---|
[1555] | 686 |
|
---|
| 687 | // Start a new query
|
---|
| 688 | // -----------------
|
---|
[2519] | 689 | if (!_rawFile) {
|
---|
[1555] | 690 |
|
---|
[138] | 691 | sleep(_nextSleep);
|
---|
[1555] | 692 | if (_nextSleep == 0) {
|
---|
| 693 | _nextSleep = 1;
|
---|
[8082] | 694 | } else {
|
---|
[1555] | 695 | _nextSleep = 2 * _nextSleep;
|
---|
[442] | 696 | if (_nextSleep > 256) {
|
---|
| 697 | _nextSleep = 256;
|
---|
[152] | 698 | }
|
---|
[1816] | 699 | #ifdef MLS_SOFTWARE
|
---|
[1817] | 700 | if (_nextSleep > 4) {
|
---|
| 701 | _nextSleep = 4;
|
---|
[1816] | 702 | }
|
---|
| 703 | #endif
|
---|
[138] | 704 | }
|
---|
[8123] | 705 | delete _query;
|
---|
[8082] | 706 | if (_ntripVersion == "U") {
|
---|
[1721] | 707 | _query = new bncNetQueryUdp();
|
---|
[8082] | 708 | } else if (_ntripVersion == "R") {
|
---|
[1555] | 709 | _query = new bncNetQueryRtp();
|
---|
[8082] | 710 | } else if (_ntripVersion == "S") {
|
---|
[1753] | 711 | _query = new bncNetQueryS();
|
---|
[8082] | 712 | } else if (_ntripVersion == "N") {
|
---|
[1621] | 713 | _query = new bncNetQueryV0();
|
---|
[8082] | 714 | } else if (_ntripVersion == "UN") {
|
---|
[1779] | 715 | _query = new bncNetQueryUdp0();
|
---|
[8082] | 716 | } else if (_ntripVersion == "2") {
|
---|
[3337] | 717 | _query = new bncNetQueryV2(false);
|
---|
[8082] | 718 | } else if (_ntripVersion == "2s") {
|
---|
[3337] | 719 | _query = new bncNetQueryV2(true);
|
---|
[8082] | 720 | } else {
|
---|
[1555] | 721 | _query = new bncNetQueryV1();
|
---|
| 722 | }
|
---|
[6770] | 723 | if (_nmea == "yes") {
|
---|
| 724 | if (_serialNMEA == MANUAL_NMEA) {
|
---|
| 725 | _query->startRequest(_mountPoint, _manualNMEAString);
|
---|
| 726 | _lastManualNMEA = QDateTime::currentDateTime();
|
---|
[8082] | 727 | } else if (_serialNMEA == AUTO_NMEA) {
|
---|
[6770] | 728 | if (_serialPort) {
|
---|
| 729 | int nb = _serialPort->bytesAvailable();
|
---|
| 730 | if (nb > 0) {
|
---|
| 731 | QByteArray data = _serialPort->read(nb);
|
---|
| 732 | int i1 = data.indexOf("$GPGGA");
|
---|
| 733 | if (i1 == -1) {
|
---|
| 734 | i1 = data.indexOf("$GNGGA");
|
---|
| 735 | }
|
---|
| 736 | if (i1 != -1) {
|
---|
| 737 | int i2 = data.indexOf("*", i1);
|
---|
| 738 | if (i2 != -1 && data.size() > i2 + 1) {
|
---|
| 739 | QByteArray gga = data.mid(i1, i2 - i1 + 3);
|
---|
| 740 | _query->startRequest(_mountPoint, gga);
|
---|
| 741 | }
|
---|
| 742 | }
|
---|
| 743 | }
|
---|
| 744 | }
|
---|
| 745 | }
|
---|
[8082] | 746 | } else {
|
---|
[1555] | 747 | _query->startRequest(_mountPoint, "");
|
---|
| 748 | }
|
---|
[6770] | 749 |
|
---|
[1555] | 750 | if (_query->status() != bncNetQuery::running) {
|
---|
| 751 | return failure;
|
---|
| 752 | }
|
---|
[138] | 753 | }
|
---|
[658] | 754 |
|
---|
[3560] | 755 | if (_rawFile) {
|
---|
| 756 | QMapIterator<QString, GPSDecoder*> itDec(_decodersRaw);
|
---|
| 757 | while (itDec.hasNext()) {
|
---|
| 758 | itDec.next();
|
---|
| 759 | GPSDecoder* decoder = itDec.value();
|
---|
| 760 | decoder->setRinexReconnectFlag(false);
|
---|
| 761 | }
|
---|
[8082] | 762 | } else {
|
---|
| 763 | _decoder->setRinexReconnectFlag(false);
|
---|
[658] | 764 | }
|
---|
[1555] | 765 |
|
---|
| 766 | return success;
|
---|
[658] | 767 | }
|
---|
[1044] | 768 |
|
---|
[1555] | 769 | // RTCM scan output
|
---|
[1044] | 770 | //////////////////////////////////////////////////////////////////////////////
|
---|
[7423] | 771 | void bncGetThread::miscScanRTCM() {
|
---|
[1044] | 772 |
|
---|
[8082] | 773 | if (!decoder()) {
|
---|
[3558] | 774 | return;
|
---|
| 775 | }
|
---|
| 776 |
|
---|
[1555] | 777 | bncSettings settings;
|
---|
[8082] | 778 | if (Qt::CheckState(settings.value("miscScanRTCM").toInt()) == Qt::Checked) {
|
---|
[1574] | 779 |
|
---|
[8082] | 780 | if (_miscMount == _staID || _miscMount == "ALL") {
|
---|
[1575] | 781 | // RTCM message types
|
---|
| 782 | // ------------------
|
---|
[4476] | 783 | for (int ii = 0; ii < decoder()->_typeList.size(); ii++) {
|
---|
[8082] | 784 | QString type = QString("%1 ").arg(decoder()->_typeList[ii]);
|
---|
[8127] | 785 | emit(newMessage(_staID + ": Received message type " + type.toLatin1(),
|
---|
[8082] | 786 | true));
|
---|
[1574] | 787 | }
|
---|
[7486] | 788 |
|
---|
[4476] | 789 | // Check Observation Types
|
---|
| 790 | // -----------------------
|
---|
| 791 | for (int ii = 0; ii < decoder()->_obsList.size(); ii++) {
|
---|
[6137] | 792 | t_satObs& obs = decoder()->_obsList[ii];
|
---|
| 793 | QVector<QString>& rnxTypes = _rnxTypes[obs._prn.system()];
|
---|
[4476] | 794 | bool allFound = true;
|
---|
[6137] | 795 | for (unsigned iFrq = 0; iFrq < obs._obs.size(); iFrq++) {
|
---|
[6579] | 796 | if (obs._obs[iFrq]->_codeValid) {
|
---|
| 797 | QString rnxStr('C');
|
---|
| 798 | rnxStr.append(obs._obs[iFrq]->_rnxType2ch.c_str());
|
---|
[8082] | 799 | if (_format.indexOf("RTCM_2") != -1
|
---|
| 800 | || _format.indexOf("RTCM2") != -1
|
---|
| 801 | || _format.indexOf("RTCM 2") != -1) {
|
---|
[6580] | 802 | rnxStr = t_rnxObsFile::type3to2(obs._prn.system(), rnxStr);
|
---|
| 803 | }
|
---|
[6579] | 804 | if (rnxTypes.indexOf(rnxStr) == -1) {
|
---|
| 805 | rnxTypes.push_back(rnxStr);
|
---|
| 806 | allFound = false;
|
---|
| 807 | }
|
---|
[4476] | 808 | }
|
---|
[6579] | 809 | if (obs._obs[iFrq]->_phaseValid) {
|
---|
| 810 | QString rnxStr('L');
|
---|
| 811 | rnxStr.append(obs._obs[iFrq]->_rnxType2ch.c_str());
|
---|
[8082] | 812 | if (_format.indexOf("RTCM_2") != -1
|
---|
| 813 | || _format.indexOf("RTCM2") != -1
|
---|
| 814 | || _format.indexOf("RTCM 2") != -1) {
|
---|
[6580] | 815 | rnxStr = t_rnxObsFile::type3to2(obs._prn.system(), rnxStr);
|
---|
| 816 | }
|
---|
[6579] | 817 | if (rnxTypes.indexOf(rnxStr) == -1) {
|
---|
| 818 | rnxTypes.push_back(rnxStr);
|
---|
| 819 | allFound = false;
|
---|
| 820 | }
|
---|
| 821 | }
|
---|
[8082] | 822 | if (obs._obs[iFrq]->_dopplerValid) {
|
---|
[6579] | 823 | QString rnxStr('D');
|
---|
| 824 | rnxStr.append(obs._obs[iFrq]->_rnxType2ch.c_str());
|
---|
[8082] | 825 | if (_format.indexOf("RTCM_2") != -1
|
---|
| 826 | || _format.indexOf("RTCM2") != -1
|
---|
| 827 | || _format.indexOf("RTCM 2") != -1) {
|
---|
[6580] | 828 | rnxStr = t_rnxObsFile::type3to2(obs._prn.system(), rnxStr);
|
---|
| 829 | }
|
---|
[6579] | 830 | if (rnxTypes.indexOf(rnxStr) == -1) {
|
---|
| 831 | rnxTypes.push_back(rnxStr);
|
---|
| 832 | allFound = false;
|
---|
| 833 | }
|
---|
| 834 | }
|
---|
[8082] | 835 | if (obs._obs[iFrq]->_snrValid) {
|
---|
[6579] | 836 | QString rnxStr('S');
|
---|
| 837 | rnxStr.append(obs._obs[iFrq]->_rnxType2ch.c_str());
|
---|
[8082] | 838 | if (_format.indexOf("RTCM_2") != -1
|
---|
| 839 | || _format.indexOf("RTCM2") != -1
|
---|
| 840 | || _format.indexOf("RTCM 2") != -1) {
|
---|
[6580] | 841 | rnxStr = t_rnxObsFile::type3to2(obs._prn.system(), rnxStr);
|
---|
| 842 | }
|
---|
[6579] | 843 | if (rnxTypes.indexOf(rnxStr) == -1) {
|
---|
| 844 | rnxTypes.push_back(rnxStr);
|
---|
| 845 | allFound = false;
|
---|
| 846 | }
|
---|
| 847 | }
|
---|
[4476] | 848 | }
|
---|
| 849 | if (!allFound) {
|
---|
[7486] | 850 | QString msg;
|
---|
[4477] | 851 | QTextStream str(&msg);
|
---|
[6579] | 852 | QString s;
|
---|
[8082] | 853 | str << obs._prn.system() << " "
|
---|
| 854 | << s.sprintf("%2d", rnxTypes.size()) << " ";
|
---|
[4476] | 855 | for (int iType = 0; iType < rnxTypes.size(); iType++) {
|
---|
[4478] | 856 | str << " " << rnxTypes[iType];
|
---|
[4476] | 857 | }
|
---|
[8127] | 858 | emit(newMessage(_staID + ": Observation Types: " + msg.toLatin1(),
|
---|
[8082] | 859 | true));
|
---|
[4476] | 860 | }
|
---|
| 861 | }
|
---|
| 862 |
|
---|
[1574] | 863 | // RTCMv3 antenna descriptor
|
---|
| 864 | // -------------------------
|
---|
[4476] | 865 | for (int ii = 0; ii < decoder()->_antType.size(); ii++) {
|
---|
[8236] | 866 | QString ant1 = QString(": Antenna Descriptor: %1 ").arg(decoder()->_antType[ii].descriptor);
|
---|
| 867 | emit(newMessage(_staID + ant1.toLatin1(), true));
|
---|
| 868 | if (strlen(decoder()->_antType[ii].serialnumber)) {
|
---|
| 869 | QString ant2 = QString(": Antenna Serial Number: %1 ").arg(decoder()->_antType[ii].serialnumber);
|
---|
| 870 | emit(newMessage(_staID + ant2.toLatin1(), true));
|
---|
| 871 | }
|
---|
[1574] | 872 | }
|
---|
[1555] | 873 |
|
---|
[1575] | 874 | // RTCM Antenna Coordinates
|
---|
| 875 | // ------------------------
|
---|
[8082] | 876 | for (int ii = 0; ii < decoder()->_antList.size(); ii++) {
|
---|
[1574] | 877 | QByteArray antT;
|
---|
[8236] | 878 | if (decoder()->_antList[ii].type == GPSDecoder::t_antRefPoint::ARP) {
|
---|
[1574] | 879 | antT = "ARP";
|
---|
[8236] | 880 | } else if (decoder()->_antList[ii].type == GPSDecoder::t_antRefPoint::APC) {
|
---|
[1574] | 881 | antT = "APC";
|
---|
| 882 | }
|
---|
[1575] | 883 | QByteArray ant1, ant2, ant3;
|
---|
[8236] | 884 | ant1 = QString("%1 ").arg(decoder()->_antList[ii].xx, 0, 'f', 4).toLatin1();
|
---|
| 885 | ant2 = QString("%1 ").arg(decoder()->_antList[ii].yy, 0, 'f', 4).toLatin1();
|
---|
| 886 | ant3 = QString("%1 ").arg(decoder()->_antList[ii].zz, 0, 'f', 4).toLatin1();
|
---|
[1575] | 887 | emit(newMessage(_staID + ": " + antT + " (ITRF) X " + ant1 + "m", true));
|
---|
| 888 | emit(newMessage(_staID + ": " + antT + " (ITRF) Y " + ant2 + "m", true));
|
---|
| 889 | emit(newMessage(_staID + ": " + antT + " (ITRF) Z " + ant3 + "m", true));
|
---|
[3595] | 890 | double hh = 0.0;
|
---|
[3523] | 891 | if (decoder()->_antList[ii].height_f) {
|
---|
[3595] | 892 | hh = decoder()->_antList[ii].height;
|
---|
[8127] | 893 | QByteArray ant4 = QString("%1 ").arg(hh, 0, 'f', 4).toLatin1();
|
---|
[8082] | 894 | emit(newMessage(
|
---|
| 895 | _staID + ": Antenna height above marker " + ant4 + "m", true));
|
---|
[1575] | 896 | }
|
---|
[7486] | 897 | emit(newAntCrd(_staID, decoder()->_antList[ii].xx,
|
---|
[8082] | 898 | decoder()->_antList[ii].yy, decoder()->_antList[ii].zz, hh, antT));
|
---|
[1218] | 899 | }
|
---|
[6864] | 900 |
|
---|
[8197] | 901 | // RTCMv3 receiver descriptor
|
---|
| 902 | // --------------------------
|
---|
| 903 | for (int ii = 0; ii < decoder()->_recType.size(); ii++) {
|
---|
[8236] | 904 | QString rec1 = QString(": Receiver Descriptor: %1 ").arg(decoder()->_recType[ii].descriptor);
|
---|
| 905 | QString rec2 = QString(": Receiver Firmware Version: %1 ").arg(decoder()->_recType[ii].firmware);
|
---|
| 906 | QString rec3 = QString(": Receiver Serial Number: %1 ").arg(decoder()->_recType[ii].serialnumber);
|
---|
| 907 | emit(newMessage(_staID + rec1.toLatin1(), true));
|
---|
| 908 | emit(newMessage(_staID + rec2.toLatin1(), true));
|
---|
| 909 | emit(newMessage(_staID + rec3.toLatin1(), true));
|
---|
[8197] | 910 | }
|
---|
| 911 |
|
---|
[6864] | 912 | // RTCM GLONASS slots
|
---|
| 913 | // ------------------
|
---|
| 914 | if (decoder()->_gloFrq.size()) {
|
---|
| 915 | bool allFound = true;
|
---|
| 916 | QString slot = decoder()->_gloFrq;
|
---|
[8082] | 917 | slot.replace(" ", " ").replace(" ", ":");
|
---|
[6864] | 918 | if (_gloSlots.indexOf(slot) == -1) {
|
---|
| 919 | _gloSlots.append(slot);
|
---|
| 920 | allFound = false;
|
---|
| 921 | }
|
---|
| 922 | if (!allFound) {
|
---|
| 923 | _gloSlots.sort();
|
---|
[8082] | 924 | emit(newMessage(
|
---|
[8127] | 925 | _staID + ": GLONASS Slot:Freq " + _gloSlots.join(" ").toLatin1(),
|
---|
[8082] | 926 | true));
|
---|
[6864] | 927 | }
|
---|
| 928 | }
|
---|
[1218] | 929 | }
|
---|
[1044] | 930 | }
|
---|
[1575] | 931 |
|
---|
[1770] | 932 | #ifdef MLS_SOFTWARE
|
---|
[3523] | 933 | for (int ii=0; ii <decoder()->_antList.size(); ii++) {
|
---|
[8082] | 934 | QByteArray antT;
|
---|
| 935 | if (decoder()->_antList[ii].type == GPSDecoder::t_antInfo::ARP) {
|
---|
| 936 | antT = "ARP";
|
---|
| 937 | }
|
---|
| 938 | else if (decoder()->_antList[ii].type == GPSDecoder::t_antInfo::APC) {
|
---|
| 939 | antT = "APC";
|
---|
| 940 | }
|
---|
| 941 | double hh = 0.0;
|
---|
| 942 | if (decoder()->_antList[ii].height_f) {
|
---|
| 943 | hh = decoder()->_antList[ii].height;
|
---|
| 944 | }
|
---|
| 945 | emit(newAntCrd(_staID, decoder()->_antList[ii].xx,
|
---|
| 946 | decoder()->_antList[ii].yy, decoder()->_antList[ii].zz,
|
---|
| 947 | hh, antT));
|
---|
[1770] | 948 | }
|
---|
[2356] | 949 |
|
---|
[3523] | 950 | for (int ii = 0; ii <decoder()->_typeList.size(); ii++) {
|
---|
| 951 | emit(newRTCMMessage(_staID, decoder()->_typeList[ii]));
|
---|
[2356] | 952 | }
|
---|
[1770] | 953 | #endif
|
---|
| 954 |
|
---|
[6864] | 955 | decoder()->_gloFrq.clear();
|
---|
[3523] | 956 | decoder()->_typeList.clear();
|
---|
| 957 | decoder()->_antType.clear();
|
---|
[8197] | 958 | decoder()->_recType.clear();
|
---|
[3523] | 959 | decoder()->_antList.clear();
|
---|
[1044] | 960 | }
|
---|
[1555] | 961 |
|
---|
[1606] | 962 | // Handle Data from Serial Port
|
---|
| 963 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 964 | void bncGetThread::slotSerialReadyRead() {
|
---|
[6770] | 965 |
|
---|
[1607] | 966 | if (_serialPort) {
|
---|
[6770] | 967 |
|
---|
[6773] | 968 | if (_nmea == "yes" && _serialNMEA == MANUAL_NMEA) {
|
---|
| 969 | if (_manualNMEASampl) {
|
---|
| 970 | int dt = _lastManualNMEA.secsTo(QDateTime::currentDateTime());
|
---|
| 971 | if (dt && (fmod(double(dt), double(_manualNMEASampl)) == 0.0)) {
|
---|
| 972 | _query->sendNMEA(_manualNMEAString);
|
---|
| 973 | _lastManualNMEA = QDateTime::currentDateTime();
|
---|
| 974 | }
|
---|
| 975 | }
|
---|
| 976 | }
|
---|
| 977 |
|
---|
[1633] | 978 | int nb = _serialPort->bytesAvailable();
|
---|
| 979 | if (nb > 0) {
|
---|
| 980 | QByteArray data = _serialPort->read(nb);
|
---|
[1711] | 981 |
|
---|
[6695] | 982 | if (_nmea == "yes" && _serialNMEA == AUTO_NMEA) {
|
---|
[1725] | 983 | int i1 = data.indexOf("$GPGGA");
|
---|
[6651] | 984 | if (i1 == -1) {
|
---|
| 985 | i1 = data.indexOf("$GNGGA");
|
---|
| 986 | }
|
---|
[1725] | 987 | if (i1 != -1) {
|
---|
[6751] | 988 | int i2 = data.indexOf("*", i1);
|
---|
[1725] | 989 | if (i2 != -1 && data.size() > i2 + 1) {
|
---|
[6751] | 990 | QByteArray gga = data.mid(i1, i2 - i1 + 3);
|
---|
[1725] | 991 | _query->sendNMEA(gga);
|
---|
[6751] | 992 | }
|
---|
| 993 | }
|
---|
[1711] | 994 | }
|
---|
| 995 |
|
---|
[1633] | 996 | if (_serialOutFile) {
|
---|
| 997 | _serialOutFile->write(data);
|
---|
| 998 | _serialOutFile->flush();
|
---|
| 999 | }
|
---|
[1607] | 1000 | }
|
---|
| 1001 | }
|
---|
[1606] | 1002 | }
|
---|
[7180] | 1003 |
|
---|
| 1004 | void bncGetThread::slotNewNMEAConnection() {
|
---|
| 1005 | _nmeaSockets->push_back(_nmeaServer->nextPendingConnection());
|
---|
[8082] | 1006 | emit(newMessage(
|
---|
[8127] | 1007 | QString("New PPP client on port: # %1").arg(_nmeaSockets->size()).toLatin1(),
|
---|
[8082] | 1008 | true));
|
---|
[7180] | 1009 | }
|
---|
| 1010 |
|
---|
| 1011 | //
|
---|
| 1012 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 1013 | void bncGetThread::slotNewNMEAstr(QByteArray staID, QByteArray str) {
|
---|
| 1014 | if (_nmeaPortsMap.contains(staID)) {
|
---|
| 1015 | int nmeaPort = _nmeaPortsMap.value(staID);
|
---|
| 1016 | QMutableListIterator<QTcpSocket*> is(*_nmeaSockets);
|
---|
| 1017 | while (is.hasNext()) {
|
---|
| 1018 | QTcpSocket* sock = is.next();
|
---|
| 1019 | if (sock->localPort() == nmeaPort) {
|
---|
| 1020 | if (sock->state() == QAbstractSocket::ConnectedState) {
|
---|
| 1021 | sock->write(str);
|
---|
[8082] | 1022 | } else if (sock->state() != QAbstractSocket::ConnectingState) {
|
---|
[7180] | 1023 | delete sock;
|
---|
| 1024 | is.remove();
|
---|
| 1025 | }
|
---|
| 1026 | }
|
---|
| 1027 | }
|
---|
| 1028 | }
|
---|
| 1029 | }
|
---|