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

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