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

Last change on this file since 3461 was 3461, 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 // Maximal Residuum
193 // ----------------
194 _MAXRES = settings.value("cmbMaxres").toDouble();
195 if (_MAXRES <= 0.0) {
196 _MAXRES = 999.0;
197 }
198}
199
200// Destructor
201////////////////////////////////////////////////////////////////////////////
202bncComb::~bncComb() {
203 QListIterator<cmbAC*> icAC(_ACs);
204 while (icAC.hasNext()) {
205 delete icAC.next();
206 }
207 delete _rtnetDecoder;
208 delete _antex;
209 for (int iPar = 1; iPar <= _params.size(); iPar++) {
210 delete _params[iPar-1];
211 }
212 QVectorIterator<cmbCorr*> itCorr(corrs());
213 while (itCorr.hasNext()) {
214 delete itCorr.next();
215 }
216}
217
218// Read and store one correction line
219////////////////////////////////////////////////////////////////////////////
220void bncComb::processCorrLine(const QString& staID, const QString& line) {
221 QMutexLocker locker(&_mutex);
222
223 // Find the AC Name
224 // ----------------
225 QString acName;
226 QListIterator<cmbAC*> icAC(_ACs);
227 while (icAC.hasNext()) {
228 cmbAC* AC = icAC.next();
229 if (AC->mountPoint == staID) {
230 acName = AC->name;
231 break;
232 }
233 }
234 if (acName.isEmpty()) {
235 return;
236 }
237
238 // Read the Correction
239 // -------------------
240 cmbCorr* newCorr = new cmbCorr();
241 newCorr->acName = acName;
242 if (!newCorr->readLine(line) == success) {
243 delete newCorr;
244 return;
245 }
246
247 // Check Modulo Time
248 // -----------------
249 if (int(newCorr->tt.gpssec()) % moduloTime != 0.0) {
250 delete newCorr;
251 return;
252 }
253
254 // Delete old corrections
255 // ----------------------
256 if (_resTime.valid() && newCorr->tt <= _resTime) {
257 delete newCorr;
258 return;
259 }
260
261 // Check the Ephemeris
262 //--------------------
263 if (_eph.find(newCorr->prn) == _eph.end()) {
264 delete newCorr;
265 return;
266 }
267 else {
268 t_eph* lastEph = _eph[newCorr->prn]->last;
269 t_eph* prevEph = _eph[newCorr->prn]->prev;
270 if (lastEph && lastEph->IOD() == newCorr->iod) {
271 newCorr->eph = lastEph;
272 }
273 else if (prevEph && prevEph->IOD() == newCorr->iod) {
274 newCorr->eph = prevEph;
275 switchToLastEph(lastEph, newCorr);
276 }
277 else {
278 delete newCorr;
279 return;
280 }
281 }
282
283 // Process previous Epoch(s)
284 // -------------------------
285 QListIterator<bncTime> itTime(_buffer.keys());
286 while (itTime.hasNext()) {
287 bncTime epoTime = itTime.next();
288 if (epoTime < newCorr->tt - moduloTime) {
289 _resTime = epoTime;
290 processEpoch();
291 }
292 }
293
294 // Merge or add the correction
295 // ---------------------------
296 QVector<cmbCorr*>& corrs = _buffer[newCorr->tt].corrs;
297 cmbCorr* existingCorr = 0;
298 QVectorIterator<cmbCorr*> itCorr(corrs);
299 while (itCorr.hasNext()) {
300 cmbCorr* hlp = itCorr.next();
301 if (hlp->prn == newCorr->prn && hlp->acName == newCorr->prn) {
302 existingCorr = hlp;
303 break;
304 }
305 }
306 if (existingCorr) {
307 delete newCorr;
308 existingCorr->readLine(line); // merge (multiple messages)
309 }
310 else {
311 corrs.append(newCorr);
312 }
313}
314
315// Change the correction so that it refers to last received ephemeris
316////////////////////////////////////////////////////////////////////////////
317void bncComb::switchToLastEph(const t_eph* lastEph, t_corr* corr) {
318
319 if (corr->eph == lastEph) {
320 return;
321 }
322
323 ColumnVector oldXC(4);
324 ColumnVector oldVV(3);
325 corr->eph->position(corr->tt.gpsw(), corr->tt.gpssec(),
326 oldXC.data(), oldVV.data());
327
328 ColumnVector newXC(4);
329 ColumnVector newVV(3);
330 lastEph->position(corr->tt.gpsw(), corr->tt.gpssec(),
331 newXC.data(), newVV.data());
332
333 ColumnVector dX = newXC.Rows(1,3) - oldXC.Rows(1,3);
334 ColumnVector dV = newVV - oldVV;
335 double dC = newXC(4) - oldXC(4);
336
337 ColumnVector dRAO(3);
338 XYZ_to_RSW(newXC.Rows(1,3), newVV, dX, dRAO);
339
340 ColumnVector dDotRAO(3);
341 XYZ_to_RSW(newXC.Rows(1,3), newVV, dV, dDotRAO);
342
343 QString msg = "switch corr " + corr->prn
344 + QString(" %1 -> %2 %3").arg(corr->iod,3)
345 .arg(lastEph->IOD(),3).arg(dC*t_CST::c, 8, 'f', 4);
346
347 emit newMessage(msg.toAscii(), false);
348
349 corr->iod = lastEph->IOD();
350 corr->eph = lastEph;
351 corr->rao += dRAO;
352 corr->dotRao += dDotRAO;
353 corr->dClk -= dC;
354}
355
356// Process Epoch
357////////////////////////////////////////////////////////////////////////////
358void bncComb::processEpoch() {
359
360 int nPar = _params.size();
361
362 _log.clear();
363
364 QTextStream out(&_log, QIODevice::WriteOnly);
365
366 out << endl << "Combination:" << endl
367 << "------------------------------" << endl;
368
369 // Observation Statistics
370 // ----------------------
371 bool masterPresent = false;
372 int numACwithObs = 0;
373 QListIterator<cmbAC*> icAC(_ACs);
374 while (icAC.hasNext()) {
375 cmbAC* AC = icAC.next();
376 AC->numObs = 0;
377 QVectorIterator<cmbCorr*> itCorr(corrs());
378 while (itCorr.hasNext()) {
379 cmbCorr* corr = itCorr.next();
380 if (corr->acName == AC->name) {
381 AC->numObs += 1;
382 if (AC->name == _masterOrbitAC) {
383 masterPresent = true;
384 }
385 }
386 }
387 out << AC->name.toAscii().data() << ": " << AC->numObs << endl;
388 if (AC->numObs > 0) {
389 ++numACwithObs;
390 }
391 }
392
393 if (numACwithObs < 3) {
394 return;
395 }
396
397 // If Master not present, switch to another one
398 // --------------------------------------------
399 if (masterPresent) {
400 _masterMissingEpochs = 0;
401 }
402 else {
403 ++_masterMissingEpochs;
404 if (_masterMissingEpochs < 10) {
405 out << "Missing Master, Epoch skipped" << endl;
406 _buffer.remove(_resTime);
407 emit newMessage(_log, false);
408 return;
409 }
410 else {
411 _masterMissingEpochs = 0;
412 QListIterator<cmbAC*> icAC(_ACs);
413 while (icAC.hasNext()) {
414 cmbAC* AC = icAC.next();
415 if (AC->numObs > 0) {
416 out << "Switching Master AC "
417 << _masterOrbitAC.toAscii().data() << " --> "
418 << AC->name.toAscii().data() << " "
419 << _resTime.datestr().c_str() << " "
420 << _resTime.timestr().c_str() << endl;
421 _masterOrbitAC = AC->name;
422 break;
423 }
424 }
425 }
426 }
427
428 // Prediction Step
429 // ---------------
430 ColumnVector x0(nPar);
431 for (int iPar = 1; iPar <= _params.size(); iPar++) {
432 cmbParam* pp = _params[iPar-1];
433//// QString prn = pp->prn;
434//// if (!prn.isEmpty() && _eph.find(prn) != _eph.end()) {
435//// switchToLastEph(_eph[prn]->last, pp);
436//// }
437 if (pp->epoSpec) {
438 pp->xx = 0.0;
439 _QQ.Row(iPar) = 0.0;
440 _QQ.Column(iPar) = 0.0;
441 _QQ(iPar,iPar) = pp->sig0 * pp->sig0;
442 }
443 else {
444 _QQ(iPar,iPar) += pp->sigP * pp->sigP;
445 }
446 x0(iPar) = pp->xx;
447 }
448
449 SymmetricMatrix QQ_sav = _QQ;
450
451 ColumnVector dx;
452 QMap<QString, t_corr*> resCorr;
453
454 // Update and outlier detection loop
455 // ---------------------------------
456 while (true) {
457
458 Matrix AA;
459 ColumnVector ll;
460 DiagonalMatrix PP;
461
462 if (createAmat(AA, ll, PP, x0, resCorr) != success) {
463 _buffer.remove(_resTime);
464 emit newMessage(_log, false);
465 return;
466 }
467
468 bncModel::kalman(AA, ll, PP, _QQ, dx);
469 ColumnVector vv = ll - AA * dx;
470
471 int maxResIndex;
472 double maxRes = vv.maximum_absolute_value1(maxResIndex);
473 out.setRealNumberNotation(QTextStream::FixedNotation);
474 out.setRealNumberPrecision(3);
475 out << _resTime.datestr().c_str() << " " << _resTime.timestr().c_str()
476 << " Maximum Residuum " << maxRes << ' '
477 << corrs()[maxResIndex-1]->acName << ' ' << corrs()[maxResIndex-1]->prn;
478
479 if (maxRes > _MAXRES) {
480 for (int iPar = 1; iPar <= _params.size(); iPar++) {
481 cmbParam* pp = _params[iPar-1];
482 if (pp->type == cmbParam::offACSat &&
483 pp->AC == corrs()[maxResIndex-1]->acName &&
484 pp->prn == corrs()[maxResIndex-1]->prn) {
485 QQ_sav.Row(iPar) = 0.0;
486 QQ_sav.Column(iPar) = 0.0;
487 QQ_sav(iPar,iPar) = pp->sig0 * pp->sig0;
488 }
489 }
490
491 out << " Outlier" << endl;
492 _QQ = QQ_sav;
493 corrs().remove(maxResIndex-1);
494 }
495 else {
496 out << " OK" << endl;
497 break;
498 }
499 }
500
501 // Update Parameter Values
502 // -----------------------
503 for (int iPar = 1; iPar <= _params.size(); iPar++) {
504 cmbParam* pp = _params[iPar-1];
505 pp->xx += dx(iPar);
506 if (pp->type == cmbParam::clkSat) {
507 if (resCorr.find(pp->prn) != resCorr.end()) {
508 resCorr[pp->prn]->dClk = pp->xx / t_CST::c;
509 }
510 }
511 out << _resTime.datestr().c_str() << " "
512 << _resTime.timestr().c_str() << " ";
513 out.setRealNumberNotation(QTextStream::FixedNotation);
514 out.setFieldWidth(8);
515 out.setRealNumberPrecision(4);
516 out << pp->toString() << " "
517 << pp->xx << " +- " << sqrt(_QQ(pp->index,pp->index)) << endl;
518 out.setFieldWidth(0);
519 }
520
521 // Print Results
522 // -------------
523 printResults(out, resCorr);
524 dumpResults(resCorr);
525
526 emit newMessage(_log, false);
527
528 // Delete Data
529 // -----------
530 _buffer.remove(_resTime);
531}
532
533// Print results
534////////////////////////////////////////////////////////////////////////////
535void bncComb::printResults(QTextStream& out,
536 const QMap<QString, t_corr*>& resCorr) {
537
538 QMapIterator<QString, t_corr*> it(resCorr);
539 while (it.hasNext()) {
540 it.next();
541 t_corr* corr = it.value();
542 const t_eph* eph = corr->eph;
543 if (eph) {
544 double xx, yy, zz, cc;
545 eph->position(_resTime.gpsw(), _resTime.gpssec(), xx, yy, zz, cc);
546
547 out << _resTime.datestr().c_str() << " "
548 << _resTime.timestr().c_str() << " ";
549 out.setFieldWidth(3);
550 out << "Full Clock " << corr->prn << " " << corr->iod << " ";
551 out.setFieldWidth(14);
552 out << (cc + corr->dClk) * t_CST::c << endl;
553 out.setFieldWidth(0);
554 }
555 else {
556 out << "bncComb::printResuls bug" << endl;
557 }
558 }
559}
560
561// Send results to RTNet Decoder and directly to PPP Client
562////////////////////////////////////////////////////////////////////////////
563void bncComb::dumpResults(const QMap<QString, t_corr*>& resCorr) {
564
565 ostringstream out; out.setf(std::ios::fixed);
566 QStringList corrLines;
567
568 unsigned year, month, day, hour, minute;
569 double sec;
570 _resTime.civil_date(year, month, day);
571 _resTime.civil_time(hour, minute, sec);
572
573 out << "* "
574 << setw(4) << year << " "
575 << setw(2) << month << " "
576 << setw(2) << day << " "
577 << setw(2) << hour << " "
578 << setw(2) << minute << " "
579 << setw(12) << setprecision(8) << sec << " "
580 << endl;
581
582 QMapIterator<QString, t_corr*> it(resCorr);
583 while (it.hasNext()) {
584 it.next();
585 t_corr* corr = it.value();
586
587 double dT = 60.0;
588
589 for (int iTime = 1; iTime <= 2; iTime++) {
590
591 bncTime time12 = (iTime == 1) ? _resTime : _resTime + dT;
592
593 ColumnVector xc(4);
594 ColumnVector vv(3);
595 corr->eph->position(time12.gpsw(), time12.gpssec(),
596 xc.data(), vv.data());
597 bncPPPclient::applyCorr(time12, corr, xc, vv);
598
599 // Relativistic Correction
600 // -----------------------
601 double relCorr = - 2.0 * DotProduct(xc.Rows(1,3),vv) / t_CST::c / t_CST::c;
602 xc(4) -= relCorr;
603
604 // Code Biases
605 // -----------
606 double dcbP1C1 = 0.0;
607 double dcbP1P2 = 0.0;
608
609 // Correction Phase Center --> CoM
610 // -------------------------------
611 ColumnVector dx(3); dx = 0.0;
612 if (_antex) {
613 double Mjd = time12.mjd() + time12.daysec()/86400.0;
614 if (_antex->satCoMcorrection(corr->prn, Mjd, xc.Rows(1,3), dx) == success) {
615 xc(1) -= dx(1);
616 xc(2) -= dx(2);
617 xc(3) -= dx(3);
618 }
619 else {
620 cout << "antenna not found" << endl;
621 }
622 }
623
624 if (iTime == 1) {
625 out << 'P' << corr->prn.toAscii().data()
626 << setw(14) << setprecision(6) << xc(1) / 1000.0
627 << setw(14) << setprecision(6) << xc(2) / 1000.0
628 << setw(14) << setprecision(6) << xc(3) / 1000.0
629 << setw(14) << setprecision(6) << xc(4) * 1e6
630 << setw(14) << setprecision(6) << relCorr * 1e6
631 << setw(8) << setprecision(3) << dx(1)
632 << setw(8) << setprecision(3) << dx(2)
633 << setw(8) << setprecision(3) << dx(3)
634 << setw(8) << setprecision(3) << dcbP1C1
635 << setw(8) << setprecision(3) << dcbP1P2
636 << setw(6) << setprecision(1) << dT;
637
638 QString line;
639 int messageType = COTYPE_GPSCOMBINED;
640 int updateInt = 0;
641 line.sprintf("%d %d %d %.1f %s"
642 " %3d"
643 " %8.3f %8.3f %8.3f %8.3f"
644 " %10.5f %10.5f %10.5f %10.5f"
645 " %10.5f %10.5f %10.5f %10.5f INTERNAL",
646 messageType, updateInt, time12.gpsw(), time12.gpssec(),
647 corr->prn.toAscii().data(),
648 corr->iod,
649 corr->dClk * t_CST::c,
650 corr->rao[0],
651 corr->rao[1],
652 corr->rao[2],
653 corr->dotDClk * t_CST::c,
654 corr->dotRao[0],
655 corr->dotRao[1],
656 corr->dotRao[2],
657 corr->dotDotDClk * t_CST::c,
658 corr->dotDotRao[0],
659 corr->dotDotRao[1],
660 corr->dotDotRao[2]);
661 corrLines << line;
662 }
663 else {
664 out << setw(14) << setprecision(6) << xc(1) / 1000.0
665 << setw(14) << setprecision(6) << xc(2) / 1000.0
666 << setw(14) << setprecision(6) << xc(3) / 1000.0 << endl;
667 }
668 }
669
670 delete corr;
671 }
672 out << "EOE" << endl; // End Of Epoch flag
673
674 if (!_rtnetDecoder) {
675 _rtnetDecoder = new bncRtnetDecoder();
676 }
677
678 vector<string> errmsg;
679 _rtnetDecoder->Decode((char*) out.str().data(), out.str().size(), errmsg);
680
681 // Optionally send new Corrections to PPP
682 // --------------------------------------
683 bncApp* app = (bncApp*) qApp;
684 if (app->_bncPPPclient) {
685 app->_bncPPPclient->slotNewCorrections(corrLines);
686 }
687}
688
689// Create First Design Matrix and Vector of Measurements
690////////////////////////////////////////////////////////////////////////////
691t_irc bncComb::createAmat(Matrix& AA, ColumnVector& ll, DiagonalMatrix& PP,
692 const ColumnVector& x0,
693 QMap<QString, t_corr*>& resCorr) {
694
695 unsigned nPar = _params.size();
696 unsigned nObs = corrs().size();
697
698 if (nObs == 0) {
699 return failure;
700 }
701
702 const int nCon = 1 + MAXPRN_GPS;
703
704 AA.ReSize(nObs+nCon, nPar); AA = 0.0;
705 ll.ReSize(nObs+nCon); ll = 0.0;
706 PP.ReSize(nObs+nCon); PP = 1.0 / (sigObs * sigObs);
707
708 int iObs = 0;
709
710 QVectorIterator<cmbCorr*> itCorr(corrs());
711 while (itCorr.hasNext()) {
712 cmbCorr* corr = itCorr.next();
713 QString prn = corr->prn;
714 switchToLastEph(_eph[prn]->last, corr);
715 ++iObs;
716
717 if (corr->acName == _masterOrbitAC && resCorr.find(prn) == resCorr.end()) {
718 resCorr[prn] = new t_corr(*corr);
719 }
720
721 for (int iPar = 1; iPar <= _params.size(); iPar++) {
722 cmbParam* pp = _params[iPar-1];
723 AA(iObs, iPar) = pp->partial(corr->acName, prn);
724 }
725
726 ll(iObs) = corr->dClk * t_CST::c - DotProduct(AA.Row(iObs), x0);
727 }
728
729 // Regularization
730 // --------------
731 const double Ph = 1.e6;
732 PP(nObs+1) = Ph;
733 for (int iPar = 1; iPar <= _params.size(); iPar++) {
734 cmbParam* pp = _params[iPar-1];
735 if (AA.Column(iPar).maximum_absolute_value() > 0.0) {
736 if (pp->type == cmbParam::clkSat) {
737 AA(nObs+1, iPar) = 1.0;
738 }
739 }
740 }
741 int iCond = 1;
742 for (int iGps = 1; iGps <= MAXPRN_GPS; iGps++) {
743 QString prn = QString("G%1").arg(iGps, 2, 10, QChar('0'));
744 ++iCond;
745 PP(nObs+iCond) = Ph;
746 for (int iPar = 1; iPar <= _params.size(); iPar++) {
747 cmbParam* pp = _params[iPar-1];
748 if (pp->type == cmbParam::offACSat && pp->prn == prn) {
749 AA(nObs+iCond, iPar) = 1.0;
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.