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

Last change on this file since 6663 was 6651, checked in by weber, 10 years ago

Upload of NMEA GNGGA string added

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