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

Last change on this file since 6004 was 5914, checked in by mervart, 10 years ago
File size: 4.5 KB
RevLine 
[5743]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 *
[5828]29 * Class: t_pppEphPool
[5743]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>
[5810]42#include "pppEphPool.h"
43#include "pppInclude.h"
[5789]44#include "pppClient.h"
[5743]45
[5814]46using namespace BNC_PPP;
[5743]47using namespace std;
48
49//
50/////////////////////////////////////////////////////////////////////////////
[5810]51void t_pppEphPool::putEphemeris(t_eph* eph) {
[5749]52 if (eph && eph->ok()) {
[5743]53 _satEphPool[eph->prn().toInt()].putEphemeris(_maxQueueSize, eph);
54 }
55 else {
56 delete eph;
57 }
58}
59
60//
61/////////////////////////////////////////////////////////////////////////////
[5810]62void t_pppEphPool::putOrbCorrection(t_orbCorr* corr) {
[5743]63 if (corr) {
64 _satEphPool[corr->prn().toInt()].putOrbCorrection(corr);
65 }
66}
67
68//
69/////////////////////////////////////////////////////////////////////////////
[5810]70void t_pppEphPool::putClkCorrection(t_clkCorr* corr) {
[5743]71 if (corr) {
72 _satEphPool[corr->prn().toInt()].putClkCorrection(corr);
73 }
74}
75
76//
77/////////////////////////////////////////////////////////////////////////////
[5810]78t_irc t_pppEphPool::getCrd(const t_prn& prn, const bncTime& tt,
[5743]79 ColumnVector& xc, ColumnVector& vv) const {
80 return _satEphPool[prn.toInt()].getCrd(tt, xc, vv);
81}
82
83//
84/////////////////////////////////////////////////////////////////////////////
[5810]85int t_pppEphPool::getChannel(const t_prn& prn) const {
[5743]86 return _satEphPool[prn.toInt()].getChannel();
87}
88
89//
90/////////////////////////////////////////////////////////////////////////////
[5810]91void t_pppEphPool::t_satEphPool::putEphemeris(unsigned maxQueueSize, t_eph* eph) {
[5743]92 if (_ephs.empty() || eph->isNewerThan(_ephs.front())) {
93 _ephs.push_front(eph);
94 if (maxQueueSize > 0 && _ephs.size() > maxQueueSize) {
95 delete _ephs.back();
96 _ephs.pop_back();
97 }
98 }
99 else {
100 delete eph;
101 }
102}
103
104//
105/////////////////////////////////////////////////////////////////////////////
[5810]106void t_pppEphPool::t_satEphPool::putOrbCorrection(t_orbCorr* corr) {
[5743]107 for (unsigned ii = 0; ii < _ephs.size(); ii++) {
108 t_eph* eph = _ephs[ii];
109 if (eph->IOD() == corr->IOD()) {
110 eph->setOrbCorr(corr);
111 return;
112 }
113 }
114 delete corr;
115}
116
117//
118/////////////////////////////////////////////////////////////////////////////
[5810]119void t_pppEphPool::t_satEphPool::putClkCorrection(t_clkCorr* corr) {
[5743]120 for (unsigned ii = 0; ii < _ephs.size(); ii++) {
121 t_eph* eph = _ephs[ii];
[5749]122 if (eph->IOD() == corr->IOD()) {
[5743]123 eph->setClkCorr(corr);
124 }
125 }
126 delete corr;
127}
128
129//
130/////////////////////////////////////////////////////////////////////////////
[5810]131t_irc t_pppEphPool::t_satEphPool::getCrd(const bncTime& tt, ColumnVector& xc,
[5743]132 ColumnVector& vv) const {
133 for (unsigned ii = 0; ii < _ephs.size(); ii++) {
134 t_eph* eph = _ephs[ii];
[5914]135 t_irc irc = eph->getCrd(tt, xc, vv, OPT->useOrbClkCorr());
[5749]136 if (irc == success) {
[5776]137 if (eph->prn().system() == 'R') {
[5749]138 double age = tt - eph->TOC();
[5743]139 if (fabs(age) > 3600.0) {
140 continue;
141 }
142 }
143 return irc;
144 }
145 }
[5749]146 return failure;
[5743]147}
148
149//
150/////////////////////////////////////////////////////////////////////////////
[5810]151int t_pppEphPool::t_satEphPool::getChannel() const {
[5743]152 if (_ephs.size() > 0) {
[5749]153 return _ephs[0]->slotNum();
[5743]154 }
155 return 0;
156}
Note: See TracBrowser for help on using the repository browser.