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

Last change on this file since 9783 was 9783, checked in by stuerze, 22 months ago

some changes regarding PPP

File size: 22.0 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
[9709]125 connect(BNC_CMB, SIGNAL(newCodeBiases(QList<t_satCodeBias>)),
126 this, SLOT(slotNewCodeBiases(QList<t_satCodeBias>)),conType);
127
[7972]128 connect(BNC_CORE, SIGNAL(providerIDChanged(QString)),
129 this, SLOT(slotProviderIDChanged(QString)));
[5860]130 }
131 else {
[5889]132 _rnxObsFile = 0;
133 _rnxNavFile = 0;
134 _corrFile = 0;
[9599]135 _ionoFile = 0;
[5953]136 _speed = settings.value("PPP/mapSpeedSlider").toInt();
[5941]137 connect(this, SIGNAL(progressRnxPPP(int)), BNC_CORE, SIGNAL(progressRnxPPP(int)));
138 connect(this, SIGNAL(finishedRnxPPP()), BNC_CORE, SIGNAL(finishedRnxPPP()));
[7278]139 connect(BNC_CORE, SIGNAL(mapSpeedSliderChanged(int)),
[5950]140 this, SLOT(slotSetSpeed(int)));
[5973]141 connect(BNC_CORE, SIGNAL(stopRinexPPP()), this, SLOT(slotSetStopFlag()));
[5860]142 }
[7278]143
[5973]144 _stopFlag = false;
[5984]145
[8794]146 QString roverName(_opt->_roverName.c_str());
[7506]147 QString country;
148 QString monNum = "0";
149 QString recNum = "0";
[8794]150 if (roverName.length() >= 9) {
151 monNum = QChar(roverName[4]);
152 recNum = QChar(roverName[5]);
153 }
[7506]154 QString intr = "1 day";
155 int sampl = 0;
[8320]156 QString distStr;
157 int num = 0;
158 int statIDlength = roverName.size() -1;
159 QString ID4 = roverName.left(4);
[9615]160 QString ID9 = roverName.left(9);
[8320]161 ID4 = ID4.toUpper();
[9615]162 ID4 = ID9.toUpper();
[7506]163 QListIterator<QString> it(settings.value("mountPoints").toStringList());
164 while (it.hasNext()) {
[8320]165 QString mp = it.next();
166 if (mp.indexOf(roverName.left(statIDlength)) != -1) {
167 ++num;
168 }
169 QStringList hlp = mp.split(" ");
[7506]170 if (hlp.size() < 7)
171 continue;
172 if (hlp.join(" ").indexOf(roverName, 0) != -1) {
173 country = hlp[2];
174 }
175 }
[5988]176
[8320]177 if (num > 1) {
178 distStr = "." + roverName.right(1);
179 }
180
[9615]181 if (ID9.size() < 9) {
182 ID9 = ID4
183 + QString("%1").arg(monNum, 1, 10)
184 + QString("%1").arg(recNum, 1, 10)
185 + country;
186 }
[7506]187 QString logFileSkl = settings.value("PPP/logPath").toString();
[7520]188 int l = logFileSkl.length();
[5988]189 if (logFileSkl.isEmpty()) {
190 _logFile = 0;
[5987]191 }
192 else {
[7520]193 if (l && logFileSkl[l-1] != QDir::separator() ) {
194 logFileSkl += QDir::separator();
195 }
[9783]196
197 logFileSkl = logFileSkl + ID9 + "${V3PROD}" + distStr + ".ppp";
198
[7506]199 _logFile = new bncoutf(logFileSkl, intr, sampl);
[5987]200 }
[5988]201
[7506]202 QString nmeaFileSkl = settings.value("PPP/nmeaPath").toString();
[7520]203 l = nmeaFileSkl.length();
[5988]204 if (nmeaFileSkl.isEmpty()) {
205 _nmeaFile = 0;
206 }
207 else {
[7520]208 if (l > 0 && nmeaFileSkl[l-1] != QDir::separator() ) {
209 nmeaFileSkl += QDir::separator();
210 }
[9783]211 nmeaFileSkl = nmeaFileSkl + ID9 + "${V3PROD}" + distStr + ".nmea";
212
[7506]213 _nmeaFile = new bncoutf(nmeaFileSkl, intr, sampl);
[5988]214 }
[7506]215 QString snxtroFileSkl = settings.value("PPP/snxtroPath").toString();
[7520]216 l = snxtroFileSkl.length();
[6608]217 if (snxtroFileSkl.isEmpty()) {
218 _snxtroFile = 0;
219 }
220 else {
[7520]221 if (l > 0 && snxtroFileSkl[l-1] != QDir::separator() ) {
222 snxtroFileSkl += QDir::separator();
223 }
[9783]224 snxtroFileSkl = snxtroFileSkl + ID9 + "${V3PROD}" + distStr + ".tra";
[8403]225 sampl = settings.value("PPP/snxtroSampl").toString().split("sec").first().toInt();
[7506]226 intr = settings.value("PPP/snxtroIntr").toString();
227 _snxtroFile = new bncSinexTro(_opt, snxtroFileSkl, intr, sampl);
[6608]228 }
[5860]229}
230
[6608]231
232
[5860]233// Destructor
234////////////////////////////////////////////////////////////////////////////
[5883]235t_pppRun::~t_pppRun() {
[5984]236 delete _logFile;
[5988]237 delete _nmeaFile;
[6608]238 delete _snxtroFile;
[7655]239 while (!_epoData.empty()) {
[7926]240 delete _epoData.front();
[7655]241 _epoData.pop_front();
242 }
[5860]243}
244
[7278]245//
[5860]246////////////////////////////////////////////////////////////////////////////
[6433]247void t_pppRun::slotNewGPSEph(t_ephGPS eph) {
[5860]248 QMutexLocker locker(&_mutex);
249 _pppClient->putEphemeris(&eph);
250}
251
[7278]252//
[5860]253////////////////////////////////////////////////////////////////////////////
[6433]254void t_pppRun::slotNewGlonassEph(t_ephGlo eph) {
[5860]255 QMutexLocker locker(&_mutex);
256 _pppClient->putEphemeris(&eph);
257}
[7278]258
259//
[5860]260////////////////////////////////////////////////////////////////////////////
[6433]261void t_pppRun::slotNewGalileoEph(t_ephGal eph) {
[5860]262 QMutexLocker locker(&_mutex);
263 _pppClient->putEphemeris(&eph);
264}
265
266//
267////////////////////////////////////////////////////////////////////////////
[6966]268void t_pppRun::slotNewBDSEph(t_ephBDS eph) {
269 QMutexLocker locker(&_mutex);
270 _pppClient->putEphemeris(&eph);
271}
272
273//
274////////////////////////////////////////////////////////////////////////////
[6137]275void t_pppRun::slotNewObs(QByteArray staID, QList<t_satObs> obsList) {
[5860]276 QMutexLocker locker(&_mutex);
277
278 if (string(staID.data()) != _opt->_roverName) {
279 return;
280 }
281
[7278]282 // Loop over all observations (possible different epochs)
[5860]283 // -----------------------------------------------------
[6137]284 QListIterator<t_satObs> it(obsList);
[5860]285 while (it.hasNext()) {
[6137]286 const t_satObs& oldObs = it.next();
287 t_satObs* newObs = new t_satObs(oldObs);
[5860]288
289 // Find the corresponding data epoch or create a new one
290 // -----------------------------------------------------
291 t_epoData* epoch = 0;
292 deque<t_epoData*>::const_iterator it;
293 for (it = _epoData.begin(); it != _epoData.end(); it++) {
294 if (newObs->_time == (*it)->_time) {
295 epoch = *it;
296 break;
297 }
298 }
299 if (epoch == 0) {
300 if (_epoData.empty() || newObs->_time > _epoData.back()->_time) {
301 epoch = new t_epoData;
302 epoch->_time = newObs->_time;
303 _epoData.push_back(epoch);
304 }
305 }
306
[6137]307 // Put data into the epoch
308 // -----------------------
[5860]309 if (epoch != 0) {
310 epoch->_satObs.push_back(newObs);
311 }
[6137]312 else {
313 delete newObs;
314 }
[5860]315 }
316
[7943]317 // Make sure the buffer does not grow beyond any limit
318 // ---------------------------------------------------
319 const unsigned MAX_EPODATA_SIZE = 120;
320 if (_epoData.size() > MAX_EPODATA_SIZE) {
321 delete _epoData.front();
322 _epoData.pop_front();
323 }
324
[5860]325 // Process the oldest epochs
326 // ------------------------
[7943]327 while (_epoData.size()) {
[5860]328
329 const vector<t_satObs*>& satObs = _epoData.front()->_satObs;
330
[7943]331 // No corrections yet, skip the epoch
332 // ----------------------------------
333 if (_opt->_corrWaitTime && !_lastClkCorrTime.valid()) {
334 return;
[5873]335 }
336
[7943]337 // Process the front epoch
338 // -----------------------
339 if (_opt->_corrWaitTime == 0 ||
[9622]340 (_epoData.front()->_time - _lastClkCorrTime) < _opt->_corrWaitTime) {
[7278]341
[9783]342 if (_opt->_corrWaitTime != 0 && (fabs(_epoData.front()->_time - _lastClkCorrTime) > 60.0)) {
[9547]343 delete _epoData.front();
344 _epoData.pop_front();
[9550]345 continue;
[9547]346 }
347
[7943]348 t_output output;
349 _pppClient->processEpoch(satObs, &output);
[5980]350
[7943]351 if (!output._error) {
352 QVector<double> xx(6);
353 xx.data()[0] = output._xyzRover[0];
354 xx.data()[1] = output._xyzRover[1];
355 xx.data()[2] = output._xyzRover[2];
356 xx.data()[3] = output._neu[0];
357 xx.data()[4] = output._neu[1];
358 xx.data()[5] = output._neu[2];
359 emit newPosition(staID, output._epoTime, xx);
360 }
[5984]361
[7943]362 delete _epoData.front();
363 _epoData.pop_front();
364
365 ostringstream log;
[9543]366 if (output._error) {
[7943]367 log << output._log;
[5989]368 }
[7943]369 else {
370 log.setf(ios::fixed);
371 log << string(output._epoTime) << ' ' << staID.data()
372 << " X = " << setprecision(4) << output._xyzRover[0]
373 << " Y = " << setprecision(4) << output._xyzRover[1]
374 << " Z = " << setprecision(4) << output._xyzRover[2]
375 << " NEU: " << showpos << setw(8) << setprecision(4) << output._neu[0]
376 << " " << showpos << setw(8) << setprecision(4) << output._neu[1]
377 << " " << showpos << setw(8) << setprecision(4) << output._neu[2]
378 << " TRP: " << showpos << setw(8) << setprecision(4) << output._trp0
379 << " " << showpos << setw(8) << setprecision(4) << output._trp;
[7815]380 }
[7943]381
382 if (_logFile && output._epoTime.valid()) {
383 _logFile->write(output._epoTime.gpsw(), output._epoTime.gpssec(),
384 QString(output._log.c_str()));
385 }
386
387 if (!output._error) {
388 QString rmcStr = nmeaString('R', output);
389 QString ggaStr = nmeaString('G', output);
390 if (_nmeaFile) {
391 _nmeaFile->write(output._epoTime.gpsw(), output._epoTime.gpssec(), rmcStr);
392 _nmeaFile->write(output._epoTime.gpsw(), output._epoTime.gpssec(), ggaStr);
393 }
[8204]394 emit newNMEAstr(staID, rmcStr.toLatin1());
395 emit newNMEAstr(staID, ggaStr.toLatin1());
[7943]396 if (_snxtroFile && output._epoTime.valid()) {
397 _snxtroFile->write(staID, int(output._epoTime.gpsw()), output._epoTime.gpssec(),
398 output._trp0 + output._trp, output._trpStdev);
399 }
400 }
401 emit newMessage(QByteArray(log.str().c_str()), true);
[5989]402 }
[7943]403 else {
404 return;
405 }
[5860]406 }
407}
[7231]408
409//
410////////////////////////////////////////////////////////////////////////////
411void t_pppRun::slotNewTec(t_vTec vTec) {
412 if (vTec._layers.size() == 0) {
413 return;
414 }
415
416 if (_opt->_realTime) {
[9599]417 if (_opt->_ionoMount.empty() && _opt->_corrMount.empty()) {
[7231]418 return;
419 }
[9599]420 if ( _opt->_ionoMount.empty() &&
421 !_opt->_corrMount.empty() && _opt->_corrMount != vTec._staID) {
422 return;
423 }
424 if (!_opt->_ionoMount.empty() && _opt->_ionoMount != vTec._staID) {
425 return;
426 }
[7231]427 }
428 _pppClient->putTec(&vTec);
429}
430
[7278]431//
[5860]432////////////////////////////////////////////////////////////////////////////
[6141]433void t_pppRun::slotNewOrbCorrections(QList<t_orbCorr> orbCorr) {
434 if (orbCorr.size() == 0) {
435 return;
436 }
[5860]437
[5937]438 if (_opt->_realTime) {
[6141]439 if (_opt->_corrMount.empty() || _opt->_corrMount != orbCorr[0]._staID) {
[5937]440 return;
441 }
[5860]442 }
[6141]443 vector<t_orbCorr*> corrections;
444 for (int ii = 0; ii < orbCorr.size(); ii++) {
445 corrections.push_back(new t_orbCorr(orbCorr[ii]));
446 }
[5860]447
[7278]448 _pppClient->putOrbCorrections(corrections);
449
450 for (unsigned ii = 0; ii < corrections.size(); ii++) {
451 delete corrections[ii];
452 }
[6141]453}
454
[7278]455//
[6141]456////////////////////////////////////////////////////////////////////////////
457void t_pppRun::slotNewClkCorrections(QList<t_clkCorr> clkCorr) {
458 if (clkCorr.size() == 0) {
[5860]459 return;
460 }
461
[7301]462 if (_opt->_realTime) {
[6141]463 if (_opt->_corrMount.empty() || _opt->_corrMount != clkCorr[0]._staID) {
464 return;
[5860]465 }
466 }
[6141]467 vector<t_clkCorr*> corrections;
468 for (int ii = 0; ii < clkCorr.size(); ii++) {
469 corrections.push_back(new t_clkCorr(clkCorr[ii]));
[6991]470 _lastClkCorrTime = clkCorr[ii]._time;
[6141]471 }
[7278]472 _pppClient->putClkCorrections(corrections);
473
474 for (unsigned ii = 0; ii < corrections.size(); ii++) {
475 delete corrections[ii];
476 }
[5860]477}
[5883]478
[7278]479//
[5883]480////////////////////////////////////////////////////////////////////////////
[6478]481void t_pppRun::slotNewCodeBiases(QList<t_satCodeBias> codeBiases) {
482 if (codeBiases.size() == 0) {
483 return;
484 }
485
486 if (_opt->_realTime) {
487 if (_opt->_corrMount.empty() || _opt->_corrMount != codeBiases[0]._staID) {
488 return;
489 }
490 }
491 vector<t_satCodeBias*> biases;
492 for (int ii = 0; ii < codeBiases.size(); ii++) {
493 biases.push_back(new t_satCodeBias(codeBiases[ii]));
494 }
495
[7278]496 _pppClient->putCodeBiases(biases);
497
498 for (unsigned ii = 0; ii < biases.size(); ii++) {
499 delete biases[ii];
500 }
[6478]501}
502
[7278]503//
[6478]504////////////////////////////////////////////////////////////////////////////
[7288]505void t_pppRun::slotNewPhaseBiases(QList<t_satPhaseBias> phaseBiases) {
506 if (phaseBiases.size() == 0) {
507 return;
508 }
509
510 if (_opt->_realTime) {
511 if (_opt->_corrMount.empty() || _opt->_corrMount != phaseBiases[0]._staID) {
512 return;
513 }
514 }
515 vector<t_satPhaseBias*> biases;
516 for (int ii = 0; ii < phaseBiases.size(); ii++) {
517 biases.push_back(new t_satPhaseBias(phaseBiases[ii]));
518 }
519
520 _pppClient->putPhaseBiases(biases);
521
522 for (unsigned ii = 0; ii < biases.size(); ii++) {
523 delete biases[ii];
524 }
525}
526
527//
528////////////////////////////////////////////////////////////////////////////
[5883]529void t_pppRun::processFiles() {
530
531 try {
[5889]532 _rnxObsFile = new t_rnxObsFile(QString(_opt->_rinexObs.c_str()), t_rnxObsFile::input);
[5883]533 }
534 catch (...) {
535 delete _rnxObsFile; _rnxObsFile = 0;
[5940]536 emit finishedRnxPPP();
[5883]537 return;
538 }
539
[9609]540 try {
541 _rnxNavFile = new t_rnxNavFile(QString(_opt->_rinexNav.c_str()), t_rnxNavFile::input);
542 }
543 catch (...) {
544 delete _rnxNavFile; _rnxNavFile = 0;
545 emit finishedRnxPPP();
546 return;
547 }
[5883]548
[5889]549 if (!_opt->_corrFile.empty()) {
550 _corrFile = new t_corrFile(QString(_opt->_corrFile.c_str()));
[9609]551 if (_opt->_ionoFile.empty()) {
552 connect(_corrFile, SIGNAL(newTec(t_vTec)), this, SLOT(slotNewTec(t_vTec)));
553 }
554 connect(_corrFile, SIGNAL(newOrbCorrections(QList<t_orbCorr>)), this, SLOT(slotNewOrbCorrections(QList<t_orbCorr>)));
555 connect(_corrFile, SIGNAL(newClkCorrections(QList<t_clkCorr>)), this, SLOT(slotNewClkCorrections(QList<t_clkCorr>)));
556 connect(_corrFile, SIGNAL(newCodeBiases(QList<t_satCodeBias>)), this, SLOT(slotNewCodeBiases(QList<t_satCodeBias>)));
557 connect(_corrFile, SIGNAL(newPhaseBiases(QList<t_satPhaseBias>)), this, SLOT(slotNewPhaseBiases(QList<t_satPhaseBias>)));
[5883]558 }
559
[9599]560 if (!_opt->_ionoFile.empty()) {
561 _ionoFile = new t_corrFile(QString(_opt->_corrFile.c_str()));
[9609]562 connect(_ionoFile, SIGNAL(newTec(t_vTec)), this, SLOT(slotNewTec(t_vTec)));
[9599]563 }
564
[5883]565 // Read/Process Observations
566 // -------------------------
567 int nEpo = 0;
568 const t_rnxObsFile::t_rnxEpo* epo = 0;
[5973]569 while ( !_stopFlag && (epo = _rnxObsFile->nextEpoch()) != 0 ) {
[5883]570 ++nEpo;
571
[5951]572 if (_speed < 100) {
573 double sleepTime = 2.0 / _speed;
[6537]574 t_pppThread::msleep(int(sleepTime*1.e3));
[5883]575 }
576
577 // Get Corrections
578 // ---------------
579 if (_corrFile) {
[6510]580 try {
581 _corrFile->syncRead(epo->tt);
582 }
583 catch (const char* msg) {
584 emit newMessage(QByteArray(msg), true);
585 break;
586 }
587 catch (const string& msg) {
588 emit newMessage(QByteArray(msg.c_str()), true);
589 break;
590 }
591 catch (...) {
592 emit newMessage("unknown exceptions in corrFile", true);
593 break;
594 }
[5883]595 }
596
[9599]597 // Get Additional VTEC Informations
598 // --------------------------------
599 if (_ionoFile) {
600 try {
601 _ionoFile->syncRead(epo->tt);
602 }
603 catch (const char* msg) {
604 emit newMessage(QByteArray(msg), true);
605 break;
606 }
607 catch (const string& msg) {
608 emit newMessage(QByteArray(msg.c_str()), true);
609 break;
610 }
611 catch (...) {
612 emit newMessage("unknown exceptions in ionoFile", true);
613 break;
614 }
615 }
616
[5883]617 // Get Ephemerides
618 // ----------------
619 t_eph* eph = 0;
[7169]620 const QMap<QString, unsigned int>* corrIODs = _corrFile ? &_corrFile->corrIODs() : 0;
[5883]621 while ( (eph = _rnxNavFile->getNextEph(epo->tt, corrIODs)) != 0 ) {
[5889]622 _pppClient->putEphemeris(eph);
623 delete eph; eph = 0;
[5883]624 }
625
[5890]626 // Create list of observations and start epoch processing
627 // ------------------------------------------------------
[6137]628 QList<t_satObs> obsList;
[5883]629 for (unsigned iObs = 0; iObs < epo->rnxSat.size(); iObs++) {
630 const t_rnxObsFile::t_rnxSat& rnxSat = epo->rnxSat[iObs];
[7278]631
[6137]632 t_satObs obs;
[5883]633 t_rnxObsFile::setObsFromRnx(_rnxObsFile, epo, rnxSat, obs);
[5890]634 obsList << obs;
635 }
636 slotNewObs(QByteArray(_opt->_roverName.c_str()), obsList);
[5883]637
[5890]638
[5883]639 if (nEpo % 10 == 0) {
[5940]640 emit progressRnxPPP(nEpo);
[5883]641 }
[7278]642
[5950]643 QCoreApplication::processEvents();
[5883]644 }
645
[5940]646 emit finishedRnxPPP();
[5927]647
[5883]648 if (BNC_CORE->mode() != t_bncCore::interactive) {
649 qApp->exit(0);
650 }
[5944]651 else {
652 BNC_CORE->stopPPP();
653 }
[5883]654}
655
[7278]656//
[5883]657////////////////////////////////////////////////////////////////////////////
658void t_pppRun::slotSetSpeed(int speed) {
659 QMutexLocker locker(&_mutex);
660 _speed = speed;
661}
[5973]662
[7278]663//
[5973]664////////////////////////////////////////////////////////////////////////////
665void t_pppRun::slotSetStopFlag() {
666 QMutexLocker locker(&_mutex);
667 _stopFlag = true;
668}
[5989]669
[7278]670//
[5989]671////////////////////////////////////////////////////////////////////////////
[5990]672QString t_pppRun::nmeaString(char strType, const t_output& output) {
[5989]673
[7278]674 double ell[3];
[5989]675 xyz2ell(output._xyzRover, ell);
676 double phiDeg = ell[0] * 180 / M_PI;
677 double lamDeg = ell[1] * 180 / M_PI;
678
[7926]679 unsigned year, month, day;
680 output._epoTime.civil_date(year, month, day);
681 double gps_utc = gnumleap(year, month, day);
682
[5989]683 char phiCh = 'N';
684 if (phiDeg < 0) {
685 phiDeg = -phiDeg;
686 phiCh = 'S';
[7278]687 }
[5989]688 char lamCh = 'E';
689 if (lamDeg < 0) {
690 lamDeg = -lamDeg;
691 lamCh = 'W';
[7278]692 }
[5989]693
[5990]694 ostringstream out;
695 out.setf(ios::fixed);
[5989]696
[5990]697 if (strType == 'R') {
[8824]698 string datestr = (output._epoTime - gps_utc).datestr(0); // yyyymmdd
[7278]699 out << "GPRMC,"
[7926]700 << (output._epoTime - gps_utc).timestr(3,0) << ",A,"
[7278]701 << setw(2) << setfill('0') << int(phiDeg)
[8824]702 << setw(7) << setprecision(4) << setfill('0') << fmod(60*phiDeg,60) << ',' << phiCh << ','
[7278]703 << setw(3) << setfill('0') << int(lamDeg)
[8824]704 << setw(7) << setprecision(4) << setfill('0') << fmod(60*lamDeg,60) << ',' << lamCh << ",,,"
705 << datestr[6] << datestr[7] << datestr[4] << datestr[5] << datestr[2] << datestr[3] << ",,";
[5990]706 }
707 else if (strType == 'G') {
[7278]708 out << "GPGGA,"
[7926]709 << (output._epoTime - gps_utc).timestr(2,0) << ','
[7278]710 << setw(2) << setfill('0') << int(phiDeg)
711 << setw(10) << setprecision(7) << setfill('0')
[5990]712 << fmod(60*phiDeg,60) << ',' << phiCh << ','
[7278]713 << setw(3) << setfill('0') << int(lamDeg)
714 << setw(10) << setprecision(7) << setfill('0')
715 << fmod(60*lamDeg,60) << ',' << lamCh
[5990]716 << ",1," << setw(2) << setfill('0') << output._numSat << ','
[7926]717 << setw(3) << setprecision(1) << output._hDop << ','
[5990]718 << setprecision(3) << ell[2] << ",M,0.0,M,,";
719 }
720 else {
721 return "";
722 }
[5989]723
[5990]724 QString nmStr(out.str().c_str());
[5989]725 unsigned char XOR = 0;
726 for (int ii = 0; ii < nmStr.length(); ii++) {
[8204]727 XOR ^= (unsigned char) nmStr[ii].toLatin1();
[5989]728 }
729
[8692]730 return '$' + nmStr + QString("*%1").arg(XOR, 2, 16, QLatin1Char('0')) + "\n";
[5989]731}
[7972]732
733//
734////////////////////////////////////////////////////////////////////////////
735void t_pppRun::slotProviderIDChanged(QString mountPoint) {
736 QMutexLocker locker(&_mutex);
737
738 if (mountPoint.toStdString() !=_opt->_corrMount) {
739 return;
740 }
741
742 QString msg = "pppRun " + QString(_opt->_roverName.c_str()) + ": Provider Changed: " + mountPoint;
[8204]743 emit newMessage(msg.toLatin1(), true);
[7972]744
745 _pppClient->reset();
746
747 while (!_epoData.empty()) {
748 delete _epoData.front();
749 _epoData.pop_front();
750 }
751}
Note: See TracBrowser for help on using the repository browser.