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