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

Last change on this file since 10936 was 10936, checked in by stuerze, 2 months ago

minor changes

File size: 37.3 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"
[10776]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);
[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//////////////////////////////////////////////////////////////////////////////
322t_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////////////////////////////////////////////////////////////////////////////
370GPSDecoder* 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////////////////////////////////////////////////////////////////////////////
383bncGetThread::~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;
[10936]405 delete _nmeaServer;
406 delete _nmeaSockets;
[1556]407 emit getThreadFinished(_staID);
[35]408}
409
[7486]410//
[1390]411////////////////////////////////////////////////////////////////////////////
412void bncGetThread::terminate() {
[1525]413 _isToBeDeleted = true;
[7854]414
[8082]415 if (_nmeaPortsMap.contains(_staID)) {
[7854]416 _nmeaPortsMap.remove(_staID);
[1559]417 }
[10936]418 delete _nmeaServer; _nmeaServer = nullptr;
419 delete _nmeaSockets; _nmeaSockets = nullptr;
[7858]420
[9688]421#ifdef BNC_DEBUG
[7859]422 if (BNC_CORE->mode() != t_bncCore::interactive) {
[8082]423 while (!isFinished()) {
424 wait();
425 }
[7859]426 delete this;
[8082]427 } else {
428 if (!isRunning()) {
429 delete this;
430 }
[7858]431 }
[9688]432#else
433 if (!isRunning()) {delete this;}
434#endif
[7858]435
[1390]436}
437
[136]438// Run
439////////////////////////////////////////////////////////////////////////////
440void bncGetThread::run() {
441
[35]442 while (true) {
[629]443 try {
[1555]444 if (_isToBeDeleted) {
[9852]445 emit(newMessage(_staID + ": is to be deleted", true));
[9854]446 QThread::exit(4);
[1555]447 this->deleteLater();
448 return;
[629]449 }
[621]450
[1555]451 if (tryReconnect() != success) {
[3532]452 if (_latencyChecker) {
453 _latencyChecker->checkReconnect();
454 }
[1555]455 continue;
[621]456 }
[1555]457
458 // Delete old observations
459 // -----------------------
[3560]460 if (_rawFile) {
461 QMapIterator<QString, GPSDecoder*> itDec(_decodersRaw);
462 while (itDec.hasNext()) {
463 itDec.next();
464 GPSDecoder* decoder = itDec.value();
465 decoder->_obsList.clear();
466 }
[8082]467 } else {
[3560]468 _decoder->_obsList.clear();
469 }
[621]470
[1555]471 // Read Data
472 // ---------
[1377]473 QByteArray data;
[8082]474 if (_query) {
[1377]475 _query->waitForReadyRead(data);
[8082]476 } else if (_rawFile) {
[2527]477 data = _rawFile->readChunk();
[3523]478 _format = _rawFile->format();
[8082]479 _staID = _rawFile->staID();
[2388]480
[5903]481 QCoreApplication::processEvents();
482
[7976]483 if (data.isEmpty() || BNC_CORE->sigintReceived) {
[10470]484 emit(newMessage("No more data or SIGINT/SIGTERM received", true));
[10221]485 BNC_CORE->stopPPP();
[5068]486 BNC_CORE->stopCombination();
[9191]487 sleep(2);
[9854]488 ::exit(5);
[1555]489 }
[1138]490 }
[8123]491
[1555]492 qint64 nBytes = data.size();
[1138]493
[1555]494 // Timeout, reconnect
495 // ------------------
496 if (nBytes == 0) {
[3532]497 if (_latencyChecker) {
498 _latencyChecker->checkReconnect();
499 }
[1555]500 emit(newMessage(_staID + ": Data timeout, reconnecting", true));
[2355]501 msleep(10000); //sleep 10 sec, G. Weber
[1555]502 continue;
[8082]503 } else {
[567]504 emit newBytes(_staID, nBytes);
[5648]505 emit newRawData(_staID, data);
[1555]506 }
[567]507
[1555]508 // Output Data
509 // -----------
[2386]510 if (_rawOutput) {
[7486]511 BNC_CORE->writeRawData(data, _staID, _format);
[2386]512 }
[2385]513
[1555]514 if (_serialPort) {
[1633]515 slotSerialReadyRead();
[1555]516 _serialPort->write(data);
517 }
[7486]518
[1555]519 // Decode Data
520 // -----------
521 vector<string> errmsg;
[3526]522 if (!decoder()) {
523 _isToBeDeleted = true;
524 continue;
525 }
[7753]526
[3523]527 t_irc irc = decoder()->Decode(data.data(), data.size(), errmsg);
[1137]528
[7753]529 if (irc != success) {
530 continue;
531 }
[1555]532 // Perform various scans and checks
533 // --------------------------------
[3532]534 if (_latencyChecker) {
[8271]535 _latencyChecker->checkOutage(irc);
[10688]536 QListIterator<GPSDecoder::t_typeInfo> it(decoder()->_typeList);
[8271]537 _ssrEpoch = static_cast<int>(decoder()->corrGPSEpochTime());
[8730]538 if (_ssrEpoch != -1) {
[9124]539 if (_rtcmSsrOrb) {
[8730]540 _latencyChecker->checkCorrLatency(_ssrEpoch, 1057);
[9124]541 _rtcmSsrOrb = false;
[8082]542 }
[9124]543 if (_rtcmSsrClk) {
[8730]544 _latencyChecker->checkCorrLatency(_ssrEpoch, 1058);
[9124]545 _rtcmSsrClk = false;
[8082]546 }
[9124]547 if (_rtcmSsrOrbClk) {
[8730]548 _latencyChecker->checkCorrLatency(_ssrEpoch, 1060);
[9124]549 _rtcmSsrOrbClk = false;
[8082]550 }
[9124]551 if (_rtcmSsrCbi) {
[8730]552 _latencyChecker->checkCorrLatency(_ssrEpoch, 1059);
[9124]553 _rtcmSsrCbi = false;
[8082]554 }
[9124]555 if (_rtcmSsrPbi) {
[8730]556 _latencyChecker->checkCorrLatency(_ssrEpoch, 1265);
[9124]557 _rtcmSsrPbi = false;
[8082]558 }
[9124]559 if (_rtcmSsrVtec) {
[8730]560 _latencyChecker->checkCorrLatency(_ssrEpoch, 1264);
[9124]561 _rtcmSsrVtec = false;
[8082]562 }
[9124]563 if (_rtcmSsrUra) {
[8730]564 _latencyChecker->checkCorrLatency(_ssrEpoch, 1061);
[9124]565 _rtcmSsrUra = false;
[8082]566 }
[9124]567 if (_rtcmSsrHr) {
[8730]568 _latencyChecker->checkCorrLatency(_ssrEpoch, 1062);
[9124]569 _rtcmSsrHr = false;
[8082]570 }
[9124]571 if (_rtcmSsrIgs) {
572 _latencyChecker->checkCorrLatency(_ssrEpoch, 4076);
573 _rtcmSsrIgs = false;
574 }
[8082]575 }
576 while (it.hasNext()) {
[10692]577 int rtcmType = it.next()._type;
[8082]578 if ((rtcmType >= 1001 && rtcmType <= 1004) || // legacy RTCM OBS
579 (rtcmType >= 1009 && rtcmType <= 1012) || // legacy RTCM OBS
[9285]580 (rtcmType >= 1070 && rtcmType <= 1137)) { // MSM RTCM OBS
[9124]581 _rtcmObs = true;
[8082]582 } else if ((rtcmType >= 1057 && rtcmType <= 1068) ||
[9124]583 (rtcmType >= 1240 && rtcmType <= 1270) ||
[10533]584 (rtcmType == 4076)) {
[8082]585 switch (rtcmType) {
586 case 1057: case 1063: case 1240: case 1246: case 1252: case 1258:
[9124]587 _rtcmSsrOrb = true;
[8082]588 break;
589 case 1058: case 1064: case 1241: case 1247: case 1253: case 1259:
[9124]590 _rtcmSsrClk = true;
[8082]591 break;
592 case 1060: case 1066: case 1243: case 1249: case 1255: case 1261:
[9124]593 _rtcmSsrOrbClk = true;
[8082]594 break;
[9017]595 case 1059: case 1065: case 1242: case 1248: case 1254: case 1260:
[9124]596 _rtcmSsrCbi = true;
[8082]597 break;
598 case 1265: case 1266: case 1267: case 1268: case 1269: case 1270:
[9124]599 _rtcmSsrPbi = true;
[8082]600 break;
601 case 1264:
[9124]602 _rtcmSsrVtec = true;
[8082]603 break;
604 case 1061: case 1067: case 1244: case 1250: case 1256: case 1262:
[9124]605 _rtcmSsrUra = true;
[8082]606 break;
607 case 1062: case 1068: case 1245: case 1251: case 1257: case 1263:
[9124]608 _rtcmSsrHr = true;
[8082]609 break;
[9124]610 case 4076:
611 _rtcmSsrIgs = true;
612 break;
[8082]613 }
614 }
615 }
[9124]616 if (_rtcmObs) {
[8082]617 _latencyChecker->checkObsLatency(decoder()->_obsList);
618 }
[3532]619 emit newLatency(_staID, _latencyChecker->currentLatency());
620 }
[7753]621 miscScanRTCM();
[1138]622
[1555]623 // Loop over all observations (observations output)
624 // ------------------------------------------------
[6137]625 QListIterator<t_satObs> it(decoder()->_obsList);
[5524]626
[6137]627 QList<t_satObs> obsListHlp;
[5524]628
[1555]629 while (it.hasNext()) {
[6137]630 const t_satObs& obs = it.next();
[2711]631
[1555]632 // Check observation epoch
633 // -----------------------
[5739]634 if (!_rawFile) {
[8011]635 bool wrongObservationEpoch = checkForWrongObsEpoch(obs._time);
636 if (wrongObservationEpoch) {
[8021]637 QString prn(obs._prn.toString().c_str());
[9544]638 QString type = QString("%1").arg(obs._type);
639 emit(newMessage(_staID + " (" + prn.toLatin1() + ")" + ": Wrong observation epoch(s)" + "( MT: " + type.toLatin1() + ")", false));
[1555]640 continue;
[940]641 }
[686]642 }
[6812]643
[3305]644 // Check observations coming twice (e.g. KOUR0 Problem)
645 // ----------------------------------------------------
[3535]646 if (!_rawFile) {
[8011]647 QString prn(obs._prn.toString().c_str());
[8417]648 bncTime obsTime = obs._time;
649 QMap<QString, bncTime>::const_iterator it = _prnLastEpo.find(prn);
[3535]650 if (it != _prnLastEpo.end()) {
[8417]651 bncTime oldTime = it.value();
[8082]652 if (obsTime < oldTime) {
[8417]653 emit(newMessage(_staID + ": old observation " + prn.toLatin1(), false));
[3535]654 continue;
[8082]655 } else if (obsTime == oldTime) {
[9131]656 emit(newMessage(_staID + ": observation coming more than once " + prn.toLatin1(), false));
[3535]657 continue;
658 }
[3302]659 }
[3535]660 _prnLastEpo[prn] = obsTime;
[3301]661 }
662
[3528]663 decoder()->dumpRinexEpoch(obs, _format);
664
[5524]665 // Save observations
666 // -----------------
667 obsListHlp.append(obs);
668 }
[2030]669
[5524]670 // Emit signal
671 // -----------
672 if (!_isToBeDeleted && obsListHlp.size() > 0) {
673 emit newObs(_staID, obsListHlp);
[249]674 }
[5524]675
[10571]676 }
677 catch (Exception& exc) {
[3311]678 emit(newMessage(_staID + " " + exc.what(), true));
679 _isToBeDeleted = true;
[10571]680 }
681 catch (std::exception& exc) {
682 emit(newMessage(_staID + " " + exc.what(), true));
[1559]683 _isToBeDeleted = true;
[1555]684 }
[10571]685 catch (const string& error) {
686 emit(newMessage(_staID + " ERROR: " + error.c_str(), true));
687 _isToBeDeleted = true;
688 }
689 catch (const char* error) {
690 emit(newMessage(_staID + " ERROR: " + error, true));
691 _isToBeDeleted = true;
692 }
693 catch (QString error) {
694 emit(newMessage(_staID + " ERROR: " + error.toStdString().c_str(), true));
695 _isToBeDeleted = true;
696 }
697 catch (...) {
698 emit(newMessage(_staID + " bncGetThread: unknown exception", true));
699 _isToBeDeleted = true;
700 }
[35]701 }
702}
703
[7486]704// Try Re-Connect
[136]705////////////////////////////////////////////////////////////////////////////
[1555]706t_irc bncGetThread::tryReconnect() {
707
708 // Easy Return
709 // -----------
710 if (_query && _query->status() == bncNetQuery::running) {
711 _nextSleep = 0;
[3560]712 if (_rawFile) {
713 QMapIterator<QString, GPSDecoder*> itDec(_decodersRaw);
714 while (itDec.hasNext()) {
715 itDec.next();
716 GPSDecoder* decoder = itDec.value();
717 decoder->setRinexReconnectFlag(false);
718 }
[8082]719 } else {
[3560]720 _decoder->setRinexReconnectFlag(false);
721 }
[1555]722 return success;
[408]723 }
[1555]724
725 // Start a new query
726 // -----------------
[2519]727 if (!_rawFile) {
[1555]728
[138]729 sleep(_nextSleep);
[1555]730 if (_nextSleep == 0) {
731 _nextSleep = 1;
[8082]732 } else {
[1555]733 _nextSleep = 2 * _nextSleep;
[442]734 if (_nextSleep > 256) {
735 _nextSleep = 256;
[152]736 }
[1816]737#ifdef MLS_SOFTWARE
[1817]738 if (_nextSleep > 4) {
739 _nextSleep = 4;
[1816]740 }
741#endif
[138]742 }
[8123]743 delete _query;
[8082]744 if (_ntripVersion == "U") {
[1721]745 _query = new bncNetQueryUdp();
[8082]746 } else if (_ntripVersion == "R") {
[1555]747 _query = new bncNetQueryRtp();
[8082]748 } else if (_ntripVersion == "S") {
[1753]749 _query = new bncNetQueryS();
[8082]750 } else if (_ntripVersion == "N") {
[1621]751 _query = new bncNetQueryV0();
[8082]752 } else if (_ntripVersion == "UN") {
[1779]753 _query = new bncNetQueryUdp0();
[8082]754 } else if (_ntripVersion == "2") {
[3337]755 _query = new bncNetQueryV2(false);
[8082]756 } else if (_ntripVersion == "2s") {
[3337]757 _query = new bncNetQueryV2(true);
[8082]758 } else {
[1555]759 _query = new bncNetQueryV1();
760 }
[6770]761 if (_nmea == "yes") {
762 if (_serialNMEA == MANUAL_NMEA) {
763 _query->startRequest(_mountPoint, _manualNMEAString);
[10421]764 _lastNMEA = QDateTime::currentDateTime();
[8082]765 } else if (_serialNMEA == AUTO_NMEA) {
[6770]766 if (_serialPort) {
767 int nb = _serialPort->bytesAvailable();
768 if (nb > 0) {
769 QByteArray data = _serialPort->read(nb);
770 int i1 = data.indexOf("$GPGGA");
771 if (i1 == -1) {
772 i1 = data.indexOf("$GNGGA");
773 }
774 if (i1 != -1) {
775 int i2 = data.indexOf("*", i1);
776 if (i2 != -1 && data.size() > i2 + 1) {
777 QByteArray gga = data.mid(i1, i2 - i1 + 3);
778 _query->startRequest(_mountPoint, gga);
[10421]779 _lastNMEA = QDateTime::currentDateTime();
[6770]780 }
781 }
782 }
783 }
784 }
[8082]785 } else {
[1555]786 _query->startRequest(_mountPoint, "");
787 }
[6770]788
[1555]789 if (_query->status() != bncNetQuery::running) {
790 return failure;
791 }
[138]792 }
[658]793
[3560]794 if (_rawFile) {
795 QMapIterator<QString, GPSDecoder*> itDec(_decodersRaw);
796 while (itDec.hasNext()) {
797 itDec.next();
798 GPSDecoder* decoder = itDec.value();
799 decoder->setRinexReconnectFlag(false);
800 }
[8082]801 } else {
802 _decoder->setRinexReconnectFlag(false);
[658]803 }
[1555]804
805 return success;
[658]806}
[1044]807
[1555]808// RTCM scan output
[1044]809//////////////////////////////////////////////////////////////////////////////
[7423]810void bncGetThread::miscScanRTCM() {
[1044]811
[8082]812 if (!decoder()) {
[3558]813 return;
814 }
815
[1555]816 bncSettings settings;
[8082]817 if (Qt::CheckState(settings.value("miscScanRTCM").toInt()) == Qt::Checked) {
[1574]818
[8082]819 if (_miscMount == _staID || _miscMount == "ALL") {
[1575]820 // RTCM message types
821 // ------------------
[4476]822 for (int ii = 0; ii < decoder()->_typeList.size(); ii++) {
[10692]823 QString type = QString("%1 ").arg(decoder()->_typeList[ii]._type);
824 QString size = (decoder()->_typeList[ii]._size) ? QString("(size %1)").arg(decoder()->_typeList[ii]._size) : "";
[10688]825 emit(newMessage(_staID + ": Received message type " + type.toLatin1() + size.toLatin1(), true));
[1574]826 }
[7486]827
[4476]828 // Check Observation Types
829 // -----------------------
830 for (int ii = 0; ii < decoder()->_obsList.size(); ii++) {
[10221]831 t_satObs& obs = decoder()->_obsList[ii];
[6137]832 QVector<QString>& rnxTypes = _rnxTypes[obs._prn.system()];
[4476]833 bool allFound = true;
[6137]834 for (unsigned iFrq = 0; iFrq < obs._obs.size(); iFrq++) {
[6579]835 if (obs._obs[iFrq]->_codeValid) {
836 QString rnxStr('C');
837 rnxStr.append(obs._obs[iFrq]->_rnxType2ch.c_str());
[8082]838 if (_format.indexOf("RTCM_2") != -1
839 || _format.indexOf("RTCM2") != -1
840 || _format.indexOf("RTCM 2") != -1) {
[6580]841 rnxStr = t_rnxObsFile::type3to2(obs._prn.system(), rnxStr);
842 }
[6579]843 if (rnxTypes.indexOf(rnxStr) == -1) {
844 rnxTypes.push_back(rnxStr);
845 allFound = false;
846 }
[4476]847 }
[6579]848 if (obs._obs[iFrq]->_phaseValid) {
849 QString rnxStr('L');
850 rnxStr.append(obs._obs[iFrq]->_rnxType2ch.c_str());
[8082]851 if (_format.indexOf("RTCM_2") != -1
852 || _format.indexOf("RTCM2") != -1
853 || _format.indexOf("RTCM 2") != -1) {
[6580]854 rnxStr = t_rnxObsFile::type3to2(obs._prn.system(), rnxStr);
855 }
[6579]856 if (rnxTypes.indexOf(rnxStr) == -1) {
857 rnxTypes.push_back(rnxStr);
858 allFound = false;
859 }
860 }
[8082]861 if (obs._obs[iFrq]->_dopplerValid) {
[6579]862 QString rnxStr('D');
863 rnxStr.append(obs._obs[iFrq]->_rnxType2ch.c_str());
[8082]864 if (_format.indexOf("RTCM_2") != -1
865 || _format.indexOf("RTCM2") != -1
866 || _format.indexOf("RTCM 2") != -1) {
[6580]867 rnxStr = t_rnxObsFile::type3to2(obs._prn.system(), rnxStr);
868 }
[6579]869 if (rnxTypes.indexOf(rnxStr) == -1) {
870 rnxTypes.push_back(rnxStr);
871 allFound = false;
872 }
873 }
[8082]874 if (obs._obs[iFrq]->_snrValid) {
[6579]875 QString rnxStr('S');
876 rnxStr.append(obs._obs[iFrq]->_rnxType2ch.c_str());
[8082]877 if (_format.indexOf("RTCM_2") != -1
878 || _format.indexOf("RTCM2") != -1
879 || _format.indexOf("RTCM 2") != -1) {
[6580]880 rnxStr = t_rnxObsFile::type3to2(obs._prn.system(), rnxStr);
881 }
[6579]882 if (rnxTypes.indexOf(rnxStr) == -1) {
883 rnxTypes.push_back(rnxStr);
884 allFound = false;
885 }
886 }
[4476]887 }
888 if (!allFound) {
[7486]889 QString msg;
[4477]890 QTextStream str(&msg);
[9559]891 str << obs._prn.system() << QString(" %1 ").arg(rnxTypes.size());
[4476]892 for (int iType = 0; iType < rnxTypes.size(); iType++) {
[4478]893 str << " " << rnxTypes[iType];
[4476]894 }
[10564]895 emit(newMessage(_staID + ": Observation Types: " + msg.toLatin1(), true));
[4476]896 }
897 }
898
[1574]899 // RTCMv3 antenna descriptor
900 // -------------------------
[4476]901 for (int ii = 0; ii < decoder()->_antType.size(); ii++) {
[10692]902 QString ant1 = QString(": Antenna Descriptor: %1 ").arg(decoder()->_antType[ii]._descriptor);
[8236]903 emit(newMessage(_staID + ant1.toLatin1(), true));
[10692]904 if (strlen(decoder()->_antType[ii]._serialnumber)) {
905 QString ant2 = QString(": Antenna Serial Number: %1 ").arg(decoder()->_antType[ii]._serialnumber);
[8236]906 emit(newMessage(_staID + ant2.toLatin1(), true));
907 }
[1574]908 }
[1555]909
[1575]910 // RTCM Antenna Coordinates
911 // ------------------------
[8082]912 for (int ii = 0; ii < decoder()->_antList.size(); ii++) {
[1574]913 QByteArray antT;
[10692]914 if (decoder()->_antList[ii]._type == GPSDecoder::t_antRefPoint::ARP) {
[1574]915 antT = "ARP";
[10692]916 } else if (decoder()->_antList[ii]._type == GPSDecoder::t_antRefPoint::APC) {
[1574]917 antT = "APC";
918 }
[1575]919 QByteArray ant1, ant2, ant3;
[10692]920 ant1 = QString("%1 ").arg(decoder()->_antList[ii]._xx, 0, 'f', 4).toLatin1();
921 ant2 = QString("%1 ").arg(decoder()->_antList[ii]._yy, 0, 'f', 4).toLatin1();
922 ant3 = QString("%1 ").arg(decoder()->_antList[ii]._zz, 0, 'f', 4).toLatin1();
[1575]923 emit(newMessage(_staID + ": " + antT + " (ITRF) X " + ant1 + "m", true));
924 emit(newMessage(_staID + ": " + antT + " (ITRF) Y " + ant2 + "m", true));
925 emit(newMessage(_staID + ": " + antT + " (ITRF) Z " + ant3 + "m", true));
[3595]926 double hh = 0.0;
[10692]927 if (decoder()->_antList[ii]._height_f) {
928 hh = decoder()->_antList[ii]._height;
[8127]929 QByteArray ant4 = QString("%1 ").arg(hh, 0, 'f', 4).toLatin1();
[8082]930 emit(newMessage(
931 _staID + ": Antenna height above marker " + ant4 + "m", true));
[1575]932 }
[10692]933 emit(newAntCrd(_staID, decoder()->_antList[ii]._xx,
934 decoder()->_antList[ii]._yy, decoder()->_antList[ii]._zz, hh, antT));
[1218]935 }
[6864]936
[8197]937 // RTCMv3 receiver descriptor
938 // --------------------------
939 for (int ii = 0; ii < decoder()->_recType.size(); ii++) {
[10692]940 QString rec1 = QString(": Receiver Descriptor: %1 ").arg(decoder()->_recType[ii]._descriptor);
941 QString rec2 = QString(": Receiver Firmware Version: %1 ").arg(decoder()->_recType[ii]._firmware);
942 QString rec3 = QString(": Receiver Serial Number: %1 ").arg(decoder()->_recType[ii]._serialnumber);
[8236]943 emit(newMessage(_staID + rec1.toLatin1(), true));
944 emit(newMessage(_staID + rec2.toLatin1(), true));
945 emit(newMessage(_staID + rec3.toLatin1(), true));
[8197]946 }
947
[6864]948 // RTCM GLONASS slots
949 // ------------------
950 if (decoder()->_gloFrq.size()) {
951 bool allFound = true;
952 QString slot = decoder()->_gloFrq;
[8082]953 slot.replace(" ", " ").replace(" ", ":");
[6864]954 if (_gloSlots.indexOf(slot) == -1) {
955 _gloSlots.append(slot);
956 allFound = false;
957 }
958 if (!allFound) {
959 _gloSlots.sort();
[8082]960 emit(newMessage(
[8127]961 _staID + ": GLONASS Slot:Freq " + _gloSlots.join(" ").toLatin1(),
[8082]962 true));
[6864]963 }
964 }
[10688]965
966 // RTCM GLONASS Code-Phase biases (MT 1230)
967 // ----------------------------------------
[10692]968 if (decoder()->_gloBiasInfo.changed()) {
969 QString gloCodePhaseBiases = decoder()->_gloBiasInfo.toString();
[10688]970 emit(newMessage(_staID + gloCodePhaseBiases.toLatin1(), true));
[10692]971 decoder()->_gloBiasInfo.setChanged(false);
[10688]972 }
973
974 // Service CRS / RTCM CRS
975 // ------------------------
[10564]976 if (fmod(decoder()->corrGPSEpochTime(), 60.0) == 0.0) {
977 // Service CRS
978 for (int ii = 0; ii < decoder()->_serviceCrs.size(); ii++) {
979 QString servicecrsname = QString(": Service CRS Name: %1 ").arg(decoder()->_serviceCrs[ii]._name);
980 QString coordinateEpoch = QString(": Service CRS Coordinate Epoch: %1 ").arg(decoder()->_serviceCrs[ii]._coordinateEpoch);
981 //QString ce = QString(": CE: %1 ").arg(decoder()->_serviceCrs[ii]._CE);
982 emit(newMessage(_staID + servicecrsname.toLatin1(), true));
983 emit(newMessage(_staID + coordinateEpoch.toLatin1(), true));
984 //emit(newMessage(_staID + ce.toLatin1(), true));
985 }
986 // RTCM CRS
987 for (int ii = 0; ii < decoder()->_rtcmCrs.size(); ii++) {
988 QString rtcmcrsname = QString(": RTCM CRS Name: %1 ").arg(decoder()->_rtcmCrs[ii]._name);
989 QString anchor = QString(": RTCM CRS Anchor: %1 ").arg(decoder()->_rtcmCrs[ii]._anchor);
990 QString platenumber = QString(": RTCM CRS Plate Number: %1 ").arg(decoder()->_rtcmCrs[ii]._plateNumber);
991 emit(newMessage(_staID + rtcmcrsname.toLatin1(), true));
992 emit(newMessage(_staID + anchor.toLatin1(), true));
993 emit(newMessage(_staID + platenumber.toLatin1(), true));
994 for (int i = 0; i<decoder()->_rtcmCrs[ii]._databaseLinks.size(); i++) {
995 QString dblink = QString(": Database Link: %1 ").arg(decoder()->_rtcmCrs[ii]._databaseLinks[i]);
996 emit(newMessage(_staID + dblink.toLatin1(), true));
997 }
[10533]998 }
999
[10564]1000 // Helmert Parameters
1001 //-------------------
1002 for (int ii = 0; ii < decoder()->_helmertPar.size(); ii++) {
1003 t_helmertPar& helmertPar = decoder()->_helmertPar[ii];
1004 bncTime t; t.setmjd(0, helmertPar._mjd); QString dateStr = QString::fromStdString(t.datestr());
1005 QString sourcename = QString(": MT1301 Source Name: %1 ").arg(helmertPar._sourceName);
1006 QString targetname = QString(": MT1301 Target Name: %1 ").arg(helmertPar._targetName);
1007 QString sysidentnum = QString(": MT1301 Sys Ident Num: %1 ").arg(helmertPar._sysIdentNum);
1008 QString trafomessageind = QString(": MT1301 Trafo Ident Num: %1 ").arg(helmertPar.IndtoString());
1009 QString epoch = QString(": MT1301 t0: MJD %1 (%2) ").arg(helmertPar._mjd).arg(dateStr);
1010 QString partrans = QString(": MT1301 Helmert Par Trans: dx = %1, dy = %2, dz = %3, dxr = %4, dyr = %5, dzr = %6")
1011 .arg(helmertPar._dx).arg(helmertPar._dy).arg(helmertPar._dz)
1012 .arg(helmertPar._dxr).arg(helmertPar._dyr).arg(helmertPar._dzr);
1013 QString parrot = QString(": MT1301 Helmert Par Rot: ox = %1, oy = %2, oz = %3, oxr = %4, oyr = %5, ozr = %6")
1014 .arg(helmertPar._ox).arg(helmertPar._oy).arg(helmertPar._oz)
1015 .arg(helmertPar._oxr).arg(helmertPar._oyr).arg(helmertPar._ozr);
1016 QString parscale = QString(": MT1301 Helmert Par Scale: sc = %1, scr = %2").arg(helmertPar._sc).arg(helmertPar._scr);
1017 emit(newMessage(_staID + sourcename.toLatin1(), true));
1018 emit(newMessage(_staID + targetname.toLatin1(), true));
1019 emit(newMessage(_staID + sysidentnum.toLatin1(), true));
1020 emit(newMessage(_staID + trafomessageind.toLatin1(), true));
1021 emit(newMessage(_staID + epoch.toLatin1(), true));
1022 emit(newMessage(_staID + partrans.toLatin1(), true));
1023 emit(newMessage(_staID + parrot.toLatin1(), true));
1024 emit(newMessage(_staID + parscale.toLatin1(), true));
1025 }
[10533]1026 }
[1218]1027 }
[1044]1028 }
[1575]1029
[1770]1030#ifdef MLS_SOFTWARE
[3523]1031 for (int ii=0; ii <decoder()->_antList.size(); ii++) {
[8082]1032 QByteArray antT;
1033 if (decoder()->_antList[ii].type == GPSDecoder::t_antInfo::ARP) {
1034 antT = "ARP";
1035 }
1036 else if (decoder()->_antList[ii].type == GPSDecoder::t_antInfo::APC) {
1037 antT = "APC";
1038 }
1039 double hh = 0.0;
1040 if (decoder()->_antList[ii].height_f) {
1041 hh = decoder()->_antList[ii].height;
1042 }
1043 emit(newAntCrd(_staID, decoder()->_antList[ii].xx,
1044 decoder()->_antList[ii].yy, decoder()->_antList[ii].zz,
1045 hh, antT));
[1770]1046 }
[2356]1047
[3523]1048 for (int ii = 0; ii <decoder()->_typeList.size(); ii++) {
1049 emit(newRTCMMessage(_staID, decoder()->_typeList[ii]));
[2356]1050 }
[1770]1051#endif
1052
[6864]1053 decoder()->_gloFrq.clear();
[10688]1054 // decoder()->_gloBiases.clear();
[3523]1055 decoder()->_typeList.clear();
1056 decoder()->_antType.clear();
[8197]1057 decoder()->_recType.clear();
[3523]1058 decoder()->_antList.clear();
[1044]1059}
[1555]1060
[1606]1061// Handle Data from Serial Port
1062////////////////////////////////////////////////////////////////////////////
1063void bncGetThread::slotSerialReadyRead() {
[6770]1064
[1607]1065 if (_serialPort) {
[6770]1066
[6773]1067 if (_nmea == "yes" && _serialNMEA == MANUAL_NMEA) {
[10420]1068 if (_NMEASampl) {
[10421]1069 int dt = _lastNMEA.secsTo(QDateTime::currentDateTime());
[10420]1070 if (dt && (fmod(double(dt), double(_NMEASampl)) == 0.0)) {
[6773]1071 _query->sendNMEA(_manualNMEAString);
[10421]1072 _lastNMEA = QDateTime::currentDateTime();
[6773]1073 }
1074 }
1075 }
1076
[1633]1077 int nb = _serialPort->bytesAvailable();
1078 if (nb > 0) {
1079 QByteArray data = _serialPort->read(nb);
[1711]1080
[6695]1081 if (_nmea == "yes" && _serialNMEA == AUTO_NMEA) {
[1725]1082 int i1 = data.indexOf("$GPGGA");
[6651]1083 if (i1 == -1) {
1084 i1 = data.indexOf("$GNGGA");
1085 }
[1725]1086 if (i1 != -1) {
[6751]1087 int i2 = data.indexOf("*", i1);
[1725]1088 if (i2 != -1 && data.size() > i2 + 1) {
[6751]1089 QByteArray gga = data.mid(i1, i2 - i1 + 3);
[10421]1090 if (_NMEASampl) {
1091 int dt = _lastNMEA.secsTo(QDateTime::currentDateTime());
1092 if (dt && (fmod(double(dt), double(_NMEASampl)) == 0.0)) {
1093 _query->sendNMEA(gga);
1094 _lastNMEA = QDateTime::currentDateTime();
1095 }
1096 }
[6751]1097 }
1098 }
[1711]1099 }
1100
[1633]1101 if (_serialOutFile) {
1102 _serialOutFile->write(data);
1103 _serialOutFile->flush();
1104 }
[1607]1105 }
1106 }
[1606]1107}
[7180]1108
1109void bncGetThread::slotNewNMEAConnection() {
1110 _nmeaSockets->push_back(_nmeaServer->nextPendingConnection());
[8082]1111 emit(newMessage(
[8127]1112 QString("New PPP client on port: # %1").arg(_nmeaSockets->size()).toLatin1(),
[8082]1113 true));
[7180]1114}
1115
1116//
1117////////////////////////////////////////////////////////////////////////////
1118void bncGetThread::slotNewNMEAstr(QByteArray staID, QByteArray str) {
1119 if (_nmeaPortsMap.contains(staID)) {
1120 int nmeaPort = _nmeaPortsMap.value(staID);
1121 QMutableListIterator<QTcpSocket*> is(*_nmeaSockets);
1122 while (is.hasNext()) {
1123 QTcpSocket* sock = is.next();
1124 if (sock->localPort() == nmeaPort) {
1125 if (sock->state() == QAbstractSocket::ConnectedState) {
1126 sock->write(str);
[8082]1127 } else if (sock->state() != QAbstractSocket::ConnectingState) {
[7180]1128 delete sock;
1129 is.remove();
1130 }
1131 }
1132 }
1133 }
1134}
Note: See TracBrowser for help on using the repository browser.