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

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

minor changes

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