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