source: ntrip/trunk/BNC/src/RTCM/RTCM2.h@ 8509

Last change on this file since 8509 was 7629, checked in by stuerze, 9 years ago

some value initialization in constructor is added

File size: 8.7 KB
Line 
1//------------------------------------------------------------------------------
2//
3// RTCM2.h
4//
5// Purpose:
6//
7// Module for extraction of RTCM2 messages
8//
9// References:
10//
11// RTCM 10402.3 Recommended Standards for Differential GNSS (Global
12// Navigation Satellite Systems) Service; RTCM Paper 136-2001/SC104-STD,
13// Version 2.3, 20 Aug. 2001; Radio Technical Commission For Maritime
14// Services, Alexandria, Virgina (2001).
15// ICD-GPS-200; Navstar GPS Space Segment / Navigation User Interfaces;
16// Revison C; 25 Sept. 1997; Arinc Research Corp., El Segundo (1997).
17// Jensen M.; RTCM2ASC Documentation;
18// URL http://kom.aau.dk/~borre/masters/receiver/rtcm2asc.htm;
19// last accessed 17 Sep. 2006
20// Sager J.; Decoder for RTCM SC-104 data from a DGPS beacon receiver;
21// URL http://www.wsrcc.com/wolfgang/ftp/rtcm-0.3.tar.gz;
22// last accessed 17 Sep. 2006
23//
24// Last modified:
25//
26// 2006/09/17 OMO Created
27// 2006/10/05 OMO Specified const'ness of various member functions
28// 2006/10/17 OMO Removed obsolete check of multiple message indicator
29// 2006/11/25 OMO Revised check for presence of GLONASS data
30// 2008/03/07 AHA Removed unnecessary failure flag
31// 2008/09/01 AHA Harmonization with newest BNC version
32//
33// (c) DLR/GSOC
34//
35//------------------------------------------------------------------------------
36
37#ifndef INC_RTCM2_H
38#define INC_RTCM2_H
39
40#include <bitset>
41#include <fstream>
42#include <string>
43#include <vector>
44
45//
46// namespace rtcm2
47//
48
49namespace rtcm2 {
50
51
52//------------------------------------------------------------------------------
53//
54// class thirtyBitWord (specification)
55//
56// Purpose:
57//
58// Handling of RTCM2 30bit words
59//
60//------------------------------------------------------------------------------
61
62class ThirtyBitWord {
63
64 public:
65
66 // Constructor and initialization
67
68 ThirtyBitWord();
69
70 void clear();
71
72 // Status queries
73
74 bool fail() const;
75 bool validParity() const;
76 bool isHeader() const;
77
78 // Access methods
79
80 unsigned int all() const;
81 unsigned int value() const;
82
83 // Input
84
85 void get(const std::string& buf);
86 void get(std::istream& inp);
87 void getHeader(std::string& buf);
88 void getHeader(std::istream& inp);
89
90 private:
91
92 // Input
93
94 void append(unsigned char c);
95
96 private:
97
98// bool failure;
99
100 //
101 // A 32-bit integer is used to store the 30-bit RTCM word as well as 2
102 // parity bits retained from the previous word
103 //
104 // Bits 31..30 (from left to right) hold the parity bits D29*..D30* of
105 // the previous 30-bit word
106 // Bits 29..06 (from left to right) hold the current data bits D01..D24
107 // Bits 05..00 (from left to right) hold the current parity bits D25..D30
108 //
109
110 unsigned int W;
111
112};
113
114
115
116//------------------------------------------------------------------------------
117//
118// RTCM2packet (class definition)
119//
120// Purpose:
121//
122// A class for handling RTCM2 data packets
123//
124//------------------------------------------------------------------------------
125
126class RTCM2packet {
127
128 public:
129
130 // Constructor and initialization
131
132 RTCM2packet();
133
134 void clear();
135
136 // Status queries
137
138 bool valid() const;
139
140 // Input
141
142 void getPacket(std::string& buf);
143 void getPacket(std::istream& inp);
144 friend std::istream& operator >> (std::istream& is, RTCM2packet& p);
145
146 //
147 // Access methods
148 //
149
150 // Header and data words contents (parity corrected)
151
152 unsigned int header1() const;
153 unsigned int header2() const;
154 unsigned int dataWord(int i) const;
155
156 // Header information
157
158 unsigned int msgType() const;
159 unsigned int ID() const { return msgType(); };
160 unsigned int stationID() const;
161 unsigned int modZCount() const;
162 unsigned int seqNumber() const;
163 unsigned int nDataWords() const;
164 unsigned int staHealth() const;
165
166 // Data access
167
168 unsigned int getUnsignedBits (unsigned int start,
169 unsigned int n ) const;
170 int getBits (unsigned int start,
171 unsigned int n ) const;
172
173 private:
174
175 // All input of RTCM data uses a single instance, W, of a 30-bit word
176 // to maintain parity bits between consecutive inputs.
177
178 ThirtyBitWord W;
179
180 // Two 30-bit words make up the header of an RTCM2 message
181 // (parity corrected)
182
183 unsigned int H1;
184 unsigned int H2;
185
186 // Data words (parity corrected)
187
188 std::vector<unsigned int> DW;
189
190};
191
192
193//------------------------------------------------------------------------------
194//
195// RTCM2_03 (class definition)
196//
197// Purpose:
198//
199// A class for handling RTCM 2 GPS Reference Station Parameters messages
200//
201//------------------------------------------------------------------------------
202
203class RTCM2_03 {
204
205 public:
206 // Constructor
207 RTCM2_03() {
208 validMsg = false;
209 x = 0.0;
210 y = 0.0;
211 z = 0.0;
212 }
213 void extract(const RTCM2packet& P);
214 bool validMsg; // Validity flag
215 double x,y,z; // Station coordinates
216
217};
218
219
220//------------------------------------------------------------------------------
221//
222// RTCM2_23 (class definition)
223//
224// Purpose:
225//
226// A class for handling RTCM 2 Antenna Type Definition messages
227//
228//------------------------------------------------------------------------------
229
230class RTCM2_23 {
231
232 public:
233 RTCM2_23 () {
234 validMsg = false;
235 }
236 void extract(const RTCM2packet& P);
237 bool validMsg; // Validity flag
238 std::string antType; // Antenna descriptor
239 std::string antSN ; // Antenna Serial Number
240
241};
242
243
244//------------------------------------------------------------------------------
245//
246// RTCM2_24 (class definition)
247//
248// Purpose:
249//
250// A class for handling RTCM 2 Reference Station Antenna
251// Reference Point Parameter messages
252//
253//------------------------------------------------------------------------------
254
255class RTCM2_24 {
256
257 public:
258 RTCM2_24 () {
259 validMsg = false;
260 isGPS = false;
261 isGLONASS = false;
262 x = 0.0;
263 y = 0.0;
264 z = 0.0;
265 h = 0.0;
266 }
267 void extract(const RTCM2packet& P);
268 bool validMsg; // Validity flag
269 bool isGPS; // Flag for GPS supporting station
270 bool isGLONASS; // Flag for GLONASS supporting station
271 double x,y,z; // Station coordinates (ECEF,[m])
272 double h; // Antenna height [m]
273
274};
275
276
277
278//------------------------------------------------------------------------------
279//
280// RTCM2_Obs (class definition)
281//
282// Purpose:
283//
284// A class for handling blocks of RTCM2 18 & 19 packets that need to be
285// combined to get a complete set of measurements
286//
287//------------------------------------------------------------------------------
288
289class RTCM2_Obs {
290
291 public:
292
293 RTCM2_Obs(); // Constructor
294
295 void extract(const RTCM2packet& P); // Packet handler
296 void clear(); // Initialization
297 bool valid() const; // Check for complete obs block
298
299 double resolvedPhase_L1(int i) const; // L1 & L2 carrier phase of i-th sat
300 double resolvedPhase_L2(int i) const; // with resolved 2^24 cy ambiguity
301 // (based on rng_C1)
302
303 void resolveEpoch (int refWeek, // Resolve epoch using reference
304 double refSecs, // epoch (GPS week and secs)
305 int& epochWeek,
306 double& epochSecs ) const;
307
308
309 public:
310
311 double secs; // Seconds of hour (GPS time)
312 int nSat; // Number of space vehicles
313 std::vector<int> PRN; // PRN (satellite number)
314 std::vector<double> rng_C1; // C/A code pseudorange on L1 [m]
315 std::vector<double> rng_P1; // P(Y) code pseudorange on L1 [m]
316 std::vector<double> rng_P2; // Pseudorange on L2 [m]
317 std::vector<double> cph_L1; // Carrier phase on L1 [cy]
318 std::vector<double> cph_L2; // Carrier phase on L2 [cy]
319 std::vector<int> slip_L1; // Carrier phase slip counter, L1
320 std::vector<int> slip_L2; // Carrier phase slip counter, L1
321
322 private:
323
324 bool anyGPS() const;
325 bool anyGLONASS() const;
326 bool allGPS() const;
327 bool allGLONASS() const;
328
329 private:
330
331 typedef std::bitset<8> msgflags;
332
333 msgflags availability; // Msg availability flags
334 bool GPSonly; // Flag for GPS-only station
335
336};
337
338
339}; // End of namespace rtcm2
340
341#endif // include blocker
Note: See TracBrowser for help on using the repository browser.