source: ntrip/trunk/BNC/src/bncgetthread.cpp@ 10696

Last change on this file since 10696 was 10696, checked in by stuerze, 5 weeks ago

bind all outPorts to localHost

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