source: ntrip/trunk/BNC/src/bncgetthread.cpp@ 5163

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