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