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

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

* empty log message *

File size: 6.0 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 if (_eph.contains(prn)) {
118 t_ephGPS* ee = static_cast<t_ephGPS*>(_eph.value(prn));
119 if ( (ee->GPSweek() < gpseph.GPSweek) ||
120 (ee->GPSweek() == gpseph.GPSweek &&
121 ee->TOC() < gpseph.TOC) ) {
122 ee->set(&gpseph);
123 }
124 }
125 else {
126 t_ephGPS* ee = new t_ephGPS();
127 ee->set(&gpseph);
128 _eph[prn] = ee;
129 }
130}
131
132//
133////////////////////////////////////////////////////////////////////////////
134void bncPPPclient::slotNewCorrections(QList<QString> corrList) {
135 QMutexLocker locker(&_mutex);
136 QListIterator<QString> it(corrList);
137 while (it.hasNext()) {
138 QTextStream in(it.next().toAscii());
139 int messageType;
140 int updateInterval;
141 int GPSweek;
142 double GPSweeks;
143 QString prn;
144 in >> messageType >> updateInterval >> GPSweek >> GPSweeks >> prn;
145 if ( messageType == COTYPE_GPSCOMBINED ||
146 messageType == COTYPE_GLONASSCOMBINED ) {
147 t_corr* cc = 0;
148 if (_corr.contains(prn)) {
149 cc = _corr.value(prn);
150 }
151 else {
152 cc = new t_corr();
153 _corr[prn] = cc;
154 }
155 cc->tt.set(GPSweek, GPSweeks);
156 in >> cc->iod >> cc->dClk >> cc->rao[0] >> cc->rao[1] >> cc->rao[2];
157 }
158 }
159}
160
161// Satellite Position
162////////////////////////////////////////////////////////////////////////////
163t_irc bncPPPclient::getSatPos(const t_time& tt, const QString& prn,
164 ColumnVector& xc, ColumnVector& vv, bool& corr) {
165
166 const double MAXAGE = 120.0;
167
168 corr = false;
169
170 if (_eph.contains(prn)) {
171 t_eph* ee = _eph.value(prn);
172 ee->position(tt.gpsw(), tt.gpssec(), xc.data(), vv.data());
173
174 if (_corr.contains(prn)) {
175 t_corr* cc = _corr.value(prn);
176 if (ee->IOD() == cc->iod && (tt - cc->tt) < MAXAGE) {
177 corr = true;
178 applyCorr(cc, xc, vv);
179 }
180 }
181
182 return success;
183 }
184
185 return failure;
186}
187
188//
189////////////////////////////////////////////////////////////////////////////
190void bncPPPclient::applyCorr(const t_corr* cc, ColumnVector& xc,
191 ColumnVector& vv) {
192
193}
194
195//
196////////////////////////////////////////////////////////////////////////////
197void bncPPPclient::processEpoch() {
198
199 cout.setf(ios::fixed);
200
201 QMapIterator<QString, t_satData*> it(_epoData->satData);
202 while (it.hasNext()) {
203 it.next();
204 QString prn = it.key();
205 t_satData* satData = it.value();
206
207 ColumnVector xc(4);
208 ColumnVector vv(3);
209
210 bool corr = false;
211 if (getSatPos(_epoData->tt, prn, xc, vv, corr) == success) {
212 cout << _epoData->tt.timestr(1) << " " << prn.toAscii().data() << " "
213 << setw(14) << setprecision(3) << xc(1) << " "
214 << setw(14) << setprecision(3) << xc(2) << " "
215 << setw(14) << setprecision(3) << xc(3) << " "
216 << setw(12) << setprecision(6) << xc(4)*1.e6;
217 if (corr) {
218 cout << endl;
219 }
220 else {
221 cout << " !\n";
222 }
223 }
224 }
225
226 cout << endl;
227 cout.flush();
228}
Note: See TracBrowser for help on using the repository browser.