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