[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 | *
|
---|
| 38 | * Changes:
|
---|
| 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"
|
---|
[5883] | 55 | #include "rinex/rnxobsfile.h"
|
---|
| 56 | #include "rinex/rnxnavfile.h"
|
---|
| 57 | #include "rinex/corrfile.h"
|
---|
[5860] | 58 |
|
---|
| 59 | using namespace BNC_PPP;
|
---|
| 60 | using namespace std;
|
---|
| 61 |
|
---|
| 62 | // Constructor
|
---|
| 63 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5883] | 64 | t_pppRun::t_pppRun(const t_pppOptions* opt) {
|
---|
| 65 |
|
---|
[5860] | 66 | _opt = opt;
|
---|
[5883] | 67 |
|
---|
[5860] | 68 | connect(this, SIGNAL(newMessage(QByteArray,bool)),
|
---|
| 69 | BNC_CORE, SLOT(slotMessage(const QByteArray,bool)));
|
---|
[5883] | 70 |
|
---|
[5991] | 71 | connect(this, SIGNAL(newPosition(QByteArray, bncTime, QVector<double>)),
|
---|
[5954] | 72 | BNC_CORE, SIGNAL(newPosition(QByteArray, bncTime, QVector<double>)));
|
---|
[5949] | 73 |
|
---|
[5991] | 74 | connect(this, SIGNAL(newNMEAstr(QByteArray, QByteArray)),
|
---|
| 75 | BNC_CORE, SIGNAL(newNMEAstr(QByteArray, QByteArray)));
|
---|
| 76 |
|
---|
[5883] | 77 | _pppClient = new t_pppClient(_opt);
|
---|
| 78 |
|
---|
[5984] | 79 | bncSettings settings;
|
---|
| 80 |
|
---|
[5860] | 81 | if (_opt->_realTime) {
|
---|
[5945] | 82 | Qt::ConnectionType conType = Qt::AutoConnection;
|
---|
| 83 | if (BNC_CORE->mode() == t_bncCore::batchPostProcessing) {
|
---|
| 84 | conType = Qt::BlockingQueuedConnection;
|
---|
| 85 | }
|
---|
| 86 |
|
---|
[6137] | 87 | connect(BNC_CORE->caster(), SIGNAL(newObs(QByteArray, QList<t_satObs>)),
|
---|
| 88 | this, SLOT(slotNewObs(QByteArray, QList<t_satObs>)),conType);
|
---|
[5860] | 89 |
|
---|
[6433] | 90 | connect(BNC_CORE, SIGNAL(newGPSEph(t_ephGPS)),
|
---|
| 91 | this, SLOT(slotNewGPSEph(t_ephGPS)),conType);
|
---|
[5860] | 92 |
|
---|
[6433] | 93 | connect(BNC_CORE, SIGNAL(newGlonassEph(t_ephGlo)),
|
---|
| 94 | this, SLOT(slotNewGlonassEph(t_ephGlo)),conType);
|
---|
[5860] | 95 |
|
---|
[6433] | 96 | connect(BNC_CORE, SIGNAL(newGalileoEph(t_ephGal)),
|
---|
| 97 | this, SLOT(slotNewGalileoEph(t_ephGal)),conType);
|
---|
[5860] | 98 |
|
---|
[6141] | 99 | connect(BNC_CORE, SIGNAL(newOrbCorrections(QList<t_orbCorr>)),
|
---|
| 100 | this, SLOT(slotNewOrbCorrections(QList<t_orbCorr>)),conType);
|
---|
| 101 |
|
---|
| 102 | connect(BNC_CORE, SIGNAL(newClkCorrections(QList<t_clkCorr>)),
|
---|
| 103 | this, SLOT(slotNewClkCorrections(QList<t_clkCorr>)),conType);
|
---|
[5860] | 104 | }
|
---|
| 105 | else {
|
---|
[5889] | 106 | _rnxObsFile = 0;
|
---|
| 107 | _rnxNavFile = 0;
|
---|
| 108 | _corrFile = 0;
|
---|
[5953] | 109 | _speed = settings.value("PPP/mapSpeedSlider").toInt();
|
---|
[5941] | 110 | connect(this, SIGNAL(progressRnxPPP(int)), BNC_CORE, SIGNAL(progressRnxPPP(int)));
|
---|
| 111 | connect(this, SIGNAL(finishedRnxPPP()), BNC_CORE, SIGNAL(finishedRnxPPP()));
|
---|
[5950] | 112 | connect(BNC_CORE, SIGNAL(mapSpeedSliderChanged(int)),
|
---|
| 113 | this, SLOT(slotSetSpeed(int)));
|
---|
[5973] | 114 | connect(BNC_CORE, SIGNAL(stopRinexPPP()), this, SLOT(slotSetStopFlag()));
|
---|
[5860] | 115 | }
|
---|
[5973] | 116 |
|
---|
| 117 | _stopFlag = false;
|
---|
[5984] | 118 |
|
---|
[5988] | 119 | QString roverName(_opt->_roverName.c_str());
|
---|
| 120 |
|
---|
[5984] | 121 | QString logFileSkl = settings.value("PPP/logFile").toString();
|
---|
[5988] | 122 | if (logFileSkl.isEmpty()) {
|
---|
| 123 | _logFile = 0;
|
---|
[5987] | 124 | }
|
---|
| 125 | else {
|
---|
[5988] | 126 | if (logFileSkl.indexOf("${STATION}") == -1) {
|
---|
| 127 | logFileSkl = roverName + "_" + logFileSkl;
|
---|
| 128 | }
|
---|
| 129 | else {
|
---|
| 130 | logFileSkl.replace("${STATION}", roverName);
|
---|
| 131 | }
|
---|
| 132 | _logFile = new bncoutf(logFileSkl, "1 day", 0);
|
---|
[5987] | 133 | }
|
---|
[5988] | 134 |
|
---|
| 135 | QString nmeaFileSkl = settings.value("PPP/nmeaFile").toString();
|
---|
| 136 | if (nmeaFileSkl.isEmpty()) {
|
---|
| 137 | _nmeaFile = 0;
|
---|
| 138 | }
|
---|
| 139 | else {
|
---|
| 140 | if (nmeaFileSkl.indexOf("${STATION}") == -1) {
|
---|
| 141 | nmeaFileSkl = roverName + "_" + nmeaFileSkl;
|
---|
| 142 | }
|
---|
| 143 | else {
|
---|
| 144 | nmeaFileSkl.replace("${STATION}", roverName);
|
---|
| 145 | }
|
---|
| 146 | _nmeaFile = new bncoutf(nmeaFileSkl, "1 day", 0);
|
---|
| 147 | }
|
---|
[5860] | 148 | }
|
---|
| 149 |
|
---|
| 150 | // Destructor
|
---|
| 151 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5883] | 152 | t_pppRun::~t_pppRun() {
|
---|
[5984] | 153 | delete _logFile;
|
---|
[5988] | 154 | delete _nmeaFile;
|
---|
[5860] | 155 | }
|
---|
| 156 |
|
---|
| 157 | //
|
---|
| 158 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6433] | 159 | void t_pppRun::slotNewGPSEph(t_ephGPS eph) {
|
---|
[5860] | 160 | QMutexLocker locker(&_mutex);
|
---|
| 161 | _pppClient->putEphemeris(&eph);
|
---|
| 162 | }
|
---|
| 163 |
|
---|
| 164 | //
|
---|
| 165 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6433] | 166 | void t_pppRun::slotNewGlonassEph(t_ephGlo eph) {
|
---|
[5860] | 167 | QMutexLocker locker(&_mutex);
|
---|
| 168 | _pppClient->putEphemeris(&eph);
|
---|
| 169 | }
|
---|
| 170 |
|
---|
| 171 | //
|
---|
| 172 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6433] | 173 | void t_pppRun::slotNewGalileoEph(t_ephGal eph) {
|
---|
[5860] | 174 | QMutexLocker locker(&_mutex);
|
---|
| 175 | _pppClient->putEphemeris(&eph);
|
---|
| 176 | }
|
---|
| 177 |
|
---|
| 178 | //
|
---|
| 179 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6137] | 180 | void t_pppRun::slotNewObs(QByteArray staID, QList<t_satObs> obsList) {
|
---|
[5860] | 181 | QMutexLocker locker(&_mutex);
|
---|
| 182 |
|
---|
| 183 | if (string(staID.data()) != _opt->_roverName) {
|
---|
| 184 | return;
|
---|
| 185 | }
|
---|
| 186 |
|
---|
| 187 | // Loop over all obsevations (possible different epochs)
|
---|
| 188 | // -----------------------------------------------------
|
---|
[6137] | 189 | QListIterator<t_satObs> it(obsList);
|
---|
[5860] | 190 | while (it.hasNext()) {
|
---|
[6137] | 191 | const t_satObs& oldObs = it.next();
|
---|
| 192 | t_satObs* newObs = new t_satObs(oldObs);
|
---|
[5860] | 193 |
|
---|
| 194 | // Find the corresponding data epoch or create a new one
|
---|
| 195 | // -----------------------------------------------------
|
---|
| 196 | t_epoData* epoch = 0;
|
---|
| 197 | deque<t_epoData*>::const_iterator it;
|
---|
| 198 | for (it = _epoData.begin(); it != _epoData.end(); it++) {
|
---|
| 199 | if (newObs->_time == (*it)->_time) {
|
---|
| 200 | epoch = *it;
|
---|
| 201 | break;
|
---|
| 202 | }
|
---|
| 203 | }
|
---|
| 204 | if (epoch == 0) {
|
---|
| 205 | if (_epoData.empty() || newObs->_time > _epoData.back()->_time) {
|
---|
| 206 | epoch = new t_epoData;
|
---|
| 207 | epoch->_time = newObs->_time;
|
---|
| 208 | _epoData.push_back(epoch);
|
---|
| 209 | }
|
---|
| 210 | }
|
---|
| 211 |
|
---|
[6137] | 212 | // Put data into the epoch
|
---|
| 213 | // -----------------------
|
---|
[5860] | 214 | if (epoch != 0) {
|
---|
| 215 | epoch->_satObs.push_back(newObs);
|
---|
| 216 | }
|
---|
[6137] | 217 | else {
|
---|
| 218 | delete newObs;
|
---|
| 219 | }
|
---|
[5860] | 220 | }
|
---|
| 221 |
|
---|
| 222 | // Process the oldest epochs
|
---|
| 223 | // ------------------------
|
---|
[5999] | 224 | while (_epoData.size() && !waitForCorr(_epoData.front()->_time)) {
|
---|
[5860] | 225 |
|
---|
| 226 | const vector<t_satObs*>& satObs = _epoData.front()->_satObs;
|
---|
| 227 |
|
---|
| 228 | t_output output;
|
---|
| 229 | _pppClient->processEpoch(satObs, &output);
|
---|
| 230 |
|
---|
[5953] | 231 | if (!output._error) {
|
---|
[5879] | 232 | QVector<double> xx(6);
|
---|
| 233 | xx.data()[0] = output._xyzRover[0];
|
---|
| 234 | xx.data()[1] = output._xyzRover[1];
|
---|
| 235 | xx.data()[2] = output._xyzRover[2];
|
---|
| 236 | xx.data()[3] = output._neu[0];
|
---|
| 237 | xx.data()[4] = output._neu[1];
|
---|
| 238 | xx.data()[5] = output._neu[2];
|
---|
[5954] | 239 | emit newPosition(staID, output._epoTime, xx);
|
---|
[5873] | 240 | }
|
---|
| 241 |
|
---|
[5860] | 242 | delete _epoData.front(); _epoData.pop_front();
|
---|
| 243 |
|
---|
[5980] | 244 | ostringstream log;
|
---|
| 245 | if (output._error) {
|
---|
| 246 | log << output._log;
|
---|
| 247 | }
|
---|
| 248 | else {
|
---|
| 249 | log.setf(ios::fixed);
|
---|
[5982] | 250 | log << string(output._epoTime) << ' ' << staID.data()
|
---|
| 251 | << " X = " << setprecision(4) << output._xyzRover[0]
|
---|
| 252 | << " Y = " << setprecision(4) << output._xyzRover[1]
|
---|
| 253 | << " Z = " << setprecision(4) << output._xyzRover[2]
|
---|
| 254 | << " NEU: " << setprecision(4) << output._neu[0]
|
---|
| 255 | << " " << setprecision(4) << output._neu[1]
|
---|
| 256 | << " " << setprecision(4) << output._neu[2];
|
---|
[5980] | 257 | }
|
---|
| 258 |
|
---|
[5988] | 259 | if (_logFile && output._epoTime.valid()) {
|
---|
[5986] | 260 | _logFile->write(output._epoTime.gpsw(), output._epoTime.gpssec(),
|
---|
| 261 | QString(output._log.c_str()));
|
---|
| 262 | }
|
---|
[5984] | 263 |
|
---|
[5989] | 264 | if (!output._error) {
|
---|
[5990] | 265 | QString rmcStr = nmeaString('R', output);
|
---|
| 266 | QString ggaStr = nmeaString('G', output);
|
---|
[5989] | 267 | if (_nmeaFile) {
|
---|
| 268 | _nmeaFile->write(output._epoTime.gpsw(), output._epoTime.gpssec(), rmcStr);
|
---|
| 269 | _nmeaFile->write(output._epoTime.gpsw(), output._epoTime.gpssec(), ggaStr);
|
---|
| 270 | }
|
---|
| 271 | emit newNMEAstr(staID, rmcStr.toAscii());
|
---|
| 272 | emit newNMEAstr(staID, ggaStr.toAscii());
|
---|
| 273 | }
|
---|
| 274 |
|
---|
[5980] | 275 | emit newMessage(QByteArray(log.str().c_str()), true);
|
---|
[5860] | 276 | }
|
---|
| 277 | }
|
---|
| 278 |
|
---|
| 279 | //
|
---|
| 280 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6141] | 281 | void t_pppRun::slotNewOrbCorrections(QList<t_orbCorr> orbCorr) {
|
---|
| 282 | if (orbCorr.size() == 0) {
|
---|
| 283 | return;
|
---|
| 284 | }
|
---|
[5860] | 285 |
|
---|
[5937] | 286 | if (_opt->_realTime) {
|
---|
[6141] | 287 | if (_opt->_corrMount.empty() || _opt->_corrMount != orbCorr[0]._staID) {
|
---|
[5937] | 288 | return;
|
---|
| 289 | }
|
---|
[5860] | 290 | }
|
---|
[6141] | 291 | vector<t_orbCorr*> corrections;
|
---|
| 292 | for (int ii = 0; ii < orbCorr.size(); ii++) {
|
---|
| 293 | corrections.push_back(new t_orbCorr(orbCorr[ii]));
|
---|
| 294 | _lastClkCorrTime = orbCorr[ii]._time;
|
---|
| 295 | }
|
---|
[5860] | 296 |
|
---|
[6141] | 297 | _pppClient->putOrbCorrections(corrections);
|
---|
| 298 | }
|
---|
| 299 |
|
---|
| 300 | //
|
---|
| 301 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 302 | void t_pppRun::slotNewClkCorrections(QList<t_clkCorr> clkCorr) {
|
---|
| 303 | if (clkCorr.size() == 0) {
|
---|
[5860] | 304 | return;
|
---|
| 305 | }
|
---|
| 306 |
|
---|
[6141] | 307 | if (_opt->_realTime) {
|
---|
| 308 | if (_opt->_corrMount.empty() || _opt->_corrMount != clkCorr[0]._staID) {
|
---|
| 309 | return;
|
---|
[5860] | 310 | }
|
---|
| 311 | }
|
---|
[6141] | 312 | vector<t_clkCorr*> corrections;
|
---|
| 313 | for (int ii = 0; ii < clkCorr.size(); ii++) {
|
---|
| 314 | corrections.push_back(new t_clkCorr(clkCorr[ii]));
|
---|
| 315 | }
|
---|
[5860] | 316 |
|
---|
[6141] | 317 | _pppClient->putClkCorrections(corrections);
|
---|
[5860] | 318 | }
|
---|
[5883] | 319 |
|
---|
| 320 | //
|
---|
| 321 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 322 | void t_pppRun::processFiles() {
|
---|
| 323 |
|
---|
| 324 | try {
|
---|
[5889] | 325 | _rnxObsFile = new t_rnxObsFile(QString(_opt->_rinexObs.c_str()), t_rnxObsFile::input);
|
---|
[5883] | 326 | }
|
---|
| 327 | catch (...) {
|
---|
| 328 | delete _rnxObsFile; _rnxObsFile = 0;
|
---|
[5940] | 329 | emit finishedRnxPPP();
|
---|
[5883] | 330 | return;
|
---|
| 331 | }
|
---|
| 332 |
|
---|
[5889] | 333 | _rnxNavFile = new t_rnxNavFile(QString(_opt->_rinexNav.c_str()), t_rnxNavFile::input);
|
---|
[5883] | 334 |
|
---|
[5889] | 335 | if (!_opt->_corrFile.empty()) {
|
---|
| 336 | _corrFile = new t_corrFile(QString(_opt->_corrFile.c_str()));
|
---|
[6145] | 337 | connect(_corrFile, SIGNAL(newOrbCorrections(QList<t_orbCorr>)),
|
---|
| 338 | this, SLOT(slotNewOrbCorrections(QList<t_orbCorr>)));
|
---|
[6185] | 339 | connect(_corrFile, SIGNAL(newClkCorrections(QList<t_clkCorr>)),
|
---|
| 340 | this, SLOT(slotNewClkCorrections(QList<t_clkCorr>)));
|
---|
[5883] | 341 | }
|
---|
| 342 |
|
---|
| 343 | // Read/Process Observations
|
---|
| 344 | // -------------------------
|
---|
| 345 | int nEpo = 0;
|
---|
| 346 | const t_rnxObsFile::t_rnxEpo* epo = 0;
|
---|
[5973] | 347 | while ( !_stopFlag && (epo = _rnxObsFile->nextEpoch()) != 0 ) {
|
---|
[5883] | 348 | ++nEpo;
|
---|
| 349 |
|
---|
[5951] | 350 | if (_speed < 100) {
|
---|
| 351 | double sleepTime = 2.0 / _speed;
|
---|
| 352 | t_pppThread::msleep(sleepTime*1.e3);
|
---|
[5883] | 353 | }
|
---|
| 354 |
|
---|
| 355 | // Get Corrections
|
---|
| 356 | // ---------------
|
---|
| 357 | if (_corrFile) {
|
---|
| 358 | _corrFile->syncRead(epo->tt);
|
---|
| 359 | }
|
---|
| 360 |
|
---|
| 361 | // Get Ephemerides
|
---|
| 362 | // ----------------
|
---|
| 363 | t_eph* eph = 0;
|
---|
| 364 | const QMap<QString, int>* corrIODs = _corrFile ? &_corrFile->corrIODs() : 0;
|
---|
| 365 | while ( (eph = _rnxNavFile->getNextEph(epo->tt, corrIODs)) != 0 ) {
|
---|
[5889] | 366 | _pppClient->putEphemeris(eph);
|
---|
| 367 | delete eph; eph = 0;
|
---|
[5883] | 368 | }
|
---|
| 369 |
|
---|
[5890] | 370 | // Create list of observations and start epoch processing
|
---|
| 371 | // ------------------------------------------------------
|
---|
[6137] | 372 | QList<t_satObs> obsList;
|
---|
[5883] | 373 | for (unsigned iObs = 0; iObs < epo->rnxSat.size(); iObs++) {
|
---|
| 374 | const t_rnxObsFile::t_rnxSat& rnxSat = epo->rnxSat[iObs];
|
---|
| 375 |
|
---|
[6137] | 376 | t_satObs obs;
|
---|
[5883] | 377 | t_rnxObsFile::setObsFromRnx(_rnxObsFile, epo, rnxSat, obs);
|
---|
[5890] | 378 | obsList << obs;
|
---|
| 379 | }
|
---|
| 380 | slotNewObs(QByteArray(_opt->_roverName.c_str()), obsList);
|
---|
[5883] | 381 |
|
---|
[5890] | 382 |
|
---|
[5883] | 383 | if (nEpo % 10 == 0) {
|
---|
[5940] | 384 | emit progressRnxPPP(nEpo);
|
---|
[5883] | 385 | }
|
---|
[5950] | 386 |
|
---|
| 387 | QCoreApplication::processEvents();
|
---|
[5883] | 388 | }
|
---|
| 389 |
|
---|
[5940] | 390 | emit finishedRnxPPP();
|
---|
[5927] | 391 |
|
---|
[5883] | 392 | if (BNC_CORE->mode() != t_bncCore::interactive) {
|
---|
| 393 | qApp->exit(0);
|
---|
| 394 | }
|
---|
[5944] | 395 | else {
|
---|
| 396 | BNC_CORE->stopPPP();
|
---|
| 397 | }
|
---|
[5883] | 398 | }
|
---|
| 399 |
|
---|
| 400 | //
|
---|
| 401 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 402 | void t_pppRun::slotSetSpeed(int speed) {
|
---|
| 403 | QMutexLocker locker(&_mutex);
|
---|
| 404 | _speed = speed;
|
---|
| 405 | }
|
---|
[5973] | 406 |
|
---|
| 407 | //
|
---|
| 408 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 409 | void t_pppRun::slotSetStopFlag() {
|
---|
| 410 | QMutexLocker locker(&_mutex);
|
---|
| 411 | _stopFlag = true;
|
---|
| 412 | }
|
---|
[5989] | 413 |
|
---|
| 414 | //
|
---|
| 415 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5990] | 416 | QString t_pppRun::nmeaString(char strType, const t_output& output) {
|
---|
[5989] | 417 |
|
---|
| 418 | double ell[3];
|
---|
| 419 | xyz2ell(output._xyzRover, ell);
|
---|
| 420 | double phiDeg = ell[0] * 180 / M_PI;
|
---|
| 421 | double lamDeg = ell[1] * 180 / M_PI;
|
---|
| 422 |
|
---|
| 423 | char phiCh = 'N';
|
---|
| 424 | if (phiDeg < 0) {
|
---|
| 425 | phiDeg = -phiDeg;
|
---|
| 426 | phiCh = 'S';
|
---|
| 427 | }
|
---|
| 428 | char lamCh = 'E';
|
---|
| 429 | if (lamDeg < 0) {
|
---|
| 430 | lamDeg = -lamDeg;
|
---|
| 431 | lamCh = 'W';
|
---|
| 432 | }
|
---|
| 433 |
|
---|
[5990] | 434 | ostringstream out;
|
---|
| 435 | out.setf(ios::fixed);
|
---|
[5989] | 436 |
|
---|
[5990] | 437 | if (strType == 'R') {
|
---|
| 438 | string datestr = output._epoTime.datestr(0); // yyyymmdd
|
---|
| 439 | out << "GPRMC,"
|
---|
| 440 | << output._epoTime.timestr(0,0) << ",A,"
|
---|
| 441 | << setw(2) << setfill('0') << int(phiDeg)
|
---|
| 442 | << setw(6) << setprecision(3) << setfill('0')
|
---|
| 443 | << fmod(60*phiDeg,60) << ',' << phiCh << ','
|
---|
| 444 | << setw(3) << setfill('0') << int(lamDeg)
|
---|
| 445 | << setw(6) << setprecision(3) << setfill('0')
|
---|
| 446 | << fmod(60*lamDeg,60) << ',' << lamCh << ",,,"
|
---|
| 447 | << datestr[6] << datestr[7] << datestr[4] << datestr[5]
|
---|
| 448 | << datestr[2] << datestr[3] << ",,";
|
---|
| 449 | }
|
---|
| 450 | else if (strType == 'G') {
|
---|
| 451 | out << "GPGGA,"
|
---|
| 452 | << output._epoTime.timestr(0,0) << ','
|
---|
| 453 | << setw(2) << setfill('0') << int(phiDeg)
|
---|
| 454 | << setw(10) << setprecision(7) << setfill('0')
|
---|
| 455 | << fmod(60*phiDeg,60) << ',' << phiCh << ','
|
---|
| 456 | << setw(3) << setfill('0') << int(lamDeg)
|
---|
| 457 | << setw(10) << setprecision(7) << setfill('0')
|
---|
| 458 | << fmod(60*lamDeg,60) << ',' << lamCh
|
---|
| 459 | << ",1," << setw(2) << setfill('0') << output._numSat << ','
|
---|
| 460 | << setw(3) << setprecision(1) << output._pDop << ','
|
---|
| 461 | << setprecision(3) << ell[2] << ",M,0.0,M,,";
|
---|
| 462 | }
|
---|
| 463 | else {
|
---|
| 464 | return "";
|
---|
| 465 | }
|
---|
[5989] | 466 |
|
---|
[5990] | 467 | QString nmStr(out.str().c_str());
|
---|
[5989] | 468 | unsigned char XOR = 0;
|
---|
| 469 | for (int ii = 0; ii < nmStr.length(); ii++) {
|
---|
| 470 | XOR ^= (unsigned char) nmStr[ii].toAscii();
|
---|
| 471 | }
|
---|
| 472 |
|
---|
| 473 | return '$' + nmStr + QString("*%1\n").arg(int(XOR), 0, 16).toUpper();
|
---|
| 474 | }
|
---|
| 475 |
|
---|
[5999] | 476 | //
|
---|
| 477 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 478 | bool t_pppRun::waitForCorr(const bncTime& epoTime) const {
|
---|
| 479 |
|
---|
[6001] | 480 | if (!_opt->_realTime || _opt->_corrMount.empty()) {
|
---|
[5999] | 481 | return false;
|
---|
| 482 | }
|
---|
[6001] | 483 | else if (!_lastClkCorrTime.valid()) {
|
---|
| 484 | return true;
|
---|
| 485 | }
|
---|
| 486 | else {
|
---|
| 487 | double dt = epoTime - _lastClkCorrTime;
|
---|
| 488 | if (dt > 1.0 && dt < _opt->_corrWaitTime) {
|
---|
| 489 | return true;
|
---|
| 490 | }
|
---|
| 491 | else {
|
---|
| 492 | return false;
|
---|
| 493 | }
|
---|
| 494 | }
|
---|
[5999] | 495 | return false;
|
---|
| 496 | }
|
---|