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_pppEphPool
|
---|
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 "pppEphPool.h"
|
---|
43 | #include "pppInclude.h"
|
---|
44 | #include "pppClient.h"
|
---|
45 |
|
---|
46 | using namespace BNC_PPP;
|
---|
47 | using namespace std;
|
---|
48 |
|
---|
49 | //
|
---|
50 | /////////////////////////////////////////////////////////////////////////////
|
---|
51 | void t_pppEphPool::putEphemeris(t_eph* eph) {
|
---|
52 | if (eph && eph->ok()) {
|
---|
53 | _satEphPool[eph->prn().toInt()].putEphemeris(_maxQueueSize, eph);
|
---|
54 | }
|
---|
55 | else {
|
---|
56 | delete eph;
|
---|
57 | }
|
---|
58 | }
|
---|
59 |
|
---|
60 | //
|
---|
61 | /////////////////////////////////////////////////////////////////////////////
|
---|
62 | void t_pppEphPool::putOrbCorrection(t_orbCorr* corr) {
|
---|
63 | if (corr) {
|
---|
64 | _satEphPool[corr->prn().toInt()].putOrbCorrection(corr);
|
---|
65 | }
|
---|
66 | }
|
---|
67 |
|
---|
68 | //
|
---|
69 | /////////////////////////////////////////////////////////////////////////////
|
---|
70 | void t_pppEphPool::putClkCorrection(t_clkCorr* corr) {
|
---|
71 | if (corr) {
|
---|
72 | _satEphPool[corr->prn().toInt()].putClkCorrection(corr);
|
---|
73 | }
|
---|
74 | }
|
---|
75 |
|
---|
76 | //
|
---|
77 | /////////////////////////////////////////////////////////////////////////////
|
---|
78 | t_irc t_pppEphPool::getCrd(const t_prn& prn, const bncTime& tt,
|
---|
79 | ColumnVector& xc, ColumnVector& vv) const {
|
---|
80 | return _satEphPool[prn.toInt()].getCrd(tt, xc, vv);
|
---|
81 | }
|
---|
82 |
|
---|
83 | //
|
---|
84 | /////////////////////////////////////////////////////////////////////////////
|
---|
85 | int t_pppEphPool::getChannel(const t_prn& prn) const {
|
---|
86 | return _satEphPool[prn.toInt()].getChannel();
|
---|
87 | }
|
---|
88 |
|
---|
89 | //
|
---|
90 | /////////////////////////////////////////////////////////////////////////////
|
---|
91 | void t_pppEphPool::t_satEphPool::putEphemeris(unsigned maxQueueSize, t_eph* eph) {
|
---|
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 | /////////////////////////////////////////////////////////////////////////////
|
---|
106 | void t_pppEphPool::t_satEphPool::putOrbCorrection(t_orbCorr* corr) {
|
---|
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 | /////////////////////////////////////////////////////////////////////////////
|
---|
119 | void t_pppEphPool::t_satEphPool::putClkCorrection(t_clkCorr* corr) {
|
---|
120 | for (unsigned ii = 0; ii < _ephs.size(); ii++) {
|
---|
121 | t_eph* eph = _ephs[ii];
|
---|
122 | if (eph->IOD() == corr->IOD()) {
|
---|
123 | eph->setClkCorr(corr);
|
---|
124 | }
|
---|
125 | }
|
---|
126 | delete corr;
|
---|
127 | }
|
---|
128 |
|
---|
129 | //
|
---|
130 | /////////////////////////////////////////////////////////////////////////////
|
---|
131 | t_irc t_pppEphPool::t_satEphPool::getCrd(const bncTime& tt, ColumnVector& xc,
|
---|
132 | ColumnVector& vv) const {
|
---|
133 | for (unsigned ii = 0; ii < _ephs.size(); ii++) {
|
---|
134 | t_eph* eph = _ephs[ii];
|
---|
135 | t_irc irc = eph->getCrd(tt, xc, vv, OPT->corrRequired());
|
---|
136 | if (irc == success) {
|
---|
137 | if (eph->prn().system() == 'R') {
|
---|
138 | double age = tt - eph->TOC();
|
---|
139 | if (fabs(age) > 3600.0) {
|
---|
140 | continue;
|
---|
141 | }
|
---|
142 | }
|
---|
143 | return irc;
|
---|
144 | }
|
---|
145 | }
|
---|
146 | return failure;
|
---|
147 | }
|
---|
148 |
|
---|
149 | //
|
---|
150 | /////////////////////////////////////////////////////////////////////////////
|
---|
151 | int t_pppEphPool::t_satEphPool::getChannel() const {
|
---|
152 | if (_ephs.size() > 0) {
|
---|
153 | return _ephs[0]->slotNum();
|
---|
154 | }
|
---|
155 | return 0;
|
---|
156 | }
|
---|