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

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

* empty log message *

File size: 8.3 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//
28// (c) DLR/GSOC
29//
30//------------------------------------------------------------------------------
31
32#ifndef INC_RTCM2_H
33#define INC_RTCM2_H
34
35#include <bitset>
36#include <fstream>
37#include <string>
38#include <vector>
39
40// begin added by LM
41#include "GPSDecoder.h"
42class RTCM2 : public GPSDecoder {
43public:
44 RTCM2();
45 ~RTCM2();
46 void Decode(char* buffer = 0, int bufLen = 0);
47private:
48 string _buffer;
49} ;
50// end added by LM
51
52//
53// namespace rtcm2
54//
55
56namespace rtcm2 {
57
58
59//------------------------------------------------------------------------------
60//
61// class thirtyBitWord (specification)
62//
63// Purpose:
64//
65// Handling of RTCM2 30bit words
66//
67//------------------------------------------------------------------------------
68
69class ThirtyBitWord {
70
71 public:
72
73 // Constructor and initialization
74
75 ThirtyBitWord();
76
77 void clear();
78
79 // Status queries
80
81 bool fail() const;
82 bool validParity() const;
83 bool isHeader() const;
84
85 // Access methods
86
87 unsigned int all() const;
88 unsigned int value() const;
89
90 // Input
91
92 void get(std::string& buf);
93 void get(std::istream& inp);
94 void getHeader(std::string& buf);
95 void getHeader(std::istream& inp);
96
97 private:
98
99 // Input
100
101 void append(unsigned char c);
102
103 private:
104
105 bool failure;
106
107 //
108 // A 32-bit integer is used to store the 30-bit RTCM word as well as 2
109 // parity bits retained from the previous word
110 //
111 // Bits 31..30 (from left to right) hold the parity bits D29*..D30* of
112 // the previous 30-bit word
113 // Bits 29..06 (from left to right) hold the current data bits D01..D24
114 // Bits 05..00 (from left to right) hold the current parity bits D25..D30
115 //
116
117 unsigned int W;
118
119};
120
121
122
123//------------------------------------------------------------------------------
124//
125// RTCM2packet (class definition)
126//
127// Purpose:
128//
129// A class for handling RTCM2 data packets
130//
131//------------------------------------------------------------------------------
132
133class RTCM2packet {
134
135 public:
136
137 // Constructor and initialization
138
139 RTCM2packet();
140
141 void clear();
142
143 // Status queries
144
145 bool valid() const;
146
147 // Input
148
149 void getPacket(std::string& buf);
150 void getPacket(std::istream& inp);
151 friend std::istream& operator >> (std::istream& is, RTCM2packet& p);
152
153 //
154 // Access methods
155 //
156
157 // Header and data words contents (parity corrected)
158
159 unsigned int header1() const;
160 unsigned int header2() const;
161 unsigned int dataWord(int i) const;
162
163 // Header information
164
165 unsigned int msgType() const;
166 unsigned int ID() const { return msgType(); };
167 unsigned int stationID() const;
168 unsigned int modZCount() const;
169 unsigned int seqNumber() const;
170 unsigned int nDataWords() const;
171 unsigned int staHealth() const;
172
173 // Data access
174
175 unsigned int getUnsignedBits (unsigned int start,
176 unsigned int n ) const;
177 int getBits (unsigned int start,
178 unsigned int n ) const;
179
180 private:
181
182 // All input of RTCM data uses a single instance, W, of a 30-bit word
183 // to maintain parity bits between consecutive inputs.
184
185 ThirtyBitWord W;
186
187 // Two 30-bit words make up the header of an RTCM2 message
188 // (parity corrected)
189
190 unsigned int H1;
191 unsigned int H2;
192
193 // Data words (parity corrected)
194
195 std::vector<unsigned int> DW;
196
197};
198
199
200//------------------------------------------------------------------------------
201//
202// RTCM2_03 (class definition)
203//
204// Purpose:
205//
206// A class for handling RTCM 2 GPS Reference Station Parameters messages
207//
208//------------------------------------------------------------------------------
209
210class RTCM2_03 {
211
212 public:
213
214 void extract(const RTCM2packet& P);
215
216 public:
217
218 bool validMsg; // Validity flag
219 double x,y,z; // Station coordinates
220
221};
222
223
224//------------------------------------------------------------------------------
225//
226// RTCM2_23 (class definition)
227//
228// Purpose:
229//
230// A class for handling RTCM 2 Antenna Type Definition messages
231//
232//------------------------------------------------------------------------------
233
234class RTCM2_23 {
235
236 public:
237
238 void extract(const RTCM2packet& P);
239
240 public:
241
242 bool validMsg; // Validity flag
243 std::string antType; // Antenna descriptor
244 std::string antSN ; // Antenna Serial Number
245
246};
247
248
249//------------------------------------------------------------------------------
250//
251// RTCM2_24 (class definition)
252//
253// Purpose:
254//
255// A class for handling RTCM 2 Reference Station Antenna
256// Reference Point Parameter messages
257//
258//------------------------------------------------------------------------------
259
260class RTCM2_24 {
261
262 public:
263
264 void extract(const RTCM2packet& P);
265
266 public:
267
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(); // Check for complete obs block
298
299 double resolvedPhase_L1(int i); // L1 & L2 carrier phase of i-th sat
300 double resolvedPhase_L2(int i); // 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 );
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
320 private:
321
322 bool anyGPS();
323 bool anyGLONASS();
324 bool allGPS();
325 bool allGLONASS();
326
327 private:
328
329 typedef std::bitset<8> msgflags;
330
331 msgflags availability; // Msg availability flags
332 bool pendingMsg; // Multiple message indicator
333
334};
335
336
337}; // End of namespace rtcm2
338
339#endif // include blocker
Note: See TracBrowser for help on using the repository browser.