source: ntrip/branches/BNC_2.12/src/combination/bnccomb.cpp@ 9269

Last change on this file since 9269 was 9269, checked in by stuerze, 3 years ago

minor changes to prevent erroneous epehemeris data sets from usage in combination

File size: 35.9 KB
RevLine 
[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 *
[7297]13 * Changes:
[2898]14 *
15 * -----------------------------------------------------------------------*/
16
[2933]17#include <newmatio.h>
[2921]18#include <iomanip>
[3214]19#include <sstream>
[2898]20
21#include "bnccomb.h"
[5070]22#include "bnccore.h"
[3201]23#include "upload/bncrtnetdecoder.h"
[2910]24#include "bncsettings.h"
[2988]25#include "bncutils.h"
[3181]26#include "bncsp3.h"
[3052]27#include "bncantex.h"
[5742]28#include "t_prn.h"
[2898]29
[3455]30const double sig0_offAC = 1000.0;
31const double sig0_offACSat = 100.0;
[3468]32const double sigP_offACSat = 0.01;
[3455]33const double sig0_clkSat = 100.0;
34
35const double sigObs = 0.05;
36
37using namespace std;
38
[2898]39// Constructor
40////////////////////////////////////////////////////////////////////////////
[6155]41bncComb::cmbParam::cmbParam(parType type_, int index_, const QString& ac_, const QString& prn_) {
[3032]42
[3433]43 type = type_;
44 index = index_;
45 AC = ac_;
46 prn = prn_;
47 xx = 0.0;
[3455]48 eph = 0;
[3429]49
[3485]50 if (type == offACgps) {
[3455]51 epoSpec = true;
52 sig0 = sig0_offAC;
53 sigP = sig0;
[3429]54 }
[3485]55 else if (type == offACglo) {
56 epoSpec = true;
57 sig0 = sig0_offAC;
58 sigP = sig0;
59 }
[3429]60 else if (type == offACSat) {
[3455]61 epoSpec = false;
62 sig0 = sig0_offACSat;
63 sigP = sigP_offACSat;
[3429]64 }
65 else if (type == clkSat) {
[3455]66 epoSpec = true;
67 sig0 = sig0_clkSat;
68 sigP = sig0;
[3429]69 }
[2933]70}
71
72// Destructor
73////////////////////////////////////////////////////////////////////////////
[6155]74bncComb::cmbParam::~cmbParam() {
[2933]75}
76
77// Partial
78////////////////////////////////////////////////////////////////////////////
[6155]79double bncComb::cmbParam::partial(const QString& AC_, const QString& prn_) {
[7297]80
[3485]81 if (type == offACgps) {
82 if (AC == AC_ && prn_[0] == 'G') {
[2934]83 return 1.0;
84 }
85 }
[3485]86 else if (type == offACglo) {
87 if (AC == AC_ && prn_[0] == 'R') {
88 return 1.0;
89 }
90 }
[3429]91 else if (type == offACSat) {
92 if (AC == AC_ && prn == prn_) {
[2933]93 return 1.0;
94 }
95 }
[3429]96 else if (type == clkSat) {
97 if (prn == prn_) {
[2933]98 return 1.0;
99 }
100 }
101
102 return 0.0;
103}
104
[7297]105//
[2990]106////////////////////////////////////////////////////////////////////////////
[6155]107QString bncComb::cmbParam::toString() const {
[2933]108
[2990]109 QString outStr;
[7297]110
[3485]111 if (type == offACgps) {
112 outStr = "AC offset GPS " + AC;
[2990]113 }
[3485]114 else if (type == offACglo) {
115 outStr = "AC offset GLO " + AC;
116 }
[3429]117 else if (type == offACSat) {
[7008]118 outStr = "Sat Offset " + AC + " " + prn.mid(0,3);
[2990]119 }
[3429]120 else if (type == clkSat) {
[7008]121 outStr = "Clk Corr " + prn.mid(0,3);
[2990]122 }
[2933]123
[2990]124 return outStr;
125}
126
[7299]127// Singleton
128////////////////////////////////////////////////////////////////////////////
129bncComb* bncComb::instance() {
130 static bncComb _bncComb;
131 return &_bncComb;
132}
133
[2933]134// Constructor
135////////////////////////////////////////////////////////////////////////////
[6443]136bncComb::bncComb() : _ephUser(true) {
[2910]137
138 bncSettings settings;
139
[7297]140 QStringList cmbStreams = settings.value("cmbStreams").toStringList();
[2918]141
[4183]142 _cmbSampl = settings.value("cmbSampl").toInt();
143 if (_cmbSampl <= 0) {
144 _cmbSampl = 10;
145 }
146
[3455]147 _masterMissingEpochs = 0;
148
[7297]149 if (cmbStreams.size() >= 1 && !cmbStreams[0].isEmpty()) {
150 QListIterator<QString> it(cmbStreams);
[2910]151 while (it.hasNext()) {
152 QStringList hlp = it.next().split(" ");
[2918]153 cmbAC* newAC = new cmbAC();
154 newAC->mountPoint = hlp[0];
155 newAC->name = hlp[1];
156 newAC->weight = hlp[2].toDouble();
[3453]157 if (_masterOrbitAC.isEmpty()) {
158 _masterOrbitAC = newAC->name;
159 }
[3429]160 _ACs.append(newAC);
[2910]161 }
162 }
[2927]163
[9036]164 QString ssrFormat;
[9267]165 _ssrCorr = 0;
[9036]166 QListIterator<QString> it(settings.value("uploadMountpointsOut").toStringList());
167 while (it.hasNext()) {
168 QStringList hlp = it.next().split(",");
[9080]169 if (hlp.size() > 5) {
170 ssrFormat = hlp[5];
[9036]171 }
172 }
173 if (ssrFormat == "IGS-SSR") {
174 _ssrCorr = new SsrCorrIgs();
175 }
176 else if (ssrFormat == "RTCM-SSR") {
177 _ssrCorr = new SsrCorrRtcm();
178 }
[9267]179 else { // default
180 _ssrCorr = new SsrCorrIgs();
181 }
182
[3211]183 _rtnetDecoder = 0;
[3201]184
[7297]185 connect(this, SIGNAL(newMessage(QByteArray,bool)),
[5068]186 BNC_CORE, SLOT(slotMessage(const QByteArray,bool)));
[2933]187
[5583]188 connect(BNC_CORE, SIGNAL(providerIDChanged(QString)),
[6155]189 this, SLOT(slotProviderIDChanged(QString)));
[5583]190
[6155]191 connect(BNC_CORE, SIGNAL(newOrbCorrections(QList<t_orbCorr>)),
192 this, SLOT(slotNewOrbCorrections(QList<t_orbCorr>)));
193
194 connect(BNC_CORE, SIGNAL(newClkCorrections(QList<t_clkCorr>)),
195 this, SLOT(slotNewClkCorrections(QList<t_clkCorr>)));
196
[3470]197 // Combination Method
198 // ------------------
[3481]199 if (settings.value("cmbMethod").toString() == "Single-Epoch") {
200 _method = singleEpoch;
[3470]201 }
202 else {
[3481]203 _method = filter;
[3470]204 }
[3032]205
[3484]206 // Use Glonass
207 // -----------
[6174]208 if ( Qt::CheckState(settings.value("cmbUseGlonass").toInt()) == Qt::Checked) {
[3484]209 _useGlonass = true;
210 }
211 else {
212 _useGlonass = false;
213 }
214
[3032]215 // Initialize Parameters (model: Clk_Corr = AC_Offset + Sat_Offset + Clk)
216 // ----------------------------------------------------------------------
[3470]217 if (_method == filter) {
218 int nextPar = 0;
219 QListIterator<cmbAC*> it(_ACs);
220 while (it.hasNext()) {
221 cmbAC* AC = it.next();
[3485]222 _params.push_back(new cmbParam(cmbParam::offACgps, ++nextPar, AC->name, ""));
[5808]223 for (unsigned iGps = 1; iGps <= t_prn::MAXPRN_GPS; iGps++) {
[7008]224 QString prn = QString("G%1_0").arg(iGps, 2, 10, QChar('0'));
[7297]225 _params.push_back(new cmbParam(cmbParam::offACSat, ++nextPar,
[3470]226 AC->name, prn));
227 }
[3483]228 if (_useGlonass) {
[3485]229 _params.push_back(new cmbParam(cmbParam::offACglo, ++nextPar, AC->name, ""));
[5808]230 for (unsigned iGlo = 1; iGlo <= t_prn::MAXPRN_GLONASS; iGlo++) {
[7008]231 QString prn = QString("R%1_0").arg(iGlo, 2, 10, QChar('0'));
[7297]232 _params.push_back(new cmbParam(cmbParam::offACSat, ++nextPar,
[3483]233 AC->name, prn));
234 }
235 }
[3470]236 }
[5808]237 for (unsigned iGps = 1; iGps <= t_prn::MAXPRN_GPS; iGps++) {
[7008]238 QString prn = QString("G%1_0").arg(iGps, 2, 10, QChar('0'));
[3470]239 _params.push_back(new cmbParam(cmbParam::clkSat, ++nextPar, "", prn));
[2991]240 }
[3483]241 if (_useGlonass) {
[5808]242 for (unsigned iGlo = 1; iGlo <= t_prn::MAXPRN_GLONASS; iGlo++) {
[7008]243 QString prn = QString("R%1_0").arg(iGlo, 2, 10, QChar('0'));
[3483]244 _params.push_back(new cmbParam(cmbParam::clkSat, ++nextPar, "", prn));
245 }
246 }
[7297]247
[3470]248 // Initialize Variance-Covariance Matrix
249 // -------------------------------------
250 _QQ.ReSize(_params.size());
251 _QQ = 0.0;
252 for (int iPar = 1; iPar <= _params.size(); iPar++) {
253 cmbParam* pp = _params[iPar-1];
254 _QQ(iPar,iPar) = pp->sig0 * pp->sig0;
255 }
[2991]256 }
[2933]257
[3052]258 // ANTEX File
259 // ----------
260 _antex = 0;
[6667]261 QString antexFileName = settings.value("uploadAntexFile").toString();
[3052]262 if (!antexFileName.isEmpty()) {
263 _antex = new bncAntex();
264 if (_antex->readFile(antexFileName) != success) {
265 emit newMessage("wrong ANTEX file", true);
266 delete _antex;
267 _antex = 0;
268 }
269 }
[3138]270
[3329]271 // Maximal Residuum
272 // ----------------
273 _MAXRES = settings.value("cmbMaxres").toDouble();
274 if (_MAXRES <= 0.0) {
275 _MAXRES = 999.0;
276 }
[2898]277}
278
279// Destructor
280////////////////////////////////////////////////////////////////////////////
281bncComb::~bncComb() {
[3429]282 QListIterator<cmbAC*> icAC(_ACs);
283 while (icAC.hasNext()) {
284 delete icAC.next();
[2918]285 }
[3201]286 delete _rtnetDecoder;
[9036]287 if (_ssrCorr) {
288 delete _ssrCorr;
289 }
[3052]290 delete _antex;
[3296]291 for (int iPar = 1; iPar <= _params.size(); iPar++) {
292 delete _params[iPar-1];
293 }
[3556]294 QListIterator<bncTime> itTime(_buffer.keys());
[3551]295 while (itTime.hasNext()) {
[3556]296 bncTime epoTime = itTime.next();
297 _buffer.remove(epoTime);
[3429]298 }
[2898]299}
300
[6155]301// Remember orbit corrections
[2898]302////////////////////////////////////////////////////////////////////////////
[6155]303void bncComb::slotNewOrbCorrections(QList<t_orbCorr> orbCorrections) {
[2906]304 QMutexLocker locker(&_mutex);
[2913]305
[6155]306 for (int ii = 0; ii < orbCorrections.size(); ii++) {
307 t_orbCorr& orbCorr = orbCorrections[ii];
308 QString staID(orbCorr._staID.c_str());
[7008]309 QString prn(orbCorr._prn.toInternalString().c_str());
[6155]310
311 // Find/Check the AC Name
312 // ----------------------
313 QString acName;
314 QListIterator<cmbAC*> icAC(_ACs);
315 while (icAC.hasNext()) {
316 cmbAC* AC = icAC.next();
317 if (AC->mountPoint == staID) {
318 acName = AC->name;
319 break;
320 }
[3431]321 }
[6155]322 if (acName.isEmpty()) {
323 continue;
324 }
[3431]325
[6155]326 // Store the correction
327 // --------------------
328 QMap<t_prn, t_orbCorr>& storage = _orbCorrections[acName];
329 storage[orbCorr._prn] = orbCorr;
[2913]330 }
[6155]331}
[2913]332
[6155]333// Process clock corrections
334////////////////////////////////////////////////////////////////////////////
335void bncComb::slotNewClkCorrections(QList<t_clkCorr> clkCorrections) {
336 QMutexLocker locker(&_mutex);
337
338 bncTime lastTime;
339
340 for (int ii = 0; ii < clkCorrections.size(); ii++) {
341 t_clkCorr& clkCorr = clkCorrections[ii];
342 QString staID(clkCorr._staID.c_str());
[6961]343 QString prn(clkCorr._prn.toInternalString().c_str());
[6155]344
345 // Set the last time
346 // -----------------
347 if (lastTime.undef() || clkCorr._time > lastTime) {
348 lastTime = clkCorr._time;
[3483]349 }
350
[6155]351 // Find/Check the AC Name
352 // ----------------------
353 QString acName;
354 QListIterator<cmbAC*> icAC(_ACs);
355 while (icAC.hasNext()) {
356 cmbAC* AC = icAC.next();
357 if (AC->mountPoint == staID) {
358 acName = AC->name;
359 break;
360 }
[3588]361 }
[6155]362 if (acName.isEmpty()) {
363 continue;
364 }
[3588]365
[6155]366 // Check GLONASS
367 // -------------
368 if (!_useGlonass && clkCorr._prn.system() == 'R') {
369 continue;
[3590]370 }
371
[8176]372 if (
373 clkCorr._prn.system() == 'E' ||
374 clkCorr._prn.system() == 'C' ||
375 clkCorr._prn.system() == 'J' ||
376 clkCorr._prn.system() == 'I' ||
377 clkCorr._prn.system() == 'S' ) {
378 continue;
379 }
[8484]380
[6155]381 // Check Modulo Time
382 // -----------------
[8448]383 int sec = int(nint(clkCorr._time.gpssec()*10));
384 if (sec % (_cmbSampl*10) != 0.0) {
[6155]385 continue;
386 }
[3274]387
[6155]388 // Check Correction Age
389 // --------------------
390 if (_resTime.valid() && clkCorr._time <= _resTime) {
[7008]391 emit newMessage("bncComb: old correction: " + acName.toAscii() + " " + prn.mid(0,3).toAscii(), true);
[6155]392 continue;
393 }
[7297]394
[6155]395 // Create new correction
396 // ---------------------
397 cmbCorr* newCorr = new cmbCorr();
[6157]398 newCorr->_prn = prn;
[6155]399 newCorr->_time = clkCorr._time;
400 newCorr->_iod = clkCorr._iod;
401 newCorr->_acName = acName;
[6159]402 newCorr->_clkCorr = clkCorr;
[6155]403
[6156]404 // Check orbit correction
405 // ----------------------
406 if (!_orbCorrections.contains(acName)) {
407 delete newCorr;
408 continue;
409 }
410 else {
411 QMap<t_prn, t_orbCorr>& storage = _orbCorrections[acName];
[9267]412 if (!storage.contains(clkCorr._prn) ||
413 storage[clkCorr._prn]._iod != newCorr->_iod) {
[6156]414 delete newCorr;
415 continue;
416 }
417 else {
[6159]418 newCorr->_orbCorr = storage[clkCorr._prn];
[6156]419 }
420 }
421
[6155]422 // Check the Ephemeris
423 //--------------------
[7012]424 t_eph* ephLast = _ephUser.ephLast(prn);
425 t_eph* ephPrev = _ephUser.ephPrev(prn);
[6443]426 if (ephLast == 0) {
[8696]427 emit newMessage("bncComb: eph not found for " + prn.mid(0,3).toAscii(), true);
[6155]428 delete newCorr;
429 continue;
[2986]430 }
[9269]431 else if (ephLast->checkState() == t_eph::bad ||
432 ephLast->checkState() == t_eph::outdated ||
433 ephLast->checkState() == t_eph::unhealthy) {
[9267]434 emit newMessage("bncComb: eph not ok for " + prn.mid(0,3).toLatin1(), true);
435 delete newCorr;
436 continue;
437 }
[3029]438 else {
[6443]439 if (ephLast->IOD() == newCorr->_iod) {
440 newCorr->_eph = ephLast;
[6155]441 }
[9269]442 else if (ephPrev && ephPrev->checkState() == t_eph::ok &&
443 ephPrev->IOD() == newCorr->_iod) {
[6443]444 newCorr->_eph = ephPrev;
445 switchToLastEph(ephLast, newCorr);
[6155]446 }
447 else {
[8696]448 emit newMessage("bncComb: eph not found for " + prn.mid(0,3).toAscii() +
449 QString(" with IOD %1").arg(newCorr->_iod).toAscii(), true);
[6155]450 delete newCorr;
451 continue;
452 }
[2986]453 }
[6155]454
455 // Store correction into the buffer
456 // --------------------------------
457 QVector<cmbCorr*>& corrs = _buffer[newCorr->_time].corrs;
458 corrs.push_back(newCorr);
[2986]459 }
460
[3435]461 // Process previous Epoch(s)
462 // -------------------------
[7392]463 const double outWait = 1.0 * _cmbSampl;
[3556]464 QListIterator<bncTime> itTime(_buffer.keys());
[3435]465 while (itTime.hasNext()) {
[3556]466 bncTime epoTime = itTime.next();
[7392]467 if (epoTime < lastTime - outWait) {
[3556]468 _resTime = epoTime;
[3435]469 processEpoch();
470 }
[2927]471 }
[2898]472}
473
[7297]474// Change the correction so that it refers to last received ephemeris
[2986]475////////////////////////////////////////////////////////////////////////////
[7012]476void bncComb::switchToLastEph(t_eph* lastEph, cmbCorr* corr) {
[3028]477
[6155]478 if (corr->_eph == lastEph) {
[3429]479 return;
480 }
481
[8541]482 ColumnVector oldXC(6);
[2987]483 ColumnVector oldVV(3);
[9267]484 if (corr->_eph->getCrd(corr->_time, oldXC, oldVV, false) != success) {
485 return;
486 }
[2988]487
[8541]488 ColumnVector newXC(6);
[2987]489 ColumnVector newVV(3);
[9267]490 if (lastEph->getCrd(corr->_time, newXC, newVV, false) != success) {
491 return;
492 }
[2988]493
494 ColumnVector dX = newXC.Rows(1,3) - oldXC.Rows(1,3);
[2989]495 ColumnVector dV = newVV - oldVV;
496 double dC = newXC(4) - oldXC(4);
497
[2988]498 ColumnVector dRAO(3);
499 XYZ_to_RSW(newXC.Rows(1,3), newVV, dX, dRAO);
[2989]500
501 ColumnVector dDotRAO(3);
502 XYZ_to_RSW(newXC.Rows(1,3), newVV, dV, dDotRAO);
503
[6963]504 QString msg = "switch corr " + corr->_prn.mid(0,3)
[6155]505 + QString(" %1 -> %2 %3").arg(corr->_iod,3).arg(lastEph->IOD(),3).arg(dC*t_CST::c, 8, 'f', 4);
[3013]506
[3029]507 emit newMessage(msg.toAscii(), false);
[3028]508
[6155]509 corr->_iod = lastEph->IOD();
510 corr->_eph = lastEph;
511
[6159]512 corr->_orbCorr._xr += dRAO;
513 corr->_orbCorr._dotXr += dDotRAO;
514 corr->_clkCorr._dClk -= dC;
[2986]515}
516
[3429]517// Process Epoch
[2928]518////////////////////////////////////////////////////////////////////////////
[3429]519void bncComb::processEpoch() {
[2918]520
[2990]521 _log.clear();
522
523 QTextStream out(&_log, QIODevice::WriteOnly);
524
[7297]525 out << endl << "Combination:" << endl
[3472]526 << "------------------------------" << endl;
[2990]527
[3433]528 // Observation Statistics
529 // ----------------------
[3455]530 bool masterPresent = false;
[3433]531 QListIterator<cmbAC*> icAC(_ACs);
532 while (icAC.hasNext()) {
533 cmbAC* AC = icAC.next();
534 AC->numObs = 0;
[3434]535 QVectorIterator<cmbCorr*> itCorr(corrs());
[3433]536 while (itCorr.hasNext()) {
537 cmbCorr* corr = itCorr.next();
[6157]538 if (corr->_acName == AC->name) {
[3433]539 AC->numObs += 1;
[3453]540 if (AC->name == _masterOrbitAC) {
541 masterPresent = true;
542 }
[3433]543 }
544 }
545 out << AC->name.toAscii().data() << ": " << AC->numObs << endl;
546 }
547
[3453]548 // If Master not present, switch to another one
549 // --------------------------------------------
[4889]550 const unsigned switchMasterAfterGap = 1;
[3456]551 if (masterPresent) {
552 _masterMissingEpochs = 0;
553 }
554 else {
[3455]555 ++_masterMissingEpochs;
[4889]556 if (_masterMissingEpochs < switchMasterAfterGap) {
[3457]557 out << "Missing Master, Epoch skipped" << endl;
[3556]558 _buffer.remove(_resTime);
[3455]559 emit newMessage(_log, false);
560 return;
[3453]561 }
[3455]562 else {
563 _masterMissingEpochs = 0;
564 QListIterator<cmbAC*> icAC(_ACs);
565 while (icAC.hasNext()) {
566 cmbAC* AC = icAC.next();
567 if (AC->numObs > 0) {
568 out << "Switching Master AC "
[7297]569 << _masterOrbitAC.toAscii().data() << " --> "
570 << AC->name.toAscii().data() << " "
571 << _resTime.datestr().c_str() << " "
[3455]572 << _resTime.timestr().c_str() << endl;
573 _masterOrbitAC = AC->name;
574 break;
575 }
[3452]576 }
577 }
578 }
579
[6157]580 QMap<QString, cmbCorr*> resCorr;
[3472]581
582 // Perform the actual Combination using selected Method
583 // ----------------------------------------------------
584 t_irc irc;
[3475]585 ColumnVector dx;
[3472]586 if (_method == filter) {
[3475]587 irc = processEpoch_filter(out, resCorr, dx);
[3472]588 }
589 else {
[3475]590 irc = processEpoch_singleEpoch(out, resCorr, dx);
[3472]591 }
592
[3475]593 // Update Parameter Values, Print Results
594 // --------------------------------------
[3472]595 if (irc == success) {
[3475]596 for (int iPar = 1; iPar <= _params.size(); iPar++) {
597 cmbParam* pp = _params[iPar-1];
598 pp->xx += dx(iPar);
599 if (pp->type == cmbParam::clkSat) {
600 if (resCorr.find(pp->prn) != resCorr.end()) {
[6160]601 resCorr[pp->prn]->_dClkResult = pp->xx / t_CST::c;
[3475]602 }
603 }
[7297]604 out << _resTime.datestr().c_str() << " "
[3475]605 << _resTime.timestr().c_str() << " ";
606 out.setRealNumberNotation(QTextStream::FixedNotation);
607 out.setFieldWidth(8);
608 out.setRealNumberPrecision(4);
609 out << pp->toString() << " "
610 << pp->xx << " +- " << sqrt(_QQ(pp->index,pp->index)) << endl;
611 out.setFieldWidth(0);
612 }
[3472]613 printResults(out, resCorr);
614 dumpResults(resCorr);
615 }
616
617 // Delete Data, emit Message
618 // -------------------------
[3556]619 _buffer.remove(_resTime);
[3472]620 emit newMessage(_log, false);
621}
622
623// Process Epoch - Filter Method
624////////////////////////////////////////////////////////////////////////////
625t_irc bncComb::processEpoch_filter(QTextStream& out,
[6157]626 QMap<QString, cmbCorr*>& resCorr,
[3475]627 ColumnVector& dx) {
[3472]628
[3429]629 // Prediction Step
630 // ---------------
[3472]631 int nPar = _params.size();
[2933]632 ColumnVector x0(nPar);
633 for (int iPar = 1; iPar <= _params.size(); iPar++) {
[3455]634 cmbParam* pp = _params[iPar-1];
635 if (pp->epoSpec) {
[3451]636 pp->xx = 0.0;
[3455]637 _QQ.Row(iPar) = 0.0;
638 _QQ.Column(iPar) = 0.0;
639 _QQ(iPar,iPar) = pp->sig0 * pp->sig0;
[3451]640 }
[3455]641 else {
642 _QQ(iPar,iPar) += pp->sigP * pp->sigP;
643 }
[2933]644 x0(iPar) = pp->xx;
645 }
646
[3487]647 // Check Satellite Positions for Outliers
648 // --------------------------------------
[3497]649 if (checkOrbits(out) != success) {
[3487]650 return failure;
651 }
[3441]652
[3455]653 // Update and outlier detection loop
654 // ---------------------------------
[3487]655 SymmetricMatrix QQ_sav = _QQ;
[3455]656 while (true) {
[3135]657
[3455]658 Matrix AA;
659 ColumnVector ll;
660 DiagonalMatrix PP;
[3429]661
[3455]662 if (createAmat(AA, ll, PP, x0, resCorr) != success) {
[3472]663 return failure;
[3441]664 }
[2933]665
[6169]666 dx.ReSize(nPar); dx = 0.0;
[5808]667 kalman(AA, ll, PP, _QQ, dx);
[6164]668
[3429]669 ColumnVector vv = ll - AA * dx;
[3080]670
[3429]671 int maxResIndex;
[7297]672 double maxRes = vv.maximum_absolute_value1(maxResIndex);
[3429]673 out.setRealNumberNotation(QTextStream::FixedNotation);
[7297]674 out.setRealNumberPrecision(3);
[3429]675 out << _resTime.datestr().c_str() << " " << _resTime.timestr().c_str()
[3432]676 << " Maximum Residuum " << maxRes << ' '
[6962]677 << corrs()[maxResIndex-1]->_acName << ' ' << corrs()[maxResIndex-1]->_prn.mid(0,3);
[3432]678 if (maxRes > _MAXRES) {
679 for (int iPar = 1; iPar <= _params.size(); iPar++) {
680 cmbParam* pp = _params[iPar-1];
[7297]681 if (pp->type == cmbParam::offACSat &&
[6157]682 pp->AC == corrs()[maxResIndex-1]->_acName &&
[6962]683 pp->prn == corrs()[maxResIndex-1]->_prn.mid(0,3)) {
[3432]684 QQ_sav.Row(iPar) = 0.0;
685 QQ_sav.Column(iPar) = 0.0;
[3455]686 QQ_sav(iPar,iPar) = pp->sig0 * pp->sig0;
[3432]687 }
688 }
689
690 out << " Outlier" << endl;
691 _QQ = QQ_sav;
[3455]692 corrs().remove(maxResIndex-1);
[3432]693 }
694 else {
695 out << " OK" << endl;
[6330]696 out.setRealNumberNotation(QTextStream::FixedNotation);
697 out.setRealNumberPrecision(4);
698 for (int ii = 0; ii < corrs().size(); ii++) {
[8066]699 const cmbCorr* corr = corrs()[ii];
[6330]700 out << _resTime.datestr().c_str() << ' '
701 << _resTime.timestr().c_str() << " "
[6962]702 << corr->_acName << ' ' << corr->_prn.mid(0,3);
[6330]703 out.setFieldWidth(10);
704 out << " res = " << vv[ii] << endl;
705 out.setFieldWidth(0);
706 }
[3432]707 break;
708 }
709 }
710
[3472]711 return success;
[2918]712}
[3011]713
[3201]714// Print results
[3011]715////////////////////////////////////////////////////////////////////////////
[3429]716void bncComb::printResults(QTextStream& out,
[6157]717 const QMap<QString, cmbCorr*>& resCorr) {
[3011]718
[6157]719 QMapIterator<QString, cmbCorr*> it(resCorr);
[3011]720 while (it.hasNext()) {
721 it.next();
[6157]722 cmbCorr* corr = it.value();
723 const t_eph* eph = corr->_eph;
[3015]724 if (eph) {
[8541]725 ColumnVector xc(6);
[6109]726 ColumnVector vv(3);
[9269]727 if (eph->getCrd(_resTime, xc, vv, false) != success) {
728 continue;
729 }
[7297]730 out << _resTime.datestr().c_str() << " "
[3429]731 << _resTime.timestr().c_str() << " ";
[3015]732 out.setFieldWidth(3);
[6962]733 out << "Full Clock " << corr->_prn.mid(0,3) << " " << corr->_iod << " ";
[3015]734 out.setFieldWidth(14);
[6160]735 out << (xc(4) + corr->_dClkResult) * t_CST::c << endl;
[3370]736 out.setFieldWidth(0);
[3015]737 }
738 else {
739 out << "bncComb::printResuls bug" << endl;
740 }
[3011]741 }
742}
[3202]743
744// Send results to RTNet Decoder and directly to PPP Client
745////////////////////////////////////////////////////////////////////////////
[6157]746void bncComb::dumpResults(const QMap<QString, cmbCorr*>& resCorr) {
[3202]747
[6161]748 QList<t_orbCorr> orbCorrections;
749 QList<t_clkCorr> clkCorrections;
750
[5337]751 QString outLines;
[3214]752 unsigned year, month, day, hour, minute;
753 double sec;
[3429]754 _resTime.civil_date(year, month, day);
755 _resTime.civil_time(hour, minute, sec);
[3214]756
[7297]757 outLines.sprintf("* %4d %2d %2d %d %d %12.8f\n",
[5337]758 year, month, day, hour, minute, sec);
[3214]759
[6157]760 QMapIterator<QString, cmbCorr*> it(resCorr);
[3202]761 while (it.hasNext()) {
762 it.next();
[6157]763 cmbCorr* corr = it.value();
[3202]764
[7013]765 t_orbCorr orbCorr(corr->_orbCorr);
766 orbCorr._staID = "INTERNAL";
767 orbCorrections.push_back(orbCorr);
768
769 t_clkCorr clkCorr(corr->_clkCorr);
770 clkCorr._staID = "INTERNAL";
771 clkCorr._dClk = corr->_dClkResult;
772 clkCorr._dotDClk = 0.0;
773 clkCorr._dotDotDClk = 0.0;
774 clkCorrections.push_back(clkCorr);
775
[8541]776 ColumnVector xc(6);
[4978]777 ColumnVector vv(3);
[7013]778 corr->_eph->setClkCorr(dynamic_cast<const t_clkCorr*>(&clkCorr));
779 corr->_eph->setOrbCorr(dynamic_cast<const t_orbCorr*>(&orbCorr));
[9269]780 if (corr->_eph->getCrd(_resTime, xc, vv, true) != success) {
781 delete corr;
782 continue;
783 }
[7012]784
[4978]785 // Correction Phase Center --> CoM
786 // -------------------------------
787 ColumnVector dx(3); dx = 0.0;
788 if (_antex) {
789 double Mjd = _resTime.mjd() + _resTime.daysec()/86400.0;
[6157]790 if (_antex->satCoMcorrection(corr->_prn, Mjd, xc.Rows(1,3), dx) != success) {
[4992]791 dx = 0;
[6970]792 _log += "antenna not found " + corr->_prn.mid(0,3).toAscii() + '\n';
[3214]793 }
794 }
[7012]795
796 outLines += corr->_prn.mid(0,3);
[5337]797 QString hlp;
798 hlp.sprintf(" APC 3 %15.4f %15.4f %15.4f"
799 " Clk 1 %15.4f"
800 " Vel 3 %15.4f %15.4f %15.4f"
801 " CoM 3 %15.4f %15.4f %15.4f\n",
[7012]802 xc(1), xc(2), xc(3),
803 xc(4) * t_CST::c,
[5337]804 vv(1), vv(2), vv(3),
805 xc(1)-dx(1), xc(2)-dx(2), xc(3)-dx(3));
806 outLines += hlp;
807
[4978]808 QString line;
[9036]809 int messageType = _ssrCorr->COTYPE_GPSCOMBINED;
[5564]810 int updateInt = 0;
[4978]811 line.sprintf("%d %d %d %.1f %s"
[7055]812 " %lu"
[4978]813 " %8.3f %8.3f %8.3f %8.3f"
814 " %10.5f %10.5f %10.5f %10.5f"
[5576]815 " %10.5f INTERNAL",
[4978]816 messageType, updateInt, _resTime.gpsw(), _resTime.gpssec(),
[7012]817 corr->_prn.mid(0,3).toAscii().data(),
[6157]818 corr->_iod,
[6160]819 corr->_dClkResult * t_CST::c,
[6159]820 corr->_orbCorr._xr[0],
821 corr->_orbCorr._xr[1],
822 corr->_orbCorr._xr[2],
[6157]823 0.0,
[6159]824 corr->_orbCorr._dotXr[0],
825 corr->_orbCorr._dotXr[1],
826 corr->_orbCorr._dotXr[2],
[6157]827 0.0);
[3214]828 delete corr;
829 }
830
[5337]831 outLines += "EOE\n"; // End Of Epoch flag
832
[3215]833 if (!_rtnetDecoder) {
834 _rtnetDecoder = new bncRtnetDecoder();
835 }
[3221]836
[3215]837 vector<string> errmsg;
[5337]838 _rtnetDecoder->Decode(outLines.toAscii().data(), outLines.length(), errmsg);
[3215]839
[5861]840 // Send new Corrections to PPP etc.
841 // --------------------------------
[6161]842 if (orbCorrections.size() > 0 && clkCorrections.size() > 0) {
843 emit newOrbCorrections(orbCorrections);
844 emit newClkCorrections(clkCorrections);
845 }
[3202]846}
[3455]847
848// Create First Design Matrix and Vector of Measurements
849////////////////////////////////////////////////////////////////////////////
850t_irc bncComb::createAmat(Matrix& AA, ColumnVector& ll, DiagonalMatrix& PP,
[7297]851 const ColumnVector& x0,
[6157]852 QMap<QString, cmbCorr*>& resCorr) {
[3455]853
854 unsigned nPar = _params.size();
[7297]855 unsigned nObs = corrs().size();
[3455]856
857 if (nObs == 0) {
858 return failure;
859 }
860
[5742]861 int maxSat = t_prn::MAXPRN_GPS;
[3486]862// if (_useGlonass) {
[5742]863// maxSat = t_prn::MAXPRN_GPS + t_prn::MAXPRN_GLONASS;
[3486]864// }
[3455]865
[5742]866 const int nCon = (_method == filter) ? 1 + maxSat : 0;
[3483]867
[3455]868 AA.ReSize(nObs+nCon, nPar); AA = 0.0;
869 ll.ReSize(nObs+nCon); ll = 0.0;
870 PP.ReSize(nObs+nCon); PP = 1.0 / (sigObs * sigObs);
871
872 int iObs = 0;
873 QVectorIterator<cmbCorr*> itCorr(corrs());
874 while (itCorr.hasNext()) {
875 cmbCorr* corr = itCorr.next();
[6157]876 QString prn = corr->_prn;
[3487]877
[3455]878 ++iObs;
879
[6157]880 if (corr->_acName == _masterOrbitAC && resCorr.find(prn) == resCorr.end()) {
881 resCorr[prn] = new cmbCorr(*corr);
[3455]882 }
883
884 for (int iPar = 1; iPar <= _params.size(); iPar++) {
885 cmbParam* pp = _params[iPar-1];
[6157]886 AA(iObs, iPar) = pp->partial(corr->_acName, prn);
[3455]887 }
888
[6160]889 ll(iObs) = corr->_clkCorr._dClk * t_CST::c - DotProduct(AA.Row(iObs), x0);
[3455]890 }
891
892 // Regularization
893 // --------------
[3474]894 if (_method == filter) {
895 const double Ph = 1.e6;
896 PP(nObs+1) = Ph;
[3461]897 for (int iPar = 1; iPar <= _params.size(); iPar++) {
898 cmbParam* pp = _params[iPar-1];
[3465]899 if ( AA.Column(iPar).maximum_absolute_value() > 0.0 &&
[3474]900 pp->type == cmbParam::clkSat ) {
901 AA(nObs+1, iPar) = 1.0;
[3455]902 }
903 }
[3474]904 int iCond = 1;
[5808]905 for (unsigned iGps = 1; iGps <= t_prn::MAXPRN_GPS; iGps++) {
[7132]906 QString prn = QString("G%1_0").arg(iGps, 2, 10, QChar('0'));
[3474]907 ++iCond;
908 PP(nObs+iCond) = Ph;
909 for (int iPar = 1; iPar <= _params.size(); iPar++) {
910 cmbParam* pp = _params[iPar-1];
[7299]911 if ( pp &&
912 AA.Column(iPar).maximum_absolute_value() > 0.0 &&
[7297]913 pp->type == cmbParam::offACSat &&
[3474]914 pp->prn == prn) {
915 AA(nObs+iCond, iPar) = 1.0;
916 }
917 }
918 }
[3486]919// if (_useGlonass) {
[9036]920// for (unsigned iGlo = 1; iGlo <= t_prn::MAXPRN_GLONASS; iGlo++) {
[7132]921// QString prn = QString("R%1_0").arg(iGlo, 2, 10, QChar('0'));
[3486]922// ++iCond;
923// PP(nObs+iCond) = Ph;
924// for (int iPar = 1; iPar <= _params.size(); iPar++) {
925// cmbParam* pp = _params[iPar-1];
[7299]926// if ( pp &&
927// AA.Column(iPar).maximum_absolute_value() > 0.0 &&
[7297]928// pp->type == cmbParam::offACSat &&
[3486]929// pp->prn == prn) {
930// AA(nObs+iCond, iPar) = 1.0;
931// }
932// }
933// }
934// }
[3455]935 }
936
937 return success;
938}
[3470]939
940// Process Epoch - Single-Epoch Method
941////////////////////////////////////////////////////////////////////////////
[3472]942t_irc bncComb::processEpoch_singleEpoch(QTextStream& out,
[6157]943 QMap<QString, cmbCorr*>& resCorr,
[3475]944 ColumnVector& dx) {
[3470]945
[3487]946 // Check Satellite Positions for Outliers
947 // --------------------------------------
[3497]948 if (checkOrbits(out) != success) {
[3487]949 return failure;
950 }
951
[3482]952 // Outlier Detection Loop
953 // ----------------------
954 while (true) {
[7297]955
[3482]956 // Remove Satellites that are not in Master
957 // ----------------------------------------
958 QMutableVectorIterator<cmbCorr*> it(corrs());
959 while (it.hasNext()) {
960 cmbCorr* corr = it.next();
[6157]961 QString prn = corr->_prn;
[3482]962 bool foundMaster = false;
963 QVectorIterator<cmbCorr*> itHlp(corrs());
964 while (itHlp.hasNext()) {
965 cmbCorr* corrHlp = itHlp.next();
[6157]966 QString prnHlp = corrHlp->_prn;
967 QString ACHlp = corrHlp->_acName;
[3482]968 if (ACHlp == _masterOrbitAC && prn == prnHlp) {
969 foundMaster = true;
970 break;
971 }
[3476]972 }
[3482]973 if (!foundMaster) {
[3556]974 delete corr;
[3482]975 it.remove();
976 }
[3473]977 }
[7297]978
[3482]979 // Count Number of Observations per Satellite and per AC
980 // -----------------------------------------------------
981 QMap<QString, int> numObsPrn;
982 QMap<QString, int> numObsAC;
983 QVectorIterator<cmbCorr*> itCorr(corrs());
984 while (itCorr.hasNext()) {
985 cmbCorr* corr = itCorr.next();
[6157]986 QString prn = corr->_prn;
987 QString AC = corr->_acName;
[3482]988 if (numObsPrn.find(prn) == numObsPrn.end()) {
989 numObsPrn[prn] = 1;
990 }
991 else {
992 numObsPrn[prn] += 1;
993 }
994 if (numObsAC.find(AC) == numObsAC.end()) {
995 numObsAC[AC] = 1;
996 }
997 else {
998 numObsAC[AC] += 1;
999 }
[3476]1000 }
[7297]1001
[3482]1002 // Clean-Up the Paramters
1003 // ----------------------
1004 for (int iPar = 1; iPar <= _params.size(); iPar++) {
1005 delete _params[iPar-1];
[3474]1006 }
[3482]1007 _params.clear();
[7297]1008
[3482]1009 // Set new Parameters
1010 // ------------------
1011 int nextPar = 0;
[7297]1012
[3482]1013 QMapIterator<QString, int> itAC(numObsAC);
1014 while (itAC.hasNext()) {
1015 itAC.next();
1016 const QString& AC = itAC.key();
1017 int numObs = itAC.value();
1018 if (AC != _masterOrbitAC && numObs > 0) {
[3485]1019 _params.push_back(new cmbParam(cmbParam::offACgps, ++nextPar, AC, ""));
1020 if (_useGlonass) {
1021 _params.push_back(new cmbParam(cmbParam::offACglo, ++nextPar, AC, ""));
1022 }
[3482]1023 }
[7297]1024 }
1025
[3482]1026 QMapIterator<QString, int> itPrn(numObsPrn);
1027 while (itPrn.hasNext()) {
1028 itPrn.next();
1029 const QString& prn = itPrn.key();
1030 int numObs = itPrn.value();
1031 if (numObs > 0) {
1032 _params.push_back(new cmbParam(cmbParam::clkSat, ++nextPar, "", prn));
1033 }
[7297]1034 }
1035
[3482]1036 int nPar = _params.size();
[7297]1037 ColumnVector x0(nPar);
[3482]1038 x0 = 0.0;
[7297]1039
[3482]1040 // Create First-Design Matrix
1041 // --------------------------
1042 Matrix AA;
1043 ColumnVector ll;
1044 DiagonalMatrix PP;
1045 if (createAmat(AA, ll, PP, x0, resCorr) != success) {
1046 return failure;
[3476]1047 }
[7297]1048
[3482]1049 ColumnVector vv;
1050 try {
1051 Matrix ATP = AA.t() * PP;
1052 SymmetricMatrix NN; NN << ATP * AA;
1053 ColumnVector bb = ATP * ll;
1054 _QQ = NN.i();
1055 dx = _QQ * bb;
1056 vv = ll - AA * dx;
[3476]1057 }
[3482]1058 catch (Exception& exc) {
1059 out << exc.what() << endl;
1060 return failure;
[3476]1061 }
[3474]1062
[3482]1063 int maxResIndex;
[7297]1064 double maxRes = vv.maximum_absolute_value1(maxResIndex);
[3482]1065 out.setRealNumberNotation(QTextStream::FixedNotation);
[7297]1066 out.setRealNumberPrecision(3);
[3482]1067 out << _resTime.datestr().c_str() << " " << _resTime.timestr().c_str()
1068 << " Maximum Residuum " << maxRes << ' '
[7715]1069 << corrs()[maxResIndex-1]->_acName << ' ' << corrs()[maxResIndex-1]->_prn.mid(0,3);
[3474]1070
[3482]1071 if (maxRes > _MAXRES) {
1072 out << " Outlier" << endl;
[3556]1073 delete corrs()[maxResIndex-1];
[3482]1074 corrs().remove(maxResIndex-1);
[3474]1075 }
[3482]1076 else {
1077 out << " OK" << endl;
1078 out.setRealNumberNotation(QTextStream::FixedNotation);
[7297]1079 out.setRealNumberPrecision(3);
[3482]1080 for (int ii = 0; ii < vv.Nrows(); ii++) {
1081 const cmbCorr* corr = corrs()[ii];
[7297]1082 out << _resTime.datestr().c_str() << ' '
[3482]1083 << _resTime.timestr().c_str() << " "
[6962]1084 << corr->_acName << ' ' << corr->_prn.mid(0,3);
[3482]1085 out.setFieldWidth(6);
[6330]1086 out << " res = " << vv[ii] << endl;
[3482]1087 out.setFieldWidth(0);
1088 }
1089 return success;
[3474]1090 }
1091
[3473]1092 }
[3474]1093
[3482]1094 return failure;
[3470]1095}
[3487]1096
1097// Check Satellite Positions for Outliers
1098////////////////////////////////////////////////////////////////////////////
[3497]1099t_irc bncComb::checkOrbits(QTextStream& out) {
[3487]1100
[3489]1101 const double MAX_DISPLACEMENT = 0.20;
[3488]1102
[3502]1103 // Switch to last ephemeris (if possible)
1104 // --------------------------------------
[3501]1105 QMutableVectorIterator<cmbCorr*> im(corrs());
1106 while (im.hasNext()) {
1107 cmbCorr* corr = im.next();
[6157]1108 QString prn = corr->_prn;
[6443]1109
[7012]1110 t_eph* ephLast = _ephUser.ephLast(prn);
1111 t_eph* ephPrev = _ephUser.ephPrev(prn);
[6443]1112
1113 if (ephLast == 0) {
[6962]1114 out << "checkOrbit: missing eph (not found) " << corr->_prn.mid(0,3) << endl;
[3556]1115 delete corr;
[3501]1116 im.remove();
1117 }
[6157]1118 else if (corr->_eph == 0) {
[6962]1119 out << "checkOrbit: missing eph (zero) " << corr->_prn.mid(0,3) << endl;
[3556]1120 delete corr;
[3503]1121 im.remove();
1122 }
[3502]1123 else {
[6443]1124 if ( corr->_eph == ephLast || corr->_eph == ephPrev ) {
1125 switchToLastEph(ephLast, corr);
[3502]1126 }
1127 else {
[6962]1128 out << "checkOrbit: missing eph (deleted) " << corr->_prn.mid(0,3) << endl;
[3556]1129 delete corr;
[3502]1130 im.remove();
1131 }
1132 }
[3501]1133 }
1134
[3488]1135 while (true) {
1136
1137 // Compute Mean Corrections for all Satellites
1138 // -------------------------------------------
[3489]1139 QMap<QString, int> numCorr;
[3488]1140 QMap<QString, ColumnVector> meanRao;
1141 QVectorIterator<cmbCorr*> it(corrs());
1142 while (it.hasNext()) {
1143 cmbCorr* corr = it.next();
[6157]1144 QString prn = corr->_prn;
[3488]1145 if (meanRao.find(prn) == meanRao.end()) {
1146 meanRao[prn].ReSize(4);
[6159]1147 meanRao[prn].Rows(1,3) = corr->_orbCorr._xr;
[7297]1148 meanRao[prn](4) = 1;
[3488]1149 }
1150 else {
[6159]1151 meanRao[prn].Rows(1,3) += corr->_orbCorr._xr;
[7297]1152 meanRao[prn](4) += 1;
[3488]1153 }
[3489]1154 if (numCorr.find(prn) == numCorr.end()) {
1155 numCorr[prn] = 1;
1156 }
1157 else {
1158 numCorr[prn] += 1;
1159 }
[3487]1160 }
[7297]1161
[3488]1162 // Compute Differences wrt Mean, find Maximum
1163 // ------------------------------------------
1164 QMap<QString, cmbCorr*> maxDiff;
1165 it.toFront();
1166 while (it.hasNext()) {
1167 cmbCorr* corr = it.next();
[6157]1168 QString prn = corr->_prn;
[3488]1169 if (meanRao[prn](4) != 0) {
1170 meanRao[prn] /= meanRao[prn](4);
1171 meanRao[prn](4) = 0;
1172 }
[6159]1173 corr->_diffRao = corr->_orbCorr._xr - meanRao[prn].Rows(1,3);
[3488]1174 if (maxDiff.find(prn) == maxDiff.end()) {
1175 maxDiff[prn] = corr;
1176 }
1177 else {
[6157]1178 double normMax = maxDiff[prn]->_diffRao.norm_Frobenius();
1179 double norm = corr->_diffRao.norm_Frobenius();
[3488]1180 if (norm > normMax) {
1181 maxDiff[prn] = corr;
1182 }
[7297]1183 }
[3487]1184 }
[7297]1185
[3655]1186 if (_ACs.size() == 1) {
1187 break;
1188 }
1189
[3488]1190 // Remove Outliers
1191 // ---------------
1192 bool removed = false;
1193 QMutableVectorIterator<cmbCorr*> im(corrs());
1194 while (im.hasNext()) {
1195 cmbCorr* corr = im.next();
[6157]1196 QString prn = corr->_prn;
[3489]1197 if (numCorr[prn] < 2) {
[3556]1198 delete corr;
[3489]1199 im.remove();
1200 }
1201 else if (corr == maxDiff[prn]) {
[6157]1202 double norm = corr->_diffRao.norm_Frobenius();
[3488]1203 if (norm > MAX_DISPLACEMENT) {
[3497]1204 out << _resTime.datestr().c_str() << " "
1205 << _resTime.timestr().c_str() << " "
[7297]1206 << "Orbit Outlier: "
1207 << corr->_acName.toAscii().data() << " "
[6963]1208 << prn.mid(0,3).toAscii().data() << " "
[7297]1209 << corr->_iod << " "
[6157]1210 << norm << endl;
[3556]1211 delete corr;
[3488]1212 im.remove();
1213 removed = true;
1214 }
1215 }
[3487]1216 }
[7297]1217
[3488]1218 if (!removed) {
1219 break;
1220 }
[3487]1221 }
1222
1223 return success;
1224}
[3588]1225
[7297]1226//
[3588]1227////////////////////////////////////////////////////////////////////////////
[5583]1228void bncComb::slotProviderIDChanged(QString mountPoint) {
1229 QMutexLocker locker(&_mutex);
1230
[8066]1231 QTextStream out(&_log, QIODevice::WriteOnly);
1232
[5583]1233 // Find the AC Name
1234 // ----------------
1235 QString acName;
1236 QListIterator<cmbAC*> icAC(_ACs);
1237 while (icAC.hasNext()) {
1238 cmbAC* AC = icAC.next();
1239 if (AC->mountPoint == mountPoint) {
1240 acName = AC->name;
[8066]1241 out << "Provider ID changed: AC " << AC->name.toAscii().data() << " "
1242 << _resTime.datestr().c_str() << " "
1243 << _resTime.timestr().c_str() << endl;
[5583]1244 break;
1245 }
1246 }
1247 if (acName.isEmpty()) {
1248 return;
1249 }
1250
1251 // Remove all corrections of the corresponding AC
1252 // ----------------------------------------------
1253 QListIterator<bncTime> itTime(_buffer.keys());
1254 while (itTime.hasNext()) {
1255 bncTime epoTime = itTime.next();
1256 QVector<cmbCorr*>& corrVec = _buffer[epoTime].corrs;
[5584]1257 QMutableVectorIterator<cmbCorr*> it(corrVec);
[5583]1258 while (it.hasNext()) {
1259 cmbCorr* corr = it.next();
[6157]1260 if (acName == corr->_acName) {
[5584]1261 delete corr;
1262 it.remove();
[5583]1263 }
1264 }
1265 }
[5585]1266
1267 // Reset Satellite Offsets
1268 // -----------------------
1269 if (_method == filter) {
1270 for (int iPar = 1; iPar <= _params.size(); iPar++) {
1271 cmbParam* pp = _params[iPar-1];
1272 if (pp->AC == acName && pp->type == cmbParam::offACSat) {
1273 pp->xx = 0.0;
1274 _QQ.Row(iPar) = 0.0;
1275 _QQ.Column(iPar) = 0.0;
1276 _QQ(iPar,iPar) = pp->sig0 * pp->sig0;
1277 }
1278 }
1279 }
[5583]1280}
Note: See TracBrowser for help on using the repository browser.