| 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,v 1.4 2009/04/24 08:36:34 stoecker Exp $
|
|---|
| 9 | Authors: Dirk Stöcker
|
|---|
| 10 | Description: state space approach for RTCM3
|
|---|
| 11 | */
|
|---|
| 12 |
|
|---|
| 13 | #include <string.h>
|
|---|
| 14 |
|
|---|
| 15 | enum SatelliteReferenceDatum { DATUM_ITRF=0, DATUM_LOCAL=1 };
|
|---|
| 16 | enum SatelliteReferencePoint { POINT_IONOFREE=0, POINT_CENTER=1 };
|
|---|
| 17 | enum ClockOrbitType {
|
|---|
| 18 | COTYPE_GPSORBIT=3001, COTYPE_GPSCLOCK=3002,
|
|---|
| 19 | COTYPE_GPSCOMBINED=3004, COTYPE_GPSURA=3005, COTYPE_GPSHR=3006,
|
|---|
| 20 |
|
|---|
| 21 | COTYPE_GLONASSORBIT=3007, COTYPE_GLONASSCLOCK=3008,
|
|---|
| 22 | COTYPE_GLONASSCOMBINED=3010, COTYPE_GLONASSURA=3011, COTYPE_GLONASSHR=3012,
|
|---|
| 23 |
|
|---|
| 24 | COTYPE_AUTO=0 };
|
|---|
| 25 | enum BiasType { BTYPE_GPS=3003, BTYPE_GLONASS=3009, BTYPE_AUTO = 0 };
|
|---|
| 26 |
|
|---|
| 27 | enum COR_CONSTANTS {
|
|---|
| 28 | CLOCKORBIT_BUFFERSIZE=2048,
|
|---|
| 29 | CLOCKORBIT_NUMGPS=32,
|
|---|
| 30 | CLOCKORBIT_NUMGLONASS=24,
|
|---|
| 31 | CLOCKORBIT_NUMBIAS=10
|
|---|
| 32 | };
|
|---|
| 33 |
|
|---|
| 34 | enum CodeType {
|
|---|
| 35 | CODETYPEGPS_L1_CA = 0,
|
|---|
| 36 | CODETYPEGPS_L1_P = 1,
|
|---|
| 37 | CODETYPEGPS_L1_Z = 2,
|
|---|
| 38 | /* ... */
|
|---|
| 39 |
|
|---|
| 40 | CODETYPEGLONASS_L1_CA = 0,
|
|---|
| 41 | CODETYPEGLONASS_L1_P = 1,
|
|---|
| 42 | CODETYPEGLONASS_L2_CA = 2,
|
|---|
| 43 | CODETYPEGLONASS_L2_P = 3,
|
|---|
| 44 | };
|
|---|
| 45 |
|
|---|
| 46 | /* GLONASS data is stored with offset CLOCKORBIT_NUMGPS in the data structures.
|
|---|
| 47 | So first GLONASS satellite is at xxx->Sat[CLOCKORBIT_NUMGPS], first
|
|---|
| 48 | GPS satellite is xxx->Sat[0]. */
|
|---|
| 49 |
|
|---|
| 50 | struct ClockOrbit
|
|---|
| 51 | {
|
|---|
| 52 | int GPSEpochTime; /* 0 .. 604799 s */
|
|---|
| 53 | int GLONASSEpochTime; /* 0 .. 86399 s (86400 for leap second) */
|
|---|
| 54 | int NumberOfGPSSat; /* 0 .. 32 */
|
|---|
| 55 | int NumberOfGLONASSSat; /* 0 .. 24 */
|
|---|
| 56 | int ClockDataSupplied; /* boolean */
|
|---|
| 57 | int HRDataSupplied; /* boolean */
|
|---|
| 58 | int OrbitDataSupplied; /* boolean */
|
|---|
| 59 | int URADataSupplied; /* boolean */
|
|---|
| 60 | int epochGPS[101]; /* Weber, for latency */
|
|---|
| 61 | int epochSize; /* Weber, for latency */
|
|---|
| 62 | int UpdateInterval;
|
|---|
| 63 | enum SatelliteReferencePoint SatRefPoint;
|
|---|
| 64 | enum SatelliteReferenceDatum SatRefDatum;
|
|---|
| 65 | struct SatData {
|
|---|
| 66 | int ID; /* GPS or GLONASS */
|
|---|
| 67 | int IOD; /* GPS or GLONASS */
|
|---|
| 68 | int URA;
|
|---|
| 69 | double hrclock;
|
|---|
| 70 | struct OrbitPart
|
|---|
| 71 | {
|
|---|
| 72 | double DeltaRadial; /* m */
|
|---|
| 73 | double DeltaAlongTrack; /* m */
|
|---|
| 74 | double DeltaCrossTrack; /* m */
|
|---|
| 75 | double DotDeltaRadial; /* m/s */
|
|---|
| 76 | double DotDeltaAlongTrack; /* m/s */
|
|---|
| 77 | double DotDeltaCrossTrack; /* m/s */
|
|---|
| 78 | double DotDotDeltaRadial; /* m/ss */
|
|---|
| 79 | double DotDotDeltaAlongTrack; /* m/ss */
|
|---|
| 80 | double DotDotDeltaCrossTrack; /* m/ss */
|
|---|
| 81 | } Orbit;
|
|---|
| 82 | struct ClockPart
|
|---|
| 83 | {
|
|---|
| 84 | double DeltaA0; /* m */
|
|---|
| 85 | double DeltaA1; /* m/s */
|
|---|
| 86 | double DeltaA2; /* m/ss */
|
|---|
| 87 | } Clock;
|
|---|
| 88 | } Sat[CLOCKORBIT_NUMGPS+CLOCKORBIT_NUMGLONASS];
|
|---|
| 89 | };
|
|---|
| 90 |
|
|---|
| 91 | struct Bias
|
|---|
| 92 | {
|
|---|
| 93 | int GPSEpochTime; /* 0 .. 604799 s */
|
|---|
| 94 | int GLONASSEpochTime; /* 0 .. 86399 s (86400 for leap second) */
|
|---|
| 95 | int NumberOfGPSSat; /* 0 .. 32 */
|
|---|
| 96 | int NumberOfGLONASSSat; /* 0 .. 24 */
|
|---|
| 97 | int UpdateInterval;
|
|---|
| 98 | struct BiasSat
|
|---|
| 99 | {
|
|---|
| 100 | int ID; /* GPS or GLONASS */
|
|---|
| 101 | int NumberOfCodeBiases;
|
|---|
| 102 | struct CodeBias
|
|---|
| 103 | {
|
|---|
| 104 | enum CodeType Type;
|
|---|
| 105 | float Bias; /* m */
|
|---|
| 106 | } Biases[CLOCKORBIT_NUMBIAS];
|
|---|
| 107 | } Sat[CLOCKORBIT_NUMGPS+CLOCKORBIT_NUMGLONASS];
|
|---|
| 108 | };
|
|---|
| 109 |
|
|---|
| 110 | /* return size of resulting data or 0 in case of an error */
|
|---|
| 111 | size_t MakeClockOrbit(const struct ClockOrbit *co, enum ClockOrbitType type,
|
|---|
| 112 | int moremessagesfollow, char *buffer, size_t size);
|
|---|
| 113 | size_t MakeBias(const struct Bias *b, enum BiasType type,
|
|---|
| 114 | int moremessagesfollow, char *buffer, size_t size);
|
|---|
| 115 |
|
|---|
| 116 | enum GCOB_RETURN {
|
|---|
| 117 | /* all well */
|
|---|
| 118 | GCOBR_MESSAGEFOLLOWS = 1,
|
|---|
| 119 | GCOBR_OK = 0,
|
|---|
| 120 | /* unknown data, a warning */
|
|---|
| 121 | GCOBR_UNKNOWNTYPE = -1,
|
|---|
| 122 | GCOBR_UNKNOWNDATA = -2,
|
|---|
| 123 | GCOBR_CRCMISMATCH = -3,
|
|---|
| 124 | /* failed to do the work */
|
|---|
| 125 | GCOBR_NOCLOCKORBITPARAMETER = -10,
|
|---|
| 126 | GCOBR_NOBIASPARAMETER = -11,
|
|---|
| 127 | /* data mismatch - data in storage does not match new data */
|
|---|
| 128 | GCOBR_TIMEMISMATCH = -20,
|
|---|
| 129 | GCOBR_DATAMISMATCH = -21,
|
|---|
| 130 | /* not enough data - can decode the block completely */
|
|---|
| 131 | GCOBR_SHORTBUFFER = -30,
|
|---|
| 132 | GCOBR_MISSINGBITS = -31,
|
|---|
| 133 | GCOBR_MESSAGEEXCEEDSBUFFER = -32,
|
|---|
| 134 | GCOBR_SHORTMESSAGE = -33
|
|---|
| 135 | };
|
|---|
| 136 |
|
|---|
| 137 | /* 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
|
|---|
| 138 | function to have a clean state. */
|
|---|
| 139 |
|
|---|
| 140 | /* buffer should point to a RTCM3 block */
|
|---|
| 141 | enum GCOB_RETURN GetClockOrbitBias(struct ClockOrbit *co, struct Bias *b,
|
|---|
| 142 | const char *buffer, size_t size, int *bytesused);
|
|---|
| 143 |
|
|---|
| 144 | #endif /* RTCM3_CLOCK_ORBIT_RTCM_H */
|
|---|