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

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

* empty log message *

File size: 5.3 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}
58
59// Destructor
60////////////////////////////////////////////////////////////////////////////
61bncPPPclient::~bncPPPclient() {
62 delete _data;
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 (!_data) {
85 _data = new t_data();
86 _data->tt = tt;
87 }
88 else if (tt != _data->tt) {
89 processEpoch();
90 _data = new t_data();
91 _data->tt = tt;
92 }
93
94 ++_data->numSat;
95
96 if (_data->numSat > t_data::MAXOBS) {
97 cerr << "putNewObs: numSat > MAXOBS\n";
98 exit(1);
99 }
100
101 _data->prn[_data->numSat] =
102 QString("%1%2").arg(obs->satSys).arg(obs->satNum, 2, 10, QChar('0'));
103
104 _data->C1[_data->numSat] = obs->C1;
105 _data->C2[_data->numSat] = obs->C2;
106 _data->P1[_data->numSat] = obs->P1;
107 _data->P2[_data->numSat] = obs->P2;
108 _data->L1[_data->numSat] = obs->L1;
109 _data->L2[_data->numSat] = obs->L2;
110}
111
112//
113////////////////////////////////////////////////////////////////////////////
114void bncPPPclient::slotNewEphGPS(gpsephemeris gpseph) {
115 QMutexLocker locker(&_mutex);
116
117 QString prn = QString("G%1").arg(gpseph.satellite, 2, 10, QChar('0'));
118
119 if (_eph.contains(prn)) {
120 (static_cast<t_ephGPS*>(_eph.value(prn)))->set(&gpseph);
121 }
122 else {
123 t_ephGPS* ee = new t_ephGPS();
124 ee->set(&gpseph);
125 _eph[prn] = ee;
126 }
127}
128
129//
130////////////////////////////////////////////////////////////////////////////
131void bncPPPclient::slotNewCorrections(QList<QString> corrList) {
132 QMutexLocker locker(&_mutex);
133 QListIterator<QString> it(corrList);
134 while (it.hasNext()) {
135 QTextStream in(it.next().toAscii());
136 int messageType;
137 int updateInterval;
138 int GPSweek;
139 double GPSweeks;
140 QString prn;
141 in >> messageType >> updateInterval >> GPSweek >> GPSweeks >> prn;
142 if ( messageType == COTYPE_GPSCOMBINED ||
143 messageType == COTYPE_GLONASSCOMBINED ) {
144 t_corr* cc = 0;
145 if (_corr.contains(prn)) {
146 cc = _corr.value(prn);
147 }
148 else {
149 cc = new t_corr();
150 _corr[prn] = cc;
151 }
152 cc->tt.set(GPSweek, GPSweeks);
153 in >> cc->iod >> cc->dClk >> cc->rao[0] >> cc->rao[1] >> cc->rao[2];
154 }
155 }
156}
157
158// Satellite Position
159////////////////////////////////////////////////////////////////////////////
160t_irc bncPPPclient::getSatPos(const t_time& tt, const QString& prn,
161 ColumnVector& xc, ColumnVector& vv) {
162
163 if (_eph.contains(prn)) {
164 _eph.value(prn)->position(tt.gpsw(), tt.gpssec(), xc.data(), vv.data());
165 return success;
166 }
167
168 return failure;
169}
170
171//
172////////////////////////////////////////////////////////////////////////////
173void bncPPPclient::processEpoch() {
174 if (!_data) {
175 return;
176 }
177
178 for (int is = 1; is <= _data->numSat; is++) {
179 QString prn = _data->prn[is];
180
181 ColumnVector xc(4);
182 ColumnVector vv(3);
183
184 cout.setf(ios::fixed);
185
186 if (getSatPos(_data->tt, prn, xc, vv) == success) {
187 cout << _data->tt.timestr(1) << " " << prn.toAscii().data() << " "
188 << setw(14) << setprecision(3) << xc(1) << " "
189 << setw(14) << setprecision(3) << xc(2) << " "
190 << setw(14) << setprecision(3) << xc(3) << " "
191 << setw(14) << setprecision(6) << xc(4)*1.e6 << endl;
192 }
193 }
194
195 cout << endl;
196 cout.flush();
197
198 delete _data;
199 _data = 0;
200}
201
Note: See TracBrowser for help on using the repository browser.