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

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