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 |
|
---|
46 | extern "C" {
|
---|
47 | #include "clock_orbit_rtcm.h"
|
---|
48 | }
|
---|
49 |
|
---|
50 | using namespace std;
|
---|
51 |
|
---|
52 | // Constructor
|
---|
53 | ////////////////////////////////////////////////////////////////////////////
|
---|
54 | bncPPPclient::bncPPPclient(QByteArray staID) {
|
---|
55 | _staID = staID;
|
---|
56 | _epoData = 0;
|
---|
57 | }
|
---|
58 |
|
---|
59 | // Destructor
|
---|
60 | ////////////////////////////////////////////////////////////////////////////
|
---|
61 | bncPPPclient::~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 | ////////////////////////////////////////////////////////////////////////////
|
---|
77 | void 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 | ////////////////////////////////////////////////////////////////////////////
|
---|
112 | void 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 | (static_cast<t_ephGPS*>(_eph.value(prn)))->set(&gpseph);
|
---|
119 | }
|
---|
120 | else {
|
---|
121 | t_ephGPS* ee = new t_ephGPS();
|
---|
122 | ee->set(&gpseph);
|
---|
123 | _eph[prn] = ee;
|
---|
124 | }
|
---|
125 | }
|
---|
126 |
|
---|
127 | //
|
---|
128 | ////////////////////////////////////////////////////////////////////////////
|
---|
129 | void bncPPPclient::slotNewCorrections(QList<QString> corrList) {
|
---|
130 | QMutexLocker locker(&_mutex);
|
---|
131 | QListIterator<QString> it(corrList);
|
---|
132 | while (it.hasNext()) {
|
---|
133 | QTextStream in(it.next().toAscii());
|
---|
134 | int messageType;
|
---|
135 | int updateInterval;
|
---|
136 | int GPSweek;
|
---|
137 | double GPSweeks;
|
---|
138 | QString prn;
|
---|
139 | in >> messageType >> updateInterval >> GPSweek >> GPSweeks >> prn;
|
---|
140 | if ( messageType == COTYPE_GPSCOMBINED ||
|
---|
141 | messageType == COTYPE_GLONASSCOMBINED ) {
|
---|
142 | t_corr* cc = 0;
|
---|
143 | if (_corr.contains(prn)) {
|
---|
144 | cc = _corr.value(prn);
|
---|
145 | }
|
---|
146 | else {
|
---|
147 | cc = new t_corr();
|
---|
148 | _corr[prn] = cc;
|
---|
149 | }
|
---|
150 | cc->tt.set(GPSweek, GPSweeks);
|
---|
151 | in >> cc->iod >> cc->dClk >> cc->rao[0] >> cc->rao[1] >> cc->rao[2];
|
---|
152 | }
|
---|
153 | }
|
---|
154 | }
|
---|
155 |
|
---|
156 | // Satellite Position
|
---|
157 | ////////////////////////////////////////////////////////////////////////////
|
---|
158 | t_irc bncPPPclient::getSatPos(const t_time& tt, const QString& prn,
|
---|
159 | ColumnVector& xc, ColumnVector& vv) {
|
---|
160 |
|
---|
161 | if (_eph.contains(prn)) {
|
---|
162 | _eph.value(prn)->position(tt.gpsw(), tt.gpssec(), xc.data(), vv.data());
|
---|
163 | return success;
|
---|
164 | }
|
---|
165 |
|
---|
166 | return failure;
|
---|
167 | }
|
---|
168 |
|
---|
169 | //
|
---|
170 | ////////////////////////////////////////////////////////////////////////////
|
---|
171 | void bncPPPclient::processEpoch() {
|
---|
172 |
|
---|
173 | QMapIterator<QString, t_satData*> it(_epoData->satData);
|
---|
174 | while (it.hasNext()) {
|
---|
175 | it.next();
|
---|
176 | QString prn = it.key();
|
---|
177 | t_satData* satData = it.value();
|
---|
178 |
|
---|
179 | ColumnVector xc(4);
|
---|
180 | ColumnVector vv(3);
|
---|
181 |
|
---|
182 | cout.setf(ios::fixed);
|
---|
183 |
|
---|
184 | if (getSatPos(_epoData->tt, prn, xc, vv) == success) {
|
---|
185 | cout << _epoData->tt.timestr(1) << " " << prn.toAscii().data() << " "
|
---|
186 | << setw(14) << setprecision(3) << xc(1) << " "
|
---|
187 | << setw(14) << setprecision(3) << xc(2) << " "
|
---|
188 | << setw(14) << setprecision(3) << xc(3) << " "
|
---|
189 | << setw(14) << setprecision(6) << xc(4)*1.e6 << endl;
|
---|
190 | }
|
---|
191 | }
|
---|
192 |
|
---|
193 | cout << endl;
|
---|
194 | cout.flush();
|
---|
195 | }
|
---|