source: ntrip/trunk/BNC/bncgetthread.cpp@ 3559

Last change on this file since 3559 was 3559, checked in by weber, 12 years ago
File size: 22.4 KB
Line 
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 <QtNetwork>
48#include <QTime>
49
50#include "bncgetthread.h"
51#include "bnctabledlg.h"
52#include "bncapp.h"
53#include "bncutils.h"
54#include "bnczerodecoder.h"
55#include "bncnetqueryv0.h"
56#include "bncnetqueryv1.h"
57#include "bncnetqueryv2.h"
58#include "bncnetqueryrtp.h"
59#include "bncnetqueryudp.h"
60#include "bncnetqueryudp0.h"
61#include "bncnetquerys.h"
62#include "bncsettings.h"
63#include "latencychecker.h"
64#include "bncpppclient.h"
65#include "upload/bncrtnetdecoder.h"
66#include "RTCM/RTCM2Decoder.h"
67#include "RTCM3/RTCM3Decoder.h"
68#include "GPSS/gpssDecoder.h"
69#include "GPSS/hassDecoder.h"
70#include "serial/qextserialport.h"
71
72using namespace std;
73
74// Constructor 1
75////////////////////////////////////////////////////////////////////////////
76bncGetThread::bncGetThread(bncRawFile* rawFile) {
77
78 _rawFile = rawFile;
79 _format = rawFile->format();
80 _staID = rawFile->staID();
81 _rawOutput = false;
82 _ntripVersion = "N";
83
84 initialize();
85}
86
87// Constructor 2
88////////////////////////////////////////////////////////////////////////////
89bncGetThread::bncGetThread(const QUrl& mountPoint,
90 const QByteArray& format,
91 const QByteArray& latitude,
92 const QByteArray& longitude,
93 const QByteArray& nmea,
94 const QByteArray& ntripVersion) {
95 _rawFile = 0;
96 _mountPoint = mountPoint;
97 _staID = mountPoint.path().mid(1).toAscii();
98 _format = format;
99 _latitude = latitude;
100 _longitude = longitude;
101 _nmea = nmea;
102 _ntripVersion = ntripVersion;
103
104 bncSettings settings;
105 if (!settings.value("rawOutFile").toString().isEmpty()) {
106 _rawOutput = true;
107 }
108
109 initialize();
110 initDecoder();
111}
112
113// Initialization (common part of the constructor)
114////////////////////////////////////////////////////////////////////////////
115void bncGetThread::initialize() {
116
117 bncSettings settings;
118
119 setTerminationEnabled(true);
120
121 bncApp* app = (bncApp*) qApp;
122
123 connect(this, SIGNAL(newMessage(QByteArray,bool)),
124 app, SLOT(slotMessage(const QByteArray,bool)));
125
126 _isToBeDeleted = false;
127 _query = 0;
128 _nextSleep = 0;
129 _PPPclient = 0;
130 _miscMount = settings.value("miscMount").toString();
131
132 // Serial Port
133 // -----------
134 _serialNMEA = NO_NMEA;
135 _serialOutFile = 0;
136 _serialPort = 0;
137
138 if (!_staID.isEmpty() &&
139 settings.value("serialMountPoint").toString() == _staID) {
140 _serialPort = new QextSerialPort(settings.value("serialPortName").toString() );
141 _serialPort->setTimeout(0,100);
142
143 // Baud Rate
144 // ---------
145 QString hlp = settings.value("serialBaudRate").toString();
146 if (hlp == "110") {
147 _serialPort->setBaudRate(BAUD110);
148 }
149 else if (hlp == "300") {
150 _serialPort->setBaudRate(BAUD300);
151 }
152 else if (hlp == "600") {
153 _serialPort->setBaudRate(BAUD600);
154 }
155 else if (hlp == "1200") {
156 _serialPort->setBaudRate(BAUD1200);
157 }
158 else if (hlp == "2400") {
159 _serialPort->setBaudRate(BAUD2400);
160 }
161 else if (hlp == "4800") {
162 _serialPort->setBaudRate(BAUD4800);
163 }
164 else if (hlp == "9600") {
165 _serialPort->setBaudRate(BAUD9600);
166 }
167 else if (hlp == "19200") {
168 _serialPort->setBaudRate(BAUD19200);
169 }
170 else if (hlp == "38400") {
171 _serialPort->setBaudRate(BAUD38400);
172 }
173 else if (hlp == "57600") {
174 _serialPort->setBaudRate(BAUD57600);
175 }
176 else if (hlp == "115200") {
177 _serialPort->setBaudRate(BAUD115200);
178 }
179
180 // Parity
181 // ------
182 hlp = settings.value("serialParity").toString();
183 if (hlp == "NONE") {
184 _serialPort->setParity(PAR_NONE);
185 }
186 else if (hlp == "ODD") {
187 _serialPort->setParity(PAR_ODD);
188 }
189 else if (hlp == "EVEN") {
190 _serialPort->setParity(PAR_EVEN);
191 }
192 else if (hlp == "SPACE") {
193 _serialPort->setParity(PAR_SPACE);
194 }
195
196 // Data Bits
197 // ---------
198 hlp = settings.value("serialDataBits").toString();
199 if (hlp == "5") {
200 _serialPort->setDataBits(DATA_5);
201 }
202 else if (hlp == "6") {
203 _serialPort->setDataBits(DATA_6);
204 }
205 else if (hlp == "7") {
206 _serialPort->setDataBits(DATA_7);
207 }
208 else if (hlp == "8") {
209 _serialPort->setDataBits(DATA_8);
210 }
211 hlp = settings.value("serialStopBits").toString();
212 if (hlp == "1") {
213 _serialPort->setStopBits(STOP_1);
214 }
215 else if (hlp == "2") {
216 _serialPort->setStopBits(STOP_2);
217 }
218
219 // Flow Control
220 // ------------
221 hlp = settings.value("serialFlowControl").toString();
222 if (hlp == "XONXOFF") {
223 _serialPort->setFlowControl(FLOW_XONXOFF);
224 }
225 else if (hlp == "HARDWARE") {
226 _serialPort->setFlowControl(FLOW_HARDWARE);
227 }
228 else {
229 _serialPort->setFlowControl(FLOW_OFF);
230 }
231
232 // Open Serial Port
233 // ----------------
234 _serialPort->open(QIODevice::ReadWrite|QIODevice::Unbuffered);
235 if (!_serialPort->isOpen()) {
236 delete _serialPort;
237 _serialPort = 0;
238 emit(newMessage((_staID + ": Cannot open serial port\n"), true));
239 }
240 connect(_serialPort, SIGNAL(readyRead()),
241 this, SLOT(slotSerialReadyRead()));
242
243 // Automatic NMEA
244 // --------------
245 if (settings.value("serialAutoNMEA").toString() == "Auto") {
246 _serialNMEA = AUTO_NMEA;
247
248 QString fName = settings.value("serialFileNMEA").toString();
249 if (!fName.isEmpty()) {
250 _serialOutFile = new QFile(fName);
251 if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) {
252 _serialOutFile->open(QIODevice::WriteOnly | QIODevice::Append);
253 }
254 else {
255 _serialOutFile->open(QIODevice::WriteOnly);
256 }
257 }
258 }
259
260 // Manual NMEA
261 // -----------
262 else {
263 _serialNMEA = MANUAL_NMEA;
264 }
265 }
266
267 if (!_staID.isEmpty()) {
268 _latencyChecker = new latencyChecker(_staID);
269 }
270 else {
271 _latencyChecker = 0;
272 }
273}
274
275// Instantiate the decoder
276//////////////////////////////////////////////////////////////////////////////
277t_irc bncGetThread::initDecoder() {
278
279 if (_format.indexOf("RTCM_2") != -1 || _format.indexOf("RTCM2") != -1 ||
280 _format.indexOf("RTCM 2") != -1 ) {
281 emit(newMessage(_staID + ": Get data in RTCM 2.x format", true));
282 _decoders[_staID] = new RTCM2Decoder(_staID.data());
283 }
284 else if (_format.indexOf("RTCM_3") != -1 || _format.indexOf("RTCM3") != -1 ||
285 _format.indexOf("RTCM 3") != -1 ) {
286 emit(newMessage(_staID + ": Get data in RTCM 3.x format", true));
287 RTCM3Decoder* newDecoder = new RTCM3Decoder(_staID, _rawFile);
288 _decoders[_staID] = newDecoder;
289 connect((RTCM3Decoder*) newDecoder, SIGNAL(newMessage(QByteArray,bool)),
290 this, SIGNAL(newMessage(QByteArray,bool)));
291 }
292 else if (_format.indexOf("GPSS") != -1 || _format.indexOf("BNC") != -1) {
293 emit(newMessage(_staID + ": Get Data in GPSS format", true));
294 _decoders[_staID] = new gpssDecoder();
295 }
296 else if (_format.indexOf("ZERO") != -1) {
297 emit(newMessage(_staID + ": Get data in original format", true));
298 _decoders[_staID] = new bncZeroDecoder(_staID);
299 }
300 else if (_format.indexOf("RTNET") != -1) {
301 emit(newMessage(_staID + ": Get data in RTNet format", true));
302 _decoders[_staID] = new bncRtnetDecoder();
303 }
304 else if (_format.indexOf("HASS2ASCII") != -1) {
305 emit(newMessage(_staID + ": Get data in HASS2ASCII format", true));
306 _decoders[_staID] = new hassDecoder(_staID);
307 }
308 else {
309 emit(newMessage(_staID + ": Unknown data format " + _format, true));
310 _isToBeDeleted = true;
311 return failure;
312 }
313
314 msleep(100); //sleep 0.1 sec
315
316 if (_decoders.contains(_staID)) {
317 _decoders[_staID]->initRinex(_staID, _mountPoint, _latitude, _longitude,
318 _nmea, _ntripVersion);
319 }
320 else {
321 emit(newMessage(_staID + ": no decoder initialized " + _format, true));
322 _isToBeDeleted = true;
323 return failure;
324 }
325
326 // Initialize PPP Client?
327 // ----------------------
328#ifndef MLS_SOFTWARE
329 bncSettings settings;
330 if (settings.value("pppMount").toString() == _staID) {
331 _PPPclient = new bncPPPclient(_staID);
332 bncApp* app = (bncApp*) qApp;
333 app->_bncPPPclient = _PPPclient;
334 qRegisterMetaType<bncTime>("bncTime");
335 connect(_PPPclient, SIGNAL(newPosition(bncTime, double, double, double)),
336 this, SIGNAL(newPosition(bncTime, double, double, double)));
337 connect(_PPPclient, SIGNAL(newNMEAstr(QByteArray)),
338 this, SIGNAL(newNMEAstr(QByteArray)));
339 }
340#endif
341
342 return success;
343}
344
345// Current decoder in use
346////////////////////////////////////////////////////////////////////////////
347GPSDecoder* bncGetThread::decoder() {
348 QMutexLocker locker(&_mutexDecoder);
349
350 if (_decoders.contains(_staID) || initDecoder() == success) {
351 return _decoders[_staID];
352 }
353 else {
354 return 0;
355 }
356}
357
358// Destructor
359////////////////////////////////////////////////////////////////////////////
360bncGetThread::~bncGetThread() {
361 if (isRunning()) {
362 wait();
363 }
364 if (_query) {
365 _query->stop();
366 _query->deleteLater();
367 }
368 delete _PPPclient;
369 QMapIterator<QString, GPSDecoder*> it(_decoders);
370 while (it.hasNext()) {
371 it.next();
372 delete it.value();
373 }
374 delete _rawFile;
375 delete _serialOutFile;
376 delete _serialPort;
377 delete _latencyChecker;
378 emit getThreadFinished(_staID);
379}
380
381//
382////////////////////////////////////////////////////////////////////////////
383void bncGetThread::terminate() {
384 _isToBeDeleted = true;
385 if (!isRunning()) {
386 delete this;
387 }
388}
389
390// Run
391////////////////////////////////////////////////////////////////////////////
392void bncGetThread::run() {
393
394 while (true) {
395 try {
396 if (_isToBeDeleted) {
397 QThread::exit(0);
398 this->deleteLater();
399 return;
400 }
401
402 if (tryReconnect() != success) {
403 if (_latencyChecker) {
404 _latencyChecker->checkReconnect();
405 }
406 continue;
407 }
408
409 // Delete old observations
410 // -----------------------
411 QMapIterator<QString, GPSDecoder*> itDec(_decoders);
412 while (itDec.hasNext()) {
413 itDec.next();
414 GPSDecoder* decoder = itDec.value();
415 decoder->_obsList.clear();
416 }
417
418 // Read Data
419 // ---------
420 QByteArray data;
421 if (_query) {
422 _query->waitForReadyRead(data);
423 }
424 else if (_rawFile) {
425 data = _rawFile->readChunk();
426 _format = _rawFile->format();
427 _staID = _rawFile->staID();
428
429 if (data.isEmpty()) {
430 cout << "no more data" << endl;
431 ((bncApp*) qApp)->stopCombination();
432 QThread::exit(0);
433 delete this;
434 ::exit(0);
435 }
436 }
437 qint64 nBytes = data.size();
438
439 // Timeout, reconnect
440 // ------------------
441 if (nBytes == 0) {
442 if (_latencyChecker) {
443 _latencyChecker->checkReconnect();
444 }
445 emit(newMessage(_staID + ": Data timeout, reconnecting", true));
446 msleep(10000); //sleep 10 sec, G. Weber
447 continue;
448 }
449 else {
450 emit newBytes(_staID, nBytes);
451 }
452
453 // Output Data
454 // -----------
455 if (_rawOutput) {
456 bncApp* app = (bncApp*) qApp;
457 app->writeRawData(data, _staID, _format);
458 }
459
460 if (_serialPort) {
461 slotSerialReadyRead();
462 _serialPort->write(data);
463 }
464
465 // Decode Data
466 // -----------
467 vector<string> errmsg;
468 if (!decoder()) {
469 _isToBeDeleted = true;
470 continue;
471 }
472 decoder()->_obsList.clear();
473 t_irc irc = decoder()->Decode(data.data(), data.size(), errmsg);
474
475 // Perform various scans and checks
476 // --------------------------------
477 if (_latencyChecker) {
478 _latencyChecker->checkOutage(irc == success);
479 _latencyChecker->checkObsLatency(decoder()->_obsList);
480 _latencyChecker->checkCorrLatency(decoder()->corrGPSEpochTime());
481
482 emit newLatency(_staID, _latencyChecker->currentLatency());
483 }
484
485 scanRTCM();
486
487 // Loop over all observations (observations output)
488 // ------------------------------------------------
489 QListIterator<t_obs> it(decoder()->_obsList);
490 bool firstObs = true;
491 while (it.hasNext()) {
492 const t_obs& obs = it.next();
493
494 QString prn = QString("%1%2").arg(obs.satSys)
495 .arg(obs.satNum, 2, 10, QChar('0'));
496 long iSec = long(floor(obs.GPSWeeks+0.5));
497 long obsTime = obs.GPSWeek * 7*24*3600 + iSec;
498
499 // Check observation epoch
500 // -----------------------
501 if (!_rawFile && !dynamic_cast<gpssDecoder*>(decoder())) {
502 int week;
503 double sec;
504 currentGPSWeeks(week, sec);
505 long currTime = week * 7*24*3600 + long(sec);
506 const double maxDt = 600.0;
507 if (fabs(currTime - obsTime) > maxDt) {
508 emit( newMessage(_staID + ": Wrong observation epoch(s)", false) );
509 continue;
510 }
511 }
512
513 // Check observations coming twice (e.g. KOUR0 Problem)
514 // ----------------------------------------------------
515 if (!_rawFile) {
516 QMap<QString, long>::const_iterator it = _prnLastEpo.find(prn);
517 if (it != _prnLastEpo.end()) {
518 long oldTime = it.value();
519 if (obsTime < oldTime) {
520 emit( newMessage(_staID +
521 ": old observation " + prn.toAscii(), false));
522 continue;
523 }
524 else if (obsTime == oldTime) {
525 emit( newMessage(_staID +
526 ": observation coming more than once " + prn.toAscii(), false));
527 continue;
528 }
529 }
530 _prnLastEpo[prn] = obsTime;
531 }
532
533 decoder()->dumpRinexEpoch(obs, _format);
534
535 // PPP Client
536 // ----------
537#ifndef MLS_SOFTWARE
538 if (_PPPclient && _staID == _PPPclient->staID()) {
539 _PPPclient->putNewObs(obs);
540 }
541#endif
542
543 // Emit new observation signal
544 // ---------------------------
545 if (!_isToBeDeleted) {
546 emit newObs(_staID, firstObs, obs);
547 }
548 firstObs = false;
549 }
550 decoder()->_obsList.clear();
551 }
552 catch (Exception& exc) {
553 emit(newMessage(_staID + " " + exc.what(), true));
554 _isToBeDeleted = true;
555 }
556 catch (...) {
557 emit(newMessage(_staID + " bncGetThread exception", true));
558 _isToBeDeleted = true;
559 }
560 }
561}
562
563// Try Re-Connect
564////////////////////////////////////////////////////////////////////////////
565t_irc bncGetThread::tryReconnect() {
566
567 // Easy Return
568 // -----------
569 if (_query && _query->status() == bncNetQuery::running) {
570 _nextSleep = 0;
571 QMapIterator<QString, GPSDecoder*> itDec(_decoders);
572 while (itDec.hasNext()) {
573 itDec.next();
574 GPSDecoder* decoder = itDec.value();
575 decoder->setRinexReconnectFlag(false);
576 }
577 return success;
578 }
579
580 // Start a new query
581 // -----------------
582 if (!_rawFile) {
583
584 sleep(_nextSleep);
585 if (_nextSleep == 0) {
586 _nextSleep = 1;
587 }
588 else {
589 _nextSleep = 2 * _nextSleep;
590 if (_nextSleep > 256) {
591 _nextSleep = 256;
592 }
593#ifdef MLS_SOFTWARE
594 if (_nextSleep > 4) {
595 _nextSleep = 4;
596 }
597#endif
598 }
599
600 delete _query;
601 if (_ntripVersion == "U") {
602 _query = new bncNetQueryUdp();
603 }
604 else if (_ntripVersion == "R") {
605 _query = new bncNetQueryRtp();
606 }
607 else if (_ntripVersion == "S") {
608 _query = new bncNetQueryS();
609 }
610 else if (_ntripVersion == "N") {
611 _query = new bncNetQueryV0();
612 }
613 else if (_ntripVersion == "UN") {
614 _query = new bncNetQueryUdp0();
615 }
616 else if (_ntripVersion == "2") {
617 _query = new bncNetQueryV2(false);
618 }
619 else if (_ntripVersion == "2s") {
620 _query = new bncNetQueryV2(true);
621 }
622 else {
623 _query = new bncNetQueryV1();
624 }
625 if (_nmea == "yes" && _serialNMEA != AUTO_NMEA) {
626 QByteArray gga = ggaString(_latitude, _longitude, "100.0");
627 _query->startRequest(_mountPoint, gga);
628 }
629 else {
630 _query->startRequest(_mountPoint, "");
631 }
632 if (_query->status() != bncNetQuery::running) {
633 return failure;
634 }
635 }
636
637 QMapIterator<QString, GPSDecoder*> itDec(_decoders);
638 while (itDec.hasNext()) {
639 itDec.next();
640 GPSDecoder* decoder = itDec.value();
641 decoder->setRinexReconnectFlag(false);
642 }
643
644 return success;
645}
646
647// RTCM scan output
648//////////////////////////////////////////////////////////////////////////////
649void bncGetThread::scanRTCM() {
650
651 if (!decoder()) {
652 return;
653 }
654
655 bncSettings settings;
656 if ( Qt::CheckState(settings.value("scanRTCM").toInt()) == Qt::Checked ) {
657
658 if ( _miscMount == _staID || _miscMount == "ALL" ) {
659
660 // RTCM message types
661 // ------------------
662 for (int ii = 0; ii <decoder()->_typeList.size(); ii++) {
663 QString type = QString("%1 ").arg(decoder()->_typeList[ii]);
664 emit(newMessage(_staID + ": Received message type " + type.toAscii(), true));
665 }
666
667 // RTCMv3 antenna descriptor
668 // -------------------------
669 for (int ii=0;ii<decoder()->_antType.size();ii++) {
670 QString ant1 = QString("%1 ").arg(decoder()->_antType[ii]);
671 emit(newMessage(_staID + ": Antenna descriptor " + ant1.toAscii(), true));
672 }
673
674 // RTCM Antenna Coordinates
675 // ------------------------
676 for (int ii=0; ii <decoder()->_antList.size(); ii++) {
677 QByteArray antT;
678 if (decoder()->_antList[ii].type == GPSDecoder::t_antInfo::ARP) {
679 antT = "ARP";
680 }
681 else if (decoder()->_antList[ii].type == GPSDecoder::t_antInfo::APC) {
682 antT = "APC";
683 }
684 QByteArray ant1, ant2, ant3;
685 ant1 = QString("%1 ").arg(decoder()->_antList[ii].xx,0,'f',4).toAscii();
686 ant2 = QString("%1 ").arg(decoder()->_antList[ii].yy,0,'f',4).toAscii();
687 ant3 = QString("%1 ").arg(decoder()->_antList[ii].zz,0,'f',4).toAscii();
688 emit(newMessage(_staID + ": " + antT + " (ITRF) X " + ant1 + "m", true));
689 emit(newMessage(_staID + ": " + antT + " (ITRF) Y " + ant2 + "m", true));
690 emit(newMessage(_staID + ": " + antT + " (ITRF) Z " + ant3 + "m", true));
691 if (decoder()->_antList[ii].height_f) {
692 QByteArray ant4 = QString("%1 ").arg(decoder()->_antList[ii].height,0,'f',4).toAscii();
693 emit(newMessage(_staID + ": Antenna height above marker " + ant4 + "m", true));
694 }
695 emit(newAntCrd(_staID, decoder()->_antList[ii].xx,
696 decoder()->_antList[ii].yy, decoder()->_antList[ii].zz,
697 antT));
698 }
699 }
700 }
701
702#ifdef MLS_SOFTWARE
703 for (int ii=0; ii <decoder()->_antList.size(); ii++) {
704 QByteArray antT;
705 if (decoder()->_antList[ii].type == GPSDecoder::t_antInfo::ARP) {
706 antT = "ARP";
707 }
708 else if (decoder()->_antList[ii].type == GPSDecoder::t_antInfo::APC) {
709 antT = "APC";
710 }
711 emit(newAntCrd(_staID, decoder()->_antList[ii].xx,
712 decoder()->_antList[ii].yy, decoder()->_antList[ii].zz,
713 antT));
714 }
715
716 for (int ii = 0; ii <decoder()->_typeList.size(); ii++) {
717 emit(newRTCMMessage(_staID, decoder()->_typeList[ii]));
718 }
719#endif
720
721
722
723
724 decoder()->_typeList.clear();
725 decoder()->_antType.clear();
726 decoder()->_antList.clear();
727}
728
729// Handle Data from Serial Port
730////////////////////////////////////////////////////////////////////////////
731void bncGetThread::slotSerialReadyRead() {
732 if (_serialPort) {
733 int nb = _serialPort->bytesAvailable();
734 if (nb > 0) {
735 QByteArray data = _serialPort->read(nb);
736
737 if (_serialNMEA == AUTO_NMEA) {
738 int i1 = data.indexOf("$GPGGA");
739 if (i1 != -1) {
740 int i2 = data.indexOf("*", i1);
741 if (i2 != -1 && data.size() > i2 + 1) {
742 QByteArray gga = data.mid(i1,i2-i1+3);
743 _query->sendNMEA(gga);
744 }
745 }
746 }
747
748 if (_serialOutFile) {
749 _serialOutFile->write(data);
750 _serialOutFile->flush();
751 }
752 }
753 }
754}
755
756//
757//////////////////////////////////////////////////////////////////////////////
758void bncGetThread::slotNewEphGPS(gpsephemeris gpseph) {
759 QMutexLocker locker(&_mutexSlot);
760
761 if (!decoder()) {
762 return;
763 }
764
765 RTCM2Decoder* decoder2 = dynamic_cast<RTCM2Decoder*>(decoder());
766 RTCM3Decoder* decoder3 = dynamic_cast<RTCM3Decoder*>(decoder());
767
768 if ( decoder2 ) {
769 string storedPRN;
770 vector<int> IODs;
771
772 if ( decoder2->storeEph(gpseph, storedPRN, IODs) ) {
773#ifdef DEBUG_RTCM2_2021
774 QString msg = _staID + QString(": stored eph %1 IODs").arg(storedPRN.c_str());
775
776 for (unsigned ii = 0; ii < IODs.size(); ii++) {
777 msg += QString(" %1").arg(IODs[ii],4);
778 }
779
780 emit(newMessage(msg.toAscii()));
781#endif
782 }
783 }
784
785 if ( decoder3 ) {
786 if ( decoder3->storeEph(gpseph) ) {
787#ifdef DEBUG_RTCM3
788 QString msg = _staID + QString(": RTCM3Decoder, stored eph for satellite %1").arg(gpseph.satellite);
789 emit(newMessage(msg.toAscii(),true));
790#endif
791 }
792 }
793}
794
Note: See TracBrowser for help on using the repository browser.