[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 | using namespace std;
|
---|
| 53 |
|
---|
| 54 | // Constructor
|
---|
| 55 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 56 | bncPPPclient::bncPPPclient(QByteArray staID) {
|
---|
[2113] | 57 |
|
---|
[2226] | 58 | bncSettings settings;
|
---|
| 59 |
|
---|
| 60 | if ( Qt::CheckState(settings.value("pppGLONASS").toInt()) == Qt::Checked) {
|
---|
| 61 | _useGlonass = true;
|
---|
| 62 | }
|
---|
| 63 | else {
|
---|
| 64 | _useGlonass = false;
|
---|
| 65 | }
|
---|
| 66 |
|
---|
[2786] | 67 | if ( Qt::CheckState(settings.value("pppGalileo").toInt()) == Qt::Checked) {
|
---|
| 68 | _useGalileo = true;
|
---|
| 69 | }
|
---|
| 70 | else {
|
---|
| 71 | _useGalileo = false;
|
---|
| 72 | }
|
---|
[2776] | 73 |
|
---|
[2357] | 74 | if (settings.value("pppSPP").toString() == "PPP") {
|
---|
| 75 | _pppMode = true;
|
---|
| 76 | }
|
---|
| 77 | else {
|
---|
| 78 | _pppMode = false;
|
---|
| 79 | }
|
---|
| 80 |
|
---|
[2548] | 81 | connect(this, SIGNAL(newMessage(QByteArray,bool)),
|
---|
| 82 | ((bncApp*)qApp), SLOT(slotMessage(const QByteArray,bool)));
|
---|
| 83 |
|
---|
[2113] | 84 | connect(((bncApp*)qApp), SIGNAL(newCorrections(QList<QString>)),
|
---|
[2585] | 85 | this, SLOT(slotNewCorrections(QList<QString>)));
|
---|
[2113] | 86 |
|
---|
[2039] | 87 | _staID = staID;
|
---|
[2113] | 88 | _model = new bncModel(staID);
|
---|
[2182] | 89 | connect(_model, SIGNAL(newNMEAstr(QByteArray)),
|
---|
| 90 | this, SIGNAL(newNMEAstr(QByteArray)));
|
---|
[2035] | 91 | }
|
---|
| 92 |
|
---|
| 93 | // Destructor
|
---|
| 94 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 95 | bncPPPclient::~bncPPPclient() {
|
---|
[2058] | 96 | delete _model;
|
---|
[2808] | 97 | while (!_epoData.empty()) {
|
---|
| 98 | delete _epoData.front();
|
---|
| 99 | _epoData.pop();
|
---|
| 100 | }
|
---|
[2035] | 101 | QMapIterator<QString, t_corr*> ic(_corr);
|
---|
| 102 | while (ic.hasNext()) {
|
---|
| 103 | ic.next();
|
---|
| 104 | delete ic.value();
|
---|
| 105 | }
|
---|
[2274] | 106 | QMapIterator<QString, t_bias*> ib(_bias);
|
---|
| 107 | while (ib.hasNext()) {
|
---|
| 108 | ib.next();
|
---|
| 109 | delete ib.value();
|
---|
| 110 | }
|
---|
[2035] | 111 | }
|
---|
| 112 |
|
---|
| 113 | //
|
---|
| 114 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2711] | 115 | void bncPPPclient::putNewObs(const t_obs& obs) {
|
---|
[2037] | 116 | QMutexLocker locker(&_mutex);
|
---|
[2051] | 117 |
|
---|
[2777] | 118 | if (obs.satSys == 'R') {
|
---|
| 119 | if (!_useGlonass) return;
|
---|
[2225] | 120 | }
|
---|
[2777] | 121 | else if (obs.satSys == 'E') {
|
---|
| 122 | if (!_useGalileo) return;
|
---|
[2776] | 123 | }
|
---|
| 124 | else if (obs.satSys != 'G') {
|
---|
| 125 | return;
|
---|
| 126 | }
|
---|
[2225] | 127 |
|
---|
[2051] | 128 | t_satData* satData = new t_satData();
|
---|
[2808] | 129 | satData->tt = bncTime(obs.GPSWeek, obs.GPSWeeks);
|
---|
[2051] | 130 |
|
---|
[2274] | 131 | // Satellite Number
|
---|
| 132 | // ----------------
|
---|
[2777] | 133 | satData->prn = QString("%1%2").arg(obs.satSys).arg(obs.satNum,2,10,QChar('0'));
|
---|
[2274] | 134 |
|
---|
[2505] | 135 | // Check Slips
|
---|
| 136 | // -----------
|
---|
| 137 | slipInfo& sInfo = _slips[satData->prn];
|
---|
[2711] | 138 | if ( sInfo.slipCntL1 == obs.slip_cnt_L1 &&
|
---|
[2778] | 139 | sInfo.slipCntL2 == obs.slip_cnt_L2 &&
|
---|
| 140 | sInfo.slipCntL5 == obs.slip_cnt_L5 ) {
|
---|
[2505] | 141 | satData->slipFlag = false;
|
---|
| 142 | }
|
---|
| 143 | else {
|
---|
| 144 | satData->slipFlag = true;
|
---|
| 145 | }
|
---|
[2711] | 146 | sInfo.slipCntL1 = obs.slip_cnt_L1;
|
---|
| 147 | sInfo.slipCntL2 = obs.slip_cnt_L2;
|
---|
[2505] | 148 |
|
---|
[2274] | 149 | // Handle Code Biases
|
---|
| 150 | // ------------------
|
---|
| 151 | t_bias* bb = 0;
|
---|
| 152 | if (_bias.contains(satData->prn)) {
|
---|
| 153 | bb = _bias.value(satData->prn);
|
---|
| 154 | }
|
---|
| 155 |
|
---|
[2808] | 156 | // Add new epoch, process the older ones
|
---|
| 157 | // -------------------------------------
|
---|
| 158 | if (_epoData.size() == 0) {
|
---|
| 159 | _epoData.push(new t_epoData());
|
---|
| 160 | _epoData.back()->tt = satData->tt;
|
---|
[2037] | 161 | }
|
---|
[2808] | 162 | else if (satData->tt != _epoData.back()->tt) {
|
---|
| 163 | processEpochs();
|
---|
| 164 | _epoData.push(new t_epoData());
|
---|
| 165 | _epoData.back()->tt = satData->tt;
|
---|
[2037] | 166 | }
|
---|
[2039] | 167 |
|
---|
[2786] | 168 | // Set Observations GPS
|
---|
| 169 | // --------------------
|
---|
[2711] | 170 | if (obs.satSys == 'G') {
|
---|
[2786] | 171 | if ( (obs.P1 || obs.C1) && (obs.P2 || obs.C2) && obs.L1() && obs.L2() ) {
|
---|
| 172 | double f1 = t_CST::freq1;
|
---|
| 173 | double f2 = t_CST::freq2;
|
---|
| 174 | double c1 = f1 * f1 / (f1 * f1 - f2 * f2);
|
---|
| 175 | double c2 = - f2 * f2 / (f1 * f1 - f2 * f2);
|
---|
| 176 | if (obs.P1) {
|
---|
| 177 | satData->P1 = obs.P1 + (bb ? bb->p1 : 0.0);
|
---|
| 178 | }
|
---|
| 179 | else {
|
---|
| 180 | satData->P1 = obs.C1 + (bb ? bb->c1 : 0.0);
|
---|
| 181 | }
|
---|
| 182 | if (obs.P2) {
|
---|
| 183 | satData->P2 = obs.P2 + (bb ? bb->p2 : 0.0);
|
---|
| 184 | }
|
---|
| 185 | else {
|
---|
| 186 | satData->P2 = obs.C2;
|
---|
| 187 | }
|
---|
| 188 | satData->L1 = obs.L1() * t_CST::c / f1;
|
---|
| 189 | satData->L2 = obs.L2() * t_CST::c / f2;
|
---|
| 190 | satData->P3 = c1 * satData->P1 + c2 * satData->P2;
|
---|
| 191 | satData->L3 = c1 * satData->L1 + c2 * satData->L2;
|
---|
| 192 | satData->lambda3 = c1 * t_CST::c / f1 + c2 * t_CST::c / f2;
|
---|
[2778] | 193 |
|
---|
[2808] | 194 | _epoData.back()->satDataGPS[satData->prn] = satData;
|
---|
[2778] | 195 | }
|
---|
| 196 | else {
|
---|
| 197 | delete satData;
|
---|
| 198 | }
|
---|
[2786] | 199 | }
|
---|
[2778] | 200 |
|
---|
[2786] | 201 | // Set Observations GLONASS
|
---|
| 202 | // ------------------------
|
---|
[2711] | 203 | else if (obs.satSys == 'R') {
|
---|
[2786] | 204 | if ( (obs.P1 || obs.C1) && (obs.P2 || obs.C2) && obs.L1() && obs.L2() ) {
|
---|
| 205 | double f1 = 1602000000.0 + 562500.0 * obs.slotNum;
|
---|
| 206 | double f2 = 1246000000.0 + 437500.0 * obs.slotNum;
|
---|
| 207 | double c1 = f1 * f1 / (f1 * f1 - f2 * f2);
|
---|
| 208 | double c2 = - f2 * f2 / (f1 * f1 - f2 * f2);
|
---|
| 209 | if (obs.P1) {
|
---|
| 210 | satData->P1 = obs.P1 + (bb ? bb->p1 : 0.0);
|
---|
| 211 | }
|
---|
| 212 | else {
|
---|
| 213 | satData->P1 = obs.C1 + (bb ? bb->c1 : 0.0);
|
---|
| 214 | }
|
---|
| 215 | if (obs.P2) {
|
---|
| 216 | satData->P2 = obs.P2 + (bb ? bb->p2 : 0.0);
|
---|
| 217 | }
|
---|
| 218 | else {
|
---|
| 219 | satData->P2 = obs.C2;
|
---|
| 220 | }
|
---|
| 221 | satData->L1 = obs.L1() * t_CST::c / f1;
|
---|
| 222 | satData->L2 = obs.L2() * t_CST::c / f2;
|
---|
| 223 | satData->P3 = c1 * satData->P1 + c2 * satData->P2;
|
---|
| 224 | satData->L3 = c1 * satData->L1 + c2 * satData->L2;
|
---|
| 225 | satData->lambda3 = c1 * t_CST::c / f1 + c2 * t_CST::c / f2;
|
---|
[2778] | 226 |
|
---|
[2808] | 227 | _epoData.back()->satDataGlo[satData->prn] = satData;
|
---|
[2778] | 228 | }
|
---|
| 229 | else {
|
---|
| 230 | delete satData;
|
---|
| 231 | }
|
---|
[2786] | 232 | }
|
---|
[2778] | 233 |
|
---|
[2786] | 234 | // Set Observations Galileo
|
---|
| 235 | // ------------------------
|
---|
[2778] | 236 | else if (obs.satSys == 'E') {
|
---|
[2787] | 237 | if ( obs.C1 && obs.C5 && obs.L1() && obs.L5) {
|
---|
[2786] | 238 | double f1 = t_CST::freq1;
|
---|
| 239 | double f5 = t_CST::freq5;
|
---|
| 240 | double c1 = f1 * f1 / (f1 * f1 - f5 * f5);
|
---|
| 241 | double c5 = - f5 * f5 / (f1 * f1 - f5 * f5);
|
---|
[2778] | 242 |
|
---|
[2786] | 243 | satData->P1 = obs.C1;
|
---|
| 244 | satData->P5 = obs.C5;
|
---|
| 245 | satData->L1 = obs.L1() * t_CST::c / f1;
|
---|
| 246 | satData->L5 = obs.L5 * t_CST::c / f5;
|
---|
| 247 | satData->P3 = c1 * satData->P1 + c5 * satData->P5;
|
---|
| 248 | satData->L3 = c1 * satData->L1 + c5 * satData->L5;
|
---|
| 249 | satData->lambda3 = c1 * t_CST::c / f1 + c5 * t_CST::c / f5;
|
---|
[2808] | 250 | _epoData.back()->satDataGal[satData->prn] = satData;
|
---|
[2778] | 251 | }
|
---|
| 252 | else {
|
---|
| 253 | delete satData;
|
---|
| 254 | }
|
---|
| 255 | }
|
---|
[2035] | 256 | }
|
---|
| 257 |
|
---|
| 258 | //
|
---|
| 259 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 260 | void bncPPPclient::slotNewCorrections(QList<QString> corrList) {
|
---|
| 261 | QMutexLocker locker(&_mutex);
|
---|
[2069] | 262 |
|
---|
| 263 | if (corrList.size() == 0) {
|
---|
| 264 | return;
|
---|
| 265 | }
|
---|
| 266 |
|
---|
| 267 | // Remove All Corrections
|
---|
| 268 | // ----------------------
|
---|
| 269 | QMapIterator<QString, t_corr*> ic(_corr);
|
---|
| 270 | while (ic.hasNext()) {
|
---|
| 271 | ic.next();
|
---|
| 272 | delete ic.value();
|
---|
| 273 | }
|
---|
| 274 | _corr.clear();
|
---|
| 275 |
|
---|
[2035] | 276 | QListIterator<QString> it(corrList);
|
---|
| 277 | while (it.hasNext()) {
|
---|
[2911] | 278 | QString line = it.next();
|
---|
| 279 |
|
---|
| 280 | QTextStream in(&line);
|
---|
[2035] | 281 | int messageType;
|
---|
| 282 | int updateInterval;
|
---|
| 283 | int GPSweek;
|
---|
| 284 | double GPSweeks;
|
---|
| 285 | QString prn;
|
---|
| 286 | in >> messageType >> updateInterval >> GPSweek >> GPSweeks >> prn;
|
---|
[2809] | 287 |
|
---|
[2911] | 288 | if ( t_corr::relevantMessageType(messageType) ) {
|
---|
[2035] | 289 | t_corr* cc = 0;
|
---|
| 290 | if (_corr.contains(prn)) {
|
---|
| 291 | cc = _corr.value(prn);
|
---|
| 292 | }
|
---|
| 293 | else {
|
---|
| 294 | cc = new t_corr();
|
---|
| 295 | _corr[prn] = cc;
|
---|
| 296 | }
|
---|
[2207] | 297 |
|
---|
[2911] | 298 | cc->readLine(line);
|
---|
| 299 | _corr_tt = cc->tt;
|
---|
[2035] | 300 | }
|
---|
[2317] | 301 | else if ( messageType == BTYPE_GPS ) {
|
---|
[2274] | 302 |
|
---|
| 303 | t_bias* bb = 0;
|
---|
| 304 | if (_bias.contains(prn)) {
|
---|
[2341] | 305 | bb = _bias.value(prn);
|
---|
[2274] | 306 | }
|
---|
| 307 | else {
|
---|
| 308 | bb = new t_bias();
|
---|
| 309 | _bias[prn] = bb;
|
---|
| 310 | }
|
---|
| 311 |
|
---|
| 312 | bb->tt.set(GPSweek, GPSweeks);
|
---|
| 313 |
|
---|
| 314 | int numBiases;
|
---|
| 315 | in >> numBiases;
|
---|
| 316 | for (int ii = 0; ii < numBiases; ++ii) {
|
---|
| 317 | int bType;
|
---|
| 318 | double bValue;
|
---|
| 319 | in >> bType >> bValue;
|
---|
[2426] | 320 | if (bType == CODETYPEGPS_L1_Z) {
|
---|
[2429] | 321 | bb->p1 = bValue;
|
---|
[2274] | 322 | }
|
---|
[2426] | 323 | else if (bType == CODETYPEGPS_L1_CA) {
|
---|
[2429] | 324 | bb->c1 = bValue;
|
---|
[2426] | 325 | }
|
---|
[2365] | 326 | else if (bType == CODETYPEGPS_L2_Z) {
|
---|
[2429] | 327 | bb->p2 = bValue;
|
---|
[2274] | 328 | }
|
---|
| 329 | }
|
---|
| 330 | }
|
---|
[2035] | 331 | }
|
---|
[2208] | 332 |
|
---|
| 333 | QMutableMapIterator<QString, t_corr*> im(_corr);
|
---|
| 334 | while (im.hasNext()) {
|
---|
| 335 | im.next();
|
---|
| 336 | t_corr* cc = im.value();
|
---|
| 337 | if (!cc->ready()) {
|
---|
| 338 | delete cc;
|
---|
| 339 | im.remove();
|
---|
| 340 | }
|
---|
| 341 | }
|
---|
[2035] | 342 | }
|
---|
| 343 |
|
---|
| 344 | // Satellite Position
|
---|
| 345 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2123] | 346 | t_irc bncPPPclient::getSatPos(const bncTime& tt, const QString& prn,
|
---|
[2357] | 347 | ColumnVector& xc, ColumnVector& vv) {
|
---|
[2035] | 348 |
|
---|
[2576] | 349 | const double MAXAGE = 120.0;
|
---|
[2041] | 350 |
|
---|
[2035] | 351 | if (_eph.contains(prn)) {
|
---|
[2040] | 352 |
|
---|
[2357] | 353 | if (_pppMode) {
|
---|
[2068] | 354 | if (_corr.contains(prn)) {
|
---|
| 355 | t_corr* cc = _corr.value(prn);
|
---|
[2576] | 356 | if (tt - cc->tt < MAXAGE) {
|
---|
| 357 | t_eph* eLast = _eph.value(prn)->last;
|
---|
| 358 | t_eph* ePrev = _eph.value(prn)->prev;
|
---|
| 359 | if (eLast && eLast->IOD() == cc->iod) {
|
---|
| 360 | eLast->position(tt.gpsw(), tt.gpssec(), xc.data(), vv.data());
|
---|
| 361 | applyCorr(tt, cc, xc, vv);
|
---|
| 362 | return success;
|
---|
| 363 | }
|
---|
| 364 | else if (ePrev && ePrev->IOD() == cc->iod) {
|
---|
| 365 | ePrev->position(tt.gpsw(), tt.gpssec(), xc.data(), vv.data());
|
---|
| 366 | applyCorr(tt, cc, xc, vv);
|
---|
| 367 | return success;
|
---|
| 368 | }
|
---|
| 369 | }
|
---|
[2041] | 370 | }
|
---|
[2040] | 371 | }
|
---|
[2576] | 372 |
|
---|
| 373 | else {
|
---|
| 374 | t_eph* ee = _eph.value(prn)->last;
|
---|
| 375 | ee->position(tt.gpsw(), tt.gpssec(), xc.data(), vv.data());
|
---|
| 376 | return success;
|
---|
| 377 | }
|
---|
[2035] | 378 | }
|
---|
| 379 |
|
---|
| 380 | return failure;
|
---|
| 381 | }
|
---|
| 382 |
|
---|
| 383 | //
|
---|
| 384 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2296] | 385 | void bncPPPclient::applyCorr(const bncTime& tt, const t_corr* cc,
|
---|
| 386 | ColumnVector& xc, ColumnVector& vv) {
|
---|
[2043] | 387 | ColumnVector dx(3);
|
---|
[2041] | 388 |
|
---|
[2367] | 389 | double dt = tt - cc->tt;
|
---|
| 390 | ColumnVector raoHlp = cc->rao + cc->dotRao * dt + cc->dotDotRao * dt * dt;
|
---|
[2296] | 391 |
|
---|
| 392 | RSW_to_XYZ(xc.Rows(1,3), vv, raoHlp, dx);
|
---|
| 393 |
|
---|
[2414] | 394 | xc[0] -= dx[0];
|
---|
| 395 | xc[1] -= dx[1];
|
---|
| 396 | xc[2] -= dx[2];
|
---|
[2417] | 397 | xc[3] += cc->dClk + cc->dotDClk * dt + cc->dotDotDClk * dt * dt;
|
---|
[2041] | 398 | }
|
---|
| 399 |
|
---|
[2049] | 400 | // Correct Time of Transmission
|
---|
| 401 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2240] | 402 | t_irc bncPPPclient::cmpToT(t_satData* satData) {
|
---|
[2049] | 403 |
|
---|
[2051] | 404 | double prange = satData->P3;
|
---|
[2049] | 405 | if (prange == 0.0) {
|
---|
| 406 | return failure;
|
---|
| 407 | }
|
---|
| 408 |
|
---|
| 409 | double clkSat = 0.0;
|
---|
| 410 | for (int ii = 1; ii <= 10; ii++) {
|
---|
| 411 |
|
---|
[2808] | 412 | bncTime ToT = satData->tt - prange / t_CST::c - clkSat;
|
---|
[2049] | 413 |
|
---|
| 414 | ColumnVector xc(4);
|
---|
| 415 | ColumnVector vv(3);
|
---|
[2357] | 416 | if (getSatPos(ToT, satData->prn, xc, vv) != success) {
|
---|
[2049] | 417 | return failure;
|
---|
| 418 | }
|
---|
| 419 |
|
---|
| 420 | double clkSatOld = clkSat;
|
---|
[2050] | 421 | clkSat = xc(4);
|
---|
[2049] | 422 |
|
---|
| 423 | if ( fabs(clkSat-clkSatOld) * t_CST::c < 1.e-4 ) {
|
---|
| 424 | satData->xx = xc.Rows(1,3);
|
---|
| 425 | satData->vv = vv;
|
---|
[2050] | 426 | satData->clk = clkSat * t_CST::c;
|
---|
[2049] | 427 | return success;
|
---|
| 428 | }
|
---|
| 429 | }
|
---|
| 430 |
|
---|
| 431 | return failure;
|
---|
| 432 | }
|
---|
| 433 |
|
---|
[2041] | 434 | //
|
---|
| 435 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2808] | 436 | void bncPPPclient::processFrontEpoch() {
|
---|
[2035] | 437 |
|
---|
[2053] | 438 | // Data Pre-Processing
|
---|
| 439 | // -------------------
|
---|
[2808] | 440 | QMutableMapIterator<QString, t_satData*> iGPS(_epoData.front()->satDataGPS);
|
---|
[2231] | 441 | while (iGPS.hasNext()) {
|
---|
| 442 | iGPS.next();
|
---|
| 443 | QString prn = iGPS.key();
|
---|
| 444 | t_satData* satData = iGPS.value();
|
---|
[2049] | 445 |
|
---|
[2240] | 446 | if (cmpToT(satData) != success) {
|
---|
[2049] | 447 | delete satData;
|
---|
[2231] | 448 | iGPS.remove();
|
---|
[2049] | 449 | continue;
|
---|
| 450 | }
|
---|
[2053] | 451 | }
|
---|
[2035] | 452 |
|
---|
[2808] | 453 | QMutableMapIterator<QString, t_satData*> iGlo(_epoData.front()->satDataGlo);
|
---|
[2231] | 454 | while (iGlo.hasNext()) {
|
---|
| 455 | iGlo.next();
|
---|
| 456 | QString prn = iGlo.key();
|
---|
| 457 | t_satData* satData = iGlo.value();
|
---|
| 458 |
|
---|
[2240] | 459 | if (cmpToT(satData) != success) {
|
---|
[2231] | 460 | delete satData;
|
---|
| 461 | iGlo.remove();
|
---|
| 462 | continue;
|
---|
| 463 | }
|
---|
| 464 | }
|
---|
| 465 |
|
---|
[2808] | 466 | QMutableMapIterator<QString, t_satData*> iGal(_epoData.front()->satDataGal);
|
---|
[2779] | 467 | while (iGal.hasNext()) {
|
---|
| 468 | iGal.next();
|
---|
| 469 | QString prn = iGal.key();
|
---|
| 470 | t_satData* satData = iGal.value();
|
---|
| 471 |
|
---|
| 472 | if (cmpToT(satData) != success) {
|
---|
| 473 | delete satData;
|
---|
| 474 | iGal.remove();
|
---|
| 475 | continue;
|
---|
| 476 | }
|
---|
| 477 | }
|
---|
| 478 |
|
---|
[2060] | 479 | // Filter Solution
|
---|
| 480 | // ---------------
|
---|
[2808] | 481 | if (_model->update(_epoData.front()) == success) {
|
---|
[2145] | 482 | emit newPosition(_model->time(), _model->x(), _model->y(), _model->z());
|
---|
[2060] | 483 | }
|
---|
[2035] | 484 | }
|
---|
[2808] | 485 |
|
---|
| 486 | //
|
---|
| 487 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 488 | void bncPPPclient::processEpochs() {
|
---|
[2809] | 489 |
|
---|
[2810] | 490 | // Synchronization threshold (not used in SPP mode)
|
---|
| 491 | // ------------------------------------------------
|
---|
[2812] | 492 | bncSettings settings;
|
---|
| 493 | double maxDt = settings.value("pppSync").toDouble();
|
---|
[2809] | 494 | if (!_pppMode) {
|
---|
| 495 | maxDt = 0.0;
|
---|
| 496 | }
|
---|
| 497 |
|
---|
[2810] | 498 | // Make sure the buffer does not grow beyond any limit
|
---|
| 499 | // ---------------------------------------------------
|
---|
| 500 | const unsigned MAX_EPODATA_SIZE = 120;
|
---|
| 501 | if (_epoData.size() > MAX_EPODATA_SIZE) {
|
---|
| 502 | delete _epoData.front();
|
---|
| 503 | _epoData.pop();
|
---|
| 504 | }
|
---|
| 505 |
|
---|
| 506 | // Loop over all unprocessed epochs
|
---|
| 507 | // --------------------------------
|
---|
[2809] | 508 | while (!_epoData.empty()) {
|
---|
[2810] | 509 |
|
---|
[2809] | 510 | t_epoData* frontEpoData = _epoData.front();
|
---|
| 511 |
|
---|
| 512 | // No corrections yet, skip the epoch
|
---|
| 513 | // ----------------------------------
|
---|
| 514 | if (maxDt != 0.0 && !_corr_tt.valid()) {
|
---|
[2810] | 515 | return;
|
---|
[2809] | 516 | }
|
---|
| 517 |
|
---|
[2810] | 518 | // Process the front epoch
|
---|
| 519 | // -----------------------
|
---|
| 520 | if (maxDt == 0 || frontEpoData->tt - _corr_tt < maxDt) {
|
---|
[2809] | 521 | processFrontEpoch();
|
---|
| 522 | delete _epoData.front();
|
---|
| 523 | _epoData.pop();
|
---|
| 524 | }
|
---|
| 525 | else {
|
---|
| 526 | return;
|
---|
| 527 | }
|
---|
| 528 | }
|
---|
[2808] | 529 | }
|
---|