source: ntrip/trunk/BNC/bncpppthread.cpp@ 2024

Last change on this file since 2024 was 2024, checked in by mervart, 14 years ago

* empty log message *

File size: 5.2 KB
Line 
1// Part of BNC, a utility for retrieving decoding and
2// converting GNSS data streams from NTRIP broadcasters.
3//
4// Copyright (C) 2007
5// German Federal Agency for Cartography and Geodesy (BKG)
6// http://www.bkg.bund.de
7// Czech Technical University Prague, Department of Geodesy
8// http://www.fsv.cvut.cz
9//
10// Email: euref-ip@bkg.bund.de
11//
12// This program is free software; you can redistribute it and/or
13// modify it under the terms of the GNU General Public License
14// as published by the Free Software Foundation, version 2.
15//
16// This program is distributed in the hope that it will be useful,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19// GNU General Public License for more details.
20//
21// You should have received a copy of the GNU General Public License
22// along with this program; if not, write to the Free Software
23// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24
25/* -------------------------------------------------------------------------
26 * BKG NTRIP Client
27 * -------------------------------------------------------------------------
28 *
29 * Class: bncPPPthread
30 *
31 * Purpose: Precise Point Positioning
32 *
33 * Author: L. Mervart
34 *
35 * Created: 21-Nov-2009
36 *
37 * Changes:
38 *
39 * -----------------------------------------------------------------------*/
40
41#include <iomanip>
42
43#include "bncpppthread.h"
44
45extern "C" {
46#include "clock_orbit_rtcm.h"
47}
48
49using namespace std;
50
51// Constructor
52////////////////////////////////////////////////////////////////////////////
53bncPPPthread::bncPPPthread(QByteArray staID) {
54 _staID = staID;
55 _isToBeDeleted = false;
56 _data = 0;
57}
58
59// Destructor
60////////////////////////////////////////////////////////////////////////////
61bncPPPthread::~bncPPPthread() {
62 if (isRunning()) {
63 wait();
64 }
65 delete _data;
66 QMapIterator<QString, t_eph*> it(_eph);
67 while (it.hasNext()) {
68 it.next();
69 delete it.value();
70 }
71 QMapIterator<QString, t_corr*> ic(_corr);
72 while (ic.hasNext()) {
73 ic.next();
74 delete ic.value();
75 }
76}
77
78//
79////////////////////////////////////////////////////////////////////////////
80void bncPPPthread::terminate() {
81 _isToBeDeleted = true;
82 if (!isRunning()) {
83 delete this;
84 }
85}
86
87// Run
88////////////////////////////////////////////////////////////////////////////
89void bncPPPthread::run() {
90 while (true) {
91 try {
92 if (_isToBeDeleted) {
93 QThread::exit(0);
94 this->deleteLater();
95 return;
96 }
97 processEpoch();
98 }
99 catch (...) {
100 emit(newMessage(_staID + "bncPPPthread exception", true));
101 _isToBeDeleted = true;
102 }
103 }
104}
105
106//
107////////////////////////////////////////////////////////////////////////////
108void bncPPPthread::slotNewEpochData(QList<p_obs> obsList) {
109 QMutexLocker locker(&_mutex);
110 QListIterator<p_obs> it(obsList);
111 while (it.hasNext()) {
112 p_obs pp = it.next();
113 t_obsInternal* obs = &(pp->_o);
114 QByteArray staID = QByteArray(obs->StatID);
115 if (staID == _staID) {
116 if (!_data) {
117 _data = new t_data();
118 _data->GPSWeek = obs->GPSWeek;
119 _data->GPSWeeks = obs->GPSWeeks;
120 }
121 ++_data->numSat;
122 _data->prn[_data->numSat] =
123 QString("%1%2").arg(obs->satSys).arg(obs->satNum, 2, 10, QChar('0'));
124 _data->C1[_data->numSat] = obs->C1;
125 _data->C2[_data->numSat] = obs->C2;
126 _data->P1[_data->numSat] = obs->P1;
127 _data->P2[_data->numSat] = obs->P2;
128 _data->L1[_data->numSat] = obs->L1;
129 _data->L2[_data->numSat] = obs->L2;
130 }
131 }
132}
133
134//
135////////////////////////////////////////////////////////////////////////////
136void bncPPPthread::slotNewEphGPS(gpsephemeris gpseph) {
137 QMutexLocker locker(&_mutex);
138
139 QString prn = QString("G%1").arg(gpseph.satellite, 2, 10, QChar('0'));
140
141 if (_eph.contains(prn)) {
142 (static_cast<t_ephGPS*>(_eph.value(prn)))->set(&gpseph);
143 }
144 else {
145 t_ephGPS* ee = new t_ephGPS();
146 ee->set(&gpseph);
147 _eph[prn] = ee;
148 }
149}
150
151//
152////////////////////////////////////////////////////////////////////////////
153void bncPPPthread::slotNewCorrections(QList<QString> corrList) {
154 QMutexLocker locker(&_mutex);
155 QListIterator<QString> it(corrList);
156 while (it.hasNext()) {
157 QTextStream in(it.next().toAscii());
158 int messageType;
159 int updateInterval;
160 int GPSweek;
161 double GPSweeks;
162 QString prn;
163 in >> messageType >> updateInterval >> GPSweek >> GPSweeks >> prn;
164 if ( messageType == COTYPE_GPSCOMBINED ||
165 messageType == COTYPE_GLONASSCOMBINED ) {
166 t_corr* cc = 0;
167 if (_corr.contains(prn)) {
168 cc = _corr.value(prn);
169 }
170 else {
171 cc = new t_corr();
172 _corr[prn] = cc;
173 }
174 in >> cc->iod >> cc->dClk >> cc->rao[0] >> cc->rao[1] >> cc->rao[2];
175 }
176 }
177}
178
179//
180////////////////////////////////////////////////////////////////////////////
181void bncPPPthread::processEpoch() {
182 QMutexLocker locker(&_mutex);
183
184 if (!_data) {
185 return;
186 }
187
188 for (int is = 1; is <= _data->numSat; is++) {
189 cout << is << " " << _data->prn[is].toAscii().data() << " "
190 << _data->C1[is] << " " << _data->P1[is] << endl;
191 }
192
193 cout << endl;
194 cout.flush();
195
196 delete _data;
197 _data = 0;
198}
Note: See TracBrowser for help on using the repository browser.