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

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