[280] | 1 | // Part of BNC, a utility for retrieving decoding and
|
---|
[464] | 2 | // converting GNSS data streams from NTRIP broadcasters.
|
---|
[280] | 3 | //
|
---|
[464] | 4 | // Copyright (C) 2007
|
---|
[280] | 5 | // German Federal Agency for Cartography and Geodesy (BKG)
|
---|
| 6 | // http://www.bkg.bund.de
|
---|
[464] | 7 | // Czech Technical University Prague, Department of Geodesy
|
---|
[280] | 8 | // http://www.fsv.cvut.cz
|
---|
| 9 | //
|
---|
| 10 | // Email: euref-ip@bkg.bund.de
|
---|
| 11 | //
|
---|
| 12 | // This program is free software; you can redistribute it and/or
|
---|
| 13 | // modify it under the terms of the GNU General Public License
|
---|
| 14 | // as published by the Free Software Foundation, version 2.
|
---|
| 15 | //
|
---|
| 16 | // This program is distributed in the hope that it will be useful,
|
---|
| 17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 19 | // GNU General Public License for more details.
|
---|
| 20 | //
|
---|
| 21 | // You should have received a copy of the GNU General Public License
|
---|
| 22 | // along with this program; if not, write to the Free Software
|
---|
| 23 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
---|
[35] | 24 |
|
---|
| 25 | /* -------------------------------------------------------------------------
|
---|
[93] | 26 | * BKG NTRIP Client
|
---|
[35] | 27 | * -------------------------------------------------------------------------
|
---|
| 28 | *
|
---|
| 29 | * Class: bncGetThread
|
---|
| 30 | *
|
---|
| 31 | * Purpose: Thread that retrieves data from NTRIP caster
|
---|
| 32 | *
|
---|
| 33 | * Author: L. Mervart
|
---|
| 34 | *
|
---|
| 35 | * Created: 24-Dec-2005
|
---|
| 36 | *
|
---|
[7486] | 37 | * Changes:
|
---|
[35] | 38 | *
|
---|
| 39 | * -----------------------------------------------------------------------*/
|
---|
| 40 |
|
---|
[277] | 41 | #include <stdlib.h>
|
---|
[1044] | 42 | #include <iomanip>
|
---|
[1218] | 43 | #include <sstream>
|
---|
[277] | 44 |
|
---|
[8127] | 45 | #include <QComboBox>
|
---|
| 46 | #include <QDialog>
|
---|
[35] | 47 | #include <QFile>
|
---|
| 48 | #include <QTextStream>
|
---|
[5524] | 49 | #include <QMutex>
|
---|
[8127] | 50 | #include <QPushButton>
|
---|
| 51 | #include <QTableWidget>
|
---|
[356] | 52 | #include <QTime>
|
---|
[35] | 53 |
|
---|
| 54 | #include "bncgetthread.h"
|
---|
[192] | 55 | #include "bnctabledlg.h"
|
---|
[5070] | 56 | #include "bnccore.h"
|
---|
[352] | 57 | #include "bncutils.h"
|
---|
[8417] | 58 | #include "bnctime.h"
|
---|
[423] | 59 | #include "bnczerodecoder.h"
|
---|
[1621] | 60 | #include "bncnetqueryv0.h"
|
---|
[1387] | 61 | #include "bncnetqueryv1.h"
|
---|
| 62 | #include "bncnetqueryv2.h"
|
---|
[1410] | 63 | #include "bncnetqueryrtp.h"
|
---|
[1721] | 64 | #include "bncnetqueryudp.h"
|
---|
[1779] | 65 | #include "bncnetqueryudp0.h"
|
---|
[1753] | 66 | #include "bncnetquerys.h"
|
---|
[1535] | 67 | #include "bncsettings.h"
|
---|
[1558] | 68 | #include "latencychecker.h"
|
---|
[3168] | 69 | #include "upload/bncrtnetdecoder.h"
|
---|
[243] | 70 | #include "RTCM/RTCM2Decoder.h"
|
---|
[297] | 71 | #include "RTCM3/RTCM3Decoder.h"
|
---|
[1318] | 72 | #include "serial/qextserialport.h"
|
---|
[35] | 73 |
|
---|
| 74 | using namespace std;
|
---|
| 75 |
|
---|
[1143] | 76 | // Constructor 1
|
---|
[35] | 77 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2519] | 78 | bncGetThread::bncGetThread(bncRawFile* rawFile) {
|
---|
[1138] | 79 |
|
---|
[8082] | 80 | _rawFile = rawFile;
|
---|
| 81 | _format = rawFile->format();
|
---|
| 82 | _staID = rawFile->staID();
|
---|
| 83 | _rawOutput = false;
|
---|
[2390] | 84 | _ntripVersion = "N";
|
---|
| 85 |
|
---|
[1555] | 86 | initialize();
|
---|
[1138] | 87 | }
|
---|
| 88 |
|
---|
[1143] | 89 | // Constructor 2
|
---|
| 90 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8082] | 91 | bncGetThread::bncGetThread(const QUrl& mountPoint, const QByteArray& format,
|
---|
| 92 | const QByteArray& latitude, const QByteArray& longitude,
|
---|
| 93 | const QByteArray& nmea, const QByteArray& ntripVersion) {
|
---|
| 94 | _rawFile = 0;
|
---|
| 95 | _mountPoint = mountPoint;
|
---|
[8127] | 96 | _staID = mountPoint.path().mid(1).toLatin1();
|
---|
[8082] | 97 | _format = format;
|
---|
| 98 | _latitude = latitude;
|
---|
| 99 | _longitude = longitude;
|
---|
| 100 | _nmea = nmea;
|
---|
[1353] | 101 | _ntripVersion = ntripVersion;
|
---|
[1139] | 102 |
|
---|
[2386] | 103 | bncSettings settings;
|
---|
| 104 | if (!settings.value("rawOutFile").toString().isEmpty()) {
|
---|
| 105 | _rawOutput = true;
|
---|
[8271] | 106 | }
|
---|
| 107 | else {
|
---|
[3734] | 108 | _rawOutput = false;
|
---|
[2386] | 109 | }
|
---|
[8271] | 110 | if (!settings.value("miscMount").toString().isEmpty()) {
|
---|
| 111 | _latencycheck = true;
|
---|
| 112 | }
|
---|
| 113 | else {
|
---|
| 114 | _latencycheck = false;
|
---|
| 115 | }
|
---|
[1139] | 116 | initialize();
|
---|
[3523] | 117 | initDecoder();
|
---|
[1139] | 118 | }
|
---|
| 119 |
|
---|
[1555] | 120 | // Initialization (common part of the constructor)
|
---|
[1143] | 121 | ////////////////////////////////////////////////////////////////////////////
|
---|
[1139] | 122 | void bncGetThread::initialize() {
|
---|
| 123 |
|
---|
[3528] | 124 | bncSettings settings;
|
---|
| 125 |
|
---|
[1555] | 126 | setTerminationEnabled(true);
|
---|
| 127 |
|
---|
[7486] | 128 | connect(this, SIGNAL(newMessage(QByteArray,bool)),
|
---|
[8082] | 129 | BNC_CORE, SLOT(slotMessage(const QByteArray,bool)));
|
---|
[1555] | 130 |
|
---|
[1525] | 131 | _isToBeDeleted = false;
|
---|
[8082] | 132 | _query = 0;
|
---|
| 133 | _nextSleep = 0;
|
---|
| 134 | _miscMount = settings.value("miscMount").toString();
|
---|
| 135 | _decoder = 0;
|
---|
[255] | 136 |
|
---|
[7180] | 137 | // NMEA Port
|
---|
| 138 | // -----------
|
---|
| 139 | QListIterator<QString> iSta(settings.value("PPP/staTable").toStringList());
|
---|
| 140 | int nmeaPort = 0;
|
---|
| 141 | while (iSta.hasNext()) {
|
---|
| 142 | QStringList hlp = iSta.next().split(",");
|
---|
[8082] | 143 | if (hlp.size() < 10) {
|
---|
| 144 | continue;
|
---|
| 145 | }
|
---|
[8127] | 146 | QByteArray mp = hlp[0].toLatin1();
|
---|
[7180] | 147 | if (_staID == mp) {
|
---|
| 148 | nmeaPort = hlp[9].toInt();
|
---|
| 149 | }
|
---|
| 150 | }
|
---|
| 151 | if (nmeaPort != 0) {
|
---|
| 152 | _nmeaServer = new QTcpServer;
|
---|
[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 |
|
---|
[3560] | 319 | _decoder = 0;
|
---|
| 320 |
|
---|
[8082] | 321 | if (_format.indexOf("RTCM_2") != -1 || _format.indexOf("RTCM2") != -1
|
---|
| 322 | || _format.indexOf("RTCM 2") != -1) {
|
---|
[1555] | 323 | emit(newMessage(_staID + ": Get data in RTCM 2.x format", true));
|
---|
[3560] | 324 | _decoder = new RTCM2Decoder(_staID.data());
|
---|
[8082] | 325 | } else if (_format.indexOf("RTCM_3") != -1 || _format.indexOf("RTCM3") != -1
|
---|
| 326 | || _format.indexOf("RTCM 3") != -1) {
|
---|
[1555] | 327 | emit(newMessage(_staID + ": Get data in RTCM 3.x format", true));
|
---|
[3558] | 328 | RTCM3Decoder* newDecoder = new RTCM3Decoder(_staID, _rawFile);
|
---|
[3560] | 329 | _decoder = newDecoder;
|
---|
[7486] | 330 | connect((RTCM3Decoder*) newDecoder, SIGNAL(newMessage(QByteArray,bool)),
|
---|
[8082] | 331 | this, SIGNAL(newMessage(QByteArray,bool)));
|
---|
| 332 | } else if (_format.indexOf("ZERO") != -1) {
|
---|
[1555] | 333 | emit(newMessage(_staID + ": Get data in original format", true));
|
---|
[3560] | 334 | _decoder = new bncZeroDecoder(_staID);
|
---|
[8082] | 335 | } else if (_format.indexOf("RTNET") != -1) {
|
---|
[3168] | 336 | emit(newMessage(_staID + ": Get data in RTNet format", true));
|
---|
[3560] | 337 | _decoder = new bncRtnetDecoder();
|
---|
[8082] | 338 | } else {
|
---|
[1555] | 339 | emit(newMessage(_staID + ": Unknown data format " + _format, true));
|
---|
| 340 | _isToBeDeleted = true;
|
---|
[3523] | 341 | return failure;
|
---|
[1555] | 342 | }
|
---|
| 343 |
|
---|
[319] | 344 | msleep(100); //sleep 0.1 sec
|
---|
[7486] | 345 |
|
---|
[8082] | 346 | _decoder->initRinex(_staID, _mountPoint, _latitude, _longitude, _nmea,
|
---|
| 347 | _ntripVersion);
|
---|
[3560] | 348 |
|
---|
| 349 | if (_rawFile) {
|
---|
| 350 | _decodersRaw[_staID] = _decoder;
|
---|
[3530] | 351 | }
|
---|
| 352 |
|
---|
[3523] | 353 | return success;
|
---|
[35] | 354 | }
|
---|
| 355 |
|
---|
[3523] | 356 | // Current decoder in use
|
---|
| 357 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 358 | GPSDecoder* bncGetThread::decoder() {
|
---|
[3560] | 359 | if (!_rawFile) {
|
---|
| 360 | return _decoder;
|
---|
[8082] | 361 | } else {
|
---|
[3560] | 362 | if (_decodersRaw.contains(_staID) || initDecoder() == success) {
|
---|
| 363 | return _decodersRaw[_staID];
|
---|
| 364 | }
|
---|
[3523] | 365 | }
|
---|
[3560] | 366 | return 0;
|
---|
[3523] | 367 | }
|
---|
| 368 |
|
---|
[35] | 369 | // Destructor
|
---|
| 370 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 371 | bncGetThread::~bncGetThread() {
|
---|
[1928] | 372 | if (isRunning()) {
|
---|
| 373 | wait();
|
---|
| 374 | }
|
---|
[1527] | 375 | if (_query) {
|
---|
| 376 | _query->stop();
|
---|
[1708] | 377 | _query->deleteLater();
|
---|
[1527] | 378 | }
|
---|
[3560] | 379 | if (_rawFile) {
|
---|
| 380 | QMapIterator<QString, GPSDecoder*> it(_decodersRaw);
|
---|
| 381 | while (it.hasNext()) {
|
---|
| 382 | it.next();
|
---|
| 383 | delete it.value();
|
---|
| 384 | }
|
---|
[8082] | 385 | } else {
|
---|
[3560] | 386 | delete _decoder;
|
---|
| 387 | }
|
---|
[2519] | 388 | delete _rawFile;
|
---|
[1607] | 389 | delete _serialOutFile;
|
---|
[1328] | 390 | delete _serialPort;
|
---|
[1557] | 391 | delete _latencyChecker;
|
---|
[1556] | 392 | emit getThreadFinished(_staID);
|
---|
[35] | 393 | }
|
---|
| 394 |
|
---|
[7486] | 395 | //
|
---|
[1390] | 396 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 397 | void bncGetThread::terminate() {
|
---|
[1525] | 398 | _isToBeDeleted = true;
|
---|
[7854] | 399 |
|
---|
[8082] | 400 | if (_nmeaPortsMap.contains(_staID)) {
|
---|
[7854] | 401 | _nmeaPortsMap.remove(_staID);
|
---|
[1559] | 402 | }
|
---|
[7854] | 403 | if (_nmeaServer) {
|
---|
| 404 | delete _nmeaServer;
|
---|
| 405 | }
|
---|
| 406 | if (_nmeaSockets) {
|
---|
| 407 | delete _nmeaSockets;
|
---|
| 408 | }
|
---|
[7858] | 409 |
|
---|
| 410 | #ifdef BNC_DEBUG
|
---|
[7859] | 411 | if (BNC_CORE->mode() != t_bncCore::interactive) {
|
---|
[8082] | 412 | while (!isFinished()) {
|
---|
| 413 | wait();
|
---|
| 414 | }
|
---|
[7859] | 415 | delete this;
|
---|
[8082] | 416 | } else {
|
---|
| 417 | if (!isRunning()) {
|
---|
| 418 | delete this;
|
---|
| 419 | }
|
---|
[7858] | 420 | }
|
---|
| 421 | #else
|
---|
[8082] | 422 | if (!isRunning()) {delete this;}
|
---|
[7858] | 423 | #endif
|
---|
| 424 |
|
---|
[1390] | 425 | }
|
---|
| 426 |
|
---|
[136] | 427 | // Run
|
---|
| 428 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 429 | void bncGetThread::run() {
|
---|
| 430 |
|
---|
[35] | 431 | while (true) {
|
---|
[629] | 432 | try {
|
---|
[1555] | 433 | if (_isToBeDeleted) {
|
---|
| 434 | QThread::exit(0);
|
---|
| 435 | this->deleteLater();
|
---|
| 436 | return;
|
---|
[629] | 437 | }
|
---|
[621] | 438 |
|
---|
[1555] | 439 | if (tryReconnect() != success) {
|
---|
[3532] | 440 | if (_latencyChecker) {
|
---|
| 441 | _latencyChecker->checkReconnect();
|
---|
| 442 | }
|
---|
[1555] | 443 | continue;
|
---|
[621] | 444 | }
|
---|
[1555] | 445 |
|
---|
| 446 | // Delete old observations
|
---|
| 447 | // -----------------------
|
---|
[3560] | 448 | if (_rawFile) {
|
---|
| 449 | QMapIterator<QString, GPSDecoder*> itDec(_decodersRaw);
|
---|
| 450 | while (itDec.hasNext()) {
|
---|
| 451 | itDec.next();
|
---|
| 452 | GPSDecoder* decoder = itDec.value();
|
---|
| 453 | decoder->_obsList.clear();
|
---|
| 454 | }
|
---|
[8082] | 455 | } else {
|
---|
[3560] | 456 | _decoder->_obsList.clear();
|
---|
| 457 | }
|
---|
[621] | 458 |
|
---|
[1555] | 459 | // Read Data
|
---|
| 460 | // ---------
|
---|
[1377] | 461 | QByteArray data;
|
---|
[8082] | 462 | if (_query) {
|
---|
[1377] | 463 | _query->waitForReadyRead(data);
|
---|
[8082] | 464 | } else if (_rawFile) {
|
---|
[2527] | 465 | data = _rawFile->readChunk();
|
---|
[3523] | 466 | _format = _rawFile->format();
|
---|
[8082] | 467 | _staID = _rawFile->staID();
|
---|
[2388] | 468 |
|
---|
[5903] | 469 | QCoreApplication::processEvents();
|
---|
| 470 |
|
---|
[7976] | 471 | if (data.isEmpty() || BNC_CORE->sigintReceived) {
|
---|
| 472 | cout << "no more data or Ctrl-C received" << endl;
|
---|
[5068] | 473 | BNC_CORE->stopCombination();
|
---|
[5900] | 474 | BNC_CORE->stopPPP();
|
---|
[8781] | 475 | sleep(1);
|
---|
[5903] | 476 | ::exit(0);
|
---|
[1555] | 477 | }
|
---|
[1138] | 478 | }
|
---|
[8123] | 479 |
|
---|
[1555] | 480 | qint64 nBytes = data.size();
|
---|
[1138] | 481 |
|
---|
[1555] | 482 | // Timeout, reconnect
|
---|
| 483 | // ------------------
|
---|
| 484 | if (nBytes == 0) {
|
---|
[3532] | 485 | if (_latencyChecker) {
|
---|
| 486 | _latencyChecker->checkReconnect();
|
---|
| 487 | }
|
---|
[1555] | 488 | emit(newMessage(_staID + ": Data timeout, reconnecting", true));
|
---|
[2355] | 489 | msleep(10000); //sleep 10 sec, G. Weber
|
---|
[1555] | 490 | continue;
|
---|
[8082] | 491 | } else {
|
---|
[567] | 492 | emit newBytes(_staID, nBytes);
|
---|
[5648] | 493 | emit newRawData(_staID, data);
|
---|
[1555] | 494 | }
|
---|
[567] | 495 |
|
---|
[1555] | 496 | // Output Data
|
---|
| 497 | // -----------
|
---|
[2386] | 498 | if (_rawOutput) {
|
---|
[7486] | 499 | BNC_CORE->writeRawData(data, _staID, _format);
|
---|
[2386] | 500 | }
|
---|
[2385] | 501 |
|
---|
[1555] | 502 | if (_serialPort) {
|
---|
[1633] | 503 | slotSerialReadyRead();
|
---|
[1555] | 504 | _serialPort->write(data);
|
---|
| 505 | }
|
---|
[7486] | 506 |
|
---|
[1555] | 507 | // Decode Data
|
---|
| 508 | // -----------
|
---|
| 509 | vector<string> errmsg;
|
---|
[3526] | 510 | if (!decoder()) {
|
---|
| 511 | _isToBeDeleted = true;
|
---|
| 512 | continue;
|
---|
| 513 | }
|
---|
[7753] | 514 |
|
---|
[3523] | 515 | t_irc irc = decoder()->Decode(data.data(), data.size(), errmsg);
|
---|
[1137] | 516 |
|
---|
[7753] | 517 | if (irc != success) {
|
---|
| 518 | continue;
|
---|
| 519 | }
|
---|
[1555] | 520 | // Perform various scans and checks
|
---|
| 521 | // --------------------------------
|
---|
[3532] | 522 | if (_latencyChecker) {
|
---|
[8271] | 523 | _latencyChecker->checkOutage(irc);
|
---|
[8082] | 524 | QListIterator<int> it(decoder()->_typeList);
|
---|
[8271] | 525 | _ssrEpoch = static_cast<int>(decoder()->corrGPSEpochTime());
|
---|
[8730] | 526 | if (_ssrEpoch != -1) {
|
---|
[9124] | 527 | if (_rtcmSsrOrb) {
|
---|
[8730] | 528 | _latencyChecker->checkCorrLatency(_ssrEpoch, 1057);
|
---|
[9124] | 529 | _rtcmSsrOrb = false;
|
---|
[8082] | 530 | }
|
---|
[9124] | 531 | if (_rtcmSsrClk) {
|
---|
[8730] | 532 | _latencyChecker->checkCorrLatency(_ssrEpoch, 1058);
|
---|
[9124] | 533 | _rtcmSsrClk = false;
|
---|
[8082] | 534 | }
|
---|
[9124] | 535 | if (_rtcmSsrOrbClk) {
|
---|
[8730] | 536 | _latencyChecker->checkCorrLatency(_ssrEpoch, 1060);
|
---|
[9124] | 537 | _rtcmSsrOrbClk = false;
|
---|
[8082] | 538 | }
|
---|
[9124] | 539 | if (_rtcmSsrCbi) {
|
---|
[8730] | 540 | _latencyChecker->checkCorrLatency(_ssrEpoch, 1059);
|
---|
[9124] | 541 | _rtcmSsrCbi = false;
|
---|
[8082] | 542 | }
|
---|
[9124] | 543 | if (_rtcmSsrPbi) {
|
---|
[8730] | 544 | _latencyChecker->checkCorrLatency(_ssrEpoch, 1265);
|
---|
[9124] | 545 | _rtcmSsrPbi = false;
|
---|
[8082] | 546 | }
|
---|
[9124] | 547 | if (_rtcmSsrVtec) {
|
---|
[8730] | 548 | _latencyChecker->checkCorrLatency(_ssrEpoch, 1264);
|
---|
[9124] | 549 | _rtcmSsrVtec = false;
|
---|
[8082] | 550 | }
|
---|
[9124] | 551 | if (_rtcmSsrUra) {
|
---|
[8730] | 552 | _latencyChecker->checkCorrLatency(_ssrEpoch, 1061);
|
---|
[9124] | 553 | _rtcmSsrUra = false;
|
---|
[8082] | 554 | }
|
---|
[9124] | 555 | if (_rtcmSsrHr) {
|
---|
[8730] | 556 | _latencyChecker->checkCorrLatency(_ssrEpoch, 1062);
|
---|
[9124] | 557 | _rtcmSsrHr = false;
|
---|
[8082] | 558 | }
|
---|
[9124] | 559 | if (_rtcmSsrIgs) {
|
---|
| 560 | _latencyChecker->checkCorrLatency(_ssrEpoch, 4076);
|
---|
| 561 | _rtcmSsrIgs = false;
|
---|
| 562 | }
|
---|
[8082] | 563 | }
|
---|
| 564 | while (it.hasNext()) {
|
---|
| 565 | int rtcmType = it.next();
|
---|
| 566 | if ((rtcmType >= 1001 && rtcmType <= 1004) || // legacy RTCM OBS
|
---|
| 567 | (rtcmType >= 1009 && rtcmType <= 1012) || // legacy RTCM OBS
|
---|
[9009] | 568 | (rtcmType >= 1071 && rtcmType <= 1137)) { // MSM RTCM OBS
|
---|
[9124] | 569 | _rtcmObs = true;
|
---|
[8082] | 570 | } else if ((rtcmType >= 1057 && rtcmType <= 1068) ||
|
---|
[9124] | 571 | (rtcmType >= 1240 && rtcmType <= 1270) ||
|
---|
| 572 | (rtcmType == 4076)) {
|
---|
[8082] | 573 | switch (rtcmType) {
|
---|
| 574 | case 1057: case 1063: case 1240: case 1246: case 1252: case 1258:
|
---|
[9124] | 575 | _rtcmSsrOrb = true;
|
---|
[8082] | 576 | break;
|
---|
| 577 | case 1058: case 1064: case 1241: case 1247: case 1253: case 1259:
|
---|
[9124] | 578 | _rtcmSsrClk = true;
|
---|
[8082] | 579 | break;
|
---|
| 580 | case 1060: case 1066: case 1243: case 1249: case 1255: case 1261:
|
---|
[9124] | 581 | _rtcmSsrOrbClk = true;
|
---|
[8082] | 582 | break;
|
---|
[9017] | 583 | case 1059: case 1065: case 1242: case 1248: case 1254: case 1260:
|
---|
[9124] | 584 | _rtcmSsrCbi = true;
|
---|
[8082] | 585 | break;
|
---|
| 586 | case 1265: case 1266: case 1267: case 1268: case 1269: case 1270:
|
---|
[9124] | 587 | _rtcmSsrPbi = true;
|
---|
[8082] | 588 | break;
|
---|
| 589 | case 1264:
|
---|
[9124] | 590 | _rtcmSsrVtec = true;
|
---|
[8082] | 591 | break;
|
---|
| 592 | case 1061: case 1067: case 1244: case 1250: case 1256: case 1262:
|
---|
[9124] | 593 | _rtcmSsrUra = true;
|
---|
[8082] | 594 | break;
|
---|
| 595 | case 1062: case 1068: case 1245: case 1251: case 1257: case 1263:
|
---|
[9124] | 596 | _rtcmSsrHr = true;
|
---|
[8082] | 597 | break;
|
---|
[9124] | 598 | case 4076:
|
---|
| 599 | _rtcmSsrIgs = true;
|
---|
| 600 | break;
|
---|
[8082] | 601 | }
|
---|
| 602 | }
|
---|
| 603 | }
|
---|
[9124] | 604 | if (_rtcmObs) {
|
---|
[8082] | 605 | _latencyChecker->checkObsLatency(decoder()->_obsList);
|
---|
| 606 | }
|
---|
[3532] | 607 | emit newLatency(_staID, _latencyChecker->currentLatency());
|
---|
| 608 | }
|
---|
[7753] | 609 | miscScanRTCM();
|
---|
[1138] | 610 |
|
---|
[1555] | 611 | // Loop over all observations (observations output)
|
---|
| 612 | // ------------------------------------------------
|
---|
[6137] | 613 | QListIterator<t_satObs> it(decoder()->_obsList);
|
---|
[5524] | 614 |
|
---|
[6137] | 615 | QList<t_satObs> obsListHlp;
|
---|
[5524] | 616 |
|
---|
[1555] | 617 | while (it.hasNext()) {
|
---|
[6137] | 618 | const t_satObs& obs = it.next();
|
---|
[2711] | 619 |
|
---|
[1555] | 620 | // Check observation epoch
|
---|
| 621 | // -----------------------
|
---|
[5739] | 622 | if (!_rawFile) {
|
---|
[8011] | 623 | bool wrongObservationEpoch = checkForWrongObsEpoch(obs._time);
|
---|
| 624 | if (wrongObservationEpoch) {
|
---|
[8021] | 625 | QString prn(obs._prn.toString().c_str());
|
---|
[9131] | 626 | emit(newMessage(_staID + " (" + prn.toLatin1() + ")" + ": Wrong observation epoch(s)", false));
|
---|
[1555] | 627 | continue;
|
---|
[940] | 628 | }
|
---|
[686] | 629 | }
|
---|
[6812] | 630 |
|
---|
[3305] | 631 | // Check observations coming twice (e.g. KOUR0 Problem)
|
---|
| 632 | // ----------------------------------------------------
|
---|
[3535] | 633 | if (!_rawFile) {
|
---|
[8011] | 634 | QString prn(obs._prn.toString().c_str());
|
---|
[8417] | 635 | bncTime obsTime = obs._time;
|
---|
| 636 | QMap<QString, bncTime>::const_iterator it = _prnLastEpo.find(prn);
|
---|
[3535] | 637 | if (it != _prnLastEpo.end()) {
|
---|
[8417] | 638 | bncTime oldTime = it.value();
|
---|
[8082] | 639 | if (obsTime < oldTime) {
|
---|
[8417] | 640 | emit(newMessage(_staID + ": old observation " + prn.toLatin1(), false));
|
---|
[3535] | 641 | continue;
|
---|
[8082] | 642 | } else if (obsTime == oldTime) {
|
---|
[9131] | 643 | emit(newMessage(_staID + ": observation coming more than once " + prn.toLatin1(), false));
|
---|
[3535] | 644 | continue;
|
---|
| 645 | }
|
---|
[3302] | 646 | }
|
---|
[3535] | 647 | _prnLastEpo[prn] = obsTime;
|
---|
[3301] | 648 | }
|
---|
| 649 |
|
---|
[3528] | 650 | decoder()->dumpRinexEpoch(obs, _format);
|
---|
| 651 |
|
---|
[5524] | 652 | // Save observations
|
---|
| 653 | // -----------------
|
---|
| 654 | obsListHlp.append(obs);
|
---|
| 655 | }
|
---|
[2030] | 656 |
|
---|
[5524] | 657 | // Emit signal
|
---|
| 658 | // -----------
|
---|
| 659 | if (!_isToBeDeleted && obsListHlp.size() > 0) {
|
---|
| 660 | emit newObs(_staID, obsListHlp);
|
---|
[249] | 661 | }
|
---|
[5524] | 662 |
|
---|
[8082] | 663 | } catch (Exception& exc) {
|
---|
[3311] | 664 | emit(newMessage(_staID + " " + exc.what(), true));
|
---|
| 665 | _isToBeDeleted = true;
|
---|
[8082] | 666 | } catch (...) {
|
---|
[3311] | 667 | emit(newMessage(_staID + " bncGetThread exception", true));
|
---|
[1559] | 668 | _isToBeDeleted = true;
|
---|
[1555] | 669 | }
|
---|
[35] | 670 | }
|
---|
| 671 | }
|
---|
| 672 |
|
---|
[7486] | 673 | // Try Re-Connect
|
---|
[136] | 674 | ////////////////////////////////////////////////////////////////////////////
|
---|
[1555] | 675 | t_irc bncGetThread::tryReconnect() {
|
---|
| 676 |
|
---|
| 677 | // Easy Return
|
---|
| 678 | // -----------
|
---|
| 679 | if (_query && _query->status() == bncNetQuery::running) {
|
---|
| 680 | _nextSleep = 0;
|
---|
[3560] | 681 | if (_rawFile) {
|
---|
| 682 | QMapIterator<QString, GPSDecoder*> itDec(_decodersRaw);
|
---|
| 683 | while (itDec.hasNext()) {
|
---|
| 684 | itDec.next();
|
---|
| 685 | GPSDecoder* decoder = itDec.value();
|
---|
| 686 | decoder->setRinexReconnectFlag(false);
|
---|
| 687 | }
|
---|
[8082] | 688 | } else {
|
---|
[3560] | 689 | _decoder->setRinexReconnectFlag(false);
|
---|
| 690 | }
|
---|
[1555] | 691 | return success;
|
---|
[408] | 692 | }
|
---|
[1555] | 693 |
|
---|
| 694 | // Start a new query
|
---|
| 695 | // -----------------
|
---|
[2519] | 696 | if (!_rawFile) {
|
---|
[1555] | 697 |
|
---|
[138] | 698 | sleep(_nextSleep);
|
---|
[1555] | 699 | if (_nextSleep == 0) {
|
---|
| 700 | _nextSleep = 1;
|
---|
[8082] | 701 | } else {
|
---|
[1555] | 702 | _nextSleep = 2 * _nextSleep;
|
---|
[442] | 703 | if (_nextSleep > 256) {
|
---|
| 704 | _nextSleep = 256;
|
---|
[152] | 705 | }
|
---|
[1816] | 706 | #ifdef MLS_SOFTWARE
|
---|
[1817] | 707 | if (_nextSleep > 4) {
|
---|
| 708 | _nextSleep = 4;
|
---|
[1816] | 709 | }
|
---|
| 710 | #endif
|
---|
[138] | 711 | }
|
---|
[8123] | 712 | delete _query;
|
---|
[8082] | 713 | if (_ntripVersion == "U") {
|
---|
[1721] | 714 | _query = new bncNetQueryUdp();
|
---|
[8082] | 715 | } else if (_ntripVersion == "R") {
|
---|
[1555] | 716 | _query = new bncNetQueryRtp();
|
---|
[8082] | 717 | } else if (_ntripVersion == "S") {
|
---|
[1753] | 718 | _query = new bncNetQueryS();
|
---|
[8082] | 719 | } else if (_ntripVersion == "N") {
|
---|
[1621] | 720 | _query = new bncNetQueryV0();
|
---|
[8082] | 721 | } else if (_ntripVersion == "UN") {
|
---|
[1779] | 722 | _query = new bncNetQueryUdp0();
|
---|
[8082] | 723 | } else if (_ntripVersion == "2") {
|
---|
[3337] | 724 | _query = new bncNetQueryV2(false);
|
---|
[8082] | 725 | } else if (_ntripVersion == "2s") {
|
---|
[3337] | 726 | _query = new bncNetQueryV2(true);
|
---|
[8082] | 727 | } else {
|
---|
[1555] | 728 | _query = new bncNetQueryV1();
|
---|
| 729 | }
|
---|
[6770] | 730 | if (_nmea == "yes") {
|
---|
| 731 | if (_serialNMEA == MANUAL_NMEA) {
|
---|
| 732 | _query->startRequest(_mountPoint, _manualNMEAString);
|
---|
| 733 | _lastManualNMEA = QDateTime::currentDateTime();
|
---|
[8082] | 734 | } else if (_serialNMEA == AUTO_NMEA) {
|
---|
[6770] | 735 | if (_serialPort) {
|
---|
| 736 | int nb = _serialPort->bytesAvailable();
|
---|
| 737 | if (nb > 0) {
|
---|
| 738 | QByteArray data = _serialPort->read(nb);
|
---|
| 739 | int i1 = data.indexOf("$GPGGA");
|
---|
| 740 | if (i1 == -1) {
|
---|
| 741 | i1 = data.indexOf("$GNGGA");
|
---|
| 742 | }
|
---|
| 743 | if (i1 != -1) {
|
---|
| 744 | int i2 = data.indexOf("*", i1);
|
---|
| 745 | if (i2 != -1 && data.size() > i2 + 1) {
|
---|
| 746 | QByteArray gga = data.mid(i1, i2 - i1 + 3);
|
---|
| 747 | _query->startRequest(_mountPoint, gga);
|
---|
| 748 | }
|
---|
| 749 | }
|
---|
| 750 | }
|
---|
| 751 | }
|
---|
| 752 | }
|
---|
[8082] | 753 | } else {
|
---|
[1555] | 754 | _query->startRequest(_mountPoint, "");
|
---|
| 755 | }
|
---|
[6770] | 756 |
|
---|
[1555] | 757 | if (_query->status() != bncNetQuery::running) {
|
---|
| 758 | return failure;
|
---|
| 759 | }
|
---|
[138] | 760 | }
|
---|
[658] | 761 |
|
---|
[3560] | 762 | if (_rawFile) {
|
---|
| 763 | QMapIterator<QString, GPSDecoder*> itDec(_decodersRaw);
|
---|
| 764 | while (itDec.hasNext()) {
|
---|
| 765 | itDec.next();
|
---|
| 766 | GPSDecoder* decoder = itDec.value();
|
---|
| 767 | decoder->setRinexReconnectFlag(false);
|
---|
| 768 | }
|
---|
[8082] | 769 | } else {
|
---|
| 770 | _decoder->setRinexReconnectFlag(false);
|
---|
[658] | 771 | }
|
---|
[1555] | 772 |
|
---|
| 773 | return success;
|
---|
[658] | 774 | }
|
---|
[1044] | 775 |
|
---|
[1555] | 776 | // RTCM scan output
|
---|
[1044] | 777 | //////////////////////////////////////////////////////////////////////////////
|
---|
[7423] | 778 | void bncGetThread::miscScanRTCM() {
|
---|
[1044] | 779 |
|
---|
[8082] | 780 | if (!decoder()) {
|
---|
[3558] | 781 | return;
|
---|
| 782 | }
|
---|
| 783 |
|
---|
[1555] | 784 | bncSettings settings;
|
---|
[8082] | 785 | if (Qt::CheckState(settings.value("miscScanRTCM").toInt()) == Qt::Checked) {
|
---|
[1574] | 786 |
|
---|
[8082] | 787 | if (_miscMount == _staID || _miscMount == "ALL") {
|
---|
[1575] | 788 | // RTCM message types
|
---|
| 789 | // ------------------
|
---|
[4476] | 790 | for (int ii = 0; ii < decoder()->_typeList.size(); ii++) {
|
---|
[8082] | 791 | QString type = QString("%1 ").arg(decoder()->_typeList[ii]);
|
---|
[8127] | 792 | emit(newMessage(_staID + ": Received message type " + type.toLatin1(),
|
---|
[8082] | 793 | true));
|
---|
[1574] | 794 | }
|
---|
[7486] | 795 |
|
---|
[4476] | 796 | // Check Observation Types
|
---|
| 797 | // -----------------------
|
---|
| 798 | for (int ii = 0; ii < decoder()->_obsList.size(); ii++) {
|
---|
[6137] | 799 | t_satObs& obs = decoder()->_obsList[ii];
|
---|
| 800 | QVector<QString>& rnxTypes = _rnxTypes[obs._prn.system()];
|
---|
[4476] | 801 | bool allFound = true;
|
---|
[6137] | 802 | for (unsigned iFrq = 0; iFrq < obs._obs.size(); iFrq++) {
|
---|
[6579] | 803 | if (obs._obs[iFrq]->_codeValid) {
|
---|
| 804 | QString rnxStr('C');
|
---|
| 805 | rnxStr.append(obs._obs[iFrq]->_rnxType2ch.c_str());
|
---|
[8082] | 806 | if (_format.indexOf("RTCM_2") != -1
|
---|
| 807 | || _format.indexOf("RTCM2") != -1
|
---|
| 808 | || _format.indexOf("RTCM 2") != -1) {
|
---|
[6580] | 809 | rnxStr = t_rnxObsFile::type3to2(obs._prn.system(), rnxStr);
|
---|
| 810 | }
|
---|
[6579] | 811 | if (rnxTypes.indexOf(rnxStr) == -1) {
|
---|
| 812 | rnxTypes.push_back(rnxStr);
|
---|
| 813 | allFound = false;
|
---|
| 814 | }
|
---|
[4476] | 815 | }
|
---|
[6579] | 816 | if (obs._obs[iFrq]->_phaseValid) {
|
---|
| 817 | QString rnxStr('L');
|
---|
| 818 | rnxStr.append(obs._obs[iFrq]->_rnxType2ch.c_str());
|
---|
[8082] | 819 | if (_format.indexOf("RTCM_2") != -1
|
---|
| 820 | || _format.indexOf("RTCM2") != -1
|
---|
| 821 | || _format.indexOf("RTCM 2") != -1) {
|
---|
[6580] | 822 | rnxStr = t_rnxObsFile::type3to2(obs._prn.system(), rnxStr);
|
---|
| 823 | }
|
---|
[6579] | 824 | if (rnxTypes.indexOf(rnxStr) == -1) {
|
---|
| 825 | rnxTypes.push_back(rnxStr);
|
---|
| 826 | allFound = false;
|
---|
| 827 | }
|
---|
| 828 | }
|
---|
[8082] | 829 | if (obs._obs[iFrq]->_dopplerValid) {
|
---|
[6579] | 830 | QString rnxStr('D');
|
---|
| 831 | rnxStr.append(obs._obs[iFrq]->_rnxType2ch.c_str());
|
---|
[8082] | 832 | if (_format.indexOf("RTCM_2") != -1
|
---|
| 833 | || _format.indexOf("RTCM2") != -1
|
---|
| 834 | || _format.indexOf("RTCM 2") != -1) {
|
---|
[6580] | 835 | rnxStr = t_rnxObsFile::type3to2(obs._prn.system(), rnxStr);
|
---|
| 836 | }
|
---|
[6579] | 837 | if (rnxTypes.indexOf(rnxStr) == -1) {
|
---|
| 838 | rnxTypes.push_back(rnxStr);
|
---|
| 839 | allFound = false;
|
---|
| 840 | }
|
---|
| 841 | }
|
---|
[8082] | 842 | if (obs._obs[iFrq]->_snrValid) {
|
---|
[6579] | 843 | QString rnxStr('S');
|
---|
| 844 | rnxStr.append(obs._obs[iFrq]->_rnxType2ch.c_str());
|
---|
[8082] | 845 | if (_format.indexOf("RTCM_2") != -1
|
---|
| 846 | || _format.indexOf("RTCM2") != -1
|
---|
| 847 | || _format.indexOf("RTCM 2") != -1) {
|
---|
[6580] | 848 | rnxStr = t_rnxObsFile::type3to2(obs._prn.system(), rnxStr);
|
---|
| 849 | }
|
---|
[6579] | 850 | if (rnxTypes.indexOf(rnxStr) == -1) {
|
---|
| 851 | rnxTypes.push_back(rnxStr);
|
---|
| 852 | allFound = false;
|
---|
| 853 | }
|
---|
| 854 | }
|
---|
[4476] | 855 | }
|
---|
| 856 | if (!allFound) {
|
---|
[7486] | 857 | QString msg;
|
---|
[4477] | 858 | QTextStream str(&msg);
|
---|
[6579] | 859 | QString s;
|
---|
[8082] | 860 | str << obs._prn.system() << " "
|
---|
| 861 | << s.sprintf("%2d", rnxTypes.size()) << " ";
|
---|
[4476] | 862 | for (int iType = 0; iType < rnxTypes.size(); iType++) {
|
---|
[4478] | 863 | str << " " << rnxTypes[iType];
|
---|
[4476] | 864 | }
|
---|
[8127] | 865 | emit(newMessage(_staID + ": Observation Types: " + msg.toLatin1(),
|
---|
[8082] | 866 | true));
|
---|
[4476] | 867 | }
|
---|
| 868 | }
|
---|
| 869 |
|
---|
[1574] | 870 | // RTCMv3 antenna descriptor
|
---|
| 871 | // -------------------------
|
---|
[4476] | 872 | for (int ii = 0; ii < decoder()->_antType.size(); ii++) {
|
---|
[8236] | 873 | QString ant1 = QString(": Antenna Descriptor: %1 ").arg(decoder()->_antType[ii].descriptor);
|
---|
| 874 | emit(newMessage(_staID + ant1.toLatin1(), true));
|
---|
| 875 | if (strlen(decoder()->_antType[ii].serialnumber)) {
|
---|
| 876 | QString ant2 = QString(": Antenna Serial Number: %1 ").arg(decoder()->_antType[ii].serialnumber);
|
---|
| 877 | emit(newMessage(_staID + ant2.toLatin1(), true));
|
---|
| 878 | }
|
---|
[1574] | 879 | }
|
---|
[1555] | 880 |
|
---|
[1575] | 881 | // RTCM Antenna Coordinates
|
---|
| 882 | // ------------------------
|
---|
[8082] | 883 | for (int ii = 0; ii < decoder()->_antList.size(); ii++) {
|
---|
[1574] | 884 | QByteArray antT;
|
---|
[8236] | 885 | if (decoder()->_antList[ii].type == GPSDecoder::t_antRefPoint::ARP) {
|
---|
[1574] | 886 | antT = "ARP";
|
---|
[8236] | 887 | } else if (decoder()->_antList[ii].type == GPSDecoder::t_antRefPoint::APC) {
|
---|
[1574] | 888 | antT = "APC";
|
---|
| 889 | }
|
---|
[1575] | 890 | QByteArray ant1, ant2, ant3;
|
---|
[8236] | 891 | ant1 = QString("%1 ").arg(decoder()->_antList[ii].xx, 0, 'f', 4).toLatin1();
|
---|
| 892 | ant2 = QString("%1 ").arg(decoder()->_antList[ii].yy, 0, 'f', 4).toLatin1();
|
---|
| 893 | ant3 = QString("%1 ").arg(decoder()->_antList[ii].zz, 0, 'f', 4).toLatin1();
|
---|
[1575] | 894 | emit(newMessage(_staID + ": " + antT + " (ITRF) X " + ant1 + "m", true));
|
---|
| 895 | emit(newMessage(_staID + ": " + antT + " (ITRF) Y " + ant2 + "m", true));
|
---|
| 896 | emit(newMessage(_staID + ": " + antT + " (ITRF) Z " + ant3 + "m", true));
|
---|
[3595] | 897 | double hh = 0.0;
|
---|
[3523] | 898 | if (decoder()->_antList[ii].height_f) {
|
---|
[3595] | 899 | hh = decoder()->_antList[ii].height;
|
---|
[8127] | 900 | QByteArray ant4 = QString("%1 ").arg(hh, 0, 'f', 4).toLatin1();
|
---|
[8082] | 901 | emit(newMessage(
|
---|
| 902 | _staID + ": Antenna height above marker " + ant4 + "m", true));
|
---|
[1575] | 903 | }
|
---|
[7486] | 904 | emit(newAntCrd(_staID, decoder()->_antList[ii].xx,
|
---|
[8082] | 905 | decoder()->_antList[ii].yy, decoder()->_antList[ii].zz, hh, antT));
|
---|
[1218] | 906 | }
|
---|
[6864] | 907 |
|
---|
[8197] | 908 | // RTCMv3 receiver descriptor
|
---|
| 909 | // --------------------------
|
---|
| 910 | for (int ii = 0; ii < decoder()->_recType.size(); ii++) {
|
---|
[8236] | 911 | QString rec1 = QString(": Receiver Descriptor: %1 ").arg(decoder()->_recType[ii].descriptor);
|
---|
| 912 | QString rec2 = QString(": Receiver Firmware Version: %1 ").arg(decoder()->_recType[ii].firmware);
|
---|
| 913 | QString rec3 = QString(": Receiver Serial Number: %1 ").arg(decoder()->_recType[ii].serialnumber);
|
---|
| 914 | emit(newMessage(_staID + rec1.toLatin1(), true));
|
---|
| 915 | emit(newMessage(_staID + rec2.toLatin1(), true));
|
---|
| 916 | emit(newMessage(_staID + rec3.toLatin1(), true));
|
---|
[8197] | 917 | }
|
---|
| 918 |
|
---|
[6864] | 919 | // RTCM GLONASS slots
|
---|
| 920 | // ------------------
|
---|
| 921 | if (decoder()->_gloFrq.size()) {
|
---|
| 922 | bool allFound = true;
|
---|
| 923 | QString slot = decoder()->_gloFrq;
|
---|
[8082] | 924 | slot.replace(" ", " ").replace(" ", ":");
|
---|
[6864] | 925 | if (_gloSlots.indexOf(slot) == -1) {
|
---|
| 926 | _gloSlots.append(slot);
|
---|
| 927 | allFound = false;
|
---|
| 928 | }
|
---|
| 929 | if (!allFound) {
|
---|
| 930 | _gloSlots.sort();
|
---|
[8082] | 931 | emit(newMessage(
|
---|
[8127] | 932 | _staID + ": GLONASS Slot:Freq " + _gloSlots.join(" ").toLatin1(),
|
---|
[8082] | 933 | true));
|
---|
[6864] | 934 | }
|
---|
| 935 | }
|
---|
[1218] | 936 | }
|
---|
[1044] | 937 | }
|
---|
[1575] | 938 |
|
---|
[1770] | 939 | #ifdef MLS_SOFTWARE
|
---|
[3523] | 940 | for (int ii=0; ii <decoder()->_antList.size(); ii++) {
|
---|
[8082] | 941 | QByteArray antT;
|
---|
| 942 | if (decoder()->_antList[ii].type == GPSDecoder::t_antInfo::ARP) {
|
---|
| 943 | antT = "ARP";
|
---|
| 944 | }
|
---|
| 945 | else if (decoder()->_antList[ii].type == GPSDecoder::t_antInfo::APC) {
|
---|
| 946 | antT = "APC";
|
---|
| 947 | }
|
---|
| 948 | double hh = 0.0;
|
---|
| 949 | if (decoder()->_antList[ii].height_f) {
|
---|
| 950 | hh = decoder()->_antList[ii].height;
|
---|
| 951 | }
|
---|
| 952 | emit(newAntCrd(_staID, decoder()->_antList[ii].xx,
|
---|
| 953 | decoder()->_antList[ii].yy, decoder()->_antList[ii].zz,
|
---|
| 954 | hh, antT));
|
---|
[1770] | 955 | }
|
---|
[2356] | 956 |
|
---|
[3523] | 957 | for (int ii = 0; ii <decoder()->_typeList.size(); ii++) {
|
---|
| 958 | emit(newRTCMMessage(_staID, decoder()->_typeList[ii]));
|
---|
[2356] | 959 | }
|
---|
[1770] | 960 | #endif
|
---|
| 961 |
|
---|
[6864] | 962 | decoder()->_gloFrq.clear();
|
---|
[3523] | 963 | decoder()->_typeList.clear();
|
---|
| 964 | decoder()->_antType.clear();
|
---|
[8197] | 965 | decoder()->_recType.clear();
|
---|
[3523] | 966 | decoder()->_antList.clear();
|
---|
[1044] | 967 | }
|
---|
[1555] | 968 |
|
---|
[1606] | 969 | // Handle Data from Serial Port
|
---|
| 970 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 971 | void bncGetThread::slotSerialReadyRead() {
|
---|
[6770] | 972 |
|
---|
[1607] | 973 | if (_serialPort) {
|
---|
[6770] | 974 |
|
---|
[6773] | 975 | if (_nmea == "yes" && _serialNMEA == MANUAL_NMEA) {
|
---|
| 976 | if (_manualNMEASampl) {
|
---|
| 977 | int dt = _lastManualNMEA.secsTo(QDateTime::currentDateTime());
|
---|
| 978 | if (dt && (fmod(double(dt), double(_manualNMEASampl)) == 0.0)) {
|
---|
| 979 | _query->sendNMEA(_manualNMEAString);
|
---|
| 980 | _lastManualNMEA = QDateTime::currentDateTime();
|
---|
| 981 | }
|
---|
| 982 | }
|
---|
| 983 | }
|
---|
| 984 |
|
---|
[1633] | 985 | int nb = _serialPort->bytesAvailable();
|
---|
| 986 | if (nb > 0) {
|
---|
| 987 | QByteArray data = _serialPort->read(nb);
|
---|
[1711] | 988 |
|
---|
[6695] | 989 | if (_nmea == "yes" && _serialNMEA == AUTO_NMEA) {
|
---|
[1725] | 990 | int i1 = data.indexOf("$GPGGA");
|
---|
[6651] | 991 | if (i1 == -1) {
|
---|
| 992 | i1 = data.indexOf("$GNGGA");
|
---|
| 993 | }
|
---|
[1725] | 994 | if (i1 != -1) {
|
---|
[6751] | 995 | int i2 = data.indexOf("*", i1);
|
---|
[1725] | 996 | if (i2 != -1 && data.size() > i2 + 1) {
|
---|
[6751] | 997 | QByteArray gga = data.mid(i1, i2 - i1 + 3);
|
---|
[1725] | 998 | _query->sendNMEA(gga);
|
---|
[6751] | 999 | }
|
---|
| 1000 | }
|
---|
[1711] | 1001 | }
|
---|
| 1002 |
|
---|
[1633] | 1003 | if (_serialOutFile) {
|
---|
| 1004 | _serialOutFile->write(data);
|
---|
| 1005 | _serialOutFile->flush();
|
---|
| 1006 | }
|
---|
[1607] | 1007 | }
|
---|
| 1008 | }
|
---|
[1606] | 1009 | }
|
---|
[7180] | 1010 |
|
---|
| 1011 | void bncGetThread::slotNewNMEAConnection() {
|
---|
| 1012 | _nmeaSockets->push_back(_nmeaServer->nextPendingConnection());
|
---|
[8082] | 1013 | emit(newMessage(
|
---|
[8127] | 1014 | QString("New PPP client on port: # %1").arg(_nmeaSockets->size()).toLatin1(),
|
---|
[8082] | 1015 | true));
|
---|
[7180] | 1016 | }
|
---|
| 1017 |
|
---|
| 1018 | //
|
---|
| 1019 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 1020 | void bncGetThread::slotNewNMEAstr(QByteArray staID, QByteArray str) {
|
---|
| 1021 | if (_nmeaPortsMap.contains(staID)) {
|
---|
| 1022 | int nmeaPort = _nmeaPortsMap.value(staID);
|
---|
| 1023 | QMutableListIterator<QTcpSocket*> is(*_nmeaSockets);
|
---|
| 1024 | while (is.hasNext()) {
|
---|
| 1025 | QTcpSocket* sock = is.next();
|
---|
| 1026 | if (sock->localPort() == nmeaPort) {
|
---|
| 1027 | if (sock->state() == QAbstractSocket::ConnectedState) {
|
---|
| 1028 | sock->write(str);
|
---|
[8082] | 1029 | } else if (sock->state() != QAbstractSocket::ConnectingState) {
|
---|
[7180] | 1030 | delete sock;
|
---|
| 1031 | is.remove();
|
---|
| 1032 | }
|
---|
| 1033 | }
|
---|
| 1034 | }
|
---|
| 1035 | }
|
---|
| 1036 | }
|
---|