[2898] | 1 | /* -------------------------------------------------------------------------
|
---|
| 2 | * BKG NTRIP Client
|
---|
| 3 | * -------------------------------------------------------------------------
|
---|
| 4 | *
|
---|
| 5 | * Class: bncComb
|
---|
| 6 | *
|
---|
| 7 | * Purpose: Combinations of Orbit/Clock Corrections
|
---|
| 8 | *
|
---|
| 9 | * Author: L. Mervart
|
---|
| 10 | *
|
---|
| 11 | * Created: 22-Jan-2011
|
---|
| 12 | *
|
---|
| 13 | * Changes:
|
---|
| 14 | *
|
---|
| 15 | * -----------------------------------------------------------------------*/
|
---|
| 16 |
|
---|
[2933] | 17 | #include <newmatio.h>
|
---|
[2921] | 18 | #include <iomanip>
|
---|
[2898] | 19 |
|
---|
| 20 | #include "bnccomb.h"
|
---|
| 21 | #include "bncapp.h"
|
---|
[2927] | 22 | #include "cmbcaster.h"
|
---|
[2910] | 23 | #include "bncsettings.h"
|
---|
[2933] | 24 | #include "bncmodel.h"
|
---|
[2988] | 25 | #include "bncutils.h"
|
---|
[3027] | 26 | #include "bncpppclient.h"
|
---|
[2898] | 27 |
|
---|
| 28 | using namespace std;
|
---|
| 29 |
|
---|
| 30 | // Constructor
|
---|
| 31 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3032] | 32 | cmbParam::cmbParam(cmbParam::parType type_, int index_,
|
---|
| 33 | const QString& ac_, const QString& prn_,
|
---|
| 34 | double sig_0_, double sig_P_) {
|
---|
| 35 |
|
---|
| 36 | type = type_;
|
---|
| 37 | index = index_;
|
---|
| 38 | AC = ac_;
|
---|
| 39 | prn = prn_;
|
---|
| 40 | sig_0 = sig_0_;
|
---|
| 41 | sig_P = sig_P_;
|
---|
[2933] | 42 | xx = 0.0;
|
---|
| 43 | }
|
---|
| 44 |
|
---|
| 45 | // Destructor
|
---|
| 46 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 47 | cmbParam::~cmbParam() {
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | // Partial
|
---|
| 51 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3032] | 52 | double cmbParam::partial(const QString& AC_, t_corr* corr) {
|
---|
[2933] | 53 |
|
---|
[2934] | 54 | if (type == AC_offset) {
|
---|
[3032] | 55 | if (AC == AC_) {
|
---|
[2934] | 56 | return 1.0;
|
---|
| 57 | }
|
---|
| 58 | }
|
---|
| 59 | else if (type == Sat_offset) {
|
---|
[3032] | 60 | if (AC == AC_ && prn == corr->prn) {
|
---|
[2933] | 61 | return 1.0;
|
---|
| 62 | }
|
---|
| 63 | }
|
---|
| 64 | else if (type == clk) {
|
---|
| 65 | if (prn == corr->prn) {
|
---|
| 66 | return 1.0;
|
---|
| 67 | }
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 | return 0.0;
|
---|
| 71 | }
|
---|
| 72 |
|
---|
[2990] | 73 | //
|
---|
| 74 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 75 | QString cmbParam::toString() const {
|
---|
[2933] | 76 |
|
---|
[2990] | 77 | QString outStr;
|
---|
| 78 |
|
---|
| 79 | if (type == AC_offset) {
|
---|
[2992] | 80 | outStr = "AC offset " + AC;
|
---|
[2990] | 81 | }
|
---|
| 82 | else if (type == Sat_offset) {
|
---|
[2992] | 83 | outStr = "Sat Offset " + AC + " " + prn;
|
---|
[2990] | 84 | }
|
---|
| 85 | else if (type == clk) {
|
---|
[2992] | 86 | outStr = "Clk Corr " + prn;
|
---|
[2990] | 87 | }
|
---|
[2933] | 88 |
|
---|
[2990] | 89 | return outStr;
|
---|
| 90 | }
|
---|
| 91 |
|
---|
[2933] | 92 | // Constructor
|
---|
| 93 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2898] | 94 | bncComb::bncComb() {
|
---|
[2910] | 95 |
|
---|
| 96 | bncSettings settings;
|
---|
| 97 |
|
---|
| 98 | QStringList combineStreams = settings.value("combineStreams").toStringList();
|
---|
[2918] | 99 |
|
---|
[3032] | 100 | _masterAC = "BKG"; // TODO: make it an option
|
---|
| 101 |
|
---|
[2918] | 102 | if (combineStreams.size() >= 2) {
|
---|
[2910] | 103 | QListIterator<QString> it(combineStreams);
|
---|
| 104 | while (it.hasNext()) {
|
---|
| 105 | QStringList hlp = it.next().split(" ");
|
---|
[2918] | 106 | cmbAC* newAC = new cmbAC();
|
---|
| 107 | newAC->mountPoint = hlp[0];
|
---|
| 108 | newAC->name = hlp[1];
|
---|
| 109 | newAC->weight = hlp[2].toDouble();
|
---|
| 110 |
|
---|
| 111 | _ACs[newAC->mountPoint] = newAC;
|
---|
[2910] | 112 | }
|
---|
| 113 | }
|
---|
[2927] | 114 |
|
---|
| 115 | _caster = new cmbCaster();
|
---|
[2990] | 116 | connect(this, SIGNAL(newMessage(QByteArray,bool)),
|
---|
| 117 | ((bncApp*)qApp), SLOT(slotMessage(const QByteArray,bool)));
|
---|
[2933] | 118 |
|
---|
[3032] | 119 |
|
---|
| 120 | // A Priori Sigmas (in Meters)
|
---|
| 121 | // ---------------------------
|
---|
| 122 | double sigAC_0 = 100.0;
|
---|
| 123 | double sigAC_P = 100.0;
|
---|
| 124 | double sigSat_0 = 100.0;
|
---|
| 125 | double sigSat_P = 0.0;
|
---|
| 126 | double sigClk_0 = 100.0;
|
---|
| 127 | double sigClk_P = 100.0;
|
---|
| 128 |
|
---|
| 129 | // Initialize Parameters (model: Clk_Corr = AC_Offset + Sat_Offset + Clk)
|
---|
| 130 | // ----------------------------------------------------------------------
|
---|
[2933] | 131 | int nextPar = 0;
|
---|
[2991] | 132 | QMapIterator<QString, cmbAC*> it(_ACs);
|
---|
| 133 | while (it.hasNext()) {
|
---|
| 134 | it.next();
|
---|
| 135 | cmbAC* AC = it.value();
|
---|
[3032] | 136 | if (AC->name != _masterAC) {
|
---|
| 137 | _params.push_back(new cmbParam(cmbParam::AC_offset, ++nextPar,
|
---|
| 138 | AC->name, "", sigAC_0, sigAC_P));
|
---|
| 139 | for (int iGps = 1; iGps <= 32; iGps++) {
|
---|
| 140 | QString prn = QString("G%1").arg(iGps, 2, 10, QChar('0'));
|
---|
| 141 | _params.push_back(new cmbParam(cmbParam::Sat_offset, ++nextPar,
|
---|
| 142 | AC->name, prn, sigSat_0, sigSat_P));
|
---|
| 143 | }
|
---|
[2991] | 144 | }
|
---|
| 145 | }
|
---|
[2933] | 146 | for (int iGps = 1; iGps <= 32; iGps++) {
|
---|
| 147 | QString prn = QString("G%1").arg(iGps, 2, 10, QChar('0'));
|
---|
[3032] | 148 | _params.push_back(new cmbParam(cmbParam::clk, ++nextPar, "", prn,
|
---|
| 149 | sigClk_0, sigClk_P));
|
---|
[2933] | 150 | }
|
---|
| 151 |
|
---|
[3032] | 152 | // Initialize Variance-Covariance Matrix
|
---|
| 153 | // -------------------------------------
|
---|
| 154 | _QQ.ReSize(_params.size());
|
---|
[2933] | 155 | _QQ = 0.0;
|
---|
| 156 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
| 157 | cmbParam* pp = _params[iPar-1];
|
---|
[3032] | 158 | _QQ(iPar,iPar) = pp->sig_0 * pp->sig_0;
|
---|
[2933] | 159 | }
|
---|
[2898] | 160 | }
|
---|
| 161 |
|
---|
| 162 | // Destructor
|
---|
| 163 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 164 | bncComb::~bncComb() {
|
---|
[2918] | 165 | QMapIterator<QString, cmbAC*> it(_ACs);
|
---|
| 166 | while (it.hasNext()) {
|
---|
| 167 | it.next();
|
---|
| 168 | delete it.value();
|
---|
| 169 | }
|
---|
[2927] | 170 | delete _caster;
|
---|
[2898] | 171 | }
|
---|
| 172 |
|
---|
[2928] | 173 | // Read and store one correction line
|
---|
[2898] | 174 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 175 | void bncComb::processCorrLine(const QString& staID, const QString& line) {
|
---|
[2906] | 176 | QMutexLocker locker(&_mutex);
|
---|
[2913] | 177 |
|
---|
[2918] | 178 | // Find the relevant instance of cmbAC class
|
---|
| 179 | // -----------------------------------------
|
---|
| 180 | if (_ACs.find(staID) == _ACs.end()) {
|
---|
| 181 | return;
|
---|
| 182 | }
|
---|
| 183 | cmbAC* AC = _ACs[staID];
|
---|
| 184 |
|
---|
| 185 | // Read the Correction
|
---|
| 186 | // -------------------
|
---|
[2913] | 187 | t_corr* newCorr = new t_corr();
|
---|
| 188 | if (!newCorr->readLine(line) == success) {
|
---|
| 189 | delete newCorr;
|
---|
| 190 | return;
|
---|
| 191 | }
|
---|
| 192 |
|
---|
[2924] | 193 | // Reject delayed corrections
|
---|
| 194 | // --------------------------
|
---|
| 195 | if (_processedBeforeTime.valid() && newCorr->tt < _processedBeforeTime) {
|
---|
| 196 | delete newCorr;
|
---|
| 197 | return;
|
---|
| 198 | }
|
---|
| 199 |
|
---|
[3029] | 200 | // Check the Ephemeris
|
---|
| 201 | //--------------------
|
---|
[2986] | 202 | if (_eph.find(newCorr->prn) == _eph.end()) {
|
---|
| 203 | delete newCorr;
|
---|
| 204 | return;
|
---|
| 205 | }
|
---|
| 206 | else {
|
---|
| 207 | t_eph* lastEph = _eph[newCorr->prn]->last;
|
---|
| 208 | t_eph* prevEph = _eph[newCorr->prn]->prev;
|
---|
[3029] | 209 | if (lastEph && lastEph->IOD() == newCorr->iod) {
|
---|
| 210 | newCorr->eph = lastEph;
|
---|
[2986] | 211 | }
|
---|
[3029] | 212 | else if (prevEph && prevEph->IOD() == newCorr->iod) {
|
---|
| 213 | newCorr->eph = prevEph;
|
---|
| 214 | }
|
---|
| 215 | else {
|
---|
[2986] | 216 | delete newCorr;
|
---|
| 217 | return;
|
---|
| 218 | }
|
---|
| 219 | }
|
---|
| 220 |
|
---|
[2924] | 221 | // Process all older Epochs (if there are any)
|
---|
| 222 | // -------------------------------------------
|
---|
| 223 | const double waitTime = 5.0; // wait 5 sec
|
---|
| 224 | _processedBeforeTime = newCorr->tt - waitTime;
|
---|
| 225 |
|
---|
[2927] | 226 | QList<cmbEpoch*> epochsToProcess;
|
---|
| 227 |
|
---|
| 228 | QMapIterator<QString, cmbAC*> itAC(_ACs);
|
---|
| 229 | while (itAC.hasNext()) {
|
---|
| 230 | itAC.next();
|
---|
| 231 | cmbAC* AC = itAC.value();
|
---|
| 232 |
|
---|
| 233 | QMutableListIterator<cmbEpoch*> itEpo(AC->epochs);
|
---|
| 234 | while (itEpo.hasNext()) {
|
---|
| 235 | cmbEpoch* epoch = itEpo.next();
|
---|
| 236 | if (epoch->time < _processedBeforeTime) {
|
---|
| 237 | epochsToProcess.append(epoch);
|
---|
| 238 | itEpo.remove();
|
---|
| 239 | }
|
---|
| 240 | }
|
---|
| 241 | }
|
---|
| 242 |
|
---|
| 243 | if (epochsToProcess.size()) {
|
---|
| 244 | processEpochs(epochsToProcess);
|
---|
| 245 | }
|
---|
| 246 |
|
---|
[2920] | 247 | // Check Modulo Time
|
---|
| 248 | // -----------------
|
---|
| 249 | const int moduloTime = 10;
|
---|
| 250 | if (int(newCorr->tt.gpssec()) % moduloTime != 0.0) {
|
---|
| 251 | delete newCorr;
|
---|
| 252 | return;
|
---|
| 253 | }
|
---|
| 254 |
|
---|
[2918] | 255 | // Find/Create the instance of cmbEpoch class
|
---|
| 256 | // ------------------------------------------
|
---|
| 257 | cmbEpoch* newEpoch = 0;
|
---|
| 258 | QListIterator<cmbEpoch*> it(AC->epochs);
|
---|
| 259 | while (it.hasNext()) {
|
---|
| 260 | cmbEpoch* hlpEpoch = it.next();
|
---|
| 261 | if (hlpEpoch->time == newCorr->tt) {
|
---|
| 262 | newEpoch = hlpEpoch;
|
---|
| 263 | break;
|
---|
| 264 | }
|
---|
| 265 | }
|
---|
| 266 | if (newEpoch == 0) {
|
---|
[2927] | 267 | newEpoch = new cmbEpoch(AC->name);
|
---|
[2918] | 268 | newEpoch->time = newCorr->tt;
|
---|
| 269 | AC->epochs.append(newEpoch);
|
---|
| 270 | }
|
---|
[2924] | 271 |
|
---|
| 272 | // Merge or add the correction
|
---|
| 273 | // ---------------------------
|
---|
[2918] | 274 | if (newEpoch->corr.find(newCorr->prn) != newEpoch->corr.end()) {
|
---|
[2919] | 275 | newEpoch->corr[newCorr->prn]->readLine(line); // merge (multiple messages)
|
---|
[2918] | 276 | }
|
---|
[2919] | 277 | else {
|
---|
| 278 | newEpoch->corr[newCorr->prn] = newCorr;
|
---|
| 279 | }
|
---|
[2898] | 280 | }
|
---|
| 281 |
|
---|
[2928] | 282 | // Send results to caster
|
---|
| 283 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 284 | void bncComb::dumpResults(const bncTime& resTime,
|
---|
| 285 | const QMap<QString, t_corr*>& resCorr) {
|
---|
| 286 |
|
---|
| 287 | _caster->open();
|
---|
| 288 |
|
---|
| 289 | unsigned year, month, day;
|
---|
| 290 | resTime.civil_date (year, month, day);
|
---|
| 291 | double GPSweeks = resTime.gpssec();
|
---|
| 292 |
|
---|
| 293 | struct ClockOrbit co;
|
---|
| 294 | memset(&co, 0, sizeof(co));
|
---|
| 295 | co.GPSEpochTime = (int)GPSweeks;
|
---|
| 296 | co.GLONASSEpochTime = (int)fmod(GPSweeks, 86400.0)
|
---|
| 297 | + 3 * 3600 - gnumleap(year, month, day);
|
---|
| 298 | co.ClockDataSupplied = 1;
|
---|
| 299 | co.OrbitDataSupplied = 1;
|
---|
| 300 | co.SatRefDatum = DATUM_ITRF;
|
---|
| 301 |
|
---|
| 302 | QMapIterator<QString, t_corr*> it(resCorr);
|
---|
| 303 | while (it.hasNext()) {
|
---|
| 304 | it.next();
|
---|
| 305 | t_corr* corr = it.value();
|
---|
| 306 |
|
---|
[2931] | 307 | struct ClockOrbit::SatData* sd = 0;
|
---|
[2928] | 308 | if (corr->prn[0] == 'G') {
|
---|
| 309 | sd = co.Sat + co.NumberOfGPSSat;
|
---|
| 310 | ++co.NumberOfGPSSat;
|
---|
| 311 | }
|
---|
| 312 | else if (corr->prn[0] == 'R') {
|
---|
| 313 | sd = co.Sat + CLOCKORBIT_NUMGPS + co.NumberOfGLONASSSat;
|
---|
| 314 | ++co.NumberOfGLONASSSat;
|
---|
| 315 | }
|
---|
| 316 |
|
---|
| 317 | if (sd != 0) {
|
---|
| 318 | sd->ID = corr->prn.mid(1).toInt();
|
---|
| 319 | sd->IOD = corr->iod;
|
---|
[2930] | 320 | sd->Clock.DeltaA0 = corr->dClk * t_CST::c;
|
---|
[2928] | 321 | sd->Orbit.DeltaRadial = corr->rao(1);
|
---|
| 322 | sd->Orbit.DeltaAlongTrack = corr->rao(2);
|
---|
| 323 | sd->Orbit.DeltaCrossTrack = corr->rao(3);
|
---|
| 324 | sd->Orbit.DotDeltaRadial = corr->dotRao(1);
|
---|
| 325 | sd->Orbit.DotDeltaAlongTrack = corr->dotRao(2);
|
---|
| 326 | sd->Orbit.DotDeltaCrossTrack = corr->dotRao(3);
|
---|
| 327 | }
|
---|
| 328 |
|
---|
| 329 | delete corr;
|
---|
| 330 | }
|
---|
| 331 |
|
---|
[3025] | 332 | // Send Corrections to Caster
|
---|
| 333 | // --------------------------
|
---|
[2928] | 334 | if ( _caster->usedSocket() &&
|
---|
| 335 | (co.NumberOfGPSSat > 0 || co.NumberOfGLONASSSat > 0) ) {
|
---|
| 336 | char obuffer[CLOCKORBIT_BUFFERSIZE];
|
---|
| 337 | int len = MakeClockOrbit(&co, COTYPE_AUTO, 0, obuffer, sizeof(obuffer));
|
---|
| 338 | if (len > 0) {
|
---|
| 339 | _caster->write(obuffer, len);
|
---|
| 340 | }
|
---|
| 341 | }
|
---|
[3024] | 342 |
|
---|
[3027] | 343 | // Optionall send new Corrections to PPP client
|
---|
| 344 | // --------------------------------------------
|
---|
| 345 | bncApp* app = (bncApp*) qApp;
|
---|
| 346 | if (app->_bncPPPclient) {
|
---|
| 347 | QStringList corrLines;
|
---|
| 348 | co.messageType = COTYPE_GPSCOMBINED;
|
---|
| 349 | QStringListIterator il(RTCM3coDecoder::corrsToASCIIlines(resTime.gpsw(),
|
---|
| 350 | resTime.gpssec(), co, 0));
|
---|
| 351 | while (il.hasNext()) {
|
---|
| 352 | QString line = il.next() + " " + _caster->mountpoint();
|
---|
| 353 | corrLines << line;
|
---|
| 354 | }
|
---|
[3024] | 355 |
|
---|
[3027] | 356 | app->_bncPPPclient->slotNewCorrections(corrLines);
|
---|
[3024] | 357 | }
|
---|
[2928] | 358 | }
|
---|
| 359 |
|
---|
[2986] | 360 | // Change the correction so that it refers to last received ephemeris
|
---|
| 361 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3029] | 362 | void bncComb::switchToLastEph(const t_eph* lastEph, t_corr* corr) {
|
---|
[3028] | 363 |
|
---|
[2987] | 364 | ColumnVector oldXC(4);
|
---|
| 365 | ColumnVector oldVV(3);
|
---|
[3029] | 366 | corr->eph->position(corr->tt.gpsw(), corr->tt.gpssec(),
|
---|
| 367 | oldXC.data(), oldVV.data());
|
---|
[2988] | 368 |
|
---|
[2987] | 369 | ColumnVector newXC(4);
|
---|
| 370 | ColumnVector newVV(3);
|
---|
[3029] | 371 | lastEph->position(corr->tt.gpsw(), corr->tt.gpssec(),
|
---|
[2987] | 372 | newXC.data(), newVV.data());
|
---|
[2988] | 373 |
|
---|
| 374 | ColumnVector dX = newXC.Rows(1,3) - oldXC.Rows(1,3);
|
---|
[2989] | 375 | ColumnVector dV = newVV - oldVV;
|
---|
| 376 | double dC = newXC(4) - oldXC(4);
|
---|
| 377 |
|
---|
[2988] | 378 | ColumnVector dRAO(3);
|
---|
| 379 | XYZ_to_RSW(newXC.Rows(1,3), newVV, dX, dRAO);
|
---|
[2989] | 380 |
|
---|
| 381 | ColumnVector dDotRAO(3);
|
---|
| 382 | XYZ_to_RSW(newXC.Rows(1,3), newVV, dV, dDotRAO);
|
---|
| 383 |
|
---|
[3029] | 384 | QString msg = "switch " + corr->prn
|
---|
| 385 | + QString(" %1 -> %2 %3").arg(corr->iod,3)
|
---|
[3013] | 386 | .arg(lastEph->IOD(),3).arg(dC*t_CST::c, 8, 'f', 4);
|
---|
| 387 |
|
---|
[3029] | 388 | emit newMessage(msg.toAscii(), false);
|
---|
[3028] | 389 |
|
---|
[3029] | 390 | corr->iod = lastEph->IOD();
|
---|
| 391 | corr->eph = lastEph;
|
---|
[3031] | 392 | corr->rao += dRAO;
|
---|
| 393 | corr->dotRao += dDotRAO;
|
---|
[3029] | 394 | corr->dClk -= dC;
|
---|
[2986] | 395 | }
|
---|
| 396 |
|
---|
[2928] | 397 | // Process Epochs
|
---|
| 398 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2927] | 399 | void bncComb::processEpochs(const QList<cmbEpoch*>& epochs) {
|
---|
[2918] | 400 |
|
---|
[2990] | 401 | _log.clear();
|
---|
| 402 |
|
---|
| 403 | QTextStream out(&_log, QIODevice::WriteOnly);
|
---|
| 404 |
|
---|
[2991] | 405 | out << "Combination:" << endl
|
---|
| 406 | << "------------------------------" << endl;
|
---|
[2990] | 407 |
|
---|
[2933] | 408 | // Predict Parameters Values, Add White Noise
|
---|
| 409 | // ------------------------------------------
|
---|
| 410 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
| 411 | cmbParam* pp = _params[iPar-1];
|
---|
[3032] | 412 | if (pp->sig_P != 0.0) {
|
---|
[2933] | 413 | pp->xx = 0.0;
|
---|
| 414 | for (int jj = 1; jj <= _params.size(); jj++) {
|
---|
| 415 | _QQ(iPar, jj) = 0.0;
|
---|
| 416 | }
|
---|
[3032] | 417 | _QQ(iPar,iPar) = pp->sig_P * pp->sig_P;
|
---|
[2933] | 418 | }
|
---|
| 419 | }
|
---|
| 420 |
|
---|
[2928] | 421 | bncTime resTime = epochs.first()->time;
|
---|
| 422 | QMap<QString, t_corr*> resCorr;
|
---|
| 423 |
|
---|
[2933] | 424 | int nPar = _params.size();
|
---|
| 425 | int nObs = 0;
|
---|
| 426 |
|
---|
| 427 | ColumnVector x0(nPar);
|
---|
| 428 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
| 429 | cmbParam* pp = _params[iPar-1];
|
---|
| 430 | x0(iPar) = pp->xx;
|
---|
| 431 | }
|
---|
| 432 |
|
---|
| 433 | // Count Observations
|
---|
| 434 | // ------------------
|
---|
[2927] | 435 | QListIterator<cmbEpoch*> itEpo(epochs);
|
---|
| 436 | while (itEpo.hasNext()) {
|
---|
| 437 | cmbEpoch* epo = itEpo.next();
|
---|
[3029] | 438 | QMutableMapIterator<QString, t_corr*> itCorr(epo->corr);
|
---|
[2927] | 439 | while (itCorr.hasNext()) {
|
---|
| 440 | itCorr.next();
|
---|
[3029] | 441 | t_corr* corr = itCorr.value();
|
---|
| 442 |
|
---|
[3032] | 443 | // Switch to last ephemeris
|
---|
| 444 | // ------------------------
|
---|
[3029] | 445 | t_eph* lastEph = _eph[corr->prn]->last;
|
---|
| 446 | if (lastEph == corr->eph) {
|
---|
| 447 | ++nObs;
|
---|
| 448 | }
|
---|
| 449 | else {
|
---|
| 450 | if (corr->eph == _eph[corr->prn]->prev) {
|
---|
| 451 | switchToLastEph(lastEph, corr);
|
---|
| 452 | ++nObs;
|
---|
| 453 | }
|
---|
| 454 | else {
|
---|
| 455 | itCorr.remove();
|
---|
| 456 | }
|
---|
| 457 | }
|
---|
[2933] | 458 | }
|
---|
| 459 | }
|
---|
[2928] | 460 |
|
---|
[2933] | 461 | if (nObs > 0) {
|
---|
| 462 | Matrix AA(nObs, nPar);
|
---|
| 463 | ColumnVector ll(nObs);
|
---|
| 464 | DiagonalMatrix PP(nObs); PP = 1.0;
|
---|
| 465 |
|
---|
| 466 | int iObs = 0;
|
---|
| 467 | QListIterator<cmbEpoch*> itEpo(epochs);
|
---|
| 468 | while (itEpo.hasNext()) {
|
---|
| 469 | cmbEpoch* epo = itEpo.next();
|
---|
| 470 | QMapIterator<QString, t_corr*> itCorr(epo->corr);
|
---|
| 471 |
|
---|
| 472 | while (itCorr.hasNext()) {
|
---|
| 473 | itCorr.next();
|
---|
| 474 | ++iObs;
|
---|
| 475 | t_corr* corr = itCorr.value();
|
---|
| 476 |
|
---|
[3032] | 477 | if (epo->acName == _masterAC) {
|
---|
[2933] | 478 | resCorr[corr->prn] = new t_corr(*corr);
|
---|
| 479 | }
|
---|
| 480 |
|
---|
| 481 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
| 482 | cmbParam* pp = _params[iPar-1];
|
---|
| 483 | AA(iObs, iPar) = pp->partial(epo->acName, corr);
|
---|
| 484 | }
|
---|
| 485 |
|
---|
| 486 | ll(iObs) = corr->dClk * t_CST::c - DotProduct(AA.Row(iObs), x0);
|
---|
[3034] | 487 | }
|
---|
[2990] | 488 |
|
---|
[3034] | 489 | delete epo;
|
---|
[2933] | 490 | }
|
---|
[2928] | 491 |
|
---|
[2933] | 492 | ColumnVector dx;
|
---|
| 493 | bncModel::kalman(AA, ll, PP, _QQ, dx);
|
---|
| 494 | ColumnVector vv = ll - AA * dx;
|
---|
| 495 |
|
---|
| 496 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
| 497 | cmbParam* pp = _params[iPar-1];
|
---|
| 498 | pp->xx += dx(iPar);
|
---|
[2935] | 499 | if (pp->type == cmbParam::clk) {
|
---|
[2936] | 500 | if (resCorr.find(pp->prn) != resCorr.end()) {
|
---|
| 501 | resCorr[pp->prn]->dClk = pp->xx / t_CST::c;
|
---|
| 502 | }
|
---|
[2935] | 503 | }
|
---|
[3011] | 504 | out << currentDateAndTimeGPS().toString("yy-MM-dd hh:mm:ss ").toAscii().data();
|
---|
[2990] | 505 | out.setRealNumberNotation(QTextStream::FixedNotation);
|
---|
| 506 | out.setFieldWidth(8);
|
---|
| 507 | out.setRealNumberPrecision(4);
|
---|
| 508 | out << pp->toString() << " "
|
---|
[2991] | 509 | << pp->xx << " +- " << sqrt(_QQ(pp->index,pp->index)) << endl;
|
---|
[2918] | 510 | }
|
---|
| 511 | }
|
---|
[2919] | 512 |
|
---|
[3015] | 513 | printResults(out, resTime, resCorr);
|
---|
[2928] | 514 | dumpResults(resTime, resCorr);
|
---|
| 515 |
|
---|
[2990] | 516 | emit newMessage(_log, false);
|
---|
[2918] | 517 | }
|
---|
[3011] | 518 |
|
---|
| 519 | // Print results to caster
|
---|
| 520 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3015] | 521 | void bncComb::printResults(QTextStream& out, const bncTime& resTime,
|
---|
[3011] | 522 | const QMap<QString, t_corr*>& resCorr) {
|
---|
| 523 |
|
---|
| 524 | QMapIterator<QString, t_corr*> it(resCorr);
|
---|
| 525 | while (it.hasNext()) {
|
---|
| 526 | it.next();
|
---|
| 527 | t_corr* corr = it.value();
|
---|
[3029] | 528 | const t_eph* eph = corr->eph;
|
---|
[3015] | 529 | if (eph) {
|
---|
| 530 | double xx, yy, zz, cc;
|
---|
| 531 | eph->position(resTime.gpsw(), resTime.gpssec(), xx, yy, zz, cc);
|
---|
| 532 |
|
---|
| 533 | out << currentDateAndTimeGPS().toString("yy-MM-dd hh:mm:ss ").toAscii().data();
|
---|
| 534 | out.setFieldWidth(3);
|
---|
| 535 | out << "Full Clock " << corr->prn << " " << corr->iod << " ";
|
---|
| 536 | out.setFieldWidth(14);
|
---|
| 537 | out << (cc + corr->dClk) * t_CST::c << endl;
|
---|
| 538 | }
|
---|
| 539 | else {
|
---|
| 540 | out << "bncComb::printResuls bug" << endl;
|
---|
| 541 | }
|
---|
[3011] | 542 | }
|
---|
| 543 | }
|
---|