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

Last change on this file since 4763 was 4763, checked in by mervart, 12 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 <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("pppMount").toString() == _staID) {
333 _PPPclient = new bncPPPclient(_staID);
334 bncApp* app = (bncApp*) qApp;
335 app->_bncPPPclient = _PPPclient;
336 qRegisterMetaType<bncTime>("bncTime");
337 connect(_PPPclient, SIGNAL(newPosition(bncTime, double, double, double)),
338 this, SIGNAL(newPosition(bncTime, double, double, double)));
339 connect(_PPPclient, SIGNAL(newNMEAstr(QByteArray)),
340 this, SIGNAL(newNMEAstr(QByteArray)));
341 }
342#endif
343
344 return success;
345}
346
347// Current decoder in use
348////////////////////////////////////////////////////////////////////////////
349GPSDecoder* bncGetThread::decoder() {
350 if (!_rawFile) {
351 return _decoder;
352 }
353 else {
354 if (_decodersRaw.contains(_staID) || initDecoder() == success) {
355 return _decodersRaw[_staID];
356 }
357 }
358 return 0;
359}
360
361// Destructor
362////////////////////////////////////////////////////////////////////////////
363bncGetThread::~bncGetThread() {
364 if (isRunning()) {
365 wait();
366 }
367 if (_query) {
368 _query->stop();
369 _query->deleteLater();
370 }
371 delete _PPPclient;
372 if (_rawFile) {
373 QMapIterator<QString, GPSDecoder*> it(_decodersRaw);
374 while (it.hasNext()) {
375 it.next();
376 delete it.value();
377 }
378 }
379 else {
380 delete _decoder;
381 }
382 delete _rawFile;
383 delete _serialOutFile;
384 delete _serialPort;
385 delete _latencyChecker;
386 emit getThreadFinished(_staID);
387}
388
389//
390////////////////////////////////////////////////////////////////////////////
391void bncGetThread::terminate() {
392 _isToBeDeleted = true;
393 if (!isRunning()) {
394 delete this;
395 }
396}
397
398// Run
399////////////////////////////////////////////////////////////////////////////
400void bncGetThread::run() {
401
402 while (true) {
403 try {
404 if (_isToBeDeleted) {
405 QThread::exit(0);
406 this->deleteLater();
407 return;
408 }
409
410 if (tryReconnect() != success) {
411 if (_latencyChecker) {
412 _latencyChecker->checkReconnect();
413 }
414 continue;
415 }
416
417 // Delete old observations
418 // -----------------------
419 if (_rawFile) {
420 QMapIterator<QString, GPSDecoder*> itDec(_decodersRaw);
421 while (itDec.hasNext()) {
422 itDec.next();
423 GPSDecoder* decoder = itDec.value();
424 decoder->_obsList.clear();
425 }
426 }
427 else {
428 _decoder->_obsList.clear();
429 }
430
431 // Read Data
432 // ---------
433 QByteArray data;
434 if (_query) {
435 _query->waitForReadyRead(data);
436 }
437 else if (_rawFile) {
438 data = _rawFile->readChunk();
439 _format = _rawFile->format();
440 _staID = _rawFile->staID();
441
442 if (data.isEmpty()) {
443 cout << "no more data" << endl;
444 ((bncApp*) qApp)->stopCombination();
445 QThread::exit(0);
446 delete this;
447 ::exit(0);
448 }
449 }
450 qint64 nBytes = data.size();
451
452 // Timeout, reconnect
453 // ------------------
454 if (nBytes == 0) {
455 if (_latencyChecker) {
456 _latencyChecker->checkReconnect();
457 }
458 emit(newMessage(_staID + ": Data timeout, reconnecting", true));
459 msleep(10000); //sleep 10 sec, G. Weber
460 continue;
461 }
462 else {
463 emit newBytes(_staID, nBytes);
464 }
465
466 // Output Data
467 // -----------
468 if (_rawOutput) {
469 bncApp* app = (bncApp*) qApp;
470 app->writeRawData(data, _staID, _format);
471 }
472
473 if (_serialPort) {
474 slotSerialReadyRead();
475 _serialPort->write(data);
476 }
477
478 // Decode Data
479 // -----------
480 vector<string> errmsg;
481 if (!decoder()) {
482 _isToBeDeleted = true;
483 continue;
484 }
485 decoder()->_obsList.clear();
486 t_irc irc = decoder()->Decode(data.data(), data.size(), errmsg);
487
488 // Perform various scans and checks
489 // --------------------------------
490 if (_latencyChecker) {
491 _latencyChecker->checkOutage(irc == success);
492 _latencyChecker->checkObsLatency(decoder()->_obsList);
493 _latencyChecker->checkCorrLatency(decoder()->corrGPSEpochTime());
494
495 emit newLatency(_staID, _latencyChecker->currentLatency());
496 }
497
498 scanRTCM();
499
500 // Loop over all observations (observations output)
501 // ------------------------------------------------
502 QListIterator<t_obs> it(decoder()->_obsList);
503 bool firstObs = true;
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
556 // Emit new observation signal
557 // ---------------------------
558 if (!_isToBeDeleted) {
559 emit newObs(_staID, firstObs, obs);
560 }
561 firstObs = false;
562 }
563 decoder()->_obsList.clear();
564 }
565 catch (Exception& exc) {
566 emit(newMessage(_staID + " " + exc.what(), true));
567 _isToBeDeleted = true;
568 }
569 catch (...) {
570 emit(newMessage(_staID + " bncGetThread exception", true));
571 _isToBeDeleted = true;
572 }
573 }
574}
575
576// Try Re-Connect
577////////////////////////////////////////////////////////////////////////////
578t_irc bncGetThread::tryReconnect() {
579
580 // Easy Return
581 // -----------
582 if (_query && _query->status() == bncNetQuery::running) {
583 _nextSleep = 0;
584 if (_rawFile) {
585 QMapIterator<QString, GPSDecoder*> itDec(_decodersRaw);
586 while (itDec.hasNext()) {
587 itDec.next();
588 GPSDecoder* decoder = itDec.value();
589 decoder->setRinexReconnectFlag(false);
590 }
591 }
592 else {
593 _decoder->setRinexReconnectFlag(false);
594 }
595 return success;
596 }
597
598 // Start a new query
599 // -----------------
600 if (!_rawFile) {
601
602 sleep(_nextSleep);
603 if (_nextSleep == 0) {
604 _nextSleep = 1;
605 }
606 else {
607 _nextSleep = 2 * _nextSleep;
608 if (_nextSleep > 256) {
609 _nextSleep = 256;
610 }
611#ifdef MLS_SOFTWARE
612 if (_nextSleep > 4) {
613 _nextSleep = 4;
614 }
615#endif
616 }
617
618 delete _query;
619 if (_ntripVersion == "U") {
620 _query = new bncNetQueryUdp();
621 }
622 else if (_ntripVersion == "R") {
623 _query = new bncNetQueryRtp();
624 }
625 else if (_ntripVersion == "S") {
626 _query = new bncNetQueryS();
627 }
628 else if (_ntripVersion == "N") {
629 _query = new bncNetQueryV0();
630 }
631 else if (_ntripVersion == "UN") {
632 _query = new bncNetQueryUdp0();
633 }
634 else if (_ntripVersion == "2") {
635 _query = new bncNetQueryV2(false);
636 }
637 else if (_ntripVersion == "2s") {
638 _query = new bncNetQueryV2(true);
639 }
640 else {
641 _query = new bncNetQueryV1();
642 }
643 if (_nmea == "yes" && _serialNMEA != AUTO_NMEA) {
644 QByteArray gga = ggaString(_latitude, _longitude, "100.0");
645 _query->startRequest(_mountPoint, gga);
646 }
647 else {
648 _query->startRequest(_mountPoint, "");
649 }
650 if (_query->status() != bncNetQuery::running) {
651 return failure;
652 }
653 }
654
655 if (_rawFile) {
656 QMapIterator<QString, GPSDecoder*> itDec(_decodersRaw);
657 while (itDec.hasNext()) {
658 itDec.next();
659 GPSDecoder* decoder = itDec.value();
660 decoder->setRinexReconnectFlag(false);
661 }
662 }
663 else {
664 _decoder->setRinexReconnectFlag(false);
665 }
666
667 return success;
668}
669
670// RTCM scan output
671//////////////////////////////////////////////////////////////////////////////
672void bncGetThread::scanRTCM() {
673
674 if ( !decoder() ) {
675 return;
676 }
677
678 bncSettings settings;
679 if ( Qt::CheckState(settings.value("scanRTCM").toInt()) == Qt::Checked ) {
680
681 if ( _miscMount == _staID || _miscMount == "ALL" ) {
682
683 // RTCM message types
684 // ------------------
685 for (int ii = 0; ii < decoder()->_typeList.size(); ii++) {
686 QString type = QString("%1 ").arg(decoder()->_typeList[ii]);
687 emit(newMessage(_staID + ": Received message type " + type.toAscii(), true));
688 }
689
690 // Check Observation Types
691 // -----------------------
692 for (int ii = 0; ii < decoder()->_obsList.size(); ii++) {
693 t_obs& obs = decoder()->_obsList[ii];
694 QVector<QString>& rnxTypes = _rnxTypes[obs.satSys];
695 bool allFound = true;
696 for (int iEntry = 0; iEntry < GNSSENTRY_NUMBER; iEntry++) {
697 if (obs._measdata[iEntry] != 0.0) {
698 if (rnxTypes.indexOf(obs.rnxStr(iEntry)) == -1) {
699 allFound = false;
700 rnxTypes << obs.rnxStr(iEntry);
701 }
702 }
703 }
704 if (!allFound) {
705 QString msg;
706 QTextStream str(&msg);
707 str << obs.satSys << " " << rnxTypes.size() << " ";
708 for (int iType = 0; iType < rnxTypes.size(); iType++) {
709 str << " " << rnxTypes[iType];
710 }
711 emit(newMessage(_staID + ": Observation Types: " + msg.toAscii(), true));
712 }
713 }
714
715 // RTCMv3 antenna descriptor
716 // -------------------------
717 for (int ii = 0; ii < decoder()->_antType.size(); ii++) {
718 QString ant1 = QString("%1 ").arg(decoder()->_antType[ii]);
719 emit(newMessage(_staID + ": Antenna descriptor " + ant1.toAscii(), true));
720 }
721
722 // RTCM Antenna Coordinates
723 // ------------------------
724 for (int ii=0; ii < decoder()->_antList.size(); ii++) {
725 QByteArray antT;
726 if (decoder()->_antList[ii].type == GPSDecoder::t_antInfo::ARP) {
727 antT = "ARP";
728 }
729 else if (decoder()->_antList[ii].type == GPSDecoder::t_antInfo::APC) {
730 antT = "APC";
731 }
732 QByteArray ant1, ant2, ant3;
733 ant1 = QString("%1 ").arg(decoder()->_antList[ii].xx,0,'f',4).toAscii();
734 ant2 = QString("%1 ").arg(decoder()->_antList[ii].yy,0,'f',4).toAscii();
735 ant3 = QString("%1 ").arg(decoder()->_antList[ii].zz,0,'f',4).toAscii();
736 emit(newMessage(_staID + ": " + antT + " (ITRF) X " + ant1 + "m", true));
737 emit(newMessage(_staID + ": " + antT + " (ITRF) Y " + ant2 + "m", true));
738 emit(newMessage(_staID + ": " + antT + " (ITRF) Z " + ant3 + "m", true));
739 double hh = 0.0;
740 if (decoder()->_antList[ii].height_f) {
741 hh = decoder()->_antList[ii].height;
742 QByteArray ant4 = QString("%1 ").arg(hh,0,'f',4).toAscii();
743 emit(newMessage(_staID + ": Antenna height above marker " + ant4 + "m", true));
744 }
745 emit(newAntCrd(_staID, decoder()->_antList[ii].xx,
746 decoder()->_antList[ii].yy, decoder()->_antList[ii].zz,
747 hh, antT));
748 }
749 }
750 }
751
752#ifdef MLS_SOFTWARE
753 for (int ii=0; ii <decoder()->_antList.size(); ii++) {
754 QByteArray antT;
755 if (decoder()->_antList[ii].type == GPSDecoder::t_antInfo::ARP) {
756 antT = "ARP";
757 }
758 else if (decoder()->_antList[ii].type == GPSDecoder::t_antInfo::APC) {
759 antT = "APC";
760 }
761 double hh = 0.0;
762 if (decoder()->_antList[ii].height_f) {
763 hh = decoder()->_antList[ii].height;
764 }
765 emit(newAntCrd(_staID, decoder()->_antList[ii].xx,
766 decoder()->_antList[ii].yy, decoder()->_antList[ii].zz,
767 hh, antT));
768 }
769
770 for (int ii = 0; ii <decoder()->_typeList.size(); ii++) {
771 emit(newRTCMMessage(_staID, decoder()->_typeList[ii]));
772 }
773#endif
774
775 decoder()->_typeList.clear();
776 decoder()->_antType.clear();
777 decoder()->_antList.clear();
778}
779
780// Handle Data from Serial Port
781////////////////////////////////////////////////////////////////////////////
782void bncGetThread::slotSerialReadyRead() {
783 if (_serialPort) {
784 int nb = _serialPort->bytesAvailable();
785 if (nb > 0) {
786 QByteArray data = _serialPort->read(nb);
787
788 if (_serialNMEA == AUTO_NMEA) {
789 int i1 = data.indexOf("$GPGGA");
790 if (i1 != -1) {
791 int i2 = data.indexOf("*", i1);
792 if (i2 != -1 && data.size() > i2 + 1) {
793 QByteArray gga = data.mid(i1,i2-i1+3);
794 _query->sendNMEA(gga);
795 }
796 }
797 }
798
799 if (_serialOutFile) {
800 _serialOutFile->write(data);
801 _serialOutFile->flush();
802 }
803 }
804 }
805}
Note: See TracBrowser for help on using the repository browser.