source: ntrip/trunk/BNC/src/PPP/ephpool.cpp@ 5788

Last change on this file since 5788 was 5776, checked in by mervart, 10 years ago
File size: 4.4 KB
Line 
1// Part of BNC, a utility for retrieving decoding and
2// converting GNSS data streams from NTRIP broadcasters.
3//
4// Copyright (C) 2007
5// German Federal Agency for Cartography and Geodesy (BKG)
6// http://www.bkg.bund.de
7// Czech Technical University Prague, Department of Geodesy
8// http://www.fsv.cvut.cz
9//
10// Email: euref-ip@bkg.bund.de
11//
12// This program is free software; you can redistribute it and/or
13// modify it under the terms of the GNU General Public License
14// as published by the Free Software Foundation, version 2.
15//
16// This program is distributed in the hope that it will be useful,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19// GNU General Public License for more details.
20//
21// You should have received a copy of the GNU General Public License
22// along with this program; if not, write to the Free Software
23// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24
25/* -------------------------------------------------------------------------
26 * BKG NTRIP Client
27 * -------------------------------------------------------------------------
28 *
29 * Class: t_pppMain
30 *
31 * Purpose: Buffer with satellite ephemerides
32 *
33 * Author: L. Mervart
34 *
35 * Created: 29-Jul-2014
36 *
37 * Changes:
38 *
39 * -----------------------------------------------------------------------*/
40
41#include <iostream>
42#include "ephpool.h"
43#include "ppp.h"
44
45using namespace BNC;
46using namespace std;
47
48//
49/////////////////////////////////////////////////////////////////////////////
50void t_ephPool::putEphemeris(t_eph* eph) {
51 if (eph && eph->ok()) {
52 _satEphPool[eph->prn().toInt()].putEphemeris(_maxQueueSize, eph);
53 }
54 else {
55 delete eph;
56 }
57}
58
59//
60/////////////////////////////////////////////////////////////////////////////
61void t_ephPool::putOrbCorrection(t_orbCorr* corr) {
62 if (corr) {
63 _satEphPool[corr->prn().toInt()].putOrbCorrection(corr);
64 }
65}
66
67//
68/////////////////////////////////////////////////////////////////////////////
69void t_ephPool::putClkCorrection(t_clkCorr* corr) {
70 if (corr) {
71 _satEphPool[corr->prn().toInt()].putClkCorrection(corr);
72 }
73}
74
75//
76/////////////////////////////////////////////////////////////////////////////
77t_irc t_ephPool::getCrd(const t_prn& prn, const bncTime& tt,
78 ColumnVector& xc, ColumnVector& vv) const {
79 return _satEphPool[prn.toInt()].getCrd(tt, xc, vv);
80}
81
82//
83/////////////////////////////////////////////////////////////////////////////
84int t_ephPool::getChannel(const t_prn& prn) const {
85 return _satEphPool[prn.toInt()].getChannel();
86}
87
88//
89/////////////////////////////////////////////////////////////////////////////
90void t_ephPool::t_satEphPool::putEphemeris(unsigned maxQueueSize, t_eph* eph) {
91 if (_ephs.empty() || eph->isNewerThan(_ephs.front())) {
92 _ephs.push_front(eph);
93 if (maxQueueSize > 0 && _ephs.size() > maxQueueSize) {
94 delete _ephs.back();
95 _ephs.pop_back();
96 }
97 }
98 else {
99 delete eph;
100 }
101}
102
103//
104/////////////////////////////////////////////////////////////////////////////
105void t_ephPool::t_satEphPool::putOrbCorrection(t_orbCorr* corr) {
106 for (unsigned ii = 0; ii < _ephs.size(); ii++) {
107 t_eph* eph = _ephs[ii];
108 if (eph->IOD() == corr->IOD()) {
109 eph->setOrbCorr(corr);
110 return;
111 }
112 }
113 delete corr;
114}
115
116//
117/////////////////////////////////////////////////////////////////////////////
118void t_ephPool::t_satEphPool::putClkCorrection(t_clkCorr* corr) {
119 for (unsigned ii = 0; ii < _ephs.size(); ii++) {
120 t_eph* eph = _ephs[ii];
121 if (eph->IOD() == corr->IOD()) {
122 eph->setClkCorr(corr);
123 }
124 }
125 delete corr;
126}
127
128//
129/////////////////////////////////////////////////////////////////////////////
130t_irc t_ephPool::t_satEphPool::getCrd(const bncTime& tt, ColumnVector& xc,
131 ColumnVector& vv) const {
132 for (unsigned ii = 0; ii < _ephs.size(); ii++) {
133 t_eph* eph = _ephs[ii];
134 t_irc irc = eph->getCrd(tt, xc, vv);
135 if (irc == success) {
136 if (eph->prn().system() == 'R') {
137 double age = tt - eph->TOC();
138 if (fabs(age) > 3600.0) {
139 continue;
140 }
141 }
142 return irc;
143 }
144 }
145 return failure;
146}
147
148//
149/////////////////////////////////////////////////////////////////////////////
150int t_ephPool::t_satEphPool::getChannel() const {
151 if (_ephs.size() > 0) {
152 return _ephs[0]->slotNum();
153 }
154 return 0;
155}
Note: See TracBrowser for help on using the repository browser.