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