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

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

* empty log message *

File size: 5.6 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 _data = 0;
57 _dataHlp = 0;
58}
59
60// Destructor
61////////////////////////////////////////////////////////////////////////////
62bncPPPclient::~bncPPPclient() {
63 delete _data;
64 delete _dataHlp;
65 QMapIterator<QString, t_eph*> it(_eph);
66 while (it.hasNext()) {
67 it.next();
68 delete it.value();
69 }
70 QMapIterator<QString, t_corr*> ic(_corr);
71 while (ic.hasNext()) {
72 ic.next();
73 delete ic.value();
74 }
75}
76
77//
78////////////////////////////////////////////////////////////////////////////
79void bncPPPclient::putNewObs(p_obs pp) {
80 {
81 QMutexLocker locker(&_mutex);
82
83 t_obsInternal* obs = &(pp->_o);
84
85 t_time tt(obs->GPSWeek, obs->GPSWeeks);
86
87 if (!_dataHlp) {
88 _dataHlp = new t_data();
89 _dataHlp->tt = tt;
90 }
91 else if (tt != _dataHlp->tt) {
92 _data = _dataHlp;
93 _dataHlp = new t_data();
94 _dataHlp->tt = tt;
95 }
96
97 ++_dataHlp->numSat;
98
99 if (_dataHlp->numSat > t_data::MAXOBS) {
100 cerr << "putNewObs: numSat > MAXOBS\n";
101 exit(1);
102 }
103
104 _dataHlp->prn[_dataHlp->numSat] =
105 QString("%1%2").arg(obs->satSys).arg(obs->satNum, 2, 10, QChar('0'));
106
107 _dataHlp->C1[_dataHlp->numSat] = obs->C1;
108 _dataHlp->C2[_dataHlp->numSat] = obs->C2;
109 _dataHlp->P1[_dataHlp->numSat] = obs->P1;
110 _dataHlp->P2[_dataHlp->numSat] = obs->P2;
111 _dataHlp->L1[_dataHlp->numSat] = obs->L1;
112 _dataHlp->L2[_dataHlp->numSat] = obs->L2;
113 } // end of mutex
114
115 processEpoch(); // currently in the same thread as bncgetthread
116}
117
118//
119////////////////////////////////////////////////////////////////////////////
120void bncPPPclient::slotNewEphGPS(gpsephemeris gpseph) {
121 QMutexLocker locker(&_mutex);
122
123 QString prn = QString("G%1").arg(gpseph.satellite, 2, 10, QChar('0'));
124
125 if (_eph.contains(prn)) {
126 (static_cast<t_ephGPS*>(_eph.value(prn)))->set(&gpseph);
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) {
168
169 if (_eph.contains(prn)) {
170 _eph.value(prn)->position(tt.gpsw(), tt.gpssec(), xc.data(), vv.data());
171 return success;
172 }
173
174 return failure;
175}
176
177//
178////////////////////////////////////////////////////////////////////////////
179void bncPPPclient::processEpoch() {
180 QMutexLocker locker(&_mutex);
181
182 if (!_data) {
183 return;
184 }
185
186 for (int is = 1; is <= _data->numSat; is++) {
187 QString prn = _data->prn[is];
188
189 ColumnVector xc(4);
190 ColumnVector vv(3);
191
192 cout.setf(ios::fixed);
193
194 if (getSatPos(_data->tt, prn, xc, vv) == success) {
195 cout << _data->tt.timestr(1) << " " << prn.toAscii().data() << " "
196 << setw(14) << setprecision(3) << xc(1) << " "
197 << setw(14) << setprecision(3) << xc(2) << " "
198 << setw(14) << setprecision(3) << xc(3) << " "
199 << setw(14) << setprecision(6) << xc(4)*1.e6 << endl;
200 }
201 }
202
203 cout << endl;
204 cout.flush();
205
206 delete _data;
207 _data = 0;
208}
209
Note: See TracBrowser for help on using the repository browser.