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

Last change on this file since 3541 was 3541, checked in by mervart, 12 years ago
File size: 22.0 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 _decoders[_staID] = new RTCM3Decoder(_staID, _rawFile);
288 connect((RTCM3Decoder*) decoder(), SIGNAL(newMessage(QByteArray,bool)),
289 this, SIGNAL(newMessage(QByteArray,bool)));
290 }
291 else if (_format.indexOf("GPSS") != -1 || _format.indexOf("BNC") != -1) {
292 emit(newMessage(_staID + ": Get Data in GPSS format", true));
293 _decoders[_staID] = new gpssDecoder();
294 }
295 else if (_format.indexOf("ZERO") != -1) {
296 emit(newMessage(_staID + ": Get data in original format", true));
297 _decoders[_staID] = new bncZeroDecoder(_staID);
298 }
299 else if (_format.indexOf("RTNET") != -1) {
300 emit(newMessage(_staID + ": Get data in RTNet format", true));
301 _decoders[_staID] = new bncRtnetDecoder();
302 }
303 else if (_format.indexOf("HASS2ASCII") != -1) {
304 emit(newMessage(_staID + ": Get data in HASS2ASCII format", true));
305 _decoders[_staID] = new hassDecoder(_staID);
306 }
307 else {
308 emit(newMessage(_staID + ": Unknown data format " + _format, true));
309 _isToBeDeleted = true;
310 return failure;
311 }
312
313 msleep(100); //sleep 0.1 sec
314
315 if (decoder()) {
316 decoder()->initRinex(_staID, _mountPoint, _latitude, _longitude,
317 _nmea, _ntripVersion);
318
319 }
320
321 // Initialize PPP Client?
322 // ----------------------
323#ifndef MLS_SOFTWARE
324 bncSettings settings;
325 if (settings.value("pppMount").toString() == _staID) {
326 _PPPclient = new bncPPPclient(_staID);
327 bncApp* app = (bncApp*) qApp;
328 app->_bncPPPclient = _PPPclient;
329 qRegisterMetaType<bncTime>("bncTime");
330 connect(_PPPclient, SIGNAL(newPosition(bncTime, double, double, double)),
331 this, SIGNAL(newPosition(bncTime, double, double, double)));
332 connect(_PPPclient, SIGNAL(newNMEAstr(QByteArray)),
333 this, SIGNAL(newNMEAstr(QByteArray)));
334 }
335#endif
336
337 return success;
338}
339
340// Current decoder in use
341////////////////////////////////////////////////////////////////////////////
342GPSDecoder* bncGetThread::decoder() {
343 if (_decoders.contains(_staID) || initDecoder() == success) {
344 return _decoders.value(_staID);
345 }
346 else {
347 return 0;
348 }
349}
350
351// Destructor
352////////////////////////////////////////////////////////////////////////////
353bncGetThread::~bncGetThread() {
354 if (isRunning()) {
355 wait();
356 }
357 if (_query) {
358 _query->stop();
359 _query->deleteLater();
360 }
361 delete _PPPclient;
362 QMapIterator<QString, GPSDecoder*> it(_decoders);
363 while (it.hasNext()) {
364 it.next();
365 delete it.value();
366 }
367 delete _rawFile;
368 delete _serialOutFile;
369 delete _serialPort;
370 delete _latencyChecker;
371 emit getThreadFinished(_staID);
372}
373
374//
375////////////////////////////////////////////////////////////////////////////
376void bncGetThread::terminate() {
377 _isToBeDeleted = true;
378 if (!isRunning()) {
379 delete this;
380 }
381}
382
383// Run
384////////////////////////////////////////////////////////////////////////////
385void bncGetThread::run() {
386
387 while (true) {
388 try {
389 if (_isToBeDeleted) {
390 QThread::exit(0);
391 this->deleteLater();
392 return;
393 }
394
395 if (tryReconnect() != success) {
396 if (_latencyChecker) {
397 _latencyChecker->checkReconnect();
398 }
399 continue;
400 }
401
402 // Delete old observations
403 // -----------------------
404 QMapIterator<QString, GPSDecoder*> itDec(_decoders);
405 while (itDec.hasNext()) {
406 itDec.next();
407 GPSDecoder* decoder = itDec.value();
408 decoder->_obsList.clear();
409 }
410
411 // Read Data
412 // ---------
413 QByteArray data;
414 if (_query) {
415 _query->waitForReadyRead(data);
416 }
417 else if (_rawFile) {
418 data = _rawFile->readChunk();
419 _format = _rawFile->format();
420 _staID = _rawFile->staID();
421
422 if (data.isEmpty()) {
423 cout << "no more data" << endl;
424 QThread::exit(0);
425 delete this;
426 ::exit(0);
427 }
428 }
429 qint64 nBytes = data.size();
430
431 // Timeout, reconnect
432 // ------------------
433 if (nBytes == 0) {
434 if (_latencyChecker) {
435 _latencyChecker->checkReconnect();
436 }
437 emit(newMessage(_staID + ": Data timeout, reconnecting", true));
438 msleep(10000); //sleep 10 sec, G. Weber
439 continue;
440 }
441 else {
442 emit newBytes(_staID, nBytes);
443 }
444
445 // Output Data
446 // -----------
447 if (_rawOutput) {
448 bncApp* app = (bncApp*) qApp;
449 app->writeRawData(data, _staID, _format);
450 }
451
452 if (_serialPort) {
453 slotSerialReadyRead();
454 _serialPort->write(data);
455 }
456
457 // Decode Data
458 // -----------
459 vector<string> errmsg;
460 if (!decoder()) {
461 _isToBeDeleted = true;
462 continue;
463 }
464 decoder()->_obsList.clear();
465 t_irc irc = decoder()->Decode(data.data(), data.size(), errmsg);
466
467 // Perform various scans and checks
468 // --------------------------------
469 if (_latencyChecker) {
470 _latencyChecker->checkOutage(irc == success);
471 _latencyChecker->checkObsLatency(decoder()->_obsList);
472 _latencyChecker->checkCorrLatency(decoder()->corrGPSEpochTime());
473
474 emit newLatency(_staID, _latencyChecker->currentLatency());
475 }
476
477 scanRTCM();
478
479 // Loop over all observations (observations output)
480 // ------------------------------------------------
481 QListIterator<t_obs> it(decoder()->_obsList);
482 bool firstObs = true;
483 while (it.hasNext()) {
484 const t_obs& obs = it.next();
485
486 QString prn = QString("%1%2").arg(obs.satSys)
487 .arg(obs.satNum, 2, 10, QChar('0'));
488 long iSec = long(floor(obs.GPSWeeks+0.5));
489 long obsTime = obs.GPSWeek * 7*24*3600 + iSec;
490
491 // Check observation epoch
492 // -----------------------
493 if (!_rawFile && !dynamic_cast<gpssDecoder*>(decoder())) {
494 int week;
495 double sec;
496 currentGPSWeeks(week, sec);
497 long currTime = week * 7*24*3600 + long(sec);
498 const double maxDt = 600.0;
499 if (fabs(currTime - obsTime) > maxDt) {
500 emit( newMessage(_staID + ": Wrong observation epoch(s)", false) );
501 continue;
502 }
503 }
504
505 // Check observations coming twice (e.g. KOUR0 Problem)
506 // ----------------------------------------------------
507 if (!_rawFile) {
508 QMap<QString, long>::const_iterator it = _prnLastEpo.find(prn);
509 if (it != _prnLastEpo.end()) {
510 long oldTime = it.value();
511 if (obsTime < oldTime) {
512 emit( newMessage(_staID +
513 ": old observation " + prn.toAscii(), false));
514 continue;
515 }
516 else if (obsTime == oldTime) {
517 emit( newMessage(_staID +
518 ": observation coming more than once " + prn.toAscii(), false));
519 continue;
520 }
521 }
522 _prnLastEpo[prn] = obsTime;
523 }
524
525 decoder()->dumpRinexEpoch(obs, _format);
526
527 // PPP Client
528 // ----------
529#ifndef MLS_SOFTWARE
530 if (_PPPclient && _staID == _PPPclient->staID()) {
531 _PPPclient->putNewObs(obs);
532 }
533#endif
534
535 // Emit new observation signal
536 // ---------------------------
537 if (!_isToBeDeleted) {
538 emit newObs(_staID, firstObs, obs);
539 }
540 firstObs = false;
541 }
542 decoder()->_obsList.clear();
543 }
544 catch (Exception& exc) {
545 emit(newMessage(_staID + " " + exc.what(), true));
546 _isToBeDeleted = true;
547 }
548 catch (...) {
549 emit(newMessage(_staID + " bncGetThread exception", true));
550 _isToBeDeleted = true;
551 }
552 }
553}
554
555// Try Re-Connect
556////////////////////////////////////////////////////////////////////////////
557t_irc bncGetThread::tryReconnect() {
558
559 // Easy Return
560 // -----------
561 if (_query && _query->status() == bncNetQuery::running) {
562 _nextSleep = 0;
563 QMapIterator<QString, GPSDecoder*> itDec(_decoders);
564 while (itDec.hasNext()) {
565 itDec.next();
566 GPSDecoder* decoder = itDec.value();
567 decoder->setRinexReconnectFlag(false);
568 }
569 return success;
570 }
571
572 // Start a new query
573 // -----------------
574 if (!_rawFile) {
575
576 sleep(_nextSleep);
577 if (_nextSleep == 0) {
578 _nextSleep = 1;
579 }
580 else {
581 _nextSleep = 2 * _nextSleep;
582 if (_nextSleep > 256) {
583 _nextSleep = 256;
584 }
585#ifdef MLS_SOFTWARE
586 if (_nextSleep > 4) {
587 _nextSleep = 4;
588 }
589#endif
590 }
591
592 delete _query;
593 if (_ntripVersion == "U") {
594 _query = new bncNetQueryUdp();
595 }
596 else if (_ntripVersion == "R") {
597 _query = new bncNetQueryRtp();
598 }
599 else if (_ntripVersion == "S") {
600 _query = new bncNetQueryS();
601 }
602 else if (_ntripVersion == "N") {
603 _query = new bncNetQueryV0();
604 }
605 else if (_ntripVersion == "UN") {
606 _query = new bncNetQueryUdp0();
607 }
608 else if (_ntripVersion == "2") {
609 _query = new bncNetQueryV2(false);
610 }
611 else if (_ntripVersion == "2s") {
612 _query = new bncNetQueryV2(true);
613 }
614 else {
615 _query = new bncNetQueryV1();
616 }
617 if (_nmea == "yes" && _serialNMEA != AUTO_NMEA) {
618 QByteArray gga = ggaString(_latitude, _longitude, "100.0");
619 _query->startRequest(_mountPoint, gga);
620 }
621 else {
622 _query->startRequest(_mountPoint, "");
623 }
624 if (_query->status() != bncNetQuery::running) {
625 return failure;
626 }
627 }
628
629 QMapIterator<QString, GPSDecoder*> itDec(_decoders);
630 while (itDec.hasNext()) {
631 itDec.next();
632 GPSDecoder* decoder = itDec.value();
633 decoder->setRinexReconnectFlag(false);
634 }
635
636 return success;
637}
638
639// RTCM scan output
640//////////////////////////////////////////////////////////////////////////////
641void bncGetThread::scanRTCM() {
642
643 bncSettings settings;
644 if ( Qt::CheckState(settings.value("scanRTCM").toInt()) == Qt::Checked ) {
645
646 if ( _miscMount == _staID || _miscMount == "ALL" ) {
647
648 // RTCM message types
649 // ------------------
650 for (int ii = 0; ii <decoder()->_typeList.size(); ii++) {
651 QString type = QString("%1 ").arg(decoder()->_typeList[ii]);
652 emit(newMessage(_staID + ": Received message type " + type.toAscii(), true));
653 }
654
655 // RTCMv3 antenna descriptor
656 // -------------------------
657 for (int ii=0;ii<decoder()->_antType.size();ii++) {
658 QString ant1 = QString("%1 ").arg(decoder()->_antType[ii]);
659 emit(newMessage(_staID + ": Antenna descriptor " + ant1.toAscii(), true));
660 }
661
662 // RTCM Antenna Coordinates
663 // ------------------------
664 for (int ii=0; ii <decoder()->_antList.size(); ii++) {
665 QByteArray antT;
666 if (decoder()->_antList[ii].type == GPSDecoder::t_antInfo::ARP) {
667 antT = "ARP";
668 }
669 else if (decoder()->_antList[ii].type == GPSDecoder::t_antInfo::APC) {
670 antT = "APC";
671 }
672 QByteArray ant1, ant2, ant3;
673 ant1 = QString("%1 ").arg(decoder()->_antList[ii].xx,0,'f',4).toAscii();
674 ant2 = QString("%1 ").arg(decoder()->_antList[ii].yy,0,'f',4).toAscii();
675 ant3 = QString("%1 ").arg(decoder()->_antList[ii].zz,0,'f',4).toAscii();
676 emit(newMessage(_staID + ": " + antT + " (ITRF) X " + ant1 + "m", true));
677 emit(newMessage(_staID + ": " + antT + " (ITRF) Y " + ant2 + "m", true));
678 emit(newMessage(_staID + ": " + antT + " (ITRF) Z " + ant3 + "m", true));
679 if (decoder()->_antList[ii].height_f) {
680 QByteArray ant4 = QString("%1 ").arg(decoder()->_antList[ii].height,0,'f',4).toAscii();
681 emit(newMessage(_staID + ": Antenna height above marker " + ant4 + "m", true));
682 }
683 emit(newAntCrd(_staID, decoder()->_antList[ii].xx,
684 decoder()->_antList[ii].yy, decoder()->_antList[ii].zz,
685 antT));
686 }
687 }
688 }
689
690#ifdef MLS_SOFTWARE
691 for (int ii=0; ii <decoder()->_antList.size(); ii++) {
692 QByteArray antT;
693 if (decoder()->_antList[ii].type == GPSDecoder::t_antInfo::ARP) {
694 antT = "ARP";
695 }
696 else if (decoder()->_antList[ii].type == GPSDecoder::t_antInfo::APC) {
697 antT = "APC";
698 }
699 emit(newAntCrd(_staID, decoder()->_antList[ii].xx,
700 decoder()->_antList[ii].yy, decoder()->_antList[ii].zz,
701 antT));
702 }
703
704 for (int ii = 0; ii <decoder()->_typeList.size(); ii++) {
705 emit(newRTCMMessage(_staID, decoder()->_typeList[ii]));
706 }
707#endif
708
709
710
711
712 decoder()->_typeList.clear();
713 decoder()->_antType.clear();
714 decoder()->_antList.clear();
715}
716
717// Handle Data from Serial Port
718////////////////////////////////////////////////////////////////////////////
719void bncGetThread::slotSerialReadyRead() {
720 if (_serialPort) {
721 int nb = _serialPort->bytesAvailable();
722 if (nb > 0) {
723 QByteArray data = _serialPort->read(nb);
724
725 if (_serialNMEA == AUTO_NMEA) {
726 int i1 = data.indexOf("$GPGGA");
727 if (i1 != -1) {
728 int i2 = data.indexOf("*", i1);
729 if (i2 != -1 && data.size() > i2 + 1) {
730 QByteArray gga = data.mid(i1,i2-i1+3);
731 _query->sendNMEA(gga);
732 }
733 }
734 }
735
736 if (_serialOutFile) {
737 _serialOutFile->write(data);
738 _serialOutFile->flush();
739 }
740 }
741 }
742}
743
744//
745//////////////////////////////////////////////////////////////////////////////
746void bncGetThread::slotNewEphGPS(gpsephemeris gpseph) {
747 RTCM2Decoder* decoder2 = dynamic_cast<RTCM2Decoder*>(decoder());
748 RTCM3Decoder* decoder3 = dynamic_cast<RTCM3Decoder*>(decoder());
749
750 if ( decoder2 ) {
751 QMutexLocker locker(&_mutex);
752
753 string storedPRN;
754 vector<int> IODs;
755
756 if ( decoder2->storeEph(gpseph, storedPRN, IODs) ) {
757#ifdef DEBUG_RTCM2_2021
758 QString msg = _staID + QString(": stored eph %1 IODs").arg(storedPRN.c_str());
759
760 for (unsigned ii = 0; ii < IODs.size(); ii++) {
761 msg += QString(" %1").arg(IODs[ii],4);
762 }
763
764 emit(newMessage(msg.toAscii()));
765#endif
766 }
767 }
768
769 if ( decoder3 ) {
770 QMutexLocker locker(&_mutex);
771
772 if ( decoder3->storeEph(gpseph) ) {
773#ifdef DEBUG_RTCM3
774 QString msg = _staID + QString(": RTCM3Decoder, stored eph for satellite %1").arg(gpseph.satellite);
775 emit(newMessage(msg.toAscii(),true));
776#endif
777 }
778 }
779}
780
Note: See TracBrowser for help on using the repository browser.