[2035] | 1 | // Part of BNC, a utility for retrieving decoding and
|
---|
| 2 | // converting GNSS data streams from NTRIP broadcasters.
|
---|
| 3 | //
|
---|
| 4 | // Copyright (C) 2007
|
---|
| 5 | // German Federal Agency for Cartography and Geodesy (BKG)
|
---|
| 6 | // http://www.bkg.bund.de
|
---|
| 7 | // Czech Technical University Prague, Department of Geodesy
|
---|
| 8 | // http://www.fsv.cvut.cz
|
---|
| 9 | //
|
---|
| 10 | // Email: euref-ip@bkg.bund.de
|
---|
| 11 | //
|
---|
| 12 | // This program is free software; you can redistribute it and/or
|
---|
| 13 | // modify it under the terms of the GNU General Public License
|
---|
| 14 | // as published by the Free Software Foundation, version 2.
|
---|
| 15 | //
|
---|
| 16 | // This program is distributed in the hope that it will be useful,
|
---|
| 17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 19 | // GNU General Public License for more details.
|
---|
| 20 | //
|
---|
| 21 | // You should have received a copy of the GNU General Public License
|
---|
| 22 | // along with this program; if not, write to the Free Software
|
---|
| 23 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
---|
| 24 |
|
---|
| 25 | /* -------------------------------------------------------------------------
|
---|
| 26 | * BKG NTRIP Client
|
---|
| 27 | * -------------------------------------------------------------------------
|
---|
| 28 | *
|
---|
| 29 | * Class: bncPPPclient
|
---|
| 30 | *
|
---|
| 31 | * Purpose: Precise Point Positioning
|
---|
| 32 | *
|
---|
| 33 | * Author: L. Mervart
|
---|
| 34 | *
|
---|
| 35 | * Created: 21-Nov-2009
|
---|
| 36 | *
|
---|
| 37 | * Changes:
|
---|
| 38 | *
|
---|
| 39 | * -----------------------------------------------------------------------*/
|
---|
| 40 |
|
---|
[2249] | 41 | #include <newmatio.h>
|
---|
[2238] | 42 | #include <iomanip>
|
---|
[2549] | 43 | #include <sstream>
|
---|
[2238] | 44 |
|
---|
[2035] | 45 | #include "bncpppclient.h"
|
---|
[2113] | 46 | #include "bncapp.h"
|
---|
[2043] | 47 | #include "bncutils.h"
|
---|
[2044] | 48 | #include "bncconst.h"
|
---|
[2058] | 49 | #include "bncmodel.h"
|
---|
[2226] | 50 | #include "bncsettings.h"
|
---|
[2035] | 51 |
|
---|
| 52 | extern "C" {
|
---|
| 53 | #include "clock_orbit_rtcm.h"
|
---|
| 54 | }
|
---|
| 55 |
|
---|
| 56 | using namespace std;
|
---|
| 57 |
|
---|
| 58 | // Constructor
|
---|
| 59 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 60 | bncPPPclient::bncPPPclient(QByteArray staID) {
|
---|
[2113] | 61 |
|
---|
[2226] | 62 | bncSettings settings;
|
---|
| 63 |
|
---|
| 64 | if ( Qt::CheckState(settings.value("pppGLONASS").toInt()) == Qt::Checked) {
|
---|
| 65 | _useGlonass = true;
|
---|
| 66 | }
|
---|
| 67 | else {
|
---|
| 68 | _useGlonass = false;
|
---|
| 69 | }
|
---|
| 70 |
|
---|
[2357] | 71 | if (settings.value("pppSPP").toString() == "PPP") {
|
---|
| 72 | _pppMode = true;
|
---|
| 73 | }
|
---|
| 74 | else {
|
---|
| 75 | _pppMode = false;
|
---|
| 76 | }
|
---|
| 77 |
|
---|
[2548] | 78 | connect(this, SIGNAL(newMessage(QByteArray,bool)),
|
---|
| 79 | ((bncApp*)qApp), SLOT(slotMessage(const QByteArray,bool)));
|
---|
| 80 |
|
---|
[2113] | 81 | connect(((bncApp*)qApp), SIGNAL(newEphGPS(gpsephemeris)),
|
---|
[2545] | 82 | this, SLOT(slotNewEphGPS(gpsephemeris)),
|
---|
| 83 | Qt::DirectConnection);
|
---|
[2548] | 84 |
|
---|
[2224] | 85 | connect(((bncApp*)qApp), SIGNAL(newEphGlonass(glonassephemeris)),
|
---|
[2545] | 86 | this, SLOT(slotNewEphGlonass(glonassephemeris)),
|
---|
| 87 | Qt::DirectConnection);
|
---|
[2548] | 88 |
|
---|
[2113] | 89 | connect(((bncApp*)qApp), SIGNAL(newCorrections(QList<QString>)),
|
---|
[2545] | 90 | this, SLOT(slotNewCorrections(QList<QString>)),
|
---|
| 91 | Qt::DirectConnection);
|
---|
[2113] | 92 |
|
---|
[2039] | 93 | _staID = staID;
|
---|
| 94 | _epoData = 0;
|
---|
[2113] | 95 | _model = new bncModel(staID);
|
---|
[2182] | 96 | connect(_model, SIGNAL(newNMEAstr(QByteArray)),
|
---|
| 97 | this, SIGNAL(newNMEAstr(QByteArray)));
|
---|
[2035] | 98 | }
|
---|
| 99 |
|
---|
| 100 | // Destructor
|
---|
| 101 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 102 | bncPPPclient::~bncPPPclient() {
|
---|
[2058] | 103 | delete _model;
|
---|
[2039] | 104 | delete _epoData;
|
---|
[2035] | 105 | QMapIterator<QString, t_eph*> it(_eph);
|
---|
| 106 | while (it.hasNext()) {
|
---|
| 107 | it.next();
|
---|
| 108 | delete it.value();
|
---|
| 109 | }
|
---|
| 110 | QMapIterator<QString, t_corr*> ic(_corr);
|
---|
| 111 | while (ic.hasNext()) {
|
---|
| 112 | ic.next();
|
---|
| 113 | delete ic.value();
|
---|
| 114 | }
|
---|
[2274] | 115 | QMapIterator<QString, t_bias*> ib(_bias);
|
---|
| 116 | while (ib.hasNext()) {
|
---|
| 117 | ib.next();
|
---|
| 118 | delete ib.value();
|
---|
| 119 | }
|
---|
[2035] | 120 | }
|
---|
| 121 |
|
---|
| 122 | //
|
---|
| 123 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 124 | void bncPPPclient::putNewObs(p_obs pp) {
|
---|
[2037] | 125 | QMutexLocker locker(&_mutex);
|
---|
[2051] | 126 |
|
---|
[2037] | 127 | t_obsInternal* obs = &(pp->_o);
|
---|
[2051] | 128 |
|
---|
[2226] | 129 | if (obs->satSys != 'G' && !_useGlonass) {
|
---|
[2225] | 130 | return;
|
---|
| 131 | }
|
---|
| 132 |
|
---|
[2051] | 133 | t_satData* satData = new t_satData();
|
---|
| 134 |
|
---|
[2274] | 135 | // Satellite Number
|
---|
| 136 | // ----------------
|
---|
| 137 | if (obs->satSys == 'G') {
|
---|
| 138 | QString prn = QString("G%1").arg(obs->satNum, 2, 10, QChar('0'));
|
---|
| 139 | satData->prn = prn;
|
---|
| 140 | }
|
---|
| 141 | else if (obs->satSys == 'R') {
|
---|
| 142 | QString prn = QString("R%1").arg(obs->satNum, 2, 10, QChar('0'));
|
---|
| 143 | satData->prn = prn;
|
---|
| 144 | }
|
---|
| 145 |
|
---|
[2505] | 146 | // Check Slips
|
---|
| 147 | // -----------
|
---|
| 148 | slipInfo& sInfo = _slips[satData->prn];
|
---|
| 149 | if ( sInfo.slipCntL1 == obs->slip_cnt_L1 &&
|
---|
| 150 | sInfo.slipCntL2 == obs->slip_cnt_L2 ) {
|
---|
| 151 | satData->slipFlag = false;
|
---|
| 152 | }
|
---|
| 153 | else {
|
---|
| 154 | satData->slipFlag = true;
|
---|
| 155 | }
|
---|
| 156 | sInfo.slipCntL1 = obs->slip_cnt_L1;
|
---|
| 157 | sInfo.slipCntL2 = obs->slip_cnt_L2;
|
---|
| 158 |
|
---|
[2274] | 159 | // Handle Code Biases
|
---|
| 160 | // ------------------
|
---|
| 161 | t_bias* bb = 0;
|
---|
| 162 | if (_bias.contains(satData->prn)) {
|
---|
| 163 | bb = _bias.value(satData->prn);
|
---|
| 164 | }
|
---|
| 165 |
|
---|
[2051] | 166 | // Set Code Observations
|
---|
| 167 | // ---------------------
|
---|
| 168 | if (obs->P1) {
|
---|
[2426] | 169 | satData->P1 = obs->P1 + (bb ? bb->p1 : 0.0);
|
---|
[2051] | 170 | satData->codeTypeF1 = t_satData::P_CODE;
|
---|
| 171 | }
|
---|
| 172 | else if (obs->C1) {
|
---|
[2426] | 173 | satData->P1 = obs->C1 + (bb ? bb->c1 : 0.0);
|
---|
[2051] | 174 | satData->codeTypeF1 = t_satData::C_CODE;
|
---|
| 175 | }
|
---|
| 176 | else {
|
---|
| 177 | delete satData;
|
---|
| 178 | return;
|
---|
| 179 | }
|
---|
| 180 |
|
---|
| 181 | if (obs->P2) {
|
---|
[2426] | 182 | satData->P2 = obs->P2 + (bb ? bb->p2 : 0.0);
|
---|
[2051] | 183 | satData->codeTypeF2 = t_satData::P_CODE;
|
---|
| 184 | }
|
---|
| 185 | else if (obs->C2) {
|
---|
[2317] | 186 | satData->P2 = obs->C2;
|
---|
[2051] | 187 | satData->codeTypeF2 = t_satData::C_CODE;
|
---|
| 188 | }
|
---|
| 189 | else {
|
---|
| 190 | delete satData;
|
---|
| 191 | return;
|
---|
| 192 | }
|
---|
| 193 |
|
---|
[2228] | 194 | double f1 = t_CST::freq1;
|
---|
| 195 | double f2 = t_CST::freq2;
|
---|
| 196 |
|
---|
[2229] | 197 | if (obs->satSys == 'R') {
|
---|
| 198 | f1 = 1602000000.0 + 562500.0 * obs->slot;
|
---|
| 199 | f2 = 1246000000.0 + 437500.0 * obs->slot;
|
---|
| 200 | }
|
---|
| 201 |
|
---|
[2228] | 202 | // Ionosphere-Free Combination
|
---|
| 203 | // ---------------------------
|
---|
| 204 | double c1 = f1 * f1 / (f1 * f1 - f2 * f2);
|
---|
| 205 | double c2 = - f2 * f2 / (f1 * f1 - f2 * f2);
|
---|
| 206 |
|
---|
[2051] | 207 | satData->P3 = c1 * satData->P1 + c2 * satData->P2;
|
---|
| 208 |
|
---|
| 209 | // Set Phase Observations
|
---|
| 210 | // ----------------------
|
---|
| 211 | if (obs->L1 && obs->L2) {
|
---|
[2228] | 212 | satData->L1 = obs->L1 * t_CST::c / f1;
|
---|
| 213 | satData->L2 = obs->L2 * t_CST::c / f2;
|
---|
[2051] | 214 | }
|
---|
| 215 | else {
|
---|
| 216 | delete satData;
|
---|
| 217 | return;
|
---|
| 218 | }
|
---|
| 219 | satData->L3 = c1 * satData->L1 + c2 * satData->L2;
|
---|
| 220 |
|
---|
| 221 | // Add new Satellite to the epoch
|
---|
| 222 | // ------------------------------
|
---|
[2123] | 223 | bncTime tt(obs->GPSWeek, obs->GPSWeeks);
|
---|
[2037] | 224 |
|
---|
[2039] | 225 | if (!_epoData) {
|
---|
| 226 | _epoData = new t_epoData();
|
---|
| 227 | _epoData->tt = tt;
|
---|
[2037] | 228 | }
|
---|
[2039] | 229 | else if (tt != _epoData->tt) {
|
---|
[2037] | 230 | processEpoch();
|
---|
[2039] | 231 | delete _epoData;
|
---|
| 232 | _epoData = new t_epoData();
|
---|
| 233 | _epoData->tt = tt;
|
---|
[2037] | 234 | }
|
---|
[2039] | 235 |
|
---|
[2231] | 236 | if (obs->satSys == 'G') {
|
---|
[2274] | 237 | _epoData->satDataGPS[satData->prn] = satData;
|
---|
[2231] | 238 | }
|
---|
| 239 | else if (obs->satSys == 'R') {
|
---|
[2274] | 240 | _epoData->satDataGlo[satData->prn] = satData;
|
---|
[2231] | 241 | }
|
---|
[2035] | 242 | }
|
---|
| 243 |
|
---|
| 244 | //
|
---|
| 245 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 246 | void bncPPPclient::slotNewEphGPS(gpsephemeris gpseph) {
|
---|
| 247 | QMutexLocker locker(&_mutex);
|
---|
| 248 |
|
---|
| 249 | QString prn = QString("G%1").arg(gpseph.satellite, 2, 10, QChar('0'));
|
---|
| 250 |
|
---|
| 251 | if (_eph.contains(prn)) {
|
---|
[2040] | 252 | t_ephGPS* ee = static_cast<t_ephGPS*>(_eph.value(prn));
|
---|
| 253 | if ( (ee->GPSweek() < gpseph.GPSweek) ||
|
---|
| 254 | (ee->GPSweek() == gpseph.GPSweek &&
|
---|
| 255 | ee->TOC() < gpseph.TOC) ) {
|
---|
| 256 | ee->set(&gpseph);
|
---|
| 257 | }
|
---|
[2035] | 258 | }
|
---|
| 259 | else {
|
---|
| 260 | t_ephGPS* ee = new t_ephGPS();
|
---|
| 261 | ee->set(&gpseph);
|
---|
| 262 | _eph[prn] = ee;
|
---|
| 263 | }
|
---|
| 264 | }
|
---|
| 265 |
|
---|
| 266 | //
|
---|
| 267 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2224] | 268 | void bncPPPclient::slotNewEphGlonass(glonassephemeris gloeph) {
|
---|
| 269 | QMutexLocker locker(&_mutex);
|
---|
| 270 |
|
---|
| 271 | QString prn = QString("R%1").arg(gloeph.almanac_number, 2, 10, QChar('0'));
|
---|
| 272 |
|
---|
| 273 | if (_eph.contains(prn)) {
|
---|
[2268] | 274 | int ww = gloeph.GPSWeek;
|
---|
| 275 | int tow = gloeph.GPSTOW;
|
---|
| 276 | updatetime(&ww, &tow, gloeph.tb*1000, 0); // Moscow -> GPS
|
---|
[2224] | 277 | t_ephGlo* ee = static_cast<t_ephGlo*>(_eph.value(prn));
|
---|
[2268] | 278 | if (ee->GPSweek() < ww ||
|
---|
| 279 | (ee->GPSweek() == ww && ee->GPSweeks() < tow)) {
|
---|
[2224] | 280 | ee->set(&gloeph);
|
---|
| 281 | }
|
---|
| 282 | }
|
---|
| 283 | else {
|
---|
| 284 | t_ephGlo* ee = new t_ephGlo();
|
---|
| 285 | ee->set(&gloeph);
|
---|
| 286 | _eph[prn] = ee;
|
---|
| 287 | }
|
---|
| 288 | }
|
---|
| 289 |
|
---|
| 290 | //
|
---|
| 291 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2035] | 292 | void bncPPPclient::slotNewCorrections(QList<QString> corrList) {
|
---|
| 293 | QMutexLocker locker(&_mutex);
|
---|
[2069] | 294 |
|
---|
| 295 | if (corrList.size() == 0) {
|
---|
| 296 | return;
|
---|
| 297 | }
|
---|
| 298 |
|
---|
| 299 | // Remove All Corrections
|
---|
| 300 | // ----------------------
|
---|
| 301 | QMapIterator<QString, t_corr*> ic(_corr);
|
---|
| 302 | while (ic.hasNext()) {
|
---|
| 303 | ic.next();
|
---|
| 304 | delete ic.value();
|
---|
| 305 | }
|
---|
| 306 | _corr.clear();
|
---|
| 307 |
|
---|
[2035] | 308 | QListIterator<QString> it(corrList);
|
---|
| 309 | while (it.hasNext()) {
|
---|
| 310 | QTextStream in(it.next().toAscii());
|
---|
| 311 | int messageType;
|
---|
| 312 | int updateInterval;
|
---|
| 313 | int GPSweek;
|
---|
| 314 | double GPSweeks;
|
---|
| 315 | QString prn;
|
---|
| 316 | in >> messageType >> updateInterval >> GPSweek >> GPSweeks >> prn;
|
---|
| 317 | if ( messageType == COTYPE_GPSCOMBINED ||
|
---|
[2207] | 318 | messageType == COTYPE_GLONASSCOMBINED ||
|
---|
| 319 | messageType == COTYPE_GPSORBIT ||
|
---|
| 320 | messageType == COTYPE_GPSCLOCK ||
|
---|
| 321 | messageType == COTYPE_GLONASSORBIT ||
|
---|
| 322 | messageType == COTYPE_GLONASSCLOCK ) {
|
---|
| 323 |
|
---|
[2035] | 324 | t_corr* cc = 0;
|
---|
| 325 | if (_corr.contains(prn)) {
|
---|
| 326 | cc = _corr.value(prn);
|
---|
| 327 | }
|
---|
| 328 | else {
|
---|
| 329 | cc = new t_corr();
|
---|
| 330 | _corr[prn] = cc;
|
---|
| 331 | }
|
---|
[2207] | 332 |
|
---|
[2035] | 333 | cc->tt.set(GPSweek, GPSweeks);
|
---|
[2207] | 334 |
|
---|
| 335 | if ( messageType == COTYPE_GPSCOMBINED ||
|
---|
| 336 | messageType == COTYPE_GLONASSCOMBINED ) {
|
---|
[2366] | 337 | cc->rao.ReSize(3); cc->rao = 0.0;
|
---|
| 338 | cc->dotRao.ReSize(3); cc->dotRao = 0.0;
|
---|
| 339 | cc->dotDotRao.ReSize(3); cc->dotDotRao = 0.0;
|
---|
| 340 | cc->dClk = 0.0;
|
---|
| 341 | cc->dotDClk = 0.0;
|
---|
| 342 | cc->dotDotDClk = 0.0;
|
---|
| 343 | in >> cc->iod
|
---|
| 344 | >> cc->dClk >> cc->rao[0] >> cc->rao[1] >> cc->rao[2]
|
---|
| 345 | >> cc->dotDClk >> cc->dotRao[0] >> cc->dotRao[1] >> cc->dotRao[2]
|
---|
| 346 | >> cc->dotDotDClk >> cc->dotDotRao[0] >> cc->dotDotRao[1] >> cc->dotDotRao[2];
|
---|
| 347 | cc->dClk /= t_CST::c;
|
---|
| 348 | cc->dotDClk /= t_CST::c;
|
---|
| 349 | cc->dotDotDClk /= t_CST::c;
|
---|
[2208] | 350 | cc->raoSet = true;
|
---|
| 351 | cc->dClkSet = true;
|
---|
[2207] | 352 | }
|
---|
| 353 | else if ( messageType == COTYPE_GPSORBIT ||
|
---|
| 354 | messageType == COTYPE_GLONASSORBIT ) {
|
---|
[2366] | 355 | cc->rao.ReSize(3); cc->rao = 0.0;
|
---|
| 356 | cc->dotRao.ReSize(3); cc->dotRao = 0.0;
|
---|
| 357 | cc->dotDotRao.ReSize(3); cc->dotDotRao = 0.0;
|
---|
| 358 | in >> cc->iod
|
---|
| 359 | >> cc->rao[0] >> cc->rao[1] >> cc->rao[2]
|
---|
| 360 | >> cc->dotRao[0] >> cc->dotRao[1] >> cc->dotRao[2]
|
---|
| 361 | >> cc->dotDotRao[0] >> cc->dotDotRao[1] >> cc->dotDotRao[2];
|
---|
[2208] | 362 | cc->raoSet = true;
|
---|
[2207] | 363 | }
|
---|
| 364 | else if ( messageType == COTYPE_GPSCLOCK ||
|
---|
| 365 | messageType == COTYPE_GLONASSCLOCK ) {
|
---|
| 366 | int dummyIOD;
|
---|
[2366] | 367 | cc->dClk = 0.0;
|
---|
| 368 | cc->dotDClk = 0.0;
|
---|
| 369 | cc->dotDotDClk = 0.0;
|
---|
| 370 | in >> dummyIOD >> cc->dClk >> cc->dotDClk >> cc->dotDotDClk;
|
---|
| 371 | cc->dClk /= t_CST::c;
|
---|
| 372 | cc->dotDClk /= t_CST::c;
|
---|
| 373 | cc->dotDotDClk /= t_CST::c;
|
---|
[2208] | 374 | cc->dClkSet = true;
|
---|
[2207] | 375 | }
|
---|
[2035] | 376 | }
|
---|
[2317] | 377 | else if ( messageType == BTYPE_GPS ) {
|
---|
[2274] | 378 |
|
---|
| 379 | t_bias* bb = 0;
|
---|
| 380 | if (_bias.contains(prn)) {
|
---|
[2341] | 381 | bb = _bias.value(prn);
|
---|
[2274] | 382 | }
|
---|
| 383 | else {
|
---|
| 384 | bb = new t_bias();
|
---|
| 385 | _bias[prn] = bb;
|
---|
| 386 | }
|
---|
| 387 |
|
---|
| 388 | bb->tt.set(GPSweek, GPSweeks);
|
---|
| 389 |
|
---|
| 390 | int numBiases;
|
---|
| 391 | in >> numBiases;
|
---|
| 392 | for (int ii = 0; ii < numBiases; ++ii) {
|
---|
| 393 | int bType;
|
---|
| 394 | double bValue;
|
---|
| 395 | in >> bType >> bValue;
|
---|
[2426] | 396 | if (bType == CODETYPEGPS_L1_Z) {
|
---|
[2429] | 397 | bb->p1 = bValue;
|
---|
[2274] | 398 | }
|
---|
[2426] | 399 | else if (bType == CODETYPEGPS_L1_CA) {
|
---|
[2429] | 400 | bb->c1 = bValue;
|
---|
[2426] | 401 | }
|
---|
[2365] | 402 | else if (bType == CODETYPEGPS_L2_Z) {
|
---|
[2429] | 403 | bb->p2 = bValue;
|
---|
[2274] | 404 | }
|
---|
| 405 | }
|
---|
| 406 | }
|
---|
[2035] | 407 | }
|
---|
[2208] | 408 |
|
---|
| 409 | QMutableMapIterator<QString, t_corr*> im(_corr);
|
---|
| 410 | while (im.hasNext()) {
|
---|
| 411 | im.next();
|
---|
| 412 | t_corr* cc = im.value();
|
---|
| 413 | if (!cc->ready()) {
|
---|
| 414 | delete cc;
|
---|
| 415 | im.remove();
|
---|
| 416 | }
|
---|
| 417 | }
|
---|
[2035] | 418 | }
|
---|
| 419 |
|
---|
| 420 | // Satellite Position
|
---|
| 421 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2123] | 422 | t_irc bncPPPclient::getSatPos(const bncTime& tt, const QString& prn,
|
---|
[2357] | 423 | ColumnVector& xc, ColumnVector& vv) {
|
---|
[2035] | 424 |
|
---|
[2067] | 425 | const double MAXAGE = 120.0;
|
---|
[2041] | 426 |
|
---|
[2035] | 427 | if (_eph.contains(prn)) {
|
---|
[2040] | 428 | t_eph* ee = _eph.value(prn);
|
---|
| 429 | ee->position(tt.gpsw(), tt.gpssec(), xc.data(), vv.data());
|
---|
| 430 |
|
---|
[2357] | 431 | if (_pppMode) {
|
---|
[2068] | 432 | if (_corr.contains(prn)) {
|
---|
| 433 | t_corr* cc = _corr.value(prn);
|
---|
| 434 | if (ee->IOD() == cc->iod && (tt - cc->tt) < MAXAGE) {
|
---|
[2296] | 435 | applyCorr(tt, cc, xc, vv);
|
---|
[2068] | 436 | return success;
|
---|
| 437 | }
|
---|
[2041] | 438 | }
|
---|
[2068] | 439 | return failure;
|
---|
[2040] | 440 | }
|
---|
[2068] | 441 |
|
---|
[2035] | 442 | return success;
|
---|
| 443 | }
|
---|
| 444 |
|
---|
| 445 | return failure;
|
---|
| 446 | }
|
---|
| 447 |
|
---|
| 448 | //
|
---|
| 449 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2296] | 450 | void bncPPPclient::applyCorr(const bncTime& tt, const t_corr* cc,
|
---|
| 451 | ColumnVector& xc, ColumnVector& vv) {
|
---|
[2043] | 452 | ColumnVector dx(3);
|
---|
[2041] | 453 |
|
---|
[2367] | 454 | double dt = tt - cc->tt;
|
---|
| 455 | ColumnVector raoHlp = cc->rao + cc->dotRao * dt + cc->dotDotRao * dt * dt;
|
---|
[2296] | 456 |
|
---|
| 457 | RSW_to_XYZ(xc.Rows(1,3), vv, raoHlp, dx);
|
---|
| 458 |
|
---|
[2414] | 459 | xc[0] -= dx[0];
|
---|
| 460 | xc[1] -= dx[1];
|
---|
| 461 | xc[2] -= dx[2];
|
---|
[2417] | 462 | xc[3] += cc->dClk + cc->dotDClk * dt + cc->dotDotDClk * dt * dt;
|
---|
[2041] | 463 | }
|
---|
| 464 |
|
---|
[2049] | 465 | // Correct Time of Transmission
|
---|
| 466 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2240] | 467 | t_irc bncPPPclient::cmpToT(t_satData* satData) {
|
---|
[2049] | 468 |
|
---|
[2051] | 469 | double prange = satData->P3;
|
---|
[2049] | 470 | if (prange == 0.0) {
|
---|
| 471 | return failure;
|
---|
| 472 | }
|
---|
| 473 |
|
---|
| 474 | double clkSat = 0.0;
|
---|
| 475 | for (int ii = 1; ii <= 10; ii++) {
|
---|
| 476 |
|
---|
[2123] | 477 | bncTime ToT = _epoData->tt - prange / t_CST::c - clkSat;
|
---|
[2049] | 478 |
|
---|
| 479 | ColumnVector xc(4);
|
---|
| 480 | ColumnVector vv(3);
|
---|
[2357] | 481 | if (getSatPos(ToT, satData->prn, xc, vv) != success) {
|
---|
[2049] | 482 | return failure;
|
---|
| 483 | }
|
---|
| 484 |
|
---|
| 485 | double clkSatOld = clkSat;
|
---|
[2050] | 486 | clkSat = xc(4);
|
---|
[2049] | 487 |
|
---|
| 488 | if ( fabs(clkSat-clkSatOld) * t_CST::c < 1.e-4 ) {
|
---|
| 489 | satData->xx = xc.Rows(1,3);
|
---|
| 490 | satData->vv = vv;
|
---|
[2050] | 491 | satData->clk = clkSat * t_CST::c;
|
---|
[2049] | 492 | return success;
|
---|
| 493 | }
|
---|
| 494 | }
|
---|
| 495 |
|
---|
| 496 | return failure;
|
---|
| 497 | }
|
---|
| 498 |
|
---|
[2041] | 499 | //
|
---|
| 500 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2035] | 501 | void bncPPPclient::processEpoch() {
|
---|
| 502 |
|
---|
[2053] | 503 | // Data Pre-Processing
|
---|
| 504 | // -------------------
|
---|
[2231] | 505 | QMutableMapIterator<QString, t_satData*> iGPS(_epoData->satDataGPS);
|
---|
| 506 | while (iGPS.hasNext()) {
|
---|
| 507 | iGPS.next();
|
---|
| 508 | QString prn = iGPS.key();
|
---|
| 509 | t_satData* satData = iGPS.value();
|
---|
[2049] | 510 |
|
---|
[2240] | 511 | if (cmpToT(satData) != success) {
|
---|
[2049] | 512 | delete satData;
|
---|
[2231] | 513 | iGPS.remove();
|
---|
[2049] | 514 | continue;
|
---|
| 515 | }
|
---|
[2053] | 516 | }
|
---|
[2035] | 517 |
|
---|
[2231] | 518 | QMutableMapIterator<QString, t_satData*> iGlo(_epoData->satDataGlo);
|
---|
| 519 | while (iGlo.hasNext()) {
|
---|
| 520 | iGlo.next();
|
---|
| 521 | QString prn = iGlo.key();
|
---|
| 522 | t_satData* satData = iGlo.value();
|
---|
| 523 |
|
---|
[2240] | 524 | if (cmpToT(satData) != success) {
|
---|
[2231] | 525 | delete satData;
|
---|
| 526 | iGlo.remove();
|
---|
| 527 | continue;
|
---|
| 528 | }
|
---|
| 529 | }
|
---|
| 530 |
|
---|
[2060] | 531 | // Filter Solution
|
---|
| 532 | // ---------------
|
---|
[2143] | 533 | if (_model->update(_epoData) == success) {
|
---|
[2145] | 534 | emit newPosition(_model->time(), _model->x(), _model->y(), _model->z());
|
---|
[2060] | 535 | }
|
---|
[2035] | 536 | }
|
---|
[2049] | 537 |
|
---|