source: ntrip/trunk/BNC/src/PPP/pppThread.cpp@ 5784

Last change on this file since 5784 was 5784, checked in by mervart, 10 years ago
File size: 7.1 KB
RevLine 
[4757]1
[5719]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 *
[5731]30 * Class: t_pppThread, t_pppRun
[5719]31 *
32 * Purpose: Single PPP Client (running in its own thread)
33 *
34 * Author: L. Mervart
35 *
36 * Created: 29-Jul-2014
37 *
38 * Changes:
39 *
40 * -----------------------------------------------------------------------*/
41
42
[4757]43#include <iostream>
[4775]44#include <iomanip>
[4757]45#include <string.h>
[5782]46#include <map>
[4757]47
[5680]48#include "pppThread.h"
[5068]49#include "bnccore.h"
[4757]50
[5719]51using namespace BNC;
[4757]52using namespace std;
53
54// Constructor
55////////////////////////////////////////////////////////////////////////////
[5721]56t_pppThread::t_pppThread(const t_options* opt) : QThread(0) {
[5774]57 _opt = opt;
58 _pppRun = 0;
[5775]59 connect(this, SIGNAL(finished()), this, SLOT(deleteLater()));
60
[5767]61 connect(this, SIGNAL(newMessage(QByteArray,bool)),
62 BNC_CORE, SLOT(slotMessage(const QByteArray,bool)));
[4763]63}
64
65// Destructor
66////////////////////////////////////////////////////////////////////////////
[5680]67t_pppThread::~t_pppThread() {
[5775]68 cout << "~t_pppThread" << endl;
[5731]69 delete _pppRun;
[4763]70}
71
72// Run (virtual)
73////////////////////////////////////////////////////////////////////////////
[5680]74void t_pppThread::run() {
[5742]75 try {
76 _pppRun = new t_pppRun(_opt);
[5775]77 QThread::exec();
[5742]78 }
[5763]79 catch (pppExcept exc) {
[5768]80 _pppRun = 0;
[5766]81 emit newMessage(QByteArray(exc.what().c_str()), true);
[5742]82 }
[5731]83}
84
85// Constructor
86////////////////////////////////////////////////////////////////////////////
[5736]87t_pppRun::t_pppRun(const t_options* opt) {
[5731]88 _opt = opt;
[5767]89 connect(this, SIGNAL(newMessage(QByteArray,bool)),
90 BNC_CORE, SLOT(slotMessage(const QByteArray,bool)));
[5742]91 if (_opt->_realTime) {
[5729]92 connect(BNC_CORE->caster(), SIGNAL(newObs(QByteArray, QList<t_obs>)),
93 this, SLOT(slotNewObs(QByteArray, QList<t_obs>)));
[4757]94
[5722]95 connect(BNC_CORE, SIGNAL(newEphGPS(gpsephemeris)),
96 this, SLOT(slotNewEphGPS(gpsephemeris)));
97
98 connect(BNC_CORE, SIGNAL(newEphGlonass(glonassephemeris)),
99 this, SLOT(slotNewEphGlonass(glonassephemeris)));
100
101 connect(BNC_CORE, SIGNAL(newEphGalileo(galileoephemeris)),
102 this, SLOT(slotNewEphGalileo(galileoephemeris)));
[4757]103
[5732]104 connect(BNC_CORE, SIGNAL(newCorrections(QStringList)),
105 this, SLOT(slotNewCorrections(QStringList)));
[5742]106
[5761]107 _pppClient = new t_pppClient(_opt);
[5722]108 }
[5742]109 else {
[5766]110 throw pppExcept("t_pppRun: post-processing not yet implemented");
[5742]111 }
[5731]112}
[5729]113
[5731]114// Destructor
115////////////////////////////////////////////////////////////////////////////
116t_pppRun::~t_pppRun() {
[5775]117 cout << "~t_pppRun" << endl;
[4757]118}
119
120//
121////////////////////////////////////////////////////////////////////////////
[5731]122void t_pppRun::slotNewEphGPS(gpsephemeris gpseph) {
[4757]123 QMutexLocker locker(&_mutex);
[5742]124 t_ephGPS eph;
125 eph.set(&gpseph);
[5772]126 _pppClient->putEphemeris(&eph);
[4757]127}
128
129//
130////////////////////////////////////////////////////////////////////////////
[5731]131void t_pppRun::slotNewEphGlonass(glonassephemeris gloeph) {
[4757]132 QMutexLocker locker(&_mutex);
[5769]133 t_ephGlo eph;
134 eph.set(&gloeph);
[5772]135 _pppClient->putEphemeris(&eph);
[4757]136}
137
138//
139////////////////////////////////////////////////////////////////////////////
[5769]140void t_pppRun::slotNewEphGalileo(galileoephemeris galeph) {
[5681]141 QMutexLocker locker(&_mutex);
[5769]142 t_ephGal eph;
143 eph.set(&galeph);
[5772]144 _pppClient->putEphemeris(&eph);
[4757]145}
146
147//
148////////////////////////////////////////////////////////////////////////////
[5732]149void t_pppRun::slotNewCorrections(QStringList corrList) {
[4757]150 QMutexLocker locker(&_mutex);
[5771]151
152 QStringListIterator it(corrList);
153 while (it.hasNext()) {
[5775]154 it.next();
[5771]155 }
156
[5779]157 // _pppClient->putOrbCorrections(const std::vector<t_orbCorr*>& corr);
158 // _pppClient->putClkCorrections(const std::vector<t_clkCorr*>& corr);
159 // _pppClient->putBiases(const std::vector<t_satBiases*>& biases);
[4757]160}
161//
162////////////////////////////////////////////////////////////////////////////
[5731]163void t_pppRun::slotNewObs(QByteArray staID, QList<t_obs> obsList) {
[4757]164 QMutexLocker locker(&_mutex);
[5766]165
[5777]166 if (string(staID.data()) != _opt->_roverName) {
167 return;
168 }
169
[5781]170 // class t_pppObs {
171 // std::string _rnxType2ch;
172 // double _code;
173 // bool _codeValid;
174 // double _phase;
175 // bool _phaseValid;
176 // double _doppler;
177 // bool _dopplerValid;
178 // double _snr;
179 // bool _snrValid;
180 // bool _slip;
181 // int _slipCounter;
182 // int _biasJumpCounter;
183 // };
184 //
185 // class t_pppSatObs {
186 // t_prn _prn;
187 // bncTime _time;
188 // std::vector<t_pppObs> _obs;
189 // };
190
[5780]191 vector<t_pppSatObs*> pppSatObs;
[5778]192 QListIterator<t_obs> it(obsList);
193 while (it.hasNext()) {
[5780]194 const t_obs& oldObs = it.next();
195 t_pppSatObs* newObs = new t_pppSatObs;
[5781]196
197 newObs->_prn.set(oldObs.satSys, oldObs.satNum);
198 newObs->_time.set(oldObs.GPSWeek, oldObs.GPSWeeks);
[5780]199
[5782]200 map<string, t_pppObs*> pppObsMap;
201 for (unsigned iEntry = 0; iEntry < GNSSENTRY_NUMBER; iEntry++) {
202 string hlp(oldObs.rnxStr(iEntry).toAscii().data());
203 if (hlp.length() == 3) {
204 char obsType = hlp[0];
205 string rnxType2ch = hlp.substr(1);
[5783]206 if (obsType == 'C' || obsType == 'L') {
207 t_pppObs* pppObs = 0;
208 if (pppObsMap.find(rnxType2ch) == pppObsMap.end()) {
209 pppObs = new t_pppObs();
210 pppObsMap[rnxType2ch] = pppObs;
[5784]211 pppObs->_rnxType2ch = rnxType2ch;
212 newObs->_obs.push_back(pppObs);
[5783]213 }
214 else {
215 pppObs = pppObsMap[rnxType2ch];
216 }
217 if (obsType == 'C') {
218 pppObs->_code = oldObs._measdata[iEntry];
219 pppObs->_codeValid = true;
220 }
221 else if (obsType == 'L') {
222 pppObs->_phase = oldObs._measdata[iEntry];
223 pppObs->_phaseValid = true;
224 }
225 }
[5782]226 }
227 }
228
[5784]229 pppSatObs.push_back(newObs);
[5778]230 }
[5772]231
[5778]232 t_output output;
[5780]233 _pppClient->processEpoch(pppSatObs, &output);
[5772]234
[5780]235 for (unsigned ii = 0; ii < pppSatObs.size(); ii++) {
236 delete pppSatObs[ii];
[5779]237 }
[5780]238 pppSatObs.clear();
[5779]239
[5772]240 emit newMessage(QByteArray(output._log.c_str()), true);
[5589]241}
[5525]242
Note: See TracBrowser for help on using the repository browser.