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

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