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 8943 20200608 14:50:04Z stuerze $


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 


17  enum 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 


26  enum 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 


36  enum 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_SBAS + 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 


76  enum 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_SBAS + COBOFS_BIAS,


82  BTYPE_BDS = COBBASE_BDS + COBOFS_BIAS,


83  BTYPE_AUTO = 0


84  };


85 


86  enum 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 


97  enum VTECType {


98  VTEC_BASE = 1264


99  };


100 


101  /* if some systems aren't supported at all, change the following numbers to zero


102  for these systems to save space */


103  enum COR_CONSTANTS {


104  CLOCKORBIT_BUFFERSIZE=8192,


105  CLOCKORBIT_NUMGPS=32,


106  CLOCKORBIT_NUMGLONASS=26,


107  CLOCKORBIT_NUMGALILEO=36,


108  CLOCKORBIT_NUMQZSS=10,


109  CLOCKORBIT_NUMSBAS=38,


110  CLOCKORBIT_NUMBDS=65,


111  CLOCKORBIT_NUMBIAS=100,


112  CLOCKORBIT_NUMIONOLAYERS=4,


113  CLOCKORBIT_MAXIONOORDER=16,


114  CLOCKORBIT_MAXIONODEGREE=16


115  };


116 


117  enum 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 


127  enum 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 


142  enum 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_L2C_M = 7,


151  CODETYPEGPS_L2C_L = 8,


152  CODETYPEGPS_L2C_ML = 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  CODETYPEGPS_L1C_D = 17,


161  CODETYPEGPS_L1C_P = 18,


162  CODETYPEGPS_L1C_DP = 19,


163 


164  CODETYPEGLONASS_L1_CA = 0,


165  CODETYPEGLONASS_L1_P = 1,


166  CODETYPEGLONASS_L2_CA = 2,


167  CODETYPEGLONASS_L2_P = 3,


168  CODETYPEGLONASS_L1a_OCd = 4,


169  CODETYPEGLONASS_L1a_OCp = 5,


170  CODETYPEGLONASS_L1a_OCdp = 6,


171  CODETYPEGLONASS_L2a_CSI = 7,


172  CODETYPEGLONASS_L2a_OCp = 8,


173  CODETYPEGLONASS_L2a_CSIOCp = 9,


174  CODETYPEGLONASS_L3_I = 10,


175  CODETYPEGLONASS_L3_Q = 11,


176  CODETYPEGLONASS_L3_IQ = 12,


177 


178  CODETYPEGALILEO_E1_A = 0,


179  CODETYPEGALILEO_E1_B = 1,


180  CODETYPEGALILEO_E1_C = 2,


181  CODETYPEGALILEO_E1_BC = 3,


182  CODETYPEGALILEO_E1_ABC = 4,


183  CODETYPEGALILEO_E5A_I = 5,


184  CODETYPEGALILEO_E5A_Q = 6,


185  CODETYPEGALILEO_E5A_IQ = 7,


186  CODETYPEGALILEO_E5B_I = 8,


187  CODETYPEGALILEO_E5B_Q = 9,


188  CODETYPEGALILEO_E5B_IQ = 10,


189  CODETYPEGALILEO_E5_I = 11,


190  CODETYPEGALILEO_E5_Q = 12,


191  CODETYPEGALILEO_E5_IQ = 13,


192  CODETYPEGALILEO_E6_A = 14,


193  CODETYPEGALILEO_E6_B = 15,


194  CODETYPEGALILEO_E6_C = 16,


195  CODETYPEGALILEO_E6_BC = 17,


196  CODETYPEGALILEO_E6_ABC = 18,


197 


198  CODETYPEQZSS_L1_CA = 0,


199  CODETYPEQZSS_L1C_D = 1,


200  CODETYPEQZSS_L1C_P = 2,


201  CODETYPEQZSS_L2C_M = 3,


202  CODETYPEQZSS_L2C_L = 4,


203  CODETYPEQZSS_L2C_ML = 5,


204  CODETYPEQZSS_L5_I = 6,


205  CODETYPEQZSS_L5_Q = 7,


206  CODETYPEQZSS_L5_IQ = 8,


207  CODETYPEQZSS_L6_D = 9,


208  CODETYPEQZSS_L6_P = 10,


209  CODETYPEQZSS_L6_DP = 11,


210  CODETYPEQZSS_L1C_DP = 12,


211  CODETYPEQZSS_L1_S = 13,


212  CODETYPEQZSS_L5_D = 14,


213  CODETYPEQZSS_L5_P = 15,


214  CODETYPEQZSS_L5_DP = 16,


215  CODETYPEQZSS_L6_E = 17,


216  CODETYPEQZSS_L6_DE = 18,


217 


218  CODETYPE_SBAS_L1_CA = 0,


219  CODETYPE_SBAS_L5_I = 1,


220  CODETYPE_SBAS_L5_Q = 2,


221  CODETYPE_SBAS_L5_IQ = 3,


222  CODETYPE_BDS_B1_I = 0,


223  CODETYPE_BDS_B1_Q = 1,


224  CODETYPE_BDS_B1_IQ = 2,


225  CODETYPE_BDS_B3_I = 3,


226  CODETYPE_BDS_B3_Q = 4,


227  CODETYPE_BDS_B3_IQ = 5,


228  CODETYPE_BDS_B2_I = 6,


229  CODETYPE_BDS_B2_Q = 7,


230  CODETYPE_BDS_B2_IQ = 8,


231  CODETYPE_BDS_B1a_D = 9,


232  CODETYPE_BDS_B1a_P = 10,


233  CODETYPE_BDS_B1a_DP = 11,


234  CODETYPE_BDS_B2a_D = 12,


235  CODETYPE_BDS_B2a_P = 13,


236  CODETYPE_BDS_B2a_DP = 14,


237 


238  CODETYPE_IRNSS_S_SPS = 8,


239  CODETYPE_IRNSS_L5_SPS = 22


240  };


241 


242  #define SSR_MAXURA 5.5 /* > 5466.5mm in meter */


243 


244  /* satellite system data is stored with offset CLOCKORBIT_OFFSET...


245  in the data structures. So first GLONASS satellite is at


246  xxx>Sat[CLOCKORBIT_OFFSETGLONASS], first GPS satellite is


247  xxx>Sat[CLOCKORBIT_OFFSETGPS]. */


248 


249  #ifdef COR_LEGACY


250  /* old names */


251  #define NumberOfGPSSat NumberOfSat[CLOCKORBIT_SATGPS]


252  #define NumberOfGLONASSSat NumberOfSat[CLOCKORBIT_SATGLONASS]


253  #define GPSEpochTime EpochTime[CLOCKORBIT_SATGPS] /* 0 .. 604799 s */


254  #define GLONASSEpochTime EpochTime[CLOCKORBIT_SATGLONASS] /* 0 .. 86399 s (86400 for leap second) */


255  #define ClockDataSupplied Supplied[COBOFS_CLOCK]


256  #define HRDataSupplied Supplied[COBOFS_HR]


257  #define OrbitDataSupplied Supplied[COBOFS_ORBIT]


258  #define URADataSupplied Supplied[COBOFS_URA]


259  #define GetClockOrbitBias(a,b,c,d,e) GetSSR(a,b,0,0,c,d,e)


260  #endif /* COR_LEGACY */


261 


262  /* latency check code, disabled by default */


263  #ifdef COR_LATENCY


264  #define COR_LATENCYCOUNT 100


265  #endif


266 


267  struct ClockOrbit


268  {


269  enum ClockOrbitType messageType;


270  unsigned int EpochTime[CLOCKORBIT_SATNUM]; /* 0 .. system specific maximum */


271  unsigned int NumberOfSat[CLOCKORBIT_SATNUM]; /* 0 .. CLOCKORBIT_NUM... */


272 


273  unsigned int Supplied[COBOFS_NUM]; /* boolean */


274  #ifdef COR_LATENCY


275  unsigned int epochGPS[COR_LATENCYCOUNT+1]; /* Weber, for latency */


276  unsigned int epochSize; /* Weber, for latency */


277  #endif


278  unsigned int SSRIOD;


279  unsigned int SSRProviderID;


280  unsigned int SSRSolutionID;


281  unsigned int UpdateInterval;


282  enum SatelliteReferenceDatum SatRefDatum;


283  struct SatData {


284  unsigned int ID; /* all */


285  unsigned int IOD; /* all */


286  unsigned int toe; /* SBAS, BDS */


287  double UserRangeAccuracy; /* accuracy values in [m] */


288  double hrclock;


289  struct OrbitPart


290  {


291  double DeltaRadial; /* m */


292  double DeltaAlongTrack; /* m */


293  double DeltaCrossTrack; /* m */


294  double DotDeltaRadial; /* m/s */


295  double DotDeltaAlongTrack; /* m/s */


296  double DotDeltaCrossTrack; /* m/s */


297  } Orbit;


298  struct ClockPart


299  {


300  double DeltaA0; /* m */


301  double DeltaA1; /* m/s */


302  double DeltaA2; /* m/ss */


303  } Clock;


304  } Sat[CLOCKORBIT_COUNTSAT];


305  };


306 


307  struct CodeBias


308  {


309  enum CodeBiasType messageType;


310  unsigned int EpochTime[CLOCKORBIT_SATNUM]; /* 0 .. system specific maximum */


311  unsigned int NumberOfSat[CLOCKORBIT_SATNUM]; /* 0 .. CLOCKORBIT_NUM... */


312  unsigned int UpdateInterval;


313  unsigned int SSRIOD;


314  unsigned int SSRProviderID;


315  unsigned int SSRSolutionID;


316  struct BiasSat


317  {


318  unsigned int ID; /* all */


319  unsigned int NumberOfCodeBiases;


320  struct CodeBiasEntry


321  {


322  enum CodeType Type;


323  float Bias; /* m */


324  } Biases[CLOCKORBIT_NUMBIAS];


325  } Sat[CLOCKORBIT_COUNTSAT];


326  };


327 


328  struct PhaseBias


329  {


330  enum PhaseBiasType messageType;


331  unsigned int EpochTime[CLOCKORBIT_SATNUM]; /* 0 .. system specific maximum */


332  unsigned int NumberOfSat[CLOCKORBIT_SATNUM]; /* 0 .. CLOCKORBIT_NUM... */


333  unsigned int UpdateInterval;


334  unsigned int SSRIOD;


335  unsigned int SSRProviderID;


336  unsigned int SSRSolutionID;


337  unsigned int DispersiveBiasConsistencyIndicator;


338  unsigned int MWConsistencyIndicator;


339  struct PhaseBiasSat


340  {


341  unsigned int ID; /* all */


342  unsigned int NumberOfPhaseBiases;


343  double YawAngle; /* radiant */


344  double YawRate; /* radiant/s */


345  struct PhaseBiasEntry


346  {


347  enum CodeType Type;


348  unsigned int SignalIntegerIndicator;


349  unsigned int SignalsWideLaneIntegerIndicator;


350  unsigned int SignalDiscontinuityCounter;


351  float Bias; /* m */


352  } Biases[CLOCKORBIT_NUMBIAS];


353  } Sat[CLOCKORBIT_COUNTSAT];


354  };


355 


356  struct VTEC


357  {


358  unsigned int EpochTime; /* GPS */


359  unsigned int UpdateInterval;


360  unsigned int SSRIOD;


361  unsigned int SSRProviderID;


362  unsigned int SSRSolutionID;


363  unsigned int NumLayers; /* 14 */


364  double Quality;


365  struct IonoLayers {


366  double Height; /* m */


367  unsigned int Degree; /* 116 */


368  unsigned int Order; /* 116 */


369  double Sinus[CLOCKORBIT_MAXIONODEGREE][CLOCKORBIT_MAXIONOORDER];


370  double Cosinus[CLOCKORBIT_MAXIONODEGREE][CLOCKORBIT_MAXIONOORDER];


371  } Layers[CLOCKORBIT_NUMIONOLAYERS];


372  };


373 


374  /* return size of resulting data or 0 in case of an error */


375  size_t MakeClockOrbit(const struct ClockOrbit *co, enum ClockOrbitType type,


376  int moremessagesfollow, char *buffer, size_t size);


377  size_t MakeCodeBias(const struct CodeBias *b, enum CodeBiasType type,


378  int moremessagesfollow, char *buffer, size_t size);


379  size_t MakePhaseBias(const struct PhaseBias *b, enum PhaseBiasType type,


380  int moremessagesfollow, char *buffer, size_t size);


381  size_t MakeVTEC(const struct VTEC *b, int moremessagesfollow, char *buffer,


382  size_t size);


383 


384  enum GCOB_RETURN {


385  /* all well */


386  GCOBR_MESSAGEFOLLOWS = 1,


387  GCOBR_OK = 0,


388  /* unknown data, a warning */


389  GCOBR_UNKNOWNTYPE = 1,


390  GCOBR_UNKNOWNDATA = 2,


391  GCOBR_CRCMISMATCH = 3,


392  GCOBR_SHORTMESSAGE = 4,


393  /* failed to do the work */


394  GCOBR_NOCLOCKORBITPARAMETER = 10,


395  GCOBR_NOCODEBIASPARAMETER = 11,


396  GCOBR_NOPHASEBIASPARAMETER = 12,


397  GCOBR_NOVTECPARAMETER = 13,


398  /* data mismatch  data in storage does not match new data */


399  GCOBR_TIMEMISMATCH = 20,


400  GCOBR_DATAMISMATCH = 21,


401  /* not enough data  can decode the block completely */


402  GCOBR_SHORTBUFFER = 30,


403  GCOBR_MESSAGEEXCEEDSBUFFER = 31};


404 


405  /* 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


406  function to have a clean state. */


407 


408  /* buffer should point to a RTCM3 block */


409  enum GCOB_RETURN GetSSR(struct ClockOrbit *co, struct CodeBias *b, struct VTEC *v,


410  struct PhaseBias *pb, const char *buffer, size_t size, int *bytesused);


411 


412  #endif /* RTCM3_CLOCK_ORBIT_RTCM_H */

