[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 | }
|
---|
[6608] | 151 |
|
---|
| 152 | QString snxtroFileSkl = settings.value("PPP/snxtroFile").toString();
|
---|
| 153 | if (snxtroFileSkl.isEmpty()) {
|
---|
| 154 | _snxtroFile = 0;
|
---|
| 155 | }
|
---|
| 156 | else {
|
---|
| 157 | if (snxtroFileSkl.indexOf("${STATION}") == -1) {
|
---|
| 158 | snxtroFileSkl = snxtroFileSkl + "_" + roverName;
|
---|
| 159 | }
|
---|
| 160 | else {
|
---|
| 161 | snxtroFileSkl.replace("${STATION}", roverName);
|
---|
| 162 | }
|
---|
| 163 | _snxtroFile = new bncoutf(snxtroFileSkl, "1 day", 0);
|
---|
| 164 | }
|
---|
[5860] | 165 | }
|
---|
| 166 |
|
---|
[6608] | 167 |
|
---|
| 168 |
|
---|
[5860] | 169 | // Destructor
|
---|
| 170 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5883] | 171 | t_pppRun::~t_pppRun() {
|
---|
[5984] | 172 | delete _logFile;
|
---|
[5988] | 173 | delete _nmeaFile;
|
---|
[6608] | 174 | delete _snxtroFile;
|
---|
[5860] | 175 | }
|
---|
| 176 |
|
---|
| 177 | //
|
---|
| 178 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6433] | 179 | void t_pppRun::slotNewGPSEph(t_ephGPS eph) {
|
---|
[5860] | 180 | QMutexLocker locker(&_mutex);
|
---|
| 181 | _pppClient->putEphemeris(&eph);
|
---|
| 182 | }
|
---|
| 183 |
|
---|
| 184 | //
|
---|
| 185 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6433] | 186 | void t_pppRun::slotNewGlonassEph(t_ephGlo eph) {
|
---|
[5860] | 187 | QMutexLocker locker(&_mutex);
|
---|
| 188 | _pppClient->putEphemeris(&eph);
|
---|
| 189 | }
|
---|
| 190 |
|
---|
| 191 | //
|
---|
| 192 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6433] | 193 | void t_pppRun::slotNewGalileoEph(t_ephGal eph) {
|
---|
[5860] | 194 | QMutexLocker locker(&_mutex);
|
---|
| 195 | _pppClient->putEphemeris(&eph);
|
---|
| 196 | }
|
---|
| 197 |
|
---|
| 198 | //
|
---|
| 199 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6137] | 200 | void t_pppRun::slotNewObs(QByteArray staID, QList<t_satObs> obsList) {
|
---|
[5860] | 201 | QMutexLocker locker(&_mutex);
|
---|
| 202 |
|
---|
| 203 | if (string(staID.data()) != _opt->_roverName) {
|
---|
| 204 | return;
|
---|
| 205 | }
|
---|
| 206 |
|
---|
| 207 | // Loop over all obsevations (possible different epochs)
|
---|
| 208 | // -----------------------------------------------------
|
---|
[6137] | 209 | QListIterator<t_satObs> it(obsList);
|
---|
[5860] | 210 | while (it.hasNext()) {
|
---|
[6137] | 211 | const t_satObs& oldObs = it.next();
|
---|
| 212 | t_satObs* newObs = new t_satObs(oldObs);
|
---|
[5860] | 213 |
|
---|
| 214 | // Find the corresponding data epoch or create a new one
|
---|
| 215 | // -----------------------------------------------------
|
---|
| 216 | t_epoData* epoch = 0;
|
---|
| 217 | deque<t_epoData*>::const_iterator it;
|
---|
| 218 | for (it = _epoData.begin(); it != _epoData.end(); it++) {
|
---|
| 219 | if (newObs->_time == (*it)->_time) {
|
---|
| 220 | epoch = *it;
|
---|
| 221 | break;
|
---|
| 222 | }
|
---|
| 223 | }
|
---|
| 224 | if (epoch == 0) {
|
---|
| 225 | if (_epoData.empty() || newObs->_time > _epoData.back()->_time) {
|
---|
| 226 | epoch = new t_epoData;
|
---|
| 227 | epoch->_time = newObs->_time;
|
---|
| 228 | _epoData.push_back(epoch);
|
---|
| 229 | }
|
---|
| 230 | }
|
---|
| 231 |
|
---|
[6137] | 232 | // Put data into the epoch
|
---|
| 233 | // -----------------------
|
---|
[5860] | 234 | if (epoch != 0) {
|
---|
| 235 | epoch->_satObs.push_back(newObs);
|
---|
| 236 | }
|
---|
[6137] | 237 | else {
|
---|
| 238 | delete newObs;
|
---|
| 239 | }
|
---|
[5860] | 240 | }
|
---|
| 241 |
|
---|
| 242 | // Process the oldest epochs
|
---|
| 243 | // ------------------------
|
---|
[5999] | 244 | while (_epoData.size() && !waitForCorr(_epoData.front()->_time)) {
|
---|
[5860] | 245 |
|
---|
| 246 | const vector<t_satObs*>& satObs = _epoData.front()->_satObs;
|
---|
| 247 |
|
---|
| 248 | t_output output;
|
---|
| 249 | _pppClient->processEpoch(satObs, &output);
|
---|
| 250 |
|
---|
[5953] | 251 | if (!output._error) {
|
---|
[5879] | 252 | QVector<double> xx(6);
|
---|
| 253 | xx.data()[0] = output._xyzRover[0];
|
---|
| 254 | xx.data()[1] = output._xyzRover[1];
|
---|
| 255 | xx.data()[2] = output._xyzRover[2];
|
---|
| 256 | xx.data()[3] = output._neu[0];
|
---|
| 257 | xx.data()[4] = output._neu[1];
|
---|
| 258 | xx.data()[5] = output._neu[2];
|
---|
[5954] | 259 | emit newPosition(staID, output._epoTime, xx);
|
---|
[5873] | 260 | }
|
---|
| 261 |
|
---|
[5860] | 262 | delete _epoData.front(); _epoData.pop_front();
|
---|
| 263 |
|
---|
[5980] | 264 | ostringstream log;
|
---|
| 265 | if (output._error) {
|
---|
| 266 | log << output._log;
|
---|
| 267 | }
|
---|
| 268 | else {
|
---|
| 269 | log.setf(ios::fixed);
|
---|
[5982] | 270 | log << string(output._epoTime) << ' ' << staID.data()
|
---|
| 271 | << " X = " << setprecision(4) << output._xyzRover[0]
|
---|
| 272 | << " Y = " << setprecision(4) << output._xyzRover[1]
|
---|
| 273 | << " Z = " << setprecision(4) << output._xyzRover[2]
|
---|
| 274 | << " NEU: " << setprecision(4) << output._neu[0]
|
---|
| 275 | << " " << setprecision(4) << output._neu[1]
|
---|
| 276 | << " " << setprecision(4) << output._neu[2];
|
---|
[5980] | 277 | }
|
---|
| 278 |
|
---|
[5988] | 279 | if (_logFile && output._epoTime.valid()) {
|
---|
[5986] | 280 | _logFile->write(output._epoTime.gpsw(), output._epoTime.gpssec(),
|
---|
| 281 | QString(output._log.c_str()));
|
---|
| 282 | }
|
---|
[5984] | 283 |
|
---|
[5989] | 284 | if (!output._error) {
|
---|
[5990] | 285 | QString rmcStr = nmeaString('R', output);
|
---|
| 286 | QString ggaStr = nmeaString('G', output);
|
---|
[5989] | 287 | if (_nmeaFile) {
|
---|
| 288 | _nmeaFile->write(output._epoTime.gpsw(), output._epoTime.gpssec(), rmcStr);
|
---|
| 289 | _nmeaFile->write(output._epoTime.gpsw(), output._epoTime.gpssec(), ggaStr);
|
---|
| 290 | }
|
---|
| 291 | emit newNMEAstr(staID, rmcStr.toAscii());
|
---|
| 292 | emit newNMEAstr(staID, ggaStr.toAscii());
|
---|
| 293 | }
|
---|
| 294 |
|
---|
[6608] | 295 | if (_snxtroFile && output._epoTime.valid()) {
|
---|
| 296 | // _snxtroFile->write(output._epoTime.gpsw(), output._epoTime.gpssec(),QString("TEST"));
|
---|
| 297 | }
|
---|
| 298 |
|
---|
[5980] | 299 | emit newMessage(QByteArray(log.str().c_str()), true);
|
---|
[5860] | 300 | }
|
---|
| 301 | }
|
---|
| 302 |
|
---|
| 303 | //
|
---|
| 304 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6141] | 305 | void t_pppRun::slotNewOrbCorrections(QList<t_orbCorr> orbCorr) {
|
---|
| 306 | if (orbCorr.size() == 0) {
|
---|
| 307 | return;
|
---|
| 308 | }
|
---|
[5860] | 309 |
|
---|
[5937] | 310 | if (_opt->_realTime) {
|
---|
[6141] | 311 | if (_opt->_corrMount.empty() || _opt->_corrMount != orbCorr[0]._staID) {
|
---|
[5937] | 312 | return;
|
---|
| 313 | }
|
---|
[5860] | 314 | }
|
---|
[6141] | 315 | vector<t_orbCorr*> corrections;
|
---|
| 316 | for (int ii = 0; ii < orbCorr.size(); ii++) {
|
---|
| 317 | corrections.push_back(new t_orbCorr(orbCorr[ii]));
|
---|
| 318 | _lastClkCorrTime = orbCorr[ii]._time;
|
---|
| 319 | }
|
---|
[5860] | 320 |
|
---|
[6141] | 321 | _pppClient->putOrbCorrections(corrections);
|
---|
| 322 | }
|
---|
| 323 |
|
---|
| 324 | //
|
---|
| 325 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 326 | void t_pppRun::slotNewClkCorrections(QList<t_clkCorr> clkCorr) {
|
---|
| 327 | if (clkCorr.size() == 0) {
|
---|
[5860] | 328 | return;
|
---|
| 329 | }
|
---|
| 330 |
|
---|
[6141] | 331 | if (_opt->_realTime) {
|
---|
| 332 | if (_opt->_corrMount.empty() || _opt->_corrMount != clkCorr[0]._staID) {
|
---|
| 333 | return;
|
---|
[5860] | 334 | }
|
---|
| 335 | }
|
---|
[6141] | 336 | vector<t_clkCorr*> corrections;
|
---|
| 337 | for (int ii = 0; ii < clkCorr.size(); ii++) {
|
---|
| 338 | corrections.push_back(new t_clkCorr(clkCorr[ii]));
|
---|
| 339 | }
|
---|
[5860] | 340 |
|
---|
[6141] | 341 | _pppClient->putClkCorrections(corrections);
|
---|
[5860] | 342 | }
|
---|
[5883] | 343 |
|
---|
| 344 | //
|
---|
| 345 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6478] | 346 | void t_pppRun::slotNewCodeBiases(QList<t_satCodeBias> codeBiases) {
|
---|
| 347 | if (codeBiases.size() == 0) {
|
---|
| 348 | return;
|
---|
| 349 | }
|
---|
| 350 |
|
---|
| 351 | if (_opt->_realTime) {
|
---|
| 352 | if (_opt->_corrMount.empty() || _opt->_corrMount != codeBiases[0]._staID) {
|
---|
| 353 | return;
|
---|
| 354 | }
|
---|
| 355 | }
|
---|
| 356 | vector<t_satCodeBias*> biases;
|
---|
| 357 | for (int ii = 0; ii < codeBiases.size(); ii++) {
|
---|
| 358 | biases.push_back(new t_satCodeBias(codeBiases[ii]));
|
---|
| 359 | }
|
---|
| 360 |
|
---|
| 361 | _pppClient->putCodeBiases(biases);
|
---|
| 362 | }
|
---|
| 363 |
|
---|
| 364 | //
|
---|
| 365 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5883] | 366 | void t_pppRun::processFiles() {
|
---|
| 367 |
|
---|
| 368 | try {
|
---|
[5889] | 369 | _rnxObsFile = new t_rnxObsFile(QString(_opt->_rinexObs.c_str()), t_rnxObsFile::input);
|
---|
[5883] | 370 | }
|
---|
| 371 | catch (...) {
|
---|
| 372 | delete _rnxObsFile; _rnxObsFile = 0;
|
---|
[5940] | 373 | emit finishedRnxPPP();
|
---|
[5883] | 374 | return;
|
---|
| 375 | }
|
---|
| 376 |
|
---|
[5889] | 377 | _rnxNavFile = new t_rnxNavFile(QString(_opt->_rinexNav.c_str()), t_rnxNavFile::input);
|
---|
[5883] | 378 |
|
---|
[5889] | 379 | if (!_opt->_corrFile.empty()) {
|
---|
| 380 | _corrFile = new t_corrFile(QString(_opt->_corrFile.c_str()));
|
---|
[6145] | 381 | connect(_corrFile, SIGNAL(newOrbCorrections(QList<t_orbCorr>)),
|
---|
| 382 | this, SLOT(slotNewOrbCorrections(QList<t_orbCorr>)));
|
---|
[6185] | 383 | connect(_corrFile, SIGNAL(newClkCorrections(QList<t_clkCorr>)),
|
---|
| 384 | this, SLOT(slotNewClkCorrections(QList<t_clkCorr>)));
|
---|
[6478] | 385 | connect(_corrFile, SIGNAL(newCodeBiases(QList<t_satCodeBias>)),
|
---|
| 386 | this, SLOT(slotNewCodeBiases(QList<t_satCodeBias>)));
|
---|
[5883] | 387 | }
|
---|
| 388 |
|
---|
| 389 | // Read/Process Observations
|
---|
| 390 | // -------------------------
|
---|
| 391 | int nEpo = 0;
|
---|
| 392 | const t_rnxObsFile::t_rnxEpo* epo = 0;
|
---|
[5973] | 393 | while ( !_stopFlag && (epo = _rnxObsFile->nextEpoch()) != 0 ) {
|
---|
[5883] | 394 | ++nEpo;
|
---|
| 395 |
|
---|
[5951] | 396 | if (_speed < 100) {
|
---|
| 397 | double sleepTime = 2.0 / _speed;
|
---|
[6537] | 398 | t_pppThread::msleep(int(sleepTime*1.e3));
|
---|
[5883] | 399 | }
|
---|
| 400 |
|
---|
| 401 | // Get Corrections
|
---|
| 402 | // ---------------
|
---|
| 403 | if (_corrFile) {
|
---|
[6510] | 404 | try {
|
---|
| 405 | _corrFile->syncRead(epo->tt);
|
---|
| 406 | }
|
---|
| 407 | catch (const char* msg) {
|
---|
| 408 | emit newMessage(QByteArray(msg), true);
|
---|
| 409 | break;
|
---|
| 410 | }
|
---|
| 411 | catch (const string& msg) {
|
---|
| 412 | emit newMessage(QByteArray(msg.c_str()), true);
|
---|
| 413 | break;
|
---|
| 414 | }
|
---|
| 415 | catch (...) {
|
---|
| 416 | emit newMessage("unknown exceptions in corrFile", true);
|
---|
| 417 | break;
|
---|
| 418 | }
|
---|
[5883] | 419 | }
|
---|
| 420 |
|
---|
| 421 | // Get Ephemerides
|
---|
| 422 | // ----------------
|
---|
| 423 | t_eph* eph = 0;
|
---|
| 424 | const QMap<QString, int>* corrIODs = _corrFile ? &_corrFile->corrIODs() : 0;
|
---|
| 425 | while ( (eph = _rnxNavFile->getNextEph(epo->tt, corrIODs)) != 0 ) {
|
---|
[5889] | 426 | _pppClient->putEphemeris(eph);
|
---|
| 427 | delete eph; eph = 0;
|
---|
[5883] | 428 | }
|
---|
| 429 |
|
---|
[5890] | 430 | // Create list of observations and start epoch processing
|
---|
| 431 | // ------------------------------------------------------
|
---|
[6137] | 432 | QList<t_satObs> obsList;
|
---|
[5883] | 433 | for (unsigned iObs = 0; iObs < epo->rnxSat.size(); iObs++) {
|
---|
| 434 | const t_rnxObsFile::t_rnxSat& rnxSat = epo->rnxSat[iObs];
|
---|
| 435 |
|
---|
[6137] | 436 | t_satObs obs;
|
---|
[5883] | 437 | t_rnxObsFile::setObsFromRnx(_rnxObsFile, epo, rnxSat, obs);
|
---|
[5890] | 438 | obsList << obs;
|
---|
| 439 | }
|
---|
| 440 | slotNewObs(QByteArray(_opt->_roverName.c_str()), obsList);
|
---|
[5883] | 441 |
|
---|
[5890] | 442 |
|
---|
[5883] | 443 | if (nEpo % 10 == 0) {
|
---|
[5940] | 444 | emit progressRnxPPP(nEpo);
|
---|
[5883] | 445 | }
|
---|
[5950] | 446 |
|
---|
| 447 | QCoreApplication::processEvents();
|
---|
[5883] | 448 | }
|
---|
| 449 |
|
---|
[5940] | 450 | emit finishedRnxPPP();
|
---|
[5927] | 451 |
|
---|
[5883] | 452 | if (BNC_CORE->mode() != t_bncCore::interactive) {
|
---|
| 453 | qApp->exit(0);
|
---|
| 454 | }
|
---|
[5944] | 455 | else {
|
---|
| 456 | BNC_CORE->stopPPP();
|
---|
| 457 | }
|
---|
[5883] | 458 | }
|
---|
| 459 |
|
---|
| 460 | //
|
---|
| 461 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 462 | void t_pppRun::slotSetSpeed(int speed) {
|
---|
| 463 | QMutexLocker locker(&_mutex);
|
---|
| 464 | _speed = speed;
|
---|
| 465 | }
|
---|
[5973] | 466 |
|
---|
| 467 | //
|
---|
| 468 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 469 | void t_pppRun::slotSetStopFlag() {
|
---|
| 470 | QMutexLocker locker(&_mutex);
|
---|
| 471 | _stopFlag = true;
|
---|
| 472 | }
|
---|
[5989] | 473 |
|
---|
| 474 | //
|
---|
| 475 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5990] | 476 | QString t_pppRun::nmeaString(char strType, const t_output& output) {
|
---|
[5989] | 477 |
|
---|
| 478 | double ell[3];
|
---|
| 479 | xyz2ell(output._xyzRover, ell);
|
---|
| 480 | double phiDeg = ell[0] * 180 / M_PI;
|
---|
| 481 | double lamDeg = ell[1] * 180 / M_PI;
|
---|
| 482 |
|
---|
| 483 | char phiCh = 'N';
|
---|
| 484 | if (phiDeg < 0) {
|
---|
| 485 | phiDeg = -phiDeg;
|
---|
| 486 | phiCh = 'S';
|
---|
| 487 | }
|
---|
| 488 | char lamCh = 'E';
|
---|
| 489 | if (lamDeg < 0) {
|
---|
| 490 | lamDeg = -lamDeg;
|
---|
| 491 | lamCh = 'W';
|
---|
| 492 | }
|
---|
| 493 |
|
---|
[5990] | 494 | ostringstream out;
|
---|
| 495 | out.setf(ios::fixed);
|
---|
[5989] | 496 |
|
---|
[5990] | 497 | if (strType == 'R') {
|
---|
| 498 | string datestr = output._epoTime.datestr(0); // yyyymmdd
|
---|
| 499 | out << "GPRMC,"
|
---|
| 500 | << output._epoTime.timestr(0,0) << ",A,"
|
---|
| 501 | << setw(2) << setfill('0') << int(phiDeg)
|
---|
| 502 | << setw(6) << setprecision(3) << setfill('0')
|
---|
| 503 | << fmod(60*phiDeg,60) << ',' << phiCh << ','
|
---|
| 504 | << setw(3) << setfill('0') << int(lamDeg)
|
---|
| 505 | << setw(6) << setprecision(3) << setfill('0')
|
---|
| 506 | << fmod(60*lamDeg,60) << ',' << lamCh << ",,,"
|
---|
| 507 | << datestr[6] << datestr[7] << datestr[4] << datestr[5]
|
---|
| 508 | << datestr[2] << datestr[3] << ",,";
|
---|
| 509 | }
|
---|
| 510 | else if (strType == 'G') {
|
---|
| 511 | out << "GPGGA,"
|
---|
| 512 | << output._epoTime.timestr(0,0) << ','
|
---|
| 513 | << setw(2) << setfill('0') << int(phiDeg)
|
---|
| 514 | << setw(10) << setprecision(7) << setfill('0')
|
---|
| 515 | << fmod(60*phiDeg,60) << ',' << phiCh << ','
|
---|
| 516 | << setw(3) << setfill('0') << int(lamDeg)
|
---|
| 517 | << setw(10) << setprecision(7) << setfill('0')
|
---|
| 518 | << fmod(60*lamDeg,60) << ',' << lamCh
|
---|
| 519 | << ",1," << setw(2) << setfill('0') << output._numSat << ','
|
---|
| 520 | << setw(3) << setprecision(1) << output._pDop << ','
|
---|
| 521 | << setprecision(3) << ell[2] << ",M,0.0,M,,";
|
---|
| 522 | }
|
---|
| 523 | else {
|
---|
| 524 | return "";
|
---|
| 525 | }
|
---|
[5989] | 526 |
|
---|
[5990] | 527 | QString nmStr(out.str().c_str());
|
---|
[5989] | 528 | unsigned char XOR = 0;
|
---|
| 529 | for (int ii = 0; ii < nmStr.length(); ii++) {
|
---|
| 530 | XOR ^= (unsigned char) nmStr[ii].toAscii();
|
---|
| 531 | }
|
---|
| 532 |
|
---|
| 533 | return '$' + nmStr + QString("*%1\n").arg(int(XOR), 0, 16).toUpper();
|
---|
| 534 | }
|
---|
| 535 |
|
---|
[5999] | 536 | //
|
---|
| 537 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 538 | bool t_pppRun::waitForCorr(const bncTime& epoTime) const {
|
---|
| 539 |
|
---|
[6001] | 540 | if (!_opt->_realTime || _opt->_corrMount.empty()) {
|
---|
[5999] | 541 | return false;
|
---|
| 542 | }
|
---|
[6001] | 543 | else if (!_lastClkCorrTime.valid()) {
|
---|
| 544 | return true;
|
---|
| 545 | }
|
---|
| 546 | else {
|
---|
| 547 | double dt = epoTime - _lastClkCorrTime;
|
---|
| 548 | if (dt > 1.0 && dt < _opt->_corrWaitTime) {
|
---|
| 549 | return true;
|
---|
| 550 | }
|
---|
| 551 | else {
|
---|
| 552 | return false;
|
---|
| 553 | }
|
---|
| 554 | }
|
---|
[5999] | 555 | return false;
|
---|
| 556 | }
|
---|