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

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