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

Last change on this file since 2450 was 2390, checked in by mervart, 14 years ago

* empty log message *

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