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

Last change on this file since 10805 was 10805, checked in by stuerze, 8 days ago

minor changes regarding ppp output

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