source: ntrip/trunk/BNC/src/pppRun.cpp@ 9615

Last change on this file since 9615 was 9615, checked in by stuerze, 2 years ago

minor changes

File size: 22.2 KB
RevLine 
[5860]1
2// Part of BNC, a utility for retrieving decoding and
3// converting GNSS data streams from NTRIP broadcasters.
4//
5// Copyright (C) 2007
6// German Federal Agency for Cartography and Geodesy (BKG)
7// http://www.bkg.bund.de
8// Czech Technical University Prague, Department of Geodesy
9// http://www.fsv.cvut.cz
10//
11// Email: euref-ip@bkg.bund.de
12//
13// This program is free software; you can redistribute it and/or
14// modify it under the terms of the GNU General Public License
15// as published by the Free Software Foundation, version 2.
16//
17// This program is distributed in the hope that it will be useful,
18// but WITHOUT ANY WARRANTY; without even the implied warranty of
19// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20// GNU General Public License for more details.
21//
22// You should have received a copy of the GNU General Public License
23// along with this program; if not, write to the Free Software
24// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25
26/* -------------------------------------------------------------------------
27 * BKG NTRIP Client
28 * -------------------------------------------------------------------------
29 *
[5883]30 * Class: t_pppRun
[5860]31 *
32 * Purpose: Single Real-Time PPP Client
33 *
34 * Author: L. Mervart
35 *
36 * Created: 29-Jul-2014
37 *
[7278]38 * Changes:
[5860]39 *
40 * -----------------------------------------------------------------------*/
41
42
43#include <iostream>
44#include <iomanip>
[5980]45#include <sstream>
[5860]46#include <string.h>
47#include <map>
48
[5883]49#include "pppRun.h"
[5891]50#include "pppThread.h"
[5860]51#include "bnccore.h"
52#include "bncephuser.h"
[5953]53#include "bncsettings.h"
[5984]54#include "bncoutf.h"
[6653]55#include "bncsinextro.h"
[5883]56#include "rinex/rnxobsfile.h"
57#include "rinex/rnxnavfile.h"
58#include "rinex/corrfile.h"
[7299]59#include "combination/bnccomb.h"
[5860]60
61using namespace BNC_PPP;
62using namespace std;
63
64// Constructor
65////////////////////////////////////////////////////////////////////////////
[5883]66t_pppRun::t_pppRun(const t_pppOptions* opt) {
67
[5860]68 _opt = opt;
[5883]69
[7278]70 connect(this, SIGNAL(newMessage(QByteArray,bool)),
[5860]71 BNC_CORE, SLOT(slotMessage(const QByteArray,bool)));
[5883]72
[5991]73 connect(this, SIGNAL(newPosition(QByteArray, bncTime, QVector<double>)),
[5954]74 BNC_CORE, SIGNAL(newPosition(QByteArray, bncTime, QVector<double>)));
[5949]75
[5991]76 connect(this, SIGNAL(newNMEAstr(QByteArray, QByteArray)),
77 BNC_CORE, SIGNAL(newNMEAstr(QByteArray, QByteArray)));
78
[5883]79 _pppClient = new t_pppClient(_opt);
80
[5984]81 bncSettings settings;
82
[5860]83 if (_opt->_realTime) {
[5945]84 Qt::ConnectionType conType = Qt::AutoConnection;
85 if (BNC_CORE->mode() == t_bncCore::batchPostProcessing) {
86 conType = Qt::BlockingQueuedConnection;
87 }
88
[6137]89 connect(BNC_CORE->caster(), SIGNAL(newObs(QByteArray, QList<t_satObs>)),
90 this, SLOT(slotNewObs(QByteArray, QList<t_satObs>)),conType);
[5860]91
[6433]92 connect(BNC_CORE, SIGNAL(newGPSEph(t_ephGPS)),
93 this, SLOT(slotNewGPSEph(t_ephGPS)),conType);
[7278]94
[6433]95 connect(BNC_CORE, SIGNAL(newGlonassEph(t_ephGlo)),
96 this, SLOT(slotNewGlonassEph(t_ephGlo)),conType);
[7278]97
[6433]98 connect(BNC_CORE, SIGNAL(newGalileoEph(t_ephGal)),
99 this, SLOT(slotNewGalileoEph(t_ephGal)),conType);
[5860]100
[6966]101 connect(BNC_CORE, SIGNAL(newBDSEph(t_ephBDS)),
102 this, SLOT(slotNewBDSEph(t_ephBDS)),conType);
103
[7231]104 connect(BNC_CORE, SIGNAL(newTec(t_vTec)),
105 this, SLOT(slotNewTec(t_vTec)),conType);
106
[6141]107 connect(BNC_CORE, SIGNAL(newOrbCorrections(QList<t_orbCorr>)),
108 this, SLOT(slotNewOrbCorrections(QList<t_orbCorr>)),conType);
109
110 connect(BNC_CORE, SIGNAL(newClkCorrections(QList<t_clkCorr>)),
111 this, SLOT(slotNewClkCorrections(QList<t_clkCorr>)),conType);
[6478]112
113 connect(BNC_CORE, SIGNAL(newCodeBiases(QList<t_satCodeBias>)),
114 this, SLOT(slotNewCodeBiases(QList<t_satCodeBias>)),conType);
[7288]115
116 connect(BNC_CORE, SIGNAL(newPhaseBiases(QList<t_satPhaseBias>)),
117 this, SLOT(slotNewPhaseBiases(QList<t_satPhaseBias>)),conType);
[7299]118
119 connect(BNC_CMB, SIGNAL(newOrbCorrections(QList<t_orbCorr>)),
120 this, SLOT(slotNewOrbCorrections(QList<t_orbCorr>)),conType);
121
122 connect(BNC_CMB, SIGNAL(newClkCorrections(QList<t_clkCorr>)),
123 this, SLOT(slotNewClkCorrections(QList<t_clkCorr>)),conType);
[8320]124
[7972]125 connect(BNC_CORE, SIGNAL(providerIDChanged(QString)),
126 this, SLOT(slotProviderIDChanged(QString)));
[5860]127 }
128 else {
[5889]129 _rnxObsFile = 0;
130 _rnxNavFile = 0;
131 _corrFile = 0;
[9599]132 _ionoFile = 0;
[5953]133 _speed = settings.value("PPP/mapSpeedSlider").toInt();
[5941]134 connect(this, SIGNAL(progressRnxPPP(int)), BNC_CORE, SIGNAL(progressRnxPPP(int)));
135 connect(this, SIGNAL(finishedRnxPPP()), BNC_CORE, SIGNAL(finishedRnxPPP()));
[7278]136 connect(BNC_CORE, SIGNAL(mapSpeedSliderChanged(int)),
[5950]137 this, SLOT(slotSetSpeed(int)));
[5973]138 connect(BNC_CORE, SIGNAL(stopRinexPPP()), this, SLOT(slotSetStopFlag()));
[5860]139 }
[7278]140
[5973]141 _stopFlag = false;
[5984]142
[8794]143 QString roverName(_opt->_roverName.c_str());
[7506]144 QString country;
145 QString monNum = "0";
146 QString recNum = "0";
[8794]147 if (roverName.length() >= 9) {
148 monNum = QChar(roverName[4]);
149 recNum = QChar(roverName[5]);
150 }
[7506]151 QString intr = "1 day";
152 int sampl = 0;
[8320]153 QString distStr;
154 int num = 0;
155 int statIDlength = roverName.size() -1;
156 QString ID4 = roverName.left(4);
[9615]157 QString ID9 = roverName.left(9);
[8320]158 ID4 = ID4.toUpper();
[9615]159 ID4 = ID9.toUpper();
[7506]160 QListIterator<QString> it(settings.value("mountPoints").toStringList());
161 while (it.hasNext()) {
[8320]162 QString mp = it.next();
163 if (mp.indexOf(roverName.left(statIDlength)) != -1) {
164 ++num;
165 }
166 QStringList hlp = mp.split(" ");
[7506]167 if (hlp.size() < 7)
168 continue;
169 if (hlp.join(" ").indexOf(roverName, 0) != -1) {
170 country = hlp[2];
171 }
172 }
[5988]173
[8320]174 if (num > 1) {
175 distStr = "." + roverName.right(1);
176 }
177
[9615]178 if (ID9.size() < 9) {
179 ID9 = ID4
180 + QString("%1").arg(monNum, 1, 10)
181 + QString("%1").arg(recNum, 1, 10)
182 + country;
183 }
[9158]184 bool v2filenames = settings.value("PPP/v2filenames").toBool();
[7506]185 QString logFileSkl = settings.value("PPP/logPath").toString();
[7520]186 int l = logFileSkl.length();
[5988]187 if (logFileSkl.isEmpty()) {
188 _logFile = 0;
[5987]189 }
190 else {
[7520]191 if (l && logFileSkl[l-1] != QDir::separator() ) {
192 logFileSkl += QDir::separator();
193 }
[9158]194 if (!v2filenames) {
[9418]195 logFileSkl = logFileSkl + ID9 + "${V3PROD}" + distStr + ".ppp";
[5988]196 }
197 else {
[8320]198 logFileSkl = logFileSkl + ID4 + "${GPSWD}" + distStr + ".ppp";
[5988]199 }
[7506]200 _logFile = new bncoutf(logFileSkl, intr, sampl);
[5987]201 }
[5988]202
[7506]203 QString nmeaFileSkl = settings.value("PPP/nmeaPath").toString();
[7520]204 l = nmeaFileSkl.length();
[5988]205 if (nmeaFileSkl.isEmpty()) {
206 _nmeaFile = 0;
207 }
208 else {
[7520]209 if (l > 0 && nmeaFileSkl[l-1] != QDir::separator() ) {
210 nmeaFileSkl += QDir::separator();
211 }
[9158]212 if (!v2filenames) {
[9418]213 nmeaFileSkl = nmeaFileSkl + ID9 + "${V3PROD}" + distStr + ".nmea";
[5988]214 }
215 else {
[8320]216 nmeaFileSkl = nmeaFileSkl + ID4 + "${GPSWD}" + distStr + ".nmea";
[5988]217 }
[7506]218 _nmeaFile = new bncoutf(nmeaFileSkl, intr, sampl);
[5988]219 }
[7506]220 QString snxtroFileSkl = settings.value("PPP/snxtroPath").toString();
[7520]221 l = snxtroFileSkl.length();
[6608]222 if (snxtroFileSkl.isEmpty()) {
223 _snxtroFile = 0;
224 }
225 else {
[7520]226 if (l > 0 && snxtroFileSkl[l-1] != QDir::separator() ) {
227 snxtroFileSkl += QDir::separator();
228 }
[9158]229 if (!v2filenames) {
[9424]230 snxtroFileSkl = snxtroFileSkl + ID9 + "${V3PROD}" + distStr + ".tra";
[6608]231 }
232 else {
[8320]233 snxtroFileSkl = snxtroFileSkl + ID4 + "${GPSWD}" + distStr + ".tro";
[6608]234 }
[8403]235 sampl = settings.value("PPP/snxtroSampl").toString().split("sec").first().toInt();
[7506]236 intr = settings.value("PPP/snxtroIntr").toString();
237 _snxtroFile = new bncSinexTro(_opt, snxtroFileSkl, intr, sampl);
[6608]238 }
[5860]239}
240
[6608]241
242
[5860]243// Destructor
244////////////////////////////////////////////////////////////////////////////
[5883]245t_pppRun::~t_pppRun() {
[5984]246 delete _logFile;
[5988]247 delete _nmeaFile;
[6608]248 delete _snxtroFile;
[7655]249 while (!_epoData.empty()) {
[7926]250 delete _epoData.front();
[7655]251 _epoData.pop_front();
252 }
[5860]253}
254
[7278]255//
[5860]256////////////////////////////////////////////////////////////////////////////
[6433]257void t_pppRun::slotNewGPSEph(t_ephGPS eph) {
[5860]258 QMutexLocker locker(&_mutex);
259 _pppClient->putEphemeris(&eph);
260}
261
[7278]262//
[5860]263////////////////////////////////////////////////////////////////////////////
[6433]264void t_pppRun::slotNewGlonassEph(t_ephGlo eph) {
[5860]265 QMutexLocker locker(&_mutex);
266 _pppClient->putEphemeris(&eph);
267}
[7278]268
269//
[5860]270////////////////////////////////////////////////////////////////////////////
[6433]271void t_pppRun::slotNewGalileoEph(t_ephGal eph) {
[5860]272 QMutexLocker locker(&_mutex);
273 _pppClient->putEphemeris(&eph);
274}
275
276//
277////////////////////////////////////////////////////////////////////////////
[6966]278void t_pppRun::slotNewBDSEph(t_ephBDS eph) {
279 QMutexLocker locker(&_mutex);
280 _pppClient->putEphemeris(&eph);
281}
282
283//
284////////////////////////////////////////////////////////////////////////////
[6137]285void t_pppRun::slotNewObs(QByteArray staID, QList<t_satObs> obsList) {
[5860]286 QMutexLocker locker(&_mutex);
287
288 if (string(staID.data()) != _opt->_roverName) {
289 return;
290 }
291
[7278]292 // Loop over all observations (possible different epochs)
[5860]293 // -----------------------------------------------------
[6137]294 QListIterator<t_satObs> it(obsList);
[5860]295 while (it.hasNext()) {
[6137]296 const t_satObs& oldObs = it.next();
297 t_satObs* newObs = new t_satObs(oldObs);
[5860]298
299 // Find the corresponding data epoch or create a new one
300 // -----------------------------------------------------
301 t_epoData* epoch = 0;
302 deque<t_epoData*>::const_iterator it;
303 for (it = _epoData.begin(); it != _epoData.end(); it++) {
304 if (newObs->_time == (*it)->_time) {
305 epoch = *it;
306 break;
307 }
308 }
309 if (epoch == 0) {
310 if (_epoData.empty() || newObs->_time > _epoData.back()->_time) {
311 epoch = new t_epoData;
312 epoch->_time = newObs->_time;
313 _epoData.push_back(epoch);
314 }
315 }
316
[6137]317 // Put data into the epoch
318 // -----------------------
[5860]319 if (epoch != 0) {
320 epoch->_satObs.push_back(newObs);
321 }
[6137]322 else {
323 delete newObs;
324 }
[5860]325 }
326
[7943]327 // Make sure the buffer does not grow beyond any limit
328 // ---------------------------------------------------
329 const unsigned MAX_EPODATA_SIZE = 120;
330 if (_epoData.size() > MAX_EPODATA_SIZE) {
331 delete _epoData.front();
332 _epoData.pop_front();
333 }
334
[5860]335 // Process the oldest epochs
336 // ------------------------
[7943]337 while (_epoData.size()) {
[5860]338
339 const vector<t_satObs*>& satObs = _epoData.front()->_satObs;
340
[7943]341 // No corrections yet, skip the epoch
342 // ----------------------------------
343 if (_opt->_corrWaitTime && !_lastClkCorrTime.valid()) {
344 return;
[5873]345 }
346
[7943]347 // Process the front epoch
348 // -----------------------
349 if (_opt->_corrWaitTime == 0 ||
350 _epoData.front()->_time - _lastClkCorrTime < _opt->_corrWaitTime) {
[7278]351
[9547]352 if (_epoData.front()->_time - _lastClkCorrTime < 0) {
353 delete _epoData.front();
354 _epoData.pop_front();
[9550]355 continue;
[9547]356 }
357
[7943]358 t_output output;
359 _pppClient->processEpoch(satObs, &output);
[5980]360
[7943]361 if (!output._error) {
362 QVector<double> xx(6);
363 xx.data()[0] = output._xyzRover[0];
364 xx.data()[1] = output._xyzRover[1];
365 xx.data()[2] = output._xyzRover[2];
366 xx.data()[3] = output._neu[0];
367 xx.data()[4] = output._neu[1];
368 xx.data()[5] = output._neu[2];
369 emit newPosition(staID, output._epoTime, xx);
370 }
[5984]371
[7943]372 delete _epoData.front();
373 _epoData.pop_front();
374
375 ostringstream log;
[9543]376 if (output._error) {
[7943]377 log << output._log;
[5989]378 }
[7943]379 else {
380 log.setf(ios::fixed);
381 log << string(output._epoTime) << ' ' << staID.data()
382 << " X = " << setprecision(4) << output._xyzRover[0]
383 << " Y = " << setprecision(4) << output._xyzRover[1]
384 << " Z = " << setprecision(4) << output._xyzRover[2]
385 << " NEU: " << showpos << setw(8) << setprecision(4) << output._neu[0]
386 << " " << showpos << setw(8) << setprecision(4) << output._neu[1]
387 << " " << showpos << setw(8) << setprecision(4) << output._neu[2]
388 << " TRP: " << showpos << setw(8) << setprecision(4) << output._trp0
389 << " " << showpos << setw(8) << setprecision(4) << output._trp;
[7815]390 }
[7943]391
392 if (_logFile && output._epoTime.valid()) {
393 _logFile->write(output._epoTime.gpsw(), output._epoTime.gpssec(),
394 QString(output._log.c_str()));
395 }
396
397 if (!output._error) {
398 QString rmcStr = nmeaString('R', output);
399 QString ggaStr = nmeaString('G', output);
400 if (_nmeaFile) {
401 _nmeaFile->write(output._epoTime.gpsw(), output._epoTime.gpssec(), rmcStr);
402 _nmeaFile->write(output._epoTime.gpsw(), output._epoTime.gpssec(), ggaStr);
403 }
[8204]404 emit newNMEAstr(staID, rmcStr.toLatin1());
405 emit newNMEAstr(staID, ggaStr.toLatin1());
[7943]406 if (_snxtroFile && output._epoTime.valid()) {
407 _snxtroFile->write(staID, int(output._epoTime.gpsw()), output._epoTime.gpssec(),
408 output._trp0 + output._trp, output._trpStdev);
409 }
410 }
411 emit newMessage(QByteArray(log.str().c_str()), true);
[5989]412 }
[7943]413 else {
414 return;
415 }
[5860]416 }
417}
[7231]418
419//
420////////////////////////////////////////////////////////////////////////////
421void t_pppRun::slotNewTec(t_vTec vTec) {
422 if (vTec._layers.size() == 0) {
423 return;
424 }
425
426 if (_opt->_realTime) {
[9599]427 if (_opt->_ionoMount.empty() && _opt->_corrMount.empty()) {
[7231]428 return;
429 }
[9599]430 if ( _opt->_ionoMount.empty() &&
431 !_opt->_corrMount.empty() && _opt->_corrMount != vTec._staID) {
432 return;
433 }
434 if (!_opt->_ionoMount.empty() && _opt->_ionoMount != vTec._staID) {
435 return;
436 }
[7231]437 }
438 _pppClient->putTec(&vTec);
439}
440
[7278]441//
[5860]442////////////////////////////////////////////////////////////////////////////
[6141]443void t_pppRun::slotNewOrbCorrections(QList<t_orbCorr> orbCorr) {
444 if (orbCorr.size() == 0) {
445 return;
446 }
[5860]447
[5937]448 if (_opt->_realTime) {
[6141]449 if (_opt->_corrMount.empty() || _opt->_corrMount != orbCorr[0]._staID) {
[5937]450 return;
451 }
[5860]452 }
[6141]453 vector<t_orbCorr*> corrections;
454 for (int ii = 0; ii < orbCorr.size(); ii++) {
455 corrections.push_back(new t_orbCorr(orbCorr[ii]));
456 }
[5860]457
[7278]458 _pppClient->putOrbCorrections(corrections);
459
460 for (unsigned ii = 0; ii < corrections.size(); ii++) {
461 delete corrections[ii];
462 }
[6141]463}
464
[7278]465//
[6141]466////////////////////////////////////////////////////////////////////////////
467void t_pppRun::slotNewClkCorrections(QList<t_clkCorr> clkCorr) {
468 if (clkCorr.size() == 0) {
[5860]469 return;
470 }
471
[7301]472 if (_opt->_realTime) {
[6141]473 if (_opt->_corrMount.empty() || _opt->_corrMount != clkCorr[0]._staID) {
474 return;
[5860]475 }
476 }
[6141]477 vector<t_clkCorr*> corrections;
478 for (int ii = 0; ii < clkCorr.size(); ii++) {
479 corrections.push_back(new t_clkCorr(clkCorr[ii]));
[6991]480 _lastClkCorrTime = clkCorr[ii]._time;
[6141]481 }
[7278]482 _pppClient->putClkCorrections(corrections);
483
484 for (unsigned ii = 0; ii < corrections.size(); ii++) {
485 delete corrections[ii];
486 }
[5860]487}
[5883]488
[7278]489//
[5883]490////////////////////////////////////////////////////////////////////////////
[6478]491void t_pppRun::slotNewCodeBiases(QList<t_satCodeBias> codeBiases) {
492 if (codeBiases.size() == 0) {
493 return;
494 }
495
496 if (_opt->_realTime) {
497 if (_opt->_corrMount.empty() || _opt->_corrMount != codeBiases[0]._staID) {
498 return;
499 }
500 }
501 vector<t_satCodeBias*> biases;
502 for (int ii = 0; ii < codeBiases.size(); ii++) {
503 biases.push_back(new t_satCodeBias(codeBiases[ii]));
504 }
505
[7278]506 _pppClient->putCodeBiases(biases);
507
508 for (unsigned ii = 0; ii < biases.size(); ii++) {
509 delete biases[ii];
510 }
[6478]511}
512
[7278]513//
[6478]514////////////////////////////////////////////////////////////////////////////
[7288]515void t_pppRun::slotNewPhaseBiases(QList<t_satPhaseBias> phaseBiases) {
516 if (phaseBiases.size() == 0) {
517 return;
518 }
519
520 if (_opt->_realTime) {
521 if (_opt->_corrMount.empty() || _opt->_corrMount != phaseBiases[0]._staID) {
522 return;
523 }
524 }
525 vector<t_satPhaseBias*> biases;
526 for (int ii = 0; ii < phaseBiases.size(); ii++) {
527 biases.push_back(new t_satPhaseBias(phaseBiases[ii]));
528 }
529
530 _pppClient->putPhaseBiases(biases);
531
532 for (unsigned ii = 0; ii < biases.size(); ii++) {
533 delete biases[ii];
534 }
535}
536
537//
538////////////////////////////////////////////////////////////////////////////
[5883]539void t_pppRun::processFiles() {
540
541 try {
[5889]542 _rnxObsFile = new t_rnxObsFile(QString(_opt->_rinexObs.c_str()), t_rnxObsFile::input);
[5883]543 }
544 catch (...) {
545 delete _rnxObsFile; _rnxObsFile = 0;
[5940]546 emit finishedRnxPPP();
[5883]547 return;
548 }
549
[9609]550 try {
551 _rnxNavFile = new t_rnxNavFile(QString(_opt->_rinexNav.c_str()), t_rnxNavFile::input);
552 }
553 catch (...) {
554 delete _rnxNavFile; _rnxNavFile = 0;
555 emit finishedRnxPPP();
556 return;
557 }
[5883]558
[5889]559 if (!_opt->_corrFile.empty()) {
560 _corrFile = new t_corrFile(QString(_opt->_corrFile.c_str()));
[9609]561
562 if (_opt->_ionoFile.empty()) {
563 connect(_corrFile, SIGNAL(newTec(t_vTec)), this, SLOT(slotNewTec(t_vTec)));
564 }
565 connect(_corrFile, SIGNAL(newOrbCorrections(QList<t_orbCorr>)), this, SLOT(slotNewOrbCorrections(QList<t_orbCorr>)));
566 connect(_corrFile, SIGNAL(newClkCorrections(QList<t_clkCorr>)), this, SLOT(slotNewClkCorrections(QList<t_clkCorr>)));
567 connect(_corrFile, SIGNAL(newCodeBiases(QList<t_satCodeBias>)), this, SLOT(slotNewCodeBiases(QList<t_satCodeBias>)));
568 connect(_corrFile, SIGNAL(newPhaseBiases(QList<t_satPhaseBias>)), this, SLOT(slotNewPhaseBiases(QList<t_satPhaseBias>)));
[5883]569 }
570
[9599]571 if (!_opt->_ionoFile.empty()) {
572 _ionoFile = new t_corrFile(QString(_opt->_corrFile.c_str()));
[9609]573 connect(_ionoFile, SIGNAL(newTec(t_vTec)), this, SLOT(slotNewTec(t_vTec)));
[9599]574 }
575
[5883]576 // Read/Process Observations
577 // -------------------------
578 int nEpo = 0;
579 const t_rnxObsFile::t_rnxEpo* epo = 0;
[5973]580 while ( !_stopFlag && (epo = _rnxObsFile->nextEpoch()) != 0 ) {
[5883]581 ++nEpo;
582
[5951]583 if (_speed < 100) {
584 double sleepTime = 2.0 / _speed;
[6537]585 t_pppThread::msleep(int(sleepTime*1.e3));
[5883]586 }
587
588 // Get Corrections
589 // ---------------
590 if (_corrFile) {
[6510]591 try {
592 _corrFile->syncRead(epo->tt);
593 }
594 catch (const char* msg) {
595 emit newMessage(QByteArray(msg), true);
596 break;
597 }
598 catch (const string& msg) {
599 emit newMessage(QByteArray(msg.c_str()), true);
600 break;
601 }
602 catch (...) {
603 emit newMessage("unknown exceptions in corrFile", true);
604 break;
605 }
[5883]606 }
607
[9599]608 // Get Additional VTEC Informations
609 // --------------------------------
610 if (_ionoFile) {
611 try {
612 _ionoFile->syncRead(epo->tt);
613 }
614 catch (const char* msg) {
615 emit newMessage(QByteArray(msg), true);
616 break;
617 }
618 catch (const string& msg) {
619 emit newMessage(QByteArray(msg.c_str()), true);
620 break;
621 }
622 catch (...) {
623 emit newMessage("unknown exceptions in ionoFile", true);
624 break;
625 }
626 }
627
[5883]628 // Get Ephemerides
629 // ----------------
630 t_eph* eph = 0;
[7169]631 const QMap<QString, unsigned int>* corrIODs = _corrFile ? &_corrFile->corrIODs() : 0;
[5883]632 while ( (eph = _rnxNavFile->getNextEph(epo->tt, corrIODs)) != 0 ) {
[5889]633 _pppClient->putEphemeris(eph);
634 delete eph; eph = 0;
[5883]635 }
636
[5890]637 // Create list of observations and start epoch processing
638 // ------------------------------------------------------
[6137]639 QList<t_satObs> obsList;
[5883]640 for (unsigned iObs = 0; iObs < epo->rnxSat.size(); iObs++) {
641 const t_rnxObsFile::t_rnxSat& rnxSat = epo->rnxSat[iObs];
[7278]642
[6137]643 t_satObs obs;
[5883]644 t_rnxObsFile::setObsFromRnx(_rnxObsFile, epo, rnxSat, obs);
[5890]645 obsList << obs;
646 }
647 slotNewObs(QByteArray(_opt->_roverName.c_str()), obsList);
[5883]648
[5890]649
[5883]650 if (nEpo % 10 == 0) {
[5940]651 emit progressRnxPPP(nEpo);
[5883]652 }
[7278]653
[5950]654 QCoreApplication::processEvents();
[5883]655 }
656
[5940]657 emit finishedRnxPPP();
[5927]658
[5883]659 if (BNC_CORE->mode() != t_bncCore::interactive) {
660 qApp->exit(0);
661 }
[5944]662 else {
663 BNC_CORE->stopPPP();
664 }
[5883]665}
666
[7278]667//
[5883]668////////////////////////////////////////////////////////////////////////////
669void t_pppRun::slotSetSpeed(int speed) {
670 QMutexLocker locker(&_mutex);
671 _speed = speed;
672}
[5973]673
[7278]674//
[5973]675////////////////////////////////////////////////////////////////////////////
676void t_pppRun::slotSetStopFlag() {
677 QMutexLocker locker(&_mutex);
678 _stopFlag = true;
679}
[5989]680
[7278]681//
[5989]682////////////////////////////////////////////////////////////////////////////
[5990]683QString t_pppRun::nmeaString(char strType, const t_output& output) {
[5989]684
[7278]685 double ell[3];
[5989]686 xyz2ell(output._xyzRover, ell);
687 double phiDeg = ell[0] * 180 / M_PI;
688 double lamDeg = ell[1] * 180 / M_PI;
689
[7926]690 unsigned year, month, day;
691 output._epoTime.civil_date(year, month, day);
692 double gps_utc = gnumleap(year, month, day);
693
[5989]694 char phiCh = 'N';
695 if (phiDeg < 0) {
696 phiDeg = -phiDeg;
697 phiCh = 'S';
[7278]698 }
[5989]699 char lamCh = 'E';
700 if (lamDeg < 0) {
701 lamDeg = -lamDeg;
702 lamCh = 'W';
[7278]703 }
[5989]704
[5990]705 ostringstream out;
706 out.setf(ios::fixed);
[5989]707
[5990]708 if (strType == 'R') {
[8824]709 string datestr = (output._epoTime - gps_utc).datestr(0); // yyyymmdd
[7278]710 out << "GPRMC,"
[7926]711 << (output._epoTime - gps_utc).timestr(3,0) << ",A,"
[7278]712 << setw(2) << setfill('0') << int(phiDeg)
[8824]713 << setw(7) << setprecision(4) << setfill('0') << fmod(60*phiDeg,60) << ',' << phiCh << ','
[7278]714 << setw(3) << setfill('0') << int(lamDeg)
[8824]715 << setw(7) << setprecision(4) << setfill('0') << fmod(60*lamDeg,60) << ',' << lamCh << ",,,"
716 << datestr[6] << datestr[7] << datestr[4] << datestr[5] << datestr[2] << datestr[3] << ",,";
[5990]717 }
718 else if (strType == 'G') {
[7278]719 out << "GPGGA,"
[7926]720 << (output._epoTime - gps_utc).timestr(2,0) << ','
[7278]721 << setw(2) << setfill('0') << int(phiDeg)
722 << setw(10) << setprecision(7) << setfill('0')
[5990]723 << fmod(60*phiDeg,60) << ',' << phiCh << ','
[7278]724 << setw(3) << setfill('0') << int(lamDeg)
725 << setw(10) << setprecision(7) << setfill('0')
726 << fmod(60*lamDeg,60) << ',' << lamCh
[5990]727 << ",1," << setw(2) << setfill('0') << output._numSat << ','
[7926]728 << setw(3) << setprecision(1) << output._hDop << ','
[5990]729 << setprecision(3) << ell[2] << ",M,0.0,M,,";
730 }
731 else {
732 return "";
733 }
[5989]734
[5990]735 QString nmStr(out.str().c_str());
[5989]736 unsigned char XOR = 0;
737 for (int ii = 0; ii < nmStr.length(); ii++) {
[8204]738 XOR ^= (unsigned char) nmStr[ii].toLatin1();
[5989]739 }
740
[8692]741 return '$' + nmStr + QString("*%1").arg(XOR, 2, 16, QLatin1Char('0')) + "\n";
[5989]742}
[7972]743
744//
745////////////////////////////////////////////////////////////////////////////
746void t_pppRun::slotProviderIDChanged(QString mountPoint) {
747 QMutexLocker locker(&_mutex);
748
749 if (mountPoint.toStdString() !=_opt->_corrMount) {
750 return;
751 }
752
753 QString msg = "pppRun " + QString(_opt->_roverName.c_str()) + ": Provider Changed: " + mountPoint;
[8204]754 emit newMessage(msg.toLatin1(), true);
[7972]755
756 _pppClient->reset();
757
758 while (!_epoData.empty()) {
759 delete _epoData.front();
760 _epoData.pop_front();
761 }
762}
Note: See TracBrowser for help on using the repository browser.