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

Last change on this file since 7506 was 7506, checked in by stuerze, 9 years ago

automatic file name generation for ppp output files is added

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