source: ntrip/branches/BNC_2.11.0/src/RTCM/RTCM2.h@ 6398

Last change on this file since 6398 was 1105, checked in by weber, 16 years ago

* empty log message *

File size: 8.6 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
209 void extract(const RTCM2packet& P);
210
211 public:
212
213 bool validMsg; // Validity flag
214 double x,y,z; // Station coordinates
215
216};
217
218
219//------------------------------------------------------------------------------
220//
221// RTCM2_23 (class definition)
222//
223// Purpose:
224//
225// A class for handling RTCM 2 Antenna Type Definition messages
226//
227//------------------------------------------------------------------------------
228
229class RTCM2_23 {
230
231 public:
232
233 void extract(const RTCM2packet& P);
234
235 public:
236
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
259 void extract(const RTCM2packet& P);
260
261 public:
262
263 bool validMsg; // Validity flag
264 bool isGPS; // Flag for GPS supporting station
265 bool isGLONASS; // Flag for GLONASS supporting station
266 double x,y,z; // Station coordinates (ECEF,[m])
267 double h; // Antenna height [m]
268
269};
270
271
272
273//------------------------------------------------------------------------------
274//
275// RTCM2_Obs (class definition)
276//
277// Purpose:
278//
279// A class for handling blocks of RTCM2 18 & 19 packets that need to be
280// combined to get a complete set of measurements
281//
282//------------------------------------------------------------------------------
283
284class RTCM2_Obs {
285
286 public:
287
288 RTCM2_Obs(); // Constructor
289
290 void extract(const RTCM2packet& P); // Packet handler
291 void clear(); // Initialization
292 bool valid() const; // Check for complete obs block
293
294 double resolvedPhase_L1(int i) const; // L1 & L2 carrier phase of i-th sat
295 double resolvedPhase_L2(int i) const; // with resolved 2^24 cy ambiguity
296 // (based on rng_C1)
297
298 void resolveEpoch (int refWeek, // Resolve epoch using reference
299 double refSecs, // epoch (GPS week and secs)
300 int& epochWeek,
301 double& epochSecs ) const;
302
303
304 public:
305
306 double secs; // Seconds of hour (GPS time)
307 int nSat; // Number of space vehicles
308 std::vector<int> PRN; // PRN (satellite number)
309 std::vector<double> rng_C1; // C/A code pseudorange on L1 [m]
310 std::vector<double> rng_P1; // P(Y) code pseudorange on L1 [m]
311 std::vector<double> rng_P2; // Pseudorange on L2 [m]
312 std::vector<double> cph_L1; // Carrier phase on L1 [cy]
313 std::vector<double> cph_L2; // Carrier phase on L2 [cy]
314 std::vector<int> slip_L1; // Carrier phase slip counter, L1
315 std::vector<int> slip_L2; // Carrier phase slip counter, L1
316
317 private:
318
319 bool anyGPS() const;
320 bool anyGLONASS() const;
321 bool allGPS() const;
322 bool allGLONASS() const;
323
324 private:
325
326 typedef std::bitset<8> msgflags;
327
328 msgflags availability; // Msg availability flags
329 bool GPSonly; // Flag for GPS-only station
330
331};
332
333
334}; // End of namespace rtcm2
335
336#endif // include blocker
Note: See TracBrowser for help on using the repository browser.