source: ntrip/trunk/BNC/src/RTCM/GPSDecoder.cpp@ 4389

Last change on this file since 4389 was 4389, checked in by mervart, 12 years ago
File size: 9.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: GPSDecoder
30 *
31 * Purpose: Decoder Base Class
32 *
33 * Author: L. Mervart
34 *
35 * Created: 16-Dec-2011
36 *
37 * Changes:
38 *
39 * -----------------------------------------------------------------------*/
40
41#include <iomanip>
42#include <cmath>
43
44#include "GPSDecoder.h"
45#include "bncsettings.h"
46
47using namespace std;
48
49// Constructor
50//////////////////////////////////////////////////////////////////////////////
51GPSDecoder::GPSDecoder() {
52 _rnx = 0;
53}
54
55// Initialize RINEX Writer
56//////////////////////////////////////////////////////////////////////////////
57void GPSDecoder::initRinex(const QByteArray& staID, const QUrl& mountPoint,
58 const QByteArray& latitude,
59 const QByteArray& longitude, const QByteArray& nmea,
60 const QByteArray& ntripVersion) {
61 if (_rnx) {
62 return;
63 }
64 bncSettings settings;
65 if ( !settings.value("rnxPath").toString().isEmpty() ) {
66 _rnx = new bncRinex(staID, mountPoint, latitude, longitude,
67 nmea, ntripVersion);
68 }
69}
70
71// Write RINEX Epoch
72//////////////////////////////////////////////////////////////////////////////
73void GPSDecoder::dumpRinexEpoch(const t_obs& obs, const QByteArray& format) {
74 if (_rnx) {
75 long iSec = long(floor(obs.GPSWeeks+0.5));
76 long obsTime = obs.GPSWeek * 7*24*3600 + iSec;
77 if (_rnx->samplingRate() == 0 || iSec % _rnx->samplingRate() == 0) {
78 _rnx->deepCopy(obs);
79 }
80 _rnx->dumpEpoch(format, obsTime);
81 }
82}
83
84// Set RINEX Reconnect Flag
85//////////////////////////////////////////////////////////////////////////////
86void GPSDecoder::setRinexReconnectFlag(bool flag) {
87 if (_rnx) {
88 _rnx->setReconnectFlag(flag);
89 }
90}
91
92//
93//////////////////////////////////////////////////////////////////////////////
94double t_obs::c1() const {
95 if (_measdata[GNSSENTRY_C1DATA] != 0.0) return _measdata[GNSSENTRY_C1DATA];
96 if (_measdata[GNSSENTRY_C1NDATA] != 0.0) return _measdata[GNSSENTRY_C1NDATA];
97 return 0.0;
98}
99
100double t_obs::c2() const {
101 if (_measdata[GNSSENTRY_C2DATA] != 0.0) return _measdata[GNSSENTRY_C2DATA];
102 return 0.0;
103}
104
105double t_obs::c5() const {
106 if (_measdata[GNSSENTRY_C5DATA] != 0.0) return _measdata[GNSSENTRY_C5DATA];
107 if (_measdata[GNSSENTRY_C5BDATA] != 0.0) return _measdata[GNSSENTRY_C5BDATA];
108 if (_measdata[GNSSENTRY_C5ABDATA] != 0.0) return _measdata[GNSSENTRY_C5ABDATA];
109 return 0.0;
110}
111
112double t_obs::p1() const {
113 if (_measdata[GNSSENTRY_P1DATA] != 0.0) return _measdata[GNSSENTRY_P1DATA];
114 return 0.0;
115}
116
117double t_obs::p2() const {
118 if (_measdata[GNSSENTRY_P2DATA] != 0.0) return _measdata[GNSSENTRY_P2DATA];
119 return 0.0;
120}
121
122double t_obs::l1() const {
123 if (_measdata[GNSSENTRY_L1CDATA] != 0.0) return _measdata[GNSSENTRY_L1CDATA];
124 if (_measdata[GNSSENTRY_L1PDATA] != 0.0) return _measdata[GNSSENTRY_L1PDATA];
125 if (_measdata[GNSSENTRY_L1NDATA] != 0.0) return _measdata[GNSSENTRY_L1NDATA];
126 return 0.0;
127}
128
129double t_obs::l2() const {
130 if (_measdata[GNSSENTRY_L2CDATA] != 0.0) return _measdata[GNSSENTRY_L2CDATA];
131 if (_measdata[GNSSENTRY_L2PDATA] != 0.0) return _measdata[GNSSENTRY_L2PDATA];
132 return 0.0;
133}
134
135double t_obs::l5() const {
136 if (_measdata[GNSSENTRY_L5DATA] != 0.0) return _measdata[GNSSENTRY_L5DATA];
137 if (_measdata[GNSSENTRY_L5BDATA] != 0.0) return _measdata[GNSSENTRY_L5BDATA];
138 if (_measdata[GNSSENTRY_L5ABDATA] != 0.0) return _measdata[GNSSENTRY_L5ABDATA];
139 return 0.0;
140}
141
142double t_obs::s1() const {
143 if (_measdata[GNSSENTRY_S1CDATA] != 0.0) return _measdata[GNSSENTRY_S1CDATA];
144 if (_measdata[GNSSENTRY_S1PDATA] != 0.0) return _measdata[GNSSENTRY_S1PDATA];
145 if (_measdata[GNSSENTRY_S1NDATA] != 0.0) return _measdata[GNSSENTRY_S1NDATA];
146 return 0.0;
147}
148
149double t_obs::s2() const {
150 if (_measdata[GNSSENTRY_S2CDATA] != 0.0) return _measdata[GNSSENTRY_S2CDATA];
151 if (_measdata[GNSSENTRY_S2PDATA] != 0.0) return _measdata[GNSSENTRY_S2PDATA];
152 return 0.0;
153}
154
155//
156//////////////////////////////////////////////////////////////////////////////
157std::string t_obs::entry2str(int iEntry) const {
158 if (iEntry == GNSSENTRY_C1DATA ) return "C1";
159 if (iEntry == GNSSENTRY_L1CDATA ) return "L1C";
160 if (iEntry == GNSSENTRY_D1CDATA ) return "D1C";
161 if (iEntry == GNSSENTRY_S1CDATA ) return "S1C";
162 if (iEntry == GNSSENTRY_C2DATA ) return "C2";
163 if (iEntry == GNSSENTRY_L2CDATA ) return "L2C";
164 if (iEntry == GNSSENTRY_D2CDATA ) return "D2C";
165 if (iEntry == GNSSENTRY_S2CDATA ) return "S2C";
166 if (iEntry == GNSSENTRY_P1DATA ) return "P1";
167 if (iEntry == GNSSENTRY_L1PDATA ) return "L1P";
168 if (iEntry == GNSSENTRY_D1PDATA ) return "D1P";
169 if (iEntry == GNSSENTRY_S1PDATA ) return "S1P";
170 if (iEntry == GNSSENTRY_P2DATA ) return "P2";
171 if (iEntry == GNSSENTRY_L2PDATA ) return "L2P";
172 if (iEntry == GNSSENTRY_D2PDATA ) return "D2P";
173 if (iEntry == GNSSENTRY_S2PDATA ) return "S2P";
174 if (iEntry == GNSSENTRY_C5DATA ) return "C5";
175 if (iEntry == GNSSENTRY_L5DATA ) return "L5";
176 if (iEntry == GNSSENTRY_D5DATA ) return "D5";
177 if (iEntry == GNSSENTRY_S5DATA ) return "S5";
178 if (iEntry == GNSSENTRY_C6DATA ) return "C6";
179 if (iEntry == GNSSENTRY_L6DATA ) return "L6";
180 if (iEntry == GNSSENTRY_D6DATA ) return "D6";
181 if (iEntry == GNSSENTRY_S6DATA ) return "S6";
182 if (iEntry == GNSSENTRY_C5BDATA ) return "C5B";
183 if (iEntry == GNSSENTRY_L5BDATA ) return "L5B";
184 if (iEntry == GNSSENTRY_D5BDATA ) return "D5B";
185 if (iEntry == GNSSENTRY_S5BDATA ) return "S5B";
186 if (iEntry == GNSSENTRY_C5ABDATA ) return "C5AB";
187 if (iEntry == GNSSENTRY_L5ABDATA ) return "L5AB";
188 if (iEntry == GNSSENTRY_D5ABDATA ) return "D5AB";
189 if (iEntry == GNSSENTRY_S5ABDATA ) return "S5AB";
190 if (iEntry == GNSSENTRY_CSAIFDATA) return "CSAIF";
191 if (iEntry == GNSSENTRY_LSAIFDATA) return "LSAIF";
192 if (iEntry == GNSSENTRY_DSAIFDATA) return "DSAIF";
193 if (iEntry == GNSSENTRY_SSAIFDATA) return "SSAIF";
194 if (iEntry == GNSSENTRY_C1NDATA ) return "C1N";
195 if (iEntry == GNSSENTRY_L1NDATA ) return "L1N";
196 if (iEntry == GNSSENTRY_D1NDATA ) return "D1N";
197 if (iEntry == GNSSENTRY_S1NDATA ) return "S1N";
198
199 throw "Error in t_obs::entry2str";
200}
201
202//
203//////////////////////////////////////////////////////////////////////////////
204int t_obs::str2entry(const char* strIn) const {
205
206 string str(strIn);
207
208 if (str == "C1" ) return GNSSENTRY_C1DATA;
209 if (str == "L1C" ) return GNSSENTRY_L1CDATA;
210 if (str == "D1C" ) return GNSSENTRY_D1CDATA;
211 if (str == "S1C" ) return GNSSENTRY_S1CDATA;
212 if (str == "C2" ) return GNSSENTRY_C2DATA;
213 if (str == "L2C" ) return GNSSENTRY_L2CDATA;
214 if (str == "D2C" ) return GNSSENTRY_D2CDATA;
215 if (str == "S2C" ) return GNSSENTRY_S2CDATA;
216 if (str == "P1" ) return GNSSENTRY_P1DATA;
217 if (str == "L1P" ) return GNSSENTRY_L1PDATA;
218 if (str == "D1P" ) return GNSSENTRY_D1PDATA;
219 if (str == "S1P" ) return GNSSENTRY_S1PDATA;
220 if (str == "P2" ) return GNSSENTRY_P2DATA;
221 if (str == "L2P" ) return GNSSENTRY_L2PDATA;
222 if (str == "D2P" ) return GNSSENTRY_D2PDATA;
223 if (str == "S2P" ) return GNSSENTRY_S2PDATA;
224 if (str == "C5" ) return GNSSENTRY_C5DATA;
225 if (str == "L5" ) return GNSSENTRY_L5DATA;
226 if (str == "D5" ) return GNSSENTRY_D5DATA;
227 if (str == "S5" ) return GNSSENTRY_S5DATA;
228 if (str == "C6" ) return GNSSENTRY_C6DATA;
229 if (str == "L6" ) return GNSSENTRY_L6DATA;
230 if (str == "D6" ) return GNSSENTRY_D6DATA;
231 if (str == "S6" ) return GNSSENTRY_S6DATA;
232 if (str == "C5B" ) return GNSSENTRY_C5BDATA;
233 if (str == "L5B" ) return GNSSENTRY_L5BDATA;
234 if (str == "D5B" ) return GNSSENTRY_D5BDATA;
235 if (str == "S5B" ) return GNSSENTRY_S5BDATA;
236 if (str == "C5AB" ) return GNSSENTRY_C5ABDATA;
237 if (str == "L5AB" ) return GNSSENTRY_L5ABDATA;
238 if (str == "D5AB" ) return GNSSENTRY_D5ABDATA;
239 if (str == "S5AB" ) return GNSSENTRY_S5ABDATA;
240 if (str == "CSAIF") return GNSSENTRY_CSAIFDATA;
241 if (str == "LSAIF") return GNSSENTRY_LSAIFDATA;
242 if (str == "DSAIF") return GNSSENTRY_DSAIFDATA;
243 if (str == "SSAIF") return GNSSENTRY_SSAIFDATA;
244 if (str == "C1N" ) return GNSSENTRY_C1NDATA;
245 if (str == "L1N" ) return GNSSENTRY_L1NDATA;
246 if (str == "D1N" ) return GNSSENTRY_D1NDATA;
247 if (str == "S1N" ) return GNSSENTRY_S1NDATA;
248
249 throw "Error in t_obs::str2entry";
250}
Note: See TracBrowser for help on using the repository browser.