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

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