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 8972 20200716 21:22:25Z stuerze $


9  Authors: Dirk Stöcker


10  Description: state space approach: RTCM


11  */


12 


13  #include <string.h>


14 


15 


16 


17 


18 


19 


20  enum SatelliteReferenceDatum {


21  DATUM_ITRF = 0,


22  DATUM_LOCAL = 1


23  };


24 


25  enum COR_BASE {


26  COBBASE_GPS = 1057,


27  COBBASE_GLONASS = 1063,


28  COBBASE_GALILEO = 1240,


29  COBBASE_QZSS = 1246,


30  COBBASE_SBAS = 1252,


31  COBBASE_BDS = 1258,


32  COBBASE_NUM


33  };


34 


35  enum COR_OFFSET {


36  COBOFS_ORBIT = 0,


37  COBOFS_CLOCK,


38  COBOFS_CBIAS,


39  COBOFS_COMBINED,


40  COBOFS_URA,


41  COBOFS_HR,


42  COBOFS_NUM


43  };


44 


45  enum ClockOrbitType {


46  COTYPE_GPSORBIT = COBBASE_GPS + COBOFS_ORBIT,


47  COTYPE_GPSCLOCK,


48  COTYPE_GPSCOMBINED = COBBASE_GPS + COBOFS_COMBINED,


49  COTYPE_GPSURA,


50  COTYPE_GPSHR,


51 


52  COTYPE_GLONASSORBIT = COBBASE_GLONASS + COBOFS_ORBIT,


53  COTYPE_GLONASSCLOCK,


54  COTYPE_GLONASSCOMBINED = COBBASE_GLONASS + COBOFS_COMBINED,


55  COTYPE_GLONASSURA,


56  COTYPE_GLONASSHR,


57 


58  COTYPE_GALILEOORBIT = COBBASE_GALILEO + COBOFS_ORBIT,


59  COTYPE_GALILEOCLOCK,


60  COTYPE_GALILEOCOMBINED = COBBASE_GALILEO + COBOFS_COMBINED,


61  COTYPE_GALILEOURA,


62  COTYPE_GALILEOHR,


63 


64  COTYPE_QZSSORBIT = COBBASE_QZSS + COBOFS_ORBIT,


65  COTYPE_QZSSCLOCK,


66  COTYPE_QZSSCOMBINED = COBBASE_QZSS + COBOFS_COMBINED,


67  COTYPE_QZSSURA,


68  COTYPE_QZSSHR,


69 


70  COTYPE_SBASORBIT = COBBASE_SBAS + COBOFS_ORBIT,


71  COTYPE_SBASCLOCK,


72  COTYPE_SBASCOMBINED = COBBASE_SBAS + COBOFS_COMBINED,


73  COTYPE_SBASURA,


74  COTYPE_SBASHR,


75 


76  COTYPE_BDSORBIT = COBBASE_BDS + COBOFS_ORBIT,


77  COTYPE_BDSCLOCK,


78  COTYPE_BDSCOMBINED = COBBASE_BDS + COBOFS_COMBINED,


79  COTYPE_BDSURA,


80  COTYPE_BDSHR,


81 


82  COTYPE_AUTO = 0,


83  };


84 


85  enum CodeBiasType {


86  CBTYPE_GPS = COBBASE_GPS + COBOFS_CBIAS,


87  CBTYPE_GLONASS = COBBASE_GLONASS + COBOFS_CBIAS,


88  CBTYPE_GALILEO = COBBASE_GALILEO + COBOFS_CBIAS,


89  CBTYPE_QZSS = COBBASE_QZSS + COBOFS_CBIAS,


90  CBTYPE_SBAS = COBBASE_SBAS + COBOFS_CBIAS,


91  CBTYPE_BDS = COBBASE_BDS + COBOFS_CBIAS,


92  CBTYPE_AUTO = 0


93  };


94 


95  enum PhaseBiasType{


96  PBTYPE_BASE = 1265,


97  PBTYPE_GPS = PBTYPE_BASE,


98  PBTYPE_GLONASS,


99  PBTYPE_GALILEO,


100  PBTYPE_QZSS,


101  PBTYPE_SBAS,


102  PBTYPE_BDS,


103  PBTYPE_AUTO = 0


104  };


105 


106  enum VTECType {


107  VTEC_BASE = 1264


108  };


109 


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


111  for these systems to save space */


112  enum COR_CONSTANTS {


113  CLOCKORBIT_BUFFERSIZE = 8192,


114  CLOCKORBIT_NUMGPS = 32,


115  CLOCKORBIT_NUMGLONASS = 26,


116  CLOCKORBIT_NUMGALILEO = 36,


117  CLOCKORBIT_NUMQZSS = 10,


118  CLOCKORBIT_NUMSBAS = 38,


119  CLOCKORBIT_NUMBDS = 65,


120  CLOCKORBIT_NUMBIAS = 100,


121  CLOCKORBIT_NUMIONOLAYERS = 4,


122  CLOCKORBIT_MAXIONOORDER = 16,


123  CLOCKORBIT_MAXIONODEGREE = 16


124  };


125 


126  enum COR_SATSYSTEM {


127  CLOCKORBIT_SATGPS=0,


128  CLOCKORBIT_SATGLONASS,


129  CLOCKORBIT_SATGALILEO,


130  CLOCKORBIT_SATQZSS,


131  CLOCKORBIT_SATSBAS,


132  CLOCKORBIT_SATBDS,


133  CLOCKORBIT_SATNUM


134  };


135 


136  enum COR_OFFSETS {


137  CLOCKORBIT_OFFSETGPS = 0,


138  CLOCKORBIT_OFFSETGLONASS = CLOCKORBIT_NUMGPS,


139  CLOCKORBIT_OFFSETGALILEO = CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS,


140  CLOCKORBIT_OFFSETQZSS = CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS + CLOCKORBIT_NUMGALILEO,


141  CLOCKORBIT_OFFSETSBAS = CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS + CLOCKORBIT_NUMGALILEO


142  + CLOCKORBIT_NUMQZSS,


143  CLOCKORBIT_OFFSETBDS = CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS + CLOCKORBIT_NUMGALILEO


144  + CLOCKORBIT_NUMQZSS + CLOCKORBIT_NUMSBAS,


145  CLOCKORBIT_COUNTSAT = CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS + CLOCKORBIT_NUMGALILEO


146  + CLOCKORBIT_NUMQZSS + CLOCKORBIT_NUMSBAS + CLOCKORBIT_NUMBDS


147  };


148 


149  enum CodeType {


150  CODETYPEGPS_L1_CA = 0,


151  CODETYPEGPS_L1_P = 1,


152  CODETYPEGPS_L1_Z = 2,


153  //CODETYPEGPS_L1_Y = 3,


154  //CODETYPEGPS_L1_M = 4,


155  CODETYPEGPS_L2_CA = 5,


156  CODETYPEGPS_SEMI_CODELESS = 6,


157  CODETYPEGPS_L2C_M = 7,


158  CODETYPEGPS_L2C_L = 8,


159  CODETYPEGPS_L2C_ML = 9,


160  CODETYPEGPS_L2_P = 10,


161  CODETYPEGPS_L2_Z = 11,


162  //CODETYPEGPS_L2_Y = 12,


163  //CODETYPEGPS_L2_M = 13,


164  CODETYPEGPS_L5_I = 14,


165  CODETYPEGPS_L5_Q = 15,


166  CODETYPEGPS_L5_IQ = 16,


167  CODETYPEGPS_L1C_D = 17,


168  CODETYPEGPS_L1C_P = 18,


169  CODETYPEGPS_L1C_DP = 19,


170 


171  CODETYPEGLONASS_L1_CA = 0,


172  CODETYPEGLONASS_L1_P = 1,


173  CODETYPEGLONASS_L2_CA = 2,


174  CODETYPEGLONASS_L2_P = 3,


175  CODETYPEGLONASS_L1a_OCd = 4,


176  CODETYPEGLONASS_L1a_OCp = 5,


177  CODETYPEGLONASS_L1a_OCdp = 6,


178  CODETYPEGLONASS_L2a_CSI = 7,


179  CODETYPEGLONASS_L2a_OCp = 8,


180  CODETYPEGLONASS_L2a_CSIOCp = 9,


181  CODETYPEGLONASS_L3_I = 10,


182  CODETYPEGLONASS_L3_Q = 11,


183  CODETYPEGLONASS_L3_IQ = 12,


184 


185 


186  CODETYPEGALILEO_E1_A = 0,


187  CODETYPEGALILEO_E1_B = 1,


188  CODETYPEGALILEO_E1_C = 2,


189  CODETYPEGALILEO_E1_BC = 3,


190  CODETYPEGALILEO_E1_ABC = 4,


191  CODETYPEGALILEO_E5A_I = 5,


192  CODETYPEGALILEO_E5A_Q = 6,


193  CODETYPEGALILEO_E5A_IQ = 7,


194  CODETYPEGALILEO_E5B_I = 8,


195  CODETYPEGALILEO_E5B_Q = 9,


196  CODETYPEGALILEO_E5B_IQ = 10,


197  CODETYPEGALILEO_E5_I = 11,


198  CODETYPEGALILEO_E5_Q = 12,


199  CODETYPEGALILEO_E5_IQ = 13,


200  CODETYPEGALILEO_E6_A = 14,


201  CODETYPEGALILEO_E6_B = 15,


202  CODETYPEGALILEO_E6_C = 16,


203  CODETYPEGALILEO_E6_BC = 17,


204  CODETYPEGALILEO_E6_ABC = 18,


205 


206  CODETYPEQZSS_L1_CA = 0,


207  CODETYPEQZSS_L1C_D = 1,


208  CODETYPEQZSS_L1C_P = 2,


209  CODETYPEQZSS_L2C_M = 3,


210  CODETYPEQZSS_L2C_L = 4,


211  CODETYPEQZSS_L2C_ML = 5,


212  CODETYPEQZSS_L5_I = 6,


213  CODETYPEQZSS_L5_Q = 7,


214  CODETYPEQZSS_L5_IQ = 8,


215  CODETYPEQZSS_L6_D = 9,


216  CODETYPEQZSS_L6_P = 10,


217  CODETYPEQZSS_L6_DP = 11,


218  CODETYPEQZSS_L1C_DP = 12,


219  CODETYPEQZSS_L1_S = 13,


220  CODETYPEQZSS_L5_D = 14,


221  CODETYPEQZSS_L5_P = 15,


222  CODETYPEQZSS_L5_DP = 16,


223  CODETYPEQZSS_L6_E = 17,


224  CODETYPEQZSS_L6_DE = 18,


225 


226  CODETYPE_BDS_B1_I = 0,


227  CODETYPE_BDS_B1_Q = 1,


228  CODETYPE_BDS_B1_IQ = 2,


229  CODETYPE_BDS_B3_I = 3,


230  CODETYPE_BDS_B3_Q = 4,


231  CODETYPE_BDS_B3_IQ = 5,


232  CODETYPE_BDS_B2_I = 6,


233  CODETYPE_BDS_B2_Q = 7,


234  CODETYPE_BDS_B2_IQ = 8,


235  CODETYPE_BDS_B1a_D = 9,


236  CODETYPE_BDS_B1a_P = 10,


237  CODETYPE_BDS_B1a_DP = 11,


238  CODETYPE_BDS_B2a_D = 12,


239  CODETYPE_BDS_B2a_P = 13,


240  CODETYPE_BDS_B2a_DP = 14,


241 


242  CODETYPE_SBAS_L1_CA = 0,


243  CODETYPE_SBAS_L5_I = 1,


244  CODETYPE_SBAS_L5_Q = 2,


245  CODETYPE_SBAS_L5_IQ = 3


246 


247  };


248 


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


250 


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


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


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


254  xxx>Sat[CLOCKORBIT_OFFSETGPS]. */


255 


256  struct ClockOrbit {


257  enum ClockOrbitType messageType;


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


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


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


261  unsigned int SSRIOD;


262  unsigned int SSRProviderID;


263  unsigned int SSRSolutionID;


264  unsigned int UpdateInterval;


265  enum SatelliteReferenceDatum SatRefDatum;


266  struct SatData {


267  unsigned int ID; /* all */


268  unsigned int IOD; /* all */


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


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


271  double hrclock;


272  struct OrbitPart {


273  double DeltaRadial; /* m */


274  double DeltaAlongTrack; /* m */


275  double DeltaCrossTrack; /* m */


276  double DotDeltaRadial; /* m/s */


277  double DotDeltaAlongTrack; /* m/s */


278  double DotDeltaCrossTrack; /* m/s */


279  } Orbit;


280  struct ClockPart {


281  double DeltaA0; /* m */


282  double DeltaA1; /* m/s */


283  double DeltaA2; /* m/ss */


284  } Clock;


285  } Sat[CLOCKORBIT_COUNTSAT];


286  };


287 


288  struct CodeBias {


289  enum CodeBiasType messageType;


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


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


292  unsigned int UpdateInterval;


293  unsigned int SSRIOD;


294  unsigned int SSRProviderID;


295  unsigned int SSRSolutionID;


296  struct BiasSat {


297  unsigned int ID; /* all */


298  unsigned int NumberOfCodeBiases;


299  struct CodeBiasEntry {


300  enum CodeType Type;


301  float Bias; /* m */


302  } Biases[CLOCKORBIT_NUMBIAS];


303  } Sat[CLOCKORBIT_COUNTSAT];


304  };


305 


306  struct PhaseBias {


307  enum PhaseBiasType messageType;


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


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


310  unsigned int UpdateInterval;


311  unsigned int SSRIOD;


312  unsigned int SSRProviderID;


313  unsigned int SSRSolutionID;


314  unsigned int DispersiveBiasConsistencyIndicator;


315  unsigned int MWConsistencyIndicator;


316  struct PhaseBiasSat {


317  unsigned int ID; /* all */


318  unsigned int NumberOfPhaseBiases;


319  double YawAngle; /* radiant */


320  double YawRate; /* radiant/s */


321  struct PhaseBiasEntry {


322  enum CodeType Type;


323  unsigned int SignalIntegerIndicator;


324  unsigned int SignalsWideLaneIntegerIndicator;


325  unsigned int SignalDiscontinuityCounter;


326  float Bias; /* m */


327  } Biases[CLOCKORBIT_NUMBIAS];


328  } Sat[CLOCKORBIT_COUNTSAT];


329  };


330 


331  struct VTEC {


332  unsigned int EpochTime; /* GPS */


333  unsigned int UpdateInterval;


334  unsigned int SSRIOD;


335  unsigned int SSRProviderID;


336  unsigned int SSRSolutionID;


337  unsigned int NumLayers; /* 14 */


338  double Quality;


339  struct IonoLayers {


340  double Height; /* m */


341  unsigned int Degree; /* 116 */


342  unsigned int Order; /* 116 */


343  double Sinus[CLOCKORBIT_MAXIONODEGREE][CLOCKORBIT_MAXIONOORDER];


344  double Cosinus[CLOCKORBIT_MAXIONODEGREE][CLOCKORBIT_MAXIONOORDER];


345  } Layers[CLOCKORBIT_NUMIONOLAYERS];


346  };


347 


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


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


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


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


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


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


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


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


356  size_t size);


357 


358  enum GCOB_RETURN {


359  /* all well */


360  GCOBR_MESSAGEFOLLOWS = 1,


361  GCOBR_OK = 0,


362  /* unknown data, a warning */


363  GCOBR_UNKNOWNTYPE = 1,


364  GCOBR_UNKNOWNDATA = 2,


365  GCOBR_CRCMISMATCH = 3,


366  GCOBR_SHORTMESSAGE = 4,


367  /* failed to do the work */


368  GCOBR_NOCLOCKORBITPARAMETER = 10,


369  GCOBR_NOCODEBIASPARAMETER = 11,


370  GCOBR_NOPHASEBIASPARAMETER = 12,


371  GCOBR_NOVTECPARAMETER = 13,


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


373  GCOBR_TIMEMISMATCH = 20,


374  GCOBR_DATAMISMATCH = 21,


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


376  GCOBR_SHORTBUFFER = 30,


377  GCOBR_MESSAGEEXCEEDSBUFFER = 31};


378 


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


380  function to have a clean state. */


381 


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


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


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


385 


386  #endif /* RTCM3_CLOCK_ORBIT_RTCM_H */

