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