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

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