source: ntrip/trunk/BNC/bncgetthread.cpp@ 3528

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