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

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