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