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