1 |
|
---|
2 | // Part of BNC, a utility for retrieving decoding and
|
---|
3 | // converting GNSS data streams from NTRIP broadcasters.
|
---|
4 | //
|
---|
5 | // Copyright (C) 2007
|
---|
6 | // German Federal Agency for Cartography and Geodesy (BKG)
|
---|
7 | // http://www.bkg.bund.de
|
---|
8 | // Czech Technical University Prague, Department of Geodesy
|
---|
9 | // http://www.fsv.cvut.cz
|
---|
10 | //
|
---|
11 | // Email: euref-ip@bkg.bund.de
|
---|
12 | //
|
---|
13 | // This program is free software; you can redistribute it and/or
|
---|
14 | // modify it under the terms of the GNU General Public License
|
---|
15 | // as published by the Free Software Foundation, version 2.
|
---|
16 | //
|
---|
17 | // This program is distributed in the hope that it will be useful,
|
---|
18 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
20 | // GNU General Public License for more details.
|
---|
21 | //
|
---|
22 | // You should have received a copy of the GNU General Public License
|
---|
23 | // along with this program; if not, write to the Free Software
|
---|
24 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
---|
25 |
|
---|
26 | /* -------------------------------------------------------------------------
|
---|
27 | * BKG NTRIP Client
|
---|
28 | * -------------------------------------------------------------------------
|
---|
29 | *
|
---|
30 | * Class: t_pppThread, t_pppRun
|
---|
31 | *
|
---|
32 | * Purpose: Single PPP Client (running in its own thread)
|
---|
33 | *
|
---|
34 | * Author: L. Mervart
|
---|
35 | *
|
---|
36 | * Created: 29-Jul-2014
|
---|
37 | *
|
---|
38 | * Changes:
|
---|
39 | *
|
---|
40 | * -----------------------------------------------------------------------*/
|
---|
41 |
|
---|
42 |
|
---|
43 | #include <iostream>
|
---|
44 | #include <iomanip>
|
---|
45 | #include <string.h>
|
---|
46 | #include <map>
|
---|
47 |
|
---|
48 | #include "pppThread.h"
|
---|
49 | #include "bnccore.h"
|
---|
50 |
|
---|
51 | using namespace BNC;
|
---|
52 | using namespace std;
|
---|
53 |
|
---|
54 | // Constructor
|
---|
55 | ////////////////////////////////////////////////////////////////////////////
|
---|
56 | t_pppThread::t_pppThread(const t_options* opt) : QThread(0) {
|
---|
57 | _opt = opt;
|
---|
58 | _pppRun = 0;
|
---|
59 | connect(this, SIGNAL(finished()), this, SLOT(deleteLater()));
|
---|
60 |
|
---|
61 | connect(this, SIGNAL(newMessage(QByteArray,bool)),
|
---|
62 | BNC_CORE, SLOT(slotMessage(const QByteArray,bool)));
|
---|
63 | }
|
---|
64 |
|
---|
65 | // Destructor
|
---|
66 | ////////////////////////////////////////////////////////////////////////////
|
---|
67 | t_pppThread::~t_pppThread() {
|
---|
68 | cout << "~t_pppThread" << endl;
|
---|
69 | delete _pppRun;
|
---|
70 | }
|
---|
71 |
|
---|
72 | // Run (virtual)
|
---|
73 | ////////////////////////////////////////////////////////////////////////////
|
---|
74 | void t_pppThread::run() {
|
---|
75 | try {
|
---|
76 | _pppRun = new t_pppRun(_opt);
|
---|
77 | QThread::exec();
|
---|
78 | }
|
---|
79 | catch (pppExcept exc) {
|
---|
80 | _pppRun = 0;
|
---|
81 | emit newMessage(QByteArray(exc.what().c_str()), true);
|
---|
82 | }
|
---|
83 | }
|
---|
84 |
|
---|
85 | // Constructor
|
---|
86 | ////////////////////////////////////////////////////////////////////////////
|
---|
87 | t_pppRun::t_pppRun(const t_options* opt) {
|
---|
88 | _opt = opt;
|
---|
89 | connect(this, SIGNAL(newMessage(QByteArray,bool)),
|
---|
90 | BNC_CORE, SLOT(slotMessage(const QByteArray,bool)));
|
---|
91 | if (_opt->_realTime) {
|
---|
92 | connect(BNC_CORE->caster(), SIGNAL(newObs(QByteArray, QList<t_obs>)),
|
---|
93 | this, SLOT(slotNewObs(QByteArray, QList<t_obs>)));
|
---|
94 |
|
---|
95 | connect(BNC_CORE, SIGNAL(newEphGPS(gpsephemeris)),
|
---|
96 | this, SLOT(slotNewEphGPS(gpsephemeris)));
|
---|
97 |
|
---|
98 | connect(BNC_CORE, SIGNAL(newEphGlonass(glonassephemeris)),
|
---|
99 | this, SLOT(slotNewEphGlonass(glonassephemeris)));
|
---|
100 |
|
---|
101 | connect(BNC_CORE, SIGNAL(newEphGalileo(galileoephemeris)),
|
---|
102 | this, SLOT(slotNewEphGalileo(galileoephemeris)));
|
---|
103 |
|
---|
104 | connect(BNC_CORE, SIGNAL(newCorrections(QStringList)),
|
---|
105 | this, SLOT(slotNewCorrections(QStringList)));
|
---|
106 |
|
---|
107 | _pppClient = new t_pppClient(_opt);
|
---|
108 | }
|
---|
109 | else {
|
---|
110 | throw pppExcept("t_pppRun: post-processing not yet implemented");
|
---|
111 | }
|
---|
112 | }
|
---|
113 |
|
---|
114 | // Destructor
|
---|
115 | ////////////////////////////////////////////////////////////////////////////
|
---|
116 | t_pppRun::~t_pppRun() {
|
---|
117 | cout << "~t_pppRun" << endl;
|
---|
118 | }
|
---|
119 |
|
---|
120 | //
|
---|
121 | ////////////////////////////////////////////////////////////////////////////
|
---|
122 | void t_pppRun::slotNewEphGPS(gpsephemeris gpseph) {
|
---|
123 | QMutexLocker locker(&_mutex);
|
---|
124 | t_ephGPS eph;
|
---|
125 | eph.set(&gpseph);
|
---|
126 | _pppClient->putEphemeris(&eph);
|
---|
127 | }
|
---|
128 |
|
---|
129 | //
|
---|
130 | ////////////////////////////////////////////////////////////////////////////
|
---|
131 | void t_pppRun::slotNewEphGlonass(glonassephemeris gloeph) {
|
---|
132 | QMutexLocker locker(&_mutex);
|
---|
133 | t_ephGlo eph;
|
---|
134 | eph.set(&gloeph);
|
---|
135 | _pppClient->putEphemeris(&eph);
|
---|
136 | }
|
---|
137 |
|
---|
138 | //
|
---|
139 | ////////////////////////////////////////////////////////////////////////////
|
---|
140 | void t_pppRun::slotNewEphGalileo(galileoephemeris galeph) {
|
---|
141 | QMutexLocker locker(&_mutex);
|
---|
142 | t_ephGal eph;
|
---|
143 | eph.set(&galeph);
|
---|
144 | _pppClient->putEphemeris(&eph);
|
---|
145 | }
|
---|
146 |
|
---|
147 | //
|
---|
148 | ////////////////////////////////////////////////////////////////////////////
|
---|
149 | void t_pppRun::slotNewCorrections(QStringList corrList) {
|
---|
150 | QMutexLocker locker(&_mutex);
|
---|
151 |
|
---|
152 | QStringListIterator it(corrList);
|
---|
153 | while (it.hasNext()) {
|
---|
154 | it.next();
|
---|
155 | }
|
---|
156 |
|
---|
157 | // _pppClient->putOrbCorrections(const std::vector<t_orbCorr*>& corr);
|
---|
158 | // _pppClient->putClkCorrections(const std::vector<t_clkCorr*>& corr);
|
---|
159 | // _pppClient->putBiases(const std::vector<t_satBiases*>& biases);
|
---|
160 | }
|
---|
161 | //
|
---|
162 | ////////////////////////////////////////////////////////////////////////////
|
---|
163 | void t_pppRun::slotNewObs(QByteArray staID, QList<t_obs> obsList) {
|
---|
164 | QMutexLocker locker(&_mutex);
|
---|
165 |
|
---|
166 | if (string(staID.data()) != _opt->_roverName) {
|
---|
167 | return;
|
---|
168 | }
|
---|
169 |
|
---|
170 | // class t_pppObs {
|
---|
171 | // std::string _rnxType2ch;
|
---|
172 | // double _code;
|
---|
173 | // bool _codeValid;
|
---|
174 | // double _phase;
|
---|
175 | // bool _phaseValid;
|
---|
176 | // double _doppler;
|
---|
177 | // bool _dopplerValid;
|
---|
178 | // double _snr;
|
---|
179 | // bool _snrValid;
|
---|
180 | // bool _slip;
|
---|
181 | // int _slipCounter;
|
---|
182 | // int _biasJumpCounter;
|
---|
183 | // };
|
---|
184 | //
|
---|
185 | // class t_pppSatObs {
|
---|
186 | // t_prn _prn;
|
---|
187 | // bncTime _time;
|
---|
188 | // std::vector<t_pppObs> _obs;
|
---|
189 | // };
|
---|
190 |
|
---|
191 | vector<t_pppSatObs*> pppSatObs;
|
---|
192 | QListIterator<t_obs> it(obsList);
|
---|
193 | while (it.hasNext()) {
|
---|
194 | const t_obs& oldObs = it.next();
|
---|
195 | t_pppSatObs* newObs = new t_pppSatObs;
|
---|
196 |
|
---|
197 | newObs->_prn.set(oldObs.satSys, oldObs.satNum);
|
---|
198 | newObs->_time.set(oldObs.GPSWeek, oldObs.GPSWeeks);
|
---|
199 |
|
---|
200 | map<string, t_pppObs*> pppObsMap;
|
---|
201 | for (unsigned iEntry = 0; iEntry < GNSSENTRY_NUMBER; iEntry++) {
|
---|
202 | string hlp(oldObs.rnxStr(iEntry).toAscii().data());
|
---|
203 | if (hlp.length() == 3) {
|
---|
204 | char obsType = hlp[0];
|
---|
205 | string rnxType2ch = hlp.substr(1);
|
---|
206 | if (obsType == 'C' || obsType == 'L') {
|
---|
207 | t_pppObs* pppObs = 0;
|
---|
208 | if (pppObsMap.find(rnxType2ch) == pppObsMap.end()) {
|
---|
209 | pppObs = new t_pppObs();
|
---|
210 | pppObsMap[rnxType2ch] = pppObs;
|
---|
211 | }
|
---|
212 | else {
|
---|
213 | pppObs = pppObsMap[rnxType2ch];
|
---|
214 | }
|
---|
215 | if (obsType == 'C') {
|
---|
216 | pppObs->_code = oldObs._measdata[iEntry];
|
---|
217 | pppObs->_codeValid = true;
|
---|
218 | }
|
---|
219 | else if (obsType == 'L') {
|
---|
220 | pppObs->_phase = oldObs._measdata[iEntry];
|
---|
221 | pppObs->_phaseValid = true;
|
---|
222 | }
|
---|
223 | }
|
---|
224 | }
|
---|
225 | }
|
---|
226 |
|
---|
227 | //// pppSatObs.push_back(newObs);
|
---|
228 | }
|
---|
229 |
|
---|
230 | t_output output;
|
---|
231 | _pppClient->processEpoch(pppSatObs, &output);
|
---|
232 |
|
---|
233 | for (unsigned ii = 0; ii < pppSatObs.size(); ii++) {
|
---|
234 | delete pppSatObs[ii];
|
---|
235 | }
|
---|
236 | pppSatObs.clear();
|
---|
237 |
|
---|
238 | emit newMessage(QByteArray(output._log.c_str()), true);
|
---|
239 | }
|
---|
240 |
|
---|