Changeset 6615 in ntrip for trunk/BNC/src/RTCM3


Ignore:
Timestamp:
Mar 2, 2015, 3:06:56 PM (10 years ago)
Author:
stuerze
Message:

initial import of BDS eph encoder

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/src/RTCM3/ephEncoder.cpp

    r6600 r6615  
    321321}
    322322
     323// build up RTCM3 for SBAS
     324////////////////////////////////////////////////////////////////////////////
    323325int t_ephEncoder::RTCM3(const t_ephSBAS& /* eph */, unsigned char* /* buffer */) {
    324326
     
    326328}
    327329
    328 int t_ephEncoder::RTCM3(const t_ephBDS& /* eph */, unsigned char* /* buffer */) {
    329 
    330   return 0;
    331 }
     330// build up RTCM3 for BDS
     331////////////////////////////////////////////////////////////////////////////
     332#define BDSTOINT(type, value) static_cast<type>(round(value))
     333
     334#define BDSADDBITS(a, b) {bitbuffer = (bitbuffer<<(a)) \
     335                       |(BDSTOINT(long long,b)&((1ULL<<a)-1)); \
     336                       numbits += (a); \
     337                       while(numbits >= 8) { \
     338                       buffer[size++] = bitbuffer>>(numbits-8);numbits -= 8;}}
     339#define BDSADDBITSFLOAT(a,b,c) {long long i = BDSTOINT(long long,(b)/(c)); \
     340                             BDSADDBITS(a,i)};
     341
     342int t_ephEncoder::RTCM3(const t_ephBDS& eph, unsigned char* buffer) {
     343  int size = 0;
     344  int numbits = 0;
     345  long long bitbuffer = 0;
     346  unsigned char *startbuffer = buffer;
     347  buffer= buffer+3;
     348
     349  BDSADDBITS(12, RTCM3ID_BDS)
     350  BDSADDBITS(6, eph._prn.number())
     351  BDSADDBITS(13, eph._TOC.gpsw())
     352  BDSADDBITS(4, 15);// URAI = 15: no accuracy prediction
     353  BDSADDBITSFLOAT(14, eph._IDOT, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<13))
     354  BDSADDBITS(5, eph._AODE)
     355  BDSADDBITS(17, static_cast<int>(eph._TOC.gpssec())>>3)
     356  BDSADDBITSFLOAT(11, eph._clock_driftrate, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<6))
     357  BDSADDBITSFLOAT(22, eph._clock_drift, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<20))
     358  BDSADDBITSFLOAT(24, eph._clock_bias, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<3))
     359  BDSADDBITS(5, eph._AODC)
     360  BDSADDBITSFLOAT(18, eph._Crs, 1.0/static_cast<double>(1<<6))
     361  BDSADDBITSFLOAT(16, eph._Delta_n, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<13))
     362  BDSADDBITSFLOAT(32, eph._M0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
     363  BDSADDBITSFLOAT(18, eph._Cuc, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<1))
     364  BDSADDBITSFLOAT(32, eph._e, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<3))
     365  BDSADDBITSFLOAT(18, eph._Cus, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<1))
     366  BDSADDBITSFLOAT(32, eph._sqrt_A, 1.0/static_cast<double>(1<<19))
     367  BDSADDBITS(17, static_cast<int>(eph._TOE.gpssec())>>3)
     368  BDSADDBITSFLOAT(18, eph._Cic, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<1))
     369  BDSADDBITSFLOAT(32, eph._OMEGA0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
     370  BDSADDBITSFLOAT(18, eph._Cis, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<1))
     371  BDSADDBITSFLOAT(32, eph._i0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
     372  BDSADDBITSFLOAT(18, eph._Crc, 1.0/static_cast<double>(1<<8))
     373  BDSADDBITSFLOAT(32, eph._omega, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
     374  BDSADDBITSFLOAT(24, eph._OMEGADOT, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<13))
     375  BDSADDBITSFLOAT(10, eph._TGD1, 0.0000000001)
     376  BDSADDBITSFLOAT(10, eph._TGD2, 0.0000000001)
     377  BDSADDBITS(1, eph._SatH1)
     378
     379  startbuffer[0]=0xD3;
     380  startbuffer[1]=(size >> 8);
     381  startbuffer[2]=size;
     382  unsigned long i = CRC24(size+3, startbuffer);
     383  buffer[size++] = i >> 16;
     384  buffer[size++] = i >> 8;
     385  buffer[size++] = i;
     386  size += 3;
     387  return size;
     388}
Note: See TracChangeset for help on using the changeset viewer.