[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);
|
---|
[6478] | 104 |
|
---|
| 105 | connect(BNC_CORE, SIGNAL(newCodeBiases(QList<t_satCodeBias>)),
|
---|
| 106 | this, SLOT(slotNewCodeBiases(QList<t_satCodeBias>)),conType);
|
---|
[5860] | 107 | }
|
---|
| 108 | else {
|
---|
[5889] | 109 | _rnxObsFile = 0;
|
---|
| 110 | _rnxNavFile = 0;
|
---|
| 111 | _corrFile = 0;
|
---|
[5953] | 112 | _speed = settings.value("PPP/mapSpeedSlider").toInt();
|
---|
[5941] | 113 | connect(this, SIGNAL(progressRnxPPP(int)), BNC_CORE, SIGNAL(progressRnxPPP(int)));
|
---|
| 114 | connect(this, SIGNAL(finishedRnxPPP()), BNC_CORE, SIGNAL(finishedRnxPPP()));
|
---|
[5950] | 115 | connect(BNC_CORE, SIGNAL(mapSpeedSliderChanged(int)),
|
---|
| 116 | this, SLOT(slotSetSpeed(int)));
|
---|
[5973] | 117 | connect(BNC_CORE, SIGNAL(stopRinexPPP()), this, SLOT(slotSetStopFlag()));
|
---|
[5860] | 118 | }
|
---|
[5973] | 119 |
|
---|
| 120 | _stopFlag = false;
|
---|
[5984] | 121 |
|
---|
[5988] | 122 | QString roverName(_opt->_roverName.c_str());
|
---|
| 123 |
|
---|
[5984] | 124 | QString logFileSkl = settings.value("PPP/logFile").toString();
|
---|
[5988] | 125 | if (logFileSkl.isEmpty()) {
|
---|
| 126 | _logFile = 0;
|
---|
[5987] | 127 | }
|
---|
| 128 | else {
|
---|
[5988] | 129 | if (logFileSkl.indexOf("${STATION}") == -1) {
|
---|
[6568] | 130 | logFileSkl = logFileSkl + "_" + roverName;
|
---|
[5988] | 131 | }
|
---|
| 132 | else {
|
---|
| 133 | logFileSkl.replace("${STATION}", roverName);
|
---|
| 134 | }
|
---|
| 135 | _logFile = new bncoutf(logFileSkl, "1 day", 0);
|
---|
[5987] | 136 | }
|
---|
[5988] | 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 | }
|
---|
[5860] | 151 | }
|
---|
| 152 |
|
---|
| 153 | // Destructor
|
---|
| 154 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5883] | 155 | t_pppRun::~t_pppRun() {
|
---|
[5984] | 156 | delete _logFile;
|
---|
[5988] | 157 | delete _nmeaFile;
|
---|
[5860] | 158 | }
|
---|
| 159 |
|
---|
| 160 | //
|
---|
| 161 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6433] | 162 | void t_pppRun::slotNewGPSEph(t_ephGPS eph) {
|
---|
[5860] | 163 | QMutexLocker locker(&_mutex);
|
---|
| 164 | _pppClient->putEphemeris(&eph);
|
---|
| 165 | }
|
---|
| 166 |
|
---|
| 167 | //
|
---|
| 168 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6433] | 169 | void t_pppRun::slotNewGlonassEph(t_ephGlo eph) {
|
---|
[5860] | 170 | QMutexLocker locker(&_mutex);
|
---|
| 171 | _pppClient->putEphemeris(&eph);
|
---|
| 172 | }
|
---|
| 173 |
|
---|
| 174 | //
|
---|
| 175 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6433] | 176 | void t_pppRun::slotNewGalileoEph(t_ephGal eph) {
|
---|
[5860] | 177 | QMutexLocker locker(&_mutex);
|
---|
| 178 | _pppClient->putEphemeris(&eph);
|
---|
| 179 | }
|
---|
| 180 |
|
---|
| 181 | //
|
---|
| 182 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6137] | 183 | void t_pppRun::slotNewObs(QByteArray staID, QList<t_satObs> obsList) {
|
---|
[5860] | 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 | // -----------------------------------------------------
|
---|
[6137] | 192 | QListIterator<t_satObs> it(obsList);
|
---|
[5860] | 193 | while (it.hasNext()) {
|
---|
[6137] | 194 | const t_satObs& oldObs = it.next();
|
---|
| 195 | t_satObs* newObs = new t_satObs(oldObs);
|
---|
[5860] | 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 |
|
---|
[6137] | 215 | // Put data into the epoch
|
---|
| 216 | // -----------------------
|
---|
[5860] | 217 | if (epoch != 0) {
|
---|
| 218 | epoch->_satObs.push_back(newObs);
|
---|
| 219 | }
|
---|
[6137] | 220 | else {
|
---|
| 221 | delete newObs;
|
---|
| 222 | }
|
---|
[5860] | 223 | }
|
---|
| 224 |
|
---|
| 225 | // Process the oldest epochs
|
---|
| 226 | // ------------------------
|
---|
[5999] | 227 | while (_epoData.size() && !waitForCorr(_epoData.front()->_time)) {
|
---|
[5860] | 228 |
|
---|
| 229 | const vector<t_satObs*>& satObs = _epoData.front()->_satObs;
|
---|
| 230 |
|
---|
| 231 | t_output output;
|
---|
| 232 | _pppClient->processEpoch(satObs, &output);
|
---|
| 233 |
|
---|
[5953] | 234 | if (!output._error) {
|
---|
[5879] | 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];
|
---|
[5954] | 242 | emit newPosition(staID, output._epoTime, xx);
|
---|
[5873] | 243 | }
|
---|
| 244 |
|
---|
[5860] | 245 | delete _epoData.front(); _epoData.pop_front();
|
---|
| 246 |
|
---|
[5980] | 247 | ostringstream log;
|
---|
| 248 | if (output._error) {
|
---|
| 249 | log << output._log;
|
---|
| 250 | }
|
---|
| 251 | else {
|
---|
| 252 | log.setf(ios::fixed);
|
---|
[5982] | 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];
|
---|
[5980] | 260 | }
|
---|
| 261 |
|
---|
[5988] | 262 | if (_logFile && output._epoTime.valid()) {
|
---|
[5986] | 263 | _logFile->write(output._epoTime.gpsw(), output._epoTime.gpssec(),
|
---|
| 264 | QString(output._log.c_str()));
|
---|
| 265 | }
|
---|
[5984] | 266 |
|
---|
[5989] | 267 | if (!output._error) {
|
---|
[5990] | 268 | QString rmcStr = nmeaString('R', output);
|
---|
| 269 | QString ggaStr = nmeaString('G', output);
|
---|
[5989] | 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 |
|
---|
[5980] | 278 | emit newMessage(QByteArray(log.str().c_str()), true);
|
---|
[5860] | 279 | }
|
---|
| 280 | }
|
---|
| 281 |
|
---|
| 282 | //
|
---|
| 283 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6141] | 284 | void t_pppRun::slotNewOrbCorrections(QList<t_orbCorr> orbCorr) {
|
---|
| 285 | if (orbCorr.size() == 0) {
|
---|
| 286 | return;
|
---|
| 287 | }
|
---|
[5860] | 288 |
|
---|
[5937] | 289 | if (_opt->_realTime) {
|
---|
[6141] | 290 | if (_opt->_corrMount.empty() || _opt->_corrMount != orbCorr[0]._staID) {
|
---|
[5937] | 291 | return;
|
---|
| 292 | }
|
---|
[5860] | 293 | }
|
---|
[6141] | 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 | }
|
---|
[5860] | 299 |
|
---|
[6141] | 300 | _pppClient->putOrbCorrections(corrections);
|
---|
| 301 | }
|
---|
| 302 |
|
---|
| 303 | //
|
---|
| 304 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 305 | void t_pppRun::slotNewClkCorrections(QList<t_clkCorr> clkCorr) {
|
---|
| 306 | if (clkCorr.size() == 0) {
|
---|
[5860] | 307 | return;
|
---|
| 308 | }
|
---|
| 309 |
|
---|
[6141] | 310 | if (_opt->_realTime) {
|
---|
| 311 | if (_opt->_corrMount.empty() || _opt->_corrMount != clkCorr[0]._staID) {
|
---|
| 312 | return;
|
---|
[5860] | 313 | }
|
---|
| 314 | }
|
---|
[6141] | 315 | vector<t_clkCorr*> corrections;
|
---|
| 316 | for (int ii = 0; ii < clkCorr.size(); ii++) {
|
---|
| 317 | corrections.push_back(new t_clkCorr(clkCorr[ii]));
|
---|
| 318 | }
|
---|
[5860] | 319 |
|
---|
[6141] | 320 | _pppClient->putClkCorrections(corrections);
|
---|
[5860] | 321 | }
|
---|
[5883] | 322 |
|
---|
| 323 | //
|
---|
| 324 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6478] | 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 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5883] | 345 | void t_pppRun::processFiles() {
|
---|
| 346 |
|
---|
| 347 | try {
|
---|
[5889] | 348 | _rnxObsFile = new t_rnxObsFile(QString(_opt->_rinexObs.c_str()), t_rnxObsFile::input);
|
---|
[5883] | 349 | }
|
---|
| 350 | catch (...) {
|
---|
| 351 | delete _rnxObsFile; _rnxObsFile = 0;
|
---|
[5940] | 352 | emit finishedRnxPPP();
|
---|
[5883] | 353 | return;
|
---|
| 354 | }
|
---|
| 355 |
|
---|
[5889] | 356 | _rnxNavFile = new t_rnxNavFile(QString(_opt->_rinexNav.c_str()), t_rnxNavFile::input);
|
---|
[5883] | 357 |
|
---|
[5889] | 358 | if (!_opt->_corrFile.empty()) {
|
---|
| 359 | _corrFile = new t_corrFile(QString(_opt->_corrFile.c_str()));
|
---|
[6145] | 360 | connect(_corrFile, SIGNAL(newOrbCorrections(QList<t_orbCorr>)),
|
---|
| 361 | this, SLOT(slotNewOrbCorrections(QList<t_orbCorr>)));
|
---|
[6185] | 362 | connect(_corrFile, SIGNAL(newClkCorrections(QList<t_clkCorr>)),
|
---|
| 363 | this, SLOT(slotNewClkCorrections(QList<t_clkCorr>)));
|
---|
[6478] | 364 | connect(_corrFile, SIGNAL(newCodeBiases(QList<t_satCodeBias>)),
|
---|
| 365 | this, SLOT(slotNewCodeBiases(QList<t_satCodeBias>)));
|
---|
[5883] | 366 | }
|
---|
| 367 |
|
---|
| 368 | // Read/Process Observations
|
---|
| 369 | // -------------------------
|
---|
| 370 | int nEpo = 0;
|
---|
| 371 | const t_rnxObsFile::t_rnxEpo* epo = 0;
|
---|
[5973] | 372 | while ( !_stopFlag && (epo = _rnxObsFile->nextEpoch()) != 0 ) {
|
---|
[5883] | 373 | ++nEpo;
|
---|
| 374 |
|
---|
[5951] | 375 | if (_speed < 100) {
|
---|
| 376 | double sleepTime = 2.0 / _speed;
|
---|
[6537] | 377 | t_pppThread::msleep(int(sleepTime*1.e3));
|
---|
[5883] | 378 | }
|
---|
| 379 |
|
---|
| 380 | // Get Corrections
|
---|
| 381 | // ---------------
|
---|
| 382 | if (_corrFile) {
|
---|
[6510] | 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 | }
|
---|
[5883] | 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 ) {
|
---|
[5889] | 405 | _pppClient->putEphemeris(eph);
|
---|
| 406 | delete eph; eph = 0;
|
---|
[5883] | 407 | }
|
---|
| 408 |
|
---|
[5890] | 409 | // Create list of observations and start epoch processing
|
---|
| 410 | // ------------------------------------------------------
|
---|
[6137] | 411 | QList<t_satObs> obsList;
|
---|
[5883] | 412 | for (unsigned iObs = 0; iObs < epo->rnxSat.size(); iObs++) {
|
---|
| 413 | const t_rnxObsFile::t_rnxSat& rnxSat = epo->rnxSat[iObs];
|
---|
| 414 |
|
---|
[6137] | 415 | t_satObs obs;
|
---|
[5883] | 416 | t_rnxObsFile::setObsFromRnx(_rnxObsFile, epo, rnxSat, obs);
|
---|
[5890] | 417 | obsList << obs;
|
---|
| 418 | }
|
---|
| 419 | slotNewObs(QByteArray(_opt->_roverName.c_str()), obsList);
|
---|
[5883] | 420 |
|
---|
[5890] | 421 |
|
---|
[5883] | 422 | if (nEpo % 10 == 0) {
|
---|
[5940] | 423 | emit progressRnxPPP(nEpo);
|
---|
[5883] | 424 | }
|
---|
[5950] | 425 |
|
---|
| 426 | QCoreApplication::processEvents();
|
---|
[5883] | 427 | }
|
---|
| 428 |
|
---|
[5940] | 429 | emit finishedRnxPPP();
|
---|
[5927] | 430 |
|
---|
[5883] | 431 | if (BNC_CORE->mode() != t_bncCore::interactive) {
|
---|
| 432 | qApp->exit(0);
|
---|
| 433 | }
|
---|
[5944] | 434 | else {
|
---|
| 435 | BNC_CORE->stopPPP();
|
---|
| 436 | }
|
---|
[5883] | 437 | }
|
---|
| 438 |
|
---|
| 439 | //
|
---|
| 440 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 441 | void t_pppRun::slotSetSpeed(int speed) {
|
---|
| 442 | QMutexLocker locker(&_mutex);
|
---|
| 443 | _speed = speed;
|
---|
| 444 | }
|
---|
[5973] | 445 |
|
---|
| 446 | //
|
---|
| 447 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 448 | void t_pppRun::slotSetStopFlag() {
|
---|
| 449 | QMutexLocker locker(&_mutex);
|
---|
| 450 | _stopFlag = true;
|
---|
| 451 | }
|
---|
[5989] | 452 |
|
---|
| 453 | //
|
---|
| 454 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5990] | 455 | QString t_pppRun::nmeaString(char strType, const t_output& output) {
|
---|
[5989] | 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 |
|
---|
[5990] | 473 | ostringstream out;
|
---|
| 474 | out.setf(ios::fixed);
|
---|
[5989] | 475 |
|
---|
[5990] | 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 | }
|
---|
[5989] | 505 |
|
---|
[5990] | 506 | QString nmStr(out.str().c_str());
|
---|
[5989] | 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 |
|
---|
[5999] | 515 | //
|
---|
| 516 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 517 | bool t_pppRun::waitForCorr(const bncTime& epoTime) const {
|
---|
| 518 |
|
---|
[6001] | 519 | if (!_opt->_realTime || _opt->_corrMount.empty()) {
|
---|
[5999] | 520 | return false;
|
---|
| 521 | }
|
---|
[6001] | 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 | }
|
---|
[5999] | 534 | return false;
|
---|
| 535 | }
|
---|