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

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