source: ntrip/trunk/BNC/src/PPP/pppMain.cpp@ 5911

Last change on this file since 5911 was 5911, checked in by mervart, 8 years ago
File size: 7.2 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}
62
63//
64//////////////////////////////////////////////////////////////////////////////
65void t_pppMain::start(bool ownThread) {
66 if (_running) {
67 return;
68 }
69
70 try {
71 readOptions();
72
73 QListIterator<t_pppOptions*> iOpt(_options);
74 while (iOpt.hasNext()) {
75 const t_pppOptions* opt = iOpt.next();
76 t_pppThread* pppThread = new t_pppThread(ownThread, opt);
77 if (ownThread) {
78 pppThread->start();
79 }
80 else {
81 pppThread->run();
82 }
83 _pppThreads << pppThread;
84 _running = true;
85 }
86 }
87 catch (t_except exc) {
88 _running = true;
89 stop();
90 }
91}
92
93//
94//////////////////////////////////////////////////////////////////////////////
95void t_pppMain::stop() {
96
97 if (!_running) {
98 return;
99 }
100
101 QListIterator<t_pppThread*> it(_pppThreads);
102 while (it.hasNext()) {
103 t_pppThread* pppThread = it.next();
104 pppThread->exit();
105 }
106 _pppThreads.clear();
107
108 QListIterator<t_pppOptions*> iOpt(_options);
109 while (iOpt.hasNext()) {
110 delete iOpt.next();
111 }
112 _options.clear();
113
114 _running = false;
115}
116
117//
118//////////////////////////////////////////////////////////////////////////////
119void t_pppMain::readOptions() {
120
121 QListIterator<t_pppOptions*> iOpt(_options);
122 while (iOpt.hasNext()) {
123 delete iOpt.next();
124 }
125 _options.clear();
126
127 bncSettings settings;
128
129 _logFile = settings.value("PPP/logFile").toString();
130 _nmeaFile = settings.value("PPP/nmeaFile").toString();
131 _nmeaPort = settings.value("PPP/nmeaPort").toInt();
132
133 bool realTime = false;
134 if (settings.value("PPP/dataSource").toString() == "Real-Time Streams") {
135 realTime = true;
136 }
137 else if (settings.value("PPP/dataSource").toString() == "RINEX Files") {
138 realTime = false;
139 }
140 else {
141 return;
142 }
143
144 QListIterator<QString> iSta(settings.value("PPP/staTable").toStringList());
145 while (iSta.hasNext()) {
146 QStringList hlp = iSta.next().split(",");
147
148 if (hlp.size() < 9) {
149 throw t_except("pppMain: wrong option staTable");
150 }
151
152 t_pppOptions* opt = new t_pppOptions();
153
154 opt->_realTime = realTime;
155 opt->_roverName = hlp[0].toAscii().data();
156 opt->_sigCrd[0] = hlp[1].toDouble();
157 opt->_sigCrd[1] = hlp[2].toDouble();
158 opt->_sigCrd[2] = hlp[3].toDouble();
159 opt->_noiseCrd[0] = hlp[4].toDouble();
160 opt->_noiseCrd[1] = hlp[5].toDouble();
161 opt->_noiseCrd[2] = hlp[6].toDouble();
162 opt->_sigTropo = hlp[7].toDouble();
163 opt->_noiseTropo = hlp[8].toDouble();
164
165 if (realTime) {
166 opt->_corrMount = settings.value("PPP/corrMount").toString().toAscii().data();
167 }
168 else {
169 opt->_rinexObs = settings.value("PPP/rinexObs").toString().toAscii().data();
170 opt->_rinexNav = settings.value("PPP/rinexNav").toString().toAscii().data();
171 opt->_corrFile = settings.value("PPP/corrFile").toString().toAscii().data();
172 }
173
174 opt->_crdFile = settings.value("PPP/crdFile").toString().toAscii().data();
175 opt->_antexFile = settings.value("PPP/antexFile").toString().toAscii().data();
176
177 opt->_sigmaC1 = settings.value("PPP/sigmaC1").toDouble();
178 opt->_sigmaL1 = settings.value("PPP/sigmaL1").toDouble();
179 opt->_corrWaitTime = settings.value("PPP/corrWaitTime").toDouble();
180
181 if (settings.value("PPP/lcGPS").toString() == "P3") {
182 opt->_lcGPS.push_back(t_lc::cIF);
183 }
184 else if (settings.value("PPP/lcGPS").toString() == "L3") {
185 opt->_lcGPS.push_back(t_lc::lIF);
186 }
187 else if (settings.value("PPP/lcGPS").toString() == "P3&L3") {
188 opt->_lcGPS.push_back(t_lc::cIF);
189 opt->_lcGPS.push_back(t_lc::lIF);
190 }
191
192 if (settings.value("PPP/lcGLONASS").toString() == "P3") {
193 opt->_lcGLONASS.push_back(t_lc::cIF);
194 }
195 else if (settings.value("PPP/lcGLONASS").toString() == "L3") {
196 opt->_lcGLONASS.push_back(t_lc::lIF);
197 }
198 else if (settings.value("PPP/lcGLONASS").toString() == "P3&L3") {
199 opt->_lcGLONASS.push_back(t_lc::cIF);
200 opt->_lcGLONASS.push_back(t_lc::lIF);
201 }
202
203 if (settings.value("PPP/lcGalileo").toString() == "P3") {
204 opt->_lcGalileo.push_back(t_lc::cIF);
205 }
206 else if (settings.value("PPP/lcGalileo").toString() == "L3") {
207 opt->_lcGalileo.push_back(t_lc::lIF);
208 }
209 else if (settings.value("PPP/lcGalileo").toString() == "P3&L3") {
210 opt->_lcGalileo.push_back(t_lc::cIF);
211 opt->_lcGalileo.push_back(t_lc::lIF);
212 }
213
214 // Information from the coordinate file
215 // ------------------------------------
216 string crdFileName(settings.value("PPP/crdFile").toString().toAscii().data());
217 if (!crdFileName.empty()) {
218 vector<t_pppCrdFile::t_staInfo> staInfoVec;
219 t_pppCrdFile::readCrdFile(crdFileName, staInfoVec);
220 for (unsigned ii = 0; ii < staInfoVec.size(); ii++) {
221 const t_pppCrdFile::t_staInfo& staInfo = staInfoVec[ii];
222 if (staInfo._name == opt->_roverName) {
223 opt->_xyzAprRover[0] = staInfo._xyz[0];
224 opt->_xyzAprRover[1] = staInfo._xyz[1];
225 opt->_xyzAprRover[2] = staInfo._xyz[2];
226 opt->_neuEccRover[0] = staInfo._neuAnt[0];
227 opt->_neuEccRover[1] = staInfo._neuAnt[1];
228 opt->_neuEccRover[2] = staInfo._neuAnt[2];
229 opt->_antNameRover = staInfo._antenna;
230 break;
231 }
232 }
233 }
234
235 // Some default values
236 // -------------------
237 opt->_minObs = 4;
238 opt->_minEle = 10.0 * M_PI / 180.0;
239 opt->_maxResC1 = 10.0;
240 opt->_maxResL1 = 0.10;
241 opt->_eleWgtCode = false;
242 opt->_eleWgtPhase = false;
243
244 _options << opt;
245 }
246}
247
Note: See TracBrowser for help on using the repository browser.