source: ntrip/trunk/BNC/src/RTCM/RTCM2.h@ 10576

Last change on this file since 10576 was 7629, checked in by stuerze, 9 years ago

some value initialization in constructor is added

File size: 8.7 KB
RevLine 
[206]1//------------------------------------------------------------------------------
2//
3// RTCM2.h
4//
[7629]5// Purpose:
6//
[206]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,
[7629]13// Version 2.3, 20 Aug. 2001; Radio Technical Commission For Maritime
[206]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
[254]20// Sager J.; Decoder for RTCM SC-104 data from a DGPS beacon receiver;
[206]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
[242]27// 2006/10/05 OMO Specified const'ness of various member functions
[253]28// 2006/10/17 OMO Removed obsolete check of multiple message indicator
[332]29// 2006/11/25 OMO Revised check for presence of GLONASS data
[725]30// 2008/03/07 AHA Removed unnecessary failure flag
[1105]31// 2008/09/01 AHA Harmonization with newest BNC version
[206]32//
33// (c) DLR/GSOC
34//
35//------------------------------------------------------------------------------
36
37#ifndef INC_RTCM2_H
38#define INC_RTCM2_H
39
[7629]40#include <bitset>
[206]41#include <fstream>
42#include <string>
43#include <vector>
44
45//
46// namespace rtcm2
47//
48
49namespace rtcm2 {
50
51
52//------------------------------------------------------------------------------
53//
54// class thirtyBitWord (specification)
55//
56// Purpose:
[7629]57//
[206]58// Handling of RTCM2 30bit words
59//
60//------------------------------------------------------------------------------
61
62class ThirtyBitWord {
63
64 public:
[7629]65
[206]66 // Constructor and initialization
[7629]67
[206]68 ThirtyBitWord();
[7629]69
[206]70 void clear();
71
72 // Status queries
[7629]73
[206]74 bool fail() const;
75 bool validParity() const;
76 bool isHeader() const;
77
78 // Access methods
[7629]79
[206]80 unsigned int all() const;
81 unsigned int value() const;
[7629]82
[206]83 // Input
[7629]84
[725]85 void get(const std::string& buf);
[206]86 void get(std::istream& inp);
87 void getHeader(std::string& buf);
88 void getHeader(std::istream& inp);
[7629]89
[206]90 private:
[7629]91
[206]92 // Input
93
94 void append(unsigned char c);
95
96 private:
97
[725]98// bool failure;
[206]99
100 //
101 // A 32-bit integer is used to store the 30-bit RTCM word as well as 2
102 // parity bits retained from the previous word
103 //
[7629]104 // Bits 31..30 (from left to right) hold the parity bits D29*..D30* of
[206]105 // the previous 30-bit word
106 // Bits 29..06 (from left to right) hold the current data bits D01..D24
107 // Bits 05..00 (from left to right) hold the current parity bits D25..D30
108 //
109
[7629]110 unsigned int W;
111
[206]112};
113
114
115
116//------------------------------------------------------------------------------
117//
118// RTCM2packet (class definition)
119//
120// Purpose:
121//
122// A class for handling RTCM2 data packets
123//
124//------------------------------------------------------------------------------
125
126class RTCM2packet {
[7629]127
[206]128 public:
[7629]129
[206]130 // Constructor and initialization
[7629]131
[206]132 RTCM2packet();
[7629]133
[206]134 void clear();
[7629]135
[206]136 // Status queries
137
[7629]138 bool valid() const;
[206]139
[7629]140 // Input
141
[206]142 void getPacket(std::string& buf);
143 void getPacket(std::istream& inp);
144 friend std::istream& operator >> (std::istream& is, RTCM2packet& p);
[7629]145
[206]146 //
147 // Access methods
[7629]148 //
149
[206]150 // Header and data words contents (parity corrected)
[7629]151
[206]152 unsigned int header1() const;
153 unsigned int header2() const;
154 unsigned int dataWord(int i) const;
[7629]155
[206]156 // Header information
[7629]157
[206]158 unsigned int msgType() const;
159 unsigned int ID() const { return msgType(); };
160 unsigned int stationID() const;
161 unsigned int modZCount() const;
162 unsigned int seqNumber() const;
163 unsigned int nDataWords() const;
164 unsigned int staHealth() const;
165
166 // Data access
167
168 unsigned int getUnsignedBits (unsigned int start,
169 unsigned int n ) const;
170 int getBits (unsigned int start,
171 unsigned int n ) const;
172
173 private:
174
175 // All input of RTCM data uses a single instance, W, of a 30-bit word
[7629]176 // to maintain parity bits between consecutive inputs.
177
[206]178 ThirtyBitWord W;
179
180 // Two 30-bit words make up the header of an RTCM2 message
[7629]181 // (parity corrected)
182
[206]183 unsigned int H1;
184 unsigned int H2;
185
186 // Data words (parity corrected)
187
188 std::vector<unsigned int> DW;
189
[7629]190};
[206]191
[7629]192
[206]193//------------------------------------------------------------------------------
194//
195// RTCM2_03 (class definition)
196//
197// Purpose:
198//
199// A class for handling RTCM 2 GPS Reference Station Parameters messages
200//
201//------------------------------------------------------------------------------
202
203class RTCM2_03 {
[7629]204
[1105]205 public:
206 // Constructor
[7629]207 RTCM2_03() {
208 validMsg = false;
209 x = 0.0;
210 y = 0.0;
211 z = 0.0;
212 }
[1105]213 void extract(const RTCM2packet& P);
214 bool validMsg; // Validity flag
215 double x,y,z; // Station coordinates
216
[206]217};
218
219
220//------------------------------------------------------------------------------
221//
222// RTCM2_23 (class definition)
223//
224// Purpose:
225//
226// A class for handling RTCM 2 Antenna Type Definition messages
227//
228//------------------------------------------------------------------------------
229
230class RTCM2_23 {
231
232 public:
[7629]233 RTCM2_23 () {
234 validMsg = false;
235 }
[206]236 void extract(const RTCM2packet& P);
237 bool validMsg; // Validity flag
238 std::string antType; // Antenna descriptor
239 std::string antSN ; // Antenna Serial Number
240
241};
242
243
244//------------------------------------------------------------------------------
245//
246// RTCM2_24 (class definition)
247//
248// Purpose:
249//
[7629]250// A class for handling RTCM 2 Reference Station Antenna
[206]251// Reference Point Parameter messages
252//
253//------------------------------------------------------------------------------
254
255class RTCM2_24 {
256
257 public:
[7629]258 RTCM2_24 () {
259 validMsg = false;
260 isGPS = false;
261 isGLONASS = false;
262 x = 0.0;
263 y = 0.0;
264 z = 0.0;
265 h = 0.0;
266 }
[206]267 void extract(const RTCM2packet& P);
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//
[7629]284// A class for handling blocks of RTCM2 18 & 19 packets that need to be
[206]285// combined to get a complete set of measurements
286//
287//------------------------------------------------------------------------------
288
289class RTCM2_Obs {
290
[7629]291 public:
[206]292
293 RTCM2_Obs(); // Constructor
[7629]294
[206]295 void extract(const RTCM2packet& P); // Packet handler
296 void clear(); // Initialization
[7629]297 bool valid() const; // Check for complete obs block
[206]298
[242]299 double resolvedPhase_L1(int i) const; // L1 & L2 carrier phase of i-th sat
[7629]300 double resolvedPhase_L2(int i) const; // with resolved 2^24 cy ambiguity
[206]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,
[242]306 double& epochSecs ) const;
[206]307
[7629]308
309 public:
310
[206]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]
[1044]319 std::vector<int> slip_L1; // Carrier phase slip counter, L1
320 std::vector<int> slip_L2; // Carrier phase slip counter, L1
[206]321
322 private:
323
[242]324 bool anyGPS() const;
325 bool anyGLONASS() const;
326 bool allGPS() const;
327 bool allGLONASS() const;
[206]328
329 private:
330
331 typedef std::bitset<8> msgflags;
[7629]332
[206]333 msgflags availability; // Msg availability flags
[332]334 bool GPSonly; // Flag for GPS-only station
335
[7629]336};
[206]337
338
339}; // End of namespace rtcm2
340
341#endif // include blocker
Note: See TracBrowser for help on using the repository browser.