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

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