source: ntrip/branches/BNC_2.11.0/src/bncgetthread.cpp@ 10569

Last change on this file since 10569 was 5648, checked in by mervart, 11 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 <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 emit newRawData(_staID, data);
464 }
465
466 // Output Data
467 // -----------
468 if (_rawOutput) {
469 BNC_CORE->writeRawData(data, _staID, _format);
470 }
471
472 if (_serialPort) {
473 slotSerialReadyRead();
474 _serialPort->write(data);
475 }
476
477 // Decode Data
478 // -----------
479 vector<string> errmsg;
480 if (!decoder()) {
481 _isToBeDeleted = true;
482 continue;
483 }
484 decoder()->_obsList.clear();
485 t_irc irc = decoder()->Decode(data.data(), data.size(), errmsg);
486
487 // Perform various scans and checks
488 // --------------------------------
489 if (_latencyChecker) {
490 _latencyChecker->checkOutage(irc == success);
491 _latencyChecker->checkObsLatency(decoder()->_obsList);
492 _latencyChecker->checkCorrLatency(decoder()->corrGPSEpochTime());
493
494 emit newLatency(_staID, _latencyChecker->currentLatency());
495 }
496
497 scanRTCM();
498
499 // Loop over all observations (observations output)
500 // ------------------------------------------------
501 QListIterator<t_obs> it(decoder()->_obsList);
502
503 QList<t_obs> obsListHlp;
504
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 // Save observations
557 // -----------------
558 obsListHlp.append(obs);
559 }
560
561 // Emit signal
562 // -----------
563 if (!_isToBeDeleted && obsListHlp.size() > 0) {
564 emit newObs(_staID, obsListHlp);
565 }
566
567 decoder()->_obsList.clear();
568 }
569 catch (Exception& exc) {
570 emit(newMessage(_staID + " " + exc.what(), true));
571 _isToBeDeleted = true;
572 }
573 catch (...) {
574 emit(newMessage(_staID + " bncGetThread exception", true));
575 _isToBeDeleted = true;
576 }
577 }
578}
579
580// Try Re-Connect
581////////////////////////////////////////////////////////////////////////////
582t_irc bncGetThread::tryReconnect() {
583
584 // Easy Return
585 // -----------
586 if (_query && _query->status() == bncNetQuery::running) {
587 _nextSleep = 0;
588 if (_rawFile) {
589 QMapIterator<QString, GPSDecoder*> itDec(_decodersRaw);
590 while (itDec.hasNext()) {
591 itDec.next();
592 GPSDecoder* decoder = itDec.value();
593 decoder->setRinexReconnectFlag(false);
594 }
595 }
596 else {
597 _decoder->setRinexReconnectFlag(false);
598 }
599 return success;
600 }
601
602 // Start a new query
603 // -----------------
604 if (!_rawFile) {
605
606 sleep(_nextSleep);
607 if (_nextSleep == 0) {
608 _nextSleep = 1;
609 }
610 else {
611 _nextSleep = 2 * _nextSleep;
612 if (_nextSleep > 256) {
613 _nextSleep = 256;
614 }
615#ifdef MLS_SOFTWARE
616 if (_nextSleep > 4) {
617 _nextSleep = 4;
618 }
619#endif
620 }
621
622 delete _query;
623 if (_ntripVersion == "U") {
624 _query = new bncNetQueryUdp();
625 }
626 else if (_ntripVersion == "R") {
627 _query = new bncNetQueryRtp();
628 }
629 else if (_ntripVersion == "S") {
630 _query = new bncNetQueryS();
631 }
632 else if (_ntripVersion == "N") {
633 _query = new bncNetQueryV0();
634 }
635 else if (_ntripVersion == "UN") {
636 _query = new bncNetQueryUdp0();
637 }
638 else if (_ntripVersion == "2") {
639 _query = new bncNetQueryV2(false);
640 }
641 else if (_ntripVersion == "2s") {
642 _query = new bncNetQueryV2(true);
643 }
644 else {
645 _query = new bncNetQueryV1();
646 }
647 if (_nmea == "yes" && _serialNMEA != AUTO_NMEA) {
648 QByteArray gga = ggaString(_latitude, _longitude, "100.0");
649 _query->startRequest(_mountPoint, gga);
650 }
651 else {
652 _query->startRequest(_mountPoint, "");
653 }
654 if (_query->status() != bncNetQuery::running) {
655 return failure;
656 }
657 }
658
659 if (_rawFile) {
660 QMapIterator<QString, GPSDecoder*> itDec(_decodersRaw);
661 while (itDec.hasNext()) {
662 itDec.next();
663 GPSDecoder* decoder = itDec.value();
664 decoder->setRinexReconnectFlag(false);
665 }
666 }
667 else {
668 _decoder->setRinexReconnectFlag(false);
669 }
670
671 return success;
672}
673
674// RTCM scan output
675//////////////////////////////////////////////////////////////////////////////
676void bncGetThread::scanRTCM() {
677
678 if ( !decoder() ) {
679 return;
680 }
681
682 bncSettings settings;
683 if ( Qt::CheckState(settings.value("scanRTCM").toInt()) == Qt::Checked ) {
684
685 if ( _miscMount == _staID || _miscMount == "ALL" ) {
686
687 // RTCM message types
688 // ------------------
689 for (int ii = 0; ii < decoder()->_typeList.size(); ii++) {
690 QString type = QString("%1 ").arg(decoder()->_typeList[ii]);
691 emit(newMessage(_staID + ": Received message type " + type.toAscii(), true));
692 }
693
694 // Check Observation Types
695 // -----------------------
696 for (int ii = 0; ii < decoder()->_obsList.size(); ii++) {
697 t_obs& obs = decoder()->_obsList[ii];
698 QVector<QString>& rnxTypes = _rnxTypes[obs.satSys];
699 bool allFound = true;
700 for (int iEntry = 0; iEntry < GNSSENTRY_NUMBER; iEntry++) {
701 if (obs._measdata[iEntry] != 0.0) {
702 if (rnxTypes.indexOf(obs.rnxStr(iEntry)) == -1) {
703 allFound = false;
704 rnxTypes << obs.rnxStr(iEntry);
705 }
706 }
707 }
708 if (!allFound) {
709 QString msg;
710 QTextStream str(&msg);
711 str << obs.satSys << " " << rnxTypes.size() << " ";
712 for (int iType = 0; iType < rnxTypes.size(); iType++) {
713 str << " " << rnxTypes[iType];
714 }
715 emit(newMessage(_staID + ": Observation Types: " + msg.toAscii(), true));
716 }
717 }
718
719 // RTCMv3 antenna descriptor
720 // -------------------------
721 for (int ii = 0; ii < decoder()->_antType.size(); ii++) {
722 QString ant1 = QString("%1 ").arg(decoder()->_antType[ii]);
723 emit(newMessage(_staID + ": Antenna descriptor " + ant1.toAscii(), true));
724 }
725
726 // RTCM Antenna Coordinates
727 // ------------------------
728 for (int ii=0; ii < decoder()->_antList.size(); ii++) {
729 QByteArray antT;
730 if (decoder()->_antList[ii].type == GPSDecoder::t_antInfo::ARP) {
731 antT = "ARP";
732 }
733 else if (decoder()->_antList[ii].type == GPSDecoder::t_antInfo::APC) {
734 antT = "APC";
735 }
736 QByteArray ant1, ant2, ant3;
737 ant1 = QString("%1 ").arg(decoder()->_antList[ii].xx,0,'f',4).toAscii();
738 ant2 = QString("%1 ").arg(decoder()->_antList[ii].yy,0,'f',4).toAscii();
739 ant3 = QString("%1 ").arg(decoder()->_antList[ii].zz,0,'f',4).toAscii();
740 emit(newMessage(_staID + ": " + antT + " (ITRF) X " + ant1 + "m", true));
741 emit(newMessage(_staID + ": " + antT + " (ITRF) Y " + ant2 + "m", true));
742 emit(newMessage(_staID + ": " + antT + " (ITRF) Z " + ant3 + "m", true));
743 double hh = 0.0;
744 if (decoder()->_antList[ii].height_f) {
745 hh = decoder()->_antList[ii].height;
746 QByteArray ant4 = QString("%1 ").arg(hh,0,'f',4).toAscii();
747 emit(newMessage(_staID + ": Antenna height above marker " + ant4 + "m", true));
748 }
749 emit(newAntCrd(_staID, decoder()->_antList[ii].xx,
750 decoder()->_antList[ii].yy, decoder()->_antList[ii].zz,
751 hh, antT));
752 }
753 }
754 }
755
756#ifdef MLS_SOFTWARE
757 for (int ii=0; ii <decoder()->_antList.size(); ii++) {
758 QByteArray antT;
759 if (decoder()->_antList[ii].type == GPSDecoder::t_antInfo::ARP) {
760 antT = "ARP";
761 }
762 else if (decoder()->_antList[ii].type == GPSDecoder::t_antInfo::APC) {
763 antT = "APC";
764 }
765 double hh = 0.0;
766 if (decoder()->_antList[ii].height_f) {
767 hh = decoder()->_antList[ii].height;
768 }
769 emit(newAntCrd(_staID, decoder()->_antList[ii].xx,
770 decoder()->_antList[ii].yy, decoder()->_antList[ii].zz,
771 hh, antT));
772 }
773
774 for (int ii = 0; ii <decoder()->_typeList.size(); ii++) {
775 emit(newRTCMMessage(_staID, decoder()->_typeList[ii]));
776 }
777#endif
778
779 decoder()->_typeList.clear();
780 decoder()->_antType.clear();
781 decoder()->_antList.clear();
782}
783
784// Handle Data from Serial Port
785////////////////////////////////////////////////////////////////////////////
786void bncGetThread::slotSerialReadyRead() {
787 if (_serialPort) {
788 int nb = _serialPort->bytesAvailable();
789 if (nb > 0) {
790 QByteArray data = _serialPort->read(nb);
791
792 if (_serialNMEA == AUTO_NMEA) {
793 int i1 = data.indexOf("$GPGGA");
794 if (i1 != -1) {
795 int i2 = data.indexOf("*", i1);
796 if (i2 != -1 && data.size() > i2 + 1) {
797 QByteArray gga = data.mid(i1,i2-i1+3);
798 _query->sendNMEA(gga);
799 }
800 }
801 }
802
803 if (_serialOutFile) {
804 _serialOutFile->write(data);
805 _serialOutFile->flush();
806 }
807 }
808 }
809}
Note: See TracBrowser for help on using the repository browser.