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

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