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

Last change on this file since 5785 was 5785, checked in by mervart, 10 years ago
File size: 6.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_pppThread, t_pppRun
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
43#include <iostream>
44#include <iomanip>
45#include <string.h>
46#include <map>
47
48#include "pppThread.h"
49#include "bnccore.h"
50
51using namespace BNC;
52using namespace std;
53
54// Constructor
55////////////////////////////////////////////////////////////////////////////
56t_pppThread::t_pppThread(const t_options* opt) : QThread(0) {
57 _opt = opt;
58 _pppRun = 0;
59 connect(this, SIGNAL(finished()), this, SLOT(deleteLater()));
60
61 connect(this, SIGNAL(newMessage(QByteArray,bool)),
62 BNC_CORE, SLOT(slotMessage(const QByteArray,bool)));
63}
64
65// Destructor
66////////////////////////////////////////////////////////////////////////////
67t_pppThread::~t_pppThread() {
68 cout << "~t_pppThread" << endl;
69 delete _pppRun;
70}
71
72// Run (virtual)
73////////////////////////////////////////////////////////////////////////////
74void t_pppThread::run() {
75 try {
76 _pppRun = new t_pppRun(_opt);
77 QThread::exec();
78 }
79 catch (pppExcept exc) {
80 _pppRun = 0;
81 emit newMessage(QByteArray(exc.what().c_str()), true);
82 }
83}
84
85// Constructor
86////////////////////////////////////////////////////////////////////////////
87t_pppRun::t_pppRun(const t_options* opt) {
88 _opt = opt;
89 connect(this, SIGNAL(newMessage(QByteArray,bool)),
90 BNC_CORE, SLOT(slotMessage(const QByteArray,bool)));
91 if (_opt->_realTime) {
92 connect(BNC_CORE->caster(), SIGNAL(newObs(QByteArray, QList<t_obs>)),
93 this, SLOT(slotNewObs(QByteArray, QList<t_obs>)));
94
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)));
103
104 connect(BNC_CORE, SIGNAL(newCorrections(QStringList)),
105 this, SLOT(slotNewCorrections(QStringList)));
106
107 _pppClient = new t_pppClient(_opt);
108 }
109 else {
110 throw pppExcept("t_pppRun: post-processing not yet implemented");
111 }
112}
113
114// Destructor
115////////////////////////////////////////////////////////////////////////////
116t_pppRun::~t_pppRun() {
117 cout << "~t_pppRun" << endl;
118}
119
120//
121////////////////////////////////////////////////////////////////////////////
122void t_pppRun::slotNewEphGPS(gpsephemeris gpseph) {
123 QMutexLocker locker(&_mutex);
124 t_ephGPS eph;
125 eph.set(&gpseph);
126 _pppClient->putEphemeris(&eph);
127}
128
129//
130////////////////////////////////////////////////////////////////////////////
131void t_pppRun::slotNewEphGlonass(glonassephemeris gloeph) {
132 QMutexLocker locker(&_mutex);
133 t_ephGlo eph;
134 eph.set(&gloeph);
135 _pppClient->putEphemeris(&eph);
136}
137
138//
139////////////////////////////////////////////////////////////////////////////
140void t_pppRun::slotNewEphGalileo(galileoephemeris galeph) {
141 QMutexLocker locker(&_mutex);
142 t_ephGal eph;
143 eph.set(&galeph);
144 _pppClient->putEphemeris(&eph);
145}
146
147//
148////////////////////////////////////////////////////////////////////////////
149void t_pppRun::slotNewCorrections(QStringList corrList) {
150 QMutexLocker locker(&_mutex);
151
152 QStringListIterator it(corrList);
153 while (it.hasNext()) {
154 it.next();
155 }
156
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);
160}
161//
162////////////////////////////////////////////////////////////////////////////
163void t_pppRun::slotNewObs(QByteArray staID, QList<t_obs> obsList) {
164 QMutexLocker locker(&_mutex);
165
166 if (string(staID.data()) != _opt->_roverName) {
167 return;
168 }
169
170 vector<t_pppSatObs*> pppSatObs;
171 QListIterator<t_obs> it(obsList);
172 while (it.hasNext()) {
173 const t_obs& oldObs = it.next();
174 t_pppSatObs* newObs = new t_pppSatObs;
175
176 newObs->_prn.set(oldObs.satSys, oldObs.satNum);
177 newObs->_time.set(oldObs.GPSWeek, oldObs.GPSWeeks);
178
179 map<string, t_pppObs*> pppObsMap;
180 for (unsigned iEntry = 0; iEntry < GNSSENTRY_NUMBER; iEntry++) {
181 string hlp(oldObs.rnxStr(iEntry).toAscii().data());
182 if (hlp.length() == 3) {
183 char obsType = hlp[0];
184 string rnxType2ch = hlp.substr(1);
185 if (obsType == 'C' || obsType == 'L') {
186 t_pppObs* pppObs = 0;
187 if (pppObsMap.find(rnxType2ch) == pppObsMap.end()) {
188 pppObs = new t_pppObs();
189 pppObsMap[rnxType2ch] = pppObs;
190 pppObs->_rnxType2ch = rnxType2ch;
191 newObs->_obs.push_back(pppObs);
192 }
193 else {
194 pppObs = pppObsMap[rnxType2ch];
195 }
196 if (obsType == 'C') {
197 pppObs->_code = oldObs._measdata[iEntry];
198 pppObs->_codeValid = true;
199 }
200 else if (obsType == 'L') {
201 pppObs->_phase = oldObs._measdata[iEntry];
202 pppObs->_phaseValid = true;
203 }
204 }
205 }
206 }
207
208 pppSatObs.push_back(newObs);
209 }
210
211 t_output output;
212 _pppClient->processEpoch(pppSatObs, &output);
213
214 for (unsigned ii = 0; ii < pppSatObs.size(); ii++) {
215 delete pppSatObs[ii];
216 }
217 pppSatObs.clear();
218
219 emit newMessage(QByteArray(output._log.c_str()), true);
220}
221
Note: See TracBrowser for help on using the repository browser.