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

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

* empty log message *

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