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

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

minor changes

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