source: ntrip/trunk/BNC/src/PPP/pppEphPool.cpp@ 11208

Last change on this file since 11208 was 11194, checked in by stuerze, 6 days ago

IGS-SSR format checked and fixed

  • Property svn:keywords set to Author Date Id Rev URL;svn:eol-style=native
  • Property svn:mime-type set to text/plain
File size: 6.2 KB
Line 
1/* -------------------------------------------------------------------------
2 * BKG NTRIP Client
3 * -------------------------------------------------------------------------
4 *
5 * Class: t_pppEphPool
6 *
7 * Purpose: Buffer with satellite ephemerides
8 *
9 * Author: L. Mervart
10 *
11 * Created: 29-Jul-2014
12 *
13 * Changes:
14 *
15 * -----------------------------------------------------------------------*/
16
17#include <iostream>
18#include <iomanip>
19#include "pppEphPool.h"
20#include "pppInclude.h"
21#include "pppClient.h"
22#include "bncephuser.h"
23
24using namespace BNC_PPP;
25using namespace std;
26
27//
28/////////////////////////////////////////////////////////////////////////////
29// Bad, outdated and unhealthy ephemerides are never used. Ephemerides from
30// RINEX navigation files (post-processing) never pass bncEphUser's checks and
31// stay "unchecked", so the health flag and the plausibility of the satellite
32// distance are checked here directly as well.
33/////////////////////////////////////////////////////////////////////////////
34void t_pppEphPool::putEphemeris(t_eph* eph) {
35 if (!eph) {
36 return;
37 }
38 int iPrn = eph->prn().toInt();
39 if (iPrn == 0) { // satellite number out of range
40 delete eph;
41 }
42 else if (eph->checkState() == t_eph::unhealthy || eph->isUnhealthy()) {
43 _satEphPool[iPrn].setUnhealthy(eph);
44 }
45 else if (eph->checkState() == t_eph::unchecked && !bncEphUser::radialDistanceOk(eph)) {
46 LOG << "bad ephemeris " << eph->prn().toString() << ' ' << string(eph->TOC())
47 << " - implausible satellite distance, ignored" << endl;
48 delete eph;
49 }
50 else if (eph->checkState() != t_eph::bad &&
51 eph->checkState() != t_eph::outdated) {
52 _satEphPool[iPrn].putEphemeris(_maxQueueSize, eph);
53 }
54 else {
55 delete eph;
56 }
57}
58
59//
60/////////////////////////////////////////////////////////////////////////////
61void t_pppEphPool::putOrbCorrection(t_orbCorr* corr) {
62 if (corr) {
63 _satEphPool[corr->_prn.toInt()].putOrbCorrection(corr);
64 if (OPT->_logMode > t_pppOptions::normal) {
65 LOG << "orbCorr " << string(corr->_time) << ' ' << corr->_prn.toString() << endl;
66 }
67 }
68}
69
70//
71/////////////////////////////////////////////////////////////////////////////
72void t_pppEphPool::putClkCorrection(t_clkCorr* corr) {
73 if (corr) {
74 _satEphPool[corr->_prn.toInt()].putClkCorrection(corr);
75 if (OPT->_logMode > t_pppOptions::normal) {
76 LOG.setf(ios::fixed);
77 LOG << "clkCorr " << string(corr->_time) << ' ' << corr->_prn.toString() << ' '
78 << setw(7) << setprecision(3) << corr->_dClk * t_CST::c << endl;
79 }
80 }
81}
82
83//
84/////////////////////////////////////////////////////////////////////////////
85t_irc t_pppEphPool::getCrd(const t_prn& prn, const bncTime& tt,
86 ColumnVector& xc, ColumnVector& vv) const {
87 return _satEphPool[prn.toInt()].getCrd(tt, xc, vv);
88}
89
90//
91/////////////////////////////////////////////////////////////////////////////
92int t_pppEphPool::getChannel(const t_prn& prn) const {
93 return _satEphPool[prn.toInt()].getChannel();
94}
95
96//
97/////////////////////////////////////////////////////////////////////////////
98void t_pppEphPool::t_satEphPool::putEphemeris(unsigned maxQueueSize, t_eph* eph) {
99 // data set received before (e.g. from another stream after a newer one)
100 for (unsigned ii = 0; ii < _ephs.size(); ii++) {
101 if (_ephs[ii]->sameDataSet(eph)) {
102 delete eph;
103 return;
104 }
105 }
106 if (_ephs.empty() || eph->isNewerThan(_ephs.front())) {
107 _ephs.push_front(eph);
108 if (maxQueueSize > 0 && _ephs.size() > maxQueueSize) {
109 delete _ephs.back();
110 _ephs.pop_back();
111 }
112 }
113 else {
114 delete eph;
115 }
116}
117
118// A newer ephemeris declaring the satellite unhealthy: rejecting it alone
119// would leave the older, healthy ephemerides in the pool, and the satellite
120// would still be used with them - so they are all discarded, and the
121// satellite stays unused until a newer healthy ephemeris arrives.
122/////////////////////////////////////////////////////////////////////////////
123void t_pppEphPool::t_satEphPool::setUnhealthy(t_eph* eph) {
124 if (_ephs.empty() || eph->isNewerThan(_ephs.front())) {
125 if (!_ephs.empty()) {
126 LOG << "unhealthy ephemeris " << eph->prn().toString() << ' ' << string(eph->TOC())
127 << " - older ephemerides of this satellite discarded" << endl;
128 }
129 for (unsigned ii = 0; ii < _ephs.size(); ii++) {
130 delete _ephs[ii];
131 }
132 _ephs.clear();
133 }
134 delete eph;
135}
136
137//
138/////////////////////////////////////////////////////////////////////////////
139void t_pppEphPool::t_satEphPool::putOrbCorrection(t_orbCorr* corr) {
140 if (_ephs.empty()) {
141 return;
142 }
143
144 for (unsigned ii = 0; ii < _ephs.size(); ii++) {
145 t_eph* eph = _ephs[ii];
146 if (eph->matchesSsrIOD(corr->_iod)) {
147 eph->setOrbCorr(corr);
148 }
149 else {
150 LOG << "putOrbCorrection " << corr->_prn.toString() << " corrIOD = " << corr->_iod << " ephIODs = ";
151 for (auto* e : _ephs) LOG << e->IOD() << " ";
152 LOG << endl;
153 }
154 }
155 delete corr;
156}
157
158//
159/////////////////////////////////////////////////////////////////////////////
160void t_pppEphPool::t_satEphPool::putClkCorrection(t_clkCorr* corr) {
161 if (_ephs.empty()) {
162 return;
163 }
164
165 for (unsigned ii = 0; ii < _ephs.size(); ii++) {
166 t_eph* eph = _ephs[ii];
167 if (eph->matchesSsrIOD(corr->_iod)) {
168 eph->setClkCorr(corr);
169 }
170 else {
171 LOG << "putClockCorrection " << corr->_prn.toString() << " corrIOD = " << corr->_iod << " ephIODs = ";
172 for (auto* e : _ephs) LOG << e->IOD() << " ";
173 LOG << endl;
174 }
175 }
176 delete corr;
177}
178
179//
180/////////////////////////////////////////////////////////////////////////////
181t_irc t_pppEphPool::t_satEphPool::getCrd(const bncTime& tt, ColumnVector& xc,
182 ColumnVector& vv) const {
183 if (_ephs.empty()) {
184 return failure;
185 }
186
187 for (unsigned ii = 0; ii < _ephs.size(); ii++) {
188 const t_eph* eph = _ephs[ii];
189 t_irc irc = eph->getCrd(tt, xc, vv, OPT->useOrbClkCorr());
190 if (irc == success) {
191 if (outDatedBcep(eph, tt)) {
192 continue;
193 }
194 return irc;
195 }
196 }
197 return failure;
198}
199
200//
201/////////////////////////////////////////////////////////////////////////////
202int t_pppEphPool::t_satEphPool::getChannel() const {
203 if (!_ephs.empty()) {
204 return _ephs[0]->slotNum();
205 }
206 return 0;
207}
Note: See TracBrowser for help on using the repository browser.