source: ntrip/branches/BNC_2.12/src/pppRun.cpp@ 8669

Last change on this file since 8669 was 8645, checked in by stuerze, 6 years ago

big fixed in NMEA checksum

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