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

Last change on this file since 5774 was 5774, checked in by mervart, 10 years ago
File size: 5.1 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
47#include "pppThread.h"
48#include "bnccore.h"
49
50using namespace BNC;
51using namespace std;
52
53// Constructor
54////////////////////////////////////////////////////////////////////////////
55t_pppThread::t_pppThread(const t_options* opt) : QThread(0) {
56 _opt = opt;
57 _pppRun = 0;
58 connect(this, SIGNAL(newMessage(QByteArray,bool)),
59 BNC_CORE, SLOT(slotMessage(const QByteArray,bool)));
60}
61
62// Destructor
63////////////////////////////////////////////////////////////////////////////
64t_pppThread::~t_pppThread() {
65 delete _pppRun;
66}
67
68// Run (virtual)
69////////////////////////////////////////////////////////////////////////////
70void t_pppThread::run() {
71 try {
72 _pppRun = new t_pppRun(_opt);
73 }
74 catch (pppExcept exc) {
75 _pppRun = 0;
76 emit newMessage(QByteArray(exc.what().c_str()), true);
77 }
78 QThread::exec();
79}
80
81//
82////////////////////////////////////////////////////////////////////////////
83void t_pppThread::stop() {
84 this->exit();
85 delete _pppRun; _pppRun = 0;
86 this->wait(1000);
87 this->deleteLater();
88}
89
90// Constructor
91////////////////////////////////////////////////////////////////////////////
92t_pppRun::t_pppRun(const t_options* opt) {
93 _opt = opt;
94 connect(this, SIGNAL(newMessage(QByteArray,bool)),
95 BNC_CORE, SLOT(slotMessage(const QByteArray,bool)));
96 if (_opt->_realTime) {
97 connect(BNC_CORE->caster(), SIGNAL(newObs(QByteArray, QList<t_obs>)),
98 this, SLOT(slotNewObs(QByteArray, QList<t_obs>)));
99
100 connect(BNC_CORE, SIGNAL(newEphGPS(gpsephemeris)),
101 this, SLOT(slotNewEphGPS(gpsephemeris)));
102
103 connect(BNC_CORE, SIGNAL(newEphGlonass(glonassephemeris)),
104 this, SLOT(slotNewEphGlonass(glonassephemeris)));
105
106 connect(BNC_CORE, SIGNAL(newEphGalileo(galileoephemeris)),
107 this, SLOT(slotNewEphGalileo(galileoephemeris)));
108
109 connect(BNC_CORE, SIGNAL(newCorrections(QStringList)),
110 this, SLOT(slotNewCorrections(QStringList)));
111
112 _pppClient = new t_pppClient(_opt);
113 }
114 else {
115 throw pppExcept("t_pppRun: post-processing not yet implemented");
116 }
117}
118
119// Destructor
120////////////////////////////////////////////////////////////////////////////
121t_pppRun::~t_pppRun() {
122}
123
124//
125////////////////////////////////////////////////////////////////////////////
126void t_pppRun::slotNewEphGPS(gpsephemeris gpseph) {
127 QMutexLocker locker(&_mutex);
128 t_ephGPS eph;
129 eph.set(&gpseph);
130 _pppClient->putEphemeris(&eph);
131}
132
133//
134////////////////////////////////////////////////////////////////////////////
135void t_pppRun::slotNewEphGlonass(glonassephemeris gloeph) {
136 QMutexLocker locker(&_mutex);
137 t_ephGlo eph;
138 eph.set(&gloeph);
139 _pppClient->putEphemeris(&eph);
140}
141
142//
143////////////////////////////////////////////////////////////////////////////
144void t_pppRun::slotNewEphGalileo(galileoephemeris galeph) {
145 QMutexLocker locker(&_mutex);
146 t_ephGal eph;
147 eph.set(&galeph);
148 _pppClient->putEphemeris(&eph);
149}
150
151//
152////////////////////////////////////////////////////////////////////////////
153void t_pppRun::slotNewCorrections(QStringList corrList) {
154 QMutexLocker locker(&_mutex);
155
156 QStringListIterator it(corrList);
157 while (it.hasNext()) {
158 }
159
160 // _pppClient->putOrbCorrections(const std::vector<t_orbCorr>& corr);
161 // _pppClient->putClkCorrections(const std::vector<t_clkCorr>& corr);
162 // _pppClient->putBiases(const std::vector<t_satBiases>& biases);
163}
164//
165////////////////////////////////////////////////////////////////////////////
166void t_pppRun::slotNewObs(QByteArray staID, QList<t_obs> obsList) {
167 QMutexLocker locker(&_mutex);
168
169
170 vector<t_pppSatObs> satObs;
171 t_output output;
172
173 _pppClient->processEpoch(satObs, &output);
174
175 emit newMessage(QByteArray(output._log.c_str()), true);
176}
177
Note: See TracBrowser for help on using the repository browser.