source: ntrip/trunk/clock_and_orbit/lib/clock_orbit_rtcm.h@ 6075

Last change on this file since 6075 was 5664, checked in by stoecker, 11 years ago

SSR update

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 11.2 KB
Line 
1#ifndef RTCM3_CLOCK_ORBIT_RTCM_H
2#define RTCM3_CLOCK_ORBIT_RTCM_H
3
4/* Programheader
5
6 Name: clock_orbit_rtcm.h
7 Project: RTCM3
8 Version: $Id: clock_orbit_rtcm.h 5664 2014-05-26 15:09:28Z stoecker $
9 Authors: Dirk Stöcker
10 Description: state space approach for RTCM3
11*/
12
13#include <string.h>
14
15enum SatelliteReferenceDatum { DATUM_ITRF=0, DATUM_LOCAL=1 };
16
17enum COR_BASE {
18 COBBASE_GPS = 1057,
19 COBBASE_GLONASS = 1063,
20 COBBASE_GALILEO = 1240,
21 COBBASE_QZSS = 1246,
22 COBBASE_SBAS = 1252,
23 COBBASE_BDS = 1258,
24};
25
26enum COR_OFFSET {
27 COBOFS_ORBIT = 0,
28 COBOFS_CLOCK,
29 COBOFS_BIAS,
30 COBOFS_COMBINED,
31 COBOFS_URA,
32 COBOFS_HR,
33 COBOFS_NUM
34};
35
36enum ClockOrbitType {
37 COTYPE_GPSORBIT = COBBASE_GPS + COBOFS_ORBIT,
38 COTYPE_GPSCLOCK,
39 COTYPE_GPSCOMBINED = COBBASE_GPS + COBOFS_COMBINED,
40 COTYPE_GPSURA,
41 COTYPE_GPSHR,
42
43 COTYPE_GLONASSORBIT = COBBASE_GLONASS + COBOFS_ORBIT,
44 COTYPE_GLONASSCLOCK,
45 COTYPE_GLONASSCOMBINED = COBBASE_GLONASS + COBOFS_COMBINED,
46 COTYPE_GLONASSURA,
47 COTYPE_GLONASSHR,
48
49 COTYPE_GALILEOORBIT = COBBASE_GALILEO + COBOFS_ORBIT,
50 COTYPE_GALILEOCLOCK,
51 COTYPE_GALILEOCOMBINED = COBBASE_GALILEO + COBOFS_COMBINED,
52 COTYPE_GALILEOURA,
53 COTYPE_GALILEOHR,
54
55 COTYPE_QZSSORBIT = COBBASE_QZSS + COBOFS_ORBIT,
56 COTYPE_QZSSCLOCK,
57 COTYPE_QZSSCOMBINED = COBBASE_QZSS + COBOFS_COMBINED,
58 COTYPE_QZSSURA,
59 COTYPE_QZSSHR,
60
61 COTYPE_SBASORBIT = COBBASE_SBAS + COBOFS_ORBIT,
62 COTYPE_SBASCLOCK,
63 COTYPE_SBASCOMBINED = COBBASE_QZSS + COBOFS_COMBINED,
64 COTYPE_SBASURA,
65 COTYPE_SBASHR,
66
67 COTYPE_BDSORBIT = COBBASE_BDS + COBOFS_ORBIT,
68 COTYPE_BDSCLOCK,
69 COTYPE_BDSCOMBINED = COBBASE_BDS + COBOFS_COMBINED,
70 COTYPE_BDSURA,
71 COTYPE_BDSHR,
72
73 COTYPE_AUTO = 0,
74};
75
76enum CodeBiasType {
77 BTYPE_GPS = COBBASE_GPS + COBOFS_BIAS,
78 BTYPE_GLONASS = COBBASE_GLONASS + COBOFS_BIAS,
79 BTYPE_GALILEO = COBBASE_GALILEO + COBOFS_BIAS,
80 BTYPE_QZSS = COBBASE_QZSS + COBOFS_BIAS,
81 BTYPE_SBAS = COBBASE_QZSS + COBOFS_BIAS,
82 BTYPE_BDS = COBBASE_BDS + COBOFS_BIAS,
83 BTYPE_AUTO = 0
84};
85
86enum PhaseBiasType {
87 PBTYPE_BASE = 1265,
88 PBTYPE_GPS = PBTYPE_BASE,
89 PBTYPE_GLONASS,
90 PBTYPE_GALILEO,
91 PBTYPE_QZSS,
92 PBTYPE_SBAS,
93 PBTYPE_BDS,
94 PBTYPE_AUTO = 0
95};
96
97enum VTECType {
98 VTEC_BASE = 1264
99};
100
101/* if some systems aren't supported at all, change the following numbers to zero
102for these systems to save space */
103enum COR_CONSTANTS {
104 CLOCKORBIT_BUFFERSIZE=2048,
105 CLOCKORBIT_NUMGPS=32,
106 CLOCKORBIT_NUMGLONASS=24,
107 CLOCKORBIT_NUMGALILEO=36,
108 CLOCKORBIT_NUMQZSS=10,
109 CLOCKORBIT_NUMSBAS=38,
110 CLOCKORBIT_NUMBDS=37,
111 CLOCKORBIT_NUMBIAS=10,
112 CLOCKORBIT_NUMIONOLAYERS=4,
113 CLOCKORBIT_MAXIONOORDER=8,
114 CLOCKORBIT_MAXIONODEGREE=8
115};
116
117enum COR_SATSYSTEM {
118 CLOCKORBIT_SATGPS=0,
119 CLOCKORBIT_SATGLONASS,
120 CLOCKORBIT_SATGALILEO,
121 CLOCKORBIT_SATQZSS,
122 CLOCKORBIT_SATSBAS,
123 CLOCKORBIT_SATBDS,
124 CLOCKORBIT_SATNUM
125};
126
127enum COR_OFFSETS {
128 CLOCKORBIT_OFFSETGPS=0,
129 CLOCKORBIT_OFFSETGLONASS=CLOCKORBIT_NUMGPS,
130 CLOCKORBIT_OFFSETGALILEO=CLOCKORBIT_NUMGPS+CLOCKORBIT_NUMGLONASS,
131 CLOCKORBIT_OFFSETQZSS=CLOCKORBIT_NUMGPS+CLOCKORBIT_NUMGLONASS
132 +CLOCKORBIT_NUMGALILEO,
133 CLOCKORBIT_OFFSETSBAS=CLOCKORBIT_NUMGPS+CLOCKORBIT_NUMGLONASS
134 +CLOCKORBIT_NUMGALILEO+CLOCKORBIT_NUMQZSS,
135 CLOCKORBIT_OFFSETBDS=CLOCKORBIT_NUMGPS+CLOCKORBIT_NUMGLONASS
136 +CLOCKORBIT_NUMGALILEO+CLOCKORBIT_NUMQZSS+CLOCKORBIT_NUMSBAS,
137 CLOCKORBIT_COUNTSAT=CLOCKORBIT_NUMGPS+CLOCKORBIT_NUMGLONASS
138 +CLOCKORBIT_NUMGALILEO+CLOCKORBIT_NUMQZSS+CLOCKORBIT_NUMSBAS
139 +CLOCKORBIT_NUMBDS
140};
141
142enum CodeType {
143 CODETYPEGPS_L1_CA = 0,
144 CODETYPEGPS_L1_P = 1,
145 CODETYPEGPS_L1_Z = 2,
146 /*CODETYPEGPS_L1_Y = 3,
147 CODETYPEGPS_L1_M = 4,*/
148 CODETYPEGPS_L2_CA = 5,
149 CODETYPEGPS_SEMI_CODELESS = 6,
150 CODETYPEGPS_L2_CM = 7,
151 CODETYPEGPS_L2_CL = 8,
152 CODETYPEGPS_L2_CML = 9,
153 CODETYPEGPS_L2_P = 10,
154 CODETYPEGPS_L2_Z = 11,
155 /*CODETYPEGPS_L2_Y = 12,
156 CODETYPEGPS_L2_M = 13,*/
157 CODETYPEGPS_L5_I = 14,
158 CODETYPEGPS_L5_Q = 15,
159 /*CODETYPEGPS_L5_IQ = 16,*/
160
161 CODETYPEGLONASS_L1_CA = 0,
162 CODETYPEGLONASS_L1_P = 1,
163 CODETYPEGLONASS_L2_CA = 2,
164 CODETYPEGLONASS_L2_P = 3,
165
166 CODETYPEGALILEO_E1_A = 0,
167 CODETYPEGALILEO_E1_B = 1,
168 CODETYPEGALILEO_E1_C = 2,
169 CODETYPEGALILEO_E5A_I = 5,
170 CODETYPEGALILEO_E5A_Q = 6,
171 CODETYPEGALILEO_E5B_I = 8,
172 CODETYPEGALILEO_E5B_Q = 9,
173 CODETYPEGALILEO_E5_I = 11,
174 CODETYPEGALILEO_E5_Q = 12,
175 CODETYPEGALILEO_E6_A = 14,
176 CODETYPEGALILEO_E6_B = 15,
177 CODETYPEGALILEO_E6_C = 16,
178
179 CODETYPEQZSS_L1_CA = 0,
180 CODETYPEQZSS_L1C_D = 1,
181 CODETYPEQZSS_L1C_P = 2,
182 CODETYPEQZSS_L2_CM = 3,
183 CODETYPEQZSS_L2_CL = 4,
184 CODETYPEQZSS_L2_CML = 5,
185 CODETYPEQZSS_L5_I = 6,
186 CODETYPEQZSS_L5_Q = 7,
187 CODETYPEQZSS_L5_IQ = 8,
188 CODETYPEQZSS_LEX_S = 9,
189 CODETYPEQZSS_LEX_L = 10,
190 CODETYPEQZSS_LEX_SL = 11,
191 CODETYPEQZSS_L1C_DP = 12,
192
193 CODETYPE_SBAS_L1_CA = 0,
194 CODETYPE_SBAS_L5_I = 1,
195 CODETYPE_SBAS_L5_Q = 2,
196 CODETYPE_SBAS_L5_IQ = 3,
197
198 CODETYPE_BDS_B1_I = 0,
199 CODETYPE_BDS_B1_Q = 1,
200 CODETYPE_BDS_B1_IQ = 2,
201 CODETYPE_BDS_B3_I = 3,
202 CODETYPE_BDS_B3_Q = 4,
203 CODETYPE_BDS_B3_IQ = 5,
204 CODETYPE_BDS_B2_I = 6,
205 CODETYPE_BDS_B2_Q = 7,
206 CODETYPE_BDS_B2_IQ = 8,
207};
208
209#define SSR_MAXURA 5.5 /* > 5466.5mm in meter */
210
211/* satellite system data data is stored with offset CLOCKORBIT_OFFSET...
212in the data structures. So first GLONASS satellite is at
213xxx->Sat[CLOCKORBIT_OFFSETGLONASS], first GPS satellite is
214xxx->Sat[CLOCKORBIT_OFFSETGPS]. */
215
216#ifdef COR_LEGACY
217/* old names */
218#define NumberOfGPSSat NumberOfSat[CLOCKORBIT_SATGPS]
219#define NumberOfGLONASSSat NumberOfSat[CLOCKORBIT_SATGLONASS]
220#define GPSEpochTime EpochTime[CLOCKORBIT_SATGPS] /* 0 .. 604799 s */
221#define GLONASSEpochTime EpochTime[CLOCKORBIT_SATGLONASS] /* 0 .. 86399 s (86400 for leap second) */
222#define ClockDataSupplied Supplied[COBOFS_CLOCK]
223#define HRDataSupplied Supplied[COBOFS_HR]
224#define OrbitDataSupplied Supplied[COBOFS_ORBIT]
225#define URADataSupplied Supplied[COBOFS_URA]
226#define GetClockOrbitBias(a,b,c,d,e) GetSSR(a,b,0,0,c,d,e)
227#endif /* COR_LEGACY */
228
229/* latency check code, disabled by default */
230#ifdef COR_LATENCY
231#define COR_LATENCYCOUNT 100
232#endif
233
234struct ClockOrbit
235{
236 enum ClockOrbitType messageType;
237 unsigned int EpochTime[CLOCKORBIT_SATNUM]; /* 0 .. system specific maximum */
238 unsigned int NumberOfSat[CLOCKORBIT_SATNUM]; /* 0 .. CLOCKORBIT_NUM... */
239
240 unsigned int Supplied[COBOFS_NUM]; /* boolean */
241#ifdef COR_LATENCY
242 unsigned int epochGPS[COR_LATENCYCOUNT+1]; /* Weber, for latency */
243 unsigned int epochSize; /* Weber, for latency */
244#endif
245 unsigned int SSRIOD;
246 unsigned int SSRProviderID;
247 unsigned int SSRSolutionID;
248 unsigned int UpdateInterval;
249 enum SatelliteReferenceDatum SatRefDatum;
250 struct SatData {
251 unsigned int ID; /* all */
252 unsigned int IOD; /* all */
253 unsigned int toe; /* SBAS, BDS */
254 double UserRangeAccuracy; /* accuracy values in [m] */
255 double hrclock;
256 struct OrbitPart
257 {
258 double DeltaRadial; /* m */
259 double DeltaAlongTrack; /* m */
260 double DeltaCrossTrack; /* m */
261 double DotDeltaRadial; /* m/s */
262 double DotDeltaAlongTrack; /* m/s */
263 double DotDeltaCrossTrack; /* m/s */
264 } Orbit;
265 struct ClockPart
266 {
267 double DeltaA0; /* m */
268 double DeltaA1; /* m/s */
269 double DeltaA2; /* m/ss */
270 } Clock;
271 } Sat[CLOCKORBIT_COUNTSAT];
272};
273
274struct CodeBias
275{
276 enum CodeBiasType messageType;
277 unsigned int EpochTime[CLOCKORBIT_SATNUM]; /* 0 .. system specific maximum */
278 unsigned int NumberOfSat[CLOCKORBIT_SATNUM]; /* 0 .. CLOCKORBIT_NUM... */
279 unsigned int UpdateInterval;
280 unsigned int SSRIOD;
281 unsigned int SSRProviderID;
282 unsigned int SSRSolutionID;
283 struct BiasSat
284 {
285 unsigned int ID; /* all */
286 unsigned int NumberOfCodeBiases;
287 struct CodeBiasEntry
288 {
289 enum CodeType Type;
290 float Bias; /* m */
291 } Biases[CLOCKORBIT_NUMBIAS];
292 } Sat[CLOCKORBIT_COUNTSAT];
293};
294
295struct PhaseBias
296{
297 enum PhaseBiasType messageType;
298 unsigned int EpochTime[CLOCKORBIT_SATNUM]; /* 0 .. system specific maximum */
299 unsigned int NumberOfSat[CLOCKORBIT_SATNUM]; /* 0 .. CLOCKORBIT_NUM... */
300 unsigned int UpdateInterval;
301 unsigned int SSRIOD;
302 unsigned int SSRProviderID;
303 unsigned int SSRSolutionID;
304 unsigned int DispersiveBiasConsistencyIndicator;
305 unsigned int MWConsistencyIndicator;
306 struct PhaseBiasSat
307 {
308 unsigned int ID; /* all */
309 unsigned int NumberOfPhaseBiases;
310 double YawAngle; /* radiant */
311 double YawRate; /* radiant/s */
312 struct PhaseBiasEntry
313 {
314 enum CodeType Type;
315 unsigned int SignalIntegerIndicator;
316 unsigned int SignalsWideLaneIntegerIndicator;
317 unsigned int SignalDiscontinuityCounter;
318 float Bias; /* m */
319 } Biases[CLOCKORBIT_NUMBIAS];
320 } Sat[CLOCKORBIT_COUNTSAT];
321};
322
323struct VTEC
324{
325 unsigned int EpochTime; /* GPS */
326 unsigned int UpdateInterval;
327 unsigned int SSRIOD;
328 unsigned int SSRProviderID;
329 unsigned int SSRSolutionID;
330 unsigned int NumLayers; /* 1-4 */
331 double Quality;
332 struct IonoLayers {
333 double Height; /* m */
334 unsigned int Degree; /* 1-8 */
335 unsigned int Order; /* 1-8 */
336 double Sinus[CLOCKORBIT_MAXIONODEGREE][CLOCKORBIT_MAXIONOORDER];
337 double Cosinus[CLOCKORBIT_MAXIONODEGREE][CLOCKORBIT_MAXIONOORDER];
338 } Layers[CLOCKORBIT_NUMIONOLAYERS];
339};
340
341/* return size of resulting data or 0 in case of an error */
342size_t MakeClockOrbit(const struct ClockOrbit *co, enum ClockOrbitType type,
343 int moremessagesfollow, char *buffer, size_t size);
344size_t MakeCodeBias(const struct CodeBias *b, enum CodeBiasType type,
345 int moremessagesfollow, char *buffer, size_t size);
346size_t MakePhaseBias(const struct PhaseBias *b, enum PhaseBiasType type,
347 int moremessagesfollow, char *buffer, size_t size);
348size_t MakeVTEC(const struct VTEC *b, int moremessagesfollow, char *buffer,
349 size_t size);
350
351enum GCOB_RETURN {
352 /* all well */
353 GCOBR_MESSAGEFOLLOWS = 1,
354 GCOBR_OK = 0,
355 /* unknown data, a warning */
356 GCOBR_UNKNOWNTYPE = -1,
357 GCOBR_UNKNOWNDATA = -2,
358 GCOBR_CRCMISMATCH = -3,
359 GCOBR_SHORTMESSAGE = -4,
360 /* failed to do the work */
361 GCOBR_NOCLOCKORBITPARAMETER = -10,
362 GCOBR_NOCODEBIASPARAMETER = -11,
363 GCOBR_NOPHASEBIASPARAMETER = -12,
364 GCOBR_NOVTECPARAMETER = -13,
365 /* data mismatch - data in storage does not match new data */
366 GCOBR_TIMEMISMATCH = -20,
367 GCOBR_DATAMISMATCH = -21,
368 /* not enough data - can decode the block completely */
369 GCOBR_SHORTBUFFER = -30,
370 GCOBR_MESSAGEEXCEEDSBUFFER = -31};
371
372/* NOTE: When an error message has been emitted, the output structures may have been modified. Make a copy of the previous variant before calling the
373function to have a clean state. */
374
375/* buffer should point to a RTCM3 block */
376enum GCOB_RETURN GetSSR(struct ClockOrbit *co, struct CodeBias *b, struct VTEC *v,
377 struct PhaseBias *pb, const char *buffer, size_t size, int *bytesused);
378
379#endif /* RTCM3_CLOCK_ORBIT_RTCM_H */
Note: See TracBrowser for help on using the repository browser.