[5860] | 1 |
|
---|
| 2 | // Part of BNC, a utility for retrieving decoding and
|
---|
| 3 | // converting GNSS data streams from NTRIP broadcasters.
|
---|
| 4 | //
|
---|
| 5 | // Copyright (C) 2007
|
---|
| 6 | // German Federal Agency for Cartography and Geodesy (BKG)
|
---|
| 7 | // http://www.bkg.bund.de
|
---|
| 8 | // Czech Technical University Prague, Department of Geodesy
|
---|
| 9 | // http://www.fsv.cvut.cz
|
---|
| 10 | //
|
---|
| 11 | // Email: euref-ip@bkg.bund.de
|
---|
| 12 | //
|
---|
| 13 | // This program is free software; you can redistribute it and/or
|
---|
| 14 | // modify it under the terms of the GNU General Public License
|
---|
| 15 | // as published by the Free Software Foundation, version 2.
|
---|
| 16 | //
|
---|
| 17 | // This program is distributed in the hope that it will be useful,
|
---|
| 18 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 20 | // GNU General Public License for more details.
|
---|
| 21 | //
|
---|
| 22 | // You should have received a copy of the GNU General Public License
|
---|
| 23 | // along with this program; if not, write to the Free Software
|
---|
| 24 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
---|
| 25 |
|
---|
| 26 | /* -------------------------------------------------------------------------
|
---|
| 27 | * BKG NTRIP Client
|
---|
| 28 | * -------------------------------------------------------------------------
|
---|
| 29 | *
|
---|
[5883] | 30 | * Class: t_pppRun
|
---|
[5860] | 31 | *
|
---|
| 32 | * Purpose: Single Real-Time PPP Client
|
---|
| 33 | *
|
---|
| 34 | * Author: L. Mervart
|
---|
| 35 | *
|
---|
| 36 | * Created: 29-Jul-2014
|
---|
| 37 | *
|
---|
| 38 | * Changes:
|
---|
| 39 | *
|
---|
| 40 | * -----------------------------------------------------------------------*/
|
---|
| 41 |
|
---|
| 42 |
|
---|
| 43 | #include <iostream>
|
---|
| 44 | #include <iomanip>
|
---|
[5980] | 45 | #include <sstream>
|
---|
[5860] | 46 | #include <string.h>
|
---|
| 47 | #include <map>
|
---|
| 48 |
|
---|
[5883] | 49 | #include "pppRun.h"
|
---|
[5891] | 50 | #include "pppThread.h"
|
---|
[5860] | 51 | #include "bnccore.h"
|
---|
| 52 | #include "bncephuser.h"
|
---|
[5953] | 53 | #include "bncsettings.h"
|
---|
[5984] | 54 | #include "bncoutf.h"
|
---|
[5883] | 55 | #include "rinex/rnxobsfile.h"
|
---|
| 56 | #include "rinex/rnxnavfile.h"
|
---|
| 57 | #include "rinex/corrfile.h"
|
---|
[5860] | 58 |
|
---|
| 59 | using namespace BNC_PPP;
|
---|
| 60 | using namespace std;
|
---|
| 61 |
|
---|
| 62 | // Constructor
|
---|
| 63 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5883] | 64 | t_pppRun::t_pppRun(const t_pppOptions* opt) {
|
---|
| 65 |
|
---|
[5860] | 66 | _opt = opt;
|
---|
[5883] | 67 |
|
---|
[5860] | 68 | connect(this, SIGNAL(newMessage(QByteArray,bool)),
|
---|
| 69 | BNC_CORE, SLOT(slotMessage(const QByteArray,bool)));
|
---|
[5883] | 70 |
|
---|
[5991] | 71 | connect(this, SIGNAL(newPosition(QByteArray, bncTime, QVector<double>)),
|
---|
[5954] | 72 | BNC_CORE, SIGNAL(newPosition(QByteArray, bncTime, QVector<double>)));
|
---|
[5949] | 73 |
|
---|
[5991] | 74 | connect(this, SIGNAL(newNMEAstr(QByteArray, QByteArray)),
|
---|
| 75 | BNC_CORE, SIGNAL(newNMEAstr(QByteArray, QByteArray)));
|
---|
| 76 |
|
---|
[5883] | 77 | for (unsigned iPrn = 0; iPrn <= t_prn::MAXPRN; iPrn++) {
|
---|
| 78 | _lastOrbCorrIOD[iPrn] = -1;
|
---|
| 79 | _lastClkCorrValue[iPrn] = 0.0;
|
---|
| 80 | }
|
---|
| 81 |
|
---|
| 82 | _pppClient = new t_pppClient(_opt);
|
---|
| 83 |
|
---|
[5984] | 84 | bncSettings settings;
|
---|
| 85 |
|
---|
[5860] | 86 | if (_opt->_realTime) {
|
---|
[5945] | 87 | Qt::ConnectionType conType = Qt::AutoConnection;
|
---|
| 88 | if (BNC_CORE->mode() == t_bncCore::batchPostProcessing) {
|
---|
| 89 | conType = Qt::BlockingQueuedConnection;
|
---|
| 90 | }
|
---|
| 91 |
|
---|
[6137] | 92 | connect(BNC_CORE->caster(), SIGNAL(newObs(QByteArray, QList<t_satObs>)),
|
---|
| 93 | this, SLOT(slotNewObs(QByteArray, QList<t_satObs>)),conType);
|
---|
[5860] | 94 |
|
---|
| 95 | connect(BNC_CORE, SIGNAL(newEphGPS(gpsephemeris)),
|
---|
[5945] | 96 | this, SLOT(slotNewEphGPS(gpsephemeris)),conType);
|
---|
[5860] | 97 |
|
---|
| 98 | connect(BNC_CORE, SIGNAL(newEphGlonass(glonassephemeris)),
|
---|
[5945] | 99 | this, SLOT(slotNewEphGlonass(glonassephemeris)),conType);
|
---|
[5860] | 100 |
|
---|
| 101 | connect(BNC_CORE, SIGNAL(newEphGalileo(galileoephemeris)),
|
---|
[5945] | 102 | this, SLOT(slotNewEphGalileo(galileoephemeris)),conType);
|
---|
[5860] | 103 |
|
---|
| 104 | connect(BNC_CORE, SIGNAL(newCorrections(QStringList)),
|
---|
[5945] | 105 | this, SLOT(slotNewCorrections(QStringList)),conType);
|
---|
[5860] | 106 | }
|
---|
| 107 | else {
|
---|
[5889] | 108 | _rnxObsFile = 0;
|
---|
| 109 | _rnxNavFile = 0;
|
---|
| 110 | _corrFile = 0;
|
---|
[5953] | 111 | _speed = settings.value("PPP/mapSpeedSlider").toInt();
|
---|
[5941] | 112 | connect(this, SIGNAL(progressRnxPPP(int)), BNC_CORE, SIGNAL(progressRnxPPP(int)));
|
---|
| 113 | connect(this, SIGNAL(finishedRnxPPP()), BNC_CORE, SIGNAL(finishedRnxPPP()));
|
---|
[5950] | 114 | connect(BNC_CORE, SIGNAL(mapSpeedSliderChanged(int)),
|
---|
| 115 | this, SLOT(slotSetSpeed(int)));
|
---|
[5973] | 116 | connect(BNC_CORE, SIGNAL(stopRinexPPP()), this, SLOT(slotSetStopFlag()));
|
---|
[5860] | 117 | }
|
---|
[5973] | 118 |
|
---|
| 119 | _stopFlag = false;
|
---|
[5984] | 120 |
|
---|
[5988] | 121 | QString roverName(_opt->_roverName.c_str());
|
---|
| 122 |
|
---|
[5984] | 123 | QString logFileSkl = settings.value("PPP/logFile").toString();
|
---|
[5988] | 124 | if (logFileSkl.isEmpty()) {
|
---|
| 125 | _logFile = 0;
|
---|
[5987] | 126 | }
|
---|
| 127 | else {
|
---|
[5988] | 128 | if (logFileSkl.indexOf("${STATION}") == -1) {
|
---|
| 129 | logFileSkl = roverName + "_" + logFileSkl;
|
---|
| 130 | }
|
---|
| 131 | else {
|
---|
| 132 | logFileSkl.replace("${STATION}", roverName);
|
---|
| 133 | }
|
---|
| 134 | _logFile = new bncoutf(logFileSkl, "1 day", 0);
|
---|
[5987] | 135 | }
|
---|
[5988] | 136 |
|
---|
| 137 | QString nmeaFileSkl = settings.value("PPP/nmeaFile").toString();
|
---|
| 138 | if (nmeaFileSkl.isEmpty()) {
|
---|
| 139 | _nmeaFile = 0;
|
---|
| 140 | }
|
---|
| 141 | else {
|
---|
| 142 | if (nmeaFileSkl.indexOf("${STATION}") == -1) {
|
---|
| 143 | nmeaFileSkl = roverName + "_" + nmeaFileSkl;
|
---|
| 144 | }
|
---|
| 145 | else {
|
---|
| 146 | nmeaFileSkl.replace("${STATION}", roverName);
|
---|
| 147 | }
|
---|
| 148 | _nmeaFile = new bncoutf(nmeaFileSkl, "1 day", 0);
|
---|
| 149 | }
|
---|
[5860] | 150 | }
|
---|
| 151 |
|
---|
| 152 | // Destructor
|
---|
| 153 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5883] | 154 | t_pppRun::~t_pppRun() {
|
---|
[5984] | 155 | delete _logFile;
|
---|
[5988] | 156 | delete _nmeaFile;
|
---|
[5860] | 157 | }
|
---|
| 158 |
|
---|
| 159 | //
|
---|
| 160 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5883] | 161 | void t_pppRun::slotNewEphGPS(gpsephemeris gpseph) {
|
---|
[5860] | 162 | QMutexLocker locker(&_mutex);
|
---|
| 163 | t_ephGPS eph;
|
---|
| 164 | eph.set(&gpseph);
|
---|
| 165 | _pppClient->putEphemeris(&eph);
|
---|
| 166 | }
|
---|
| 167 |
|
---|
| 168 | //
|
---|
| 169 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5883] | 170 | void t_pppRun::slotNewEphGlonass(glonassephemeris gloeph) {
|
---|
[5860] | 171 | QMutexLocker locker(&_mutex);
|
---|
| 172 | t_ephGlo eph;
|
---|
| 173 | eph.set(&gloeph);
|
---|
| 174 | _pppClient->putEphemeris(&eph);
|
---|
| 175 | }
|
---|
| 176 |
|
---|
| 177 | //
|
---|
| 178 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5883] | 179 | void t_pppRun::slotNewEphGalileo(galileoephemeris galeph) {
|
---|
[5860] | 180 | QMutexLocker locker(&_mutex);
|
---|
| 181 | t_ephGal eph;
|
---|
| 182 | eph.set(&galeph);
|
---|
| 183 | _pppClient->putEphemeris(&eph);
|
---|
| 184 | }
|
---|
| 185 |
|
---|
| 186 | //
|
---|
| 187 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6137] | 188 | void t_pppRun::slotNewObs(QByteArray staID, QList<t_satObs> obsList) {
|
---|
[5860] | 189 | QMutexLocker locker(&_mutex);
|
---|
| 190 |
|
---|
| 191 | if (string(staID.data()) != _opt->_roverName) {
|
---|
| 192 | return;
|
---|
| 193 | }
|
---|
| 194 |
|
---|
| 195 | // Loop over all obsevations (possible different epochs)
|
---|
| 196 | // -----------------------------------------------------
|
---|
[6137] | 197 | QListIterator<t_satObs> it(obsList);
|
---|
[5860] | 198 | while (it.hasNext()) {
|
---|
[6137] | 199 | const t_satObs& oldObs = it.next();
|
---|
| 200 | t_satObs* newObs = new t_satObs(oldObs);
|
---|
[5860] | 201 |
|
---|
| 202 | // Find the corresponding data epoch or create a new one
|
---|
| 203 | // -----------------------------------------------------
|
---|
| 204 | t_epoData* epoch = 0;
|
---|
| 205 | deque<t_epoData*>::const_iterator it;
|
---|
| 206 | for (it = _epoData.begin(); it != _epoData.end(); it++) {
|
---|
| 207 | if (newObs->_time == (*it)->_time) {
|
---|
| 208 | epoch = *it;
|
---|
| 209 | break;
|
---|
| 210 | }
|
---|
| 211 | }
|
---|
| 212 | if (epoch == 0) {
|
---|
| 213 | if (_epoData.empty() || newObs->_time > _epoData.back()->_time) {
|
---|
| 214 | epoch = new t_epoData;
|
---|
| 215 | epoch->_time = newObs->_time;
|
---|
| 216 | _epoData.push_back(epoch);
|
---|
| 217 | }
|
---|
| 218 | }
|
---|
| 219 |
|
---|
[6137] | 220 | // Put data into the epoch
|
---|
| 221 | // -----------------------
|
---|
[5860] | 222 | if (epoch != 0) {
|
---|
| 223 | epoch->_satObs.push_back(newObs);
|
---|
| 224 | }
|
---|
[6137] | 225 | else {
|
---|
| 226 | delete newObs;
|
---|
| 227 | }
|
---|
[5860] | 228 | }
|
---|
| 229 |
|
---|
| 230 | // Process the oldest epochs
|
---|
| 231 | // ------------------------
|
---|
[5999] | 232 | while (_epoData.size() && !waitForCorr(_epoData.front()->_time)) {
|
---|
[5860] | 233 |
|
---|
| 234 | const vector<t_satObs*>& satObs = _epoData.front()->_satObs;
|
---|
| 235 |
|
---|
| 236 | t_output output;
|
---|
| 237 | _pppClient->processEpoch(satObs, &output);
|
---|
| 238 |
|
---|
[5953] | 239 | if (!output._error) {
|
---|
[5879] | 240 | QVector<double> xx(6);
|
---|
| 241 | xx.data()[0] = output._xyzRover[0];
|
---|
| 242 | xx.data()[1] = output._xyzRover[1];
|
---|
| 243 | xx.data()[2] = output._xyzRover[2];
|
---|
| 244 | xx.data()[3] = output._neu[0];
|
---|
| 245 | xx.data()[4] = output._neu[1];
|
---|
| 246 | xx.data()[5] = output._neu[2];
|
---|
[5954] | 247 | emit newPosition(staID, output._epoTime, xx);
|
---|
[5873] | 248 | }
|
---|
| 249 |
|
---|
[5860] | 250 | delete _epoData.front(); _epoData.pop_front();
|
---|
| 251 |
|
---|
[5980] | 252 | ostringstream log;
|
---|
| 253 | if (output._error) {
|
---|
| 254 | log << output._log;
|
---|
| 255 | }
|
---|
| 256 | else {
|
---|
| 257 | log.setf(ios::fixed);
|
---|
[5982] | 258 | log << string(output._epoTime) << ' ' << staID.data()
|
---|
| 259 | << " X = " << setprecision(4) << output._xyzRover[0]
|
---|
| 260 | << " Y = " << setprecision(4) << output._xyzRover[1]
|
---|
| 261 | << " Z = " << setprecision(4) << output._xyzRover[2]
|
---|
| 262 | << " NEU: " << setprecision(4) << output._neu[0]
|
---|
| 263 | << " " << setprecision(4) << output._neu[1]
|
---|
| 264 | << " " << setprecision(4) << output._neu[2];
|
---|
[5980] | 265 | }
|
---|
| 266 |
|
---|
[5988] | 267 | if (_logFile && output._epoTime.valid()) {
|
---|
[5986] | 268 | _logFile->write(output._epoTime.gpsw(), output._epoTime.gpssec(),
|
---|
| 269 | QString(output._log.c_str()));
|
---|
| 270 | }
|
---|
[5984] | 271 |
|
---|
[5989] | 272 | if (!output._error) {
|
---|
[5990] | 273 | QString rmcStr = nmeaString('R', output);
|
---|
| 274 | QString ggaStr = nmeaString('G', output);
|
---|
[5989] | 275 | if (_nmeaFile) {
|
---|
| 276 | _nmeaFile->write(output._epoTime.gpsw(), output._epoTime.gpssec(), rmcStr);
|
---|
| 277 | _nmeaFile->write(output._epoTime.gpsw(), output._epoTime.gpssec(), ggaStr);
|
---|
| 278 | }
|
---|
| 279 | emit newNMEAstr(staID, rmcStr.toAscii());
|
---|
| 280 | emit newNMEAstr(staID, ggaStr.toAscii());
|
---|
| 281 | }
|
---|
| 282 |
|
---|
[5980] | 283 | emit newMessage(QByteArray(log.str().c_str()), true);
|
---|
[5860] | 284 | }
|
---|
| 285 | }
|
---|
| 286 |
|
---|
| 287 | //
|
---|
| 288 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5883] | 289 | void t_pppRun::slotNewCorrections(QStringList corrList) {
|
---|
[5860] | 290 | QMutexLocker locker(&_mutex);
|
---|
| 291 |
|
---|
| 292 | // Check the Mountpoint (source of corrections)
|
---|
| 293 | // --------------------------------------------
|
---|
[5937] | 294 | if (_opt->_realTime) {
|
---|
| 295 | if (_opt->_corrMount.empty()) {
|
---|
| 296 | return;
|
---|
| 297 | }
|
---|
| 298 | QMutableListIterator<QString> itm(corrList);
|
---|
| 299 | while (itm.hasNext()) {
|
---|
| 300 | QStringList hlp = itm.next().split(" ");
|
---|
| 301 | if (hlp.size() > 0) {
|
---|
| 302 | QString mountpoint = hlp[hlp.size()-1];
|
---|
| 303 | if (mountpoint != QString(_opt->_corrMount.c_str())) {
|
---|
| 304 | itm.remove();
|
---|
| 305 | }
|
---|
[5860] | 306 | }
|
---|
| 307 | }
|
---|
| 308 | }
|
---|
| 309 |
|
---|
| 310 | if (corrList.size() == 0) {
|
---|
| 311 | return;
|
---|
| 312 | }
|
---|
| 313 |
|
---|
| 314 | vector<t_orbCorr*> orbCorr;
|
---|
| 315 | vector<t_clkCorr*> clkCorr;
|
---|
| 316 | vector<t_satBias*> satBias;
|
---|
| 317 |
|
---|
| 318 | QListIterator<QString> it(corrList);
|
---|
| 319 | while (it.hasNext()) {
|
---|
| 320 | QString line = it.next();
|
---|
| 321 |
|
---|
| 322 | QTextStream in(&line);
|
---|
| 323 | int messageType;
|
---|
| 324 | int updateInterval;
|
---|
| 325 | int GPSweek;
|
---|
| 326 | double GPSweeks;
|
---|
| 327 | QString prn;
|
---|
| 328 | in >> messageType >> updateInterval >> GPSweek >> GPSweeks >> prn;
|
---|
| 329 |
|
---|
| 330 | if ( t_corr::relevantMessageType(messageType) ) {
|
---|
| 331 | t_corr corr;
|
---|
| 332 | corr.readLine(line);
|
---|
| 333 | if (messageType == COTYPE_GPSCOMBINED || messageType == COTYPE_GLONASSCOMBINED ||
|
---|
| 334 | messageType == COTYPE_GPSORBIT || messageType == COTYPE_GLONASSORBIT ) {
|
---|
| 335 | t_orbCorr* cc = new t_orbCorr();
|
---|
| 336 | cc->_prn.set(corr.prn.toAscii().data());
|
---|
| 337 | cc->_iod = corr.iod;
|
---|
| 338 | cc->_time = corr.tRao;
|
---|
| 339 | cc->_system = 'R';
|
---|
| 340 | cc->_xr[0] = corr.rao[0];
|
---|
| 341 | cc->_xr[1] = corr.rao[1];
|
---|
| 342 | cc->_xr[2] = corr.rao[2];
|
---|
| 343 | cc->_dotXr[0] = corr.dotRao[0];
|
---|
| 344 | cc->_dotXr[0] = corr.dotRao[1];
|
---|
| 345 | cc->_dotXr[0] = corr.dotRao[2];
|
---|
| 346 | orbCorr.push_back(cc);
|
---|
| 347 |
|
---|
| 348 | _lastOrbCorrIOD[cc->_prn.toInt()] = cc->_iod;
|
---|
| 349 | }
|
---|
| 350 | else if (messageType == COTYPE_GPSCOMBINED || messageType == COTYPE_GLONASSCOMBINED ||
|
---|
| 351 | messageType == COTYPE_GPSCLOCK || messageType == COTYPE_GLONASSCLOCK ) {
|
---|
| 352 | t_clkCorr* cc = new t_clkCorr();
|
---|
| 353 | cc->_prn.set(corr.prn.toAscii().data());
|
---|
| 354 | cc->_iod = corr.iod;
|
---|
| 355 | cc->_time = corr.tClk;
|
---|
| 356 | cc->_dClk = corr.dClk;
|
---|
| 357 | cc->_dotDClk = corr.dotDClk;
|
---|
| 358 | cc->_dotDotDClk = corr.dotDotDClk;
|
---|
| 359 | cc->_clkPartial = 0.0;
|
---|
| 360 | if (messageType == COTYPE_GPSCLOCK || messageType == COTYPE_GLONASSCLOCK) {
|
---|
| 361 | int lastIOD = _lastOrbCorrIOD[cc->_prn.toInt()];
|
---|
| 362 | if (lastIOD != -1) {
|
---|
| 363 | cc->_iod = lastIOD;
|
---|
| 364 | }
|
---|
| 365 | else {
|
---|
| 366 | delete cc;
|
---|
| 367 | cc = 0;
|
---|
| 368 | }
|
---|
| 369 | }
|
---|
| 370 | if (cc) {
|
---|
[5998] | 371 | clkCorr.push_back(cc);
|
---|
| 372 | _lastClkCorrValue[cc->_prn.toInt()] = cc->_dClk;
|
---|
[5860] | 373 | if (_lastClkCorrTime.undef() || cc->_time > _lastClkCorrTime) {
|
---|
| 374 | _lastClkCorrTime = cc->_time;
|
---|
| 375 | }
|
---|
| 376 | }
|
---|
| 377 | }
|
---|
| 378 | }
|
---|
| 379 | else if ( messageType == BTYPE_GPS || messageType == BTYPE_GLONASS ) {
|
---|
| 380 | t_bias bias;
|
---|
| 381 | bias.readLine(line);
|
---|
| 382 | }
|
---|
| 383 | }
|
---|
| 384 |
|
---|
| 385 | _pppClient->putOrbCorrections(orbCorr);
|
---|
| 386 | _pppClient->putClkCorrections(clkCorr);
|
---|
| 387 | _pppClient->putBiases(satBias);
|
---|
| 388 |
|
---|
| 389 | for (unsigned ii = 0; ii < orbCorr.size(); ii++) {
|
---|
| 390 | delete orbCorr[ii];
|
---|
| 391 | }
|
---|
| 392 | for (unsigned ii = 0; ii < clkCorr.size(); ii++) {
|
---|
| 393 | delete clkCorr[ii];
|
---|
| 394 | }
|
---|
| 395 | for (unsigned ii = 0; ii < satBias.size(); ii++) {
|
---|
| 396 | delete satBias[ii];
|
---|
| 397 | }
|
---|
| 398 | }
|
---|
[5883] | 399 |
|
---|
| 400 |
|
---|
| 401 | //
|
---|
| 402 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 403 | void t_pppRun::processFiles() {
|
---|
| 404 |
|
---|
| 405 | try {
|
---|
[5889] | 406 | _rnxObsFile = new t_rnxObsFile(QString(_opt->_rinexObs.c_str()), t_rnxObsFile::input);
|
---|
[5883] | 407 | }
|
---|
| 408 | catch (...) {
|
---|
| 409 | delete _rnxObsFile; _rnxObsFile = 0;
|
---|
[5940] | 410 | emit finishedRnxPPP();
|
---|
[5883] | 411 | return;
|
---|
| 412 | }
|
---|
| 413 |
|
---|
[5889] | 414 | _rnxNavFile = new t_rnxNavFile(QString(_opt->_rinexNav.c_str()), t_rnxNavFile::input);
|
---|
[5883] | 415 |
|
---|
[5889] | 416 | if (!_opt->_corrFile.empty()) {
|
---|
| 417 | _corrFile = new t_corrFile(QString(_opt->_corrFile.c_str()));
|
---|
[5883] | 418 | connect(_corrFile, SIGNAL(newCorrections(QStringList)),
|
---|
[5889] | 419 | this, SLOT(slotNewCorrections(QStringList)));
|
---|
[5883] | 420 | }
|
---|
| 421 |
|
---|
| 422 | // Read/Process Observations
|
---|
| 423 | // -------------------------
|
---|
| 424 | int nEpo = 0;
|
---|
| 425 | const t_rnxObsFile::t_rnxEpo* epo = 0;
|
---|
[5973] | 426 | while ( !_stopFlag && (epo = _rnxObsFile->nextEpoch()) != 0 ) {
|
---|
[5883] | 427 | ++nEpo;
|
---|
| 428 |
|
---|
[5951] | 429 | if (_speed < 100) {
|
---|
| 430 | double sleepTime = 2.0 / _speed;
|
---|
| 431 | t_pppThread::msleep(sleepTime*1.e3);
|
---|
[5883] | 432 | }
|
---|
| 433 |
|
---|
| 434 | // Get Corrections
|
---|
| 435 | // ---------------
|
---|
| 436 | if (_corrFile) {
|
---|
| 437 | _corrFile->syncRead(epo->tt);
|
---|
| 438 | }
|
---|
| 439 |
|
---|
| 440 | // Get Ephemerides
|
---|
| 441 | // ----------------
|
---|
| 442 | t_eph* eph = 0;
|
---|
| 443 | const QMap<QString, int>* corrIODs = _corrFile ? &_corrFile->corrIODs() : 0;
|
---|
| 444 | while ( (eph = _rnxNavFile->getNextEph(epo->tt, corrIODs)) != 0 ) {
|
---|
[5889] | 445 | _pppClient->putEphemeris(eph);
|
---|
| 446 | delete eph; eph = 0;
|
---|
[5883] | 447 | }
|
---|
| 448 |
|
---|
[5890] | 449 | // Create list of observations and start epoch processing
|
---|
| 450 | // ------------------------------------------------------
|
---|
[6137] | 451 | QList<t_satObs> obsList;
|
---|
[5883] | 452 | for (unsigned iObs = 0; iObs < epo->rnxSat.size(); iObs++) {
|
---|
| 453 | const t_rnxObsFile::t_rnxSat& rnxSat = epo->rnxSat[iObs];
|
---|
| 454 |
|
---|
[6137] | 455 | t_satObs obs;
|
---|
[5883] | 456 | t_rnxObsFile::setObsFromRnx(_rnxObsFile, epo, rnxSat, obs);
|
---|
[5890] | 457 | obsList << obs;
|
---|
| 458 | }
|
---|
| 459 | slotNewObs(QByteArray(_opt->_roverName.c_str()), obsList);
|
---|
[5883] | 460 |
|
---|
[5890] | 461 |
|
---|
[5883] | 462 | if (nEpo % 10 == 0) {
|
---|
[5940] | 463 | emit progressRnxPPP(nEpo);
|
---|
[5883] | 464 | }
|
---|
[5950] | 465 |
|
---|
| 466 | QCoreApplication::processEvents();
|
---|
[5883] | 467 | }
|
---|
| 468 |
|
---|
[5940] | 469 | emit finishedRnxPPP();
|
---|
[5927] | 470 |
|
---|
[5883] | 471 | if (BNC_CORE->mode() != t_bncCore::interactive) {
|
---|
| 472 | qApp->exit(0);
|
---|
| 473 | }
|
---|
[5944] | 474 | else {
|
---|
| 475 | BNC_CORE->stopPPP();
|
---|
| 476 | }
|
---|
[5883] | 477 | }
|
---|
| 478 |
|
---|
| 479 | //
|
---|
| 480 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 481 | void t_pppRun::slotSetSpeed(int speed) {
|
---|
| 482 | QMutexLocker locker(&_mutex);
|
---|
| 483 | _speed = speed;
|
---|
| 484 | }
|
---|
[5973] | 485 |
|
---|
| 486 | //
|
---|
| 487 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 488 | void t_pppRun::slotSetStopFlag() {
|
---|
| 489 | QMutexLocker locker(&_mutex);
|
---|
| 490 | _stopFlag = true;
|
---|
| 491 | }
|
---|
[5989] | 492 |
|
---|
| 493 | //
|
---|
| 494 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5990] | 495 | QString t_pppRun::nmeaString(char strType, const t_output& output) {
|
---|
[5989] | 496 |
|
---|
| 497 | double ell[3];
|
---|
| 498 | xyz2ell(output._xyzRover, ell);
|
---|
| 499 | double phiDeg = ell[0] * 180 / M_PI;
|
---|
| 500 | double lamDeg = ell[1] * 180 / M_PI;
|
---|
| 501 |
|
---|
| 502 | char phiCh = 'N';
|
---|
| 503 | if (phiDeg < 0) {
|
---|
| 504 | phiDeg = -phiDeg;
|
---|
| 505 | phiCh = 'S';
|
---|
| 506 | }
|
---|
| 507 | char lamCh = 'E';
|
---|
| 508 | if (lamDeg < 0) {
|
---|
| 509 | lamDeg = -lamDeg;
|
---|
| 510 | lamCh = 'W';
|
---|
| 511 | }
|
---|
| 512 |
|
---|
[5990] | 513 | ostringstream out;
|
---|
| 514 | out.setf(ios::fixed);
|
---|
[5989] | 515 |
|
---|
[5990] | 516 | if (strType == 'R') {
|
---|
| 517 | string datestr = output._epoTime.datestr(0); // yyyymmdd
|
---|
| 518 | out << "GPRMC,"
|
---|
| 519 | << output._epoTime.timestr(0,0) << ",A,"
|
---|
| 520 | << setw(2) << setfill('0') << int(phiDeg)
|
---|
| 521 | << setw(6) << setprecision(3) << setfill('0')
|
---|
| 522 | << fmod(60*phiDeg,60) << ',' << phiCh << ','
|
---|
| 523 | << setw(3) << setfill('0') << int(lamDeg)
|
---|
| 524 | << setw(6) << setprecision(3) << setfill('0')
|
---|
| 525 | << fmod(60*lamDeg,60) << ',' << lamCh << ",,,"
|
---|
| 526 | << datestr[6] << datestr[7] << datestr[4] << datestr[5]
|
---|
| 527 | << datestr[2] << datestr[3] << ",,";
|
---|
| 528 | }
|
---|
| 529 | else if (strType == 'G') {
|
---|
| 530 | out << "GPGGA,"
|
---|
| 531 | << output._epoTime.timestr(0,0) << ','
|
---|
| 532 | << setw(2) << setfill('0') << int(phiDeg)
|
---|
| 533 | << setw(10) << setprecision(7) << setfill('0')
|
---|
| 534 | << fmod(60*phiDeg,60) << ',' << phiCh << ','
|
---|
| 535 | << setw(3) << setfill('0') << int(lamDeg)
|
---|
| 536 | << setw(10) << setprecision(7) << setfill('0')
|
---|
| 537 | << fmod(60*lamDeg,60) << ',' << lamCh
|
---|
| 538 | << ",1," << setw(2) << setfill('0') << output._numSat << ','
|
---|
| 539 | << setw(3) << setprecision(1) << output._pDop << ','
|
---|
| 540 | << setprecision(3) << ell[2] << ",M,0.0,M,,";
|
---|
| 541 | }
|
---|
| 542 | else {
|
---|
| 543 | return "";
|
---|
| 544 | }
|
---|
[5989] | 545 |
|
---|
[5990] | 546 | QString nmStr(out.str().c_str());
|
---|
[5989] | 547 | unsigned char XOR = 0;
|
---|
| 548 | for (int ii = 0; ii < nmStr.length(); ii++) {
|
---|
| 549 | XOR ^= (unsigned char) nmStr[ii].toAscii();
|
---|
| 550 | }
|
---|
| 551 |
|
---|
| 552 | return '$' + nmStr + QString("*%1\n").arg(int(XOR), 0, 16).toUpper();
|
---|
| 553 | }
|
---|
| 554 |
|
---|
[5999] | 555 | //
|
---|
| 556 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 557 | bool t_pppRun::waitForCorr(const bncTime& epoTime) const {
|
---|
| 558 |
|
---|
[6001] | 559 | if (!_opt->_realTime || _opt->_corrMount.empty()) {
|
---|
[5999] | 560 | return false;
|
---|
| 561 | }
|
---|
[6001] | 562 | else if (!_lastClkCorrTime.valid()) {
|
---|
| 563 | return true;
|
---|
| 564 | }
|
---|
| 565 | else {
|
---|
| 566 | double dt = epoTime - _lastClkCorrTime;
|
---|
| 567 | if (dt > 1.0 && dt < _opt->_corrWaitTime) {
|
---|
| 568 | return true;
|
---|
| 569 | }
|
---|
| 570 | else {
|
---|
| 571 | return false;
|
---|
| 572 | }
|
---|
| 573 | }
|
---|
[5999] | 574 | return false;
|
---|
| 575 | }
|
---|