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