source: ntrip/trunk/BNC/src/combination/bnccomb.cpp@ 9265

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

minor changes

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