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

Last change on this file since 254 was 254, checked in by mervart, 18 years ago

* empty log message *

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