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

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

parameter added to be able to chose the corrections to be combined

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