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

Last change on this file since 5739 was 5739, checked in by mervart, 8 years ago
File size: 22.3 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 "bncpppclient.h"
66#include "upload/bncrtnetdecoder.h"
67#include "RTCM/RTCM2Decoder.h"
68#include "RTCM3/RTCM3Decoder.h"
69#include "serial/qextserialport.h"
70
71using namespace std;
72
73// Constructor 1
74////////////////////////////////////////////////////////////////////////////
75bncGetThread::bncGetThread(bncRawFile* rawFile) {
76
77 _rawFile = rawFile;
78 _format = rawFile->format();
79 _staID = rawFile->staID();
80 _rawOutput = false;
81 _ntripVersion = "N";
82
83 initialize();
84}
85
86// Constructor 2
87////////////////////////////////////////////////////////////////////////////
88bncGetThread::bncGetThread(const QUrl& mountPoint,
89 const QByteArray& format,
90 const QByteArray& latitude,
91 const QByteArray& longitude,
92 const QByteArray& nmea,
93 const QByteArray& ntripVersion) {
94 _rawFile = 0;
95 _mountPoint = mountPoint;
96 _staID = mountPoint.path().mid(1).toAscii();
97 _format = format;
98 _latitude = latitude;
99 _longitude = longitude;
100 _nmea = nmea;
101 _ntripVersion = ntripVersion;
102
103 bncSettings settings;
104 if (!settings.value("rawOutFile").toString().isEmpty()) {
105 _rawOutput = true;
106 } else {
107 _rawOutput = false;
108 }
109
110 initialize();
111 initDecoder();
112}
113
114// Initialization (common part of the constructor)
115////////////////////////////////////////////////////////////////////////////
116void bncGetThread::initialize() {
117
118 bncSettings settings;
119
120 setTerminationEnabled(true);
121
122 connect(this, SIGNAL(newMessage(QByteArray,bool)),
123 BNC_CORE, SLOT(slotMessage(const QByteArray,bool)));
124
125 _isToBeDeleted = false;
126 _query = 0;
127 _nextSleep = 0;
128 _PPPclient = 0;
129 _miscMount = settings.value("miscMount").toString();
130 _decoder = 0;
131
132 // Serial Port
133 // -----------
134 _serialNMEA = NO_NMEA;
135 _serialOutFile = 0;
136 _serialPort = 0;
137
138 if (!_staID.isEmpty() &&
139 settings.value("serialMountPoint").toString() == _staID) {
140 _serialPort = new QextSerialPort(settings.value("serialPortName").toString() );
141 _serialPort->setTimeout(0,100);
142
143 // Baud Rate
144 // ---------
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 }
179
180 // Parity
181 // ------
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 }
195
196 // Data Bits
197 // ---------
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 }
218
219 // Flow Control
220 // ------------
221 hlp = settings.value("serialFlowControl").toString();
222 if (hlp == "XONXOFF") {
223 _serialPort->setFlowControl(FLOW_XONXOFF);
224 }
225 else if (hlp == "HARDWARE") {
226 _serialPort->setFlowControl(FLOW_HARDWARE);
227 }
228 else {
229 _serialPort->setFlowControl(FLOW_OFF);
230 }
231
232 // Open Serial Port
233 // ----------------
234 _serialPort->open(QIODevice::ReadWrite|QIODevice::Unbuffered);
235 if (!_serialPort->isOpen()) {
236 delete _serialPort;
237 _serialPort = 0;
238 emit(newMessage((_staID + ": Cannot open serial port\n"), true));
239 }
240 connect(_serialPort, SIGNAL(readyRead()),
241 this, SLOT(slotSerialReadyRead()));
242
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 }
257 }
258 }
259
260 // Manual NMEA
261 // -----------
262 else {
263 _serialNMEA = MANUAL_NMEA;
264 }
265 }
266
267 if (!_staID.isEmpty()) {
268 _latencyChecker = new latencyChecker(_staID);
269 }
270 else {
271 _latencyChecker = 0;
272 }
273}
274
275// Instantiate the decoder
276//////////////////////////////////////////////////////////////////////////////
277t_irc bncGetThread::initDecoder() {
278
279 _decoder = 0;
280
281 if (_format.indexOf("RTCM_2") != -1 || _format.indexOf("RTCM2") != -1 ||
282 _format.indexOf("RTCM 2") != -1 ) {
283 emit(newMessage(_staID + ": Get data in RTCM 2.x format", true));
284 _decoder = new RTCM2Decoder(_staID.data());
285 }
286 else if (_format.indexOf("RTCM_3") != -1 || _format.indexOf("RTCM3") != -1 ||
287 _format.indexOf("RTCM 3") != -1 ) {
288 emit(newMessage(_staID + ": Get data in RTCM 3.x format", true));
289 RTCM3Decoder* newDecoder = new RTCM3Decoder(_staID, _rawFile);
290 _decoder = newDecoder;
291 connect((RTCM3Decoder*) newDecoder, SIGNAL(newMessage(QByteArray,bool)),
292 this, SIGNAL(newMessage(QByteArray,bool)));
293 }
294 else if (_format.indexOf("ZERO") != -1) {
295 emit(newMessage(_staID + ": Get data in original format", true));
296 _decoder = new bncZeroDecoder(_staID);
297 }
298 else if (_format.indexOf("RTNET") != -1) {
299 emit(newMessage(_staID + ": Get data in RTNet format", true));
300 _decoder = new bncRtnetDecoder();
301 }
302 else {
303 emit(newMessage(_staID + ": Unknown data format " + _format, true));
304 _isToBeDeleted = true;
305 return failure;
306 }
307
308 msleep(100); //sleep 0.1 sec
309
310 _decoder->initRinex(_staID, _mountPoint, _latitude, _longitude,
311 _nmea, _ntripVersion);
312
313 if (_rawFile) {
314 _decodersRaw[_staID] = _decoder;
315 }
316
317 // Initialize PPP Client?
318 // ----------------------
319#ifndef MLS_SOFTWARE
320 bncSettings settings;
321 if (!settings.value("pppSPP").toString().isEmpty() &&
322 settings.value("pppMount").toString() == _staID) {
323 _PPPclient = new bncPPPclient(_staID);
324 BNC_CORE->_bncPPPclient = _PPPclient;
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
333 return success;
334}
335
336// Current decoder in use
337////////////////////////////////////////////////////////////////////////////
338GPSDecoder* bncGetThread::decoder() {
339 if (!_rawFile) {
340 return _decoder;
341 }
342 else {
343 if (_decodersRaw.contains(_staID) || initDecoder() == success) {
344 return _decodersRaw[_staID];
345 }
346 }
347 return 0;
348}
349
350// Destructor
351////////////////////////////////////////////////////////////////////////////
352bncGetThread::~bncGetThread() {
353 if (isRunning()) {
354 wait();
355 }
356 if (_query) {
357 _query->stop();
358 _query->deleteLater();
359 }
360 delete _PPPclient;
361 if (_rawFile) {
362 QMapIterator<QString, GPSDecoder*> it(_decodersRaw);
363 while (it.hasNext()) {
364 it.next();
365 delete it.value();
366 }
367 }
368 else {
369 delete _decoder;
370 }
371 delete _rawFile;
372 delete _serialOutFile;
373 delete _serialPort;
374 delete _latencyChecker;
375 emit getThreadFinished(_staID);
376}
377
378//
379////////////////////////////////////////////////////////////////////////////
380void bncGetThread::terminate() {
381 _isToBeDeleted = true;
382 if (!isRunning()) {
383 delete this;
384 }
385}
386
387// Run
388////////////////////////////////////////////////////////////////////////////
389void bncGetThread::run() {
390
391 while (true) {
392 try {
393 if (_isToBeDeleted) {
394 QThread::exit(0);
395 this->deleteLater();
396 return;
397 }
398
399 if (tryReconnect() != success) {
400 if (_latencyChecker) {
401 _latencyChecker->checkReconnect();
402 }
403 continue;
404 }
405
406 // Delete old observations
407 // -----------------------
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 }
415 }
416 else {
417 _decoder->_obsList.clear();
418 }
419
420 // Read Data
421 // ---------
422 QByteArray data;
423 if (_query) {
424 _query->waitForReadyRead(data);
425 }
426 else if (_rawFile) {
427 data = _rawFile->readChunk();
428 _format = _rawFile->format();
429 _staID = _rawFile->staID();
430
431 if (data.isEmpty()) {
432 cout << "no more data" << endl;
433 BNC_CORE->stopCombination();
434 QThread::exit(0);
435 delete this;
436 ::exit(0);
437 }
438 }
439 qint64 nBytes = data.size();
440
441 // Timeout, reconnect
442 // ------------------
443 if (nBytes == 0) {
444 if (_latencyChecker) {
445 _latencyChecker->checkReconnect();
446 }
447 emit(newMessage(_staID + ": Data timeout, reconnecting", true));
448 msleep(10000); //sleep 10 sec, G. Weber
449 continue;
450 }
451 else {
452 emit newBytes(_staID, nBytes);
453 emit newRawData(_staID, data);
454 }
455
456 // Output Data
457 // -----------
458 if (_rawOutput) {
459 BNC_CORE->writeRawData(data, _staID, _format);
460 }
461
462 if (_serialPort) {
463 slotSerialReadyRead();
464 _serialPort->write(data);
465 }
466
467 // Decode Data
468 // -----------
469 vector<string> errmsg;
470 if (!decoder()) {
471 _isToBeDeleted = true;
472 continue;
473 }
474 decoder()->_obsList.clear();
475 t_irc irc = decoder()->Decode(data.data(), data.size(), errmsg);
476
477 // Perform various scans and checks
478 // --------------------------------
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 }
486
487 scanRTCM();
488
489 // Loop over all observations (observations output)
490 // ------------------------------------------------
491 QListIterator<t_obs> it(decoder()->_obsList);
492
493 QList<t_obs> obsListHlp;
494
495 while (it.hasNext()) {
496 const t_obs& obs = it.next();
497
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
503 // Check observation epoch
504 // -----------------------
505 if (!_rawFile) {
506 int week;
507 double sec;
508 currentGPSWeeks(week, sec);
509 long currTime = week * 7*24*3600 + long(sec);
510 const double maxDt = 600.0;
511 if (fabs(currTime - obsTime) > maxDt) {
512 emit( newMessage(_staID + ": Wrong observation epoch(s)", false) );
513 continue;
514 }
515 }
516
517 // Check observations coming twice (e.g. KOUR0 Problem)
518 // ----------------------------------------------------
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 }
533 }
534 _prnLastEpo[prn] = obsTime;
535 }
536
537 decoder()->dumpRinexEpoch(obs, _format);
538
539 // PPP Client
540 // ----------
541#ifndef MLS_SOFTWARE
542 if (_PPPclient && _staID == _PPPclient->staID()) {
543 _PPPclient->putNewObs(obs);
544 }
545#endif
546 // Save observations
547 // -----------------
548 obsListHlp.append(obs);
549 }
550
551 // Emit signal
552 // -----------
553 if (!_isToBeDeleted && obsListHlp.size() > 0) {
554 emit newObs(_staID, obsListHlp);
555 }
556
557 decoder()->_obsList.clear();
558 }
559 catch (Exception& exc) {
560 emit(newMessage(_staID + " " + exc.what(), true));
561 _isToBeDeleted = true;
562 }
563 catch (...) {
564 emit(newMessage(_staID + " bncGetThread exception", true));
565 _isToBeDeleted = true;
566 }
567 }
568}
569
570// Try Re-Connect
571////////////////////////////////////////////////////////////////////////////
572t_irc bncGetThread::tryReconnect() {
573
574 // Easy Return
575 // -----------
576 if (_query && _query->status() == bncNetQuery::running) {
577 _nextSleep = 0;
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 }
585 }
586 else {
587 _decoder->setRinexReconnectFlag(false);
588 }
589 return success;
590 }
591
592 // Start a new query
593 // -----------------
594 if (!_rawFile) {
595
596 sleep(_nextSleep);
597 if (_nextSleep == 0) {
598 _nextSleep = 1;
599 }
600 else {
601 _nextSleep = 2 * _nextSleep;
602 if (_nextSleep > 256) {
603 _nextSleep = 256;
604 }
605#ifdef MLS_SOFTWARE
606 if (_nextSleep > 4) {
607 _nextSleep = 4;
608 }
609#endif
610 }
611
612 delete _query;
613 if (_ntripVersion == "U") {
614 _query = new bncNetQueryUdp();
615 }
616 else if (_ntripVersion == "R") {
617 _query = new bncNetQueryRtp();
618 }
619 else if (_ntripVersion == "S") {
620 _query = new bncNetQueryS();
621 }
622 else if (_ntripVersion == "N") {
623 _query = new bncNetQueryV0();
624 }
625 else if (_ntripVersion == "UN") {
626 _query = new bncNetQueryUdp0();
627 }
628 else if (_ntripVersion == "2") {
629 _query = new bncNetQueryV2(false);
630 }
631 else if (_ntripVersion == "2s") {
632 _query = new bncNetQueryV2(true);
633 }
634 else {
635 _query = new bncNetQueryV1();
636 }
637 if (_nmea == "yes" && _serialNMEA != AUTO_NMEA) {
638 QByteArray gga = ggaString(_latitude, _longitude, "100.0");
639 _query->startRequest(_mountPoint, gga);
640 }
641 else {
642 _query->startRequest(_mountPoint, "");
643 }
644 if (_query->status() != bncNetQuery::running) {
645 return failure;
646 }
647 }
648
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 }
656 }
657 else {
658 _decoder->setRinexReconnectFlag(false);
659 }
660
661 return success;
662}
663
664// RTCM scan output
665//////////////////////////////////////////////////////////////////////////////
666void bncGetThread::scanRTCM() {
667
668 if ( !decoder() ) {
669 return;
670 }
671
672 bncSettings settings;
673 if ( Qt::CheckState(settings.value("scanRTCM").toInt()) == Qt::Checked ) {
674
675 if ( _miscMount == _staID || _miscMount == "ALL" ) {
676
677 // RTCM message types
678 // ------------------
679 for (int ii = 0; ii < decoder()->_typeList.size(); ii++) {
680 QString type = QString("%1 ").arg(decoder()->_typeList[ii]);
681 emit(newMessage(_staID + ": Received message type " + type.toAscii(), true));
682 }
683
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) {
699 QString msg;
700 QTextStream str(&msg);
701 str << obs.satSys << " " << rnxTypes.size() << " ";
702 for (int iType = 0; iType < rnxTypes.size(); iType++) {
703 str << " " << rnxTypes[iType];
704 }
705 emit(newMessage(_staID + ": Observation Types: " + msg.toAscii(), true));
706 }
707 }
708
709 // RTCMv3 antenna descriptor
710 // -------------------------
711 for (int ii = 0; ii < decoder()->_antType.size(); ii++) {
712 QString ant1 = QString("%1 ").arg(decoder()->_antType[ii]);
713 emit(newMessage(_staID + ": Antenna descriptor " + ant1.toAscii(), true));
714 }
715
716 // RTCM Antenna Coordinates
717 // ------------------------
718 for (int ii=0; ii < decoder()->_antList.size(); ii++) {
719 QByteArray antT;
720 if (decoder()->_antList[ii].type == GPSDecoder::t_antInfo::ARP) {
721 antT = "ARP";
722 }
723 else if (decoder()->_antList[ii].type == GPSDecoder::t_antInfo::APC) {
724 antT = "APC";
725 }
726 QByteArray ant1, ant2, ant3;
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();
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));
733 double hh = 0.0;
734 if (decoder()->_antList[ii].height_f) {
735 hh = decoder()->_antList[ii].height;
736 QByteArray ant4 = QString("%1 ").arg(hh,0,'f',4).toAscii();
737 emit(newMessage(_staID + ": Antenna height above marker " + ant4 + "m", true));
738 }
739 emit(newAntCrd(_staID, decoder()->_antList[ii].xx,
740 decoder()->_antList[ii].yy, decoder()->_antList[ii].zz,
741 hh, antT));
742 }
743 }
744 }
745
746#ifdef MLS_SOFTWARE
747 for (int ii=0; ii <decoder()->_antList.size(); ii++) {
748 QByteArray antT;
749 if (decoder()->_antList[ii].type == GPSDecoder::t_antInfo::ARP) {
750 antT = "ARP";
751 }
752 else if (decoder()->_antList[ii].type == GPSDecoder::t_antInfo::APC) {
753 antT = "APC";
754 }
755 double hh = 0.0;
756 if (decoder()->_antList[ii].height_f) {
757 hh = decoder()->_antList[ii].height;
758 }
759 emit(newAntCrd(_staID, decoder()->_antList[ii].xx,
760 decoder()->_antList[ii].yy, decoder()->_antList[ii].zz,
761 hh, antT));
762 }
763
764 for (int ii = 0; ii <decoder()->_typeList.size(); ii++) {
765 emit(newRTCMMessage(_staID, decoder()->_typeList[ii]));
766 }
767#endif
768
769 decoder()->_typeList.clear();
770 decoder()->_antType.clear();
771 decoder()->_antList.clear();
772}
773
774// Handle Data from Serial Port
775////////////////////////////////////////////////////////////////////////////
776void bncGetThread::slotSerialReadyRead() {
777 if (_serialPort) {
778 int nb = _serialPort->bytesAvailable();
779 if (nb > 0) {
780 QByteArray data = _serialPort->read(nb);
781
782 if (_serialNMEA == AUTO_NMEA) {
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 }
791 }
792
793 if (_serialOutFile) {
794 _serialOutFile->write(data);
795 _serialOutFile->flush();
796 }
797 }
798 }
799}
Note: See TracBrowser for help on using the repository browser.