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