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

Last change on this file since 10927 was 10805, checked in by stuerze, 3 months ago

minor changes regarding ppp output

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