1 | // Part of BNC, a utility for retrieving decoding and
|
---|
2 | // converting GNSS data streams from NTRIP broadcasters.
|
---|
3 | //
|
---|
4 | // Copyright (C) 2007
|
---|
5 | // German Federal Agency for Cartography and Geodesy (BKG)
|
---|
6 | // http://www.bkg.bund.de
|
---|
7 | // Czech Technical University Prague, Department of Geodesy
|
---|
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.
|
---|
24 |
|
---|
25 | /* -------------------------------------------------------------------------
|
---|
26 | * BKG NTRIP Client
|
---|
27 | * -------------------------------------------------------------------------
|
---|
28 | *
|
---|
29 | * Class: bncGetThread
|
---|
30 | *
|
---|
31 | * Purpose: Thread that retrieves data from NTRIP caster
|
---|
32 | *
|
---|
33 | * Author: L. Mervart
|
---|
34 | *
|
---|
35 | * Created: 24-Dec-2005
|
---|
36 | *
|
---|
37 | * Changes:
|
---|
38 | *
|
---|
39 | * -----------------------------------------------------------------------*/
|
---|
40 |
|
---|
41 | #include <stdlib.h>
|
---|
42 | #include <iomanip>
|
---|
43 | #include <sstream>
|
---|
44 |
|
---|
45 | #include <QFile>
|
---|
46 | #include <QTextStream>
|
---|
47 | #include <QMutex>
|
---|
48 | #include <QtNetwork>
|
---|
49 | #include <QTime>
|
---|
50 |
|
---|
51 | #include "bncgetthread.h"
|
---|
52 | #include "bnctabledlg.h"
|
---|
53 | #include "bnccore.h"
|
---|
54 | #include "bncutils.h"
|
---|
55 | #include "bnczerodecoder.h"
|
---|
56 | #include "bncnetqueryv0.h"
|
---|
57 | #include "bncnetqueryv1.h"
|
---|
58 | #include "bncnetqueryv2.h"
|
---|
59 | #include "bncnetqueryrtp.h"
|
---|
60 | #include "bncnetqueryudp.h"
|
---|
61 | #include "bncnetqueryudp0.h"
|
---|
62 | #include "bncnetquerys.h"
|
---|
63 | #include "bncsettings.h"
|
---|
64 | #include "latencychecker.h"
|
---|
65 | #include "upload/bncrtnetdecoder.h"
|
---|
66 | #include "RTCM/RTCM2Decoder.h"
|
---|
67 | #include "RTCM3/RTCM3Decoder.h"
|
---|
68 | #include "serial/qextserialport.h"
|
---|
69 |
|
---|
70 | using namespace std;
|
---|
71 |
|
---|
72 | // Constructor 1
|
---|
73 | ////////////////////////////////////////////////////////////////////////////
|
---|
74 | bncGetThread::bncGetThread(bncRawFile* rawFile) {
|
---|
75 |
|
---|
76 | _rawFile = rawFile;
|
---|
77 | _format = rawFile->format();
|
---|
78 | _staID = rawFile->staID();
|
---|
79 | _rawOutput = false;
|
---|
80 | _ntripVersion = "N";
|
---|
81 |
|
---|
82 | initialize();
|
---|
83 | }
|
---|
84 |
|
---|
85 | // Constructor 2
|
---|
86 | ////////////////////////////////////////////////////////////////////////////
|
---|
87 | bncGetThread::bncGetThread(const QUrl& mountPoint, const QByteArray& format,
|
---|
88 | const QByteArray& latitude, const QByteArray& longitude,
|
---|
89 | const QByteArray& nmea, const QByteArray& ntripVersion) {
|
---|
90 | _rawFile = 0;
|
---|
91 | _mountPoint = mountPoint;
|
---|
92 | _staID = mountPoint.path().mid(1).toAscii();
|
---|
93 | _format = format;
|
---|
94 | _latitude = latitude;
|
---|
95 | _longitude = longitude;
|
---|
96 | _nmea = nmea;
|
---|
97 | _ntripVersion = ntripVersion;
|
---|
98 |
|
---|
99 | bncSettings settings;
|
---|
100 | if (!settings.value("rawOutFile").toString().isEmpty()) {
|
---|
101 | _rawOutput = true;
|
---|
102 | } else {
|
---|
103 | _rawOutput = false;
|
---|
104 | }
|
---|
105 |
|
---|
106 | initialize();
|
---|
107 | initDecoder();
|
---|
108 | }
|
---|
109 |
|
---|
110 | // Initialization (common part of the constructor)
|
---|
111 | ////////////////////////////////////////////////////////////////////////////
|
---|
112 | void bncGetThread::initialize() {
|
---|
113 |
|
---|
114 | bncSettings settings;
|
---|
115 |
|
---|
116 | setTerminationEnabled(true);
|
---|
117 |
|
---|
118 | connect(this, SIGNAL(newMessage(QByteArray,bool)),
|
---|
119 | BNC_CORE, SLOT(slotMessage(const QByteArray,bool)));
|
---|
120 |
|
---|
121 | _isToBeDeleted = false;
|
---|
122 | _query = 0;
|
---|
123 | _nextSleep = 0;
|
---|
124 | _miscMount = settings.value("miscMount").toString();
|
---|
125 | _decoder = 0;
|
---|
126 |
|
---|
127 | // NMEA Port
|
---|
128 | // -----------
|
---|
129 | QListIterator<QString> iSta(settings.value("PPP/staTable").toStringList());
|
---|
130 | int nmeaPort = 0;
|
---|
131 | while (iSta.hasNext()) {
|
---|
132 | QStringList hlp = iSta.next().split(",");
|
---|
133 | if (hlp.size() < 10) {
|
---|
134 | continue;
|
---|
135 | }
|
---|
136 | QByteArray mp = hlp[0].toAscii();
|
---|
137 | if (_staID == mp) {
|
---|
138 | nmeaPort = hlp[9].toInt();
|
---|
139 | }
|
---|
140 | }
|
---|
141 | if (nmeaPort != 0) {
|
---|
142 | _nmeaServer = new QTcpServer;
|
---|
143 | if (!_nmeaServer->listen(QHostAddress::Any, nmeaPort)) {
|
---|
144 | emit newMessage("bncCaster: Cannot listen on port", true);
|
---|
145 | } else {
|
---|
146 | connect(_nmeaServer, SIGNAL(newConnection()), this,
|
---|
147 | SLOT(slotNewNMEAConnection()));
|
---|
148 | connect(BNC_CORE, SIGNAL(newNMEAstr(QByteArray, QByteArray)), this,
|
---|
149 | SLOT(slotNewNMEAstr(QByteArray, QByteArray)));
|
---|
150 | _nmeaSockets = new QList<QTcpSocket*>;
|
---|
151 | _nmeaPortsMap[_staID] = nmeaPort;
|
---|
152 | }
|
---|
153 | } else {
|
---|
154 | _nmeaServer = 0;
|
---|
155 | _nmeaSockets = 0;
|
---|
156 | }
|
---|
157 |
|
---|
158 | // Serial Port
|
---|
159 | // -----------
|
---|
160 | _serialNMEA = NO_NMEA;
|
---|
161 | _serialOutFile = 0;
|
---|
162 | _serialPort = 0;
|
---|
163 |
|
---|
164 | if (!_staID.isEmpty()
|
---|
165 | && settings.value("serialMountPoint").toString() == _staID) {
|
---|
166 | _serialPort = new QextSerialPort(
|
---|
167 | settings.value("serialPortName").toString());
|
---|
168 | _serialPort->setTimeout(0, 100);
|
---|
169 |
|
---|
170 | // Baud Rate
|
---|
171 | // ---------
|
---|
172 | QString hlp = settings.value("serialBaudRate").toString();
|
---|
173 | if (hlp == "110") {
|
---|
174 | _serialPort->setBaudRate(BAUD110);
|
---|
175 | } else if (hlp == "300") {
|
---|
176 | _serialPort->setBaudRate(BAUD300);
|
---|
177 | } else if (hlp == "600") {
|
---|
178 | _serialPort->setBaudRate(BAUD600);
|
---|
179 | } else if (hlp == "1200") {
|
---|
180 | _serialPort->setBaudRate(BAUD1200);
|
---|
181 | } else if (hlp == "2400") {
|
---|
182 | _serialPort->setBaudRate(BAUD2400);
|
---|
183 | } else if (hlp == "4800") {
|
---|
184 | _serialPort->setBaudRate(BAUD4800);
|
---|
185 | } else if (hlp == "9600") {
|
---|
186 | _serialPort->setBaudRate(BAUD9600);
|
---|
187 | } else if (hlp == "19200") {
|
---|
188 | _serialPort->setBaudRate(BAUD19200);
|
---|
189 | } else if (hlp == "38400") {
|
---|
190 | _serialPort->setBaudRate(BAUD38400);
|
---|
191 | } else if (hlp == "57600") {
|
---|
192 | _serialPort->setBaudRate(BAUD57600);
|
---|
193 | } else if (hlp == "115200") {
|
---|
194 | _serialPort->setBaudRate(BAUD115200);
|
---|
195 | }
|
---|
196 |
|
---|
197 | // Parity
|
---|
198 | // ------
|
---|
199 | hlp = settings.value("serialParity").toString();
|
---|
200 | if (hlp == "NONE") {
|
---|
201 | _serialPort->setParity(PAR_NONE);
|
---|
202 | } else if (hlp == "ODD") {
|
---|
203 | _serialPort->setParity(PAR_ODD);
|
---|
204 | } else if (hlp == "EVEN") {
|
---|
205 | _serialPort->setParity(PAR_EVEN);
|
---|
206 | } else if (hlp == "SPACE") {
|
---|
207 | _serialPort->setParity(PAR_SPACE);
|
---|
208 | }
|
---|
209 |
|
---|
210 | // Data Bits
|
---|
211 | // ---------
|
---|
212 | hlp = settings.value("serialDataBits").toString();
|
---|
213 | if (hlp == "5") {
|
---|
214 | _serialPort->setDataBits(DATA_5);
|
---|
215 | } else if (hlp == "6") {
|
---|
216 | _serialPort->setDataBits(DATA_6);
|
---|
217 | } else if (hlp == "7") {
|
---|
218 | _serialPort->setDataBits(DATA_7);
|
---|
219 | } else if (hlp == "8") {
|
---|
220 | _serialPort->setDataBits(DATA_8);
|
---|
221 | }
|
---|
222 | hlp = settings.value("serialStopBits").toString();
|
---|
223 | if (hlp == "1") {
|
---|
224 | _serialPort->setStopBits(STOP_1);
|
---|
225 | } else if (hlp == "2") {
|
---|
226 | _serialPort->setStopBits(STOP_2);
|
---|
227 | }
|
---|
228 |
|
---|
229 | // Flow Control
|
---|
230 | // ------------
|
---|
231 | hlp = settings.value("serialFlowControl").toString();
|
---|
232 | if (hlp == "XONXOFF") {
|
---|
233 | _serialPort->setFlowControl(FLOW_XONXOFF);
|
---|
234 | } else if (hlp == "HARDWARE") {
|
---|
235 | _serialPort->setFlowControl(FLOW_HARDWARE);
|
---|
236 | } else {
|
---|
237 | _serialPort->setFlowControl(FLOW_OFF);
|
---|
238 | }
|
---|
239 |
|
---|
240 | // Open Serial Port
|
---|
241 | // ----------------
|
---|
242 | _serialPort->open(QIODevice::ReadWrite | QIODevice::Unbuffered);
|
---|
243 | if (!_serialPort->isOpen()) {
|
---|
244 | delete _serialPort;
|
---|
245 | _serialPort = 0;
|
---|
246 | emit(newMessage((_staID + ": Cannot open serial port\n"), true));
|
---|
247 | }
|
---|
248 | connect(_serialPort, SIGNAL(readyRead()), this,
|
---|
249 | SLOT(slotSerialReadyRead()));
|
---|
250 |
|
---|
251 | // Automatic NMEA
|
---|
252 | // --------------
|
---|
253 | QString nmeaMode = settings.value("serialAutoNMEA").toString();
|
---|
254 | if (nmeaMode == "Auto") {
|
---|
255 | _serialNMEA = AUTO_NMEA;
|
---|
256 | QString fName = settings.value("serialFileNMEA").toString();
|
---|
257 | if (!fName.isEmpty()) {
|
---|
258 | _serialOutFile = new QFile(fName);
|
---|
259 | if (Qt::CheckState(settings.value("rnxAppend").toInt())
|
---|
260 | == Qt::Checked) {
|
---|
261 | _serialOutFile->open(QIODevice::WriteOnly | QIODevice::Append);
|
---|
262 | } else {
|
---|
263 | _serialOutFile->open(QIODevice::WriteOnly);
|
---|
264 | }
|
---|
265 | }
|
---|
266 | }
|
---|
267 | // Manual NMEA
|
---|
268 | // -----------
|
---|
269 | if ((nmeaMode == "Manual GPGGA") || (nmeaMode == "Manual GNGGA")) {
|
---|
270 | _serialNMEA = MANUAL_NMEA;
|
---|
271 | bncSettings settings;
|
---|
272 | _manualNMEASampl = settings.value("serialManualNMEASampling").toInt();
|
---|
273 | QString hlp = settings.value("serialHeightNMEA").toString();
|
---|
274 | if (hlp.isEmpty()) {
|
---|
275 | hlp = "0.0";
|
---|
276 | }
|
---|
277 | QByteArray _serialHeightNMEA = hlp.toAscii();
|
---|
278 | _manualNMEAString = ggaString(_latitude, _longitude, _serialHeightNMEA,
|
---|
279 | nmeaMode);
|
---|
280 | }
|
---|
281 | }
|
---|
282 |
|
---|
283 | if (!_staID.isEmpty()) {
|
---|
284 | _latencyChecker = new latencyChecker(_staID);
|
---|
285 | obs = false;
|
---|
286 | ssrOrb = false;
|
---|
287 | ssrClk = false;
|
---|
288 | ssrOrbClk = false;
|
---|
289 | ssrCbi = false;
|
---|
290 | ssrPbi = false;
|
---|
291 | ssrVtec = false;
|
---|
292 | ssrUra = false;
|
---|
293 | ssrHr = false;
|
---|
294 | _oldSsrEpoch = 0;
|
---|
295 | _ssrEpoch = 0;
|
---|
296 | } else {
|
---|
297 | _latencyChecker = 0;
|
---|
298 | }
|
---|
299 | }
|
---|
300 |
|
---|
301 | // Instantiate the decoder
|
---|
302 | //////////////////////////////////////////////////////////////////////////////
|
---|
303 | t_irc bncGetThread::initDecoder() {
|
---|
304 |
|
---|
305 | _decoder = 0;
|
---|
306 |
|
---|
307 | if (_format.indexOf("RTCM_2") != -1 || _format.indexOf("RTCM2") != -1
|
---|
308 | || _format.indexOf("RTCM 2") != -1) {
|
---|
309 | emit(newMessage(_staID + ": Get data in RTCM 2.x format", true));
|
---|
310 | _decoder = new RTCM2Decoder(_staID.data());
|
---|
311 | } else if (_format.indexOf("RTCM_3") != -1 || _format.indexOf("RTCM3") != -1
|
---|
312 | || _format.indexOf("RTCM 3") != -1) {
|
---|
313 | emit(newMessage(_staID + ": Get data in RTCM 3.x format", true));
|
---|
314 | RTCM3Decoder* newDecoder = new RTCM3Decoder(_staID, _rawFile);
|
---|
315 | _decoder = newDecoder;
|
---|
316 | connect((RTCM3Decoder*) newDecoder, SIGNAL(newMessage(QByteArray,bool)),
|
---|
317 | this, SIGNAL(newMessage(QByteArray,bool)));
|
---|
318 | } else if (_format.indexOf("ZERO") != -1) {
|
---|
319 | emit(newMessage(_staID + ": Get data in original format", true));
|
---|
320 | _decoder = new bncZeroDecoder(_staID);
|
---|
321 | } else if (_format.indexOf("RTNET") != -1) {
|
---|
322 | emit(newMessage(_staID + ": Get data in RTNet format", true));
|
---|
323 | _decoder = new bncRtnetDecoder();
|
---|
324 | } else {
|
---|
325 | emit(newMessage(_staID + ": Unknown data format " + _format, true));
|
---|
326 | _isToBeDeleted = true;
|
---|
327 | return failure;
|
---|
328 | }
|
---|
329 |
|
---|
330 | msleep(100); //sleep 0.1 sec
|
---|
331 |
|
---|
332 | _decoder->initRinex(_staID, _mountPoint, _latitude, _longitude, _nmea,
|
---|
333 | _ntripVersion);
|
---|
334 |
|
---|
335 | if (_rawFile) {
|
---|
336 | _decodersRaw[_staID] = _decoder;
|
---|
337 | }
|
---|
338 |
|
---|
339 | return success;
|
---|
340 | }
|
---|
341 |
|
---|
342 | // Current decoder in use
|
---|
343 | ////////////////////////////////////////////////////////////////////////////
|
---|
344 | GPSDecoder* bncGetThread::decoder() {
|
---|
345 | if (!_rawFile) {
|
---|
346 | return _decoder;
|
---|
347 | } else {
|
---|
348 | if (_decodersRaw.contains(_staID) || initDecoder() == success) {
|
---|
349 | return _decodersRaw[_staID];
|
---|
350 | }
|
---|
351 | }
|
---|
352 | return 0;
|
---|
353 | }
|
---|
354 |
|
---|
355 | // Destructor
|
---|
356 | ////////////////////////////////////////////////////////////////////////////
|
---|
357 | bncGetThread::~bncGetThread() {
|
---|
358 | if (isRunning()) {
|
---|
359 | wait();
|
---|
360 | }
|
---|
361 | if (_query) {
|
---|
362 | _query->stop();
|
---|
363 | _query->deleteLater();
|
---|
364 | }
|
---|
365 | if (_rawFile) {
|
---|
366 | QMapIterator<QString, GPSDecoder*> it(_decodersRaw);
|
---|
367 | while (it.hasNext()) {
|
---|
368 | it.next();
|
---|
369 | delete it.value();
|
---|
370 | }
|
---|
371 | } else {
|
---|
372 | delete _decoder;
|
---|
373 | }
|
---|
374 | delete _rawFile;
|
---|
375 | delete _serialOutFile;
|
---|
376 | delete _serialPort;
|
---|
377 | delete _latencyChecker;
|
---|
378 | emit getThreadFinished(_staID);
|
---|
379 | }
|
---|
380 |
|
---|
381 | //
|
---|
382 | ////////////////////////////////////////////////////////////////////////////
|
---|
383 | void bncGetThread::terminate() {
|
---|
384 | _isToBeDeleted = true;
|
---|
385 |
|
---|
386 | if (_nmeaPortsMap.contains(_staID)) {
|
---|
387 | _nmeaPortsMap.remove(_staID);
|
---|
388 | }
|
---|
389 | if (_nmeaServer) {
|
---|
390 | delete _nmeaServer;
|
---|
391 | }
|
---|
392 | if (_nmeaSockets) {
|
---|
393 | delete _nmeaSockets;
|
---|
394 | }
|
---|
395 |
|
---|
396 | #ifdef BNC_DEBUG
|
---|
397 | if (BNC_CORE->mode() != t_bncCore::interactive) {
|
---|
398 | while (!isFinished()) {
|
---|
399 | wait();
|
---|
400 | }
|
---|
401 | delete this;
|
---|
402 | } else {
|
---|
403 | if (!isRunning()) {
|
---|
404 | delete this;
|
---|
405 | }
|
---|
406 | }
|
---|
407 | #else
|
---|
408 | if (!isRunning()) {delete this;}
|
---|
409 | #endif
|
---|
410 |
|
---|
411 | }
|
---|
412 |
|
---|
413 | // Run
|
---|
414 | ////////////////////////////////////////////////////////////////////////////
|
---|
415 | void bncGetThread::run() {
|
---|
416 |
|
---|
417 | while (true) {
|
---|
418 | try {
|
---|
419 | if (_isToBeDeleted) {
|
---|
420 | QThread::exit(0);
|
---|
421 | this->deleteLater();
|
---|
422 | return;
|
---|
423 | }
|
---|
424 |
|
---|
425 | if (tryReconnect() != success) {
|
---|
426 | if (_latencyChecker) {
|
---|
427 | _latencyChecker->checkReconnect();
|
---|
428 | }
|
---|
429 | continue;
|
---|
430 | }
|
---|
431 |
|
---|
432 | // Delete old observations
|
---|
433 | // -----------------------
|
---|
434 | if (_rawFile) {
|
---|
435 | QMapIterator<QString, GPSDecoder*> itDec(_decodersRaw);
|
---|
436 | while (itDec.hasNext()) {
|
---|
437 | itDec.next();
|
---|
438 | GPSDecoder* decoder = itDec.value();
|
---|
439 | decoder->_obsList.clear();
|
---|
440 | }
|
---|
441 | } else {
|
---|
442 | _decoder->_obsList.clear();
|
---|
443 | }
|
---|
444 |
|
---|
445 | // Read Data
|
---|
446 | // ---------
|
---|
447 | QByteArray data;
|
---|
448 | if (_query) {
|
---|
449 | _query->waitForReadyRead(data);
|
---|
450 | } else if (_rawFile) {
|
---|
451 | data = _rawFile->readChunk();
|
---|
452 | _format = _rawFile->format();
|
---|
453 | _staID = _rawFile->staID();
|
---|
454 |
|
---|
455 | QCoreApplication::processEvents();
|
---|
456 |
|
---|
457 | if (data.isEmpty() || BNC_CORE->sigintReceived) {
|
---|
458 | cout << "no more data or Ctrl-C received" << endl;
|
---|
459 | BNC_CORE->stopCombination();
|
---|
460 | BNC_CORE->stopPPP();
|
---|
461 | ::exit(0);
|
---|
462 | }
|
---|
463 | }
|
---|
464 | qint64 nBytes = data.size();
|
---|
465 |
|
---|
466 | // Timeout, reconnect
|
---|
467 | // ------------------
|
---|
468 | if (nBytes == 0) {
|
---|
469 | if (_latencyChecker) {
|
---|
470 | _latencyChecker->checkReconnect();
|
---|
471 | }
|
---|
472 | emit(newMessage(_staID + ": Data timeout, reconnecting", true));
|
---|
473 | msleep(10000); //sleep 10 sec, G. Weber
|
---|
474 | continue;
|
---|
475 | } else {
|
---|
476 | emit newBytes(_staID, nBytes);
|
---|
477 | emit newRawData(_staID, data);
|
---|
478 | }
|
---|
479 |
|
---|
480 | // Output Data
|
---|
481 | // -----------
|
---|
482 | if (_rawOutput) {
|
---|
483 | BNC_CORE->writeRawData(data, _staID, _format);
|
---|
484 | }
|
---|
485 |
|
---|
486 | if (_serialPort) {
|
---|
487 | slotSerialReadyRead();
|
---|
488 | _serialPort->write(data);
|
---|
489 | }
|
---|
490 |
|
---|
491 | // Decode Data
|
---|
492 | // -----------
|
---|
493 | vector<string> errmsg;
|
---|
494 | if (!decoder()) {
|
---|
495 | _isToBeDeleted = true;
|
---|
496 | continue;
|
---|
497 | }
|
---|
498 |
|
---|
499 | t_irc irc = decoder()->Decode(data.data(), data.size(), errmsg);
|
---|
500 |
|
---|
501 | if (irc != success) {
|
---|
502 | continue;
|
---|
503 | }
|
---|
504 | // Perform various scans and checks
|
---|
505 | // --------------------------------
|
---|
506 | if (_latencyChecker) {
|
---|
507 | _latencyChecker->checkOutage(irc == success);
|
---|
508 | QListIterator<int> it(decoder()->_typeList);
|
---|
509 | _ssrEpoch = decoder()->corrGPSEpochTime();
|
---|
510 | if (_oldSsrEpoch > 0 && _ssrEpoch && _ssrEpoch > _oldSsrEpoch) {
|
---|
511 | if (ssrOrb) {
|
---|
512 | _latencyChecker->checkCorrLatency(_oldSsrEpoch, 1057);
|
---|
513 | ssrOrb = false;
|
---|
514 | }
|
---|
515 | if (ssrClk) {
|
---|
516 | _latencyChecker->checkCorrLatency(_oldSsrEpoch, 1058);
|
---|
517 | ssrClk = false;
|
---|
518 | }
|
---|
519 | if (ssrOrbClk) {
|
---|
520 | _latencyChecker->checkCorrLatency(_oldSsrEpoch, 1060);
|
---|
521 | ssrOrbClk = false;
|
---|
522 | }
|
---|
523 | if (ssrCbi) {
|
---|
524 | _latencyChecker->checkCorrLatency(_oldSsrEpoch, 1059);
|
---|
525 | ssrCbi = false;
|
---|
526 | }
|
---|
527 | if (ssrPbi) {
|
---|
528 | _latencyChecker->checkCorrLatency(_oldSsrEpoch, 1265);
|
---|
529 | ssrPbi = false;
|
---|
530 | }
|
---|
531 | if (ssrVtec) {
|
---|
532 | _latencyChecker->checkCorrLatency(_oldSsrEpoch, 1264);
|
---|
533 | ssrVtec = false;
|
---|
534 | }
|
---|
535 | if (ssrUra) {
|
---|
536 | _latencyChecker->checkCorrLatency(_oldSsrEpoch, 1061);
|
---|
537 | ssrUra = false;
|
---|
538 | }
|
---|
539 | if (ssrHr) {
|
---|
540 | _latencyChecker->checkCorrLatency(_oldSsrEpoch, 1062);
|
---|
541 | ssrHr = false;
|
---|
542 | }
|
---|
543 | }
|
---|
544 | while (it.hasNext()) {
|
---|
545 | int rtcmType = it.next();
|
---|
546 | if ((rtcmType >= 1001 && rtcmType <= 1004) || // legacy RTCM OBS
|
---|
547 | (rtcmType >= 1009 && rtcmType <= 1012) || // legacy RTCM OBS
|
---|
548 | (rtcmType >= 1071 && rtcmType <= 1127)) { // MSM RTCM OBS
|
---|
549 | obs = true;
|
---|
550 | } else if ((rtcmType >= 1057 && rtcmType <= 1068) ||
|
---|
551 | (rtcmType >= 1240 && rtcmType <= 1270)) {
|
---|
552 | switch (rtcmType) {
|
---|
553 | case 1057: case 1063: case 1240: case 1246: case 1252: case 1258:
|
---|
554 | ssrOrb = true;
|
---|
555 | break;
|
---|
556 | case 1058: case 1064: case 1241: case 1247: case 1253: case 1259:
|
---|
557 | ssrClk = true;
|
---|
558 | break;
|
---|
559 | case 1060: case 1066: case 1243: case 1249: case 1255: case 1261:
|
---|
560 | ssrOrbClk = true;
|
---|
561 | break;
|
---|
562 | case 1059: case 1065: case 1242: case 1248: case 1254: case 1260:
|
---|
563 | ssrCbi = true;
|
---|
564 | break;
|
---|
565 | case 1265: case 1266: case 1267: case 1268: case 1269: case 1270:
|
---|
566 | ssrPbi = true;
|
---|
567 | break;
|
---|
568 | case 1264:
|
---|
569 | ssrVtec = true;
|
---|
570 | break;
|
---|
571 | case 1061: case 1067: case 1244: case 1250: case 1256: case 1262:
|
---|
572 | ssrUra = true;
|
---|
573 | break;
|
---|
574 | case 1062: case 1068: case 1245: case 1251: case 1257: case 1263:
|
---|
575 | ssrHr = true;
|
---|
576 | break;
|
---|
577 | }
|
---|
578 | }
|
---|
579 | }
|
---|
580 | if (obs) {
|
---|
581 | _latencyChecker->checkObsLatency(decoder()->_obsList);
|
---|
582 | }
|
---|
583 | _oldSsrEpoch = _ssrEpoch;
|
---|
584 | emit newLatency(_staID, _latencyChecker->currentLatency());
|
---|
585 | }
|
---|
586 | miscScanRTCM();
|
---|
587 |
|
---|
588 | // Loop over all observations (observations output)
|
---|
589 | // ------------------------------------------------
|
---|
590 | QListIterator<t_satObs> it(decoder()->_obsList);
|
---|
591 |
|
---|
592 | QList<t_satObs> obsListHlp;
|
---|
593 |
|
---|
594 | while (it.hasNext()) {
|
---|
595 | const t_satObs& obs = it.next();
|
---|
596 |
|
---|
597 | // Check observation epoch
|
---|
598 | // -----------------------
|
---|
599 | if (!_rawFile) {
|
---|
600 | bool wrongObservationEpoch = checkForWrongObsEpoch(obs._time);
|
---|
601 | if (wrongObservationEpoch) {
|
---|
602 | QString prn(obs._prn.toString().c_str());
|
---|
603 | emit(newMessage(
|
---|
604 | _staID + " (" + prn.toAscii() + ")"
|
---|
605 | + ": Wrong observation epoch(s)", false));
|
---|
606 | continue;
|
---|
607 | }
|
---|
608 | }
|
---|
609 |
|
---|
610 | // Check observations coming twice (e.g. KOUR0 Problem)
|
---|
611 | // ----------------------------------------------------
|
---|
612 | if (!_rawFile) {
|
---|
613 | QString prn(obs._prn.toString().c_str());
|
---|
614 | long iSec = long(floor(obs._time.gpssec() + 0.5));
|
---|
615 | long obsTime = obs._time.gpsw() * 7 * 24 * 3600 + iSec;
|
---|
616 | QMap<QString, long>::const_iterator it = _prnLastEpo.find(prn);
|
---|
617 | if (it != _prnLastEpo.end()) {
|
---|
618 | long oldTime = it.value();
|
---|
619 | if (obsTime < oldTime) {
|
---|
620 | emit(newMessage(_staID + ": old observation " + prn.toAscii(),
|
---|
621 | false));
|
---|
622 | continue;
|
---|
623 | } else if (obsTime == oldTime) {
|
---|
624 | emit(newMessage(
|
---|
625 | _staID + ": observation coming more than once "
|
---|
626 | + prn.toAscii(), false));
|
---|
627 | continue;
|
---|
628 | }
|
---|
629 | }
|
---|
630 | _prnLastEpo[prn] = obsTime;
|
---|
631 | }
|
---|
632 |
|
---|
633 | decoder()->dumpRinexEpoch(obs, _format);
|
---|
634 |
|
---|
635 | // Save observations
|
---|
636 | // -----------------
|
---|
637 | obsListHlp.append(obs);
|
---|
638 | }
|
---|
639 |
|
---|
640 | // Emit signal
|
---|
641 | // -----------
|
---|
642 | if (!_isToBeDeleted && obsListHlp.size() > 0) {
|
---|
643 | emit newObs(_staID, obsListHlp);
|
---|
644 | }
|
---|
645 |
|
---|
646 | } catch (Exception& exc) {
|
---|
647 | emit(newMessage(_staID + " " + exc.what(), true));
|
---|
648 | _isToBeDeleted = true;
|
---|
649 | } catch (...) {
|
---|
650 | emit(newMessage(_staID + " bncGetThread exception", true));
|
---|
651 | _isToBeDeleted = true;
|
---|
652 | }
|
---|
653 | }
|
---|
654 | }
|
---|
655 |
|
---|
656 | // Try Re-Connect
|
---|
657 | ////////////////////////////////////////////////////////////////////////////
|
---|
658 | t_irc bncGetThread::tryReconnect() {
|
---|
659 |
|
---|
660 | // Easy Return
|
---|
661 | // -----------
|
---|
662 | if (_query && _query->status() == bncNetQuery::running) {
|
---|
663 | _nextSleep = 0;
|
---|
664 | if (_rawFile) {
|
---|
665 | QMapIterator<QString, GPSDecoder*> itDec(_decodersRaw);
|
---|
666 | while (itDec.hasNext()) {
|
---|
667 | itDec.next();
|
---|
668 | GPSDecoder* decoder = itDec.value();
|
---|
669 | decoder->setRinexReconnectFlag(false);
|
---|
670 | }
|
---|
671 | } else {
|
---|
672 | _decoder->setRinexReconnectFlag(false);
|
---|
673 | }
|
---|
674 | return success;
|
---|
675 | }
|
---|
676 |
|
---|
677 | // Start a new query
|
---|
678 | // -----------------
|
---|
679 | if (!_rawFile) {
|
---|
680 |
|
---|
681 | sleep(_nextSleep);
|
---|
682 | if (_nextSleep == 0) {
|
---|
683 | _nextSleep = 1;
|
---|
684 | } else {
|
---|
685 | _nextSleep = 2 * _nextSleep;
|
---|
686 | if (_nextSleep > 256) {
|
---|
687 | _nextSleep = 256;
|
---|
688 | }
|
---|
689 | #ifdef MLS_SOFTWARE
|
---|
690 | if (_nextSleep > 4) {
|
---|
691 | _nextSleep = 4;
|
---|
692 | }
|
---|
693 | #endif
|
---|
694 | }
|
---|
695 | if (_query) {
|
---|
696 | delete _query;
|
---|
697 | }
|
---|
698 | if (_ntripVersion == "U") {
|
---|
699 | _query = new bncNetQueryUdp();
|
---|
700 | } else if (_ntripVersion == "R") {
|
---|
701 | _query = new bncNetQueryRtp();
|
---|
702 | } else if (_ntripVersion == "S") {
|
---|
703 | _query = new bncNetQueryS();
|
---|
704 | } else if (_ntripVersion == "N") {
|
---|
705 | _query = new bncNetQueryV0();
|
---|
706 | } else if (_ntripVersion == "UN") {
|
---|
707 | _query = new bncNetQueryUdp0();
|
---|
708 | } else if (_ntripVersion == "2") {
|
---|
709 | _query = new bncNetQueryV2(false);
|
---|
710 | } else if (_ntripVersion == "2s") {
|
---|
711 | _query = new bncNetQueryV2(true);
|
---|
712 | } else {
|
---|
713 | _query = new bncNetQueryV1();
|
---|
714 | }
|
---|
715 | if (_nmea == "yes") {
|
---|
716 | if (_serialNMEA == MANUAL_NMEA) {
|
---|
717 | _query->startRequest(_mountPoint, _manualNMEAString);
|
---|
718 | _lastManualNMEA = QDateTime::currentDateTime();
|
---|
719 | } else if (_serialNMEA == AUTO_NMEA) {
|
---|
720 | if (_serialPort) {
|
---|
721 | int nb = _serialPort->bytesAvailable();
|
---|
722 | if (nb > 0) {
|
---|
723 | QByteArray data = _serialPort->read(nb);
|
---|
724 | int i1 = data.indexOf("$GPGGA");
|
---|
725 | if (i1 == -1) {
|
---|
726 | i1 = data.indexOf("$GNGGA");
|
---|
727 | }
|
---|
728 | if (i1 != -1) {
|
---|
729 | int i2 = data.indexOf("*", i1);
|
---|
730 | if (i2 != -1 && data.size() > i2 + 1) {
|
---|
731 | QByteArray gga = data.mid(i1, i2 - i1 + 3);
|
---|
732 | _query->startRequest(_mountPoint, gga);
|
---|
733 | }
|
---|
734 | }
|
---|
735 | }
|
---|
736 | }
|
---|
737 | }
|
---|
738 | } else {
|
---|
739 | _query->startRequest(_mountPoint, "");
|
---|
740 | }
|
---|
741 |
|
---|
742 | if (_query->status() != bncNetQuery::running) {
|
---|
743 | return failure;
|
---|
744 | }
|
---|
745 | }
|
---|
746 |
|
---|
747 | if (_rawFile) {
|
---|
748 | QMapIterator<QString, GPSDecoder*> itDec(_decodersRaw);
|
---|
749 | while (itDec.hasNext()) {
|
---|
750 | itDec.next();
|
---|
751 | GPSDecoder* decoder = itDec.value();
|
---|
752 | decoder->setRinexReconnectFlag(false);
|
---|
753 | }
|
---|
754 | } else {
|
---|
755 | _decoder->setRinexReconnectFlag(false);
|
---|
756 | }
|
---|
757 |
|
---|
758 | return success;
|
---|
759 | }
|
---|
760 |
|
---|
761 | // RTCM scan output
|
---|
762 | //////////////////////////////////////////////////////////////////////////////
|
---|
763 | void bncGetThread::miscScanRTCM() {
|
---|
764 |
|
---|
765 | if (!decoder()) {
|
---|
766 | return;
|
---|
767 | }
|
---|
768 |
|
---|
769 | bncSettings settings;
|
---|
770 | if (Qt::CheckState(settings.value("miscScanRTCM").toInt()) == Qt::Checked) {
|
---|
771 |
|
---|
772 | if (_miscMount == _staID || _miscMount == "ALL") {
|
---|
773 | // RTCM message types
|
---|
774 | // ------------------
|
---|
775 | for (int ii = 0; ii < decoder()->_typeList.size(); ii++) {
|
---|
776 | QString type = QString("%1 ").arg(decoder()->_typeList[ii]);
|
---|
777 | emit(newMessage(_staID + ": Received message type " + type.toAscii(),
|
---|
778 | true));
|
---|
779 | }
|
---|
780 |
|
---|
781 | // Check Observation Types
|
---|
782 | // -----------------------
|
---|
783 | for (int ii = 0; ii < decoder()->_obsList.size(); ii++) {
|
---|
784 | t_satObs& obs = decoder()->_obsList[ii];
|
---|
785 | QVector<QString>& rnxTypes = _rnxTypes[obs._prn.system()];
|
---|
786 | bool allFound = true;
|
---|
787 | for (unsigned iFrq = 0; iFrq < obs._obs.size(); iFrq++) {
|
---|
788 | if (obs._obs[iFrq]->_codeValid) {
|
---|
789 | QString rnxStr('C');
|
---|
790 | rnxStr.append(obs._obs[iFrq]->_rnxType2ch.c_str());
|
---|
791 | if (_format.indexOf("RTCM_2") != -1
|
---|
792 | || _format.indexOf("RTCM2") != -1
|
---|
793 | || _format.indexOf("RTCM 2") != -1) {
|
---|
794 | rnxStr = t_rnxObsFile::type3to2(obs._prn.system(), rnxStr);
|
---|
795 | }
|
---|
796 | if (rnxTypes.indexOf(rnxStr) == -1) {
|
---|
797 | rnxTypes.push_back(rnxStr);
|
---|
798 | allFound = false;
|
---|
799 | }
|
---|
800 | }
|
---|
801 | if (obs._obs[iFrq]->_phaseValid) {
|
---|
802 | QString rnxStr('L');
|
---|
803 | rnxStr.append(obs._obs[iFrq]->_rnxType2ch.c_str());
|
---|
804 | if (_format.indexOf("RTCM_2") != -1
|
---|
805 | || _format.indexOf("RTCM2") != -1
|
---|
806 | || _format.indexOf("RTCM 2") != -1) {
|
---|
807 | rnxStr = t_rnxObsFile::type3to2(obs._prn.system(), rnxStr);
|
---|
808 | }
|
---|
809 | if (rnxTypes.indexOf(rnxStr) == -1) {
|
---|
810 | rnxTypes.push_back(rnxStr);
|
---|
811 | allFound = false;
|
---|
812 | }
|
---|
813 | }
|
---|
814 | if (obs._obs[iFrq]->_dopplerValid) {
|
---|
815 | QString rnxStr('D');
|
---|
816 | rnxStr.append(obs._obs[iFrq]->_rnxType2ch.c_str());
|
---|
817 | if (_format.indexOf("RTCM_2") != -1
|
---|
818 | || _format.indexOf("RTCM2") != -1
|
---|
819 | || _format.indexOf("RTCM 2") != -1) {
|
---|
820 | rnxStr = t_rnxObsFile::type3to2(obs._prn.system(), rnxStr);
|
---|
821 | }
|
---|
822 | if (rnxTypes.indexOf(rnxStr) == -1) {
|
---|
823 | rnxTypes.push_back(rnxStr);
|
---|
824 | allFound = false;
|
---|
825 | }
|
---|
826 | }
|
---|
827 | if (obs._obs[iFrq]->_snrValid) {
|
---|
828 | QString rnxStr('S');
|
---|
829 | rnxStr.append(obs._obs[iFrq]->_rnxType2ch.c_str());
|
---|
830 | if (_format.indexOf("RTCM_2") != -1
|
---|
831 | || _format.indexOf("RTCM2") != -1
|
---|
832 | || _format.indexOf("RTCM 2") != -1) {
|
---|
833 | rnxStr = t_rnxObsFile::type3to2(obs._prn.system(), rnxStr);
|
---|
834 | }
|
---|
835 | if (rnxTypes.indexOf(rnxStr) == -1) {
|
---|
836 | rnxTypes.push_back(rnxStr);
|
---|
837 | allFound = false;
|
---|
838 | }
|
---|
839 | }
|
---|
840 | }
|
---|
841 | if (!allFound) {
|
---|
842 | QString msg;
|
---|
843 | QTextStream str(&msg);
|
---|
844 | QString s;
|
---|
845 | str << obs._prn.system() << " "
|
---|
846 | << s.sprintf("%2d", rnxTypes.size()) << " ";
|
---|
847 | for (int iType = 0; iType < rnxTypes.size(); iType++) {
|
---|
848 | str << " " << rnxTypes[iType];
|
---|
849 | }
|
---|
850 | emit(newMessage(_staID + ": Observation Types: " + msg.toAscii(),
|
---|
851 | true));
|
---|
852 | }
|
---|
853 | }
|
---|
854 |
|
---|
855 | // RTCMv3 antenna descriptor
|
---|
856 | // -------------------------
|
---|
857 | for (int ii = 0; ii < decoder()->_antType.size(); ii++) {
|
---|
858 | QString ant1 = QString("%1 ").arg(decoder()->_antType[ii]);
|
---|
859 | emit(newMessage(_staID + ": Antenna descriptor " + ant1.toAscii(), true));
|
---|
860 | }
|
---|
861 |
|
---|
862 | // RTCM Antenna Coordinates
|
---|
863 | // ------------------------
|
---|
864 | for (int ii = 0; ii < decoder()->_antList.size(); ii++) {
|
---|
865 | QByteArray antT;
|
---|
866 | if (decoder()->_antList[ii].type == GPSDecoder::t_antInfo::ARP) {
|
---|
867 | antT = "ARP";
|
---|
868 | } else if (decoder()->_antList[ii].type == GPSDecoder::t_antInfo::APC) {
|
---|
869 | antT = "APC";
|
---|
870 | }
|
---|
871 | QByteArray ant1, ant2, ant3;
|
---|
872 | ant1 =
|
---|
873 | QString("%1 ").arg(decoder()->_antList[ii].xx, 0, 'f', 4).toAscii();
|
---|
874 | ant2 =
|
---|
875 | QString("%1 ").arg(decoder()->_antList[ii].yy, 0, 'f', 4).toAscii();
|
---|
876 | ant3 =
|
---|
877 | QString("%1 ").arg(decoder()->_antList[ii].zz, 0, 'f', 4).toAscii();
|
---|
878 | emit(newMessage(_staID + ": " + antT + " (ITRF) X " + ant1 + "m", true));
|
---|
879 | emit(newMessage(_staID + ": " + antT + " (ITRF) Y " + ant2 + "m", true));
|
---|
880 | emit(newMessage(_staID + ": " + antT + " (ITRF) Z " + ant3 + "m", true));
|
---|
881 | double hh = 0.0;
|
---|
882 | if (decoder()->_antList[ii].height_f) {
|
---|
883 | hh = decoder()->_antList[ii].height;
|
---|
884 | QByteArray ant4 = QString("%1 ").arg(hh, 0, 'f', 4).toAscii();
|
---|
885 | emit(newMessage(
|
---|
886 | _staID + ": Antenna height above marker " + ant4 + "m", true));
|
---|
887 | }
|
---|
888 | emit(newAntCrd(_staID, decoder()->_antList[ii].xx,
|
---|
889 | decoder()->_antList[ii].yy, decoder()->_antList[ii].zz, hh, antT));
|
---|
890 | }
|
---|
891 |
|
---|
892 | // RTCM GLONASS slots
|
---|
893 | // ------------------
|
---|
894 | if (decoder()->_gloFrq.size()) {
|
---|
895 | bool allFound = true;
|
---|
896 | QString slot = decoder()->_gloFrq;
|
---|
897 | slot.replace(" ", " ").replace(" ", ":");
|
---|
898 | if (_gloSlots.indexOf(slot) == -1) {
|
---|
899 | _gloSlots.append(slot);
|
---|
900 | allFound = false;
|
---|
901 | }
|
---|
902 | if (!allFound) {
|
---|
903 | _gloSlots.sort();
|
---|
904 | emit(newMessage(
|
---|
905 | _staID + ": GLONASS Slot:Freq " + _gloSlots.join(" ").toAscii(),
|
---|
906 | true));
|
---|
907 | }
|
---|
908 | }
|
---|
909 | }
|
---|
910 | }
|
---|
911 |
|
---|
912 | #ifdef MLS_SOFTWARE
|
---|
913 | for (int ii=0; ii <decoder()->_antList.size(); ii++) {
|
---|
914 | QByteArray antT;
|
---|
915 | if (decoder()->_antList[ii].type == GPSDecoder::t_antInfo::ARP) {
|
---|
916 | antT = "ARP";
|
---|
917 | }
|
---|
918 | else if (decoder()->_antList[ii].type == GPSDecoder::t_antInfo::APC) {
|
---|
919 | antT = "APC";
|
---|
920 | }
|
---|
921 | double hh = 0.0;
|
---|
922 | if (decoder()->_antList[ii].height_f) {
|
---|
923 | hh = decoder()->_antList[ii].height;
|
---|
924 | }
|
---|
925 | emit(newAntCrd(_staID, decoder()->_antList[ii].xx,
|
---|
926 | decoder()->_antList[ii].yy, decoder()->_antList[ii].zz,
|
---|
927 | hh, antT));
|
---|
928 | }
|
---|
929 |
|
---|
930 | for (int ii = 0; ii <decoder()->_typeList.size(); ii++) {
|
---|
931 | emit(newRTCMMessage(_staID, decoder()->_typeList[ii]));
|
---|
932 | }
|
---|
933 | #endif
|
---|
934 |
|
---|
935 | decoder()->_gloFrq.clear();
|
---|
936 | decoder()->_typeList.clear();
|
---|
937 | decoder()->_antType.clear();
|
---|
938 | decoder()->_antList.clear();
|
---|
939 | }
|
---|
940 |
|
---|
941 | // Handle Data from Serial Port
|
---|
942 | ////////////////////////////////////////////////////////////////////////////
|
---|
943 | void bncGetThread::slotSerialReadyRead() {
|
---|
944 |
|
---|
945 | if (_serialPort) {
|
---|
946 |
|
---|
947 | if (_nmea == "yes" && _serialNMEA == MANUAL_NMEA) {
|
---|
948 | if (_manualNMEASampl) {
|
---|
949 | int dt = _lastManualNMEA.secsTo(QDateTime::currentDateTime());
|
---|
950 | if (dt && (fmod(double(dt), double(_manualNMEASampl)) == 0.0)) {
|
---|
951 | _query->sendNMEA(_manualNMEAString);
|
---|
952 | _lastManualNMEA = QDateTime::currentDateTime();
|
---|
953 | }
|
---|
954 | }
|
---|
955 | }
|
---|
956 |
|
---|
957 | int nb = _serialPort->bytesAvailable();
|
---|
958 | if (nb > 0) {
|
---|
959 | QByteArray data = _serialPort->read(nb);
|
---|
960 |
|
---|
961 | if (_nmea == "yes" && _serialNMEA == AUTO_NMEA) {
|
---|
962 | int i1 = data.indexOf("$GPGGA");
|
---|
963 | if (i1 == -1) {
|
---|
964 | i1 = data.indexOf("$GNGGA");
|
---|
965 | }
|
---|
966 | if (i1 != -1) {
|
---|
967 | int i2 = data.indexOf("*", i1);
|
---|
968 | if (i2 != -1 && data.size() > i2 + 1) {
|
---|
969 | QByteArray gga = data.mid(i1, i2 - i1 + 3);
|
---|
970 | _query->sendNMEA(gga);
|
---|
971 | }
|
---|
972 | }
|
---|
973 | }
|
---|
974 |
|
---|
975 | if (_serialOutFile) {
|
---|
976 | _serialOutFile->write(data);
|
---|
977 | _serialOutFile->flush();
|
---|
978 | }
|
---|
979 | }
|
---|
980 | }
|
---|
981 | }
|
---|
982 |
|
---|
983 | void bncGetThread::slotNewNMEAConnection() {
|
---|
984 | _nmeaSockets->push_back(_nmeaServer->nextPendingConnection());
|
---|
985 | emit(newMessage(
|
---|
986 | QString("New PPP client on port: # %1").arg(_nmeaSockets->size()).toAscii(),
|
---|
987 | true));
|
---|
988 | }
|
---|
989 |
|
---|
990 | //
|
---|
991 | ////////////////////////////////////////////////////////////////////////////
|
---|
992 | void bncGetThread::slotNewNMEAstr(QByteArray staID, QByteArray str) {
|
---|
993 | if (_nmeaPortsMap.contains(staID)) {
|
---|
994 | int nmeaPort = _nmeaPortsMap.value(staID);
|
---|
995 | QMutableListIterator<QTcpSocket*> is(*_nmeaSockets);
|
---|
996 | while (is.hasNext()) {
|
---|
997 | QTcpSocket* sock = is.next();
|
---|
998 | if (sock->localPort() == nmeaPort) {
|
---|
999 | if (sock->state() == QAbstractSocket::ConnectedState) {
|
---|
1000 | sock->write(str);
|
---|
1001 | } else if (sock->state() != QAbstractSocket::ConnectingState) {
|
---|
1002 | delete sock;
|
---|
1003 | is.remove();
|
---|
1004 | }
|
---|
1005 | }
|
---|
1006 | }
|
---|
1007 | }
|
---|
1008 | }
|
---|