source: ntrip/trunk/BNC/src/pppMain.cpp@ 7856

Last change on this file since 7856 was 7856, checked in by stuerze, 8 years ago

minor changes to allow a clean end of program

File size: 13.3 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_pppMain
31 *
32 * Purpose: Start of the PPP client(s)
33 *
34 * Author: L. Mervart
35 *
36 * Created: 29-Jul-2014
37 *
38 * Changes:
39 *
40 * -----------------------------------------------------------------------*/
41
42#include <iostream>
43
44#include "pppMain.h"
45#include "pppCrdFile.h"
46#include "bncsettings.h"
47
48using namespace BNC_PPP;
49using namespace std;
50
51// Constructor
52//////////////////////////////////////////////////////////////////////////////
53t_pppMain::t_pppMain() {
54 _running = false;
55}
56
57// Destructor
58//////////////////////////////////////////////////////////////////////////////
59t_pppMain::~t_pppMain() {
60 stop();
61 QListIterator<t_pppOptions*> iOpt(_options);
62 while (iOpt.hasNext()) {
63 delete iOpt.next();
64 }
65}
66
67//
68//////////////////////////////////////////////////////////////////////////////
69void t_pppMain::start() {
70 if (_running) {
71 return;
72 }
73
74 try {
75 readOptions();
76
77 QListIterator<t_pppOptions*> iOpt(_options);
78 while (iOpt.hasNext()) {
79 const t_pppOptions* opt = iOpt.next();
80 t_pppThread* pppThread = new t_pppThread(opt);
81 pppThread->start();
82 _pppThreads << pppThread;
83 _running = true;
84 }
85 }
86 catch (t_except exc) {
87 _running = true;
88 stop();
89 }
90}
91
92//
93//////////////////////////////////////////////////////////////////////////////
94void t_pppMain::stop() {
95
96 if (!_running) {
97 return;
98 }
99
100 if (_realTime) {
101 QListIterator<t_pppThread*> it(_pppThreads);
102 while (it.hasNext()) {
103 t_pppThread* pppThread = it.next();
104 pppThread->exit();
105 if (BNC_CORE->mode() != t_bncCore::interactive) {
106 while(!pppThread->isFinished()) {
107 pppThread->wait();
108 }
109 delete pppThread;
110 }
111 }
112 _pppThreads.clear();
113 }
114
115 _running = false;
116}
117
118//
119//////////////////////////////////////////////////////////////////////////////
120void t_pppMain::readOptions() {
121
122 QListIterator<t_pppOptions*> iOpt(_options);
123 while (iOpt.hasNext()) {
124 delete iOpt.next();
125 }
126 _options.clear();
127
128 bncSettings settings;
129
130 _realTime = false;
131 if (settings.value("PPP/dataSource").toString() == "Real-Time Streams") {
132 _realTime = true;
133 }
134 else if (settings.value("PPP/dataSource").toString() == "RINEX Files") {
135 _realTime = false;
136 }
137 else {
138 return;
139 }
140
141 QListIterator<QString> iSta(settings.value("PPP/staTable").toStringList());
142 while (iSta.hasNext()) {
143 QStringList hlp = iSta.next().split(",");
144
145 if (hlp.size() < 10) {
146 throw t_except("pppMain: wrong option staTable");
147 }
148
149 t_pppOptions* opt = new t_pppOptions();
150
151 opt->_realTime = _realTime;
152 opt->_roverName = hlp[0].toStdString();
153 opt->_aprSigCrd[0] = hlp[1].toDouble();
154 opt->_aprSigCrd[1] = hlp[2].toDouble();
155 opt->_aprSigCrd[2] = hlp[3].toDouble();
156 opt->_noiseCrd[0] = hlp[4].toDouble();
157 opt->_noiseCrd[1] = hlp[5].toDouble();
158 opt->_noiseCrd[2] = hlp[6].toDouble();
159 opt->_aprSigTrp = hlp[7].toDouble();
160 opt->_noiseTrp = hlp[8].toDouble();
161 opt->_nmeaPort = hlp[9].toInt();
162
163 if (_realTime) {
164 opt->_corrMount.assign(settings.value("PPP/corrMount").toString().toStdString());
165 }
166 else {
167 opt->_rinexObs.assign(settings.value("PPP/rinexObs").toString().toStdString());
168 opt->_rinexNav.assign(settings.value("PPP/rinexNav").toString().toStdString());
169 opt->_corrFile.assign(settings.value("PPP/corrFile").toString().toStdString());
170 }
171
172 opt->_crdFile.assign(settings.value("PPP/crdFile").toString().toStdString());
173 opt->_antexFileName.assign(settings.value("PPP/antexFile").toString().toStdString());
174
175 opt->_sigmaC1 = settings.value("PPP/sigmaC1").toDouble(); if (opt->_sigmaC1 <= 0.0) opt->_sigmaC1 = 2.0;
176 opt->_sigmaL1 = settings.value("PPP/sigmaL1").toDouble(); if (opt->_sigmaL1 <= 0.0) opt->_sigmaL1 = 0.01;
177 opt->_corrWaitTime = settings.value("PPP/corrWaitTime").toDouble();
178
179 if (settings.value("PPP/lcGPS").toString() == "P1") {
180 opt->_LCsGPS.push_back(t_lc::c1);
181 }
182 else if (settings.value("PPP/lcGPS").toString() == "L1") {
183 opt->_LCsGPS.push_back(t_lc::l1);
184 }
185 else if (settings.value("PPP/lcGPS").toString() == "P1&L1") {
186 opt->_LCsGPS.push_back(t_lc::c1);
187 opt->_LCsGPS.push_back(t_lc::l1);
188 }
189 if (settings.value("PPP/lcGPS").toString() == "P2") {
190 opt->_LCsGPS.push_back(t_lc::c2);
191 }
192 else if (settings.value("PPP/lcGPS").toString() == "L2") {
193 opt->_LCsGPS.push_back(t_lc::l2);
194 }
195 else if (settings.value("PPP/lcGPS").toString() == "P2&L2") {
196 opt->_LCsGPS.push_back(t_lc::c2);
197 opt->_LCsGPS.push_back(t_lc::l2);
198 }
199 if (settings.value("PPP/lcGPS").toString() == "Pi") {
200 opt->_LCsGPS.push_back(t_lc::c1);
201 opt->_LCsGPS.push_back(t_lc::c2);
202 }
203 else if (settings.value("PPP/lcGPS").toString() == "Li") {
204 opt->_LCsGPS.push_back(t_lc::l1);
205 opt->_LCsGPS.push_back(t_lc::l2);
206 }
207 else if (settings.value("PPP/lcGPS").toString() == "Pi&Li") {
208 opt->_LCsGPS.push_back(t_lc::c1);
209 opt->_LCsGPS.push_back(t_lc::c2);
210 opt->_LCsGPS.push_back(t_lc::l1);
211 opt->_LCsGPS.push_back(t_lc::l2);
212 }
213 if (settings.value("PPP/lcGPS").toString() == "P3") {
214 opt->_LCsGPS.push_back(t_lc::cIF);
215 }
216 else if (settings.value("PPP/lcGPS").toString() == "L3") {
217 opt->_LCsGPS.push_back(t_lc::lIF);
218 }
219 else if (settings.value("PPP/lcGPS").toString() == "P3&L3") {
220 opt->_LCsGPS.push_back(t_lc::cIF);
221 opt->_LCsGPS.push_back(t_lc::lIF);
222 }
223
224 if (settings.value("PPP/lcGLONASS").toString() == "P1") {
225 opt->_LCsGLONASS.push_back(t_lc::c1);
226 }
227 else if (settings.value("PPP/lcGLONASS").toString() == "L1") {
228 opt->_LCsGLONASS.push_back(t_lc::l1);
229 }
230 else if (settings.value("PPP/lcGLONASS").toString() == "P1&L1") {
231 opt->_LCsGLONASS.push_back(t_lc::c1);
232 opt->_LCsGLONASS.push_back(t_lc::l1);
233 }
234 if (settings.value("PPP/lcGLONASS").toString() == "P2") {
235 opt->_LCsGLONASS.push_back(t_lc::c2);
236 }
237 else if (settings.value("PPP/lcGLONASS").toString() == "L2") {
238 opt->_LCsGLONASS.push_back(t_lc::l2);
239 }
240 else if (settings.value("PPP/lcGLONASS").toString() == "P2&L2") {
241 opt->_LCsGLONASS.push_back(t_lc::c2);
242 opt->_LCsGLONASS.push_back(t_lc::l2);
243 }
244 if (settings.value("PPP/lcGLONASS").toString() == "Pi") {
245 opt->_LCsGLONASS.push_back(t_lc::c1);
246 opt->_LCsGLONASS.push_back(t_lc::c2);
247 }
248 else if (settings.value("PPP/lcGLONASS").toString() == "Li") {
249 opt->_LCsGLONASS.push_back(t_lc::l1);
250 opt->_LCsGLONASS.push_back(t_lc::l2);
251 }
252 else if (settings.value("PPP/lcGLONASS").toString() == "Pi&Li") {
253 opt->_LCsGLONASS.push_back(t_lc::c1);
254 opt->_LCsGLONASS.push_back(t_lc::c2);
255 opt->_LCsGLONASS.push_back(t_lc::l1);
256 opt->_LCsGLONASS.push_back(t_lc::l2);
257 }
258 if (settings.value("PPP/lcGLONASS").toString() == "P3") {
259 opt->_LCsGLONASS.push_back(t_lc::cIF);
260 }
261 else if (settings.value("PPP/lcGLONASS").toString() == "L3") {
262 opt->_LCsGLONASS.push_back(t_lc::lIF);
263 }
264 else if (settings.value("PPP/lcGLONASS").toString() == "P3&L3") {
265 opt->_LCsGLONASS.push_back(t_lc::cIF);
266 opt->_LCsGLONASS.push_back(t_lc::lIF);
267 }
268
269 if (settings.value("PPP/lcGalileo").toString() == "P1") {
270 opt->_LCsGalileo.push_back(t_lc::c1);
271 }
272 else if (settings.value("PPP/lcGalileo").toString() == "L1") {
273 opt->_LCsGalileo.push_back(t_lc::l1);
274 }
275 else if (settings.value("PPP/lcGalileo").toString() == "P1&L1") {
276 opt->_LCsGalileo.push_back(t_lc::c1);
277 opt->_LCsGalileo.push_back(t_lc::l1);
278 }
279 if (settings.value("PPP/lcGalileo").toString() == "P5") {
280 opt->_LCsGalileo.push_back(t_lc::c2);
281 }
282 else if (settings.value("PPP/lcGalileo").toString() == "L5") {
283 opt->_LCsGalileo.push_back(t_lc::l2);
284 }
285 else if (settings.value("PPP/lcGalileo").toString() == "P5&L5") {
286 opt->_LCsGalileo.push_back(t_lc::c2);
287 opt->_LCsGalileo.push_back(t_lc::l2);
288 }
289 if (settings.value("PPP/lcGalileo").toString() == "Pi") {
290 opt->_LCsGalileo.push_back(t_lc::c1);
291 opt->_LCsGalileo.push_back(t_lc::c2);
292 }
293 else if (settings.value("PPP/lcGalileo").toString() == "Li") {
294 opt->_LCsGalileo.push_back(t_lc::l1);
295 opt->_LCsGalileo.push_back(t_lc::l2);
296 }
297 else if (settings.value("PPP/lcGalileo").toString() == "Pi&Li") {
298 opt->_LCsGalileo.push_back(t_lc::c1);
299 opt->_LCsGalileo.push_back(t_lc::c2);
300 opt->_LCsGalileo.push_back(t_lc::l1);
301 opt->_LCsGalileo.push_back(t_lc::l2);
302 }
303 if (settings.value("PPP/lcGalileo").toString() == "P3") {
304 opt->_LCsGalileo.push_back(t_lc::cIF);
305 }
306 else if (settings.value("PPP/lcGalileo").toString() == "L3") {
307 opt->_LCsGalileo.push_back(t_lc::lIF);
308 }
309 else if (settings.value("PPP/lcGalileo").toString() == "P3&L3") {
310 opt->_LCsGalileo.push_back(t_lc::cIF);
311 opt->_LCsGalileo.push_back(t_lc::lIF);
312 }
313
314 if (settings.value("PPP/lcBDS").toString() == "P2") {
315 opt->_LCsBDS.push_back(t_lc::c1);
316 }
317 else if (settings.value("PPP/lcBDS").toString() == "L2") {
318 opt->_LCsBDS.push_back(t_lc::l1);
319 }
320 else if (settings.value("PPP/lcBDS").toString() == "P2&L2") {
321 opt->_LCsBDS.push_back(t_lc::c1);
322 opt->_LCsBDS.push_back(t_lc::l1);
323 }
324 if (settings.value("PPP/lcBDS").toString() == "P7") {
325 opt->_LCsBDS.push_back(t_lc::c2);
326 }
327 else if (settings.value("PPP/lcBDS").toString() == "L7") {
328 opt->_LCsBDS.push_back(t_lc::l2);
329 }
330 else if (settings.value("PPP/lcBDS").toString() == "P7&L7") {
331 opt->_LCsBDS.push_back(t_lc::c2);
332 opt->_LCsBDS.push_back(t_lc::l2);
333 }
334 if (settings.value("PPP/lcBDS").toString() == "Pi") {
335 opt->_LCsBDS.push_back(t_lc::c1);
336 opt->_LCsBDS.push_back(t_lc::c2);
337 }
338 else if (settings.value("PPP/lcBDS").toString() == "Li") {
339 opt->_LCsBDS.push_back(t_lc::l1);
340 opt->_LCsBDS.push_back(t_lc::l2);
341 }
342 else if (settings.value("PPP/lcBDS").toString() == "Pi&Li") {
343 opt->_LCsBDS.push_back(t_lc::c1);
344 opt->_LCsBDS.push_back(t_lc::c2);
345 opt->_LCsBDS.push_back(t_lc::l1);
346 opt->_LCsBDS.push_back(t_lc::l2);
347 }
348 if (settings.value("PPP/lcBDS").toString() == "P3") {
349 opt->_LCsBDS.push_back(t_lc::cIF);
350 }
351 else if (settings.value("PPP/lcBDS").toString() == "L3") {
352 opt->_LCsBDS.push_back(t_lc::lIF);
353 }
354 else if (settings.value("PPP/lcBDS").toString() == "P3&L3") {
355 opt->_LCsBDS.push_back(t_lc::cIF);
356 opt->_LCsBDS.push_back(t_lc::lIF);
357 }
358
359 // Information from the coordinate file
360 // ------------------------------------
361 string crdFileName(settings.value("PPP/crdFile").toString().toStdString());
362 if (!crdFileName.empty()) {
363 vector<t_pppCrdFile::t_staInfo> staInfoVec;
364 t_pppCrdFile::readCrdFile(crdFileName, staInfoVec);
365 for (unsigned ii = 0; ii < staInfoVec.size(); ii++) {
366 const t_pppCrdFile::t_staInfo& staInfo = staInfoVec[ii];
367 if (staInfo._name == opt->_roverName) {
368 opt->_xyzAprRover[0] = staInfo._xyz[0];
369 opt->_xyzAprRover[1] = staInfo._xyz[1];
370 opt->_xyzAprRover[2] = staInfo._xyz[2];
371 opt->_neuEccRover[0] = staInfo._neuAnt[0];
372 opt->_neuEccRover[1] = staInfo._neuAnt[1];
373 opt->_neuEccRover[2] = staInfo._neuAnt[2];
374 opt->_antNameRover = staInfo._antenna;
375 opt->_recNameRover = staInfo._receiver;
376 break;
377 }
378 }
379 }
380
381 opt->_minObs = settings.value("PPP/minObs").toInt(); if (opt->_minObs < 4) opt->_minObs = 4;
382 opt->_minEle = settings.value("PPP/minEle").toDouble() * M_PI / 180.0;
383 opt->_maxResC1 = settings.value("PPP/maxResC1").toDouble(); if (opt->_maxResC1 <= 0.0) opt->_maxResC1 = 3.0;
384 opt->_maxResL1 = settings.value("PPP/maxResL1").toDouble(); if (opt->_maxResL1 <= 0.0) opt->_maxResL1 = 0.03;
385 opt->_eleWgtCode = (settings.value("PPP/eleWgtCode").toInt() != 0);
386 opt->_eleWgtPhase = (settings.value("PPP/eleWgtPhase").toInt() != 0);
387 opt->_seedingTime = settings.value("PPP/seedingTime").toDouble();
388
389 // Some default values
390 // -------------------
391 opt->_aprSigAmb = 100.0;
392 opt->_noiseClk = 1000.0;
393
394 _options << opt;
395 }
396}
397
Note: See TracBrowser for help on using the repository browser.