[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);
|
---|
[8082] | 299 | obs = false;
|
---|
| 300 | ssrOrb = false;
|
---|
| 301 | ssrClk = false;
|
---|
| 302 | ssrOrbClk = false;
|
---|
| 303 | ssrCbi = false;
|
---|
| 304 | ssrPbi = false;
|
---|
| 305 | ssrVtec = false;
|
---|
| 306 | ssrUra = false;
|
---|
| 307 | ssrHr = false;
|
---|
| 308 | _ssrEpoch = 0;
|
---|
| 309 | } else {
|
---|
[3532] | 310 | _latencyChecker = 0;
|
---|
| 311 | }
|
---|
[3523] | 312 | }
|
---|
| 313 |
|
---|
| 314 | // Instantiate the decoder
|
---|
| 315 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 316 | t_irc bncGetThread::initDecoder() {
|
---|
| 317 |
|
---|
[3560] | 318 | _decoder = 0;
|
---|
| 319 |
|
---|
[8082] | 320 | if (_format.indexOf("RTCM_2") != -1 || _format.indexOf("RTCM2") != -1
|
---|
| 321 | || _format.indexOf("RTCM 2") != -1) {
|
---|
[1555] | 322 | emit(newMessage(_staID + ": Get data in RTCM 2.x format", true));
|
---|
[3560] | 323 | _decoder = new RTCM2Decoder(_staID.data());
|
---|
[8082] | 324 | } else if (_format.indexOf("RTCM_3") != -1 || _format.indexOf("RTCM3") != -1
|
---|
| 325 | || _format.indexOf("RTCM 3") != -1) {
|
---|
[1555] | 326 | emit(newMessage(_staID + ": Get data in RTCM 3.x format", true));
|
---|
[3558] | 327 | RTCM3Decoder* newDecoder = new RTCM3Decoder(_staID, _rawFile);
|
---|
[3560] | 328 | _decoder = newDecoder;
|
---|
[7486] | 329 | connect((RTCM3Decoder*) newDecoder, SIGNAL(newMessage(QByteArray,bool)),
|
---|
[8082] | 330 | this, SIGNAL(newMessage(QByteArray,bool)));
|
---|
| 331 | } else if (_format.indexOf("ZERO") != -1) {
|
---|
[1555] | 332 | emit(newMessage(_staID + ": Get data in original format", true));
|
---|
[3560] | 333 | _decoder = new bncZeroDecoder(_staID);
|
---|
[8082] | 334 | } else if (_format.indexOf("RTNET") != -1) {
|
---|
[3168] | 335 | emit(newMessage(_staID + ": Get data in RTNet format", true));
|
---|
[3560] | 336 | _decoder = new bncRtnetDecoder();
|
---|
[8082] | 337 | } else {
|
---|
[1555] | 338 | emit(newMessage(_staID + ": Unknown data format " + _format, true));
|
---|
| 339 | _isToBeDeleted = true;
|
---|
[3523] | 340 | return failure;
|
---|
[1555] | 341 | }
|
---|
| 342 |
|
---|
[319] | 343 | msleep(100); //sleep 0.1 sec
|
---|
[7486] | 344 |
|
---|
[8082] | 345 | _decoder->initRinex(_staID, _mountPoint, _latitude, _longitude, _nmea,
|
---|
| 346 | _ntripVersion);
|
---|
[3560] | 347 |
|
---|
| 348 | if (_rawFile) {
|
---|
| 349 | _decodersRaw[_staID] = _decoder;
|
---|
[3530] | 350 | }
|
---|
| 351 |
|
---|
[3523] | 352 | return success;
|
---|
[35] | 353 | }
|
---|
| 354 |
|
---|
[3523] | 355 | // Current decoder in use
|
---|
| 356 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 357 | GPSDecoder* bncGetThread::decoder() {
|
---|
[3560] | 358 | if (!_rawFile) {
|
---|
| 359 | return _decoder;
|
---|
[8082] | 360 | } else {
|
---|
[3560] | 361 | if (_decodersRaw.contains(_staID) || initDecoder() == success) {
|
---|
| 362 | return _decodersRaw[_staID];
|
---|
| 363 | }
|
---|
[3523] | 364 | }
|
---|
[3560] | 365 | return 0;
|
---|
[3523] | 366 | }
|
---|
| 367 |
|
---|
[35] | 368 | // Destructor
|
---|
| 369 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 370 | bncGetThread::~bncGetThread() {
|
---|
[1928] | 371 | if (isRunning()) {
|
---|
| 372 | wait();
|
---|
| 373 | }
|
---|
[1527] | 374 | if (_query) {
|
---|
| 375 | _query->stop();
|
---|
[1708] | 376 | _query->deleteLater();
|
---|
[1527] | 377 | }
|
---|
[3560] | 378 | if (_rawFile) {
|
---|
| 379 | QMapIterator<QString, GPSDecoder*> it(_decodersRaw);
|
---|
| 380 | while (it.hasNext()) {
|
---|
| 381 | it.next();
|
---|
| 382 | delete it.value();
|
---|
| 383 | }
|
---|
[8082] | 384 | } else {
|
---|
[3560] | 385 | delete _decoder;
|
---|
| 386 | }
|
---|
[2519] | 387 | delete _rawFile;
|
---|
[1607] | 388 | delete _serialOutFile;
|
---|
[1328] | 389 | delete _serialPort;
|
---|
[1557] | 390 | delete _latencyChecker;
|
---|
[1556] | 391 | emit getThreadFinished(_staID);
|
---|
[35] | 392 | }
|
---|
| 393 |
|
---|
[7486] | 394 | //
|
---|
[1390] | 395 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 396 | void bncGetThread::terminate() {
|
---|
[1525] | 397 | _isToBeDeleted = true;
|
---|
[7854] | 398 |
|
---|
[8082] | 399 | if (_nmeaPortsMap.contains(_staID)) {
|
---|
[7854] | 400 | _nmeaPortsMap.remove(_staID);
|
---|
[1559] | 401 | }
|
---|
[7854] | 402 | if (_nmeaServer) {
|
---|
| 403 | delete _nmeaServer;
|
---|
| 404 | }
|
---|
| 405 | if (_nmeaSockets) {
|
---|
| 406 | delete _nmeaSockets;
|
---|
| 407 | }
|
---|
[7858] | 408 |
|
---|
| 409 | #ifdef BNC_DEBUG
|
---|
[7859] | 410 | if (BNC_CORE->mode() != t_bncCore::interactive) {
|
---|
[8082] | 411 | while (!isFinished()) {
|
---|
| 412 | wait();
|
---|
| 413 | }
|
---|
[7859] | 414 | delete this;
|
---|
[8082] | 415 | } else {
|
---|
| 416 | if (!isRunning()) {
|
---|
| 417 | delete this;
|
---|
| 418 | }
|
---|
[7858] | 419 | }
|
---|
| 420 | #else
|
---|
[8082] | 421 | if (!isRunning()) {delete this;}
|
---|
[7858] | 422 | #endif
|
---|
| 423 |
|
---|
[1390] | 424 | }
|
---|
| 425 |
|
---|
[136] | 426 | // Run
|
---|
| 427 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 428 | void bncGetThread::run() {
|
---|
| 429 |
|
---|
[35] | 430 | while (true) {
|
---|
[629] | 431 | try {
|
---|
[1555] | 432 | if (_isToBeDeleted) {
|
---|
| 433 | QThread::exit(0);
|
---|
| 434 | this->deleteLater();
|
---|
| 435 | return;
|
---|
[629] | 436 | }
|
---|
[621] | 437 |
|
---|
[1555] | 438 | if (tryReconnect() != success) {
|
---|
[3532] | 439 | if (_latencyChecker) {
|
---|
| 440 | _latencyChecker->checkReconnect();
|
---|
| 441 | }
|
---|
[1555] | 442 | continue;
|
---|
[621] | 443 | }
|
---|
[1555] | 444 |
|
---|
| 445 | // Delete old observations
|
---|
| 446 | // -----------------------
|
---|
[3560] | 447 | if (_rawFile) {
|
---|
| 448 | QMapIterator<QString, GPSDecoder*> itDec(_decodersRaw);
|
---|
| 449 | while (itDec.hasNext()) {
|
---|
| 450 | itDec.next();
|
---|
| 451 | GPSDecoder* decoder = itDec.value();
|
---|
| 452 | decoder->_obsList.clear();
|
---|
| 453 | }
|
---|
[8082] | 454 | } else {
|
---|
[3560] | 455 | _decoder->_obsList.clear();
|
---|
| 456 | }
|
---|
[621] | 457 |
|
---|
[1555] | 458 | // Read Data
|
---|
| 459 | // ---------
|
---|
[1377] | 460 | QByteArray data;
|
---|
[8082] | 461 | if (_query) {
|
---|
[1377] | 462 | _query->waitForReadyRead(data);
|
---|
[8082] | 463 | } else if (_rawFile) {
|
---|
[2527] | 464 | data = _rawFile->readChunk();
|
---|
[3523] | 465 | _format = _rawFile->format();
|
---|
[8082] | 466 | _staID = _rawFile->staID();
|
---|
[2388] | 467 |
|
---|
[5903] | 468 | QCoreApplication::processEvents();
|
---|
| 469 |
|
---|
[7976] | 470 | if (data.isEmpty() || BNC_CORE->sigintReceived) {
|
---|
| 471 | cout << "no more data or Ctrl-C received" << endl;
|
---|
[5068] | 472 | BNC_CORE->stopCombination();
|
---|
[5900] | 473 | BNC_CORE->stopPPP();
|
---|
[8781] | 474 | sleep(1);
|
---|
[5903] | 475 | ::exit(0);
|
---|
[1555] | 476 | }
|
---|
[1138] | 477 | }
|
---|
[8123] | 478 |
|
---|
[1555] | 479 | qint64 nBytes = data.size();
|
---|
[1138] | 480 |
|
---|
[1555] | 481 | // Timeout, reconnect
|
---|
| 482 | // ------------------
|
---|
| 483 | if (nBytes == 0) {
|
---|
[3532] | 484 | if (_latencyChecker) {
|
---|
| 485 | _latencyChecker->checkReconnect();
|
---|
| 486 | }
|
---|
[1555] | 487 | emit(newMessage(_staID + ": Data timeout, reconnecting", true));
|
---|
[2355] | 488 | msleep(10000); //sleep 10 sec, G. Weber
|
---|
[1555] | 489 | continue;
|
---|
[8082] | 490 | } else {
|
---|
[567] | 491 | emit newBytes(_staID, nBytes);
|
---|
[5648] | 492 | emit newRawData(_staID, data);
|
---|
[1555] | 493 | }
|
---|
[567] | 494 |
|
---|
[1555] | 495 | // Output Data
|
---|
| 496 | // -----------
|
---|
[2386] | 497 | if (_rawOutput) {
|
---|
[7486] | 498 | BNC_CORE->writeRawData(data, _staID, _format);
|
---|
[2386] | 499 | }
|
---|
[2385] | 500 |
|
---|
[1555] | 501 | if (_serialPort) {
|
---|
[1633] | 502 | slotSerialReadyRead();
|
---|
[1555] | 503 | _serialPort->write(data);
|
---|
| 504 | }
|
---|
[7486] | 505 |
|
---|
[1555] | 506 | // Decode Data
|
---|
| 507 | // -----------
|
---|
| 508 | vector<string> errmsg;
|
---|
[3526] | 509 | if (!decoder()) {
|
---|
| 510 | _isToBeDeleted = true;
|
---|
| 511 | continue;
|
---|
| 512 | }
|
---|
[7753] | 513 |
|
---|
[3523] | 514 | t_irc irc = decoder()->Decode(data.data(), data.size(), errmsg);
|
---|
[1137] | 515 |
|
---|
[7753] | 516 | if (irc != success) {
|
---|
| 517 | continue;
|
---|
| 518 | }
|
---|
[1555] | 519 | // Perform various scans and checks
|
---|
| 520 | // --------------------------------
|
---|
[3532] | 521 | if (_latencyChecker) {
|
---|
[8271] | 522 | _latencyChecker->checkOutage(irc);
|
---|
[8082] | 523 | QListIterator<int> it(decoder()->_typeList);
|
---|
[8271] | 524 | _ssrEpoch = static_cast<int>(decoder()->corrGPSEpochTime());
|
---|
[8730] | 525 | if (_ssrEpoch != -1) {
|
---|
[8082] | 526 | if (ssrOrb) {
|
---|
[8730] | 527 | _latencyChecker->checkCorrLatency(_ssrEpoch, 1057);
|
---|
[8082] | 528 | ssrOrb = false;
|
---|
| 529 | }
|
---|
| 530 | if (ssrClk) {
|
---|
[8730] | 531 | _latencyChecker->checkCorrLatency(_ssrEpoch, 1058);
|
---|
[8082] | 532 | ssrClk = false;
|
---|
| 533 | }
|
---|
| 534 | if (ssrOrbClk) {
|
---|
[8730] | 535 | _latencyChecker->checkCorrLatency(_ssrEpoch, 1060);
|
---|
[8082] | 536 | ssrOrbClk = false;
|
---|
| 537 | }
|
---|
| 538 | if (ssrCbi) {
|
---|
[8730] | 539 | _latencyChecker->checkCorrLatency(_ssrEpoch, 1059);
|
---|
[8082] | 540 | ssrCbi = false;
|
---|
| 541 | }
|
---|
| 542 | if (ssrPbi) {
|
---|
[8730] | 543 | _latencyChecker->checkCorrLatency(_ssrEpoch, 1265);
|
---|
[8082] | 544 | ssrPbi = false;
|
---|
| 545 | }
|
---|
| 546 | if (ssrVtec) {
|
---|
[8730] | 547 | _latencyChecker->checkCorrLatency(_ssrEpoch, 1264);
|
---|
[8082] | 548 | ssrVtec = false;
|
---|
| 549 | }
|
---|
| 550 | if (ssrUra) {
|
---|
[8730] | 551 | _latencyChecker->checkCorrLatency(_ssrEpoch, 1061);
|
---|
[8082] | 552 | ssrUra = false;
|
---|
| 553 | }
|
---|
| 554 | if (ssrHr) {
|
---|
[8730] | 555 | _latencyChecker->checkCorrLatency(_ssrEpoch, 1062);
|
---|
[8082] | 556 | ssrHr = false;
|
---|
| 557 | }
|
---|
| 558 | }
|
---|
| 559 | while (it.hasNext()) {
|
---|
| 560 | int rtcmType = it.next();
|
---|
| 561 | if ((rtcmType >= 1001 && rtcmType <= 1004) || // legacy RTCM OBS
|
---|
| 562 | (rtcmType >= 1009 && rtcmType <= 1012) || // legacy RTCM OBS
|
---|
[9009] | 563 | (rtcmType >= 1071 && rtcmType <= 1137)) { // MSM RTCM OBS
|
---|
[8082] | 564 | obs = true;
|
---|
| 565 | } else if ((rtcmType >= 1057 && rtcmType <= 1068) ||
|
---|
| 566 | (rtcmType >= 1240 && rtcmType <= 1270)) {
|
---|
| 567 | switch (rtcmType) {
|
---|
| 568 | case 1057: case 1063: case 1240: case 1246: case 1252: case 1258:
|
---|
| 569 | ssrOrb = true;
|
---|
| 570 | break;
|
---|
| 571 | case 1058: case 1064: case 1241: case 1247: case 1253: case 1259:
|
---|
| 572 | ssrClk = true;
|
---|
| 573 | break;
|
---|
| 574 | case 1060: case 1066: case 1243: case 1249: case 1255: case 1261:
|
---|
| 575 | ssrOrbClk = true;
|
---|
| 576 | break;
|
---|
[9017] | 577 | case 1059: case 1065: case 1242: case 1248: case 1254: case 1260:
|
---|
[8082] | 578 | ssrCbi = true;
|
---|
| 579 | break;
|
---|
| 580 | case 1265: case 1266: case 1267: case 1268: case 1269: case 1270:
|
---|
| 581 | ssrPbi = true;
|
---|
| 582 | break;
|
---|
| 583 | case 1264:
|
---|
| 584 | ssrVtec = true;
|
---|
| 585 | break;
|
---|
| 586 | case 1061: case 1067: case 1244: case 1250: case 1256: case 1262:
|
---|
| 587 | ssrUra = true;
|
---|
| 588 | break;
|
---|
| 589 | case 1062: case 1068: case 1245: case 1251: case 1257: case 1263:
|
---|
| 590 | ssrHr = true;
|
---|
| 591 | break;
|
---|
| 592 | }
|
---|
| 593 | }
|
---|
| 594 | }
|
---|
| 595 | if (obs) {
|
---|
| 596 | _latencyChecker->checkObsLatency(decoder()->_obsList);
|
---|
| 597 | }
|
---|
[3532] | 598 | emit newLatency(_staID, _latencyChecker->currentLatency());
|
---|
| 599 | }
|
---|
[7753] | 600 | miscScanRTCM();
|
---|
[1138] | 601 |
|
---|
[1555] | 602 | // Loop over all observations (observations output)
|
---|
| 603 | // ------------------------------------------------
|
---|
[6137] | 604 | QListIterator<t_satObs> it(decoder()->_obsList);
|
---|
[5524] | 605 |
|
---|
[6137] | 606 | QList<t_satObs> obsListHlp;
|
---|
[5524] | 607 |
|
---|
[1555] | 608 | while (it.hasNext()) {
|
---|
[6137] | 609 | const t_satObs& obs = it.next();
|
---|
[2711] | 610 |
|
---|
[1555] | 611 | // Check observation epoch
|
---|
| 612 | // -----------------------
|
---|
[5739] | 613 | if (!_rawFile) {
|
---|
[8011] | 614 | bool wrongObservationEpoch = checkForWrongObsEpoch(obs._time);
|
---|
| 615 | if (wrongObservationEpoch) {
|
---|
[8021] | 616 | QString prn(obs._prn.toString().c_str());
|
---|
[8082] | 617 | emit(newMessage(
|
---|
[8127] | 618 | _staID + " (" + prn.toLatin1() + ")"
|
---|
[8082] | 619 | + ": Wrong observation epoch(s)", false));
|
---|
[1555] | 620 | continue;
|
---|
[940] | 621 | }
|
---|
[686] | 622 | }
|
---|
[6812] | 623 |
|
---|
[3305] | 624 | // Check observations coming twice (e.g. KOUR0 Problem)
|
---|
| 625 | // ----------------------------------------------------
|
---|
[3535] | 626 | if (!_rawFile) {
|
---|
[8011] | 627 | QString prn(obs._prn.toString().c_str());
|
---|
[8417] | 628 | bncTime obsTime = obs._time;
|
---|
| 629 | QMap<QString, bncTime>::const_iterator it = _prnLastEpo.find(prn);
|
---|
[3535] | 630 | if (it != _prnLastEpo.end()) {
|
---|
[8417] | 631 | bncTime oldTime = it.value();
|
---|
[8082] | 632 | if (obsTime < oldTime) {
|
---|
[8417] | 633 | emit(newMessage(_staID + ": old observation " + prn.toLatin1(), false));
|
---|
[3535] | 634 | continue;
|
---|
[8082] | 635 | } else if (obsTime == oldTime) {
|
---|
[8417] | 636 | emit(newMessage(_staID + ": observation coming more than once "
|
---|
| 637 | + prn.toLatin1(), false));
|
---|
[3535] | 638 | continue;
|
---|
| 639 | }
|
---|
[3302] | 640 | }
|
---|
[3535] | 641 | _prnLastEpo[prn] = obsTime;
|
---|
[3301] | 642 | }
|
---|
| 643 |
|
---|
[3528] | 644 | decoder()->dumpRinexEpoch(obs, _format);
|
---|
| 645 |
|
---|
[5524] | 646 | // Save observations
|
---|
| 647 | // -----------------
|
---|
| 648 | obsListHlp.append(obs);
|
---|
| 649 | }
|
---|
[2030] | 650 |
|
---|
[5524] | 651 | // Emit signal
|
---|
| 652 | // -----------
|
---|
| 653 | if (!_isToBeDeleted && obsListHlp.size() > 0) {
|
---|
| 654 | emit newObs(_staID, obsListHlp);
|
---|
[249] | 655 | }
|
---|
[5524] | 656 |
|
---|
[8082] | 657 | } catch (Exception& exc) {
|
---|
[3311] | 658 | emit(newMessage(_staID + " " + exc.what(), true));
|
---|
| 659 | _isToBeDeleted = true;
|
---|
[8082] | 660 | } catch (...) {
|
---|
[3311] | 661 | emit(newMessage(_staID + " bncGetThread exception", true));
|
---|
[1559] | 662 | _isToBeDeleted = true;
|
---|
[1555] | 663 | }
|
---|
[35] | 664 | }
|
---|
| 665 | }
|
---|
| 666 |
|
---|
[7486] | 667 | // Try Re-Connect
|
---|
[136] | 668 | ////////////////////////////////////////////////////////////////////////////
|
---|
[1555] | 669 | t_irc bncGetThread::tryReconnect() {
|
---|
| 670 |
|
---|
| 671 | // Easy Return
|
---|
| 672 | // -----------
|
---|
| 673 | if (_query && _query->status() == bncNetQuery::running) {
|
---|
| 674 | _nextSleep = 0;
|
---|
[3560] | 675 | if (_rawFile) {
|
---|
| 676 | QMapIterator<QString, GPSDecoder*> itDec(_decodersRaw);
|
---|
| 677 | while (itDec.hasNext()) {
|
---|
| 678 | itDec.next();
|
---|
| 679 | GPSDecoder* decoder = itDec.value();
|
---|
| 680 | decoder->setRinexReconnectFlag(false);
|
---|
| 681 | }
|
---|
[8082] | 682 | } else {
|
---|
[3560] | 683 | _decoder->setRinexReconnectFlag(false);
|
---|
| 684 | }
|
---|
[1555] | 685 | return success;
|
---|
[408] | 686 | }
|
---|
[1555] | 687 |
|
---|
| 688 | // Start a new query
|
---|
| 689 | // -----------------
|
---|
[2519] | 690 | if (!_rawFile) {
|
---|
[1555] | 691 |
|
---|
[138] | 692 | sleep(_nextSleep);
|
---|
[1555] | 693 | if (_nextSleep == 0) {
|
---|
| 694 | _nextSleep = 1;
|
---|
[8082] | 695 | } else {
|
---|
[1555] | 696 | _nextSleep = 2 * _nextSleep;
|
---|
[442] | 697 | if (_nextSleep > 256) {
|
---|
| 698 | _nextSleep = 256;
|
---|
[152] | 699 | }
|
---|
[1816] | 700 | #ifdef MLS_SOFTWARE
|
---|
[1817] | 701 | if (_nextSleep > 4) {
|
---|
| 702 | _nextSleep = 4;
|
---|
[1816] | 703 | }
|
---|
| 704 | #endif
|
---|
[138] | 705 | }
|
---|
[8123] | 706 | delete _query;
|
---|
[8082] | 707 | if (_ntripVersion == "U") {
|
---|
[1721] | 708 | _query = new bncNetQueryUdp();
|
---|
[8082] | 709 | } else if (_ntripVersion == "R") {
|
---|
[1555] | 710 | _query = new bncNetQueryRtp();
|
---|
[8082] | 711 | } else if (_ntripVersion == "S") {
|
---|
[1753] | 712 | _query = new bncNetQueryS();
|
---|
[8082] | 713 | } else if (_ntripVersion == "N") {
|
---|
[1621] | 714 | _query = new bncNetQueryV0();
|
---|
[8082] | 715 | } else if (_ntripVersion == "UN") {
|
---|
[1779] | 716 | _query = new bncNetQueryUdp0();
|
---|
[8082] | 717 | } else if (_ntripVersion == "2") {
|
---|
[3337] | 718 | _query = new bncNetQueryV2(false);
|
---|
[8082] | 719 | } else if (_ntripVersion == "2s") {
|
---|
[3337] | 720 | _query = new bncNetQueryV2(true);
|
---|
[8082] | 721 | } else {
|
---|
[1555] | 722 | _query = new bncNetQueryV1();
|
---|
| 723 | }
|
---|
[6770] | 724 | if (_nmea == "yes") {
|
---|
| 725 | if (_serialNMEA == MANUAL_NMEA) {
|
---|
| 726 | _query->startRequest(_mountPoint, _manualNMEAString);
|
---|
| 727 | _lastManualNMEA = QDateTime::currentDateTime();
|
---|
[8082] | 728 | } else if (_serialNMEA == AUTO_NMEA) {
|
---|
[6770] | 729 | if (_serialPort) {
|
---|
| 730 | int nb = _serialPort->bytesAvailable();
|
---|
| 731 | if (nb > 0) {
|
---|
| 732 | QByteArray data = _serialPort->read(nb);
|
---|
| 733 | int i1 = data.indexOf("$GPGGA");
|
---|
| 734 | if (i1 == -1) {
|
---|
| 735 | i1 = data.indexOf("$GNGGA");
|
---|
| 736 | }
|
---|
| 737 | if (i1 != -1) {
|
---|
| 738 | int i2 = data.indexOf("*", i1);
|
---|
| 739 | if (i2 != -1 && data.size() > i2 + 1) {
|
---|
| 740 | QByteArray gga = data.mid(i1, i2 - i1 + 3);
|
---|
| 741 | _query->startRequest(_mountPoint, gga);
|
---|
| 742 | }
|
---|
| 743 | }
|
---|
| 744 | }
|
---|
| 745 | }
|
---|
| 746 | }
|
---|
[8082] | 747 | } else {
|
---|
[1555] | 748 | _query->startRequest(_mountPoint, "");
|
---|
| 749 | }
|
---|
[6770] | 750 |
|
---|
[1555] | 751 | if (_query->status() != bncNetQuery::running) {
|
---|
| 752 | return failure;
|
---|
| 753 | }
|
---|
[138] | 754 | }
|
---|
[658] | 755 |
|
---|
[3560] | 756 | if (_rawFile) {
|
---|
| 757 | QMapIterator<QString, GPSDecoder*> itDec(_decodersRaw);
|
---|
| 758 | while (itDec.hasNext()) {
|
---|
| 759 | itDec.next();
|
---|
| 760 | GPSDecoder* decoder = itDec.value();
|
---|
| 761 | decoder->setRinexReconnectFlag(false);
|
---|
| 762 | }
|
---|
[8082] | 763 | } else {
|
---|
| 764 | _decoder->setRinexReconnectFlag(false);
|
---|
[658] | 765 | }
|
---|
[1555] | 766 |
|
---|
| 767 | return success;
|
---|
[658] | 768 | }
|
---|
[1044] | 769 |
|
---|
[1555] | 770 | // RTCM scan output
|
---|
[1044] | 771 | //////////////////////////////////////////////////////////////////////////////
|
---|
[7423] | 772 | void bncGetThread::miscScanRTCM() {
|
---|
[1044] | 773 |
|
---|
[8082] | 774 | if (!decoder()) {
|
---|
[3558] | 775 | return;
|
---|
| 776 | }
|
---|
| 777 |
|
---|
[1555] | 778 | bncSettings settings;
|
---|
[8082] | 779 | if (Qt::CheckState(settings.value("miscScanRTCM").toInt()) == Qt::Checked) {
|
---|
[1574] | 780 |
|
---|
[8082] | 781 | if (_miscMount == _staID || _miscMount == "ALL") {
|
---|
[1575] | 782 | // RTCM message types
|
---|
| 783 | // ------------------
|
---|
[4476] | 784 | for (int ii = 0; ii < decoder()->_typeList.size(); ii++) {
|
---|
[8082] | 785 | QString type = QString("%1 ").arg(decoder()->_typeList[ii]);
|
---|
[8127] | 786 | emit(newMessage(_staID + ": Received message type " + type.toLatin1(),
|
---|
[8082] | 787 | true));
|
---|
[1574] | 788 | }
|
---|
[7486] | 789 |
|
---|
[4476] | 790 | // Check Observation Types
|
---|
| 791 | // -----------------------
|
---|
| 792 | for (int ii = 0; ii < decoder()->_obsList.size(); ii++) {
|
---|
[6137] | 793 | t_satObs& obs = decoder()->_obsList[ii];
|
---|
| 794 | QVector<QString>& rnxTypes = _rnxTypes[obs._prn.system()];
|
---|
[4476] | 795 | bool allFound = true;
|
---|
[6137] | 796 | for (unsigned iFrq = 0; iFrq < obs._obs.size(); iFrq++) {
|
---|
[6579] | 797 | if (obs._obs[iFrq]->_codeValid) {
|
---|
| 798 | QString rnxStr('C');
|
---|
| 799 | rnxStr.append(obs._obs[iFrq]->_rnxType2ch.c_str());
|
---|
[8082] | 800 | if (_format.indexOf("RTCM_2") != -1
|
---|
| 801 | || _format.indexOf("RTCM2") != -1
|
---|
| 802 | || _format.indexOf("RTCM 2") != -1) {
|
---|
[6580] | 803 | rnxStr = t_rnxObsFile::type3to2(obs._prn.system(), rnxStr);
|
---|
| 804 | }
|
---|
[6579] | 805 | if (rnxTypes.indexOf(rnxStr) == -1) {
|
---|
| 806 | rnxTypes.push_back(rnxStr);
|
---|
| 807 | allFound = false;
|
---|
| 808 | }
|
---|
[4476] | 809 | }
|
---|
[6579] | 810 | if (obs._obs[iFrq]->_phaseValid) {
|
---|
| 811 | QString rnxStr('L');
|
---|
| 812 | rnxStr.append(obs._obs[iFrq]->_rnxType2ch.c_str());
|
---|
[8082] | 813 | if (_format.indexOf("RTCM_2") != -1
|
---|
| 814 | || _format.indexOf("RTCM2") != -1
|
---|
| 815 | || _format.indexOf("RTCM 2") != -1) {
|
---|
[6580] | 816 | rnxStr = t_rnxObsFile::type3to2(obs._prn.system(), rnxStr);
|
---|
| 817 | }
|
---|
[6579] | 818 | if (rnxTypes.indexOf(rnxStr) == -1) {
|
---|
| 819 | rnxTypes.push_back(rnxStr);
|
---|
| 820 | allFound = false;
|
---|
| 821 | }
|
---|
| 822 | }
|
---|
[8082] | 823 | if (obs._obs[iFrq]->_dopplerValid) {
|
---|
[6579] | 824 | QString rnxStr('D');
|
---|
| 825 | rnxStr.append(obs._obs[iFrq]->_rnxType2ch.c_str());
|
---|
[8082] | 826 | if (_format.indexOf("RTCM_2") != -1
|
---|
| 827 | || _format.indexOf("RTCM2") != -1
|
---|
| 828 | || _format.indexOf("RTCM 2") != -1) {
|
---|
[6580] | 829 | rnxStr = t_rnxObsFile::type3to2(obs._prn.system(), rnxStr);
|
---|
| 830 | }
|
---|
[6579] | 831 | if (rnxTypes.indexOf(rnxStr) == -1) {
|
---|
| 832 | rnxTypes.push_back(rnxStr);
|
---|
| 833 | allFound = false;
|
---|
| 834 | }
|
---|
| 835 | }
|
---|
[8082] | 836 | if (obs._obs[iFrq]->_snrValid) {
|
---|
[6579] | 837 | QString rnxStr('S');
|
---|
| 838 | rnxStr.append(obs._obs[iFrq]->_rnxType2ch.c_str());
|
---|
[8082] | 839 | if (_format.indexOf("RTCM_2") != -1
|
---|
| 840 | || _format.indexOf("RTCM2") != -1
|
---|
| 841 | || _format.indexOf("RTCM 2") != -1) {
|
---|
[6580] | 842 | rnxStr = t_rnxObsFile::type3to2(obs._prn.system(), rnxStr);
|
---|
| 843 | }
|
---|
[6579] | 844 | if (rnxTypes.indexOf(rnxStr) == -1) {
|
---|
| 845 | rnxTypes.push_back(rnxStr);
|
---|
| 846 | allFound = false;
|
---|
| 847 | }
|
---|
| 848 | }
|
---|
[4476] | 849 | }
|
---|
| 850 | if (!allFound) {
|
---|
[7486] | 851 | QString msg;
|
---|
[4477] | 852 | QTextStream str(&msg);
|
---|
[6579] | 853 | QString s;
|
---|
[8082] | 854 | str << obs._prn.system() << " "
|
---|
| 855 | << s.sprintf("%2d", rnxTypes.size()) << " ";
|
---|
[4476] | 856 | for (int iType = 0; iType < rnxTypes.size(); iType++) {
|
---|
[4478] | 857 | str << " " << rnxTypes[iType];
|
---|
[4476] | 858 | }
|
---|
[8127] | 859 | emit(newMessage(_staID + ": Observation Types: " + msg.toLatin1(),
|
---|
[8082] | 860 | true));
|
---|
[4476] | 861 | }
|
---|
| 862 | }
|
---|
| 863 |
|
---|
[1574] | 864 | // RTCMv3 antenna descriptor
|
---|
| 865 | // -------------------------
|
---|
[4476] | 866 | for (int ii = 0; ii < decoder()->_antType.size(); ii++) {
|
---|
[8236] | 867 | QString ant1 = QString(": Antenna Descriptor: %1 ").arg(decoder()->_antType[ii].descriptor);
|
---|
| 868 | emit(newMessage(_staID + ant1.toLatin1(), true));
|
---|
| 869 | if (strlen(decoder()->_antType[ii].serialnumber)) {
|
---|
| 870 | QString ant2 = QString(": Antenna Serial Number: %1 ").arg(decoder()->_antType[ii].serialnumber);
|
---|
| 871 | emit(newMessage(_staID + ant2.toLatin1(), true));
|
---|
| 872 | }
|
---|
[1574] | 873 | }
|
---|
[1555] | 874 |
|
---|
[1575] | 875 | // RTCM Antenna Coordinates
|
---|
| 876 | // ------------------------
|
---|
[8082] | 877 | for (int ii = 0; ii < decoder()->_antList.size(); ii++) {
|
---|
[1574] | 878 | QByteArray antT;
|
---|
[8236] | 879 | if (decoder()->_antList[ii].type == GPSDecoder::t_antRefPoint::ARP) {
|
---|
[1574] | 880 | antT = "ARP";
|
---|
[8236] | 881 | } else if (decoder()->_antList[ii].type == GPSDecoder::t_antRefPoint::APC) {
|
---|
[1574] | 882 | antT = "APC";
|
---|
| 883 | }
|
---|
[1575] | 884 | QByteArray ant1, ant2, ant3;
|
---|
[8236] | 885 | ant1 = QString("%1 ").arg(decoder()->_antList[ii].xx, 0, 'f', 4).toLatin1();
|
---|
| 886 | ant2 = QString("%1 ").arg(decoder()->_antList[ii].yy, 0, 'f', 4).toLatin1();
|
---|
| 887 | ant3 = QString("%1 ").arg(decoder()->_antList[ii].zz, 0, 'f', 4).toLatin1();
|
---|
[1575] | 888 | emit(newMessage(_staID + ": " + antT + " (ITRF) X " + ant1 + "m", true));
|
---|
| 889 | emit(newMessage(_staID + ": " + antT + " (ITRF) Y " + ant2 + "m", true));
|
---|
| 890 | emit(newMessage(_staID + ": " + antT + " (ITRF) Z " + ant3 + "m", true));
|
---|
[3595] | 891 | double hh = 0.0;
|
---|
[3523] | 892 | if (decoder()->_antList[ii].height_f) {
|
---|
[3595] | 893 | hh = decoder()->_antList[ii].height;
|
---|
[8127] | 894 | QByteArray ant4 = QString("%1 ").arg(hh, 0, 'f', 4).toLatin1();
|
---|
[8082] | 895 | emit(newMessage(
|
---|
| 896 | _staID + ": Antenna height above marker " + ant4 + "m", true));
|
---|
[1575] | 897 | }
|
---|
[7486] | 898 | emit(newAntCrd(_staID, decoder()->_antList[ii].xx,
|
---|
[8082] | 899 | decoder()->_antList[ii].yy, decoder()->_antList[ii].zz, hh, antT));
|
---|
[1218] | 900 | }
|
---|
[6864] | 901 |
|
---|
[8197] | 902 | // RTCMv3 receiver descriptor
|
---|
| 903 | // --------------------------
|
---|
| 904 | for (int ii = 0; ii < decoder()->_recType.size(); ii++) {
|
---|
[8236] | 905 | QString rec1 = QString(": Receiver Descriptor: %1 ").arg(decoder()->_recType[ii].descriptor);
|
---|
| 906 | QString rec2 = QString(": Receiver Firmware Version: %1 ").arg(decoder()->_recType[ii].firmware);
|
---|
| 907 | QString rec3 = QString(": Receiver Serial Number: %1 ").arg(decoder()->_recType[ii].serialnumber);
|
---|
| 908 | emit(newMessage(_staID + rec1.toLatin1(), true));
|
---|
| 909 | emit(newMessage(_staID + rec2.toLatin1(), true));
|
---|
| 910 | emit(newMessage(_staID + rec3.toLatin1(), true));
|
---|
[8197] | 911 | }
|
---|
| 912 |
|
---|
[6864] | 913 | // RTCM GLONASS slots
|
---|
| 914 | // ------------------
|
---|
| 915 | if (decoder()->_gloFrq.size()) {
|
---|
| 916 | bool allFound = true;
|
---|
| 917 | QString slot = decoder()->_gloFrq;
|
---|
[8082] | 918 | slot.replace(" ", " ").replace(" ", ":");
|
---|
[6864] | 919 | if (_gloSlots.indexOf(slot) == -1) {
|
---|
| 920 | _gloSlots.append(slot);
|
---|
| 921 | allFound = false;
|
---|
| 922 | }
|
---|
| 923 | if (!allFound) {
|
---|
| 924 | _gloSlots.sort();
|
---|
[8082] | 925 | emit(newMessage(
|
---|
[8127] | 926 | _staID + ": GLONASS Slot:Freq " + _gloSlots.join(" ").toLatin1(),
|
---|
[8082] | 927 | true));
|
---|
[6864] | 928 | }
|
---|
| 929 | }
|
---|
[1218] | 930 | }
|
---|
[1044] | 931 | }
|
---|
[1575] | 932 |
|
---|
[1770] | 933 | #ifdef MLS_SOFTWARE
|
---|
[3523] | 934 | for (int ii=0; ii <decoder()->_antList.size(); ii++) {
|
---|
[8082] | 935 | QByteArray antT;
|
---|
| 936 | if (decoder()->_antList[ii].type == GPSDecoder::t_antInfo::ARP) {
|
---|
| 937 | antT = "ARP";
|
---|
| 938 | }
|
---|
| 939 | else if (decoder()->_antList[ii].type == GPSDecoder::t_antInfo::APC) {
|
---|
| 940 | antT = "APC";
|
---|
| 941 | }
|
---|
| 942 | double hh = 0.0;
|
---|
| 943 | if (decoder()->_antList[ii].height_f) {
|
---|
| 944 | hh = decoder()->_antList[ii].height;
|
---|
| 945 | }
|
---|
| 946 | emit(newAntCrd(_staID, decoder()->_antList[ii].xx,
|
---|
| 947 | decoder()->_antList[ii].yy, decoder()->_antList[ii].zz,
|
---|
| 948 | hh, antT));
|
---|
[1770] | 949 | }
|
---|
[2356] | 950 |
|
---|
[3523] | 951 | for (int ii = 0; ii <decoder()->_typeList.size(); ii++) {
|
---|
| 952 | emit(newRTCMMessage(_staID, decoder()->_typeList[ii]));
|
---|
[2356] | 953 | }
|
---|
[1770] | 954 | #endif
|
---|
| 955 |
|
---|
[6864] | 956 | decoder()->_gloFrq.clear();
|
---|
[3523] | 957 | decoder()->_typeList.clear();
|
---|
| 958 | decoder()->_antType.clear();
|
---|
[8197] | 959 | decoder()->_recType.clear();
|
---|
[3523] | 960 | decoder()->_antList.clear();
|
---|
[1044] | 961 | }
|
---|
[1555] | 962 |
|
---|
[1606] | 963 | // Handle Data from Serial Port
|
---|
| 964 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 965 | void bncGetThread::slotSerialReadyRead() {
|
---|
[6770] | 966 |
|
---|
[1607] | 967 | if (_serialPort) {
|
---|
[6770] | 968 |
|
---|
[6773] | 969 | if (_nmea == "yes" && _serialNMEA == MANUAL_NMEA) {
|
---|
| 970 | if (_manualNMEASampl) {
|
---|
| 971 | int dt = _lastManualNMEA.secsTo(QDateTime::currentDateTime());
|
---|
| 972 | if (dt && (fmod(double(dt), double(_manualNMEASampl)) == 0.0)) {
|
---|
| 973 | _query->sendNMEA(_manualNMEAString);
|
---|
| 974 | _lastManualNMEA = QDateTime::currentDateTime();
|
---|
| 975 | }
|
---|
| 976 | }
|
---|
| 977 | }
|
---|
| 978 |
|
---|
[1633] | 979 | int nb = _serialPort->bytesAvailable();
|
---|
| 980 | if (nb > 0) {
|
---|
| 981 | QByteArray data = _serialPort->read(nb);
|
---|
[1711] | 982 |
|
---|
[6695] | 983 | if (_nmea == "yes" && _serialNMEA == AUTO_NMEA) {
|
---|
[1725] | 984 | int i1 = data.indexOf("$GPGGA");
|
---|
[6651] | 985 | if (i1 == -1) {
|
---|
| 986 | i1 = data.indexOf("$GNGGA");
|
---|
| 987 | }
|
---|
[1725] | 988 | if (i1 != -1) {
|
---|
[6751] | 989 | int i2 = data.indexOf("*", i1);
|
---|
[1725] | 990 | if (i2 != -1 && data.size() > i2 + 1) {
|
---|
[6751] | 991 | QByteArray gga = data.mid(i1, i2 - i1 + 3);
|
---|
[1725] | 992 | _query->sendNMEA(gga);
|
---|
[6751] | 993 | }
|
---|
| 994 | }
|
---|
[1711] | 995 | }
|
---|
| 996 |
|
---|
[1633] | 997 | if (_serialOutFile) {
|
---|
| 998 | _serialOutFile->write(data);
|
---|
| 999 | _serialOutFile->flush();
|
---|
| 1000 | }
|
---|
[1607] | 1001 | }
|
---|
| 1002 | }
|
---|
[1606] | 1003 | }
|
---|
[7180] | 1004 |
|
---|
| 1005 | void bncGetThread::slotNewNMEAConnection() {
|
---|
| 1006 | _nmeaSockets->push_back(_nmeaServer->nextPendingConnection());
|
---|
[8082] | 1007 | emit(newMessage(
|
---|
[8127] | 1008 | QString("New PPP client on port: # %1").arg(_nmeaSockets->size()).toLatin1(),
|
---|
[8082] | 1009 | true));
|
---|
[7180] | 1010 | }
|
---|
| 1011 |
|
---|
| 1012 | //
|
---|
| 1013 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 1014 | void bncGetThread::slotNewNMEAstr(QByteArray staID, QByteArray str) {
|
---|
| 1015 | if (_nmeaPortsMap.contains(staID)) {
|
---|
| 1016 | int nmeaPort = _nmeaPortsMap.value(staID);
|
---|
| 1017 | QMutableListIterator<QTcpSocket*> is(*_nmeaSockets);
|
---|
| 1018 | while (is.hasNext()) {
|
---|
| 1019 | QTcpSocket* sock = is.next();
|
---|
| 1020 | if (sock->localPort() == nmeaPort) {
|
---|
| 1021 | if (sock->state() == QAbstractSocket::ConnectedState) {
|
---|
| 1022 | sock->write(str);
|
---|
[8082] | 1023 | } else if (sock->state() != QAbstractSocket::ConnectingState) {
|
---|
[7180] | 1024 | delete sock;
|
---|
| 1025 | is.remove();
|
---|
| 1026 | }
|
---|
| 1027 | }
|
---|
| 1028 | }
|
---|
| 1029 | }
|
---|
| 1030 | }
|
---|