source: ntrip/trunk/BNC/combination/bnccomb.cpp@ 3456

Last change on this file since 3456 was 3456, checked in by mervart, 13 years ago
File size: 21.2 KB
Line 
1/* -------------------------------------------------------------------------
2 * BKG NTRIP Client
3 * -------------------------------------------------------------------------
4 *
5 * Class: bncComb
6 *
7 * Purpose: Combinations of Orbit/Clock Corrections
8 *
9 * Author: L. Mervart
10 *
11 * Created: 22-Jan-2011
12 *
13 * Changes:
14 *
15 * -----------------------------------------------------------------------*/
16
17#include <newmatio.h>
18#include <iomanip>
19#include <sstream>
20
21#include "bnccomb.h"
22#include "bncapp.h"
23#include "upload/bncrtnetdecoder.h"
24#include "bncsettings.h"
25#include "bncmodel.h"
26#include "bncutils.h"
27#include "bncpppclient.h"
28#include "bncsp3.h"
29#include "bncantex.h"
30#include "bnctides.h"
31
32const int moduloTime = 10;
33
34const double sig0_offAC = 1000.0;
35const double sig0_offACSat = 100.0;
36const double sigP_offACSat = 0.0;
37const double sig0_clkSat = 100.0;
38
39const double sigObs = 0.05;
40
41const int MAXPRN_GPS = 32;
42
43using namespace std;
44
45// Constructor
46////////////////////////////////////////////////////////////////////////////
47cmbParam::cmbParam(parType type_, int index_,
48 const QString& ac_, const QString& prn_) {
49
50 type = type_;
51 index = index_;
52 AC = ac_;
53 prn = prn_;
54 xx = 0.0;
55 eph = 0;
56
57 if (type == offAC) {
58 epoSpec = true;
59 sig0 = sig0_offAC;
60 sigP = sig0;
61 }
62 else if (type == offACSat) {
63 epoSpec = false;
64 sig0 = sig0_offACSat;
65 sigP = sigP_offACSat;
66 }
67 else if (type == clkSat) {
68 epoSpec = true;
69 sig0 = sig0_clkSat;
70 sigP = sig0;
71 }
72}
73
74// Destructor
75////////////////////////////////////////////////////////////////////////////
76cmbParam::~cmbParam() {
77}
78
79// Partial
80////////////////////////////////////////////////////////////////////////////
81double cmbParam::partial(const QString& AC_, const QString& prn_) {
82
83 if (type == offAC) {
84 if (AC == AC_) {
85 return 1.0;
86 }
87 }
88 else if (type == offACSat) {
89 if (AC == AC_ && prn == prn_) {
90 return 1.0;
91 }
92 }
93 else if (type == clkSat) {
94 if (prn == prn_) {
95 return 1.0;
96 }
97 }
98
99 return 0.0;
100}
101
102//
103////////////////////////////////////////////////////////////////////////////
104QString cmbParam::toString() const {
105
106 QString outStr;
107
108 if (type == offAC) {
109 outStr = "AC offset " + AC;
110 }
111 else if (type == offACSat) {
112 outStr = "Sat Offset " + AC + " " + prn;
113 }
114 else if (type == clkSat) {
115 outStr = "Clk Corr " + prn;
116 }
117
118 return outStr;
119}
120
121// Constructor
122////////////////////////////////////////////////////////////////////////////
123bncComb::bncComb() {
124
125 bncSettings settings;
126
127 QStringList combineStreams = settings.value("combineStreams").toStringList();
128
129 _masterMissingEpochs = 0;
130
131 if (combineStreams.size() >= 1 && !combineStreams[0].isEmpty()) {
132 QListIterator<QString> it(combineStreams);
133 while (it.hasNext()) {
134 QStringList hlp = it.next().split(" ");
135 cmbAC* newAC = new cmbAC();
136 newAC->mountPoint = hlp[0];
137 newAC->name = hlp[1];
138 newAC->weight = hlp[2].toDouble();
139 if (_masterOrbitAC.isEmpty()) {
140 _masterOrbitAC = newAC->name;
141 }
142 _ACs.append(newAC);
143 }
144 }
145
146 _rtnetDecoder = 0;
147
148 connect(this, SIGNAL(newMessage(QByteArray,bool)),
149 ((bncApp*)qApp), SLOT(slotMessage(const QByteArray,bool)));
150
151
152 // Initialize Parameters (model: Clk_Corr = AC_Offset + Sat_Offset + Clk)
153 // ----------------------------------------------------------------------
154 int nextPar = 0;
155 QListIterator<cmbAC*> it(_ACs);
156 while (it.hasNext()) {
157 cmbAC* AC = it.next();
158 _params.push_back(new cmbParam(cmbParam::offAC, ++nextPar, AC->name, ""));
159 for (int iGps = 1; iGps <= MAXPRN_GPS; iGps++) {
160 QString prn = QString("G%1").arg(iGps, 2, 10, QChar('0'));
161 _params.push_back(new cmbParam(cmbParam::offACSat, ++nextPar,
162 AC->name, prn));
163 }
164 }
165 for (int iGps = 1; iGps <= MAXPRN_GPS; iGps++) {
166 QString prn = QString("G%1").arg(iGps, 2, 10, QChar('0'));
167 _params.push_back(new cmbParam(cmbParam::clkSat, ++nextPar, "", prn));
168 }
169
170 // Initialize Variance-Covariance Matrix
171 // -------------------------------------
172 _QQ.ReSize(_params.size());
173 _QQ = 0.0;
174 for (int iPar = 1; iPar <= _params.size(); iPar++) {
175 cmbParam* pp = _params[iPar-1];
176 _QQ(iPar,iPar) = pp->sig0 * pp->sig0;
177 }
178
179 // ANTEX File
180 // ----------
181 _antex = 0;
182 QString antexFileName = settings.value("pppAntex").toString();
183 if (!antexFileName.isEmpty()) {
184 _antex = new bncAntex();
185 if (_antex->readFile(antexFileName) != success) {
186 emit newMessage("wrong ANTEX file", true);
187 delete _antex;
188 _antex = 0;
189 }
190 }
191
192 // Not yet regularized
193 // -------------------
194 _firstReg = false;
195
196 // Maximal Residuum
197 // ----------------
198 _MAXRES = settings.value("cmbMaxres").toDouble();
199 if (_MAXRES <= 0.0) {
200 _MAXRES = 999.0;
201 }
202}
203
204// Destructor
205////////////////////////////////////////////////////////////////////////////
206bncComb::~bncComb() {
207 QListIterator<cmbAC*> icAC(_ACs);
208 while (icAC.hasNext()) {
209 delete icAC.next();
210 }
211 delete _rtnetDecoder;
212 delete _antex;
213 for (int iPar = 1; iPar <= _params.size(); iPar++) {
214 delete _params[iPar-1];
215 }
216 QVectorIterator<cmbCorr*> itCorr(corrs());
217 while (itCorr.hasNext()) {
218 delete itCorr.next();
219 }
220}
221
222// Read and store one correction line
223////////////////////////////////////////////////////////////////////////////
224void bncComb::processCorrLine(const QString& staID, const QString& line) {
225 QMutexLocker locker(&_mutex);
226
227 // Find the AC Name
228 // ----------------
229 QString acName;
230 QListIterator<cmbAC*> icAC(_ACs);
231 while (icAC.hasNext()) {
232 cmbAC* AC = icAC.next();
233 if (AC->mountPoint == staID) {
234 acName = AC->name;
235 break;
236 }
237 }
238 if (acName.isEmpty()) {
239 return;
240 }
241
242 // Read the Correction
243 // -------------------
244 cmbCorr* newCorr = new cmbCorr();
245 newCorr->acName = acName;
246 if (!newCorr->readLine(line) == success) {
247 delete newCorr;
248 return;
249 }
250
251 // Check Modulo Time
252 // -----------------
253 if (int(newCorr->tt.gpssec()) % moduloTime != 0.0) {
254 delete newCorr;
255 return;
256 }
257
258 // Delete old corrections
259 // ----------------------
260 if (_resTime.valid() && newCorr->tt <= _resTime) {
261 delete newCorr;
262 return;
263 }
264
265 // Check the Ephemeris
266 //--------------------
267 if (_eph.find(newCorr->prn) == _eph.end()) {
268 delete newCorr;
269 return;
270 }
271 else {
272 t_eph* lastEph = _eph[newCorr->prn]->last;
273 t_eph* prevEph = _eph[newCorr->prn]->prev;
274 if (lastEph && lastEph->IOD() == newCorr->iod) {
275 newCorr->eph = lastEph;
276 }
277 else if (prevEph && prevEph->IOD() == newCorr->iod) {
278 newCorr->eph = prevEph;
279 switchToLastEph(lastEph, newCorr);
280 }
281 else {
282 delete newCorr;
283 return;
284 }
285 }
286
287 // Process previous Epoch(s)
288 // -------------------------
289 QListIterator<bncTime> itTime(_buffer.keys());
290 while (itTime.hasNext()) {
291 bncTime epoTime = itTime.next();
292 if (epoTime < newCorr->tt - moduloTime) {
293 _resTime = epoTime;
294 processEpoch();
295 }
296 }
297
298 // Merge or add the correction
299 // ---------------------------
300 QVector<cmbCorr*>& corrs = _buffer[newCorr->tt].corrs;
301 cmbCorr* existingCorr = 0;
302 QVectorIterator<cmbCorr*> itCorr(corrs);
303 while (itCorr.hasNext()) {
304 cmbCorr* hlp = itCorr.next();
305 if (hlp->prn == newCorr->prn && hlp->acName == newCorr->prn) {
306 existingCorr = hlp;
307 break;
308 }
309 }
310 if (existingCorr) {
311 delete newCorr;
312 existingCorr->readLine(line); // merge (multiple messages)
313 }
314 else {
315 corrs.append(newCorr);
316 }
317}
318
319// Change the correction so that it refers to last received ephemeris
320////////////////////////////////////////////////////////////////////////////
321void bncComb::switchToLastEph(const t_eph* lastEph, t_corr* corr) {
322
323 if (corr->eph == lastEph) {
324 return;
325 }
326
327 ColumnVector oldXC(4);
328 ColumnVector oldVV(3);
329 corr->eph->position(corr->tt.gpsw(), corr->tt.gpssec(),
330 oldXC.data(), oldVV.data());
331
332 ColumnVector newXC(4);
333 ColumnVector newVV(3);
334 lastEph->position(corr->tt.gpsw(), corr->tt.gpssec(),
335 newXC.data(), newVV.data());
336
337 ColumnVector dX = newXC.Rows(1,3) - oldXC.Rows(1,3);
338 ColumnVector dV = newVV - oldVV;
339 double dC = newXC(4) - oldXC(4);
340
341 ColumnVector dRAO(3);
342 XYZ_to_RSW(newXC.Rows(1,3), newVV, dX, dRAO);
343
344 ColumnVector dDotRAO(3);
345 XYZ_to_RSW(newXC.Rows(1,3), newVV, dV, dDotRAO);
346
347 QString msg = "switch corr " + corr->prn
348 + QString(" %1 -> %2 %3").arg(corr->iod,3)
349 .arg(lastEph->IOD(),3).arg(dC*t_CST::c, 8, 'f', 4);
350
351 emit newMessage(msg.toAscii(), false);
352
353 corr->iod = lastEph->IOD();
354 corr->eph = lastEph;
355 corr->rao += dRAO;
356 corr->dotRao += dDotRAO;
357 corr->dClk -= dC;
358}
359
360// Process Epoch
361////////////////////////////////////////////////////////////////////////////
362void bncComb::processEpoch() {
363
364 int nPar = _params.size();
365
366 _log.clear();
367
368 QTextStream out(&_log, QIODevice::WriteOnly);
369
370 out << endl << "Combination:" << endl
371 << "------------------------------" << endl;
372
373 // Observation Statistics
374 // ----------------------
375 bool masterPresent = false;
376 QListIterator<cmbAC*> icAC(_ACs);
377 while (icAC.hasNext()) {
378 cmbAC* AC = icAC.next();
379 AC->numObs = 0;
380 QVectorIterator<cmbCorr*> itCorr(corrs());
381 while (itCorr.hasNext()) {
382 cmbCorr* corr = itCorr.next();
383 if (corr->acName == AC->name) {
384 AC->numObs += 1;
385 if (AC->name == _masterOrbitAC) {
386 masterPresent = true;
387 }
388 }
389 }
390 out << AC->name.toAscii().data() << ": " << AC->numObs << endl;
391 }
392
393 // If Master not present, switch to another one
394 // --------------------------------------------
395 if (masterPresent) {
396 _masterMissingEpochs = 0;
397 }
398 else {
399 ++_masterMissingEpochs;
400 if (_masterMissingEpochs < 2) {
401 out << "Missing Master, Epoch skipped\n";
402 _buffer.remove(_resTime);
403 emit newMessage(_log, false);
404 return;
405 }
406 else {
407 _masterMissingEpochs = 0;
408 QListIterator<cmbAC*> icAC(_ACs);
409 while (icAC.hasNext()) {
410 cmbAC* AC = icAC.next();
411 if (AC->numObs > 0) {
412 out << "Switching Master AC "
413 << _masterOrbitAC.toAscii().data() << " --> "
414 << AC->name.toAscii().data() << " "
415 << _resTime.datestr().c_str() << " "
416 << _resTime.timestr().c_str() << endl;
417 _masterOrbitAC = AC->name;
418 break;
419 }
420 }
421 }
422 }
423
424 // Prediction Step
425 // ---------------
426 ColumnVector x0(nPar);
427 for (int iPar = 1; iPar <= _params.size(); iPar++) {
428 cmbParam* pp = _params[iPar-1];
429 QString prn = pp->prn;
430 if (!prn.isEmpty() && _eph.find(prn) != _eph.end()) {
431 switchToLastEph(_eph[prn]->last, pp);
432 }
433 if (pp->epoSpec) {
434 pp->xx = 0.0;
435 _QQ.Row(iPar) = 0.0;
436 _QQ.Column(iPar) = 0.0;
437 _QQ(iPar,iPar) = pp->sig0 * pp->sig0;
438 }
439 else {
440 _QQ(iPar,iPar) += pp->sigP * pp->sigP;
441 }
442 x0(iPar) = pp->xx;
443 }
444
445 SymmetricMatrix QQ_sav = _QQ;
446
447 ColumnVector dx;
448 QMap<QString, t_corr*> resCorr;
449
450 // Update and outlier detection loop
451 // ---------------------------------
452 while (true) {
453
454 Matrix AA;
455 ColumnVector ll;
456 DiagonalMatrix PP;
457
458 if (createAmat(AA, ll, PP, x0, resCorr) != success) {
459 _buffer.remove(_resTime);
460 emit newMessage(_log, false);
461 return;
462 }
463
464 bncModel::kalman(AA, ll, PP, _QQ, dx);
465 ColumnVector vv = ll - AA * dx;
466
467 int maxResIndex;
468 double maxRes = vv.maximum_absolute_value1(maxResIndex);
469 out.setRealNumberNotation(QTextStream::FixedNotation);
470 out.setRealNumberPrecision(3);
471 out << _resTime.datestr().c_str() << " " << _resTime.timestr().c_str()
472 << " Maximum Residuum " << maxRes << ' '
473 << corrs()[maxResIndex-1]->acName << ' ' << corrs()[maxResIndex-1]->prn;
474
475 if (maxRes > _MAXRES) {
476 for (int iPar = 1; iPar <= _params.size(); iPar++) {
477 cmbParam* pp = _params[iPar-1];
478 if (pp->type == cmbParam::offACSat &&
479 pp->AC == corrs()[maxResIndex-1]->acName &&
480 pp->prn == corrs()[maxResIndex-1]->prn) {
481 QQ_sav.Row(iPar) = 0.0;
482 QQ_sav.Column(iPar) = 0.0;
483 QQ_sav(iPar,iPar) = pp->sig0 * pp->sig0;
484 }
485 }
486
487 out << " Outlier" << endl;
488 _QQ = QQ_sav;
489 corrs().remove(maxResIndex-1);
490 }
491 else {
492 out << " OK" << endl;
493 break;
494 }
495 }
496
497 _firstReg = true;
498
499 // Update Parameter Values
500 // -----------------------
501 for (int iPar = 1; iPar <= _params.size(); iPar++) {
502 cmbParam* pp = _params[iPar-1];
503 pp->xx += dx(iPar);
504 if (pp->type == cmbParam::clkSat) {
505 if (resCorr.find(pp->prn) != resCorr.end()) {
506 resCorr[pp->prn]->dClk = pp->xx / t_CST::c;
507 }
508 }
509 out << _resTime.datestr().c_str() << " "
510 << _resTime.timestr().c_str() << " ";
511 out.setRealNumberNotation(QTextStream::FixedNotation);
512 out.setFieldWidth(8);
513 out.setRealNumberPrecision(4);
514 out << pp->toString() << " "
515 << pp->xx << " +- " << sqrt(_QQ(pp->index,pp->index)) << endl;
516 out.setFieldWidth(0);
517 }
518
519 // Print Results
520 // -------------
521 printResults(out, resCorr);
522 dumpResults(resCorr);
523
524 emit newMessage(_log, false);
525
526 // Delete Data
527 // -----------
528 _buffer.remove(_resTime);
529}
530
531// Print results
532////////////////////////////////////////////////////////////////////////////
533void bncComb::printResults(QTextStream& out,
534 const QMap<QString, t_corr*>& resCorr) {
535
536 QMapIterator<QString, t_corr*> it(resCorr);
537 while (it.hasNext()) {
538 it.next();
539 t_corr* corr = it.value();
540 const t_eph* eph = corr->eph;
541 if (eph) {
542 double xx, yy, zz, cc;
543 eph->position(_resTime.gpsw(), _resTime.gpssec(), xx, yy, zz, cc);
544
545 out << _resTime.datestr().c_str() << " "
546 << _resTime.timestr().c_str() << " ";
547 out.setFieldWidth(3);
548 out << "Full Clock " << corr->prn << " " << corr->iod << " ";
549 out.setFieldWidth(14);
550 out << (cc + corr->dClk) * t_CST::c << endl;
551 out.setFieldWidth(0);
552 }
553 else {
554 out << "bncComb::printResuls bug" << endl;
555 }
556 }
557}
558
559// Send results to RTNet Decoder and directly to PPP Client
560////////////////////////////////////////////////////////////////////////////
561void bncComb::dumpResults(const QMap<QString, t_corr*>& resCorr) {
562
563 ostringstream out; out.setf(std::ios::fixed);
564 QStringList corrLines;
565
566 unsigned year, month, day, hour, minute;
567 double sec;
568 _resTime.civil_date(year, month, day);
569 _resTime.civil_time(hour, minute, sec);
570
571 out << "* "
572 << setw(4) << year << " "
573 << setw(2) << month << " "
574 << setw(2) << day << " "
575 << setw(2) << hour << " "
576 << setw(2) << minute << " "
577 << setw(12) << setprecision(8) << sec << " "
578 << endl;
579
580 QMapIterator<QString, t_corr*> it(resCorr);
581 while (it.hasNext()) {
582 it.next();
583 t_corr* corr = it.value();
584
585 double dT = 60.0;
586
587 for (int iTime = 1; iTime <= 2; iTime++) {
588
589 bncTime time12 = (iTime == 1) ? _resTime : _resTime + dT;
590
591 ColumnVector xc(4);
592 ColumnVector vv(3);
593 corr->eph->position(time12.gpsw(), time12.gpssec(),
594 xc.data(), vv.data());
595 bncPPPclient::applyCorr(time12, corr, xc, vv);
596
597 // Relativistic Correction
598 // -----------------------
599 double relCorr = - 2.0 * DotProduct(xc.Rows(1,3),vv) / t_CST::c / t_CST::c;
600 xc(4) -= relCorr;
601
602 // Code Biases
603 // -----------
604 double dcbP1C1 = 0.0;
605 double dcbP1P2 = 0.0;
606
607 // Correction Phase Center --> CoM
608 // -------------------------------
609 ColumnVector dx(3); dx = 0.0;
610 if (_antex) {
611 double Mjd = time12.mjd() + time12.daysec()/86400.0;
612 if (_antex->satCoMcorrection(corr->prn, Mjd, xc.Rows(1,3), dx) == success) {
613 xc(1) -= dx(1);
614 xc(2) -= dx(2);
615 xc(3) -= dx(3);
616 }
617 else {
618 cout << "antenna not found" << endl;
619 }
620 }
621
622 if (iTime == 1) {
623 out << 'P' << corr->prn.toAscii().data()
624 << setw(14) << setprecision(6) << xc(1) / 1000.0
625 << setw(14) << setprecision(6) << xc(2) / 1000.0
626 << setw(14) << setprecision(6) << xc(3) / 1000.0
627 << setw(14) << setprecision(6) << xc(4) * 1e6
628 << setw(14) << setprecision(6) << relCorr * 1e6
629 << setw(8) << setprecision(3) << dx(1)
630 << setw(8) << setprecision(3) << dx(2)
631 << setw(8) << setprecision(3) << dx(3)
632 << setw(8) << setprecision(3) << dcbP1C1
633 << setw(8) << setprecision(3) << dcbP1P2
634 << setw(6) << setprecision(1) << dT;
635
636 QString line;
637 int messageType = COTYPE_GPSCOMBINED;
638 int updateInt = 0;
639 line.sprintf("%d %d %d %.1f %s"
640 " %3d"
641 " %8.3f %8.3f %8.3f %8.3f"
642 " %10.5f %10.5f %10.5f %10.5f"
643 " %10.5f %10.5f %10.5f %10.5f INTERNAL",
644 messageType, updateInt, time12.gpsw(), time12.gpssec(),
645 corr->prn.toAscii().data(),
646 corr->iod,
647 corr->dClk * t_CST::c,
648 corr->rao[0],
649 corr->rao[1],
650 corr->rao[2],
651 corr->dotDClk * t_CST::c,
652 corr->dotRao[0],
653 corr->dotRao[1],
654 corr->dotRao[2],
655 corr->dotDotDClk * t_CST::c,
656 corr->dotDotRao[0],
657 corr->dotDotRao[1],
658 corr->dotDotRao[2]);
659 corrLines << line;
660 }
661 else {
662 out << setw(14) << setprecision(6) << xc(1) / 1000.0
663 << setw(14) << setprecision(6) << xc(2) / 1000.0
664 << setw(14) << setprecision(6) << xc(3) / 1000.0 << endl;
665 }
666 }
667
668 delete corr;
669 }
670 out << "EOE" << endl; // End Of Epoch flag
671
672 if (!_rtnetDecoder) {
673 _rtnetDecoder = new bncRtnetDecoder();
674 }
675
676 vector<string> errmsg;
677 _rtnetDecoder->Decode((char*) out.str().data(), out.str().size(), errmsg);
678
679 // Optionally send new Corrections to PPP
680 // --------------------------------------
681 bncApp* app = (bncApp*) qApp;
682 if (app->_bncPPPclient) {
683 app->_bncPPPclient->slotNewCorrections(corrLines);
684 }
685}
686
687// Create First Design Matrix and Vector of Measurements
688////////////////////////////////////////////////////////////////////////////
689t_irc bncComb::createAmat(Matrix& AA, ColumnVector& ll, DiagonalMatrix& PP,
690 const ColumnVector& x0,
691 QMap<QString, t_corr*>& resCorr) {
692
693 unsigned nPar = _params.size();
694 unsigned nObs = corrs().size();
695
696 if (nObs == 0) {
697 return failure;
698 }
699
700 const int nCon = (_firstReg == false) ? 1 + MAXPRN_GPS : 1;
701
702 AA.ReSize(nObs+nCon, nPar); AA = 0.0;
703 ll.ReSize(nObs+nCon); ll = 0.0;
704 PP.ReSize(nObs+nCon); PP = 1.0 / (sigObs * sigObs);
705
706 int iObs = 0;
707
708 QVectorIterator<cmbCorr*> itCorr(corrs());
709 while (itCorr.hasNext()) {
710 cmbCorr* corr = itCorr.next();
711 QString prn = corr->prn;
712 switchToLastEph(_eph[prn]->last, corr);
713 ++iObs;
714
715 if (corr->acName == _masterOrbitAC && resCorr.find(prn) == resCorr.end()) {
716 resCorr[prn] = new t_corr(*corr);
717 }
718
719 for (int iPar = 1; iPar <= _params.size(); iPar++) {
720 cmbParam* pp = _params[iPar-1];
721 AA(iObs, iPar) = pp->partial(corr->acName, prn);
722 }
723
724 ll(iObs) = corr->dClk * t_CST::c - DotProduct(AA.Row(iObs), x0);
725 }
726
727 // Regularization
728 // --------------
729 const double Ph = 1.e6;
730 int iCond = 1;
731 PP(nObs+iCond) = Ph;
732 for (int iPar = 1; iPar <= _params.size(); iPar++) {
733 cmbParam* pp = _params[iPar-1];
734 if (pp->type == cmbParam::clkSat &&
735 AA.Column(iPar).maximum_absolute_value() > 0.0) {
736 AA(nObs+iCond, iPar) = 1.0;
737 }
738 }
739
740 if (!_firstReg) {
741 for (int iGps = 1; iGps <= MAXPRN_GPS; iGps++) {
742 ++iCond;
743 QString prn = QString("G%1").arg(iGps, 2, 10, QChar('0'));
744 PP(nObs+1+iGps) = Ph;
745 for (int iPar = 1; iPar <= _params.size(); iPar++) {
746 cmbParam* pp = _params[iPar-1];
747 if (pp->type == cmbParam::offACSat && pp->prn == prn) {
748 AA(nObs+iCond, iPar) = 1.0;
749 }
750 }
751 }
752 }
753
754 return success;
755}
756
757// Change the parameter so that it refers to last received ephemeris
758////////////////////////////////////////////////////////////////////////////
759void bncComb::switchToLastEph(const t_eph* lastEph, cmbParam* pp) {
760
761 if (pp->type != cmbParam::clkSat) {
762 return;
763 }
764
765 if (pp->eph == 0) {
766 pp->eph = lastEph;
767 return;
768 }
769
770 if (pp->eph == lastEph) {
771 return;
772 }
773
774 ColumnVector oldXC(4);
775 ColumnVector oldVV(3);
776 pp->eph->position(_resTime.gpsw(), _resTime.gpssec(),
777 oldXC.data(), oldVV.data());
778
779 ColumnVector newXC(4);
780 ColumnVector newVV(3);
781 lastEph->position(_resTime.gpsw(), _resTime.gpssec(),
782 newXC.data(), newVV.data());
783
784 double dC = newXC(4) - oldXC(4);
785
786 QString msg = "switch param " + pp->prn
787 + QString(" %1 -> %2 %3").arg(pp->eph->IOD(),3)
788 .arg(lastEph->IOD(),3).arg(dC*t_CST::c, 8, 'f', 4);
789
790 emit newMessage(msg.toAscii(), false);
791
792 pp->eph = lastEph;
793 pp->xx -= dC * t_CST::c;
794}
795
Note: See TracBrowser for help on using the repository browser.