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

Last change on this file since 6912 was 6864, checked in by stuerze, 9 years ago

scanning of GLONASS slots is added

File size: 25.4 KB
Line 
1// Part of BNC, a utility for retrieving decoding and
2// converting GNSS data streams from NTRIP broadcasters.
3//
4// Copyright (C) 2007
5// German Federal Agency for Cartography and Geodesy (BKG)
6// http://www.bkg.bund.de
7// Czech Technical University Prague, Department of Geodesy
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.
24
25/* -------------------------------------------------------------------------
26 * BKG NTRIP Client
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
41#include <stdlib.h>
42#include <iomanip>
43#include <sstream>
44
45#include <QFile>
46#include <QTextStream>
47#include <QMutex>
48#include <QtNetwork>
49#include <QTime>
50
51#include "bncgetthread.h"
52#include "bnctabledlg.h"
53#include "bnccore.h"
54#include "bncutils.h"
55#include "bnczerodecoder.h"
56#include "bncnetqueryv0.h"
57#include "bncnetqueryv1.h"
58#include "bncnetqueryv2.h"
59#include "bncnetqueryrtp.h"
60#include "bncnetqueryudp.h"
61#include "bncnetqueryudp0.h"
62#include "bncnetquerys.h"
63#include "bncsettings.h"
64#include "latencychecker.h"
65#include "upload/bncrtnetdecoder.h"
66#include "RTCM/RTCM2Decoder.h"
67#include "RTCM3/RTCM3Decoder.h"
68#include "serial/qextserialport.h"
69
70using namespace std;
71
72// Constructor 1
73////////////////////////////////////////////////////////////////////////////
74bncGetThread::bncGetThread(bncRawFile* rawFile) {
75
76 _rawFile = rawFile;
77 _format = rawFile->format();
78 _staID = rawFile->staID();
79 _rawOutput = false;
80 _ntripVersion = "N";
81
82 initialize();
83}
84
85// Constructor 2
86////////////////////////////////////////////////////////////////////////////
87bncGetThread::bncGetThread(const QUrl& mountPoint,
88 const QByteArray& format,
89 const QByteArray& latitude,
90 const QByteArray& longitude,
91 const QByteArray& nmea,
92 const QByteArray& ntripVersion) {
93 _rawFile = 0;
94 _mountPoint = mountPoint;
95 _staID = mountPoint.path().mid(1).toAscii();
96 _format = format;
97 _latitude = latitude;
98 _longitude = longitude;
99 _nmea = nmea;
100 _ntripVersion = ntripVersion;
101
102 bncSettings settings;
103 if (!settings.value("rawOutFile").toString().isEmpty()) {
104 _rawOutput = true;
105 } else {
106 _rawOutput = false;
107 }
108
109 initialize();
110 initDecoder();
111}
112
113// Initialization (common part of the constructor)
114////////////////////////////////////////////////////////////////////////////
115void bncGetThread::initialize() {
116
117 bncSettings settings;
118
119 setTerminationEnabled(true);
120
121 connect(this, SIGNAL(newMessage(QByteArray,bool)),
122 BNC_CORE, SLOT(slotMessage(const QByteArray,bool)));
123
124 _isToBeDeleted = false;
125 _query = 0;
126 _nextSleep = 0;
127 _miscMount = settings.value("miscMount").toString();
128 _decoder = 0;
129
130 // Serial Port
131 // -----------
132 _serialNMEA = NO_NMEA;
133 _serialOutFile = 0;
134 _serialPort = 0;
135
136 if (!_staID.isEmpty() &&
137 settings.value("serialMountPoint").toString() == _staID) {
138 _serialPort = new QextSerialPort(settings.value("serialPortName").toString() );
139 _serialPort->setTimeout(0,100);
140
141 // Baud Rate
142 // ---------
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 }
177
178 // Parity
179 // ------
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 }
193
194 // Data Bits
195 // ---------
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 }
216
217 // Flow Control
218 // ------------
219 hlp = settings.value("serialFlowControl").toString();
220 if (hlp == "XONXOFF") {
221 _serialPort->setFlowControl(FLOW_XONXOFF);
222 }
223 else if (hlp == "HARDWARE") {
224 _serialPort->setFlowControl(FLOW_HARDWARE);
225 }
226 else {
227 _serialPort->setFlowControl(FLOW_OFF);
228 }
229
230 // Open Serial Port
231 // ----------------
232 _serialPort->open(QIODevice::ReadWrite|QIODevice::Unbuffered);
233 if (!_serialPort->isOpen()) {
234 delete _serialPort;
235 _serialPort = 0;
236 emit(newMessage((_staID + ": Cannot open serial port\n"), true));
237 }
238 connect(_serialPort, SIGNAL(readyRead()),
239 this, SLOT(slotSerialReadyRead()));
240
241 // Automatic NMEA
242 // --------------
243 QString nmeaMode = settings.value("serialAutoNMEA").toString();
244 if (nmeaMode == "Auto") {
245 _serialNMEA = AUTO_NMEA;
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 }
255 }
256 }
257 // Manual NMEA
258 // -----------
259 if ((nmeaMode == "Manual GPGGA") ||(nmeaMode == "Manual GNGGA")) {
260 _serialNMEA = MANUAL_NMEA;
261 bncSettings settings;
262 _manualNMEASampl = settings.value("serialManualNMEASampling").toInt();
263 QString hlp = settings.value("serialHeightNMEA").toString();
264 if (hlp.isEmpty()) {
265 hlp = "0.0";
266 }
267 QByteArray _serialHeightNMEA = hlp.toAscii();
268 _manualNMEAString = ggaString(_latitude, _longitude, _serialHeightNMEA, nmeaMode);
269 }
270 }
271
272 if (!_staID.isEmpty()) {
273 _latencyChecker = new latencyChecker(_staID);
274 }
275 else {
276 _latencyChecker = 0;
277 }
278}
279
280// Instantiate the decoder
281//////////////////////////////////////////////////////////////////////////////
282t_irc bncGetThread::initDecoder() {
283
284 _decoder = 0;
285
286 if (_format.indexOf("RTCM_2") != -1 || _format.indexOf("RTCM2") != -1 ||
287 _format.indexOf("RTCM 2") != -1 ) {
288 emit(newMessage(_staID + ": Get data in RTCM 2.x format", true));
289 _decoder = new RTCM2Decoder(_staID.data());
290 }
291 else if (_format.indexOf("RTCM_3") != -1 || _format.indexOf("RTCM3") != -1 ||
292 _format.indexOf("RTCM 3") != -1 ) {
293 emit(newMessage(_staID + ": Get data in RTCM 3.x format", true));
294 RTCM3Decoder* newDecoder = new RTCM3Decoder(_staID, _rawFile);
295 _decoder = newDecoder;
296 connect((RTCM3Decoder*) newDecoder, SIGNAL(newMessage(QByteArray,bool)),
297 this, SIGNAL(newMessage(QByteArray,bool)));
298 }
299 else if (_format.indexOf("ZERO") != -1) {
300 emit(newMessage(_staID + ": Get data in original format", true));
301 _decoder = new bncZeroDecoder(_staID);
302 }
303 else if (_format.indexOf("RTNET") != -1) {
304 emit(newMessage(_staID + ": Get data in RTNet format", true));
305 _decoder = new bncRtnetDecoder();
306 }
307 else {
308 emit(newMessage(_staID + ": Unknown data format " + _format, true));
309 _isToBeDeleted = true;
310 return failure;
311 }
312
313 msleep(100); //sleep 0.1 sec
314
315 _decoder->initRinex(_staID, _mountPoint, _latitude, _longitude,
316 _nmea, _ntripVersion);
317
318 if (_rawFile) {
319 _decodersRaw[_staID] = _decoder;
320 }
321
322 return success;
323}
324
325// Current decoder in use
326////////////////////////////////////////////////////////////////////////////
327GPSDecoder* bncGetThread::decoder() {
328 if (!_rawFile) {
329 return _decoder;
330 }
331 else {
332 if (_decodersRaw.contains(_staID) || initDecoder() == success) {
333 return _decodersRaw[_staID];
334 }
335 }
336 return 0;
337}
338
339// Destructor
340////////////////////////////////////////////////////////////////////////////
341bncGetThread::~bncGetThread() {
342 if (isRunning()) {
343 wait();
344 }
345 if (_query) {
346 _query->stop();
347 _query->deleteLater();
348 }
349 if (_rawFile) {
350 QMapIterator<QString, GPSDecoder*> it(_decodersRaw);
351 while (it.hasNext()) {
352 it.next();
353 delete it.value();
354 }
355 }
356 else {
357 delete _decoder;
358 }
359 delete _rawFile;
360 delete _serialOutFile;
361 delete _serialPort;
362 delete _latencyChecker;
363 emit getThreadFinished(_staID);
364}
365
366//
367////////////////////////////////////////////////////////////////////////////
368void bncGetThread::terminate() {
369 _isToBeDeleted = true;
370 if (!isRunning()) {
371 delete this;
372 }
373}
374
375// Run
376////////////////////////////////////////////////////////////////////////////
377void bncGetThread::run() {
378
379 while (true) {
380 try {
381 if (_isToBeDeleted) {
382 QThread::exit(0);
383 this->deleteLater();
384 return;
385 }
386
387 if (tryReconnect() != success) {
388 if (_latencyChecker) {
389 _latencyChecker->checkReconnect();
390 }
391 continue;
392 }
393
394 // Delete old observations
395 // -----------------------
396 if (_rawFile) {
397 QMapIterator<QString, GPSDecoder*> itDec(_decodersRaw);
398 while (itDec.hasNext()) {
399 itDec.next();
400 GPSDecoder* decoder = itDec.value();
401 decoder->_obsList.clear();
402 }
403 }
404 else {
405 _decoder->_obsList.clear();
406 }
407
408 // Read Data
409 // ---------
410 QByteArray data;
411 if (_query) {
412 _query->waitForReadyRead(data);
413 }
414 else if (_rawFile) {
415 data = _rawFile->readChunk();
416 _format = _rawFile->format();
417 _staID = _rawFile->staID();
418
419 QCoreApplication::processEvents();
420
421 if (data.isEmpty()) {
422 cout << "no more data" << endl;
423 BNC_CORE->stopCombination();
424 BNC_CORE->stopPPP();
425 ::exit(0);
426 }
427 }
428 qint64 nBytes = data.size();
429
430 // Timeout, reconnect
431 // ------------------
432 if (nBytes == 0) {
433 if (_latencyChecker) {
434 _latencyChecker->checkReconnect();
435 }
436 emit(newMessage(_staID + ": Data timeout, reconnecting", true));
437 msleep(10000); //sleep 10 sec, G. Weber
438 continue;
439 }
440 else {
441 emit newBytes(_staID, nBytes);
442 emit newRawData(_staID, data);
443 }
444
445 // Output Data
446 // -----------
447 if (_rawOutput) {
448 BNC_CORE->writeRawData(data, _staID, _format);
449 }
450
451 if (_serialPort) {
452 slotSerialReadyRead();
453 _serialPort->write(data);
454 }
455
456 // Decode Data
457 // -----------
458 vector<string> errmsg;
459 if (!decoder()) {
460 _isToBeDeleted = true;
461 continue;
462 }
463 decoder()->_obsList.clear();
464 t_irc irc = decoder()->Decode(data.data(), data.size(), errmsg);
465
466 // Perform various scans and checks
467 // --------------------------------
468 if (_latencyChecker) {
469 _latencyChecker->checkOutage(irc == success);
470 _latencyChecker->checkObsLatency(decoder()->_obsList);
471 _latencyChecker->checkCorrLatency(decoder()->corrGPSEpochTime());
472
473 emit newLatency(_staID, _latencyChecker->currentLatency());
474 }
475
476 scanRTCM();
477
478 // Loop over all observations (observations output)
479 // ------------------------------------------------
480 QListIterator<t_satObs> it(decoder()->_obsList);
481
482 QList<t_satObs> obsListHlp;
483
484 while (it.hasNext()) {
485 const t_satObs& obs = it.next();
486
487 QString prn(obs._prn.toString().c_str());
488 long iSec = long(floor(obs._time.gpssec()+0.5));
489 long obsTime = obs._time.gpsw()*7*24*3600 + iSec;
490
491 // Check observation epoch
492 // -----------------------
493 if (!_rawFile) {
494 int week;
495 double sec;
496 currentGPSWeeks(week, sec);
497 long currTime = week * 7*24*3600 + long(sec);
498 const double maxDt = 600.0;
499 if (fabs(currTime - obsTime) > maxDt) {
500 emit( newMessage(_staID + ": Wrong observation epoch(s)", false) );
501 continue;
502 }
503 }
504
505 // Check observations coming twice (e.g. KOUR0 Problem)
506 // ----------------------------------------------------
507 if (!_rawFile) {
508 QMap<QString, long>::const_iterator it = _prnLastEpo.find(prn);
509 if (it != _prnLastEpo.end()) {
510 long oldTime = it.value();
511 if (obsTime < oldTime) {
512 emit( newMessage(_staID +
513 ": old observation " + prn.toAscii(), false));
514 continue;
515 }
516 else if (obsTime == oldTime) {
517 emit( newMessage(_staID +
518 ": observation coming more than once " + prn.toAscii(), false));
519 continue;
520 }
521 }
522 _prnLastEpo[prn] = obsTime;
523 }
524
525 decoder()->dumpRinexEpoch(obs, _format);
526
527 // Save observations
528 // -----------------
529 obsListHlp.append(obs);
530 }
531
532 // Emit signal
533 // -----------
534 if (!_isToBeDeleted && obsListHlp.size() > 0) {
535 emit newObs(_staID, obsListHlp);
536 }
537
538 decoder()->_obsList.clear();
539 }
540 catch (Exception& exc) {
541 emit(newMessage(_staID + " " + exc.what(), true));
542 _isToBeDeleted = true;
543 }
544 catch (...) {
545 emit(newMessage(_staID + " bncGetThread exception", true));
546 _isToBeDeleted = true;
547 }
548 }
549}
550
551// Try Re-Connect
552////////////////////////////////////////////////////////////////////////////
553t_irc bncGetThread::tryReconnect() {
554
555 // Easy Return
556 // -----------
557 if (_query && _query->status() == bncNetQuery::running) {
558 _nextSleep = 0;
559 if (_rawFile) {
560 QMapIterator<QString, GPSDecoder*> itDec(_decodersRaw);
561 while (itDec.hasNext()) {
562 itDec.next();
563 GPSDecoder* decoder = itDec.value();
564 decoder->setRinexReconnectFlag(false);
565 }
566 }
567 else {
568 _decoder->setRinexReconnectFlag(false);
569 }
570 return success;
571 }
572
573 // Start a new query
574 // -----------------
575 if (!_rawFile) {
576
577 sleep(_nextSleep);
578 if (_nextSleep == 0) {
579 _nextSleep = 1;
580 }
581 else {
582 _nextSleep = 2 * _nextSleep;
583 if (_nextSleep > 256) {
584 _nextSleep = 256;
585 }
586#ifdef MLS_SOFTWARE
587 if (_nextSleep > 4) {
588 _nextSleep = 4;
589 }
590#endif
591 }
592
593 delete _query;
594 if (_ntripVersion == "U") {
595 _query = new bncNetQueryUdp();
596 }
597 else if (_ntripVersion == "R") {
598 _query = new bncNetQueryRtp();
599 }
600 else if (_ntripVersion == "S") {
601 _query = new bncNetQueryS();
602 }
603 else if (_ntripVersion == "N") {
604 _query = new bncNetQueryV0();
605 }
606 else if (_ntripVersion == "UN") {
607 _query = new bncNetQueryUdp0();
608 }
609 else if (_ntripVersion == "2") {
610 _query = new bncNetQueryV2(false);
611 }
612 else if (_ntripVersion == "2s") {
613 _query = new bncNetQueryV2(true);
614 }
615 else {
616 _query = new bncNetQueryV1();
617 }
618 if (_nmea == "yes") {
619 if (_serialNMEA == MANUAL_NMEA) {
620 _query->startRequest(_mountPoint, _manualNMEAString);
621 _lastManualNMEA = QDateTime::currentDateTime();
622 }
623 else if (_serialNMEA == AUTO_NMEA) {
624 if (_serialPort) {
625 int nb = _serialPort->bytesAvailable();
626 if (nb > 0) {
627 QByteArray data = _serialPort->read(nb);
628 int i1 = data.indexOf("$GPGGA");
629 if (i1 == -1) {
630 i1 = data.indexOf("$GNGGA");
631 }
632 if (i1 != -1) {
633 int i2 = data.indexOf("*", i1);
634 if (i2 != -1 && data.size() > i2 + 1) {
635 QByteArray gga = data.mid(i1, i2 - i1 + 3);
636 _query->startRequest(_mountPoint, gga);
637 }
638 }
639 }
640 }
641 }
642 }
643 else {
644 _query->startRequest(_mountPoint, "");
645 }
646
647 if (_query->status() != bncNetQuery::running) {
648 return failure;
649 }
650 }
651
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 }
659 }
660 else {
661 _decoder->setRinexReconnectFlag(false);
662 }
663
664 return success;
665}
666
667// RTCM scan output
668//////////////////////////////////////////////////////////////////////////////
669void bncGetThread::scanRTCM() {
670
671 if ( !decoder() ) {
672 return;
673 }
674
675 bncSettings settings;
676 if ( Qt::CheckState(settings.value("scanRTCM").toInt()) == Qt::Checked ) {
677
678 if ( _miscMount == _staID || _miscMount == "ALL" ) {
679 // RTCM message types
680 // ------------------
681 for (int ii = 0; ii < decoder()->_typeList.size(); ii++) {
682 QString type = QString("%1 ").arg(decoder()->_typeList[ii]);
683 emit(newMessage(_staID + ": Received message type " + type.toAscii(), true));
684 }
685
686 // Check Observation Types
687 // -----------------------
688 for (int ii = 0; ii < decoder()->_obsList.size(); ii++) {
689 t_satObs& obs = decoder()->_obsList[ii];
690 QVector<QString>& rnxTypes = _rnxTypes[obs._prn.system()];
691 bool allFound = true;
692 for (unsigned iFrq = 0; iFrq < obs._obs.size(); iFrq++) {
693 if (obs._obs[iFrq]->_codeValid) {
694 QString rnxStr('C');
695 rnxStr.append(obs._obs[iFrq]->_rnxType2ch.c_str());
696 if (_format.indexOf("RTCM_2") != -1 ||
697 _format.indexOf("RTCM2") != -1 ||
698 _format.indexOf("RTCM 2") != -1 ) {
699 rnxStr = t_rnxObsFile::type3to2(obs._prn.system(), rnxStr);
700 }
701 if (rnxTypes.indexOf(rnxStr) == -1) {
702 rnxTypes.push_back(rnxStr);
703 allFound = false;
704 }
705 }
706 if (obs._obs[iFrq]->_phaseValid) {
707 QString rnxStr('L');
708 rnxStr.append(obs._obs[iFrq]->_rnxType2ch.c_str());
709 if (_format.indexOf("RTCM_2") != -1 ||
710 _format.indexOf("RTCM2") != -1 ||
711 _format.indexOf("RTCM 2") != -1 ) {
712 rnxStr = t_rnxObsFile::type3to2(obs._prn.system(), rnxStr);
713 }
714 if (rnxTypes.indexOf(rnxStr) == -1) {
715 rnxTypes.push_back(rnxStr);
716 allFound = false;
717 }
718 }
719 if (obs._obs[iFrq]->_dopplerValid){
720 QString rnxStr('D');
721 rnxStr.append(obs._obs[iFrq]->_rnxType2ch.c_str());
722 if (_format.indexOf("RTCM_2") != -1 ||
723 _format.indexOf("RTCM2") != -1 ||
724 _format.indexOf("RTCM 2") != -1 ) {
725 rnxStr = t_rnxObsFile::type3to2(obs._prn.system(), rnxStr);
726 }
727 if (rnxTypes.indexOf(rnxStr) == -1) {
728 rnxTypes.push_back(rnxStr);
729 allFound = false;
730 }
731 }
732 if (obs._obs[iFrq]->_snrValid){
733 QString rnxStr('S');
734 rnxStr.append(obs._obs[iFrq]->_rnxType2ch.c_str());
735 if (_format.indexOf("RTCM_2") != -1 ||
736 _format.indexOf("RTCM2") != -1 ||
737 _format.indexOf("RTCM 2") != -1 ) {
738 rnxStr = t_rnxObsFile::type3to2(obs._prn.system(), rnxStr);
739 }
740 if (rnxTypes.indexOf(rnxStr) == -1) {
741 rnxTypes.push_back(rnxStr);
742 allFound = false;
743 }
744 }
745 }
746 if (!allFound) {
747 QString msg;
748 QTextStream str(&msg);
749 QString s;
750 str << obs._prn.system() << " " << s.sprintf("%2d", rnxTypes.size()) << " ";
751 for (int iType = 0; iType < rnxTypes.size(); iType++) {
752 str << " " << rnxTypes[iType];
753 }
754 emit(newMessage(_staID + ": Observation Types: " + msg.toAscii(), true));
755 }
756 }
757
758 // RTCMv3 antenna descriptor
759 // -------------------------
760 for (int ii = 0; ii < decoder()->_antType.size(); ii++) {
761 QString ant1 = QString("%1 ").arg(decoder()->_antType[ii]);
762 emit(newMessage(_staID + ": Antenna descriptor " + ant1.toAscii(), true));
763 }
764
765 // RTCM Antenna Coordinates
766 // ------------------------
767 for (int ii=0; ii < decoder()->_antList.size(); ii++) {
768 QByteArray antT;
769 if (decoder()->_antList[ii].type == GPSDecoder::t_antInfo::ARP) {
770 antT = "ARP";
771 }
772 else if (decoder()->_antList[ii].type == GPSDecoder::t_antInfo::APC) {
773 antT = "APC";
774 }
775 QByteArray ant1, ant2, ant3;
776 ant1 = QString("%1 ").arg(decoder()->_antList[ii].xx,0,'f',4).toAscii();
777 ant2 = QString("%1 ").arg(decoder()->_antList[ii].yy,0,'f',4).toAscii();
778 ant3 = QString("%1 ").arg(decoder()->_antList[ii].zz,0,'f',4).toAscii();
779 emit(newMessage(_staID + ": " + antT + " (ITRF) X " + ant1 + "m", true));
780 emit(newMessage(_staID + ": " + antT + " (ITRF) Y " + ant2 + "m", true));
781 emit(newMessage(_staID + ": " + antT + " (ITRF) Z " + ant3 + "m", true));
782 double hh = 0.0;
783 if (decoder()->_antList[ii].height_f) {
784 hh = decoder()->_antList[ii].height;
785 QByteArray ant4 = QString("%1 ").arg(hh,0,'f',4).toAscii();
786 emit(newMessage(_staID + ": Antenna height above marker " + ant4 + "m", true));
787 }
788 emit(newAntCrd(_staID, decoder()->_antList[ii].xx,
789 decoder()->_antList[ii].yy, decoder()->_antList[ii].zz,
790 hh, antT));
791 }
792
793 // RTCM GLONASS slots
794 // ------------------
795 if (decoder()->_gloFrq.size()) {
796 bool allFound = true;
797 QString slot = decoder()->_gloFrq;
798 if (_gloSlots.indexOf(slot) == -1) {
799 _gloSlots.append(slot);
800 allFound = false;
801 }
802 if (!allFound) {
803 _gloSlots.sort();
804 emit(newMessage(_staID + ": GLONASS slots " + _gloSlots.join(" ").toAscii(), true));
805 }
806 }
807 }
808 }
809
810#ifdef MLS_SOFTWARE
811 for (int ii=0; ii <decoder()->_antList.size(); ii++) {
812 QByteArray antT;
813 if (decoder()->_antList[ii].type == GPSDecoder::t_antInfo::ARP) {
814 antT = "ARP";
815 }
816 else if (decoder()->_antList[ii].type == GPSDecoder::t_antInfo::APC) {
817 antT = "APC";
818 }
819 double hh = 0.0;
820 if (decoder()->_antList[ii].height_f) {
821 hh = decoder()->_antList[ii].height;
822 }
823 emit(newAntCrd(_staID, decoder()->_antList[ii].xx,
824 decoder()->_antList[ii].yy, decoder()->_antList[ii].zz,
825 hh, antT));
826 }
827
828 for (int ii = 0; ii <decoder()->_typeList.size(); ii++) {
829 emit(newRTCMMessage(_staID, decoder()->_typeList[ii]));
830 }
831#endif
832
833 decoder()->_gloFrq.clear();
834 decoder()->_typeList.clear();
835 decoder()->_antType.clear();
836 decoder()->_antList.clear();
837}
838
839// Handle Data from Serial Port
840////////////////////////////////////////////////////////////////////////////
841void bncGetThread::slotSerialReadyRead() {
842
843 if (_serialPort) {
844
845 if (_nmea == "yes" && _serialNMEA == MANUAL_NMEA) {
846 if (_manualNMEASampl) {
847 int dt = _lastManualNMEA.secsTo(QDateTime::currentDateTime());
848 if (dt && (fmod(double(dt), double(_manualNMEASampl)) == 0.0)) {
849 _query->sendNMEA(_manualNMEAString);
850 _lastManualNMEA = QDateTime::currentDateTime();
851 }
852 }
853 }
854
855 int nb = _serialPort->bytesAvailable();
856 if (nb > 0) {
857 QByteArray data = _serialPort->read(nb);
858
859 if (_nmea == "yes" && _serialNMEA == AUTO_NMEA) {
860 int i1 = data.indexOf("$GPGGA");
861 if (i1 == -1) {
862 i1 = data.indexOf("$GNGGA");
863 }
864 if (i1 != -1) {
865 int i2 = data.indexOf("*", i1);
866 if (i2 != -1 && data.size() > i2 + 1) {
867 QByteArray gga = data.mid(i1, i2 - i1 + 3);
868 _query->sendNMEA(gga);
869 }
870 }
871 }
872
873 if (_serialOutFile) {
874 _serialOutFile->write(data);
875 _serialOutFile->flush();
876 }
877 }
878 }
879}
Note: See TracBrowser for help on using the repository browser.