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