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