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: bncPPPthread
|
---|
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 |
|
---|
43 | #include "bncpppthread.h"
|
---|
44 |
|
---|
45 | extern "C" {
|
---|
46 | #include "clock_orbit_rtcm.h"
|
---|
47 | }
|
---|
48 |
|
---|
49 | using namespace std;
|
---|
50 |
|
---|
51 | // Constructor
|
---|
52 | ////////////////////////////////////////////////////////////////////////////
|
---|
53 | bncPPPthread::bncPPPthread(QByteArray staID) {
|
---|
54 | _staID = staID;
|
---|
55 | _isToBeDeleted = false;
|
---|
56 | _data = 0;
|
---|
57 | }
|
---|
58 |
|
---|
59 | // Destructor
|
---|
60 | ////////////////////////////////////////////////////////////////////////////
|
---|
61 | bncPPPthread::~bncPPPthread() {
|
---|
62 | if (isRunning()) {
|
---|
63 | wait();
|
---|
64 | }
|
---|
65 | delete _data;
|
---|
66 | QMapIterator<QString, t_eph*> it(_eph);
|
---|
67 | while (it.hasNext()) {
|
---|
68 | it.next();
|
---|
69 | delete it.value();
|
---|
70 | }
|
---|
71 | QMapIterator<QString, t_corr*> ic(_corr);
|
---|
72 | while (ic.hasNext()) {
|
---|
73 | ic.next();
|
---|
74 | delete ic.value();
|
---|
75 | }
|
---|
76 | }
|
---|
77 |
|
---|
78 | //
|
---|
79 | ////////////////////////////////////////////////////////////////////////////
|
---|
80 | void bncPPPthread::terminate() {
|
---|
81 | _isToBeDeleted = true;
|
---|
82 | if (!isRunning()) {
|
---|
83 | delete this;
|
---|
84 | }
|
---|
85 | }
|
---|
86 |
|
---|
87 | // Run
|
---|
88 | ////////////////////////////////////////////////////////////////////////////
|
---|
89 | void bncPPPthread::run() {
|
---|
90 | while (true) {
|
---|
91 | try {
|
---|
92 | if (_isToBeDeleted) {
|
---|
93 | QThread::exit(0);
|
---|
94 | this->deleteLater();
|
---|
95 | return;
|
---|
96 | }
|
---|
97 | processEpoch();
|
---|
98 | }
|
---|
99 | catch (...) {
|
---|
100 | emit(newMessage(_staID + "bncPPPthread exception", true));
|
---|
101 | _isToBeDeleted = true;
|
---|
102 | }
|
---|
103 | }
|
---|
104 | }
|
---|
105 |
|
---|
106 | //
|
---|
107 | ////////////////////////////////////////////////////////////////////////////
|
---|
108 | void bncPPPthread::slotNewEpochData(QList<p_obs> obsList) {
|
---|
109 | QMutexLocker locker(&_mutex);
|
---|
110 | QListIterator<p_obs> it(obsList);
|
---|
111 |
|
---|
112 | delete _data;
|
---|
113 | _data = new t_data();
|
---|
114 |
|
---|
115 | while (it.hasNext()) {
|
---|
116 | p_obs pp = it.next();
|
---|
117 | t_obsInternal* obs = &(pp->_o);
|
---|
118 | QByteArray staID = QByteArray(obs->StatID);
|
---|
119 | if (staID == _staID) {
|
---|
120 | if (_data->tt.undef()) {
|
---|
121 | _data->tt.set(obs->GPSWeek, obs->GPSWeeks);
|
---|
122 | }
|
---|
123 | ++_data->numSat;
|
---|
124 | _data->prn[_data->numSat] =
|
---|
125 | QString("%1%2").arg(obs->satSys).arg(obs->satNum, 2, 10, QChar('0'));
|
---|
126 | _data->C1[_data->numSat] = obs->C1;
|
---|
127 | _data->C2[_data->numSat] = obs->C2;
|
---|
128 | _data->P1[_data->numSat] = obs->P1;
|
---|
129 | _data->P2[_data->numSat] = obs->P2;
|
---|
130 | _data->L1[_data->numSat] = obs->L1;
|
---|
131 | _data->L2[_data->numSat] = obs->L2;
|
---|
132 | }
|
---|
133 | }
|
---|
134 | }
|
---|
135 |
|
---|
136 | //
|
---|
137 | ////////////////////////////////////////////////////////////////////////////
|
---|
138 | void bncPPPthread::slotNewEphGPS(gpsephemeris gpseph) {
|
---|
139 | QMutexLocker locker(&_mutex);
|
---|
140 |
|
---|
141 | QString prn = QString("G%1").arg(gpseph.satellite, 2, 10, QChar('0'));
|
---|
142 |
|
---|
143 | if (_eph.contains(prn)) {
|
---|
144 | (static_cast<t_ephGPS*>(_eph.value(prn)))->set(&gpseph);
|
---|
145 | }
|
---|
146 | else {
|
---|
147 | t_ephGPS* ee = new t_ephGPS();
|
---|
148 | ee->set(&gpseph);
|
---|
149 | _eph[prn] = ee;
|
---|
150 | }
|
---|
151 | }
|
---|
152 |
|
---|
153 | //
|
---|
154 | ////////////////////////////////////////////////////////////////////////////
|
---|
155 | void bncPPPthread::slotNewCorrections(QList<QString> corrList) {
|
---|
156 | QMutexLocker locker(&_mutex);
|
---|
157 | QListIterator<QString> it(corrList);
|
---|
158 | while (it.hasNext()) {
|
---|
159 | QTextStream in(it.next().toAscii());
|
---|
160 | int messageType;
|
---|
161 | int updateInterval;
|
---|
162 | int GPSweek;
|
---|
163 | double GPSweeks;
|
---|
164 | QString prn;
|
---|
165 | in >> messageType >> updateInterval >> GPSweek >> GPSweeks >> prn;
|
---|
166 | if ( messageType == COTYPE_GPSCOMBINED ||
|
---|
167 | messageType == COTYPE_GLONASSCOMBINED ) {
|
---|
168 | t_corr* cc = 0;
|
---|
169 | if (_corr.contains(prn)) {
|
---|
170 | cc = _corr.value(prn);
|
---|
171 | }
|
---|
172 | else {
|
---|
173 | cc = new t_corr();
|
---|
174 | _corr[prn] = cc;
|
---|
175 | }
|
---|
176 | cc->tt.set(GPSweek, GPSweeks);
|
---|
177 | in >> cc->iod >> cc->dClk >> cc->rao[0] >> cc->rao[1] >> cc->rao[2];
|
---|
178 | }
|
---|
179 | }
|
---|
180 | }
|
---|
181 |
|
---|
182 | // Satellite Position
|
---|
183 | ////////////////////////////////////////////////////////////////////////////
|
---|
184 | t_irc bncPPPthread::getSatPos(const t_time& tt, const QString& prn,
|
---|
185 | ColumnVector& xc, ColumnVector& vv) {
|
---|
186 |
|
---|
187 | return success;
|
---|
188 | }
|
---|
189 |
|
---|
190 | //
|
---|
191 | ////////////////////////////////////////////////////////////////////////////
|
---|
192 | void bncPPPthread::processEpoch() {
|
---|
193 | QMutexLocker locker(&_mutex);
|
---|
194 |
|
---|
195 | if (!_data) {
|
---|
196 | return;
|
---|
197 | }
|
---|
198 |
|
---|
199 | for (int is = 1; is <= _data->numSat; is++) {
|
---|
200 | QString prn = _data->prn[is];
|
---|
201 |
|
---|
202 | ColumnVector xc(4);
|
---|
203 | ColumnVector vv(3);
|
---|
204 |
|
---|
205 | if (getSatPos(_data->tt, prn, xc, vv) == success) {
|
---|
206 |
|
---|
207 | }
|
---|
208 | }
|
---|
209 |
|
---|
210 | cout << endl;
|
---|
211 | cout.flush();
|
---|
212 |
|
---|
213 | delete _data;
|
---|
214 | _data = 0;
|
---|
215 | }
|
---|
216 |
|
---|