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_pppRun
|
---|
31 | *
|
---|
32 | * Purpose: Single Real-Time PPP Client
|
---|
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 <sstream>
|
---|
46 | #include <string.h>
|
---|
47 | #include <map>
|
---|
48 |
|
---|
49 | #include "pppRun.h"
|
---|
50 | #include "pppThread.h"
|
---|
51 | #include "bnccore.h"
|
---|
52 | #include "bncephuser.h"
|
---|
53 | #include "bncsettings.h"
|
---|
54 | #include "bncoutf.h"
|
---|
55 | #include "bncsinextro.h"
|
---|
56 | #include "rinex/rnxobsfile.h"
|
---|
57 | #include "rinex/rnxnavfile.h"
|
---|
58 | #include "rinex/corrfile.h"
|
---|
59 | #include "combination/bnccomb.h"
|
---|
60 |
|
---|
61 | using namespace BNC_PPP;
|
---|
62 | using namespace std;
|
---|
63 |
|
---|
64 | // Constructor
|
---|
65 | ////////////////////////////////////////////////////////////////////////////
|
---|
66 | t_pppRun::t_pppRun(const t_pppOptions* opt) {
|
---|
67 |
|
---|
68 | _opt = opt;
|
---|
69 |
|
---|
70 | connect(this, SIGNAL(newMessage(QByteArray,bool)),
|
---|
71 | BNC_CORE, SLOT(slotMessage(const QByteArray,bool)));
|
---|
72 |
|
---|
73 | connect(this, SIGNAL(newPosition(QByteArray, bncTime, QVector<double>)),
|
---|
74 | BNC_CORE, SIGNAL(newPosition(QByteArray, bncTime, QVector<double>)));
|
---|
75 |
|
---|
76 | connect(this, SIGNAL(newNMEAstr(QByteArray, QByteArray)),
|
---|
77 | BNC_CORE, SIGNAL(newNMEAstr(QByteArray, QByteArray)));
|
---|
78 |
|
---|
79 | _pppClient = new t_pppClient(_opt);
|
---|
80 |
|
---|
81 | bncSettings settings;
|
---|
82 |
|
---|
83 | if (_opt->_realTime) {
|
---|
84 | Qt::ConnectionType conType = Qt::AutoConnection;
|
---|
85 | if (BNC_CORE->mode() == t_bncCore::batchPostProcessing) {
|
---|
86 | conType = Qt::BlockingQueuedConnection;
|
---|
87 | }
|
---|
88 |
|
---|
89 | connect(BNC_CORE->caster(), SIGNAL(newObs(QByteArray, QList<t_satObs>)),
|
---|
90 | this, SLOT(slotNewObs(QByteArray, QList<t_satObs>)),conType);
|
---|
91 |
|
---|
92 | connect(BNC_CORE, SIGNAL(newGPSEph(t_ephGPS)),
|
---|
93 | this, SLOT(slotNewGPSEph(t_ephGPS)),conType);
|
---|
94 |
|
---|
95 | connect(BNC_CORE, SIGNAL(newGlonassEph(t_ephGlo)),
|
---|
96 | this, SLOT(slotNewGlonassEph(t_ephGlo)),conType);
|
---|
97 |
|
---|
98 | connect(BNC_CORE, SIGNAL(newGalileoEph(t_ephGal)),
|
---|
99 | this, SLOT(slotNewGalileoEph(t_ephGal)),conType);
|
---|
100 |
|
---|
101 | connect(BNC_CORE, SIGNAL(newBDSEph(t_ephBDS)),
|
---|
102 | this, SLOT(slotNewBDSEph(t_ephBDS)),conType);
|
---|
103 |
|
---|
104 | connect(BNC_CORE, SIGNAL(newTec(t_vTec)),
|
---|
105 | this, SLOT(slotNewTec(t_vTec)),conType);
|
---|
106 |
|
---|
107 | connect(BNC_CORE, SIGNAL(newOrbCorrections(QList<t_orbCorr>)),
|
---|
108 | this, SLOT(slotNewOrbCorrections(QList<t_orbCorr>)),conType);
|
---|
109 |
|
---|
110 | connect(BNC_CORE, SIGNAL(newClkCorrections(QList<t_clkCorr>)),
|
---|
111 | this, SLOT(slotNewClkCorrections(QList<t_clkCorr>)),conType);
|
---|
112 |
|
---|
113 | connect(BNC_CORE, SIGNAL(newCodeBiases(QList<t_satCodeBias>)),
|
---|
114 | this, SLOT(slotNewCodeBiases(QList<t_satCodeBias>)),conType);
|
---|
115 |
|
---|
116 | connect(BNC_CORE, SIGNAL(newPhaseBiases(QList<t_satPhaseBias>)),
|
---|
117 | this, SLOT(slotNewPhaseBiases(QList<t_satPhaseBias>)),conType);
|
---|
118 |
|
---|
119 | connect(BNC_CMB, SIGNAL(newOrbCorrections(QList<t_orbCorr>)),
|
---|
120 | this, SLOT(slotNewOrbCorrections(QList<t_orbCorr>)),conType);
|
---|
121 |
|
---|
122 | connect(BNC_CMB, SIGNAL(newClkCorrections(QList<t_clkCorr>)),
|
---|
123 | this, SLOT(slotNewClkCorrections(QList<t_clkCorr>)),conType);
|
---|
124 | }
|
---|
125 | else {
|
---|
126 | _rnxObsFile = 0;
|
---|
127 | _rnxNavFile = 0;
|
---|
128 | _corrFile = 0;
|
---|
129 | _speed = settings.value("PPP/mapSpeedSlider").toInt();
|
---|
130 | connect(this, SIGNAL(progressRnxPPP(int)), BNC_CORE, SIGNAL(progressRnxPPP(int)));
|
---|
131 | connect(this, SIGNAL(finishedRnxPPP()), BNC_CORE, SIGNAL(finishedRnxPPP()));
|
---|
132 | connect(BNC_CORE, SIGNAL(mapSpeedSliderChanged(int)),
|
---|
133 | this, SLOT(slotSetSpeed(int)));
|
---|
134 | connect(BNC_CORE, SIGNAL(stopRinexPPP()), this, SLOT(slotSetStopFlag()));
|
---|
135 | }
|
---|
136 |
|
---|
137 | _stopFlag = false;
|
---|
138 |
|
---|
139 | QString roverName(_opt->_roverName.c_str()), fullRoverName("");
|
---|
140 | QString country;
|
---|
141 | QString monNum = "0";
|
---|
142 | QString recNum = "0";
|
---|
143 | QString intr = "1 day";
|
---|
144 | int sampl = 0;
|
---|
145 | QListIterator<QString> it(settings.value("mountPoints").toStringList());
|
---|
146 | while (it.hasNext()) {
|
---|
147 | QStringList hlp = it.next().split(" ");
|
---|
148 | if (hlp.size() < 7)
|
---|
149 | continue;
|
---|
150 | if (hlp.join(" ").indexOf(roverName, 0) != -1) {
|
---|
151 | country = hlp[2];
|
---|
152 | }
|
---|
153 | }
|
---|
154 | fullRoverName = roverName.left(4) +
|
---|
155 | QString("%1").arg(monNum, 1, 10) +
|
---|
156 | QString("%1").arg(recNum, 1, 10) +
|
---|
157 | country;
|
---|
158 |
|
---|
159 | bool v3filenames = settings.value("PPP/v3filenames").toBool();
|
---|
160 | QString logFileSkl = settings.value("PPP/logPath").toString();
|
---|
161 | int l = logFileSkl.length();
|
---|
162 | if (logFileSkl.isEmpty()) {
|
---|
163 | _logFile = 0;
|
---|
164 | }
|
---|
165 | else {
|
---|
166 | if (l && logFileSkl[l-1] != QDir::separator() ) {
|
---|
167 | logFileSkl += QDir::separator();
|
---|
168 | }
|
---|
169 | if (v3filenames) {
|
---|
170 | logFileSkl = logFileSkl + fullRoverName + "${V3}" + ".ppp";
|
---|
171 | }
|
---|
172 | else {
|
---|
173 | logFileSkl = logFileSkl + roverName.left(4) + "${GPSWD}" + ".ppp";
|
---|
174 | }
|
---|
175 | _logFile = new bncoutf(logFileSkl, intr, sampl);
|
---|
176 | }
|
---|
177 |
|
---|
178 | QString nmeaFileSkl = settings.value("PPP/nmeaPath").toString();
|
---|
179 | l = nmeaFileSkl.length();
|
---|
180 | if (nmeaFileSkl.isEmpty()) {
|
---|
181 | _nmeaFile = 0;
|
---|
182 | }
|
---|
183 | else {
|
---|
184 | if (l > 0 && nmeaFileSkl[l-1] != QDir::separator() ) {
|
---|
185 | nmeaFileSkl += QDir::separator();
|
---|
186 | }
|
---|
187 | if (v3filenames) {
|
---|
188 | nmeaFileSkl = nmeaFileSkl + fullRoverName + "${V3}" + ".nmea";
|
---|
189 | }
|
---|
190 | else {
|
---|
191 | nmeaFileSkl = nmeaFileSkl + roverName.left(4) + "${GPSWD}" + ".nmea";
|
---|
192 | }
|
---|
193 | _nmeaFile = new bncoutf(nmeaFileSkl, intr, sampl);
|
---|
194 | }
|
---|
195 |
|
---|
196 | QString snxtroFileSkl = settings.value("PPP/snxtroPath").toString();
|
---|
197 | l = snxtroFileSkl.length();
|
---|
198 | if (snxtroFileSkl.isEmpty()) {
|
---|
199 | _snxtroFile = 0;
|
---|
200 | }
|
---|
201 | else {
|
---|
202 | if (l > 0 && snxtroFileSkl[l-1] != QDir::separator() ) {
|
---|
203 | snxtroFileSkl += QDir::separator();
|
---|
204 | }
|
---|
205 | if (v3filenames) {
|
---|
206 | snxtroFileSkl = snxtroFileSkl + fullRoverName + "${V3}" + ".tra";
|
---|
207 | }
|
---|
208 | else {
|
---|
209 | snxtroFileSkl = snxtroFileSkl + roverName.left(4) + "${GPSWD}" + ".tro";
|
---|
210 | }
|
---|
211 | sampl = settings.value("PPP/snxtroSampl").toInt();
|
---|
212 | intr = settings.value("PPP/snxtroIntr").toString();
|
---|
213 | _snxtroFile = new bncSinexTro(_opt, snxtroFileSkl, intr, sampl);
|
---|
214 | }
|
---|
215 | }
|
---|
216 |
|
---|
217 |
|
---|
218 |
|
---|
219 | // Destructor
|
---|
220 | ////////////////////////////////////////////////////////////////////////////
|
---|
221 | t_pppRun::~t_pppRun() {
|
---|
222 | delete _logFile;
|
---|
223 | delete _nmeaFile;
|
---|
224 | delete _snxtroFile;
|
---|
225 | delete _pppClient;
|
---|
226 | }
|
---|
227 |
|
---|
228 | //
|
---|
229 | ////////////////////////////////////////////////////////////////////////////
|
---|
230 | void t_pppRun::slotNewGPSEph(t_ephGPS eph) {
|
---|
231 | QMutexLocker locker(&_mutex);
|
---|
232 | _pppClient->putEphemeris(&eph);
|
---|
233 | }
|
---|
234 |
|
---|
235 | //
|
---|
236 | ////////////////////////////////////////////////////////////////////////////
|
---|
237 | void t_pppRun::slotNewGlonassEph(t_ephGlo eph) {
|
---|
238 | QMutexLocker locker(&_mutex);
|
---|
239 | _pppClient->putEphemeris(&eph);
|
---|
240 | }
|
---|
241 |
|
---|
242 | //
|
---|
243 | ////////////////////////////////////////////////////////////////////////////
|
---|
244 | void t_pppRun::slotNewGalileoEph(t_ephGal eph) {
|
---|
245 | QMutexLocker locker(&_mutex);
|
---|
246 | _pppClient->putEphemeris(&eph);
|
---|
247 | }
|
---|
248 |
|
---|
249 | //
|
---|
250 | ////////////////////////////////////////////////////////////////////////////
|
---|
251 | void t_pppRun::slotNewBDSEph(t_ephBDS eph) {
|
---|
252 | QMutexLocker locker(&_mutex);
|
---|
253 | _pppClient->putEphemeris(&eph);
|
---|
254 | }
|
---|
255 |
|
---|
256 | //
|
---|
257 | ////////////////////////////////////////////////////////////////////////////
|
---|
258 | void t_pppRun::slotNewObs(QByteArray staID, QList<t_satObs> obsList) {
|
---|
259 | QMutexLocker locker(&_mutex);
|
---|
260 |
|
---|
261 | if (string(staID.data()) != _opt->_roverName) {
|
---|
262 | return;
|
---|
263 | }
|
---|
264 |
|
---|
265 | // Loop over all observations (possible different epochs)
|
---|
266 | // -----------------------------------------------------
|
---|
267 | QListIterator<t_satObs> it(obsList);
|
---|
268 | while (it.hasNext()) {
|
---|
269 | const t_satObs& oldObs = it.next();
|
---|
270 | t_satObs* newObs = new t_satObs(oldObs);
|
---|
271 |
|
---|
272 | // Find the corresponding data epoch or create a new one
|
---|
273 | // -----------------------------------------------------
|
---|
274 | t_epoData* epoch = 0;
|
---|
275 | deque<t_epoData*>::const_iterator it;
|
---|
276 | for (it = _epoData.begin(); it != _epoData.end(); it++) {
|
---|
277 | if (newObs->_time == (*it)->_time) {
|
---|
278 | epoch = *it;
|
---|
279 | break;
|
---|
280 | }
|
---|
281 | }
|
---|
282 | if (epoch == 0) {
|
---|
283 | if (_epoData.empty() || newObs->_time > _epoData.back()->_time) {
|
---|
284 | epoch = new t_epoData;
|
---|
285 | epoch->_time = newObs->_time;
|
---|
286 | _epoData.push_back(epoch);
|
---|
287 | }
|
---|
288 | }
|
---|
289 |
|
---|
290 | // Put data into the epoch
|
---|
291 | // -----------------------
|
---|
292 | if (epoch != 0) {
|
---|
293 | epoch->_satObs.push_back(newObs);
|
---|
294 | }
|
---|
295 | else {
|
---|
296 | delete newObs;
|
---|
297 | }
|
---|
298 | }
|
---|
299 |
|
---|
300 | // Process the oldest epochs
|
---|
301 | // ------------------------
|
---|
302 | while (_epoData.size() && !waitForCorr(_epoData.front()->_time)) {
|
---|
303 |
|
---|
304 | const vector<t_satObs*>& satObs = _epoData.front()->_satObs;
|
---|
305 |
|
---|
306 | t_output output;
|
---|
307 | _pppClient->processEpoch(satObs, &output);
|
---|
308 |
|
---|
309 | if (!output._error) {
|
---|
310 | QVector<double> xx(6);
|
---|
311 | xx.data()[0] = output._xyzRover[0];
|
---|
312 | xx.data()[1] = output._xyzRover[1];
|
---|
313 | xx.data()[2] = output._xyzRover[2];
|
---|
314 | xx.data()[3] = output._neu[0];
|
---|
315 | xx.data()[4] = output._neu[1];
|
---|
316 | xx.data()[5] = output._neu[2];
|
---|
317 | emit newPosition(staID, output._epoTime, xx);
|
---|
318 | }
|
---|
319 |
|
---|
320 | delete _epoData.front(); _epoData.pop_front();
|
---|
321 |
|
---|
322 | ostringstream log;
|
---|
323 | if (output._error) {
|
---|
324 | log << output._log;
|
---|
325 | }
|
---|
326 | else {
|
---|
327 | log.setf(ios::fixed);
|
---|
328 | log << string(output._epoTime) << ' ' << staID.data()
|
---|
329 | << " X = " << setprecision(4) << output._xyzRover[0]
|
---|
330 | << " Y = " << setprecision(4) << output._xyzRover[1]
|
---|
331 | << " Z = " << setprecision(4) << output._xyzRover[2]
|
---|
332 | << " NEU: " << showpos << setw(8) << setprecision(4) << output._neu[0]
|
---|
333 | << " " << showpos << setw(8) << setprecision(4) << output._neu[1]
|
---|
334 | << " " << showpos << setw(8) << setprecision(4) << output._neu[2]
|
---|
335 | << " TRP: " << showpos << setw(8) << setprecision(4) << output._trp0
|
---|
336 | << " " << showpos << setw(8) << setprecision(4) << output._trp;
|
---|
337 | }
|
---|
338 |
|
---|
339 | if (_logFile && output._epoTime.valid()) {
|
---|
340 | _logFile->write(output._epoTime.gpsw(), output._epoTime.gpssec(),
|
---|
341 | QString(output._log.c_str()));
|
---|
342 | }
|
---|
343 |
|
---|
344 | if (!output._error) {
|
---|
345 | QString rmcStr = nmeaString('R', output);
|
---|
346 | QString ggaStr = nmeaString('G', output);
|
---|
347 | if (_nmeaFile) {
|
---|
348 | _nmeaFile->write(output._epoTime.gpsw(), output._epoTime.gpssec(), rmcStr);
|
---|
349 | _nmeaFile->write(output._epoTime.gpsw(), output._epoTime.gpssec(), ggaStr);
|
---|
350 | }
|
---|
351 | emit newNMEAstr(staID, rmcStr.toAscii());
|
---|
352 | emit newNMEAstr(staID, ggaStr.toAscii());
|
---|
353 | }
|
---|
354 |
|
---|
355 | if (_snxtroFile && output._epoTime.valid()) {
|
---|
356 | _snxtroFile->write(staID, int(output._epoTime.gpsw()), output._epoTime.gpssec(),
|
---|
357 | output._trp0 + output._trp, output._trpStdev);
|
---|
358 | }
|
---|
359 |
|
---|
360 | emit newMessage(QByteArray(log.str().c_str()), true);
|
---|
361 | }
|
---|
362 | }
|
---|
363 |
|
---|
364 | //
|
---|
365 | ////////////////////////////////////////////////////////////////////////////
|
---|
366 | void t_pppRun::slotNewTec(t_vTec vTec) {
|
---|
367 | if (vTec._layers.size() == 0) {
|
---|
368 | return;
|
---|
369 | }
|
---|
370 |
|
---|
371 | if (_opt->_realTime) {
|
---|
372 | if (_opt->_corrMount.empty() || _opt->_corrMount != vTec._staID) {
|
---|
373 | return;
|
---|
374 | }
|
---|
375 | }
|
---|
376 |
|
---|
377 | _pppClient->putTec(&vTec);
|
---|
378 | }
|
---|
379 |
|
---|
380 | //
|
---|
381 | ////////////////////////////////////////////////////////////////////////////
|
---|
382 | void t_pppRun::slotNewOrbCorrections(QList<t_orbCorr> orbCorr) {
|
---|
383 | if (orbCorr.size() == 0) {
|
---|
384 | return;
|
---|
385 | }
|
---|
386 |
|
---|
387 | if (_opt->_realTime) {
|
---|
388 | if (_opt->_corrMount.empty() || _opt->_corrMount != orbCorr[0]._staID) {
|
---|
389 | return;
|
---|
390 | }
|
---|
391 | }
|
---|
392 | vector<t_orbCorr*> corrections;
|
---|
393 | for (int ii = 0; ii < orbCorr.size(); ii++) {
|
---|
394 | corrections.push_back(new t_orbCorr(orbCorr[ii]));
|
---|
395 | }
|
---|
396 |
|
---|
397 | _pppClient->putOrbCorrections(corrections);
|
---|
398 |
|
---|
399 | for (unsigned ii = 0; ii < corrections.size(); ii++) {
|
---|
400 | delete corrections[ii];
|
---|
401 | }
|
---|
402 | }
|
---|
403 |
|
---|
404 | //
|
---|
405 | ////////////////////////////////////////////////////////////////////////////
|
---|
406 | void t_pppRun::slotNewClkCorrections(QList<t_clkCorr> clkCorr) {
|
---|
407 | if (clkCorr.size() == 0) {
|
---|
408 | return;
|
---|
409 | }
|
---|
410 |
|
---|
411 | if (_opt->_realTime) {
|
---|
412 | if (_opt->_corrMount.empty() || _opt->_corrMount != clkCorr[0]._staID) {
|
---|
413 | return;
|
---|
414 | }
|
---|
415 | }
|
---|
416 | vector<t_clkCorr*> corrections;
|
---|
417 | for (int ii = 0; ii < clkCorr.size(); ii++) {
|
---|
418 | corrections.push_back(new t_clkCorr(clkCorr[ii]));
|
---|
419 | _lastClkCorrTime = clkCorr[ii]._time;
|
---|
420 | }
|
---|
421 | _pppClient->putClkCorrections(corrections);
|
---|
422 |
|
---|
423 | for (unsigned ii = 0; ii < corrections.size(); ii++) {
|
---|
424 | delete corrections[ii];
|
---|
425 | }
|
---|
426 | }
|
---|
427 |
|
---|
428 | //
|
---|
429 | ////////////////////////////////////////////////////////////////////////////
|
---|
430 | void t_pppRun::slotNewCodeBiases(QList<t_satCodeBias> codeBiases) {
|
---|
431 | if (codeBiases.size() == 0) {
|
---|
432 | return;
|
---|
433 | }
|
---|
434 |
|
---|
435 | if (_opt->_realTime) {
|
---|
436 | if (_opt->_corrMount.empty() || _opt->_corrMount != codeBiases[0]._staID) {
|
---|
437 | return;
|
---|
438 | }
|
---|
439 | }
|
---|
440 | vector<t_satCodeBias*> biases;
|
---|
441 | for (int ii = 0; ii < codeBiases.size(); ii++) {
|
---|
442 | biases.push_back(new t_satCodeBias(codeBiases[ii]));
|
---|
443 | }
|
---|
444 |
|
---|
445 | _pppClient->putCodeBiases(biases);
|
---|
446 |
|
---|
447 | for (unsigned ii = 0; ii < biases.size(); ii++) {
|
---|
448 | delete biases[ii];
|
---|
449 | }
|
---|
450 | }
|
---|
451 |
|
---|
452 | //
|
---|
453 | ////////////////////////////////////////////////////////////////////////////
|
---|
454 | void t_pppRun::slotNewPhaseBiases(QList<t_satPhaseBias> phaseBiases) {
|
---|
455 | if (phaseBiases.size() == 0) {
|
---|
456 | return;
|
---|
457 | }
|
---|
458 |
|
---|
459 | if (_opt->_realTime) {
|
---|
460 | if (_opt->_corrMount.empty() || _opt->_corrMount != phaseBiases[0]._staID) {
|
---|
461 | return;
|
---|
462 | }
|
---|
463 | }
|
---|
464 | vector<t_satPhaseBias*> biases;
|
---|
465 | for (int ii = 0; ii < phaseBiases.size(); ii++) {
|
---|
466 | biases.push_back(new t_satPhaseBias(phaseBiases[ii]));
|
---|
467 | }
|
---|
468 |
|
---|
469 | _pppClient->putPhaseBiases(biases);
|
---|
470 |
|
---|
471 | for (unsigned ii = 0; ii < biases.size(); ii++) {
|
---|
472 | delete biases[ii];
|
---|
473 | }
|
---|
474 | }
|
---|
475 |
|
---|
476 | //
|
---|
477 | ////////////////////////////////////////////////////////////////////////////
|
---|
478 | void t_pppRun::processFiles() {
|
---|
479 |
|
---|
480 | try {
|
---|
481 | _rnxObsFile = new t_rnxObsFile(QString(_opt->_rinexObs.c_str()), t_rnxObsFile::input);
|
---|
482 | }
|
---|
483 | catch (...) {
|
---|
484 | delete _rnxObsFile; _rnxObsFile = 0;
|
---|
485 | emit finishedRnxPPP();
|
---|
486 | return;
|
---|
487 | }
|
---|
488 |
|
---|
489 | _rnxNavFile = new t_rnxNavFile(QString(_opt->_rinexNav.c_str()), t_rnxNavFile::input);
|
---|
490 |
|
---|
491 | if (!_opt->_corrFile.empty()) {
|
---|
492 | _corrFile = new t_corrFile(QString(_opt->_corrFile.c_str()));
|
---|
493 | connect(_corrFile, SIGNAL(newTec(t_vTec)),
|
---|
494 | this, SLOT(slotNewTec(t_vTec)));
|
---|
495 | connect(_corrFile, SIGNAL(newOrbCorrections(QList<t_orbCorr>)),
|
---|
496 | this, SLOT(slotNewOrbCorrections(QList<t_orbCorr>)));
|
---|
497 | connect(_corrFile, SIGNAL(newClkCorrections(QList<t_clkCorr>)),
|
---|
498 | this, SLOT(slotNewClkCorrections(QList<t_clkCorr>)));
|
---|
499 | connect(_corrFile, SIGNAL(newCodeBiases(QList<t_satCodeBias>)),
|
---|
500 | this, SLOT(slotNewCodeBiases(QList<t_satCodeBias>)));
|
---|
501 | connect(_corrFile, SIGNAL(newPhaseBiases(QList<t_satPhaseBias>)),
|
---|
502 | this, SLOT(slotNewPhaseBiases(QList<t_satPhaseBias>)));
|
---|
503 | }
|
---|
504 |
|
---|
505 | // Read/Process Observations
|
---|
506 | // -------------------------
|
---|
507 | int nEpo = 0;
|
---|
508 | const t_rnxObsFile::t_rnxEpo* epo = 0;
|
---|
509 | while ( !_stopFlag && (epo = _rnxObsFile->nextEpoch()) != 0 ) {
|
---|
510 | ++nEpo;
|
---|
511 |
|
---|
512 | if (_speed < 100) {
|
---|
513 | double sleepTime = 2.0 / _speed;
|
---|
514 | t_pppThread::msleep(int(sleepTime*1.e3));
|
---|
515 | }
|
---|
516 |
|
---|
517 | // Get Corrections
|
---|
518 | // ---------------
|
---|
519 | if (_corrFile) {
|
---|
520 | try {
|
---|
521 | _corrFile->syncRead(epo->tt);
|
---|
522 | }
|
---|
523 | catch (const char* msg) {
|
---|
524 | emit newMessage(QByteArray(msg), true);
|
---|
525 | break;
|
---|
526 | }
|
---|
527 | catch (const string& msg) {
|
---|
528 | emit newMessage(QByteArray(msg.c_str()), true);
|
---|
529 | break;
|
---|
530 | }
|
---|
531 | catch (...) {
|
---|
532 | emit newMessage("unknown exceptions in corrFile", true);
|
---|
533 | break;
|
---|
534 | }
|
---|
535 | }
|
---|
536 |
|
---|
537 | // Get Ephemerides
|
---|
538 | // ----------------
|
---|
539 | t_eph* eph = 0;
|
---|
540 | const QMap<QString, unsigned int>* corrIODs = _corrFile ? &_corrFile->corrIODs() : 0;
|
---|
541 | while ( (eph = _rnxNavFile->getNextEph(epo->tt, corrIODs)) != 0 ) {
|
---|
542 | _pppClient->putEphemeris(eph);
|
---|
543 | delete eph; eph = 0;
|
---|
544 | }
|
---|
545 |
|
---|
546 | // Create list of observations and start epoch processing
|
---|
547 | // ------------------------------------------------------
|
---|
548 | QList<t_satObs> obsList;
|
---|
549 | for (unsigned iObs = 0; iObs < epo->rnxSat.size(); iObs++) {
|
---|
550 | const t_rnxObsFile::t_rnxSat& rnxSat = epo->rnxSat[iObs];
|
---|
551 |
|
---|
552 | t_satObs obs;
|
---|
553 | t_rnxObsFile::setObsFromRnx(_rnxObsFile, epo, rnxSat, obs);
|
---|
554 | obsList << obs;
|
---|
555 | }
|
---|
556 | slotNewObs(QByteArray(_opt->_roverName.c_str()), obsList);
|
---|
557 |
|
---|
558 |
|
---|
559 | if (nEpo % 10 == 0) {
|
---|
560 | emit progressRnxPPP(nEpo);
|
---|
561 | }
|
---|
562 |
|
---|
563 | QCoreApplication::processEvents();
|
---|
564 | }
|
---|
565 |
|
---|
566 | emit finishedRnxPPP();
|
---|
567 |
|
---|
568 | if (BNC_CORE->mode() != t_bncCore::interactive) {
|
---|
569 | qApp->exit(0);
|
---|
570 | }
|
---|
571 | else {
|
---|
572 | BNC_CORE->stopPPP();
|
---|
573 | }
|
---|
574 | }
|
---|
575 |
|
---|
576 | //
|
---|
577 | ////////////////////////////////////////////////////////////////////////////
|
---|
578 | void t_pppRun::slotSetSpeed(int speed) {
|
---|
579 | QMutexLocker locker(&_mutex);
|
---|
580 | _speed = speed;
|
---|
581 | }
|
---|
582 |
|
---|
583 | //
|
---|
584 | ////////////////////////////////////////////////////////////////////////////
|
---|
585 | void t_pppRun::slotSetStopFlag() {
|
---|
586 | QMutexLocker locker(&_mutex);
|
---|
587 | _stopFlag = true;
|
---|
588 | }
|
---|
589 |
|
---|
590 | //
|
---|
591 | ////////////////////////////////////////////////////////////////////////////
|
---|
592 | QString t_pppRun::nmeaString(char strType, const t_output& output) {
|
---|
593 |
|
---|
594 | double ell[3];
|
---|
595 | xyz2ell(output._xyzRover, ell);
|
---|
596 | double phiDeg = ell[0] * 180 / M_PI;
|
---|
597 | double lamDeg = ell[1] * 180 / M_PI;
|
---|
598 |
|
---|
599 | char phiCh = 'N';
|
---|
600 | if (phiDeg < 0) {
|
---|
601 | phiDeg = -phiDeg;
|
---|
602 | phiCh = 'S';
|
---|
603 | }
|
---|
604 | char lamCh = 'E';
|
---|
605 | if (lamDeg < 0) {
|
---|
606 | lamDeg = -lamDeg;
|
---|
607 | lamCh = 'W';
|
---|
608 | }
|
---|
609 |
|
---|
610 | ostringstream out;
|
---|
611 | out.setf(ios::fixed);
|
---|
612 |
|
---|
613 | if (strType == 'R') {
|
---|
614 | string datestr = output._epoTime.datestr(0); // yyyymmdd
|
---|
615 | out << "GPRMC,"
|
---|
616 | << output._epoTime.timestr(0,0) << ",A,"
|
---|
617 | << setw(2) << setfill('0') << int(phiDeg)
|
---|
618 | << setw(6) << setprecision(3) << setfill('0')
|
---|
619 | << fmod(60*phiDeg,60) << ',' << phiCh << ','
|
---|
620 | << setw(3) << setfill('0') << int(lamDeg)
|
---|
621 | << setw(6) << setprecision(3) << setfill('0')
|
---|
622 | << fmod(60*lamDeg,60) << ',' << lamCh << ",,,"
|
---|
623 | << datestr[6] << datestr[7] << datestr[4] << datestr[5]
|
---|
624 | << datestr[2] << datestr[3] << ",,";
|
---|
625 | }
|
---|
626 | else if (strType == 'G') {
|
---|
627 | out << "GPGGA,"
|
---|
628 | << output._epoTime.timestr(0,0) << ','
|
---|
629 | << setw(2) << setfill('0') << int(phiDeg)
|
---|
630 | << setw(10) << setprecision(7) << setfill('0')
|
---|
631 | << fmod(60*phiDeg,60) << ',' << phiCh << ','
|
---|
632 | << setw(3) << setfill('0') << int(lamDeg)
|
---|
633 | << setw(10) << setprecision(7) << setfill('0')
|
---|
634 | << fmod(60*lamDeg,60) << ',' << lamCh
|
---|
635 | << ",1," << setw(2) << setfill('0') << output._numSat << ','
|
---|
636 | << setw(3) << setprecision(1) << output._pDop << ','
|
---|
637 | << setprecision(3) << ell[2] << ",M,0.0,M,,";
|
---|
638 | }
|
---|
639 | else {
|
---|
640 | return "";
|
---|
641 | }
|
---|
642 |
|
---|
643 | QString nmStr(out.str().c_str());
|
---|
644 | unsigned char XOR = 0;
|
---|
645 | for (int ii = 0; ii < nmStr.length(); ii++) {
|
---|
646 | XOR ^= (unsigned char) nmStr[ii].toAscii();
|
---|
647 | }
|
---|
648 |
|
---|
649 | return '$' + nmStr + QString("*%1\n").arg(int(XOR), 0, 16).toUpper();
|
---|
650 | }
|
---|
651 |
|
---|
652 | //
|
---|
653 | ////////////////////////////////////////////////////////////////////////////
|
---|
654 | bool t_pppRun::waitForCorr(const bncTime& epoTime) const {
|
---|
655 |
|
---|
656 | if (!_opt->_realTime || _opt->_corrMount.empty()) {
|
---|
657 | return false;
|
---|
658 | }
|
---|
659 | else if (!_lastClkCorrTime.valid()) {
|
---|
660 | return true;
|
---|
661 | }
|
---|
662 | else {
|
---|
663 | double dt = epoTime - _lastClkCorrTime;
|
---|
664 | if (dt > 1.0 && dt < _opt->_corrWaitTime) {
|
---|
665 | return true;
|
---|
666 | }
|
---|
667 | else {
|
---|
668 | return false;
|
---|
669 | }
|
---|
670 | }
|
---|
671 | return false;
|
---|
672 | }
|
---|