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

Last change on this file since 2864 was 2711, checked in by mervart, 14 years ago
File size: 19.8 KB
RevLine 
[280]1// Part of BNC, a utility for retrieving decoding and
[464]2// converting GNSS data streams from NTRIP broadcasters.
[280]3//
[464]4// Copyright (C) 2007
[280]5// German Federal Agency for Cartography and Geodesy (BKG)
6// http://www.bkg.bund.de
[464]7// Czech Technical University Prague, Department of Geodesy
[280]8// http://www.fsv.cvut.cz
9//
10// Email: euref-ip@bkg.bund.de
11//
12// This program is free software; you can redistribute it and/or
13// modify it under the terms of the GNU General Public License
14// as published by the Free Software Foundation, version 2.
15//
16// This program is distributed in the hope that it will be useful,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19// GNU General Public License for more details.
20//
21// You should have received a copy of the GNU General Public License
22// along with this program; if not, write to the Free Software
23// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
[35]24
25/* -------------------------------------------------------------------------
[93]26 * BKG NTRIP Client
[35]27 * -------------------------------------------------------------------------
28 *
29 * Class: bncGetThread
30 *
31 * Purpose: Thread that retrieves data from NTRIP caster
32 *
33 * Author: L. Mervart
34 *
35 * Created: 24-Dec-2005
36 *
37 * Changes:
38 *
39 * -----------------------------------------------------------------------*/
40
[277]41#include <stdlib.h>
[1044]42#include <iomanip>
[1218]43#include <sstream>
[277]44
[35]45#include <QFile>
46#include <QTextStream>
47#include <QtNetwork>
[356]48#include <QTime>
[35]49
50#include "bncgetthread.h"
[192]51#include "bnctabledlg.h"
[243]52#include "bncapp.h"
[352]53#include "bncutils.h"
[408]54#include "bncrinex.h"
[423]55#include "bnczerodecoder.h"
[1621]56#include "bncnetqueryv0.h"
[1387]57#include "bncnetqueryv1.h"
58#include "bncnetqueryv2.h"
[1410]59#include "bncnetqueryrtp.h"
[1721]60#include "bncnetqueryudp.h"
[1779]61#include "bncnetqueryudp0.h"
[1753]62#include "bncnetquerys.h"
[1535]63#include "bncsettings.h"
[1558]64#include "latencychecker.h"
[2035]65#include "bncpppclient.h"
[65]66
[243]67#include "RTCM/RTCM2Decoder.h"
[297]68#include "RTCM3/RTCM3Decoder.h"
[293]69#include "RTIGS/RTIGSDecoder.h"
[1310]70#include "GPSS/gpssDecoder.h"
[1318]71#include "serial/qextserialport.h"
[35]72
73using namespace std;
74
[1143]75// Constructor 1
[35]76////////////////////////////////////////////////////////////////////////////
[2519]77bncGetThread::bncGetThread(bncRawFile* rawFile) {
[1138]78
[2519]79 _rawFile = rawFile;
80 _format = rawFile->format();
81 _staID = rawFile->staID();
82 _rawOutput = false;
[2390]83 _ntripVersion = "N";
84
[1555]85 initialize();
[1138]86}
87
[1143]88// Constructor 2
89////////////////////////////////////////////////////////////////////////////
[278]90bncGetThread::bncGetThread(const QUrl& mountPoint,
[366]91 const QByteArray& format,
92 const QByteArray& latitude,
93 const QByteArray& longitude,
[1353]94 const QByteArray& nmea,
[1770]95 const QByteArray& ntripVersion, const QByteArray& extraStaID) {
[2519]96 _rawFile = 0;
[1555]97 _mountPoint = mountPoint;
[1770]98 _staID = (extraStaID.size() == 0 ? mountPoint.path().mid(1).toAscii() : extraStaID);
[1555]99 _format = format;
100 _latitude = latitude;
101 _longitude = longitude;
102 _nmea = nmea;
[1353]103 _ntripVersion = ntripVersion;
[1139]104
[2386]105 bncSettings settings;
106 if (!settings.value("rawOutFile").toString().isEmpty()) {
107 _rawOutput = true;
108 }
109
[1139]110 initialize();
111}
112
[1555]113// Initialization (common part of the constructor)
[1143]114////////////////////////////////////////////////////////////////////////////
[1139]115void bncGetThread::initialize() {
116
[1555]117 setTerminationEnabled(true);
118
[1225]119 bncApp* app = (bncApp*) qApp;
120
[1555]121 connect(this, SIGNAL(newMessage(QByteArray,bool)),
122 app, SLOT(slotMessage(const QByteArray,bool)));
123
[1525]124 _isToBeDeleted = false;
[1555]125 _decoder = 0;
126 _query = 0;
127 _nextSleep = 0;
[2035]128 _PPPclient = 0;
[255]129
[1574]130 bncSettings settings;
[1595]131
[1574]132 _miscMount = settings.value("miscMount").toString();
133
[408]134 // RINEX writer
135 // ------------
136 _samplingRate = settings.value("rnxSampl").toInt();
137 if ( settings.value("rnxPath").toString().isEmpty() ) {
138 _rnx = 0;
139 }
140 else {
[1353]141 _rnx = new bncRinex(_staID, _mountPoint, _format, _latitude,
[1639]142 _longitude, _nmea, _ntripVersion);
[408]143 }
144
[1555]145 // Serial Port
146 // -----------
[1710]147 _serialNMEA = NO_NMEA;
148 _serialOutFile = 0;
149 _serialPort = 0;
150
[1327]151 if (settings.value("serialMountPoint").toString() == _staID) {
[1710]152 _serialPort = new QextSerialPort(settings.value("serialPortName").toString() );
153 _serialPort->setTimeout(0,100);
154
155 // Baud Rate
156 // ---------
[1330]157 QString hlp = settings.value("serialBaudRate").toString();
158 if (hlp == "110") {
159 _serialPort->setBaudRate(BAUD110);
160 }
161 else if (hlp == "300") {
162 _serialPort->setBaudRate(BAUD300);
163 }
164 else if (hlp == "600") {
165 _serialPort->setBaudRate(BAUD600);
166 }
167 else if (hlp == "1200") {
168 _serialPort->setBaudRate(BAUD1200);
169 }
170 else if (hlp == "2400") {
171 _serialPort->setBaudRate(BAUD2400);
172 }
173 else if (hlp == "4800") {
174 _serialPort->setBaudRate(BAUD4800);
175 }
176 else if (hlp == "9600") {
177 _serialPort->setBaudRate(BAUD9600);
178 }
179 else if (hlp == "19200") {
180 _serialPort->setBaudRate(BAUD19200);
181 }
182 else if (hlp == "38400") {
183 _serialPort->setBaudRate(BAUD38400);
184 }
185 else if (hlp == "57600") {
186 _serialPort->setBaudRate(BAUD57600);
187 }
188 else if (hlp == "115200") {
189 _serialPort->setBaudRate(BAUD115200);
190 }
[1710]191
192 // Parity
193 // ------
[1330]194 hlp = settings.value("serialParity").toString();
195 if (hlp == "NONE") {
196 _serialPort->setParity(PAR_NONE);
197 }
198 else if (hlp == "ODD") {
199 _serialPort->setParity(PAR_ODD);
200 }
201 else if (hlp == "EVEN") {
202 _serialPort->setParity(PAR_EVEN);
203 }
204 else if (hlp == "SPACE") {
205 _serialPort->setParity(PAR_SPACE);
206 }
[1710]207
208 // Data Bits
209 // ---------
[1330]210 hlp = settings.value("serialDataBits").toString();
211 if (hlp == "5") {
212 _serialPort->setDataBits(DATA_5);
213 }
214 else if (hlp == "6") {
215 _serialPort->setDataBits(DATA_6);
216 }
217 else if (hlp == "7") {
218 _serialPort->setDataBits(DATA_7);
219 }
220 else if (hlp == "8") {
221 _serialPort->setDataBits(DATA_8);
222 }
223 hlp = settings.value("serialStopBits").toString();
224 if (hlp == "1") {
225 _serialPort->setStopBits(STOP_1);
226 }
227 else if (hlp == "2") {
228 _serialPort->setStopBits(STOP_2);
229 }
[1710]230
231 // Flow Control
232 // ------------
233 hlp = settings.value("serialFlowControl").toString();
[1711]234 if (hlp == "XONXOFF") {
[1710]235 _serialPort->setFlowControl(FLOW_XONXOFF);
236 }
237 else if (hlp == "HARDWARE") {
238 _serialPort->setFlowControl(FLOW_HARDWARE);
239 }
[1711]240 else {
241 _serialPort->setFlowControl(FLOW_OFF);
242 }
[1710]243
244 // Open Serial Port
245 // ----------------
[1326]246 _serialPort->open(QIODevice::ReadWrite|QIODevice::Unbuffered);
[1331]247 if (!_serialPort->isOpen()) {
248 delete _serialPort;
249 _serialPort = 0;
[1451]250 emit(newMessage((_staID + ": Cannot open serial port\n"), true));
[1331]251 }
[1606]252 connect(_serialPort, SIGNAL(readyRead()),
253 this, SLOT(slotSerialReadyRead()));
254
[1710]255 // Automatic NMEA
256 // --------------
257 if (settings.value("serialAutoNMEA").toString() == "Auto") {
258 _serialNMEA = AUTO_NMEA;
259
260 QString fName = settings.value("serialFileNMEA").toString();
261 if (!fName.isEmpty()) {
262 _serialOutFile = new QFile(fName);
263 if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) {
264 _serialOutFile->open(QIODevice::WriteOnly | QIODevice::Append);
265 }
266 else {
267 _serialOutFile->open(QIODevice::WriteOnly);
268 }
[1634]269 }
[1606]270 }
[1710]271
272 // Manual NMEA
273 // -----------
274 else {
275 _serialNMEA = MANUAL_NMEA;
[1636]276 }
[1318]277 }
278
[2035]279 // Initialize PPP Client?
[2004]280 // ----------------------
[2290]281#ifndef MLS_SOFTWARE
[2004]282 if (settings.value("pppMount").toString() == _staID) {
[2035]283 _PPPclient = new bncPPPclient(_staID);
[2144]284 qRegisterMetaType<bncTime>("bncTime");
[2145]285 connect(_PPPclient, SIGNAL(newPosition(bncTime, double, double, double)),
286 this, SIGNAL(newPosition(bncTime, double, double, double)));
[2290]287 connect(_PPPclient, SIGNAL(newNMEAstr(QByteArray)),
288 this, SIGNAL(newNMEAstr(QByteArray)));
[2004]289 }
[2290]290#endif
[1555]291
292 // Instantiate the decoder
293 // -----------------------
[1744]294 if (_format.indexOf("RTCM_2") != -1 || _format.indexOf("RTCM2") != -1 ||
295 _format.indexOf("RTCM 2") != -1 ) {
[1555]296 emit(newMessage(_staID + ": Get data in RTCM 2.x format", true));
297 _decoder = new RTCM2Decoder(_staID.data());
298 }
[1744]299 else if (_format.indexOf("RTCM_3") != -1 || _format.indexOf("RTCM3") != -1 ||
300 _format.indexOf("RTCM 3") != -1 ) {
[1555]301 emit(newMessage(_staID + ": Get data in RTCM 3.x format", true));
[2527]302 _decoder = new RTCM3Decoder(_staID, _rawFile);
[1555]303 connect((RTCM3Decoder*) _decoder, SIGNAL(newMessage(QByteArray,bool)),
304 this, SIGNAL(newMessage(QByteArray,bool)));
305 }
306 else if (_format.indexOf("RTIGS") != -1) {
307 emit(newMessage(_staID + ": Get data in RTIGS format", true));
308 _decoder = new RTIGSDecoder();
309 }
310 else if (_format.indexOf("GPSS") != -1 || _format.indexOf("BNC") != -1) {
311 emit(newMessage(_staID + ": Get Data in GPSS format", true));
312 _decoder = new gpssDecoder();
313 }
314 else if (_format.indexOf("ZERO") != -1) {
315 emit(newMessage(_staID + ": Get data in original format", true));
316 _decoder = new bncZeroDecoder(_staID);
317 }
318 else {
319 emit(newMessage(_staID + ": Unknown data format " + _format, true));
320 _isToBeDeleted = true;
321 }
322
[1558]323 _latencyChecker = new latencyChecker(_staID);
[1557]324
[319]325 msleep(100); //sleep 0.1 sec
[35]326}
327
328// Destructor
329////////////////////////////////////////////////////////////////////////////
330bncGetThread::~bncGetThread() {
[1928]331 if (isRunning()) {
332 wait();
333 }
[1527]334 if (_query) {
335 _query->stop();
[1708]336 _query->deleteLater();
[1527]337 }
[2035]338 delete _PPPclient;
[617]339 delete _decoder;
[1044]340 delete _rnx;
[2519]341 delete _rawFile;
[1607]342 delete _serialOutFile;
[1328]343 delete _serialPort;
[1557]344 delete _latencyChecker;
[1556]345 emit getThreadFinished(_staID);
[35]346}
347
[1390]348//
349////////////////////////////////////////////////////////////////////////////
350void bncGetThread::terminate() {
[1525]351 _isToBeDeleted = true;
[1559]352 if (!isRunning()) {
353 delete this;
354 }
[1390]355}
356
[136]357// Run
358////////////////////////////////////////////////////////////////////////////
359void bncGetThread::run() {
360
[35]361 while (true) {
[629]362 try {
[1555]363 if (_isToBeDeleted) {
364 QThread::exit(0);
365 this->deleteLater();
366 return;
[629]367 }
[621]368
[1555]369 if (tryReconnect() != success) {
[1572]370 _latencyChecker->checkReconnect();
[1555]371 continue;
[621]372 }
[1555]373
374 // Delete old observations
375 // -----------------------
[621]376 _decoder->_obsList.clear();
377
[1555]378 // Read Data
379 // ---------
[1377]380 QByteArray data;
381 if (_query) {
382 _query->waitForReadyRead(data);
[1138]383 }
[2519]384 else if (_rawFile) {
[2527]385 data = _rawFile->readChunk();
[2388]386
[1555]387 if (data.isEmpty()) {
388 cout << "no more data" << endl;
[2525]389 QThread::exit(0);
390 this->deleteLater();
391 return;
[1555]392 }
[1138]393 }
[1555]394 qint64 nBytes = data.size();
[1138]395
[1555]396 // Timeout, reconnect
397 // ------------------
398 if (nBytes == 0) {
[1576]399 _latencyChecker->checkReconnect();
[1555]400 emit(newMessage(_staID + ": Data timeout, reconnecting", true));
[2355]401 msleep(10000); //sleep 10 sec, G. Weber
[1555]402 continue;
403 }
404 else {
[567]405 emit newBytes(_staID, nBytes);
[1555]406 }
[567]407
[1555]408 // Output Data
409 // -----------
[2386]410 if (_rawOutput) {
411 bncApp* app = (bncApp*) qApp;
[2518]412 app->writeRawData(data, _staID, _format);
[2386]413 }
[2385]414
[1555]415 if (_serialPort) {
[1633]416 slotSerialReadyRead();
[1555]417 _serialPort->write(data);
418 }
419
420 // Decode Data
421 // -----------
422 vector<string> errmsg;
[1562]423 t_irc irc = _decoder->Decode(data.data(), data.size(), errmsg);
[1137]424
[1555]425 // Perform various scans and checks
426 // --------------------------------
[1562]427 _latencyChecker->checkOutage(irc == success);
428 _latencyChecker->checkObsLatency(_decoder->_obsList);
[1567]429 _latencyChecker->checkCorrLatency(_decoder->corrGPSEpochTime());
430
[1973]431 emit newLatency(_staID, _latencyChecker->currentLatency());
[1969]432
[1555]433 scanRTCM();
[1138]434
[1555]435 // Loop over all observations (observations output)
436 // ------------------------------------------------
[2711]437 QListIterator<t_obs> it(_decoder->_obsList);
438 bool firstObs = true;
[1555]439 while (it.hasNext()) {
[2711]440 const t_obs& obs = it.next();
441
[1555]442 // Check observation epoch
443 // -----------------------
[2519]444 if (!_rawFile && !dynamic_cast<gpssDecoder*>(_decoder)) {
[1555]445 int week;
446 double sec;
447 currentGPSWeeks(week, sec);
448 const double secPerWeek = 7.0 * 24.0 * 3600.0;
449
[2711]450 double currSec = week * secPerWeek + sec;
451 double obsSec = obs.GPSWeek * secPerWeek + obs.GPSWeeks;
[2488]452
[1555]453 const double maxDt = 600.0;
[2488]454
455 if (fabs(currSec - obsSec) > maxDt) {
[2308]456 emit( newMessage(_staID + ": Wrong observation epoch(s)", false) );
[1555]457 continue;
[940]458 }
[686]459 }
[1555]460
461 // RINEX Output
462 // ------------
463 if (_rnx) {
[2711]464 long iSec = long(floor(obs.GPSWeeks+0.5));
465 long newTime = obs.GPSWeek * 7*24*3600 + iSec;
[1555]466 if (_samplingRate == 0 || iSec % _samplingRate == 0) {
467 _rnx->deepCopy(obs);
[1271]468 }
[1555]469 _rnx->dumpEpoch(newTime);
[1271]470 }
[1555]471
[2030]472 // PPP Client
473 // ----------
[2290]474#ifndef MLS_SOFTWARE
[2035]475 if (_PPPclient) {
476 _PPPclient->putNewObs(obs);
[2030]477 }
[2290]478#endif
[2030]479
[1555]480 // Emit new observation signal
481 // ---------------------------
[2711]482 if (!_isToBeDeleted) {
483 emit newObs(_staID, firstObs, obs);
484 }
485 firstObs = false;
[249]486 }
[1555]487 _decoder->_obsList.clear();
[35]488 }
[1555]489 catch (...) {
[1559]490 emit(newMessage(_staID + "bncGetThread exception", true));
491 _isToBeDeleted = true;
[1555]492 }
[35]493 }
494}
495
[136]496// Try Re-Connect
497////////////////////////////////////////////////////////////////////////////
[1555]498t_irc bncGetThread::tryReconnect() {
499
500 // Easy Return
501 // -----------
502 if (_query && _query->status() == bncNetQuery::running) {
503 _nextSleep = 0;
[1709]504 if (_rnx) {
505 _rnx->setReconnectFlag(false);
506 }
[1555]507 return success;
[408]508 }
[1555]509
510 // Start a new query
511 // -----------------
[2519]512 if (!_rawFile) {
[1555]513
[138]514 sleep(_nextSleep);
[1555]515 if (_nextSleep == 0) {
516 _nextSleep = 1;
[138]517 }
518 else {
[1555]519 _nextSleep = 2 * _nextSleep;
[442]520 if (_nextSleep > 256) {
521 _nextSleep = 256;
[152]522 }
[1816]523#ifdef MLS_SOFTWARE
[1817]524 if (_nextSleep > 4) {
525 _nextSleep = 4;
[1816]526 }
527#endif
[138]528 }
[1555]529
530 delete _query;
[1722]531 if (_ntripVersion == "U") {
[1721]532 _query = new bncNetQueryUdp();
533 }
[1722]534 else if (_ntripVersion == "R") {
[1555]535 _query = new bncNetQueryRtp();
536 }
[1744]537 else if (_ntripVersion == "S") {
[1753]538 _query = new bncNetQueryS();
[1744]539 }
[1621]540 else if (_ntripVersion == "N") {
541 _query = new bncNetQueryV0();
542 }
[1779]543 else if (_ntripVersion == "UN") {
544 _query = new bncNetQueryUdp0();
545 }
[1555]546 else if (_ntripVersion == "2") {
547 _query = new bncNetQueryV2();
548 }
549 else {
550 _query = new bncNetQueryV1();
551 }
[1710]552 if (_nmea == "yes" && _serialNMEA != AUTO_NMEA) {
553 QByteArray gga = ggaString(_latitude, _longitude, "100.0");
[1555]554 _query->startRequest(_mountPoint, gga);
555 }
556 else {
557 _query->startRequest(_mountPoint, "");
558 }
559 if (_query->status() != bncNetQuery::running) {
560 return failure;
561 }
[138]562 }
[658]563
[1555]564 if (_rnx) {
565 _rnx->setReconnectFlag(true);
[658]566 }
[1555]567
568 return success;
[658]569}
[1044]570
[1555]571// RTCM scan output
[1044]572//////////////////////////////////////////////////////////////////////////////
[1555]573void bncGetThread::scanRTCM() {
[1044]574
[1555]575 bncSettings settings;
[1574]576 if ( Qt::CheckState(settings.value("scanRTCM").toInt()) == Qt::Checked ) {
577
578 if ( _miscMount == _staID || _miscMount == "ALL" ) {
579
[1575]580 // RTCM message types
581 // ------------------
[1574]582 for (int ii = 0; ii <_decoder->_typeList.size(); ii++) {
583 QString type = QString("%1 ").arg(_decoder->_typeList[ii]);
584 emit(newMessage(_staID + ": Received message type " + type.toAscii(), true));
585 }
[1044]586
[1574]587 // RTCMv3 antenna descriptor
588 // -------------------------
589 for (int ii=0;ii<_decoder->_antType.size();ii++) {
590 QString ant1 = QString("%1 ").arg(_decoder->_antType[ii]);
591 emit(newMessage(_staID + ": Antenna descriptor " + ant1.toAscii(), true));
592 }
[1555]593
[1575]594 // RTCM Antenna Coordinates
595 // ------------------------
[1574]596 for (int ii=0; ii <_decoder->_antList.size(); ii++) {
597 QByteArray antT;
598 if (_decoder->_antList[ii].type == GPSDecoder::t_antInfo::ARP) {
599 antT = "ARP";
600 }
601 else if (_decoder->_antList[ii].type == GPSDecoder::t_antInfo::APC) {
602 antT = "APC";
603 }
[1575]604 QByteArray ant1, ant2, ant3;
605 ant1 = QString("%1 ").arg(_decoder->_antList[ii].xx,0,'f',4).toAscii();
606 ant2 = QString("%1 ").arg(_decoder->_antList[ii].yy,0,'f',4).toAscii();
607 ant3 = QString("%1 ").arg(_decoder->_antList[ii].zz,0,'f',4).toAscii();
608 emit(newMessage(_staID + ": " + antT + " (ITRF) X " + ant1 + "m", true));
609 emit(newMessage(_staID + ": " + antT + " (ITRF) Y " + ant2 + "m", true));
610 emit(newMessage(_staID + ": " + antT + " (ITRF) Z " + ant3 + "m", true));
611 if (_decoder->_antList[ii].height_f) {
612 QByteArray ant4 = QString("%1 ").arg(_decoder->_antList[ii].height,0,'f',4).toAscii();
613 emit(newMessage(_staID + ": Antenna height above marker " + ant4 + "m", true));
614 }
[1574]615 emit(newAntCrd(_staID, _decoder->_antList[ii].xx,
616 _decoder->_antList[ii].yy, _decoder->_antList[ii].zz,
617 antT));
[1218]618 }
619 }
[1044]620 }
[1575]621
[1770]622#ifdef MLS_SOFTWARE
623 for (int ii=0; ii <_decoder->_antList.size(); ii++) {
624 QByteArray antT;
625 if (_decoder->_antList[ii].type == GPSDecoder::t_antInfo::ARP) {
626 antT = "ARP";
627 }
628 else if (_decoder->_antList[ii].type == GPSDecoder::t_antInfo::APC) {
629 antT = "APC";
630 }
631 emit(newAntCrd(_staID, _decoder->_antList[ii].xx,
632 _decoder->_antList[ii].yy, _decoder->_antList[ii].zz,
633 antT));
634 }
[2356]635
636 for (int ii = 0; ii <_decoder->_typeList.size(); ii++) {
637 emit(newRTCMMessage(_staID, _decoder->_typeList[ii]));
638 }
[1770]639#endif
640
641
642
643
[1555]644 _decoder->_typeList.clear();
645 _decoder->_antType.clear();
646 _decoder->_antList.clear();
[1044]647}
[1555]648
[1606]649// Handle Data from Serial Port
650////////////////////////////////////////////////////////////////////////////
651void bncGetThread::slotSerialReadyRead() {
[1607]652 if (_serialPort) {
[1633]653 int nb = _serialPort->bytesAvailable();
654 if (nb > 0) {
655 QByteArray data = _serialPort->read(nb);
[1711]656
657 if (_serialNMEA == AUTO_NMEA) {
[1725]658 int i1 = data.indexOf("$GPGGA");
659 if (i1 != -1) {
660 int i2 = data.indexOf("*", i1);
661 if (i2 != -1 && data.size() > i2 + 1) {
662 QByteArray gga = data.mid(i1,i2-i1+3);
663 _query->sendNMEA(gga);
664 }
665 }
[1711]666 }
667
[1633]668 if (_serialOutFile) {
669 _serialOutFile->write(data);
670 _serialOutFile->flush();
671 }
[1607]672 }
673 }
[1606]674}
[1768]675
676//
677//////////////////////////////////////////////////////////////////////////////
678void bncGetThread::slotNewEphGPS(gpsephemeris gpseph) {
[1807]679 RTCM2Decoder* decoder2 = dynamic_cast<RTCM2Decoder*>(_decoder);
680 RTCM3Decoder* decoder3 = dynamic_cast<RTCM3Decoder*>(_decoder);
[1768]681
[1807]682 if ( decoder2 ) {
[1768]683 QMutexLocker locker(&_mutex);
684
685 string storedPRN;
686 vector<int> IODs;
687
[1807]688 if ( decoder2->storeEph(gpseph, storedPRN, IODs) ) {
[1768]689#ifdef DEBUG_RTCM2_2021
690 QString msg = _staID + QString(": stored eph %1 IODs").arg(storedPRN.c_str());
691
692 for (unsigned ii = 0; ii < IODs.size(); ii++) {
693 msg += QString(" %1").arg(IODs[ii],4);
694 }
695
696 emit(newMessage(msg.toAscii()));
697#endif
698 }
699 }
[1807]700
701 if ( decoder3 ) {
702 QMutexLocker locker(&_mutex);
703
704 if ( decoder3->storeEph(gpseph) ) {
[1813]705#ifdef DEBUG_RTCM3
[1807]706 QString msg = _staID + QString(": RTCM3Decoder, stored eph for satellite %1").arg(gpseph.satellite);
707 emit(newMessage(msg.toAscii(),true));
[1813]708#endif
[1807]709 }
710 }
[1768]711}
712
Note: See TracBrowser for help on using the repository browser.