source: ntrip/trunk/BNC/src/pppRun.cpp@ 9622

Last change on this file since 9622 was 9622, checked in by stuerze, 5 months ago

bug fixed

File size: 22.2 KB
Line 
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
61using namespace BNC_PPP;
62using namespace std;
63
64// Constructor
65////////////////////////////////////////////////////////////////////////////
66t_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 connect(BNC_CORE, SIGNAL(providerIDChanged(QString)),
126 this, SLOT(slotProviderIDChanged(QString)));
127 }
128 else {
129 _rnxObsFile = 0;
130 _rnxNavFile = 0;
131 _corrFile = 0;
132 _ionoFile = 0;
133 _speed = settings.value("PPP/mapSpeedSlider").toInt();
134 connect(this, SIGNAL(progressRnxPPP(int)), BNC_CORE, SIGNAL(progressRnxPPP(int)));
135 connect(this, SIGNAL(finishedRnxPPP()), BNC_CORE, SIGNAL(finishedRnxPPP()));
136 connect(BNC_CORE, SIGNAL(mapSpeedSliderChanged(int)),
137 this, SLOT(slotSetSpeed(int)));
138 connect(BNC_CORE, SIGNAL(stopRinexPPP()), this, SLOT(slotSetStopFlag()));
139 }
140
141 _stopFlag = false;
142
143 QString roverName(_opt->_roverName.c_str());
144 QString country;
145 QString monNum = "0";
146 QString recNum = "0";
147 if (roverName.length() >= 9) {
148 monNum = QChar(roverName[4]);
149 recNum = QChar(roverName[5]);
150 }
151 QString intr = "1 day";
152 int sampl = 0;
153 QString distStr;
154 int num = 0;
155 int statIDlength = roverName.size() -1;
156 QString ID4 = roverName.left(4);
157 QString ID9 = roverName.left(9);
158 ID4 = ID4.toUpper();
159 ID4 = ID9.toUpper();
160 QListIterator<QString> it(settings.value("mountPoints").toStringList());
161 while (it.hasNext()) {
162 QString mp = it.next();
163 if (mp.indexOf(roverName.left(statIDlength)) != -1) {
164 ++num;
165 }
166 QStringList hlp = mp.split(" ");
167 if (hlp.size() < 7)
168 continue;
169 if (hlp.join(" ").indexOf(roverName, 0) != -1) {
170 country = hlp[2];
171 }
172 }
173
174 if (num > 1) {
175 distStr = "." + roverName.right(1);
176 }
177
178 if (ID9.size() < 9) {
179 ID9 = ID4
180 + QString("%1").arg(monNum, 1, 10)
181 + QString("%1").arg(recNum, 1, 10)
182 + country;
183 }
184 bool v2filenames = settings.value("PPP/v2filenames").toBool();
185 QString logFileSkl = settings.value("PPP/logPath").toString();
186 int l = logFileSkl.length();
187 if (logFileSkl.isEmpty()) {
188 _logFile = 0;
189 }
190 else {
191 if (l && logFileSkl[l-1] != QDir::separator() ) {
192 logFileSkl += QDir::separator();
193 }
194 if (!v2filenames) {
195 logFileSkl = logFileSkl + ID9 + "${V3PROD}" + distStr + ".ppp";
196 }
197 else {
198 logFileSkl = logFileSkl + ID4 + "${GPSWD}" + distStr + ".ppp";
199 }
200 _logFile = new bncoutf(logFileSkl, intr, sampl);
201 }
202
203 QString nmeaFileSkl = settings.value("PPP/nmeaPath").toString();
204 l = nmeaFileSkl.length();
205 if (nmeaFileSkl.isEmpty()) {
206 _nmeaFile = 0;
207 }
208 else {
209 if (l > 0 && nmeaFileSkl[l-1] != QDir::separator() ) {
210 nmeaFileSkl += QDir::separator();
211 }
212 if (!v2filenames) {
213 nmeaFileSkl = nmeaFileSkl + ID9 + "${V3PROD}" + distStr + ".nmea";
214 }
215 else {
216 nmeaFileSkl = nmeaFileSkl + ID4 + "${GPSWD}" + distStr + ".nmea";
217 }
218 _nmeaFile = new bncoutf(nmeaFileSkl, intr, sampl);
219 }
220 QString snxtroFileSkl = settings.value("PPP/snxtroPath").toString();
221 l = snxtroFileSkl.length();
222 if (snxtroFileSkl.isEmpty()) {
223 _snxtroFile = 0;
224 }
225 else {
226 if (l > 0 && snxtroFileSkl[l-1] != QDir::separator() ) {
227 snxtroFileSkl += QDir::separator();
228 }
229 if (!v2filenames) {
230 snxtroFileSkl = snxtroFileSkl + ID9 + "${V3PROD}" + distStr + ".tra";
231 }
232 else {
233 snxtroFileSkl = snxtroFileSkl + ID4 + "${GPSWD}" + distStr + ".tro";
234 }
235 sampl = settings.value("PPP/snxtroSampl").toString().split("sec").first().toInt();
236 intr = settings.value("PPP/snxtroIntr").toString();
237 _snxtroFile = new bncSinexTro(_opt, snxtroFileSkl, intr, sampl);
238 }
239}
240
241
242
243// Destructor
244////////////////////////////////////////////////////////////////////////////
245t_pppRun::~t_pppRun() {
246 delete _logFile;
247 delete _nmeaFile;
248 delete _snxtroFile;
249 while (!_epoData.empty()) {
250 delete _epoData.front();
251 _epoData.pop_front();
252 }
253}
254
255//
256////////////////////////////////////////////////////////////////////////////
257void t_pppRun::slotNewGPSEph(t_ephGPS eph) {
258 QMutexLocker locker(&_mutex);
259 _pppClient->putEphemeris(&eph);
260}
261
262//
263////////////////////////////////////////////////////////////////////////////
264void t_pppRun::slotNewGlonassEph(t_ephGlo eph) {
265 QMutexLocker locker(&_mutex);
266 _pppClient->putEphemeris(&eph);
267}
268
269//
270////////////////////////////////////////////////////////////////////////////
271void t_pppRun::slotNewGalileoEph(t_ephGal eph) {
272 QMutexLocker locker(&_mutex);
273 _pppClient->putEphemeris(&eph);
274}
275
276//
277////////////////////////////////////////////////////////////////////////////
278void t_pppRun::slotNewBDSEph(t_ephBDS eph) {
279 QMutexLocker locker(&_mutex);
280 _pppClient->putEphemeris(&eph);
281}
282
283//
284////////////////////////////////////////////////////////////////////////////
285void t_pppRun::slotNewObs(QByteArray staID, QList<t_satObs> obsList) {
286 QMutexLocker locker(&_mutex);
287
288 if (string(staID.data()) != _opt->_roverName) {
289 return;
290 }
291
292 // Loop over all observations (possible different epochs)
293 // -----------------------------------------------------
294 QListIterator<t_satObs> it(obsList);
295 while (it.hasNext()) {
296 const t_satObs& oldObs = it.next();
297 t_satObs* newObs = new t_satObs(oldObs);
298
299 // Find the corresponding data epoch or create a new one
300 // -----------------------------------------------------
301 t_epoData* epoch = 0;
302 deque<t_epoData*>::const_iterator it;
303 for (it = _epoData.begin(); it != _epoData.end(); it++) {
304 if (newObs->_time == (*it)->_time) {
305 epoch = *it;
306 break;
307 }
308 }
309 if (epoch == 0) {
310 if (_epoData.empty() || newObs->_time > _epoData.back()->_time) {
311 epoch = new t_epoData;
312 epoch->_time = newObs->_time;
313 _epoData.push_back(epoch);
314 }
315 }
316
317 // Put data into the epoch
318 // -----------------------
319 if (epoch != 0) {
320 epoch->_satObs.push_back(newObs);
321 }
322 else {
323 delete newObs;
324 }
325 }
326
327 // Make sure the buffer does not grow beyond any limit
328 // ---------------------------------------------------
329 const unsigned MAX_EPODATA_SIZE = 120;
330 if (_epoData.size() > MAX_EPODATA_SIZE) {
331 delete _epoData.front();
332 _epoData.pop_front();
333 }
334
335 // Process the oldest epochs
336 // ------------------------
337 while (_epoData.size()) {
338
339 const vector<t_satObs*>& satObs = _epoData.front()->_satObs;
340
341 // No corrections yet, skip the epoch
342 // ----------------------------------
343 if (_opt->_corrWaitTime && !_lastClkCorrTime.valid()) {
344 return;
345 }
346
347 // Process the front epoch
348 // -----------------------
349
350 if (_opt->_corrWaitTime == 0 ||
351 (_epoData.front()->_time - _lastClkCorrTime) < _opt->_corrWaitTime) {
352
353 if (fabs(_epoData.front()->_time - _lastClkCorrTime) > 60.0) {
354 delete _epoData.front();
355 _epoData.pop_front();
356 continue;
357 }
358
359 t_output output;
360 _pppClient->processEpoch(satObs, &output);
361
362 if (!output._error) {
363 QVector<double> xx(6);
364 xx.data()[0] = output._xyzRover[0];
365 xx.data()[1] = output._xyzRover[1];
366 xx.data()[2] = output._xyzRover[2];
367 xx.data()[3] = output._neu[0];
368 xx.data()[4] = output._neu[1];
369 xx.data()[5] = output._neu[2];
370 emit newPosition(staID, output._epoTime, xx);
371 }
372
373 delete _epoData.front();
374 _epoData.pop_front();
375
376 ostringstream log;
377 if (output._error) {
378 log << output._log;
379 }
380 else {
381 log.setf(ios::fixed);
382 log << string(output._epoTime) << ' ' << staID.data()
383 << " X = " << setprecision(4) << output._xyzRover[0]
384 << " Y = " << setprecision(4) << output._xyzRover[1]
385 << " Z = " << setprecision(4) << output._xyzRover[2]
386 << " NEU: " << showpos << setw(8) << setprecision(4) << output._neu[0]
387 << " " << showpos << setw(8) << setprecision(4) << output._neu[1]
388 << " " << showpos << setw(8) << setprecision(4) << output._neu[2]
389 << " TRP: " << showpos << setw(8) << setprecision(4) << output._trp0
390 << " " << showpos << setw(8) << setprecision(4) << output._trp;
391 }
392
393 if (_logFile && output._epoTime.valid()) {
394 _logFile->write(output._epoTime.gpsw(), output._epoTime.gpssec(),
395 QString(output._log.c_str()));
396 }
397
398 if (!output._error) {
399 QString rmcStr = nmeaString('R', output);
400 QString ggaStr = nmeaString('G', output);
401 if (_nmeaFile) {
402 _nmeaFile->write(output._epoTime.gpsw(), output._epoTime.gpssec(), rmcStr);
403 _nmeaFile->write(output._epoTime.gpsw(), output._epoTime.gpssec(), ggaStr);
404 }
405 emit newNMEAstr(staID, rmcStr.toLatin1());
406 emit newNMEAstr(staID, ggaStr.toLatin1());
407 if (_snxtroFile && output._epoTime.valid()) {
408 _snxtroFile->write(staID, int(output._epoTime.gpsw()), output._epoTime.gpssec(),
409 output._trp0 + output._trp, output._trpStdev);
410 }
411 }
412 emit newMessage(QByteArray(log.str().c_str()), true);
413 }
414 else {
415 return;
416 }
417 }
418}
419
420//
421////////////////////////////////////////////////////////////////////////////
422void t_pppRun::slotNewTec(t_vTec vTec) {
423 if (vTec._layers.size() == 0) {
424 return;
425 }
426
427 if (_opt->_realTime) {
428 if (_opt->_ionoMount.empty() && _opt->_corrMount.empty()) {
429 return;
430 }
431 if ( _opt->_ionoMount.empty() &&
432 !_opt->_corrMount.empty() && _opt->_corrMount != vTec._staID) {
433 return;
434 }
435 if (!_opt->_ionoMount.empty() && _opt->_ionoMount != vTec._staID) {
436 return;
437 }
438 }
439 _pppClient->putTec(&vTec);
440}
441
442//
443////////////////////////////////////////////////////////////////////////////
444void t_pppRun::slotNewOrbCorrections(QList<t_orbCorr> orbCorr) {
445 if (orbCorr.size() == 0) {
446 return;
447 }
448
449 if (_opt->_realTime) {
450 if (_opt->_corrMount.empty() || _opt->_corrMount != orbCorr[0]._staID) {
451 return;
452 }
453 }
454 vector<t_orbCorr*> corrections;
455 for (int ii = 0; ii < orbCorr.size(); ii++) {
456 corrections.push_back(new t_orbCorr(orbCorr[ii]));
457 }
458
459 _pppClient->putOrbCorrections(corrections);
460
461 for (unsigned ii = 0; ii < corrections.size(); ii++) {
462 delete corrections[ii];
463 }
464}
465
466//
467////////////////////////////////////////////////////////////////////////////
468void t_pppRun::slotNewClkCorrections(QList<t_clkCorr> clkCorr) {
469 if (clkCorr.size() == 0) {
470 return;
471 }
472
473 if (_opt->_realTime) {
474 if (_opt->_corrMount.empty() || _opt->_corrMount != clkCorr[0]._staID) {
475 return;
476 }
477 }
478 vector<t_clkCorr*> corrections;
479 for (int ii = 0; ii < clkCorr.size(); ii++) {
480 corrections.push_back(new t_clkCorr(clkCorr[ii]));
481 _lastClkCorrTime = clkCorr[ii]._time;
482 }
483 _pppClient->putClkCorrections(corrections);
484
485 for (unsigned ii = 0; ii < corrections.size(); ii++) {
486 delete corrections[ii];
487 }
488}
489
490//
491////////////////////////////////////////////////////////////////////////////
492void t_pppRun::slotNewCodeBiases(QList<t_satCodeBias> codeBiases) {
493 if (codeBiases.size() == 0) {
494 return;
495 }
496
497 if (_opt->_realTime) {
498 if (_opt->_corrMount.empty() || _opt->_corrMount != codeBiases[0]._staID) {
499 return;
500 }
501 }
502 vector<t_satCodeBias*> biases;
503 for (int ii = 0; ii < codeBiases.size(); ii++) {
504 biases.push_back(new t_satCodeBias(codeBiases[ii]));
505 }
506
507 _pppClient->putCodeBiases(biases);
508
509 for (unsigned ii = 0; ii < biases.size(); ii++) {
510 delete biases[ii];
511 }
512}
513
514//
515////////////////////////////////////////////////////////////////////////////
516void t_pppRun::slotNewPhaseBiases(QList<t_satPhaseBias> phaseBiases) {
517 if (phaseBiases.size() == 0) {
518 return;
519 }
520
521 if (_opt->_realTime) {
522 if (_opt->_corrMount.empty() || _opt->_corrMount != phaseBiases[0]._staID) {
523 return;
524 }
525 }
526 vector<t_satPhaseBias*> biases;
527 for (int ii = 0; ii < phaseBiases.size(); ii++) {
528 biases.push_back(new t_satPhaseBias(phaseBiases[ii]));
529 }
530
531 _pppClient->putPhaseBiases(biases);
532
533 for (unsigned ii = 0; ii < biases.size(); ii++) {
534 delete biases[ii];
535 }
536}
537
538//
539////////////////////////////////////////////////////////////////////////////
540void t_pppRun::processFiles() {
541
542 try {
543 _rnxObsFile = new t_rnxObsFile(QString(_opt->_rinexObs.c_str()), t_rnxObsFile::input);
544 }
545 catch (...) {
546 delete _rnxObsFile; _rnxObsFile = 0;
547 emit finishedRnxPPP();
548 return;
549 }
550
551 try {
552 _rnxNavFile = new t_rnxNavFile(QString(_opt->_rinexNav.c_str()), t_rnxNavFile::input);
553 }
554 catch (...) {
555 delete _rnxNavFile; _rnxNavFile = 0;
556 emit finishedRnxPPP();
557 return;
558 }
559
560 if (!_opt->_corrFile.empty()) {
561 _corrFile = new t_corrFile(QString(_opt->_corrFile.c_str()));
562
563 if (_opt->_ionoFile.empty()) {
564 connect(_corrFile, SIGNAL(newTec(t_vTec)), this, SLOT(slotNewTec(t_vTec)));
565 }
566 connect(_corrFile, SIGNAL(newOrbCorrections(QList<t_orbCorr>)), this, SLOT(slotNewOrbCorrections(QList<t_orbCorr>)));
567 connect(_corrFile, SIGNAL(newClkCorrections(QList<t_clkCorr>)), this, SLOT(slotNewClkCorrections(QList<t_clkCorr>)));
568 connect(_corrFile, SIGNAL(newCodeBiases(QList<t_satCodeBias>)), this, SLOT(slotNewCodeBiases(QList<t_satCodeBias>)));
569 connect(_corrFile, SIGNAL(newPhaseBiases(QList<t_satPhaseBias>)), this, SLOT(slotNewPhaseBiases(QList<t_satPhaseBias>)));
570 }
571
572 if (!_opt->_ionoFile.empty()) {
573 _ionoFile = new t_corrFile(QString(_opt->_corrFile.c_str()));
574 connect(_ionoFile, SIGNAL(newTec(t_vTec)), this, SLOT(slotNewTec(t_vTec)));
575 }
576
577 // Read/Process Observations
578 // -------------------------
579 int nEpo = 0;
580 const t_rnxObsFile::t_rnxEpo* epo = 0;
581 while ( !_stopFlag && (epo = _rnxObsFile->nextEpoch()) != 0 ) {
582 ++nEpo;
583
584 if (_speed < 100) {
585 double sleepTime = 2.0 / _speed;
586 t_pppThread::msleep(int(sleepTime*1.e3));
587 }
588
589 // Get Corrections
590 // ---------------
591 if (_corrFile) {
592 try {
593 _corrFile->syncRead(epo->tt);
594 }
595 catch (const char* msg) {
596 emit newMessage(QByteArray(msg), true);
597 break;
598 }
599 catch (const string& msg) {
600 emit newMessage(QByteArray(msg.c_str()), true);
601 break;
602 }
603 catch (...) {
604 emit newMessage("unknown exceptions in corrFile", true);
605 break;
606 }
607 }
608
609 // Get Additional VTEC Informations
610 // --------------------------------
611 if (_ionoFile) {
612 try {
613 _ionoFile->syncRead(epo->tt);
614 }
615 catch (const char* msg) {
616 emit newMessage(QByteArray(msg), true);
617 break;
618 }
619 catch (const string& msg) {
620 emit newMessage(QByteArray(msg.c_str()), true);
621 break;
622 }
623 catch (...) {
624 emit newMessage("unknown exceptions in ionoFile", true);
625 break;
626 }
627 }
628
629 // Get Ephemerides
630 // ----------------
631 t_eph* eph = 0;
632 const QMap<QString, unsigned int>* corrIODs = _corrFile ? &_corrFile->corrIODs() : 0;
633 while ( (eph = _rnxNavFile->getNextEph(epo->tt, corrIODs)) != 0 ) {
634 _pppClient->putEphemeris(eph);
635 delete eph; eph = 0;
636 }
637
638 // Create list of observations and start epoch processing
639 // ------------------------------------------------------
640 QList<t_satObs> obsList;
641 for (unsigned iObs = 0; iObs < epo->rnxSat.size(); iObs++) {
642 const t_rnxObsFile::t_rnxSat& rnxSat = epo->rnxSat[iObs];
643
644 t_satObs obs;
645 t_rnxObsFile::setObsFromRnx(_rnxObsFile, epo, rnxSat, obs);
646 obsList << obs;
647 }
648 slotNewObs(QByteArray(_opt->_roverName.c_str()), obsList);
649
650
651 if (nEpo % 10 == 0) {
652 emit progressRnxPPP(nEpo);
653 }
654
655 QCoreApplication::processEvents();
656 }
657
658 emit finishedRnxPPP();
659
660 if (BNC_CORE->mode() != t_bncCore::interactive) {
661 qApp->exit(0);
662 }
663 else {
664 BNC_CORE->stopPPP();
665 }
666}
667
668//
669////////////////////////////////////////////////////////////////////////////
670void t_pppRun::slotSetSpeed(int speed) {
671 QMutexLocker locker(&_mutex);
672 _speed = speed;
673}
674
675//
676////////////////////////////////////////////////////////////////////////////
677void t_pppRun::slotSetStopFlag() {
678 QMutexLocker locker(&_mutex);
679 _stopFlag = true;
680}
681
682//
683////////////////////////////////////////////////////////////////////////////
684QString t_pppRun::nmeaString(char strType, const t_output& output) {
685
686 double ell[3];
687 xyz2ell(output._xyzRover, ell);
688 double phiDeg = ell[0] * 180 / M_PI;
689 double lamDeg = ell[1] * 180 / M_PI;
690
691 unsigned year, month, day;
692 output._epoTime.civil_date(year, month, day);
693 double gps_utc = gnumleap(year, month, day);
694
695 char phiCh = 'N';
696 if (phiDeg < 0) {
697 phiDeg = -phiDeg;
698 phiCh = 'S';
699 }
700 char lamCh = 'E';
701 if (lamDeg < 0) {
702 lamDeg = -lamDeg;
703 lamCh = 'W';
704 }
705
706 ostringstream out;
707 out.setf(ios::fixed);
708
709 if (strType == 'R') {
710 string datestr = (output._epoTime - gps_utc).datestr(0); // yyyymmdd
711 out << "GPRMC,"
712 << (output._epoTime - gps_utc).timestr(3,0) << ",A,"
713 << setw(2) << setfill('0') << int(phiDeg)
714 << setw(7) << setprecision(4) << setfill('0') << fmod(60*phiDeg,60) << ',' << phiCh << ','
715 << setw(3) << setfill('0') << int(lamDeg)
716 << setw(7) << setprecision(4) << setfill('0') << fmod(60*lamDeg,60) << ',' << lamCh << ",,,"
717 << datestr[6] << datestr[7] << datestr[4] << datestr[5] << datestr[2] << datestr[3] << ",,";
718 }
719 else if (strType == 'G') {
720 out << "GPGGA,"
721 << (output._epoTime - gps_utc).timestr(2,0) << ','
722 << setw(2) << setfill('0') << int(phiDeg)
723 << setw(10) << setprecision(7) << setfill('0')
724 << fmod(60*phiDeg,60) << ',' << phiCh << ','
725 << setw(3) << setfill('0') << int(lamDeg)
726 << setw(10) << setprecision(7) << setfill('0')
727 << fmod(60*lamDeg,60) << ',' << lamCh
728 << ",1," << setw(2) << setfill('0') << output._numSat << ','
729 << setw(3) << setprecision(1) << output._hDop << ','
730 << setprecision(3) << ell[2] << ",M,0.0,M,,";
731 }
732 else {
733 return "";
734 }
735
736 QString nmStr(out.str().c_str());
737 unsigned char XOR = 0;
738 for (int ii = 0; ii < nmStr.length(); ii++) {
739 XOR ^= (unsigned char) nmStr[ii].toLatin1();
740 }
741
742 return '$' + nmStr + QString("*%1").arg(XOR, 2, 16, QLatin1Char('0')) + "\n";
743}
744
745//
746////////////////////////////////////////////////////////////////////////////
747void t_pppRun::slotProviderIDChanged(QString mountPoint) {
748 QMutexLocker locker(&_mutex);
749
750 if (mountPoint.toStdString() !=_opt->_corrMount) {
751 return;
752 }
753
754 QString msg = "pppRun " + QString(_opt->_roverName.c_str()) + ": Provider Changed: " + mountPoint;
755 emit newMessage(msg.toLatin1(), true);
756
757 _pppClient->reset();
758
759 while (!_epoData.empty()) {
760 delete _epoData.front();
761 _epoData.pop_front();
762 }
763}
Note: See TracBrowser for help on using the repository browser.