| 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 | *
|
|---|
| 30 | * Class: t_pppRun
|
|---|
| 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>
|
|---|
| 45 | #include <sstream>
|
|---|
| 46 | #include <string.h>
|
|---|
| 47 | #include <map>
|
|---|
| 48 |
|
|---|
| 49 | #include "pppRun.h"
|
|---|
| 50 | #include "pppThread.h"
|
|---|
| 51 | #include "bnccore.h"
|
|---|
| 52 | #include "bncephuser.h"
|
|---|
| 53 | #include "bncsettings.h"
|
|---|
| 54 | #include "bncoutf.h"
|
|---|
| 55 | #include "rinex/rnxobsfile.h"
|
|---|
| 56 | #include "rinex/rnxnavfile.h"
|
|---|
| 57 | #include "rinex/corrfile.h"
|
|---|
| 58 |
|
|---|
| 59 | using namespace BNC_PPP;
|
|---|
| 60 | using namespace std;
|
|---|
| 61 |
|
|---|
| 62 | // Constructor
|
|---|
| 63 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 64 | t_pppRun::t_pppRun(const t_pppOptions* opt) {
|
|---|
| 65 |
|
|---|
| 66 | _opt = opt;
|
|---|
| 67 |
|
|---|
| 68 | connect(this, SIGNAL(newMessage(QByteArray,bool)),
|
|---|
| 69 | BNC_CORE, SLOT(slotMessage(const QByteArray,bool)));
|
|---|
| 70 |
|
|---|
| 71 | connect(this, SIGNAL(newPosition(QByteArray, bncTime, QVector<double>)),
|
|---|
| 72 | BNC_CORE, SIGNAL(newPosition(QByteArray, bncTime, QVector<double>)));
|
|---|
| 73 |
|
|---|
| 74 | connect(this, SIGNAL(newNMEAstr(QByteArray, QByteArray)),
|
|---|
| 75 | BNC_CORE, SIGNAL(newNMEAstr(QByteArray, QByteArray)));
|
|---|
| 76 |
|
|---|
| 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 |
|
|---|
| 84 | bncSettings settings;
|
|---|
| 85 |
|
|---|
| 86 | if (_opt->_realTime) {
|
|---|
| 87 | Qt::ConnectionType conType = Qt::AutoConnection;
|
|---|
| 88 | if (BNC_CORE->mode() == t_bncCore::batchPostProcessing) {
|
|---|
| 89 | conType = Qt::BlockingQueuedConnection;
|
|---|
| 90 | }
|
|---|
| 91 |
|
|---|
| 92 | connect(BNC_CORE->caster(), SIGNAL(newObs(QByteArray, QList<t_obs>)),
|
|---|
| 93 | this, SLOT(slotNewObs(QByteArray, QList<t_obs>)),conType);
|
|---|
| 94 |
|
|---|
| 95 | connect(BNC_CORE, SIGNAL(newEphGPS(gpsephemeris)),
|
|---|
| 96 | this, SLOT(slotNewEphGPS(gpsephemeris)),conType);
|
|---|
| 97 |
|
|---|
| 98 | connect(BNC_CORE, SIGNAL(newEphGlonass(glonassephemeris)),
|
|---|
| 99 | this, SLOT(slotNewEphGlonass(glonassephemeris)),conType);
|
|---|
| 100 |
|
|---|
| 101 | connect(BNC_CORE, SIGNAL(newEphGalileo(galileoephemeris)),
|
|---|
| 102 | this, SLOT(slotNewEphGalileo(galileoephemeris)),conType);
|
|---|
| 103 |
|
|---|
| 104 | connect(BNC_CORE, SIGNAL(newCorrections(QStringList)),
|
|---|
| 105 | this, SLOT(slotNewCorrections(QStringList)),conType);
|
|---|
| 106 | }
|
|---|
| 107 | else {
|
|---|
| 108 | _rnxObsFile = 0;
|
|---|
| 109 | _rnxNavFile = 0;
|
|---|
| 110 | _corrFile = 0;
|
|---|
| 111 | _speed = settings.value("PPP/mapSpeedSlider").toInt();
|
|---|
| 112 | connect(this, SIGNAL(progressRnxPPP(int)), BNC_CORE, SIGNAL(progressRnxPPP(int)));
|
|---|
| 113 | connect(this, SIGNAL(finishedRnxPPP()), BNC_CORE, SIGNAL(finishedRnxPPP()));
|
|---|
| 114 | connect(BNC_CORE, SIGNAL(mapSpeedSliderChanged(int)),
|
|---|
| 115 | this, SLOT(slotSetSpeed(int)));
|
|---|
| 116 | connect(BNC_CORE, SIGNAL(stopRinexPPP()), this, SLOT(slotSetStopFlag()));
|
|---|
| 117 | }
|
|---|
| 118 |
|
|---|
| 119 | _stopFlag = false;
|
|---|
| 120 |
|
|---|
| 121 | QString roverName(_opt->_roverName.c_str());
|
|---|
| 122 |
|
|---|
| 123 | QString logFileSkl = settings.value("PPP/logFile").toString();
|
|---|
| 124 | if (logFileSkl.isEmpty()) {
|
|---|
| 125 | _logFile = 0;
|
|---|
| 126 | }
|
|---|
| 127 | else {
|
|---|
| 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);
|
|---|
| 135 | }
|
|---|
| 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 | }
|
|---|
| 150 | }
|
|---|
| 151 |
|
|---|
| 152 | // Destructor
|
|---|
| 153 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 154 | t_pppRun::~t_pppRun() {
|
|---|
| 155 | delete _logFile;
|
|---|
| 156 | delete _nmeaFile;
|
|---|
| 157 | }
|
|---|
| 158 |
|
|---|
| 159 | //
|
|---|
| 160 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 161 | void t_pppRun::slotNewEphGPS(gpsephemeris gpseph) {
|
|---|
| 162 | QMutexLocker locker(&_mutex);
|
|---|
| 163 | t_ephGPS eph;
|
|---|
| 164 | eph.set(&gpseph);
|
|---|
| 165 | _pppClient->putEphemeris(&eph);
|
|---|
| 166 | }
|
|---|
| 167 |
|
|---|
| 168 | //
|
|---|
| 169 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 170 | void t_pppRun::slotNewEphGlonass(glonassephemeris gloeph) {
|
|---|
| 171 | QMutexLocker locker(&_mutex);
|
|---|
| 172 | t_ephGlo eph;
|
|---|
| 173 | eph.set(&gloeph);
|
|---|
| 174 | _pppClient->putEphemeris(&eph);
|
|---|
| 175 | }
|
|---|
| 176 |
|
|---|
| 177 | //
|
|---|
| 178 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 179 | void t_pppRun::slotNewEphGalileo(galileoephemeris galeph) {
|
|---|
| 180 | QMutexLocker locker(&_mutex);
|
|---|
| 181 | t_ephGal eph;
|
|---|
| 182 | eph.set(&galeph);
|
|---|
| 183 | _pppClient->putEphemeris(&eph);
|
|---|
| 184 | }
|
|---|
| 185 |
|
|---|
| 186 | //
|
|---|
| 187 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 188 | void t_pppRun::slotNewObs(QByteArray staID, QList<t_obs> obsList) {
|
|---|
| 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 | // -----------------------------------------------------
|
|---|
| 197 | QListIterator<t_obs> it(obsList);
|
|---|
| 198 | while (it.hasNext()) {
|
|---|
| 199 | const t_obs& oldObs = it.next();
|
|---|
| 200 | t_satObs* newObs = new t_satObs;
|
|---|
| 201 |
|
|---|
| 202 | newObs->_prn.set(oldObs.satSys, oldObs.satNum);
|
|---|
| 203 | newObs->_time.set(oldObs.GPSWeek, oldObs.GPSWeeks);
|
|---|
| 204 |
|
|---|
| 205 | // Find the corresponding data epoch or create a new one
|
|---|
| 206 | // -----------------------------------------------------
|
|---|
| 207 | t_epoData* epoch = 0;
|
|---|
| 208 | deque<t_epoData*>::const_iterator it;
|
|---|
| 209 | for (it = _epoData.begin(); it != _epoData.end(); it++) {
|
|---|
| 210 | if (newObs->_time == (*it)->_time) {
|
|---|
| 211 | epoch = *it;
|
|---|
| 212 | break;
|
|---|
| 213 | }
|
|---|
| 214 | }
|
|---|
| 215 | if (epoch == 0) {
|
|---|
| 216 | if (_epoData.empty() || newObs->_time > _epoData.back()->_time) {
|
|---|
| 217 | epoch = new t_epoData;
|
|---|
| 218 | epoch->_time = newObs->_time;
|
|---|
| 219 | _epoData.push_back(epoch);
|
|---|
| 220 | }
|
|---|
| 221 | }
|
|---|
| 222 |
|
|---|
| 223 | // Fill the new observation and add it to the corresponding epoch
|
|---|
| 224 | // --------------------------------------------------------------
|
|---|
| 225 | if (epoch != 0) {
|
|---|
| 226 | epoch->_satObs.push_back(newObs);
|
|---|
| 227 | map<string, t_frqObs*> frqObsMap;
|
|---|
| 228 | for (unsigned iEntry = 0; iEntry < GNSSENTRY_NUMBER; iEntry++) {
|
|---|
| 229 | string hlp = oldObs.rnxStr(iEntry).toAscii().data();
|
|---|
| 230 | if (hlp.length() >= 2 && oldObs._measdata[iEntry] != 0.0) {
|
|---|
| 231 | char obsType = hlp[0];
|
|---|
| 232 | string rnxType2ch = hlp.substr(1);
|
|---|
| 233 | if (obsType == 'C' || obsType == 'L') {
|
|---|
| 234 | t_frqObs* frqObs = 0;
|
|---|
| 235 | if (frqObsMap.find(rnxType2ch) == frqObsMap.end()) {
|
|---|
| 236 | frqObs = new t_frqObs();
|
|---|
| 237 | frqObsMap[rnxType2ch] = frqObs;
|
|---|
| 238 | frqObs->_rnxType2ch = rnxType2ch;
|
|---|
| 239 | newObs->_obs.push_back(frqObs);
|
|---|
| 240 | }
|
|---|
| 241 | else {
|
|---|
| 242 | frqObs = frqObsMap[rnxType2ch];
|
|---|
| 243 | }
|
|---|
| 244 | if (obsType == 'C') {
|
|---|
| 245 | frqObs->_code = oldObs._measdata[iEntry];
|
|---|
| 246 | frqObs->_codeValid = true;
|
|---|
| 247 | }
|
|---|
| 248 | else if (obsType == 'L') {
|
|---|
| 249 | frqObs->_phase = oldObs._measdata[iEntry];
|
|---|
| 250 | frqObs->_phaseValid = true;
|
|---|
| 251 | }
|
|---|
| 252 | }
|
|---|
| 253 | }
|
|---|
| 254 | }
|
|---|
| 255 | }
|
|---|
| 256 | }
|
|---|
| 257 |
|
|---|
| 258 | // Process the oldest epochs
|
|---|
| 259 | // ------------------------
|
|---|
| 260 | while (_epoData.size() && !waitForCorr(_epoData.front()->_time)) {
|
|---|
| 261 |
|
|---|
| 262 | const vector<t_satObs*>& satObs = _epoData.front()->_satObs;
|
|---|
| 263 |
|
|---|
| 264 | t_output output;
|
|---|
| 265 | _pppClient->processEpoch(satObs, &output);
|
|---|
| 266 |
|
|---|
| 267 | if (!output._error) {
|
|---|
| 268 | QVector<double> xx(6);
|
|---|
| 269 | xx.data()[0] = output._xyzRover[0];
|
|---|
| 270 | xx.data()[1] = output._xyzRover[1];
|
|---|
| 271 | xx.data()[2] = output._xyzRover[2];
|
|---|
| 272 | xx.data()[3] = output._neu[0];
|
|---|
| 273 | xx.data()[4] = output._neu[1];
|
|---|
| 274 | xx.data()[5] = output._neu[2];
|
|---|
| 275 | emit newPosition(staID, output._epoTime, xx);
|
|---|
| 276 | }
|
|---|
| 277 |
|
|---|
| 278 | delete _epoData.front(); _epoData.pop_front();
|
|---|
| 279 |
|
|---|
| 280 | ostringstream log;
|
|---|
| 281 | if (output._error) {
|
|---|
| 282 | log << output._log;
|
|---|
| 283 | }
|
|---|
| 284 | else {
|
|---|
| 285 | log.setf(ios::fixed);
|
|---|
| 286 | log << string(output._epoTime) << ' ' << staID.data()
|
|---|
| 287 | << " X = " << setprecision(4) << output._xyzRover[0]
|
|---|
| 288 | << " Y = " << setprecision(4) << output._xyzRover[1]
|
|---|
| 289 | << " Z = " << setprecision(4) << output._xyzRover[2]
|
|---|
| 290 | << " NEU: " << setprecision(4) << output._neu[0]
|
|---|
| 291 | << " " << setprecision(4) << output._neu[1]
|
|---|
| 292 | << " " << setprecision(4) << output._neu[2];
|
|---|
| 293 | }
|
|---|
| 294 |
|
|---|
| 295 | if (_logFile && output._epoTime.valid()) {
|
|---|
| 296 | _logFile->write(output._epoTime.gpsw(), output._epoTime.gpssec(),
|
|---|
| 297 | QString(output._log.c_str()));
|
|---|
| 298 | }
|
|---|
| 299 |
|
|---|
| 300 | if (!output._error) {
|
|---|
| 301 | QString rmcStr = nmeaString('R', output);
|
|---|
| 302 | QString ggaStr = nmeaString('G', output);
|
|---|
| 303 | if (_nmeaFile) {
|
|---|
| 304 | _nmeaFile->write(output._epoTime.gpsw(), output._epoTime.gpssec(), rmcStr);
|
|---|
| 305 | _nmeaFile->write(output._epoTime.gpsw(), output._epoTime.gpssec(), ggaStr);
|
|---|
| 306 | }
|
|---|
| 307 | emit newNMEAstr(staID, rmcStr.toAscii());
|
|---|
| 308 | emit newNMEAstr(staID, ggaStr.toAscii());
|
|---|
| 309 | }
|
|---|
| 310 |
|
|---|
| 311 | emit newMessage(QByteArray(log.str().c_str()), true);
|
|---|
| 312 | }
|
|---|
| 313 | }
|
|---|
| 314 |
|
|---|
| 315 | //
|
|---|
| 316 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 317 | void t_pppRun::slotNewCorrections(QStringList corrList) {
|
|---|
| 318 | QMutexLocker locker(&_mutex);
|
|---|
| 319 |
|
|---|
| 320 | // Check the Mountpoint (source of corrections)
|
|---|
| 321 | // --------------------------------------------
|
|---|
| 322 | if (_opt->_realTime) {
|
|---|
| 323 | if (_opt->_corrMount.empty()) {
|
|---|
| 324 | return;
|
|---|
| 325 | }
|
|---|
| 326 | QMutableListIterator<QString> itm(corrList);
|
|---|
| 327 | while (itm.hasNext()) {
|
|---|
| 328 | QStringList hlp = itm.next().split(" ");
|
|---|
| 329 | if (hlp.size() > 0) {
|
|---|
| 330 | QString mountpoint = hlp[hlp.size()-1];
|
|---|
| 331 | if (mountpoint != QString(_opt->_corrMount.c_str())) {
|
|---|
| 332 | itm.remove();
|
|---|
| 333 | }
|
|---|
| 334 | }
|
|---|
| 335 | }
|
|---|
| 336 | }
|
|---|
| 337 |
|
|---|
| 338 | if (corrList.size() == 0) {
|
|---|
| 339 | return;
|
|---|
| 340 | }
|
|---|
| 341 |
|
|---|
| 342 | vector<t_orbCorr*> orbCorr;
|
|---|
| 343 | vector<t_clkCorr*> clkCorr;
|
|---|
| 344 | vector<t_satBias*> satBias;
|
|---|
| 345 |
|
|---|
| 346 | QListIterator<QString> it(corrList);
|
|---|
| 347 | while (it.hasNext()) {
|
|---|
| 348 | QString line = it.next();
|
|---|
| 349 |
|
|---|
| 350 | QTextStream in(&line);
|
|---|
| 351 | int messageType;
|
|---|
| 352 | int updateInterval;
|
|---|
| 353 | int GPSweek;
|
|---|
| 354 | double GPSweeks;
|
|---|
| 355 | QString prn;
|
|---|
| 356 | in >> messageType >> updateInterval >> GPSweek >> GPSweeks >> prn;
|
|---|
| 357 |
|
|---|
| 358 | if ( t_corr::relevantMessageType(messageType) ) {
|
|---|
| 359 | t_corr corr;
|
|---|
| 360 | corr.readLine(line);
|
|---|
| 361 | if (messageType == COTYPE_GPSCOMBINED || messageType == COTYPE_GLONASSCOMBINED ||
|
|---|
| 362 | messageType == COTYPE_GPSORBIT || messageType == COTYPE_GLONASSORBIT ) {
|
|---|
| 363 | t_orbCorr* cc = new t_orbCorr();
|
|---|
| 364 | cc->_prn.set(corr.prn.toAscii().data());
|
|---|
| 365 | cc->_iod = corr.iod;
|
|---|
| 366 | cc->_time = corr.tRao;
|
|---|
| 367 | cc->_system = 'R';
|
|---|
| 368 | cc->_xr[0] = corr.rao[0];
|
|---|
| 369 | cc->_xr[1] = corr.rao[1];
|
|---|
| 370 | cc->_xr[2] = corr.rao[2];
|
|---|
| 371 | cc->_dotXr[0] = corr.dotRao[0];
|
|---|
| 372 | cc->_dotXr[0] = corr.dotRao[1];
|
|---|
| 373 | cc->_dotXr[0] = corr.dotRao[2];
|
|---|
| 374 | orbCorr.push_back(cc);
|
|---|
| 375 |
|
|---|
| 376 | _lastOrbCorrIOD[cc->_prn.toInt()] = cc->_iod;
|
|---|
| 377 | }
|
|---|
| 378 | else if (messageType == COTYPE_GPSCOMBINED || messageType == COTYPE_GLONASSCOMBINED ||
|
|---|
| 379 | messageType == COTYPE_GPSCLOCK || messageType == COTYPE_GLONASSCLOCK ) {
|
|---|
| 380 | t_clkCorr* cc = new t_clkCorr();
|
|---|
| 381 | cc->_prn.set(corr.prn.toAscii().data());
|
|---|
| 382 | cc->_iod = corr.iod;
|
|---|
| 383 | cc->_time = corr.tClk;
|
|---|
| 384 | cc->_dClk = corr.dClk;
|
|---|
| 385 | cc->_dotDClk = corr.dotDClk;
|
|---|
| 386 | cc->_dotDotDClk = corr.dotDotDClk;
|
|---|
| 387 | cc->_clkPartial = 0.0;
|
|---|
| 388 | if (messageType == COTYPE_GPSCLOCK || messageType == COTYPE_GLONASSCLOCK) {
|
|---|
| 389 | int lastIOD = _lastOrbCorrIOD[cc->_prn.toInt()];
|
|---|
| 390 | if (lastIOD != -1) {
|
|---|
| 391 | cc->_iod = lastIOD;
|
|---|
| 392 | }
|
|---|
| 393 | else {
|
|---|
| 394 | delete cc;
|
|---|
| 395 | cc = 0;
|
|---|
| 396 | }
|
|---|
| 397 | }
|
|---|
| 398 | if (cc) {
|
|---|
| 399 | clkCorr.push_back(cc);
|
|---|
| 400 | _lastClkCorrValue[cc->_prn.toInt()] = cc->_dClk;
|
|---|
| 401 | if (_lastClkCorrTime.undef() || cc->_time > _lastClkCorrTime) {
|
|---|
| 402 | _lastClkCorrTime = cc->_time;
|
|---|
| 403 | }
|
|---|
| 404 | }
|
|---|
| 405 | }
|
|---|
| 406 | }
|
|---|
| 407 | else if ( messageType == BTYPE_GPS || messageType == BTYPE_GLONASS ) {
|
|---|
| 408 | t_bias bias;
|
|---|
| 409 | bias.readLine(line);
|
|---|
| 410 | }
|
|---|
| 411 | }
|
|---|
| 412 |
|
|---|
| 413 | _pppClient->putOrbCorrections(orbCorr);
|
|---|
| 414 | _pppClient->putClkCorrections(clkCorr);
|
|---|
| 415 | _pppClient->putBiases(satBias);
|
|---|
| 416 |
|
|---|
| 417 | for (unsigned ii = 0; ii < orbCorr.size(); ii++) {
|
|---|
| 418 | delete orbCorr[ii];
|
|---|
| 419 | }
|
|---|
| 420 | for (unsigned ii = 0; ii < clkCorr.size(); ii++) {
|
|---|
| 421 | delete clkCorr[ii];
|
|---|
| 422 | }
|
|---|
| 423 | for (unsigned ii = 0; ii < satBias.size(); ii++) {
|
|---|
| 424 | delete satBias[ii];
|
|---|
| 425 | }
|
|---|
| 426 | }
|
|---|
| 427 |
|
|---|
| 428 |
|
|---|
| 429 | //
|
|---|
| 430 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 431 | void t_pppRun::processFiles() {
|
|---|
| 432 |
|
|---|
| 433 | try {
|
|---|
| 434 | _rnxObsFile = new t_rnxObsFile(QString(_opt->_rinexObs.c_str()), t_rnxObsFile::input);
|
|---|
| 435 | }
|
|---|
| 436 | catch (...) {
|
|---|
| 437 | delete _rnxObsFile; _rnxObsFile = 0;
|
|---|
| 438 | emit finishedRnxPPP();
|
|---|
| 439 | return;
|
|---|
| 440 | }
|
|---|
| 441 |
|
|---|
| 442 | _rnxNavFile = new t_rnxNavFile(QString(_opt->_rinexNav.c_str()), t_rnxNavFile::input);
|
|---|
| 443 |
|
|---|
| 444 | if (!_opt->_corrFile.empty()) {
|
|---|
| 445 | _corrFile = new t_corrFile(QString(_opt->_corrFile.c_str()));
|
|---|
| 446 | connect(_corrFile, SIGNAL(newCorrections(QStringList)),
|
|---|
| 447 | this, SLOT(slotNewCorrections(QStringList)));
|
|---|
| 448 | }
|
|---|
| 449 |
|
|---|
| 450 | // Read/Process Observations
|
|---|
| 451 | // -------------------------
|
|---|
| 452 | int nEpo = 0;
|
|---|
| 453 | const t_rnxObsFile::t_rnxEpo* epo = 0;
|
|---|
| 454 | while ( !_stopFlag && (epo = _rnxObsFile->nextEpoch()) != 0 ) {
|
|---|
| 455 | ++nEpo;
|
|---|
| 456 |
|
|---|
| 457 | if (_speed < 100) {
|
|---|
| 458 | double sleepTime = 2.0 / _speed;
|
|---|
| 459 | t_pppThread::msleep(sleepTime*1.e3);
|
|---|
| 460 | }
|
|---|
| 461 |
|
|---|
| 462 | // Get Corrections
|
|---|
| 463 | // ---------------
|
|---|
| 464 | if (_corrFile) {
|
|---|
| 465 | _corrFile->syncRead(epo->tt);
|
|---|
| 466 | }
|
|---|
| 467 |
|
|---|
| 468 | // Get Ephemerides
|
|---|
| 469 | // ----------------
|
|---|
| 470 | t_eph* eph = 0;
|
|---|
| 471 | const QMap<QString, int>* corrIODs = _corrFile ? &_corrFile->corrIODs() : 0;
|
|---|
| 472 | while ( (eph = _rnxNavFile->getNextEph(epo->tt, corrIODs)) != 0 ) {
|
|---|
| 473 | _pppClient->putEphemeris(eph);
|
|---|
| 474 | delete eph; eph = 0;
|
|---|
| 475 | }
|
|---|
| 476 |
|
|---|
| 477 | // Create list of observations and start epoch processing
|
|---|
| 478 | // ------------------------------------------------------
|
|---|
| 479 | QList<t_obs> obsList;
|
|---|
| 480 | for (unsigned iObs = 0; iObs < epo->rnxSat.size(); iObs++) {
|
|---|
| 481 | const t_rnxObsFile::t_rnxSat& rnxSat = epo->rnxSat[iObs];
|
|---|
| 482 |
|
|---|
| 483 | t_obs obs;
|
|---|
| 484 | t_rnxObsFile::setObsFromRnx(_rnxObsFile, epo, rnxSat, obs);
|
|---|
| 485 | obsList << obs;
|
|---|
| 486 | }
|
|---|
| 487 | slotNewObs(QByteArray(_opt->_roverName.c_str()), obsList);
|
|---|
| 488 |
|
|---|
| 489 |
|
|---|
| 490 | if (nEpo % 10 == 0) {
|
|---|
| 491 | emit progressRnxPPP(nEpo);
|
|---|
| 492 | }
|
|---|
| 493 |
|
|---|
| 494 | QCoreApplication::processEvents();
|
|---|
| 495 | }
|
|---|
| 496 |
|
|---|
| 497 | emit finishedRnxPPP();
|
|---|
| 498 |
|
|---|
| 499 | if (BNC_CORE->mode() != t_bncCore::interactive) {
|
|---|
| 500 | qApp->exit(0);
|
|---|
| 501 | }
|
|---|
| 502 | else {
|
|---|
| 503 | BNC_CORE->stopPPP();
|
|---|
| 504 | }
|
|---|
| 505 | }
|
|---|
| 506 |
|
|---|
| 507 | //
|
|---|
| 508 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 509 | void t_pppRun::slotSetSpeed(int speed) {
|
|---|
| 510 | QMutexLocker locker(&_mutex);
|
|---|
| 511 | _speed = speed;
|
|---|
| 512 | }
|
|---|
| 513 |
|
|---|
| 514 | //
|
|---|
| 515 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 516 | void t_pppRun::slotSetStopFlag() {
|
|---|
| 517 | QMutexLocker locker(&_mutex);
|
|---|
| 518 | _stopFlag = true;
|
|---|
| 519 | }
|
|---|
| 520 |
|
|---|
| 521 | //
|
|---|
| 522 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 523 | QString t_pppRun::nmeaString(char strType, const t_output& output) {
|
|---|
| 524 |
|
|---|
| 525 | double ell[3];
|
|---|
| 526 | xyz2ell(output._xyzRover, ell);
|
|---|
| 527 | double phiDeg = ell[0] * 180 / M_PI;
|
|---|
| 528 | double lamDeg = ell[1] * 180 / M_PI;
|
|---|
| 529 |
|
|---|
| 530 | char phiCh = 'N';
|
|---|
| 531 | if (phiDeg < 0) {
|
|---|
| 532 | phiDeg = -phiDeg;
|
|---|
| 533 | phiCh = 'S';
|
|---|
| 534 | }
|
|---|
| 535 | char lamCh = 'E';
|
|---|
| 536 | if (lamDeg < 0) {
|
|---|
| 537 | lamDeg = -lamDeg;
|
|---|
| 538 | lamCh = 'W';
|
|---|
| 539 | }
|
|---|
| 540 |
|
|---|
| 541 | ostringstream out;
|
|---|
| 542 | out.setf(ios::fixed);
|
|---|
| 543 |
|
|---|
| 544 | if (strType == 'R') {
|
|---|
| 545 | string datestr = output._epoTime.datestr(0); // yyyymmdd
|
|---|
| 546 | out << "GPRMC,"
|
|---|
| 547 | << output._epoTime.timestr(0,0) << ",A,"
|
|---|
| 548 | << setw(2) << setfill('0') << int(phiDeg)
|
|---|
| 549 | << setw(6) << setprecision(3) << setfill('0')
|
|---|
| 550 | << fmod(60*phiDeg,60) << ',' << phiCh << ','
|
|---|
| 551 | << setw(3) << setfill('0') << int(lamDeg)
|
|---|
| 552 | << setw(6) << setprecision(3) << setfill('0')
|
|---|
| 553 | << fmod(60*lamDeg,60) << ',' << lamCh << ",,,"
|
|---|
| 554 | << datestr[6] << datestr[7] << datestr[4] << datestr[5]
|
|---|
| 555 | << datestr[2] << datestr[3] << ",,";
|
|---|
| 556 | }
|
|---|
| 557 | else if (strType == 'G') {
|
|---|
| 558 | out << "GPGGA,"
|
|---|
| 559 | << output._epoTime.timestr(0,0) << ','
|
|---|
| 560 | << setw(2) << setfill('0') << int(phiDeg)
|
|---|
| 561 | << setw(10) << setprecision(7) << setfill('0')
|
|---|
| 562 | << fmod(60*phiDeg,60) << ',' << phiCh << ','
|
|---|
| 563 | << setw(3) << setfill('0') << int(lamDeg)
|
|---|
| 564 | << setw(10) << setprecision(7) << setfill('0')
|
|---|
| 565 | << fmod(60*lamDeg,60) << ',' << lamCh
|
|---|
| 566 | << ",1," << setw(2) << setfill('0') << output._numSat << ','
|
|---|
| 567 | << setw(3) << setprecision(1) << output._pDop << ','
|
|---|
| 568 | << setprecision(3) << ell[2] << ",M,0.0,M,,";
|
|---|
| 569 | }
|
|---|
| 570 | else {
|
|---|
| 571 | return "";
|
|---|
| 572 | }
|
|---|
| 573 |
|
|---|
| 574 | QString nmStr(out.str().c_str());
|
|---|
| 575 | unsigned char XOR = 0;
|
|---|
| 576 | for (int ii = 0; ii < nmStr.length(); ii++) {
|
|---|
| 577 | XOR ^= (unsigned char) nmStr[ii].toAscii();
|
|---|
| 578 | }
|
|---|
| 579 |
|
|---|
| 580 | return '$' + nmStr + QString("*%1\n").arg(int(XOR), 0, 16).toUpper();
|
|---|
| 581 | }
|
|---|
| 582 |
|
|---|
| 583 | //
|
|---|
| 584 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 585 | bool t_pppRun::waitForCorr(const bncTime& epoTime) const {
|
|---|
| 586 |
|
|---|
| 587 | if (!_opt->_realTime || _opt->_corrMount.empty()) {
|
|---|
| 588 | return false;
|
|---|
| 589 | }
|
|---|
| 590 | else if (!_lastClkCorrTime.valid()) {
|
|---|
| 591 | return true;
|
|---|
| 592 | }
|
|---|
| 593 | else {
|
|---|
| 594 | double dt = epoTime - _lastClkCorrTime;
|
|---|
| 595 | if (dt > 1.0 && dt < _opt->_corrWaitTime) {
|
|---|
| 596 | return true;
|
|---|
| 597 | }
|
|---|
| 598 | else {
|
|---|
| 599 | return false;
|
|---|
| 600 | }
|
|---|
| 601 | }
|
|---|
| 602 | return false;
|
|---|
| 603 | }
|
|---|