[5852] | 1 |
|
---|
| 2 | #include "ephEncoder.h"
|
---|
[6139] | 3 |
|
---|
[5852] | 4 | using namespace std;
|
---|
| 5 |
|
---|
| 6 |
|
---|
| 7 | // build up RTCM3 for GPS
|
---|
| 8 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 9 | int t_ephEncoder::RTCM3(const t_ephGPS& eph, unsigned char *buffer) {
|
---|
| 10 |
|
---|
| 11 | unsigned char *startbuffer = buffer;
|
---|
| 12 | buffer= buffer+3;
|
---|
| 13 | int size = 0;
|
---|
| 14 | int numbits = 0;
|
---|
| 15 | unsigned long long bitbuffer = 0;
|
---|
[6819] | 16 | int ura = indexFromAccuracy(eph._ura, eph.type());
|
---|
[10215] | 17 | int L5Flag = 0;
|
---|
| 18 | int SFlag = 0;
|
---|
| 19 | int fitIntervalFlag = 0;
|
---|
[8812] | 20 |
|
---|
[6814] | 21 | if (eph.type() == t_eph::QZSS) {
|
---|
| 22 | GPSADDBITS(12, 1044)
|
---|
[8812] | 23 | GPSADDBITS(4, eph._prn.number())
|
---|
[6819] | 24 | GPSADDBITS(16, static_cast<int>(eph._TOC.gpssec())>>4)
|
---|
[8812] | 25 | GPSADDBITSFLOAT(8, eph._clock_driftrate, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<25))
|
---|
| 26 | GPSADDBITSFLOAT(16, eph._clock_drift, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<13))
|
---|
| 27 | GPSADDBITSFLOAT(22, eph._clock_bias, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
[6819] | 28 | GPSADDBITS(8, eph._IODE)
|
---|
| 29 | GPSADDBITSFLOAT(16, eph._Crs, 1.0/static_cast<double>(1<<5))
|
---|
[8812] | 30 | GPSADDBITSFLOAT(16, eph._Delta_n, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<13))
|
---|
[6819] | 31 | GPSADDBITSFLOAT(32, eph._M0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
| 32 | GPSADDBITSFLOAT(16, eph._Cuc, 1.0/static_cast<double>(1<<29))
|
---|
| 33 | GPSADDBITSFLOAT(32, eph._e, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<3))
|
---|
| 34 | GPSADDBITSFLOAT(16, eph._Cus, 1.0/static_cast<double>(1<<29))
|
---|
| 35 | GPSADDBITSFLOAT(32, eph._sqrt_A, 1.0/static_cast<double>(1<<19))
|
---|
| 36 | GPSADDBITS(16, static_cast<int>(eph._TOEsec)>>4)
|
---|
| 37 | GPSADDBITSFLOAT(16, eph._Cic, 1.0/static_cast<double>(1<<29))
|
---|
[8812] | 38 | GPSADDBITSFLOAT(32, eph._OMEGA0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
[6819] | 39 | GPSADDBITSFLOAT(16, eph._Cis, 1.0/static_cast<double>(1<<29))
|
---|
| 40 | GPSADDBITSFLOAT(32, eph._i0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
| 41 | GPSADDBITSFLOAT(16, eph._Crc, 1.0/static_cast<double>(1<<5))
|
---|
[8812] | 42 | GPSADDBITSFLOAT(32, eph._omega, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
| 43 | GPSADDBITSFLOAT(24, eph._OMEGADOT, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<13))
|
---|
| 44 | GPSADDBITSFLOAT(14, eph._IDOT, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<13))
|
---|
[6819] | 45 | GPSADDBITS(2,eph._L2Codes)
|
---|
| 46 | GPSADDBITS(10, eph._TOC.gpsw())
|
---|
| 47 | GPSADDBITS(4, ura)
|
---|
| 48 | GPSADDBITS(6, eph._health)
|
---|
| 49 | GPSADDBITSFLOAT(8, eph._TGD, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
[8853] | 50 | GPSADDBITS(10, eph._IODC)
|
---|
[8852] | 51 | (eph._fitInterval == 2.0) ? fitIntervalFlag = 0 : fitIntervalFlag = 1;
|
---|
| 52 | GPSADDBITS(1, fitIntervalFlag)
|
---|
[6819] | 53 | GPSADDBITS(3, 0) /* padding */
|
---|
[8812] | 54 | } else if (eph.type() == t_eph::IRNSS) {
|
---|
[9002] | 55 | GPSADDBITS(12, 1041)
|
---|
[8812] | 56 | GPSADDBITS(6, eph._prn.number())
|
---|
| 57 | GPSADDBITS(10, eph._TOC.gpsw())
|
---|
| 58 | GPSADDBITSFLOAT(22, eph._clock_bias, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
| 59 | GPSADDBITSFLOAT(16, eph._clock_drift, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<13))
|
---|
| 60 | GPSADDBITSFLOAT(8, eph._clock_driftrate, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<25))
|
---|
| 61 | GPSADDBITS(4, ura)
|
---|
| 62 | GPSADDBITS(16, static_cast<int>(eph._TOC.gpssec())>>4)
|
---|
| 63 | GPSADDBITSFLOAT(8, eph._TGD, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
| 64 | GPSADDBITSFLOAT(22, eph._Delta_n, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<11))
|
---|
| 65 | GPSADDBITS(8, eph._IODE) // Issue Of Data Ephemeris and Clock
|
---|
| 66 | GPSADDBITS(10, 0) /* padding */
|
---|
| 67 | if (eph._health == 0.0) {
|
---|
| 68 | L5Flag = 0;
|
---|
| 69 | SFlag = 0;
|
---|
| 70 | } else if (eph._health == 1.0) {
|
---|
| 71 | L5Flag = 0;
|
---|
| 72 | SFlag = 1;
|
---|
| 73 | } else if (eph._health == 2.0) {
|
---|
| 74 | L5Flag = 1;
|
---|
| 75 | SFlag = 0;
|
---|
| 76 | } else if (eph._health == 3.0) {
|
---|
| 77 | L5Flag = 1;
|
---|
| 78 | SFlag = 1;
|
---|
| 79 | }
|
---|
| 80 | GPSADDBITS(1, L5Flag)
|
---|
| 81 | GPSADDBITS(1, SFlag)
|
---|
| 82 | GPSADDBITSFLOAT(15, eph._Cuc, 1.0/static_cast<double>(1<<28))
|
---|
| 83 | GPSADDBITSFLOAT(15, eph._Cus, 1.0/static_cast<double>(1<<28))
|
---|
| 84 | GPSADDBITSFLOAT(15, eph._Cic, 1.0/static_cast<double>(1<<28))
|
---|
| 85 | GPSADDBITSFLOAT(15, eph._Cis, 1.0/static_cast<double>(1<<28))
|
---|
| 86 | GPSADDBITSFLOAT(15, eph._Crc, 1.0/static_cast<double>(1<< 4))
|
---|
| 87 | GPSADDBITSFLOAT(15, eph._Crs, 1.0/static_cast<double>(1<< 4))
|
---|
| 88 | GPSADDBITSFLOAT(14, eph._IDOT, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<13))
|
---|
[9328] | 89 | GPSADDBITS(2, 0) /* padding */
|
---|
[8812] | 90 | GPSADDBITSFLOAT(32, eph._M0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
| 91 | GPSADDBITS(16, static_cast<int>(eph._TOEsec)>>4)
|
---|
| 92 | GPSADDBITSFLOAT(32, eph._e, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<3))
|
---|
| 93 | GPSADDBITSFLOAT(32, eph._sqrt_A, 1.0/static_cast<double>(1<<19))
|
---|
| 94 | GPSADDBITSFLOAT(32, eph._OMEGA0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
| 95 | GPSADDBITSFLOAT(32, eph._omega, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
| 96 | GPSADDBITSFLOAT(22, eph._OMEGADOT, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<11))
|
---|
| 97 | GPSADDBITSFLOAT(32, eph._i0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
| 98 | GPSADDBITS(2, 0) /* padding */
|
---|
| 99 | } else {
|
---|
[6814] | 100 | GPSADDBITS(12, 1019)
|
---|
[6819] | 101 | GPSADDBITS(6,eph._prn.number())
|
---|
| 102 | GPSADDBITS(10, eph._TOC.gpsw())
|
---|
| 103 | GPSADDBITS(4, ura)
|
---|
| 104 | GPSADDBITS(2,eph._L2Codes)
|
---|
[8812] | 105 | GPSADDBITSFLOAT(14, eph._IDOT, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<13))
|
---|
[6819] | 106 | GPSADDBITS(8, eph._IODE)
|
---|
| 107 | GPSADDBITS(16, static_cast<int>(eph._TOC.gpssec())>>4)
|
---|
[8812] | 108 | GPSADDBITSFLOAT(8, eph._clock_driftrate, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<25))
|
---|
| 109 | GPSADDBITSFLOAT(16, eph._clock_drift, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<13))
|
---|
| 110 | GPSADDBITSFLOAT(22, eph._clock_bias, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
[6819] | 111 | GPSADDBITS(10, eph._IODC)
|
---|
| 112 | GPSADDBITSFLOAT(16, eph._Crs, 1.0/static_cast<double>(1<<5))
|
---|
[8812] | 113 | GPSADDBITSFLOAT(16, eph._Delta_n, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<13))
|
---|
[6819] | 114 | GPSADDBITSFLOAT(32, eph._M0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
| 115 | GPSADDBITSFLOAT(16, eph._Cuc, 1.0/static_cast<double>(1<<29))
|
---|
| 116 | GPSADDBITSFLOAT(32, eph._e, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<3))
|
---|
| 117 | GPSADDBITSFLOAT(16, eph._Cus, 1.0/static_cast<double>(1<<29))
|
---|
| 118 | GPSADDBITSFLOAT(32, eph._sqrt_A, 1.0/static_cast<double>(1<<19))
|
---|
| 119 | GPSADDBITS(16, static_cast<int>(eph._TOEsec)>>4)
|
---|
| 120 | GPSADDBITSFLOAT(16, eph._Cic, 1.0/static_cast<double>(1<<29))
|
---|
[8812] | 121 | GPSADDBITSFLOAT(32, eph._OMEGA0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
[6819] | 122 | GPSADDBITSFLOAT(16, eph._Cis, 1.0/static_cast<double>(1<<29))
|
---|
| 123 | GPSADDBITSFLOAT(32, eph._i0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
| 124 | GPSADDBITSFLOAT(16, eph._Crc, 1.0/static_cast<double>(1<<5))
|
---|
[8812] | 125 | GPSADDBITSFLOAT(32, eph._omega, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
| 126 | GPSADDBITSFLOAT(24, eph._OMEGADOT, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<13))
|
---|
[6819] | 127 | GPSADDBITSFLOAT(8, eph._TGD, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
[7844] | 128 | GPSADDBITS(6, eph._health)
|
---|
[6819] | 129 | GPSADDBITS(1, eph._L2PFlag)
|
---|
[8852] | 130 | (eph._fitInterval == 4.0) ? fitIntervalFlag = 0 : fitIntervalFlag = 1;
|
---|
| 131 | GPSADDBITS(1, fitIntervalFlag)
|
---|
[6814] | 132 | }
|
---|
[5852] | 133 |
|
---|
| 134 | startbuffer[0]=0xD3;
|
---|
| 135 | startbuffer[1]=(size >> 8);
|
---|
| 136 | startbuffer[2]=size;
|
---|
| 137 | unsigned long i = CRC24(size+3, startbuffer);
|
---|
| 138 | buffer[size++] = i >> 16;
|
---|
| 139 | buffer[size++] = i >> 8;
|
---|
| 140 | buffer[size++] = i;
|
---|
| 141 | size += 3;
|
---|
| 142 | return size;
|
---|
| 143 | }
|
---|
| 144 |
|
---|
| 145 | // build up RTCM3 for GLONASS
|
---|
| 146 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 147 | int t_ephEncoder::RTCM3(const t_ephGlo& eph, unsigned char *buffer)
|
---|
| 148 | {
|
---|
| 149 |
|
---|
| 150 | int size = 0;
|
---|
| 151 | int numbits = 0;
|
---|
| 152 | long long bitbuffer = 0;
|
---|
| 153 | unsigned char *startbuffer = buffer;
|
---|
| 154 | buffer= buffer+3;
|
---|
| 155 |
|
---|
| 156 | GLONASSADDBITS(12, 1020)
|
---|
[5853] | 157 | GLONASSADDBITS(6, eph._prn.number())
|
---|
| 158 | GLONASSADDBITS(5, 7+eph._frequency_number)
|
---|
[8182] | 159 | GLONASSADDBITS(1, eph._almanac_health)
|
---|
| 160 | GLONASSADDBITS(1, eph._almanac_health_availablility_indicator)
|
---|
| 161 | GLONASSADDBITS(2, eph._P1)
|
---|
[7844] | 162 | int tki = static_cast<int>(eph._tki)+3*60*60;
|
---|
| 163 | if (tki > 86400) {tki -= 86400;}
|
---|
[7849] | 164 | GLONASSADDBITS(5, static_cast<int>(tki)/(60*60))
|
---|
| 165 | GLONASSADDBITS(6, (static_cast<int>(tki)/60)%60)
|
---|
| 166 | GLONASSADDBITS(1, (static_cast<int>(tki)/30)%30)
|
---|
[7844] | 167 | GLONASSADDBITS(1, eph._health)
|
---|
[8182] | 168 | GLONASSADDBITS(1, eph._P2)
|
---|
[5853] | 169 | unsigned long long timeofday = (static_cast<int>(eph._tt.gpssec()+3*60*60-eph._gps_utc)%86400);
|
---|
[5852] | 170 | GLONASSADDBITS(7, timeofday/60/15)
|
---|
[5853] | 171 | GLONASSADDBITSFLOATM(24, eph._x_velocity*1000, 1000.0/static_cast<double>(1<<20))
|
---|
| 172 | GLONASSADDBITSFLOATM(27, eph._x_pos*1000, 1000.0/static_cast<double>(1<<11))
|
---|
| 173 | GLONASSADDBITSFLOATM(5, eph._x_acceleration*1000, 1000.0/static_cast<double>(1<<30))
|
---|
| 174 | GLONASSADDBITSFLOATM(24, eph._y_velocity*1000, 1000.0/static_cast<double>(1<<20))
|
---|
| 175 | GLONASSADDBITSFLOATM(27, eph._y_pos*1000, 1000.0/static_cast<double>(1<<11))
|
---|
| 176 | GLONASSADDBITSFLOATM(5, eph._y_acceleration*1000, 1000.0/static_cast<double>(1<<30))
|
---|
| 177 | GLONASSADDBITSFLOATM(24, eph._z_velocity*1000, 1000.0/static_cast<double>(1<<20))
|
---|
| 178 | GLONASSADDBITSFLOATM(27,eph._z_pos*1000, 1000.0/static_cast<double>(1<<11))
|
---|
| 179 | GLONASSADDBITSFLOATM(5, eph._z_acceleration*1000, 1000.0/static_cast<double>(1<<30))
|
---|
[8182] | 180 | GLONASSADDBITS(1, eph._P3)
|
---|
| 181 | GLONASSADDBITSFLOATM(11, eph._gamma, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<10))
|
---|
| 182 | GLONASSADDBITS(2, eph._M_P) /* GLONASS-M P */
|
---|
| 183 | GLONASSADDBITS(1, eph._M_l3) /* GLONASS-M ln(3) */
|
---|
[5853] | 184 | GLONASSADDBITSFLOATM(22, eph._tau, 1.0/static_cast<double>(1<<30))
|
---|
[8182] | 185 | GLONASSADDBITSFLOATM(5, eph._M_delta_tau, 1.0/static_cast<double>(1<<30)) /* GLONASS-M delta tau */
|
---|
[5853] | 186 | GLONASSADDBITS(5, eph._E)
|
---|
[8182] | 187 | GLONASSADDBITS(1, eph._M_P4) /* GLONASS-M P4 */
|
---|
| 188 | GLONASSADDBITS(4, eph._M_FT) /* GLONASS-M FT */
|
---|
| 189 | GLONASSADDBITS(11, eph._M_NT) /* GLONASS-M NT */
|
---|
| 190 | GLONASSADDBITS(2, eph._M_M) /* GLONASS-M active? */
|
---|
| 191 | GLONASSADDBITS(1, eph._additional_data_availability) /* GLONASS additional data */
|
---|
| 192 | GLONASSADDBITS(11, eph._NA) /* GLONASS NA */
|
---|
| 193 | GLONASSADDBITSFLOATM(32, eph._tauC, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<1)) /* GLONASS tau C */
|
---|
| 194 | GLONASSADDBITS(5, eph._M_N4) /* GLONASS-M N4 */
|
---|
| 195 | GLONASSADDBITSFLOATM(22, eph._M_tau_GPS, 1.0/static_cast<double>(1<<30)) /* GLONASS-M tau GPS */
|
---|
| 196 | GLONASSADDBITS(1, eph._M_l5) /* GLONASS-M ln(5) */
|
---|
[5852] | 197 | GLONASSADDBITS(7, 0) /* Reserved */
|
---|
| 198 |
|
---|
| 199 | startbuffer[0]=0xD3;
|
---|
| 200 | startbuffer[1]=(size >> 8);
|
---|
| 201 | startbuffer[2]=size;
|
---|
| 202 | unsigned long i = CRC24(size+3, startbuffer);
|
---|
| 203 | buffer[size++] = i >> 16;
|
---|
| 204 | buffer[size++] = i >> 8;
|
---|
| 205 | buffer[size++] = i;
|
---|
| 206 | size += 3;
|
---|
| 207 | return size;
|
---|
| 208 | }
|
---|
| 209 |
|
---|
| 210 | // build up RTCM3 for Galileo
|
---|
| 211 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 212 | int t_ephEncoder::RTCM3(const t_ephGal& eph, unsigned char *buffer) {
|
---|
| 213 | int size = 0;
|
---|
| 214 | int numbits = 0;
|
---|
| 215 | long long bitbuffer = 0;
|
---|
| 216 | unsigned char *startbuffer = buffer;
|
---|
| 217 | buffer= buffer+3;
|
---|
| 218 |
|
---|
[6819] | 219 | int SISA = indexFromAccuracy(eph._SISA, eph.type());
|
---|
[6799] | 220 |
|
---|
[6812] | 221 | GALILEOADDBITS(12, eph._inav ? 1046 : 1045)
|
---|
[5853] | 222 | GALILEOADDBITS(6, eph._prn.number())
|
---|
[6869] | 223 | GALILEOADDBITS(12, eph._TOC.galw())
|
---|
[5853] | 224 | GALILEOADDBITS(10, eph._IODnav)
|
---|
[6819] | 225 | GALILEOADDBITS(8, SISA)
|
---|
[8812] | 226 | GALILEOADDBITSFLOAT(14, eph._IDOT, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<13))
|
---|
[5853] | 227 | GALILEOADDBITS(14, eph._TOC.gpssec()/60)
|
---|
[8812] | 228 | GALILEOADDBITSFLOAT(6, eph._clock_driftrate, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<29))
|
---|
| 229 | GALILEOADDBITSFLOAT(21, eph._clock_drift, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<16))
|
---|
| 230 | GALILEOADDBITSFLOAT(31, eph._clock_bias, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<4))
|
---|
[5853] | 231 | GALILEOADDBITSFLOAT(16, eph._Crs, 1.0/static_cast<double>(1<<5))
|
---|
[8812] | 232 | GALILEOADDBITSFLOAT(16, eph._Delta_n, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<13))
|
---|
[5853] | 233 | GALILEOADDBITSFLOAT(32, eph._M0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
| 234 | GALILEOADDBITSFLOAT(16, eph._Cuc, 1.0/static_cast<double>(1<<29))
|
---|
| 235 | GALILEOADDBITSFLOAT(32, eph._e, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<3))
|
---|
| 236 | GALILEOADDBITSFLOAT(16, eph._Cus, 1.0/static_cast<double>(1<<29))
|
---|
| 237 | GALILEOADDBITSFLOAT(32, eph._sqrt_A, 1.0/static_cast<double>(1<<19))
|
---|
| 238 | GALILEOADDBITS(14, eph._TOEsec/60)
|
---|
| 239 | GALILEOADDBITSFLOAT(16, eph._Cic, 1.0/static_cast<double>(1<<29))
|
---|
[8812] | 240 | GALILEOADDBITSFLOAT(32, eph._OMEGA0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
[5853] | 241 | GALILEOADDBITSFLOAT(16, eph._Cis, 1.0/static_cast<double>(1<<29))
|
---|
| 242 | GALILEOADDBITSFLOAT(32, eph._i0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
| 243 | GALILEOADDBITSFLOAT(16, eph._Crc, 1.0/static_cast<double>(1<<5))
|
---|
[8812] | 244 | GALILEOADDBITSFLOAT(32, eph._omega, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
| 245 | GALILEOADDBITSFLOAT(24, eph._OMEGADOT, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<13))
|
---|
| 246 | GALILEOADDBITSFLOAT(10, eph._BGD_1_5A, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<2))
|
---|
[8813] | 247 | if(eph._inav) {
|
---|
[8812] | 248 | GALILEOADDBITSFLOAT(10, eph._BGD_1_5B, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<2))
|
---|
[5853] | 249 | GALILEOADDBITS(2, static_cast<int>(eph._E5bHS))
|
---|
[6812] | 250 | GALILEOADDBITS(1, eph._e5bDataInValid ? 1 : 0)
|
---|
[6818] | 251 | GALILEOADDBITS(2, static_cast<int>(eph._E1_bHS))
|
---|
| 252 | GALILEOADDBITS(1, eph._e1DataInValid ? 1 : 0)
|
---|
[8812] | 253 | } else {
|
---|
[5853] | 254 | GALILEOADDBITS(2, static_cast<int>(eph._E5aHS))
|
---|
[6812] | 255 | GALILEOADDBITS(1, eph._e5aDataInValid ? 1 : 0)
|
---|
[5852] | 256 | }
|
---|
| 257 |
|
---|
[6818] | 258 | GALILEOADDBITS((eph._inav ? 2 : 7), 0)
|
---|
[5852] | 259 |
|
---|
| 260 | startbuffer[0]=0xD3;
|
---|
| 261 | startbuffer[1]=(size >> 8);
|
---|
| 262 | startbuffer[2]=size;
|
---|
| 263 | unsigned long i = CRC24(size+3, startbuffer);
|
---|
| 264 | buffer[size++] = i >> 16;
|
---|
| 265 | buffer[size++] = i >> 8;
|
---|
| 266 | buffer[size++] = i;
|
---|
| 267 | size += 3;
|
---|
| 268 | return size;
|
---|
| 269 | }
|
---|
| 270 |
|
---|
[6615] | 271 | // build up RTCM3 for SBAS
|
---|
| 272 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6631] | 273 | int t_ephEncoder::RTCM3(const t_ephSBAS& eph, unsigned char* buffer) {
|
---|
| 274 | int size = 0;
|
---|
| 275 | int numbits = 0;
|
---|
| 276 | long long bitbuffer = 0;
|
---|
| 277 | unsigned char *startbuffer = buffer;
|
---|
| 278 | buffer= buffer+3;
|
---|
| 279 |
|
---|
[6819] | 280 | int ura = indexFromAccuracy(eph._ura, eph.type());
|
---|
[6631] | 281 | SBASADDBITS(12, 1043)
|
---|
| 282 | SBASADDBITS(6, eph._prn.number()-20)
|
---|
| 283 | SBASADDBITS(8, eph._IODN)
|
---|
| 284 | SBASADDBITS(13, static_cast<int>(eph._TOC.daysec())>>4)
|
---|
[6819] | 285 | SBASADDBITS(4, ura)
|
---|
[6631] | 286 | SBASADDBITSFLOAT(30, eph._x_pos, 0.08)
|
---|
| 287 | SBASADDBITSFLOAT(30, eph._y_pos, 0.08)
|
---|
| 288 | SBASADDBITSFLOAT(25, eph._z_pos, 0.4)
|
---|
| 289 | SBASADDBITSFLOAT(17, eph._x_velocity, 0.000625)
|
---|
| 290 | SBASADDBITSFLOAT(17, eph._y_velocity, 0.000625)
|
---|
| 291 | SBASADDBITSFLOAT(18, eph._z_velocity, 0.004)
|
---|
| 292 | SBASADDBITSFLOAT(10, eph._x_acceleration, 0.0000125)
|
---|
| 293 | SBASADDBITSFLOAT(10, eph._y_acceleration, 0.0000125)
|
---|
| 294 | SBASADDBITSFLOAT(10, eph._z_acceleration, 0.0000625)
|
---|
| 295 | SBASADDBITSFLOAT(12, eph._agf0, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
| 296 | SBASADDBITSFLOAT(8, eph._agf1, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<10))
|
---|
[6635] | 297 | SBASADDBITS(2,0);
|
---|
[6631] | 298 |
|
---|
| 299 | startbuffer[0]=0xD3;
|
---|
| 300 | startbuffer[1]=(size >> 8);
|
---|
| 301 | startbuffer[2]=size;
|
---|
| 302 | unsigned long i = CRC24(size+3, startbuffer);
|
---|
| 303 | buffer[size++] = i >> 16;
|
---|
| 304 | buffer[size++] = i >> 8;
|
---|
| 305 | buffer[size++] = i;
|
---|
| 306 | size += 3;
|
---|
| 307 | return size;
|
---|
[6403] | 308 | }
|
---|
| 309 |
|
---|
[6615] | 310 | // build up RTCM3 for BDS
|
---|
| 311 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 312 | int t_ephEncoder::RTCM3(const t_ephBDS& eph, unsigned char* buffer) {
|
---|
| 313 | int size = 0;
|
---|
| 314 | int numbits = 0;
|
---|
| 315 | long long bitbuffer = 0;
|
---|
| 316 | unsigned char *startbuffer = buffer;
|
---|
| 317 | buffer= buffer+3;
|
---|
| 318 |
|
---|
[6819] | 319 | int URA = indexFromAccuracy(eph._URA, eph.type());
|
---|
[9000] | 320 | BDSADDBITS(12, 1042)
|
---|
[6615] | 321 | BDSADDBITS(6, eph._prn.number())
|
---|
[8208] | 322 | BDSADDBITS(13, eph._TOC.bdsw())
|
---|
[6819] | 323 | BDSADDBITS(4, URA);
|
---|
[6615] | 324 | BDSADDBITSFLOAT(14, eph._IDOT, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<13))
|
---|
| 325 | BDSADDBITS(5, eph._AODE)
|
---|
[6812] | 326 | BDSADDBITS(17, static_cast<int>(eph._TOC.bdssec())>>3)
|
---|
[8812] | 327 | BDSADDBITSFLOAT(11, eph._clock_driftrate, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<30)/static_cast<double>(1<<6))
|
---|
[6615] | 328 | BDSADDBITSFLOAT(22, eph._clock_drift, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<20))
|
---|
| 329 | BDSADDBITSFLOAT(24, eph._clock_bias, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<3))
|
---|
| 330 | BDSADDBITS(5, eph._AODC)
|
---|
| 331 | BDSADDBITSFLOAT(18, eph._Crs, 1.0/static_cast<double>(1<<6))
|
---|
| 332 | BDSADDBITSFLOAT(16, eph._Delta_n, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<13))
|
---|
| 333 | BDSADDBITSFLOAT(32, eph._M0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
| 334 | BDSADDBITSFLOAT(18, eph._Cuc, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
| 335 | BDSADDBITSFLOAT(32, eph._e, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<3))
|
---|
| 336 | BDSADDBITSFLOAT(18, eph._Cus, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
| 337 | BDSADDBITSFLOAT(32, eph._sqrt_A, 1.0/static_cast<double>(1<<19))
|
---|
[6812] | 338 | BDSADDBITS(17, static_cast<int>(eph._TOE.bdssec())>>3)
|
---|
[6615] | 339 | BDSADDBITSFLOAT(18, eph._Cic, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
| 340 | BDSADDBITSFLOAT(32, eph._OMEGA0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
| 341 | BDSADDBITSFLOAT(18, eph._Cis, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
| 342 | BDSADDBITSFLOAT(32, eph._i0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
[6619] | 343 | BDSADDBITSFLOAT(18, eph._Crc, 1.0/static_cast<double>(1<<6))
|
---|
[6615] | 344 | BDSADDBITSFLOAT(32, eph._omega, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
| 345 | BDSADDBITSFLOAT(24, eph._OMEGADOT, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<13))
|
---|
| 346 | BDSADDBITSFLOAT(10, eph._TGD1, 0.0000000001)
|
---|
| 347 | BDSADDBITSFLOAT(10, eph._TGD2, 0.0000000001)
|
---|
| 348 | BDSADDBITS(1, eph._SatH1)
|
---|
[6627] | 349 | BDSADDBITS(1, 0) /* reserved bit, fill up 8 bits */
|
---|
[6615] | 350 |
|
---|
| 351 | startbuffer[0]=0xD3;
|
---|
| 352 | startbuffer[1]=(size >> 8);
|
---|
| 353 | startbuffer[2]=size;
|
---|
| 354 | unsigned long i = CRC24(size+3, startbuffer);
|
---|
| 355 | buffer[size++] = i >> 16;
|
---|
| 356 | buffer[size++] = i >> 8;
|
---|
| 357 | buffer[size++] = i;
|
---|
| 358 | size += 3;
|
---|
| 359 | return size;
|
---|
[6403] | 360 | }
|
---|
[7053] | 361 |
|
---|