[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)),
|
---|
[2585] | 82 | this, SLOT(slotNewEphGPS(gpsephemeris)));
|
---|
[2548] | 83 |
|
---|
[2224] | 84 | connect(((bncApp*)qApp), SIGNAL(newEphGlonass(glonassephemeris)),
|
---|
[2585] | 85 | this, SLOT(slotNewEphGlonass(glonassephemeris)));
|
---|
[2548] | 86 |
|
---|
[2113] | 87 | connect(((bncApp*)qApp), SIGNAL(newCorrections(QList<QString>)),
|
---|
[2585] | 88 | this, SLOT(slotNewCorrections(QList<QString>)));
|
---|
[2113] | 89 |
|
---|
[2039] | 90 | _staID = staID;
|
---|
| 91 | _epoData = 0;
|
---|
[2113] | 92 | _model = new bncModel(staID);
|
---|
[2182] | 93 | connect(_model, SIGNAL(newNMEAstr(QByteArray)),
|
---|
| 94 | this, SIGNAL(newNMEAstr(QByteArray)));
|
---|
[2035] | 95 | }
|
---|
| 96 |
|
---|
| 97 | // Destructor
|
---|
| 98 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 99 | bncPPPclient::~bncPPPclient() {
|
---|
[2058] | 100 | delete _model;
|
---|
[2039] | 101 | delete _epoData;
|
---|
[2575] | 102 | QMapIterator<QString, t_ephPair*> it(_eph);
|
---|
[2035] | 103 | while (it.hasNext()) {
|
---|
| 104 | it.next();
|
---|
| 105 | delete it.value();
|
---|
| 106 | }
|
---|
| 107 | QMapIterator<QString, t_corr*> ic(_corr);
|
---|
| 108 | while (ic.hasNext()) {
|
---|
| 109 | ic.next();
|
---|
| 110 | delete ic.value();
|
---|
| 111 | }
|
---|
[2274] | 112 | QMapIterator<QString, t_bias*> ib(_bias);
|
---|
| 113 | while (ib.hasNext()) {
|
---|
| 114 | ib.next();
|
---|
| 115 | delete ib.value();
|
---|
| 116 | }
|
---|
[2035] | 117 | }
|
---|
| 118 |
|
---|
| 119 | //
|
---|
| 120 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2711] | 121 | void bncPPPclient::putNewObs(const t_obs& obs) {
|
---|
[2037] | 122 | QMutexLocker locker(&_mutex);
|
---|
[2051] | 123 |
|
---|
[2711] | 124 | if (obs.satSys != 'G' && !_useGlonass) {
|
---|
[2225] | 125 | return;
|
---|
| 126 | }
|
---|
| 127 |
|
---|
[2051] | 128 | t_satData* satData = new t_satData();
|
---|
| 129 |
|
---|
[2274] | 130 | // Satellite Number
|
---|
| 131 | // ----------------
|
---|
[2711] | 132 | if (obs.satSys == 'G') {
|
---|
| 133 | QString prn = QString("G%1").arg(obs.satNum, 2, 10, QChar('0'));
|
---|
[2274] | 134 | satData->prn = prn;
|
---|
| 135 | }
|
---|
[2711] | 136 | else if (obs.satSys == 'R') {
|
---|
| 137 | QString prn = QString("R%1").arg(obs.satNum, 2, 10, QChar('0'));
|
---|
[2274] | 138 | satData->prn = prn;
|
---|
| 139 | }
|
---|
| 140 |
|
---|
[2505] | 141 | // Check Slips
|
---|
| 142 | // -----------
|
---|
| 143 | slipInfo& sInfo = _slips[satData->prn];
|
---|
[2711] | 144 | if ( sInfo.slipCntL1 == obs.slip_cnt_L1 &&
|
---|
| 145 | sInfo.slipCntL2 == obs.slip_cnt_L2 ) {
|
---|
[2505] | 146 | satData->slipFlag = false;
|
---|
| 147 | }
|
---|
| 148 | else {
|
---|
| 149 | satData->slipFlag = true;
|
---|
| 150 | }
|
---|
[2711] | 151 | sInfo.slipCntL1 = obs.slip_cnt_L1;
|
---|
| 152 | sInfo.slipCntL2 = obs.slip_cnt_L2;
|
---|
[2505] | 153 |
|
---|
[2274] | 154 | // Handle Code Biases
|
---|
| 155 | // ------------------
|
---|
| 156 | t_bias* bb = 0;
|
---|
| 157 | if (_bias.contains(satData->prn)) {
|
---|
| 158 | bb = _bias.value(satData->prn);
|
---|
| 159 | }
|
---|
| 160 |
|
---|
[2051] | 161 | // Set Code Observations
|
---|
| 162 | // ---------------------
|
---|
[2711] | 163 | if (obs.P1) {
|
---|
| 164 | satData->P1 = obs.P1 + (bb ? bb->p1 : 0.0);
|
---|
[2051] | 165 | satData->codeTypeF1 = t_satData::P_CODE;
|
---|
| 166 | }
|
---|
[2711] | 167 | else if (obs.C1) {
|
---|
| 168 | satData->P1 = obs.C1 + (bb ? bb->c1 : 0.0);
|
---|
[2051] | 169 | satData->codeTypeF1 = t_satData::C_CODE;
|
---|
| 170 | }
|
---|
| 171 | else {
|
---|
| 172 | delete satData;
|
---|
| 173 | return;
|
---|
| 174 | }
|
---|
| 175 |
|
---|
[2711] | 176 | if (obs.P2) {
|
---|
| 177 | satData->P2 = obs.P2 + (bb ? bb->p2 : 0.0);
|
---|
[2051] | 178 | satData->codeTypeF2 = t_satData::P_CODE;
|
---|
| 179 | }
|
---|
[2711] | 180 | else if (obs.C2) {
|
---|
| 181 | satData->P2 = obs.C2;
|
---|
[2051] | 182 | satData->codeTypeF2 = t_satData::C_CODE;
|
---|
| 183 | }
|
---|
| 184 | else {
|
---|
| 185 | delete satData;
|
---|
| 186 | return;
|
---|
| 187 | }
|
---|
| 188 |
|
---|
[2228] | 189 | double f1 = t_CST::freq1;
|
---|
| 190 | double f2 = t_CST::freq2;
|
---|
| 191 |
|
---|
[2711] | 192 | if (obs.satSys == 'R') {
|
---|
| 193 | f1 = 1602000000.0 + 562500.0 * obs.slotNum;
|
---|
| 194 | f2 = 1246000000.0 + 437500.0 * obs.slotNum;
|
---|
[2229] | 195 | }
|
---|
| 196 |
|
---|
[2228] | 197 | // Ionosphere-Free Combination
|
---|
| 198 | // ---------------------------
|
---|
| 199 | double c1 = f1 * f1 / (f1 * f1 - f2 * f2);
|
---|
| 200 | double c2 = - f2 * f2 / (f1 * f1 - f2 * f2);
|
---|
| 201 |
|
---|
[2051] | 202 | satData->P3 = c1 * satData->P1 + c2 * satData->P2;
|
---|
| 203 |
|
---|
| 204 | // Set Phase Observations
|
---|
| 205 | // ----------------------
|
---|
[2711] | 206 | if (obs.L1() && obs.L2()) {
|
---|
| 207 | satData->L1 = obs.L1() * t_CST::c / f1;
|
---|
| 208 | satData->L2 = obs.L2() * t_CST::c / f2;
|
---|
[2051] | 209 | }
|
---|
| 210 | else {
|
---|
| 211 | delete satData;
|
---|
| 212 | return;
|
---|
| 213 | }
|
---|
| 214 | satData->L3 = c1 * satData->L1 + c2 * satData->L2;
|
---|
| 215 |
|
---|
[2583] | 216 | // Set Ionosphere-Free Wavelength
|
---|
| 217 | // ------------------------------
|
---|
| 218 | satData->lambda3 = c1 * t_CST::c / f1 + c2 * t_CST::c / f2;
|
---|
| 219 |
|
---|
[2051] | 220 | // Add new Satellite to the epoch
|
---|
| 221 | // ------------------------------
|
---|
[2711] | 222 | bncTime tt(obs.GPSWeek, obs.GPSWeeks);
|
---|
[2037] | 223 |
|
---|
[2039] | 224 | if (!_epoData) {
|
---|
| 225 | _epoData = new t_epoData();
|
---|
| 226 | _epoData->tt = tt;
|
---|
[2037] | 227 | }
|
---|
[2039] | 228 | else if (tt != _epoData->tt) {
|
---|
[2037] | 229 | processEpoch();
|
---|
[2039] | 230 | delete _epoData;
|
---|
| 231 | _epoData = new t_epoData();
|
---|
| 232 | _epoData->tt = tt;
|
---|
[2037] | 233 | }
|
---|
[2039] | 234 |
|
---|
[2711] | 235 | if (obs.satSys == 'G') {
|
---|
[2274] | 236 | _epoData->satDataGPS[satData->prn] = satData;
|
---|
[2231] | 237 | }
|
---|
[2711] | 238 | else if (obs.satSys == 'R') {
|
---|
[2274] | 239 | _epoData->satDataGlo[satData->prn] = satData;
|
---|
[2231] | 240 | }
|
---|
[2035] | 241 | }
|
---|
| 242 |
|
---|
| 243 | //
|
---|
| 244 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 245 | void bncPPPclient::slotNewEphGPS(gpsephemeris gpseph) {
|
---|
| 246 | QMutexLocker locker(&_mutex);
|
---|
| 247 |
|
---|
| 248 | QString prn = QString("G%1").arg(gpseph.satellite, 2, 10, QChar('0'));
|
---|
| 249 |
|
---|
| 250 | if (_eph.contains(prn)) {
|
---|
[2642] | 251 | t_ephGPS* eLast = static_cast<t_ephGPS*>(_eph.value(prn)->last);
|
---|
| 252 | if ( (eLast->GPSweek() < gpseph.GPSweek) ||
|
---|
| 253 | (eLast->GPSweek() == gpseph.GPSweek &&
|
---|
| 254 | eLast->TOC() < gpseph.TOC) ) {
|
---|
[2576] | 255 | delete static_cast<t_ephGPS*>(_eph.value(prn)->prev);
|
---|
| 256 | _eph.value(prn)->prev = _eph.value(prn)->last;
|
---|
| 257 | _eph.value(prn)->last = new t_ephGPS();
|
---|
| 258 | static_cast<t_ephGPS*>(_eph.value(prn)->last)->set(&gpseph);
|
---|
[2040] | 259 | }
|
---|
[2035] | 260 | }
|
---|
| 261 | else {
|
---|
[2575] | 262 | t_ephGPS* eLast = new t_ephGPS();
|
---|
| 263 | eLast->set(&gpseph);
|
---|
| 264 | _eph.insert(prn, new t_ephPair());
|
---|
| 265 | _eph[prn]->last = eLast;
|
---|
[2035] | 266 | }
|
---|
| 267 | }
|
---|
| 268 |
|
---|
| 269 | //
|
---|
| 270 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2224] | 271 | void bncPPPclient::slotNewEphGlonass(glonassephemeris gloeph) {
|
---|
| 272 | QMutexLocker locker(&_mutex);
|
---|
| 273 |
|
---|
| 274 | QString prn = QString("R%1").arg(gloeph.almanac_number, 2, 10, QChar('0'));
|
---|
| 275 |
|
---|
| 276 | if (_eph.contains(prn)) {
|
---|
[2268] | 277 | int ww = gloeph.GPSWeek;
|
---|
| 278 | int tow = gloeph.GPSTOW;
|
---|
| 279 | updatetime(&ww, &tow, gloeph.tb*1000, 0); // Moscow -> GPS
|
---|
[2642] | 280 | t_ephGlo* eLast = static_cast<t_ephGlo*>(_eph.value(prn)->last);
|
---|
| 281 | if (eLast->GPSweek() < ww ||
|
---|
| 282 | (eLast->GPSweek() == ww && eLast->GPSweeks() < tow)) {
|
---|
[2576] | 283 | delete static_cast<t_ephGlo*>(_eph.value(prn)->prev);
|
---|
| 284 | _eph.value(prn)->prev = _eph.value(prn)->last;
|
---|
| 285 | _eph.value(prn)->last = new t_ephGlo();
|
---|
| 286 | static_cast<t_ephGlo*>(_eph.value(prn)->last)->set(&gloeph);
|
---|
[2224] | 287 | }
|
---|
| 288 | }
|
---|
| 289 | else {
|
---|
[2575] | 290 | t_ephGlo* eLast = new t_ephGlo();
|
---|
| 291 | eLast->set(&gloeph);
|
---|
| 292 | _eph.insert(prn, new t_ephPair());
|
---|
| 293 | _eph[prn]->last = eLast;
|
---|
[2224] | 294 | }
|
---|
| 295 | }
|
---|
| 296 |
|
---|
| 297 | //
|
---|
| 298 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2035] | 299 | void bncPPPclient::slotNewCorrections(QList<QString> corrList) {
|
---|
| 300 | QMutexLocker locker(&_mutex);
|
---|
[2069] | 301 |
|
---|
| 302 | if (corrList.size() == 0) {
|
---|
| 303 | return;
|
---|
| 304 | }
|
---|
| 305 |
|
---|
| 306 | // Remove All Corrections
|
---|
| 307 | // ----------------------
|
---|
| 308 | QMapIterator<QString, t_corr*> ic(_corr);
|
---|
| 309 | while (ic.hasNext()) {
|
---|
| 310 | ic.next();
|
---|
| 311 | delete ic.value();
|
---|
| 312 | }
|
---|
| 313 | _corr.clear();
|
---|
| 314 |
|
---|
[2035] | 315 | QListIterator<QString> it(corrList);
|
---|
| 316 | while (it.hasNext()) {
|
---|
| 317 | QTextStream in(it.next().toAscii());
|
---|
| 318 | int messageType;
|
---|
| 319 | int updateInterval;
|
---|
| 320 | int GPSweek;
|
---|
| 321 | double GPSweeks;
|
---|
| 322 | QString prn;
|
---|
| 323 | in >> messageType >> updateInterval >> GPSweek >> GPSweeks >> prn;
|
---|
| 324 | if ( messageType == COTYPE_GPSCOMBINED ||
|
---|
[2207] | 325 | messageType == COTYPE_GLONASSCOMBINED ||
|
---|
| 326 | messageType == COTYPE_GPSORBIT ||
|
---|
| 327 | messageType == COTYPE_GPSCLOCK ||
|
---|
| 328 | messageType == COTYPE_GLONASSORBIT ||
|
---|
| 329 | messageType == COTYPE_GLONASSCLOCK ) {
|
---|
| 330 |
|
---|
[2035] | 331 | t_corr* cc = 0;
|
---|
| 332 | if (_corr.contains(prn)) {
|
---|
| 333 | cc = _corr.value(prn);
|
---|
| 334 | }
|
---|
| 335 | else {
|
---|
| 336 | cc = new t_corr();
|
---|
| 337 | _corr[prn] = cc;
|
---|
| 338 | }
|
---|
[2207] | 339 |
|
---|
[2035] | 340 | cc->tt.set(GPSweek, GPSweeks);
|
---|
[2207] | 341 |
|
---|
| 342 | if ( messageType == COTYPE_GPSCOMBINED ||
|
---|
| 343 | messageType == COTYPE_GLONASSCOMBINED ) {
|
---|
[2366] | 344 | cc->rao.ReSize(3); cc->rao = 0.0;
|
---|
| 345 | cc->dotRao.ReSize(3); cc->dotRao = 0.0;
|
---|
| 346 | cc->dotDotRao.ReSize(3); cc->dotDotRao = 0.0;
|
---|
| 347 | cc->dClk = 0.0;
|
---|
| 348 | cc->dotDClk = 0.0;
|
---|
| 349 | cc->dotDotDClk = 0.0;
|
---|
| 350 | in >> cc->iod
|
---|
| 351 | >> cc->dClk >> cc->rao[0] >> cc->rao[1] >> cc->rao[2]
|
---|
| 352 | >> cc->dotDClk >> cc->dotRao[0] >> cc->dotRao[1] >> cc->dotRao[2]
|
---|
| 353 | >> cc->dotDotDClk >> cc->dotDotRao[0] >> cc->dotDotRao[1] >> cc->dotDotRao[2];
|
---|
| 354 | cc->dClk /= t_CST::c;
|
---|
| 355 | cc->dotDClk /= t_CST::c;
|
---|
| 356 | cc->dotDotDClk /= t_CST::c;
|
---|
[2208] | 357 | cc->raoSet = true;
|
---|
| 358 | cc->dClkSet = true;
|
---|
[2207] | 359 | }
|
---|
| 360 | else if ( messageType == COTYPE_GPSORBIT ||
|
---|
| 361 | messageType == COTYPE_GLONASSORBIT ) {
|
---|
[2366] | 362 | cc->rao.ReSize(3); cc->rao = 0.0;
|
---|
| 363 | cc->dotRao.ReSize(3); cc->dotRao = 0.0;
|
---|
| 364 | cc->dotDotRao.ReSize(3); cc->dotDotRao = 0.0;
|
---|
| 365 | in >> cc->iod
|
---|
| 366 | >> cc->rao[0] >> cc->rao[1] >> cc->rao[2]
|
---|
| 367 | >> cc->dotRao[0] >> cc->dotRao[1] >> cc->dotRao[2]
|
---|
| 368 | >> cc->dotDotRao[0] >> cc->dotDotRao[1] >> cc->dotDotRao[2];
|
---|
[2208] | 369 | cc->raoSet = true;
|
---|
[2207] | 370 | }
|
---|
| 371 | else if ( messageType == COTYPE_GPSCLOCK ||
|
---|
| 372 | messageType == COTYPE_GLONASSCLOCK ) {
|
---|
| 373 | int dummyIOD;
|
---|
[2366] | 374 | cc->dClk = 0.0;
|
---|
| 375 | cc->dotDClk = 0.0;
|
---|
| 376 | cc->dotDotDClk = 0.0;
|
---|
| 377 | in >> dummyIOD >> cc->dClk >> cc->dotDClk >> cc->dotDotDClk;
|
---|
| 378 | cc->dClk /= t_CST::c;
|
---|
| 379 | cc->dotDClk /= t_CST::c;
|
---|
| 380 | cc->dotDotDClk /= t_CST::c;
|
---|
[2208] | 381 | cc->dClkSet = true;
|
---|
[2207] | 382 | }
|
---|
[2035] | 383 | }
|
---|
[2317] | 384 | else if ( messageType == BTYPE_GPS ) {
|
---|
[2274] | 385 |
|
---|
| 386 | t_bias* bb = 0;
|
---|
| 387 | if (_bias.contains(prn)) {
|
---|
[2341] | 388 | bb = _bias.value(prn);
|
---|
[2274] | 389 | }
|
---|
| 390 | else {
|
---|
| 391 | bb = new t_bias();
|
---|
| 392 | _bias[prn] = bb;
|
---|
| 393 | }
|
---|
| 394 |
|
---|
| 395 | bb->tt.set(GPSweek, GPSweeks);
|
---|
| 396 |
|
---|
| 397 | int numBiases;
|
---|
| 398 | in >> numBiases;
|
---|
| 399 | for (int ii = 0; ii < numBiases; ++ii) {
|
---|
| 400 | int bType;
|
---|
| 401 | double bValue;
|
---|
| 402 | in >> bType >> bValue;
|
---|
[2426] | 403 | if (bType == CODETYPEGPS_L1_Z) {
|
---|
[2429] | 404 | bb->p1 = bValue;
|
---|
[2274] | 405 | }
|
---|
[2426] | 406 | else if (bType == CODETYPEGPS_L1_CA) {
|
---|
[2429] | 407 | bb->c1 = bValue;
|
---|
[2426] | 408 | }
|
---|
[2365] | 409 | else if (bType == CODETYPEGPS_L2_Z) {
|
---|
[2429] | 410 | bb->p2 = bValue;
|
---|
[2274] | 411 | }
|
---|
| 412 | }
|
---|
| 413 | }
|
---|
[2035] | 414 | }
|
---|
[2208] | 415 |
|
---|
| 416 | QMutableMapIterator<QString, t_corr*> im(_corr);
|
---|
| 417 | while (im.hasNext()) {
|
---|
| 418 | im.next();
|
---|
| 419 | t_corr* cc = im.value();
|
---|
| 420 | if (!cc->ready()) {
|
---|
| 421 | delete cc;
|
---|
| 422 | im.remove();
|
---|
| 423 | }
|
---|
| 424 | }
|
---|
[2035] | 425 | }
|
---|
| 426 |
|
---|
| 427 | // Satellite Position
|
---|
| 428 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2123] | 429 | t_irc bncPPPclient::getSatPos(const bncTime& tt, const QString& prn,
|
---|
[2357] | 430 | ColumnVector& xc, ColumnVector& vv) {
|
---|
[2035] | 431 |
|
---|
[2576] | 432 | const double MAXAGE = 120.0;
|
---|
[2041] | 433 |
|
---|
[2035] | 434 | if (_eph.contains(prn)) {
|
---|
[2040] | 435 |
|
---|
[2357] | 436 | if (_pppMode) {
|
---|
[2068] | 437 | if (_corr.contains(prn)) {
|
---|
| 438 | t_corr* cc = _corr.value(prn);
|
---|
[2576] | 439 | if (tt - cc->tt < MAXAGE) {
|
---|
| 440 | t_eph* eLast = _eph.value(prn)->last;
|
---|
| 441 | t_eph* ePrev = _eph.value(prn)->prev;
|
---|
| 442 | if (eLast && eLast->IOD() == cc->iod) {
|
---|
| 443 | eLast->position(tt.gpsw(), tt.gpssec(), xc.data(), vv.data());
|
---|
| 444 | applyCorr(tt, cc, xc, vv);
|
---|
| 445 | return success;
|
---|
| 446 | }
|
---|
| 447 | else if (ePrev && ePrev->IOD() == cc->iod) {
|
---|
| 448 | ePrev->position(tt.gpsw(), tt.gpssec(), xc.data(), vv.data());
|
---|
| 449 | applyCorr(tt, cc, xc, vv);
|
---|
| 450 | return success;
|
---|
| 451 | }
|
---|
| 452 | }
|
---|
[2041] | 453 | }
|
---|
[2040] | 454 | }
|
---|
[2576] | 455 |
|
---|
| 456 | else {
|
---|
| 457 | t_eph* ee = _eph.value(prn)->last;
|
---|
| 458 | ee->position(tt.gpsw(), tt.gpssec(), xc.data(), vv.data());
|
---|
| 459 | return success;
|
---|
| 460 | }
|
---|
[2035] | 461 | }
|
---|
| 462 |
|
---|
| 463 | return failure;
|
---|
| 464 | }
|
---|
| 465 |
|
---|
| 466 | //
|
---|
| 467 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2296] | 468 | void bncPPPclient::applyCorr(const bncTime& tt, const t_corr* cc,
|
---|
| 469 | ColumnVector& xc, ColumnVector& vv) {
|
---|
[2043] | 470 | ColumnVector dx(3);
|
---|
[2041] | 471 |
|
---|
[2367] | 472 | double dt = tt - cc->tt;
|
---|
| 473 | ColumnVector raoHlp = cc->rao + cc->dotRao * dt + cc->dotDotRao * dt * dt;
|
---|
[2296] | 474 |
|
---|
| 475 | RSW_to_XYZ(xc.Rows(1,3), vv, raoHlp, dx);
|
---|
| 476 |
|
---|
[2414] | 477 | xc[0] -= dx[0];
|
---|
| 478 | xc[1] -= dx[1];
|
---|
| 479 | xc[2] -= dx[2];
|
---|
[2417] | 480 | xc[3] += cc->dClk + cc->dotDClk * dt + cc->dotDotDClk * dt * dt;
|
---|
[2041] | 481 | }
|
---|
| 482 |
|
---|
[2049] | 483 | // Correct Time of Transmission
|
---|
| 484 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2240] | 485 | t_irc bncPPPclient::cmpToT(t_satData* satData) {
|
---|
[2049] | 486 |
|
---|
[2051] | 487 | double prange = satData->P3;
|
---|
[2049] | 488 | if (prange == 0.0) {
|
---|
| 489 | return failure;
|
---|
| 490 | }
|
---|
| 491 |
|
---|
| 492 | double clkSat = 0.0;
|
---|
| 493 | for (int ii = 1; ii <= 10; ii++) {
|
---|
| 494 |
|
---|
[2123] | 495 | bncTime ToT = _epoData->tt - prange / t_CST::c - clkSat;
|
---|
[2049] | 496 |
|
---|
| 497 | ColumnVector xc(4);
|
---|
| 498 | ColumnVector vv(3);
|
---|
[2357] | 499 | if (getSatPos(ToT, satData->prn, xc, vv) != success) {
|
---|
[2049] | 500 | return failure;
|
---|
| 501 | }
|
---|
| 502 |
|
---|
| 503 | double clkSatOld = clkSat;
|
---|
[2050] | 504 | clkSat = xc(4);
|
---|
[2049] | 505 |
|
---|
| 506 | if ( fabs(clkSat-clkSatOld) * t_CST::c < 1.e-4 ) {
|
---|
| 507 | satData->xx = xc.Rows(1,3);
|
---|
| 508 | satData->vv = vv;
|
---|
[2050] | 509 | satData->clk = clkSat * t_CST::c;
|
---|
[2049] | 510 | return success;
|
---|
| 511 | }
|
---|
| 512 | }
|
---|
| 513 |
|
---|
| 514 | return failure;
|
---|
| 515 | }
|
---|
| 516 |
|
---|
[2041] | 517 | //
|
---|
| 518 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2035] | 519 | void bncPPPclient::processEpoch() {
|
---|
| 520 |
|
---|
[2053] | 521 | // Data Pre-Processing
|
---|
| 522 | // -------------------
|
---|
[2231] | 523 | QMutableMapIterator<QString, t_satData*> iGPS(_epoData->satDataGPS);
|
---|
| 524 | while (iGPS.hasNext()) {
|
---|
| 525 | iGPS.next();
|
---|
| 526 | QString prn = iGPS.key();
|
---|
| 527 | t_satData* satData = iGPS.value();
|
---|
[2049] | 528 |
|
---|
[2240] | 529 | if (cmpToT(satData) != success) {
|
---|
[2049] | 530 | delete satData;
|
---|
[2231] | 531 | iGPS.remove();
|
---|
[2049] | 532 | continue;
|
---|
| 533 | }
|
---|
[2053] | 534 | }
|
---|
[2035] | 535 |
|
---|
[2231] | 536 | QMutableMapIterator<QString, t_satData*> iGlo(_epoData->satDataGlo);
|
---|
| 537 | while (iGlo.hasNext()) {
|
---|
| 538 | iGlo.next();
|
---|
| 539 | QString prn = iGlo.key();
|
---|
| 540 | t_satData* satData = iGlo.value();
|
---|
| 541 |
|
---|
[2240] | 542 | if (cmpToT(satData) != success) {
|
---|
[2231] | 543 | delete satData;
|
---|
| 544 | iGlo.remove();
|
---|
| 545 | continue;
|
---|
| 546 | }
|
---|
| 547 | }
|
---|
| 548 |
|
---|
[2060] | 549 | // Filter Solution
|
---|
| 550 | // ---------------
|
---|
[2143] | 551 | if (_model->update(_epoData) == success) {
|
---|
[2145] | 552 | emit newPosition(_model->time(), _model->x(), _model->y(), _model->z());
|
---|
[2060] | 553 | }
|
---|
[2035] | 554 | }
|
---|
[2049] | 555 |
|
---|