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

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