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

Last change on this file since 1081 was 1044, checked in by zdenek, 16 years ago

Zdenek Lukes: a) added logic for RTCM 2.3 messages 20/21 decoding

b) added logic for cycle slip flags (slip counters or lock time indicators) handling

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