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

Last change on this file since 11047 was 11047, checked in by stuerze, 13 hours ago

updates regarding RTCM-SSR and some ovarall improvements

  • 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.0 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 if (_ephs.empty() || eph->isNewerThan(_ephs.front())) {
100 _ephs.push_front(eph);
101 if (maxQueueSize > 0 && _ephs.size() > maxQueueSize) {
102 delete _ephs.back();
103 _ephs.pop_back();
104 }
105 }
106 else {
107 delete eph;
108 }
109}
110
111// A newer ephemeris declaring the satellite unhealthy: rejecting it alone
112// would leave the older, healthy ephemerides in the pool, and the satellite
113// would still be used with them - so they are all discarded, and the
114// satellite stays unused until a newer healthy ephemeris arrives.
115/////////////////////////////////////////////////////////////////////////////
116void t_pppEphPool::t_satEphPool::setUnhealthy(t_eph* eph) {
117 if (_ephs.empty() || eph->isNewerThan(_ephs.front())) {
118 if (!_ephs.empty()) {
119 LOG << "unhealthy ephemeris " << eph->prn().toString() << ' ' << string(eph->TOC())
120 << " - older ephemerides of this satellite discarded" << endl;
121 }
122 for (unsigned ii = 0; ii < _ephs.size(); ii++) {
123 delete _ephs[ii];
124 }
125 _ephs.clear();
126 }
127 delete eph;
128}
129
130//
131/////////////////////////////////////////////////////////////////////////////
132void t_pppEphPool::t_satEphPool::putOrbCorrection(t_orbCorr* corr) {
133 if (_ephs.empty()) {
134 return;
135 }
136
137 for (unsigned ii = 0; ii < _ephs.size(); ii++) {
138 t_eph* eph = _ephs[ii];
139 if (eph->IOD() == corr->_iod) {
140 eph->setOrbCorr(corr);
141 }
142 else {
143 LOG << "putOrbCorrection " << corr->_prn.toString() << " corrIOD = " << corr->_iod << " ephIODs = ";
144 for (auto* e : _ephs) LOG << e->IOD() << " ";
145 LOG << endl;
146 }
147 }
148 delete corr;
149}
150
151//
152/////////////////////////////////////////////////////////////////////////////
153void t_pppEphPool::t_satEphPool::putClkCorrection(t_clkCorr* corr) {
154 if (_ephs.empty()) {
155 return;
156 }
157
158 for (unsigned ii = 0; ii < _ephs.size(); ii++) {
159 t_eph* eph = _ephs[ii];
160 if (eph->IOD() == corr->_iod) {
161 eph->setClkCorr(corr);
162 }
163 else {
164 LOG << "putClockCorrection " << corr->_prn.toString() << " corrIOD = " << corr->_iod << " ephIODs = ";
165 for (auto* e : _ephs) LOG << e->IOD() << " ";
166 LOG << endl;
167 }
168 }
169 delete corr;
170}
171
172//
173/////////////////////////////////////////////////////////////////////////////
174t_irc t_pppEphPool::t_satEphPool::getCrd(const bncTime& tt, ColumnVector& xc,
175 ColumnVector& vv) const {
176 if (_ephs.empty()) {
177 return failure;
178 }
179
180 for (unsigned ii = 0; ii < _ephs.size(); ii++) {
181 const t_eph* eph = _ephs[ii];
182 t_irc irc = eph->getCrd(tt, xc, vv, OPT->useOrbClkCorr());
183 if (irc == success) {
184 if (outDatedBcep(eph, tt)) {
185 continue;
186 }
187 return irc;
188 }
189 }
190 return failure;
191}
192
193//
194/////////////////////////////////////////////////////////////////////////////
195int t_pppEphPool::t_satEphPool::getChannel() const {
196 if (!_ephs.empty()) {
197 return _ephs[0]->slotNum();
198 }
199 return 0;
200}
Note: See TracBrowser for help on using the repository browser.