source: ntrip/trunk/BNC/bncpppclient.cpp@ 2041

Last change on this file since 2041 was 2041, checked in by mervart, 14 years ago

* empty log message *

File size: 6.1 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: bncPPPclient
30 *
31 * Purpose: Precise Point Positioning
32 *
33 * Author: L. Mervart
34 *
35 * Created: 21-Nov-2009
36 *
37 * Changes:
38 *
39 * -----------------------------------------------------------------------*/
40
41#include <iomanip>
42#include <newmatio.h>
43
44#include "bncpppclient.h"
45
46extern "C" {
47#include "clock_orbit_rtcm.h"
48}
49
50using namespace std;
51
52// Constructor
53////////////////////////////////////////////////////////////////////////////
54bncPPPclient::bncPPPclient(QByteArray staID) {
55 _staID = staID;
56 _epoData = 0;
57}
58
59// Destructor
60////////////////////////////////////////////////////////////////////////////
61bncPPPclient::~bncPPPclient() {
62 delete _epoData;
63 QMapIterator<QString, t_eph*> it(_eph);
64 while (it.hasNext()) {
65 it.next();
66 delete it.value();
67 }
68 QMapIterator<QString, t_corr*> ic(_corr);
69 while (ic.hasNext()) {
70 ic.next();
71 delete ic.value();
72 }
73}
74
75//
76////////////////////////////////////////////////////////////////////////////
77void bncPPPclient::putNewObs(p_obs pp) {
78 QMutexLocker locker(&_mutex);
79
80 t_obsInternal* obs = &(pp->_o);
81
82 t_time tt(obs->GPSWeek, obs->GPSWeeks);
83
84 if (!_epoData) {
85 _epoData = new t_epoData();
86 _epoData->tt = tt;
87 }
88 else if (tt != _epoData->tt) {
89 processEpoch();
90 delete _epoData;
91 _epoData = new t_epoData();
92 _epoData->tt = tt;
93 }
94
95 t_satData* satData = new t_satData();
96
97 satData->C1 = obs->C1;
98 satData->C2 = obs->C2;
99 satData->P1 = obs->P1;
100 satData->P2 = obs->P2;
101 satData->L1 = obs->L1;
102 satData->L2 = obs->L2;
103
104 QString prn =
105 QString("%1%2").arg(obs->satSys).arg(obs->satNum, 2, 10, QChar('0'));
106
107 _epoData->satData[prn] = satData;
108}
109
110//
111////////////////////////////////////////////////////////////////////////////
112void bncPPPclient::slotNewEphGPS(gpsephemeris gpseph) {
113 QMutexLocker locker(&_mutex);
114
115 QString prn = QString("G%1").arg(gpseph.satellite, 2, 10, QChar('0'));
116
117 cout << "EPH " << prn.toAscii().data() << " " << gpseph.IODE << " "
118 << gpseph.IODC << endl;
119
120 if (_eph.contains(prn)) {
121 t_ephGPS* ee = static_cast<t_ephGPS*>(_eph.value(prn));
122 if ( (ee->GPSweek() < gpseph.GPSweek) ||
123 (ee->GPSweek() == gpseph.GPSweek &&
124 ee->TOC() < gpseph.TOC) ) {
125 ee->set(&gpseph);
126 }
127 }
128 else {
129 t_ephGPS* ee = new t_ephGPS();
130 ee->set(&gpseph);
131 _eph[prn] = ee;
132 }
133}
134
135//
136////////////////////////////////////////////////////////////////////////////
137void bncPPPclient::slotNewCorrections(QList<QString> corrList) {
138 QMutexLocker locker(&_mutex);
139 QListIterator<QString> it(corrList);
140 while (it.hasNext()) {
141 QTextStream in(it.next().toAscii());
142 int messageType;
143 int updateInterval;
144 int GPSweek;
145 double GPSweeks;
146 QString prn;
147 in >> messageType >> updateInterval >> GPSweek >> GPSweeks >> prn;
148 if ( messageType == COTYPE_GPSCOMBINED ||
149 messageType == COTYPE_GLONASSCOMBINED ) {
150 t_corr* cc = 0;
151 if (_corr.contains(prn)) {
152 cc = _corr.value(prn);
153 }
154 else {
155 cc = new t_corr();
156 _corr[prn] = cc;
157 }
158 cc->tt.set(GPSweek, GPSweeks);
159 in >> cc->iod >> cc->dClk >> cc->rao[0] >> cc->rao[1] >> cc->rao[2];
160 }
161 }
162}
163
164// Satellite Position
165////////////////////////////////////////////////////////////////////////////
166t_irc bncPPPclient::getSatPos(const t_time& tt, const QString& prn,
167 ColumnVector& xc, ColumnVector& vv, bool& corr) {
168
169 const double MAXAGE = 120.0;
170
171 corr = false;
172
173 if (_eph.contains(prn)) {
174 t_eph* ee = _eph.value(prn);
175 ee->position(tt.gpsw(), tt.gpssec(), xc.data(), vv.data());
176
177 if (_corr.contains(prn)) {
178 t_corr* cc = _corr.value(prn);
179 if (ee->IOD() == cc->iod && (tt - cc->tt) < MAXAGE) {
180 corr = true;
181 applyCorr(cc, xc, vv);
182 }
183 }
184
185 return success;
186 }
187
188 return failure;
189}
190
191//
192////////////////////////////////////////////////////////////////////////////
193void bncPPPclient::applyCorr(const t_corr* cc, ColumnVector& xc,
194 ColumnVector& vv) {
195
196}
197
198//
199////////////////////////////////////////////////////////////////////////////
200void bncPPPclient::processEpoch() {
201
202 QMapIterator<QString, t_satData*> it(_epoData->satData);
203 while (it.hasNext()) {
204 it.next();
205 QString prn = it.key();
206 t_satData* satData = it.value();
207
208 ColumnVector xc(4);
209 ColumnVector vv(3);
210
211 cout.setf(ios::fixed);
212
213 bool corr = false;
214 if (getSatPos(_epoData->tt, prn, xc, vv, corr) == success) {
215 cout << _epoData->tt.timestr(1) << " " << prn.toAscii().data() << " "
216 << setw(14) << setprecision(3) << xc(1) << " "
217 << setw(14) << setprecision(3) << xc(2) << " "
218 << setw(14) << setprecision(3) << xc(3) << " "
219 << setw(14) << setprecision(6) << xc(4)*1.e6;
220 if (corr) {
221 cout << endl;
222 }
223 else {
224 cout << " !\n";
225 }
226 }
227 }
228
229 cout << endl;
230 cout.flush();
231}
Note: See TracBrowser for help on using the repository browser.