source: ntrip/trunk/BNC/RTCM/RTCM2.h@ 967

Last change on this file since 967 was 725, checked in by weber, 17 years ago

* empty log message *

File size: 8.4 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//
32// (c) DLR/GSOC
33//
34//------------------------------------------------------------------------------
35
36#ifndef INC_RTCM2_H
37#define INC_RTCM2_H
38
39#include <bitset>
40#include <fstream>
41#include <string>
42#include <vector>
43
44//
45// namespace rtcm2
46//
47
48namespace rtcm2 {
49
50
51//------------------------------------------------------------------------------
52//
53// class thirtyBitWord (specification)
54//
55// Purpose:
56//
57// Handling of RTCM2 30bit words
58//
59//------------------------------------------------------------------------------
60
61class ThirtyBitWord {
62
63 public:
64
65 // Constructor and initialization
66
67 ThirtyBitWord();
68
69 void clear();
70
71 // Status queries
72
73 bool fail() const;
74 bool validParity() const;
75 bool isHeader() const;
76
77 // Access methods
78
79 unsigned int all() const;
80 unsigned int value() const;
81
82 // Input
83
84 void get(const std::string& buf);
85 void get(std::istream& inp);
86 void getHeader(std::string& buf);
87 void getHeader(std::istream& inp);
88
89 private:
90
91 // Input
92
93 void append(unsigned char c);
94
95 private:
96
97// bool failure;
98
99 //
100 // A 32-bit integer is used to store the 30-bit RTCM word as well as 2
101 // parity bits retained from the previous word
102 //
103 // Bits 31..30 (from left to right) hold the parity bits D29*..D30* of
104 // the previous 30-bit word
105 // Bits 29..06 (from left to right) hold the current data bits D01..D24
106 // Bits 05..00 (from left to right) hold the current parity bits D25..D30
107 //
108
109 unsigned int W;
110
111};
112
113
114
115//------------------------------------------------------------------------------
116//
117// RTCM2packet (class definition)
118//
119// Purpose:
120//
121// A class for handling RTCM2 data packets
122//
123//------------------------------------------------------------------------------
124
125class RTCM2packet {
126
127 public:
128
129 // Constructor and initialization
130
131 RTCM2packet();
132
133 void clear();
134
135 // Status queries
136
137 bool valid() const;
138
139 // Input
140
141 void getPacket(std::string& buf);
142 void getPacket(std::istream& inp);
143 friend std::istream& operator >> (std::istream& is, RTCM2packet& p);
144
145 //
146 // Access methods
147 //
148
149 // Header and data words contents (parity corrected)
150
151 unsigned int header1() const;
152 unsigned int header2() const;
153 unsigned int dataWord(int i) const;
154
155 // Header information
156
157 unsigned int msgType() const;
158 unsigned int ID() const { return msgType(); };
159 unsigned int stationID() const;
160 unsigned int modZCount() const;
161 unsigned int seqNumber() const;
162 unsigned int nDataWords() const;
163 unsigned int staHealth() const;
164
165 // Data access
166
167 unsigned int getUnsignedBits (unsigned int start,
168 unsigned int n ) const;
169 int getBits (unsigned int start,
170 unsigned int n ) const;
171
172 private:
173
174 // All input of RTCM data uses a single instance, W, of a 30-bit word
175 // to maintain parity bits between consecutive inputs.
176
177 ThirtyBitWord W;
178
179 // Two 30-bit words make up the header of an RTCM2 message
180 // (parity corrected)
181
182 unsigned int H1;
183 unsigned int H2;
184
185 // Data words (parity corrected)
186
187 std::vector<unsigned int> DW;
188
189};
190
191
192//------------------------------------------------------------------------------
193//
194// RTCM2_03 (class definition)
195//
196// Purpose:
197//
198// A class for handling RTCM 2 GPS Reference Station Parameters messages
199//
200//------------------------------------------------------------------------------
201
202class RTCM2_03 {
203
204 public:
205
206 void extract(const RTCM2packet& P);
207
208 public:
209
210 bool validMsg; // Validity flag
211 double x,y,z; // Station coordinates
212
213};
214
215
216//------------------------------------------------------------------------------
217//
218// RTCM2_23 (class definition)
219//
220// Purpose:
221//
222// A class for handling RTCM 2 Antenna Type Definition messages
223//
224//------------------------------------------------------------------------------
225
226class RTCM2_23 {
227
228 public:
229
230 void extract(const RTCM2packet& P);
231
232 public:
233
234 bool validMsg; // Validity flag
235 std::string antType; // Antenna descriptor
236 std::string antSN ; // Antenna Serial Number
237
238};
239
240
241//------------------------------------------------------------------------------
242//
243// RTCM2_24 (class definition)
244//
245// Purpose:
246//
247// A class for handling RTCM 2 Reference Station Antenna
248// Reference Point Parameter messages
249//
250//------------------------------------------------------------------------------
251
252class RTCM2_24 {
253
254 public:
255
256 void extract(const RTCM2packet& P);
257
258 public:
259
260 bool validMsg; // Validity flag
261 bool isGPS; // Flag for GPS supporting station
262 bool isGLONASS; // Flag for GLONASS supporting station
263 double x,y,z; // Station coordinates (ECEF,[m])
264 double h; // Antenna height [m]
265
266};
267
268
269
270//------------------------------------------------------------------------------
271//
272// RTCM2_Obs (class definition)
273//
274// Purpose:
275//
276// A class for handling blocks of RTCM2 18 & 19 packets that need to be
277// combined to get a complete set of measurements
278//
279//------------------------------------------------------------------------------
280
281class RTCM2_Obs {
282
283 public:
284
285 RTCM2_Obs(); // Constructor
286
287 void extract(const RTCM2packet& P); // Packet handler
288 void clear(); // Initialization
289 bool valid() const; // Check for complete obs block
290
291 double resolvedPhase_L1(int i) const; // L1 & L2 carrier phase of i-th sat
292 double resolvedPhase_L2(int i) const; // with resolved 2^24 cy ambiguity
293 // (based on rng_C1)
294
295 void resolveEpoch (int refWeek, // Resolve epoch using reference
296 double refSecs, // epoch (GPS week and secs)
297 int& epochWeek,
298 double& epochSecs ) const;
299
300
301 public:
302
303 double secs; // Seconds of hour (GPS time)
304 int nSat; // Number of space vehicles
305 std::vector<int> PRN; // PRN (satellite number)
306 std::vector<double> rng_C1; // C/A code pseudorange on L1 [m]
307 std::vector<double> rng_P1; // P(Y) code pseudorange on L1 [m]
308 std::vector<double> rng_P2; // Pseudorange on L2 [m]
309 std::vector<double> cph_L1; // Carrier phase on L1 [cy]
310 std::vector<double> cph_L2; // Carrier phase on L2 [cy]
311
312 private:
313
314 bool anyGPS() const;
315 bool anyGLONASS() const;
316 bool allGPS() const;
317 bool allGLONASS() const;
318
319 private:
320
321 typedef std::bitset<8> msgflags;
322
323 msgflags availability; // Msg availability flags
324 bool GPSonly; // Flag for GPS-only station
325
326};
327
328
329}; // End of namespace rtcm2
330
331#endif // include blocker
Note: See TracBrowser for help on using the repository browser.