[1025] | 1 | #include <math.h>
|
---|
| 2 | #include <sstream>
|
---|
[2234] | 3 | #include <iostream>
|
---|
[1025] | 4 | #include <iomanip>
|
---|
[1239] | 5 | #include <cstring>
|
---|
[1025] | 6 |
|
---|
[2234] | 7 | #include <newmatio.h>
|
---|
| 8 |
|
---|
[1025] | 9 | #include "ephemeris.h"
|
---|
[2221] | 10 | #include "bncutils.h"
|
---|
[1025] | 11 | #include "timeutils.h"
|
---|
[2285] | 12 | #include "bnctime.h"
|
---|
[5070] | 13 | #include "bnccore.h"
|
---|
[1025] | 14 |
|
---|
| 15 | using namespace std;
|
---|
| 16 |
|
---|
[3255] | 17 | // Returns CRC24
|
---|
| 18 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4018] | 19 | static unsigned long CRC24(long size, const unsigned char *buf) {
|
---|
[3255] | 20 | unsigned long crc = 0;
|
---|
[4018] | 21 | int ii;
|
---|
| 22 | while (size--) {
|
---|
[3255] | 23 | crc ^= (*buf++) << (16);
|
---|
[4018] | 24 | for(ii = 0; ii < 8; ii++) {
|
---|
[3255] | 25 | crc <<= 1;
|
---|
[4018] | 26 | if (crc & 0x1000000) {
|
---|
[3255] | 27 | crc ^= 0x01864cfb;
|
---|
[4018] | 28 | }
|
---|
[3255] | 29 | }
|
---|
| 30 | }
|
---|
| 31 | return crc;
|
---|
[1025] | 32 | }
|
---|
| 33 |
|
---|
[2222] | 34 | // Set GPS Satellite Position
|
---|
| 35 | ////////////////////////////////////////////////////////////////////////////
|
---|
[1025] | 36 | void t_ephGPS::set(const gpsephemeris* ee) {
|
---|
| 37 |
|
---|
[4097] | 38 | _receptDateTime = currentDateAndTimeGPS();
|
---|
| 39 |
|
---|
[3255] | 40 | _prn = QString("G%1").arg(ee->satellite, 2, 10, QChar('0'));
|
---|
[1025] | 41 |
|
---|
[4018] | 42 | _TOC.set(ee->GPSweek, ee->TOC);
|
---|
[3734] | 43 | _clock_bias = ee->clock_bias;
|
---|
| 44 | _clock_drift = ee->clock_drift;
|
---|
[1025] | 45 | _clock_driftrate = ee->clock_driftrate;
|
---|
| 46 |
|
---|
[4018] | 47 | _IODE = ee->IODE;
|
---|
[1025] | 48 | _Crs = ee->Crs;
|
---|
| 49 | _Delta_n = ee->Delta_n;
|
---|
| 50 | _M0 = ee->M0;
|
---|
[4018] | 51 |
|
---|
[1025] | 52 | _Cuc = ee->Cuc;
|
---|
| 53 | _e = ee->e;
|
---|
| 54 | _Cus = ee->Cus;
|
---|
| 55 | _sqrt_A = ee->sqrt_A;
|
---|
[4018] | 56 |
|
---|
| 57 | _TOEsec = ee->TOE;
|
---|
[1025] | 58 | _Cic = ee->Cic;
|
---|
| 59 | _OMEGA0 = ee->OMEGA0;
|
---|
| 60 | _Cis = ee->Cis;
|
---|
[4018] | 61 |
|
---|
[1025] | 62 | _i0 = ee->i0;
|
---|
| 63 | _Crc = ee->Crc;
|
---|
| 64 | _omega = ee->omega;
|
---|
| 65 | _OMEGADOT = ee->OMEGADOT;
|
---|
[4018] | 66 |
|
---|
[1025] | 67 | _IDOT = ee->IDOT;
|
---|
[4018] | 68 | _L2Codes = 0.0;
|
---|
[4025] | 69 | _TOEweek = ee->GPSweek;
|
---|
[4018] | 70 | _L2PFlag = 0.0;
|
---|
[1025] | 71 |
|
---|
[4027] | 72 | if (ee->URAindex <= 6) {
|
---|
| 73 | _ura = ceil(10.0*pow(2.0, 1.0+((double)ee->URAindex)/2.0))/10.0;
|
---|
| 74 | }
|
---|
| 75 | else {
|
---|
| 76 | _ura = ceil(10.0*pow(2.0, ((double)ee->URAindex)/2.0))/10.0;
|
---|
| 77 | }
|
---|
[4018] | 78 | _health = ee->SVhealth;
|
---|
[1025] | 79 | _TGD = ee->TGD;
|
---|
[4018] | 80 | _IODC = ee->IODC;
|
---|
[3659] | 81 |
|
---|
[4018] | 82 | _TOT = 0.9999e9;
|
---|
| 83 | _fitInterval = 0.0;
|
---|
| 84 |
|
---|
[3659] | 85 | _ok = true;
|
---|
[1025] | 86 | }
|
---|
| 87 |
|
---|
[2222] | 88 | // Compute GPS Satellite Position (virtual)
|
---|
[1025] | 89 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 90 | void t_ephGPS::position(int GPSweek, double GPSweeks,
|
---|
[4018] | 91 | double* xc,
|
---|
| 92 | double* vv) const {
|
---|
[1025] | 93 |
|
---|
[4018] | 94 |
|
---|
[1098] | 95 | static const double omegaEarth = 7292115.1467e-11;
|
---|
[5277] | 96 | static const double gmGRS = 398.6005e12;
|
---|
[1025] | 97 |
|
---|
| 98 | memset(xc, 0, 4*sizeof(double));
|
---|
| 99 | memset(vv, 0, 3*sizeof(double));
|
---|
| 100 |
|
---|
| 101 | double a0 = _sqrt_A * _sqrt_A;
|
---|
| 102 | if (a0 == 0) {
|
---|
| 103 | return;
|
---|
| 104 | }
|
---|
| 105 |
|
---|
[5277] | 106 | double n0 = sqrt(gmGRS/(a0*a0*a0));
|
---|
[4018] | 107 |
|
---|
| 108 | bncTime tt(GPSweek, GPSweeks);
|
---|
[4543] | 109 | double tk = tt - bncTime(int(_TOEweek), _TOEsec);
|
---|
[4018] | 110 |
|
---|
[1025] | 111 | double n = n0 + _Delta_n;
|
---|
| 112 | double M = _M0 + n*tk;
|
---|
| 113 | double E = M;
|
---|
| 114 | double E_last;
|
---|
| 115 | do {
|
---|
| 116 | E_last = E;
|
---|
| 117 | E = M + _e*sin(E);
|
---|
| 118 | } while ( fabs(E-E_last)*a0 > 0.001 );
|
---|
| 119 | double v = 2.0*atan( sqrt( (1.0 + _e)/(1.0 - _e) )*tan( E/2 ) );
|
---|
| 120 | double u0 = v + _omega;
|
---|
| 121 | double sin2u0 = sin(2*u0);
|
---|
| 122 | double cos2u0 = cos(2*u0);
|
---|
| 123 | double r = a0*(1 - _e*cos(E)) + _Crc*cos2u0 + _Crs*sin2u0;
|
---|
| 124 | double i = _i0 + _IDOT*tk + _Cic*cos2u0 + _Cis*sin2u0;
|
---|
| 125 | double u = u0 + _Cuc*cos2u0 + _Cus*sin2u0;
|
---|
| 126 | double xp = r*cos(u);
|
---|
| 127 | double yp = r*sin(u);
|
---|
| 128 | double OM = _OMEGA0 + (_OMEGADOT - omegaEarth)*tk -
|
---|
[4018] | 129 | omegaEarth*_TOEsec;
|
---|
[1025] | 130 |
|
---|
| 131 | double sinom = sin(OM);
|
---|
| 132 | double cosom = cos(OM);
|
---|
| 133 | double sini = sin(i);
|
---|
| 134 | double cosi = cos(i);
|
---|
| 135 | xc[0] = xp*cosom - yp*cosi*sinom;
|
---|
| 136 | xc[1] = xp*sinom + yp*cosi*cosom;
|
---|
| 137 | xc[2] = yp*sini;
|
---|
| 138 |
|
---|
[4018] | 139 | double tc = tt - _TOC;
|
---|
[2429] | 140 | xc[3] = _clock_bias + _clock_drift*tc + _clock_driftrate*tc*tc;
|
---|
[1025] | 141 |
|
---|
| 142 | // Velocity
|
---|
| 143 | // --------
|
---|
| 144 | double tanv2 = tan(v/2);
|
---|
| 145 | double dEdM = 1 / (1 - _e*cos(E));
|
---|
| 146 | double dotv = sqrt((1.0 + _e)/(1.0 - _e)) / cos(E/2)/cos(E/2) / (1 + tanv2*tanv2)
|
---|
| 147 | * dEdM * n;
|
---|
| 148 | double dotu = dotv + (-_Cuc*sin2u0 + _Cus*cos2u0)*2*dotv;
|
---|
| 149 | double dotom = _OMEGADOT - omegaEarth;
|
---|
| 150 | double doti = _IDOT + (-_Cic*sin2u0 + _Cis*cos2u0)*2*dotv;
|
---|
| 151 | double dotr = a0 * _e*sin(E) * dEdM * n
|
---|
| 152 | + (-_Crc*sin2u0 + _Crs*cos2u0)*2*dotv;
|
---|
| 153 | double dotx = dotr*cos(u) - r*sin(u)*dotu;
|
---|
| 154 | double doty = dotr*sin(u) + r*cos(u)*dotu;
|
---|
| 155 |
|
---|
| 156 | vv[0] = cosom *dotx - cosi*sinom *doty // dX / dr
|
---|
| 157 | - xp*sinom*dotom - yp*cosi*cosom*dotom // dX / dOMEGA
|
---|
| 158 | + yp*sini*sinom*doti; // dX / di
|
---|
| 159 |
|
---|
| 160 | vv[1] = sinom *dotx + cosi*cosom *doty
|
---|
| 161 | + xp*cosom*dotom - yp*cosi*sinom*dotom
|
---|
| 162 | - yp*sini*cosom*doti;
|
---|
| 163 |
|
---|
| 164 | vv[2] = sini *doty + yp*cosi *doti;
|
---|
[2429] | 165 |
|
---|
| 166 | // Relativistic Correction
|
---|
| 167 | // -----------------------
|
---|
| 168 | xc[3] -= 2.0 * (xc[0]*vv[0] + xc[1]*vv[1] + xc[2]*vv[2]) / t_CST::c / t_CST::c;
|
---|
[1025] | 169 | }
|
---|
| 170 |
|
---|
[3255] | 171 | // build up RTCM3 for GPS
|
---|
| 172 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4018] | 173 | #define GPSTOINT(type, value) static_cast<type>(round(value))
|
---|
[1025] | 174 |
|
---|
[3255] | 175 | #define GPSADDBITS(a, b) {bitbuffer = (bitbuffer<<(a)) \
|
---|
| 176 | |(GPSTOINT(long long,b)&((1ULL<<a)-1)); \
|
---|
| 177 | numbits += (a); \
|
---|
| 178 | while(numbits >= 8) { \
|
---|
| 179 | buffer[size++] = bitbuffer>>(numbits-8);numbits -= 8;}}
|
---|
[4018] | 180 |
|
---|
[3255] | 181 | #define GPSADDBITSFLOAT(a,b,c) {long long i = GPSTOINT(long long,(b)/(c)); \
|
---|
| 182 | GPSADDBITS(a,i)};
|
---|
| 183 |
|
---|
[4018] | 184 | int t_ephGPS::RTCM3(unsigned char *buffer) {
|
---|
[3255] | 185 |
|
---|
| 186 | unsigned char *startbuffer = buffer;
|
---|
| 187 | buffer= buffer+3;
|
---|
| 188 | int size = 0;
|
---|
| 189 | int numbits = 0;
|
---|
| 190 | unsigned long long bitbuffer = 0;
|
---|
| 191 | if (_ura <= 2.40){
|
---|
| 192 | _ura = 0;
|
---|
| 193 | }
|
---|
| 194 | else if (_ura <= 3.40){
|
---|
| 195 | _ura = 1;
|
---|
| 196 | }
|
---|
| 197 | else if (_ura <= 6.85){
|
---|
| 198 | _ura = 2;
|
---|
| 199 | }
|
---|
| 200 | else if (_ura <= 9.65){
|
---|
| 201 | _ura = 3;
|
---|
| 202 | }
|
---|
| 203 | else if (_ura <= 13.65){
|
---|
| 204 | _ura = 4;
|
---|
| 205 | }
|
---|
| 206 | else if (_ura <= 24.00){
|
---|
| 207 | _ura = 5;
|
---|
| 208 | }
|
---|
| 209 | else if (_ura <= 48.00){
|
---|
| 210 | _ura = 6;
|
---|
| 211 | }
|
---|
| 212 | else if (_ura <= 96.00){
|
---|
| 213 | _ura = 7;
|
---|
| 214 | }
|
---|
| 215 | else if (_ura <= 192.00){
|
---|
| 216 | _ura = 8;
|
---|
| 217 | }
|
---|
| 218 | else if (_ura <= 384.00){
|
---|
| 219 | _ura = 9;
|
---|
| 220 | }
|
---|
| 221 | else if (_ura <= 768.00){
|
---|
| 222 | _ura = 10;
|
---|
| 223 | }
|
---|
| 224 | else if (_ura <= 1536.00){
|
---|
| 225 | _ura = 11;
|
---|
| 226 | }
|
---|
| 227 | else if (_ura <= 1536.00){
|
---|
| 228 | _ura = 12;
|
---|
| 229 | }
|
---|
| 230 | else if (_ura <= 2072.00){
|
---|
| 231 | _ura = 13;
|
---|
| 232 | }
|
---|
| 233 | else if (_ura <= 6144.00){
|
---|
| 234 | _ura = 14;
|
---|
| 235 | }
|
---|
| 236 | else{
|
---|
| 237 | _ura = 15;
|
---|
| 238 | }
|
---|
| 239 |
|
---|
| 240 | GPSADDBITS(12, 1019)
|
---|
| 241 | GPSADDBITS(6,_prn.right((_prn.length()-1)).toInt())
|
---|
[4018] | 242 | GPSADDBITS(10, _TOC.gpsw())
|
---|
[3255] | 243 | GPSADDBITS(4, _ura)
|
---|
| 244 | GPSADDBITS(2,_L2Codes)
|
---|
[4018] | 245 | GPSADDBITSFLOAT(14, _IDOT, M_PI/static_cast<double>(1<<30)
|
---|
[3255] | 246 | /static_cast<double>(1<<13))
|
---|
| 247 | GPSADDBITS(8, _IODE)
|
---|
[4018] | 248 | GPSADDBITS(16, static_cast<int>(_TOC.gpssec())>>4)
|
---|
[3255] | 249 | GPSADDBITSFLOAT(8, _clock_driftrate, 1.0/static_cast<double>(1<<30)
|
---|
| 250 | /static_cast<double>(1<<25))
|
---|
| 251 | GPSADDBITSFLOAT(16, _clock_drift, 1.0/static_cast<double>(1<<30)
|
---|
| 252 | /static_cast<double>(1<<13))
|
---|
| 253 | GPSADDBITSFLOAT(22, _clock_bias, 1.0/static_cast<double>(1<<30)
|
---|
| 254 | /static_cast<double>(1<<1))
|
---|
| 255 | GPSADDBITS(10, _IODC)
|
---|
| 256 | GPSADDBITSFLOAT(16, _Crs, 1.0/static_cast<double>(1<<5))
|
---|
[4018] | 257 | GPSADDBITSFLOAT(16, _Delta_n, M_PI/static_cast<double>(1<<30)
|
---|
[3255] | 258 | /static_cast<double>(1<<13))
|
---|
[4018] | 259 | GPSADDBITSFLOAT(32, _M0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
[3255] | 260 | GPSADDBITSFLOAT(16, _Cuc, 1.0/static_cast<double>(1<<29))
|
---|
| 261 | GPSADDBITSFLOAT(32, _e, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<3))
|
---|
| 262 | GPSADDBITSFLOAT(16, _Cus, 1.0/static_cast<double>(1<<29))
|
---|
| 263 | GPSADDBITSFLOAT(32, _sqrt_A, 1.0/static_cast<double>(1<<19))
|
---|
[4018] | 264 | GPSADDBITS(16, static_cast<int>(_TOEsec)>>4)
|
---|
[3255] | 265 | GPSADDBITSFLOAT(16, _Cic, 1.0/static_cast<double>(1<<29))
|
---|
[4018] | 266 | GPSADDBITSFLOAT(32, _OMEGA0, M_PI/static_cast<double>(1<<30)
|
---|
[3255] | 267 | /static_cast<double>(1<<1))
|
---|
| 268 | GPSADDBITSFLOAT(16, _Cis, 1.0/static_cast<double>(1<<29))
|
---|
[4018] | 269 | GPSADDBITSFLOAT(32, _i0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
[3255] | 270 | GPSADDBITSFLOAT(16, _Crc, 1.0/static_cast<double>(1<<5))
|
---|
[4018] | 271 | GPSADDBITSFLOAT(32, _omega, M_PI/static_cast<double>(1<<30)
|
---|
[3255] | 272 | /static_cast<double>(1<<1))
|
---|
[4018] | 273 | GPSADDBITSFLOAT(24, _OMEGADOT, M_PI/static_cast<double>(1<<30)
|
---|
[3255] | 274 | /static_cast<double>(1<<13))
|
---|
| 275 | GPSADDBITSFLOAT(8, _TGD, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
| 276 | GPSADDBITS(6, _health)
|
---|
| 277 | GPSADDBITS(1, _L2PFlag)
|
---|
| 278 | GPSADDBITS(1, 0) /* GPS fit interval */
|
---|
| 279 |
|
---|
| 280 | startbuffer[0]=0xD3;
|
---|
| 281 | startbuffer[1]=(size >> 8);
|
---|
| 282 | startbuffer[2]=size;
|
---|
| 283 | unsigned long i = CRC24(size+3, startbuffer);
|
---|
| 284 | buffer[size++] = i >> 16;
|
---|
| 285 | buffer[size++] = i >> 8;
|
---|
| 286 | buffer[size++] = i;
|
---|
| 287 | size += 3;
|
---|
| 288 | return size;
|
---|
| 289 | }
|
---|
| 290 |
|
---|
[2221] | 291 | // Derivative of the state vector using a simple force model (static)
|
---|
| 292 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2556] | 293 | ColumnVector t_ephGlo::glo_deriv(double /* tt */, const ColumnVector& xv,
|
---|
| 294 | double* acc) {
|
---|
[2221] | 295 |
|
---|
| 296 | // State vector components
|
---|
| 297 | // -----------------------
|
---|
| 298 | ColumnVector rr = xv.rows(1,3);
|
---|
| 299 | ColumnVector vv = xv.rows(4,6);
|
---|
| 300 |
|
---|
| 301 | // Acceleration
|
---|
| 302 | // ------------
|
---|
[5277] | 303 | static const double gmWGS = 398.60044e12;
|
---|
[2221] | 304 | static const double AE = 6378136.0;
|
---|
| 305 | static const double OMEGA = 7292115.e-11;
|
---|
[2561] | 306 | static const double C20 = -1082.6257e-6;
|
---|
[2221] | 307 |
|
---|
| 308 | double rho = rr.norm_Frobenius();
|
---|
[5277] | 309 | double t1 = -gmWGS/(rho*rho*rho);
|
---|
| 310 | double t2 = 3.0/2.0 * C20 * (gmWGS*AE*AE) / (rho*rho*rho*rho*rho);
|
---|
[2221] | 311 | double t3 = OMEGA * OMEGA;
|
---|
| 312 | double t4 = 2.0 * OMEGA;
|
---|
| 313 | double z2 = rr(3) * rr(3);
|
---|
| 314 |
|
---|
| 315 | // Vector of derivatives
|
---|
| 316 | // ---------------------
|
---|
| 317 | ColumnVector va(6);
|
---|
| 318 | va(1) = vv(1);
|
---|
| 319 | va(2) = vv(2);
|
---|
| 320 | va(3) = vv(3);
|
---|
[2556] | 321 | va(4) = (t1 + t2*(1.0-5.0*z2/(rho*rho)) + t3) * rr(1) + t4*vv(2) + acc[0];
|
---|
| 322 | va(5) = (t1 + t2*(1.0-5.0*z2/(rho*rho)) + t3) * rr(2) - t4*vv(1) + acc[1];
|
---|
| 323 | va(6) = (t1 + t2*(3.0-5.0*z2/(rho*rho)) ) * rr(3) + acc[2];
|
---|
[2221] | 324 |
|
---|
| 325 | return va;
|
---|
| 326 | }
|
---|
| 327 |
|
---|
| 328 | // Compute Glonass Satellite Position (virtual)
|
---|
| 329 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 330 | void t_ephGlo::position(int GPSweek, double GPSweeks,
|
---|
| 331 | double* xc, double* vv) const {
|
---|
| 332 |
|
---|
| 333 | static const double nominalStep = 10.0;
|
---|
| 334 |
|
---|
| 335 | memset(xc, 0, 4*sizeof(double));
|
---|
| 336 | memset(vv, 0, 3*sizeof(double));
|
---|
| 337 |
|
---|
[4018] | 338 | double dtPos = bncTime(GPSweek, GPSweeks) - _tt;
|
---|
[2221] | 339 |
|
---|
| 340 | int nSteps = int(fabs(dtPos) / nominalStep) + 1;
|
---|
| 341 | double step = dtPos / nSteps;
|
---|
| 342 |
|
---|
[2556] | 343 | double acc[3];
|
---|
[2557] | 344 | acc[0] = _x_acceleration * 1.e3;
|
---|
[2560] | 345 | acc[1] = _y_acceleration * 1.e3;
|
---|
| 346 | acc[2] = _z_acceleration * 1.e3;
|
---|
[2221] | 347 | for (int ii = 1; ii <= nSteps; ii++) {
|
---|
[4018] | 348 | _xv = rungeKutta4(_tt.gpssec(), _xv, step, acc, glo_deriv);
|
---|
| 349 | _tt = _tt + step;
|
---|
[2221] | 350 | }
|
---|
| 351 |
|
---|
| 352 | // Position and Velocity
|
---|
| 353 | // ---------------------
|
---|
| 354 | xc[0] = _xv(1);
|
---|
| 355 | xc[1] = _xv(2);
|
---|
| 356 | xc[2] = _xv(3);
|
---|
| 357 |
|
---|
| 358 | vv[0] = _xv(4);
|
---|
| 359 | vv[1] = _xv(5);
|
---|
| 360 | vv[2] = _xv(6);
|
---|
| 361 |
|
---|
| 362 | // Clock Correction
|
---|
| 363 | // ----------------
|
---|
[4018] | 364 | double dtClk = bncTime(GPSweek, GPSweeks) - _TOC;
|
---|
[2221] | 365 | xc[3] = -_tau + _gamma * dtClk;
|
---|
| 366 | }
|
---|
| 367 |
|
---|
| 368 | // IOD of Glonass Ephemeris (virtual)
|
---|
| 369 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 370 | int t_ephGlo::IOD() const {
|
---|
[4018] | 371 | bncTime tMoscow = _TOC - _gps_utc + 3 * 3600.0;
|
---|
[3538] | 372 | return int(tMoscow.daysec() / 900);
|
---|
[2221] | 373 | }
|
---|
| 374 |
|
---|
| 375 | // Set Glonass Ephemeris
|
---|
| 376 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5133] | 377 | void t_ephGlo::set(const glonassephemeris* ee) {
|
---|
[2221] | 378 |
|
---|
[4097] | 379 | _receptDateTime = currentDateAndTimeGPS();
|
---|
| 380 |
|
---|
[3255] | 381 | _prn = QString("R%1").arg(ee->almanac_number, 2, 10, QChar('0'));
|
---|
[2223] | 382 |
|
---|
[2234] | 383 | int ww = ee->GPSWeek;
|
---|
| 384 | int tow = ee->GPSTOW;
|
---|
[2257] | 385 | updatetime(&ww, &tow, ee->tb*1000, 0); // Moscow -> GPS
|
---|
[2223] | 386 |
|
---|
[3264] | 387 | // Check the day once more
|
---|
| 388 | // -----------------------
|
---|
[5133] | 389 | bool timeChanged = false;
|
---|
[3264] | 390 | {
|
---|
[3268] | 391 | const double secPerDay = 24 * 3600.0;
|
---|
| 392 | const double secPerWeek = 7 * secPerDay;
|
---|
[3266] | 393 | int ww_old = ww;
|
---|
| 394 | int tow_old = tow;
|
---|
[3264] | 395 | int currentWeek;
|
---|
| 396 | double currentSec;
|
---|
| 397 | currentGPSWeeks(currentWeek, currentSec);
|
---|
| 398 | bncTime currentTime(currentWeek, currentSec);
|
---|
| 399 | bncTime hTime(ww, (double) tow);
|
---|
| 400 |
|
---|
[3268] | 401 | if (hTime - currentTime > secPerDay/2.0) {
|
---|
[4904] | 402 | timeChanged = true;
|
---|
[4543] | 403 | tow -= int(secPerDay);
|
---|
[3268] | 404 | if (tow < 0) {
|
---|
[4543] | 405 | tow += int(secPerWeek);
|
---|
[3268] | 406 | ww -= 1;
|
---|
| 407 | }
|
---|
[3264] | 408 | }
|
---|
[3268] | 409 | else if (hTime - currentTime < -secPerDay/2.0) {
|
---|
[4904] | 410 | timeChanged = true;
|
---|
[4543] | 411 | tow += int(secPerDay);
|
---|
[3268] | 412 | if (tow > secPerWeek) {
|
---|
[4543] | 413 | tow -= int(secPerWeek);
|
---|
[3268] | 414 | ww += 1;
|
---|
| 415 | }
|
---|
[3264] | 416 | }
|
---|
| 417 |
|
---|
[5119] | 418 | if (false && timeChanged && BNC_CORE->mode() == t_bncCore::batchPostProcessing) {
|
---|
[3265] | 419 | bncTime newHTime(ww, (double) tow);
|
---|
[3269] | 420 | cout << "GLONASS " << ee->almanac_number << " Time Changed at "
|
---|
[3266] | 421 | << currentTime.datestr() << " " << currentTime.timestr()
|
---|
| 422 | << endl
|
---|
[3268] | 423 | << "old: " << hTime.datestr() << " " << hTime.timestr()
|
---|
[3266] | 424 | << endl
|
---|
| 425 | << "new: " << newHTime.datestr() << " " << newHTime.timestr()
|
---|
| 426 | << endl
|
---|
| 427 | << "eph: " << ee->GPSWeek << " " << ee->GPSTOW << " " << ee->tb
|
---|
| 428 | << endl
|
---|
| 429 | << "ww, tow (old): " << ww_old << " " << tow_old
|
---|
| 430 | << endl
|
---|
| 431 | << "ww, tow (new): " << ww << " " << tow
|
---|
[3267] | 432 | << endl << endl;
|
---|
[3264] | 433 | }
|
---|
| 434 | }
|
---|
| 435 |
|
---|
[3263] | 436 | bncTime hlpTime(ww, (double) tow);
|
---|
[3255] | 437 | unsigned year, month, day;
|
---|
| 438 | hlpTime.civil_date(year, month, day);
|
---|
| 439 | _gps_utc = gnumleap(year, month, day);
|
---|
| 440 |
|
---|
[4018] | 441 | _TOC.set(ww, tow);
|
---|
[2223] | 442 | _E = ee->E;
|
---|
| 443 | _tau = ee->tau;
|
---|
| 444 | _gamma = ee->gamma;
|
---|
| 445 | _x_pos = ee->x_pos;
|
---|
| 446 | _x_velocity = ee->x_velocity;
|
---|
| 447 | _x_acceleration = ee->x_acceleration;
|
---|
| 448 | _y_pos = ee->y_pos;
|
---|
| 449 | _y_velocity = ee->y_velocity;
|
---|
| 450 | _y_acceleration = ee->y_acceleration;
|
---|
| 451 | _z_pos = ee->z_pos;
|
---|
| 452 | _z_velocity = ee->z_velocity;
|
---|
| 453 | _z_acceleration = ee->z_acceleration;
|
---|
| 454 | _health = 0;
|
---|
| 455 | _frequency_number = ee->frequency_number;
|
---|
[2257] | 456 | _tki = ee->tk-3*60*60; if (_tki < 0) _tki += 86400;
|
---|
[2223] | 457 |
|
---|
| 458 | // Initialize status vector
|
---|
| 459 | // ------------------------
|
---|
[4018] | 460 | _tt = _TOC;
|
---|
[2223] | 461 |
|
---|
| 462 | _xv(1) = _x_pos * 1.e3;
|
---|
| 463 | _xv(2) = _y_pos * 1.e3;
|
---|
| 464 | _xv(3) = _z_pos * 1.e3;
|
---|
| 465 | _xv(4) = _x_velocity * 1.e3;
|
---|
| 466 | _xv(5) = _y_velocity * 1.e3;
|
---|
| 467 | _xv(6) = _z_velocity * 1.e3;
|
---|
[3659] | 468 |
|
---|
| 469 | _ok = true;
|
---|
[2221] | 470 | }
|
---|
[2771] | 471 |
|
---|
[3255] | 472 | // build up RTCM3 for GLONASS
|
---|
| 473 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4018] | 474 | #define GLONASSTOINT(type, value) static_cast<type>(round(value))
|
---|
[3255] | 475 |
|
---|
| 476 | #define GLONASSADDBITS(a, b) {bitbuffer = (bitbuffer<<(a)) \
|
---|
| 477 | |(GLONASSTOINT(long long,b)&((1ULL<<(a))-1)); \
|
---|
| 478 | numbits += (a); \
|
---|
| 479 | while(numbits >= 8) { \
|
---|
| 480 | buffer[size++] = bitbuffer>>(numbits-8);numbits -= 8;}}
|
---|
| 481 | #define GLONASSADDBITSFLOATM(a,b,c) {int s; long long i; \
|
---|
| 482 | if(b < 0.0) \
|
---|
| 483 | { \
|
---|
| 484 | s = 1; \
|
---|
| 485 | i = GLONASSTOINT(long long,(-b)/(c)); \
|
---|
| 486 | if(!i) s = 0; \
|
---|
| 487 | } \
|
---|
| 488 | else \
|
---|
| 489 | { \
|
---|
| 490 | s = 0; \
|
---|
| 491 | i = GLONASSTOINT(long long,(b)/(c)); \
|
---|
| 492 | } \
|
---|
| 493 | GLONASSADDBITS(1,s) \
|
---|
| 494 | GLONASSADDBITS(a-1,i)}
|
---|
| 495 |
|
---|
| 496 | int t_ephGlo::RTCM3(unsigned char *buffer)
|
---|
| 497 | {
|
---|
| 498 |
|
---|
| 499 | int size = 0;
|
---|
| 500 | int numbits = 0;
|
---|
| 501 | long long bitbuffer = 0;
|
---|
| 502 | unsigned char *startbuffer = buffer;
|
---|
| 503 | buffer= buffer+3;
|
---|
| 504 |
|
---|
| 505 | GLONASSADDBITS(12, 1020)
|
---|
| 506 | GLONASSADDBITS(6, _prn.right((_prn.length()-1)).toInt())
|
---|
| 507 | GLONASSADDBITS(5, 7+_frequency_number)
|
---|
| 508 | GLONASSADDBITS(1, 0)
|
---|
| 509 | GLONASSADDBITS(1, 0)
|
---|
| 510 | GLONASSADDBITS(2, 0)
|
---|
| 511 | _tki=_tki+3*60*60;
|
---|
| 512 | GLONASSADDBITS(5, static_cast<int>(_tki)/(60*60))
|
---|
| 513 | GLONASSADDBITS(6, (static_cast<int>(_tki)/60)%60)
|
---|
| 514 | GLONASSADDBITS(1, (static_cast<int>(_tki)/30)%30)
|
---|
| 515 | GLONASSADDBITS(1, _health)
|
---|
| 516 | GLONASSADDBITS(1, 0)
|
---|
[4018] | 517 | unsigned long long timeofday = (static_cast<int>(_tt.gpssec()+3*60*60-_gps_utc)%86400);
|
---|
[3255] | 518 | GLONASSADDBITS(7, timeofday/60/15)
|
---|
| 519 | GLONASSADDBITSFLOATM(24, _x_velocity*1000, 1000.0/static_cast<double>(1<<20))
|
---|
| 520 | GLONASSADDBITSFLOATM(27, _x_pos*1000, 1000.0/static_cast<double>(1<<11))
|
---|
| 521 | GLONASSADDBITSFLOATM(5, _x_acceleration*1000, 1000.0/static_cast<double>(1<<30))
|
---|
| 522 | GLONASSADDBITSFLOATM(24, _y_velocity*1000, 1000.0/static_cast<double>(1<<20))
|
---|
| 523 | GLONASSADDBITSFLOATM(27, _y_pos*1000, 1000.0/static_cast<double>(1<<11))
|
---|
| 524 | GLONASSADDBITSFLOATM(5, _y_acceleration*1000, 1000.0/static_cast<double>(1<<30))
|
---|
| 525 | GLONASSADDBITSFLOATM(24, _z_velocity*1000, 1000.0/static_cast<double>(1<<20))
|
---|
| 526 | GLONASSADDBITSFLOATM(27,_z_pos*1000, 1000.0/static_cast<double>(1<<11))
|
---|
| 527 | GLONASSADDBITSFLOATM(5, _z_acceleration*1000, 1000.0/static_cast<double>(1<<30))
|
---|
| 528 | GLONASSADDBITS(1, 0)
|
---|
| 529 | GLONASSADDBITSFLOATM(11, _gamma, 1.0/static_cast<double>(1<<30)
|
---|
| 530 | /static_cast<double>(1<<10))
|
---|
| 531 | GLONASSADDBITS(2, 0) /* GLONASS-M P */
|
---|
| 532 | GLONASSADDBITS(1, 0) /* GLONASS-M ln(3) */
|
---|
| 533 | GLONASSADDBITSFLOATM(22, _tau, 1.0/static_cast<double>(1<<30))
|
---|
| 534 | GLONASSADDBITS(5, 0) /* GLONASS-M delta tau */
|
---|
| 535 | GLONASSADDBITS(5, _E)
|
---|
| 536 | GLONASSADDBITS(1, 0) /* GLONASS-M P4 */
|
---|
| 537 | GLONASSADDBITS(4, 0) /* GLONASS-M FT */
|
---|
| 538 | GLONASSADDBITS(11, 0) /* GLONASS-M NT */
|
---|
| 539 | GLONASSADDBITS(2, 0) /* GLONASS-M active? */
|
---|
| 540 | GLONASSADDBITS(1, 0) /* GLONASS additional data */
|
---|
| 541 | GLONASSADDBITS(11, 0) /* GLONASS NA */
|
---|
| 542 | GLONASSADDBITS(32, 0) /* GLONASS tau C */
|
---|
| 543 | GLONASSADDBITS(5, 0) /* GLONASS-M N4 */
|
---|
| 544 | GLONASSADDBITS(22, 0) /* GLONASS-M tau GPS */
|
---|
| 545 | GLONASSADDBITS(1, 0) /* GLONASS-M ln(5) */
|
---|
| 546 | GLONASSADDBITS(7, 0) /* Reserved */
|
---|
| 547 |
|
---|
| 548 | startbuffer[0]=0xD3;
|
---|
| 549 | startbuffer[1]=(size >> 8);
|
---|
| 550 | startbuffer[2]=size;
|
---|
| 551 | unsigned long i = CRC24(size+3, startbuffer);
|
---|
| 552 | buffer[size++] = i >> 16;
|
---|
| 553 | buffer[size++] = i >> 8;
|
---|
| 554 | buffer[size++] = i;
|
---|
| 555 | size += 3;
|
---|
| 556 | return size;
|
---|
| 557 | }
|
---|
| 558 |
|
---|
[2771] | 559 | // Set Galileo Satellite Position
|
---|
| 560 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 561 | void t_ephGal::set(const galileoephemeris* ee) {
|
---|
| 562 |
|
---|
[4097] | 563 | _receptDateTime = currentDateAndTimeGPS();
|
---|
| 564 |
|
---|
[3255] | 565 | _prn = QString("E%1").arg(ee->satellite, 2, 10, QChar('0'));
|
---|
[2771] | 566 |
|
---|
[4018] | 567 | _TOC.set(ee->Week, ee->TOC);
|
---|
[3734] | 568 | _clock_bias = ee->clock_bias;
|
---|
| 569 | _clock_drift = ee->clock_drift;
|
---|
[2771] | 570 | _clock_driftrate = ee->clock_driftrate;
|
---|
| 571 |
|
---|
[4018] | 572 | _IODnav = ee->IODnav;
|
---|
[2771] | 573 | _Crs = ee->Crs;
|
---|
| 574 | _Delta_n = ee->Delta_n;
|
---|
| 575 | _M0 = ee->M0;
|
---|
[4018] | 576 |
|
---|
[2771] | 577 | _Cuc = ee->Cuc;
|
---|
| 578 | _e = ee->e;
|
---|
| 579 | _Cus = ee->Cus;
|
---|
| 580 | _sqrt_A = ee->sqrt_A;
|
---|
[4018] | 581 |
|
---|
[5137] | 582 | _TOEsec = _TOC.gpssec();
|
---|
| 583 | //// _TOEsec = ee->TOE; //// TODO:
|
---|
[2771] | 584 | _Cic = ee->Cic;
|
---|
| 585 | _OMEGA0 = ee->OMEGA0;
|
---|
| 586 | _Cis = ee->Cis;
|
---|
[4018] | 587 |
|
---|
[2771] | 588 | _i0 = ee->i0;
|
---|
| 589 | _Crc = ee->Crc;
|
---|
| 590 | _omega = ee->omega;
|
---|
| 591 | _OMEGADOT = ee->OMEGADOT;
|
---|
[4018] | 592 |
|
---|
[2771] | 593 | _IDOT = ee->IDOT;
|
---|
[4018] | 594 | _TOEweek = ee->Week;
|
---|
| 595 |
|
---|
[3734] | 596 | _SISA = ee->SISA;
|
---|
[4018] | 597 | _E5aHS = ee->E5aHS;
|
---|
[5541] | 598 | _E5bHS = ee->E5bHS;
|
---|
[3734] | 599 | _BGD_1_5A = ee->BGD_1_5A;
|
---|
| 600 | _BGD_1_5B = ee->BGD_1_5B;
|
---|
[3659] | 601 |
|
---|
[4018] | 602 | _TOT = 0.9999e9;
|
---|
| 603 |
|
---|
[5539] | 604 | _flags = ee->flags;
|
---|
| 605 |
|
---|
[3659] | 606 | _ok = true;
|
---|
[2771] | 607 | }
|
---|
| 608 |
|
---|
| 609 | // Compute Galileo Satellite Position (virtual)
|
---|
| 610 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 611 | void t_ephGal::position(int GPSweek, double GPSweeks,
|
---|
[4018] | 612 | double* xc,
|
---|
| 613 | double* vv) const {
|
---|
[2771] | 614 |
|
---|
| 615 | static const double omegaEarth = 7292115.1467e-11;
|
---|
[5277] | 616 | static const double gmWGS = 398.60044e12;
|
---|
[2771] | 617 |
|
---|
| 618 | memset(xc, 0, 4*sizeof(double));
|
---|
| 619 | memset(vv, 0, 3*sizeof(double));
|
---|
| 620 |
|
---|
| 621 | double a0 = _sqrt_A * _sqrt_A;
|
---|
| 622 | if (a0 == 0) {
|
---|
| 623 | return;
|
---|
| 624 | }
|
---|
| 625 |
|
---|
| 626 | double n0 = sqrt(gmWGS/(a0*a0*a0));
|
---|
[4018] | 627 |
|
---|
| 628 | bncTime tt(GPSweek, GPSweeks);
|
---|
| 629 | double tk = tt - bncTime(_TOC.gpsw(), _TOEsec);
|
---|
| 630 |
|
---|
[2771] | 631 | double n = n0 + _Delta_n;
|
---|
| 632 | double M = _M0 + n*tk;
|
---|
| 633 | double E = M;
|
---|
| 634 | double E_last;
|
---|
| 635 | do {
|
---|
| 636 | E_last = E;
|
---|
| 637 | E = M + _e*sin(E);
|
---|
| 638 | } while ( fabs(E-E_last)*a0 > 0.001 );
|
---|
| 639 | double v = 2.0*atan( sqrt( (1.0 + _e)/(1.0 - _e) )*tan( E/2 ) );
|
---|
| 640 | double u0 = v + _omega;
|
---|
| 641 | double sin2u0 = sin(2*u0);
|
---|
| 642 | double cos2u0 = cos(2*u0);
|
---|
| 643 | double r = a0*(1 - _e*cos(E)) + _Crc*cos2u0 + _Crs*sin2u0;
|
---|
| 644 | double i = _i0 + _IDOT*tk + _Cic*cos2u0 + _Cis*sin2u0;
|
---|
| 645 | double u = u0 + _Cuc*cos2u0 + _Cus*sin2u0;
|
---|
| 646 | double xp = r*cos(u);
|
---|
| 647 | double yp = r*sin(u);
|
---|
| 648 | double OM = _OMEGA0 + (_OMEGADOT - omegaEarth)*tk -
|
---|
[4018] | 649 | omegaEarth*_TOEsec;
|
---|
[2771] | 650 |
|
---|
| 651 | double sinom = sin(OM);
|
---|
| 652 | double cosom = cos(OM);
|
---|
| 653 | double sini = sin(i);
|
---|
| 654 | double cosi = cos(i);
|
---|
| 655 | xc[0] = xp*cosom - yp*cosi*sinom;
|
---|
| 656 | xc[1] = xp*sinom + yp*cosi*cosom;
|
---|
| 657 | xc[2] = yp*sini;
|
---|
| 658 |
|
---|
[4018] | 659 | double tc = tt - _TOC;
|
---|
[2771] | 660 | xc[3] = _clock_bias + _clock_drift*tc + _clock_driftrate*tc*tc;
|
---|
| 661 |
|
---|
| 662 | // Velocity
|
---|
| 663 | // --------
|
---|
| 664 | double tanv2 = tan(v/2);
|
---|
| 665 | double dEdM = 1 / (1 - _e*cos(E));
|
---|
| 666 | double dotv = sqrt((1.0 + _e)/(1.0 - _e)) / cos(E/2)/cos(E/2) / (1 + tanv2*tanv2)
|
---|
| 667 | * dEdM * n;
|
---|
| 668 | double dotu = dotv + (-_Cuc*sin2u0 + _Cus*cos2u0)*2*dotv;
|
---|
| 669 | double dotom = _OMEGADOT - omegaEarth;
|
---|
| 670 | double doti = _IDOT + (-_Cic*sin2u0 + _Cis*cos2u0)*2*dotv;
|
---|
| 671 | double dotr = a0 * _e*sin(E) * dEdM * n
|
---|
| 672 | + (-_Crc*sin2u0 + _Crs*cos2u0)*2*dotv;
|
---|
| 673 | double dotx = dotr*cos(u) - r*sin(u)*dotu;
|
---|
| 674 | double doty = dotr*sin(u) + r*cos(u)*dotu;
|
---|
| 675 |
|
---|
| 676 | vv[0] = cosom *dotx - cosi*sinom *doty // dX / dr
|
---|
| 677 | - xp*sinom*dotom - yp*cosi*cosom*dotom // dX / dOMEGA
|
---|
| 678 | + yp*sini*sinom*doti; // dX / di
|
---|
| 679 |
|
---|
| 680 | vv[1] = sinom *dotx + cosi*cosom *doty
|
---|
| 681 | + xp*cosom*dotom - yp*cosi*sinom*dotom
|
---|
| 682 | - yp*sini*cosom*doti;
|
---|
| 683 |
|
---|
| 684 | vv[2] = sini *doty + yp*cosi *doti;
|
---|
| 685 |
|
---|
| 686 | // Relativistic Correction
|
---|
| 687 | // -----------------------
|
---|
| 688 | // xc(4) -= 4.442807633e-10 * _e * sqrt(a0) *sin(E);
|
---|
| 689 | xc[3] -= 2.0 * (xc[0]*vv[0] + xc[1]*vv[1] + xc[2]*vv[2]) / t_CST::c / t_CST::c;
|
---|
| 690 | }
|
---|
| 691 |
|
---|
[3255] | 692 | // build up RTCM3 for Galileo
|
---|
| 693 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4018] | 694 | #define GALILEOTOINT(type, value) static_cast<type>(round(value))
|
---|
[3279] | 695 |
|
---|
| 696 | #define GALILEOADDBITS(a, b) {bitbuffer = (bitbuffer<<(a)) \
|
---|
| 697 | |(GALILEOTOINT(long long,b)&((1LL<<a)-1)); \
|
---|
| 698 | numbits += (a); \
|
---|
| 699 | while(numbits >= 8) { \
|
---|
| 700 | buffer[size++] = bitbuffer>>(numbits-8);numbits -= 8;}}
|
---|
| 701 | #define GALILEOADDBITSFLOAT(a,b,c) {long long i = GALILEOTOINT(long long,(b)/(c)); \
|
---|
| 702 | GALILEOADDBITS(a,i)};
|
---|
| 703 |
|
---|
[3255] | 704 | int t_ephGal::RTCM3(unsigned char *buffer) {
|
---|
[3279] | 705 | int size = 0;
|
---|
| 706 | int numbits = 0;
|
---|
| 707 | long long bitbuffer = 0;
|
---|
| 708 | unsigned char *startbuffer = buffer;
|
---|
| 709 | buffer= buffer+3;
|
---|
[3255] | 710 |
|
---|
[5541] | 711 | bool inav = ( (_flags & GALEPHF_INAV) == GALEPHF_INAV );
|
---|
| 712 |
|
---|
| 713 | GALILEOADDBITS(12, inav ? 1046 : 1045)
|
---|
[3279] | 714 | GALILEOADDBITS(6, _prn.right((_prn.length()-1)).toInt())
|
---|
[4018] | 715 | GALILEOADDBITS(12, _TOC.gpsw())
|
---|
[3279] | 716 | GALILEOADDBITS(10, _IODnav)
|
---|
| 717 | GALILEOADDBITS(8, _SISA)
|
---|
[4018] | 718 | GALILEOADDBITSFLOAT(14, _IDOT, M_PI/static_cast<double>(1<<30)
|
---|
[3279] | 719 | /static_cast<double>(1<<13))
|
---|
[4018] | 720 | GALILEOADDBITS(14, _TOC.gpssec()/60)
|
---|
[3279] | 721 | GALILEOADDBITSFLOAT(6, _clock_driftrate, 1.0/static_cast<double>(1<<30)
|
---|
| 722 | /static_cast<double>(1<<29))
|
---|
| 723 | GALILEOADDBITSFLOAT(21, _clock_drift, 1.0/static_cast<double>(1<<30)
|
---|
| 724 | /static_cast<double>(1<<16))
|
---|
| 725 | GALILEOADDBITSFLOAT(31, _clock_bias, 1.0/static_cast<double>(1<<30)
|
---|
| 726 | /static_cast<double>(1<<4))
|
---|
| 727 | GALILEOADDBITSFLOAT(16, _Crs, 1.0/static_cast<double>(1<<5))
|
---|
[4018] | 728 | GALILEOADDBITSFLOAT(16, _Delta_n, M_PI/static_cast<double>(1<<30)
|
---|
[3279] | 729 | /static_cast<double>(1<<13))
|
---|
[4018] | 730 | GALILEOADDBITSFLOAT(32, _M0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
[3279] | 731 | GALILEOADDBITSFLOAT(16, _Cuc, 1.0/static_cast<double>(1<<29))
|
---|
| 732 | GALILEOADDBITSFLOAT(32, _e, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<3))
|
---|
| 733 | GALILEOADDBITSFLOAT(16, _Cus, 1.0/static_cast<double>(1<<29))
|
---|
| 734 | GALILEOADDBITSFLOAT(32, _sqrt_A, 1.0/static_cast<double>(1<<19))
|
---|
[4018] | 735 | GALILEOADDBITS(14, _TOEsec/60)
|
---|
[3279] | 736 | GALILEOADDBITSFLOAT(16, _Cic, 1.0/static_cast<double>(1<<29))
|
---|
[4018] | 737 | GALILEOADDBITSFLOAT(32, _OMEGA0, M_PI/static_cast<double>(1<<30)
|
---|
[3279] | 738 | /static_cast<double>(1<<1))
|
---|
| 739 | GALILEOADDBITSFLOAT(16, _Cis, 1.0/static_cast<double>(1<<29))
|
---|
[4018] | 740 | GALILEOADDBITSFLOAT(32, _i0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
[3279] | 741 | GALILEOADDBITSFLOAT(16, _Crc, 1.0/static_cast<double>(1<<5))
|
---|
[4018] | 742 | GALILEOADDBITSFLOAT(32, _omega, M_PI/static_cast<double>(1<<30)
|
---|
[3279] | 743 | /static_cast<double>(1<<1))
|
---|
[4018] | 744 | GALILEOADDBITSFLOAT(24, _OMEGADOT, M_PI/static_cast<double>(1<<30)
|
---|
[3279] | 745 | /static_cast<double>(1<<13))
|
---|
| 746 | GALILEOADDBITSFLOAT(10, _BGD_1_5A, 1.0/static_cast<double>(1<<30)
|
---|
| 747 | /static_cast<double>(1<<2))
|
---|
[5541] | 748 | if(inav)
|
---|
[3279] | 749 | {
|
---|
| 750 | GALILEOADDBITSFLOAT(10, _BGD_1_5B, 1.0/static_cast<double>(1<<30)
|
---|
| 751 | /static_cast<double>(1<<2))
|
---|
[5541] | 752 | GALILEOADDBITS(2, static_cast<int>(_E5bHS))
|
---|
| 753 | GALILEOADDBITS(1, _flags & GALEPHF_E5BDINVALID)
|
---|
[3279] | 754 | }
|
---|
[5541] | 755 | else
|
---|
[3279] | 756 | {
|
---|
[5541] | 757 | GALILEOADDBITS(2, static_cast<int>(_E5aHS))
|
---|
| 758 | GALILEOADDBITS(1, _flags & GALEPHF_E5ADINVALID)
|
---|
[3279] | 759 | }
|
---|
[4018] | 760 | _TOEsec = 0.9999E9;
|
---|
| 761 | GALILEOADDBITS(20, _TOEsec)
|
---|
[3279] | 762 |
|
---|
[5541] | 763 | GALILEOADDBITS(inav ? 1 : 3, 0)
|
---|
[3279] | 764 |
|
---|
| 765 | startbuffer[0]=0xD3;
|
---|
| 766 | startbuffer[1]=(size >> 8);
|
---|
| 767 | startbuffer[2]=size;
|
---|
| 768 | unsigned long i = CRC24(size+3, startbuffer);
|
---|
| 769 | buffer[size++] = i >> 16;
|
---|
| 770 | buffer[size++] = i >> 8;
|
---|
| 771 | buffer[size++] = i;
|
---|
| 772 | size += 3;
|
---|
| 773 | return size;
|
---|
[3255] | 774 | }
|
---|
[3659] | 775 |
|
---|
| 776 | // Constructor
|
---|
| 777 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 778 | t_ephGPS::t_ephGPS(float rnxVersion, const QStringList& lines) {
|
---|
[3664] | 779 |
|
---|
[3699] | 780 | const int nLines = 8;
|
---|
| 781 |
|
---|
[3665] | 782 | _ok = false;
|
---|
| 783 |
|
---|
[3699] | 784 | if (lines.size() != nLines) {
|
---|
[3660] | 785 | return;
|
---|
| 786 | }
|
---|
[3664] | 787 |
|
---|
[3668] | 788 | // RINEX Format
|
---|
| 789 | // ------------
|
---|
| 790 | int fieldLen = 19;
|
---|
| 791 |
|
---|
[3666] | 792 | int pos[4];
|
---|
| 793 | pos[0] = (rnxVersion <= 2.12) ? 3 : 4;
|
---|
[3668] | 794 | pos[1] = pos[0] + fieldLen;
|
---|
| 795 | pos[2] = pos[1] + fieldLen;
|
---|
| 796 | pos[3] = pos[2] + fieldLen;
|
---|
[3664] | 797 |
|
---|
| 798 | // Read eight lines
|
---|
| 799 | // ----------------
|
---|
[3699] | 800 | for (int iLine = 0; iLine < nLines; iLine++) {
|
---|
[3664] | 801 | QString line = lines[iLine];
|
---|
| 802 |
|
---|
| 803 | if ( iLine == 0 ) {
|
---|
[3666] | 804 | QTextStream in(line.left(pos[1]).toAscii());
|
---|
| 805 |
|
---|
| 806 | int year, month, day, hour, min;
|
---|
| 807 | double sec;
|
---|
| 808 |
|
---|
| 809 | in >> _prn >> year >> month >> day >> hour >> min >> sec;
|
---|
| 810 |
|
---|
| 811 | if (_prn.at(0) != 'G') {
|
---|
[3667] | 812 | _prn = QString("G%1").arg(_prn.toInt(), 2, 10, QLatin1Char('0'));
|
---|
[3664] | 813 | }
|
---|
[3667] | 814 |
|
---|
[3666] | 815 | if (year < 80) {
|
---|
| 816 | year += 2000;
|
---|
[3664] | 817 | }
|
---|
[3666] | 818 | else if (year < 100) {
|
---|
| 819 | year += 1900;
|
---|
| 820 | }
|
---|
| 821 |
|
---|
[4018] | 822 | _TOC.set(year, month, day, hour, min, sec);
|
---|
[3666] | 823 |
|
---|
| 824 | if ( readDbl(line, pos[1], fieldLen, _clock_bias ) ||
|
---|
| 825 | readDbl(line, pos[2], fieldLen, _clock_drift ) ||
|
---|
| 826 | readDbl(line, pos[3], fieldLen, _clock_driftrate) ) {
|
---|
| 827 | return;
|
---|
| 828 | }
|
---|
[3660] | 829 | }
|
---|
[3664] | 830 |
|
---|
| 831 | else if ( iLine == 1 ) {
|
---|
[3666] | 832 | if ( readDbl(line, pos[0], fieldLen, _IODE ) ||
|
---|
| 833 | readDbl(line, pos[1], fieldLen, _Crs ) ||
|
---|
| 834 | readDbl(line, pos[2], fieldLen, _Delta_n) ||
|
---|
| 835 | readDbl(line, pos[3], fieldLen, _M0 ) ) {
|
---|
[3664] | 836 | return;
|
---|
| 837 | }
|
---|
| 838 | }
|
---|
| 839 |
|
---|
| 840 | else if ( iLine == 2 ) {
|
---|
[3666] | 841 | if ( readDbl(line, pos[0], fieldLen, _Cuc ) ||
|
---|
| 842 | readDbl(line, pos[1], fieldLen, _e ) ||
|
---|
| 843 | readDbl(line, pos[2], fieldLen, _Cus ) ||
|
---|
| 844 | readDbl(line, pos[3], fieldLen, _sqrt_A) ) {
|
---|
[3664] | 845 | return;
|
---|
| 846 | }
|
---|
| 847 | }
|
---|
| 848 |
|
---|
| 849 | else if ( iLine == 3 ) {
|
---|
[4018] | 850 | if ( readDbl(line, pos[0], fieldLen, _TOEsec) ||
|
---|
[3666] | 851 | readDbl(line, pos[1], fieldLen, _Cic ) ||
|
---|
| 852 | readDbl(line, pos[2], fieldLen, _OMEGA0) ||
|
---|
| 853 | readDbl(line, pos[3], fieldLen, _Cis ) ) {
|
---|
[3664] | 854 | return;
|
---|
| 855 | }
|
---|
| 856 | }
|
---|
| 857 |
|
---|
| 858 | else if ( iLine == 4 ) {
|
---|
[3666] | 859 | if ( readDbl(line, pos[0], fieldLen, _i0 ) ||
|
---|
| 860 | readDbl(line, pos[1], fieldLen, _Crc ) ||
|
---|
| 861 | readDbl(line, pos[2], fieldLen, _omega ) ||
|
---|
| 862 | readDbl(line, pos[3], fieldLen, _OMEGADOT) ) {
|
---|
[3664] | 863 | return;
|
---|
| 864 | }
|
---|
| 865 | }
|
---|
| 866 |
|
---|
| 867 | else if ( iLine == 5 ) {
|
---|
[4018] | 868 | if ( readDbl(line, pos[0], fieldLen, _IDOT ) ||
|
---|
| 869 | readDbl(line, pos[1], fieldLen, _L2Codes) ||
|
---|
| 870 | readDbl(line, pos[2], fieldLen, _TOEweek ) ||
|
---|
| 871 | readDbl(line, pos[3], fieldLen, _L2PFlag) ) {
|
---|
[3664] | 872 | return;
|
---|
| 873 | }
|
---|
| 874 | }
|
---|
| 875 |
|
---|
| 876 | else if ( iLine == 6 ) {
|
---|
[4018] | 877 | if ( readDbl(line, pos[0], fieldLen, _ura ) ||
|
---|
[3666] | 878 | readDbl(line, pos[1], fieldLen, _health) ||
|
---|
| 879 | readDbl(line, pos[2], fieldLen, _TGD ) ||
|
---|
| 880 | readDbl(line, pos[3], fieldLen, _IODC ) ) {
|
---|
[3664] | 881 | return;
|
---|
| 882 | }
|
---|
| 883 | }
|
---|
| 884 |
|
---|
| 885 | else if ( iLine == 7 ) {
|
---|
[4224] | 886 | if ( readDbl(line, pos[0], fieldLen, _TOT) ) {
|
---|
[3664] | 887 | return;
|
---|
| 888 | }
|
---|
[4224] | 889 | readDbl(line, pos[1], fieldLen, _fitInterval); // _fitInterval optional
|
---|
[3664] | 890 | }
|
---|
[3660] | 891 | }
|
---|
[3661] | 892 |
|
---|
| 893 | _ok = true;
|
---|
[3659] | 894 | }
|
---|
| 895 |
|
---|
| 896 | // Constructor
|
---|
| 897 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 898 | t_ephGlo::t_ephGlo(float rnxVersion, const QStringList& lines) {
|
---|
| 899 |
|
---|
[3699] | 900 | const int nLines = 4;
|
---|
| 901 |
|
---|
[3659] | 902 | _ok = false;
|
---|
[3699] | 903 |
|
---|
| 904 | if (lines.size() != nLines) {
|
---|
| 905 | return;
|
---|
| 906 | }
|
---|
| 907 |
|
---|
| 908 | // RINEX Format
|
---|
| 909 | // ------------
|
---|
| 910 | int fieldLen = 19;
|
---|
| 911 |
|
---|
| 912 | int pos[4];
|
---|
| 913 | pos[0] = (rnxVersion <= 2.12) ? 3 : 4;
|
---|
| 914 | pos[1] = pos[0] + fieldLen;
|
---|
| 915 | pos[2] = pos[1] + fieldLen;
|
---|
| 916 | pos[3] = pos[2] + fieldLen;
|
---|
| 917 |
|
---|
| 918 | // Read four lines
|
---|
| 919 | // ---------------
|
---|
| 920 | for (int iLine = 0; iLine < nLines; iLine++) {
|
---|
| 921 | QString line = lines[iLine];
|
---|
| 922 |
|
---|
| 923 | if ( iLine == 0 ) {
|
---|
| 924 | QTextStream in(line.left(pos[1]).toAscii());
|
---|
| 925 |
|
---|
| 926 | int year, month, day, hour, min;
|
---|
| 927 | double sec;
|
---|
| 928 |
|
---|
| 929 | in >> _prn >> year >> month >> day >> hour >> min >> sec;
|
---|
| 930 |
|
---|
| 931 | if (_prn.at(0) != 'R') {
|
---|
| 932 | _prn = QString("R%1").arg(_prn.toInt(), 2, 10, QLatin1Char('0'));
|
---|
| 933 | }
|
---|
| 934 |
|
---|
| 935 | if (year < 80) {
|
---|
| 936 | year += 2000;
|
---|
| 937 | }
|
---|
| 938 | else if (year < 100) {
|
---|
| 939 | year += 1900;
|
---|
| 940 | }
|
---|
| 941 |
|
---|
[3760] | 942 | _gps_utc = gnumleap(year, month, day);
|
---|
| 943 |
|
---|
[4018] | 944 | _TOC.set(year, month, day, hour, min, sec);
|
---|
| 945 | _TOC = _TOC + _gps_utc;
|
---|
[3699] | 946 |
|
---|
[4018] | 947 | if ( readDbl(line, pos[1], fieldLen, _tau ) ||
|
---|
| 948 | readDbl(line, pos[2], fieldLen, _gamma) ||
|
---|
| 949 | readDbl(line, pos[3], fieldLen, _tki ) ) {
|
---|
[3699] | 950 | return;
|
---|
| 951 | }
|
---|
[3765] | 952 |
|
---|
| 953 | _tau = -_tau;
|
---|
[3699] | 954 | }
|
---|
| 955 |
|
---|
| 956 | else if ( iLine == 1 ) {
|
---|
| 957 | if ( readDbl(line, pos[0], fieldLen, _x_pos ) ||
|
---|
| 958 | readDbl(line, pos[1], fieldLen, _x_velocity ) ||
|
---|
| 959 | readDbl(line, pos[2], fieldLen, _x_acceleration) ||
|
---|
| 960 | readDbl(line, pos[3], fieldLen, _health ) ) {
|
---|
| 961 | return;
|
---|
| 962 | }
|
---|
| 963 | }
|
---|
| 964 |
|
---|
| 965 | else if ( iLine == 2 ) {
|
---|
| 966 | if ( readDbl(line, pos[0], fieldLen, _y_pos ) ||
|
---|
| 967 | readDbl(line, pos[1], fieldLen, _y_velocity ) ||
|
---|
| 968 | readDbl(line, pos[2], fieldLen, _y_acceleration ) ||
|
---|
| 969 | readDbl(line, pos[3], fieldLen, _frequency_number) ) {
|
---|
| 970 | return;
|
---|
| 971 | }
|
---|
| 972 | }
|
---|
| 973 |
|
---|
| 974 | else if ( iLine == 3 ) {
|
---|
| 975 | if ( readDbl(line, pos[0], fieldLen, _z_pos ) ||
|
---|
| 976 | readDbl(line, pos[1], fieldLen, _z_velocity ) ||
|
---|
| 977 | readDbl(line, pos[2], fieldLen, _z_acceleration) ||
|
---|
| 978 | readDbl(line, pos[3], fieldLen, _E ) ) {
|
---|
| 979 | return;
|
---|
| 980 | }
|
---|
| 981 | }
|
---|
| 982 | }
|
---|
| 983 |
|
---|
| 984 | // Initialize status vector
|
---|
| 985 | // ------------------------
|
---|
[4018] | 986 | _tt = _TOC;
|
---|
| 987 | _xv.ReSize(6);
|
---|
[3699] | 988 | _xv(1) = _x_pos * 1.e3;
|
---|
| 989 | _xv(2) = _y_pos * 1.e3;
|
---|
| 990 | _xv(3) = _z_pos * 1.e3;
|
---|
| 991 | _xv(4) = _x_velocity * 1.e3;
|
---|
| 992 | _xv(5) = _y_velocity * 1.e3;
|
---|
| 993 | _xv(6) = _z_velocity * 1.e3;
|
---|
| 994 |
|
---|
| 995 | _ok = true;
|
---|
[3659] | 996 | }
|
---|
| 997 |
|
---|
| 998 | // Constructor
|
---|
| 999 | //////////////////////////////////////////////////////////////////////////////
|
---|
[4891] | 1000 | t_ephGal::t_ephGal(float rnxVersion, const QStringList& lines) {
|
---|
[3659] | 1001 |
|
---|
[4891] | 1002 | const int nLines = 8;
|
---|
| 1003 |
|
---|
[3659] | 1004 | _ok = false;
|
---|
[4891] | 1005 |
|
---|
| 1006 | if (lines.size() != nLines) {
|
---|
| 1007 | return;
|
---|
| 1008 | }
|
---|
| 1009 |
|
---|
| 1010 | // RINEX Format
|
---|
| 1011 | // ------------
|
---|
| 1012 | int fieldLen = 19;
|
---|
| 1013 |
|
---|
| 1014 | int pos[4];
|
---|
| 1015 | pos[0] = (rnxVersion <= 2.12) ? 3 : 4;
|
---|
| 1016 | pos[1] = pos[0] + fieldLen;
|
---|
| 1017 | pos[2] = pos[1] + fieldLen;
|
---|
| 1018 | pos[3] = pos[2] + fieldLen;
|
---|
| 1019 |
|
---|
| 1020 | // Read eight lines
|
---|
| 1021 | // ----------------
|
---|
| 1022 | for (int iLine = 0; iLine < nLines; iLine++) {
|
---|
| 1023 | QString line = lines[iLine];
|
---|
| 1024 |
|
---|
| 1025 | if ( iLine == 0 ) {
|
---|
| 1026 | QTextStream in(line.left(pos[1]).toAscii());
|
---|
| 1027 |
|
---|
| 1028 | int year, month, day, hour, min;
|
---|
| 1029 | double sec;
|
---|
| 1030 |
|
---|
| 1031 | in >> _prn >> year >> month >> day >> hour >> min >> sec;
|
---|
| 1032 |
|
---|
| 1033 | if (_prn.at(0) != 'E') {
|
---|
| 1034 | _prn = QString("E%1").arg(_prn.toInt(), 2, 10, QLatin1Char('0'));
|
---|
| 1035 | }
|
---|
| 1036 |
|
---|
| 1037 | if (year < 80) {
|
---|
| 1038 | year += 2000;
|
---|
| 1039 | }
|
---|
| 1040 | else if (year < 100) {
|
---|
| 1041 | year += 1900;
|
---|
| 1042 | }
|
---|
| 1043 |
|
---|
| 1044 | _TOC.set(year, month, day, hour, min, sec);
|
---|
| 1045 |
|
---|
| 1046 | if ( readDbl(line, pos[1], fieldLen, _clock_bias ) ||
|
---|
| 1047 | readDbl(line, pos[2], fieldLen, _clock_drift ) ||
|
---|
| 1048 | readDbl(line, pos[3], fieldLen, _clock_driftrate) ) {
|
---|
| 1049 | return;
|
---|
| 1050 | }
|
---|
| 1051 | }
|
---|
| 1052 |
|
---|
| 1053 | else if ( iLine == 1 ) {
|
---|
| 1054 | if ( readDbl(line, pos[0], fieldLen, _IODnav ) ||
|
---|
| 1055 | readDbl(line, pos[1], fieldLen, _Crs ) ||
|
---|
| 1056 | readDbl(line, pos[2], fieldLen, _Delta_n) ||
|
---|
| 1057 | readDbl(line, pos[3], fieldLen, _M0 ) ) {
|
---|
| 1058 | return;
|
---|
| 1059 | }
|
---|
| 1060 | }
|
---|
| 1061 |
|
---|
| 1062 | else if ( iLine == 2 ) {
|
---|
| 1063 | if ( readDbl(line, pos[0], fieldLen, _Cuc ) ||
|
---|
| 1064 | readDbl(line, pos[1], fieldLen, _e ) ||
|
---|
| 1065 | readDbl(line, pos[2], fieldLen, _Cus ) ||
|
---|
| 1066 | readDbl(line, pos[3], fieldLen, _sqrt_A) ) {
|
---|
| 1067 | return;
|
---|
| 1068 | }
|
---|
| 1069 | }
|
---|
| 1070 |
|
---|
| 1071 | else if ( iLine == 3 ) {
|
---|
| 1072 | if ( readDbl(line, pos[0], fieldLen, _TOEsec) ||
|
---|
| 1073 | readDbl(line, pos[1], fieldLen, _Cic ) ||
|
---|
| 1074 | readDbl(line, pos[2], fieldLen, _OMEGA0) ||
|
---|
| 1075 | readDbl(line, pos[3], fieldLen, _Cis ) ) {
|
---|
| 1076 | return;
|
---|
| 1077 | }
|
---|
| 1078 | }
|
---|
| 1079 |
|
---|
| 1080 | else if ( iLine == 4 ) {
|
---|
| 1081 | if ( readDbl(line, pos[0], fieldLen, _i0 ) ||
|
---|
| 1082 | readDbl(line, pos[1], fieldLen, _Crc ) ||
|
---|
| 1083 | readDbl(line, pos[2], fieldLen, _omega ) ||
|
---|
| 1084 | readDbl(line, pos[3], fieldLen, _OMEGADOT) ) {
|
---|
| 1085 | return;
|
---|
| 1086 | }
|
---|
| 1087 | }
|
---|
| 1088 |
|
---|
| 1089 | else if ( iLine == 5 ) {
|
---|
| 1090 | if ( readDbl(line, pos[0], fieldLen, _IDOT ) ||
|
---|
| 1091 | readDbl(line, pos[2], fieldLen, _TOEweek) ) {
|
---|
| 1092 | return;
|
---|
| 1093 | }
|
---|
| 1094 | }
|
---|
| 1095 |
|
---|
| 1096 | else if ( iLine == 6 ) {
|
---|
| 1097 | if ( readDbl(line, pos[0], fieldLen, _SISA ) ||
|
---|
| 1098 | readDbl(line, pos[1], fieldLen, _E5aHS ) ||
|
---|
| 1099 | readDbl(line, pos[2], fieldLen, _BGD_1_5A) ||
|
---|
| 1100 | readDbl(line, pos[3], fieldLen, _BGD_1_5B) ) {
|
---|
| 1101 | return;
|
---|
| 1102 | }
|
---|
| 1103 | }
|
---|
| 1104 |
|
---|
| 1105 | else if ( iLine == 7 ) {
|
---|
| 1106 | if ( readDbl(line, pos[0], fieldLen, _TOT) ) {
|
---|
| 1107 | return;
|
---|
| 1108 | }
|
---|
| 1109 | }
|
---|
| 1110 | }
|
---|
| 1111 |
|
---|
| 1112 | _ok = true;
|
---|
[3659] | 1113 | }
|
---|
[4013] | 1114 |
|
---|
[4021] | 1115 | //
|
---|
[4013] | 1116 | //////////////////////////////////////////////////////////////////////////////
|
---|
[4029] | 1117 | QString t_eph::rinexDateStr(const bncTime& tt, const QString& prn,
|
---|
| 1118 | double version) {
|
---|
[4013] | 1119 |
|
---|
[4021] | 1120 | QString datStr;
|
---|
[4013] | 1121 |
|
---|
| 1122 | unsigned year, month, day, hour, min;
|
---|
[4018] | 1123 | double sec;
|
---|
[4029] | 1124 | tt.civil_date(year, month, day);
|
---|
| 1125 | tt.civil_time(hour, min, sec);
|
---|
[4013] | 1126 |
|
---|
[4021] | 1127 | QTextStream out(&datStr);
|
---|
[4013] | 1128 |
|
---|
| 1129 | if (version < 3.0) {
|
---|
[4029] | 1130 | QString prnHlp = prn.mid(1,2); if (prnHlp[0] == '0') prnHlp[0] = ' ';
|
---|
[4017] | 1131 | out << prnHlp << QString(" %1 %2 %3 %4 %5%6")
|
---|
[4013] | 1132 | .arg(year % 100, 2, 10, QChar('0'))
|
---|
| 1133 | .arg(month, 2)
|
---|
| 1134 | .arg(day, 2)
|
---|
| 1135 | .arg(hour, 2)
|
---|
| 1136 | .arg(min, 2)
|
---|
[4016] | 1137 | .arg(sec, 5, 'f',1);
|
---|
[4013] | 1138 | }
|
---|
| 1139 | else {
|
---|
[4029] | 1140 | out << prn << QString(" %1 %2 %3 %4 %5 %6")
|
---|
[4013] | 1141 | .arg(year, 4)
|
---|
| 1142 | .arg(month, 2, 10, QChar('0'))
|
---|
| 1143 | .arg(day, 2, 10, QChar('0'))
|
---|
| 1144 | .arg(hour, 2, 10, QChar('0'))
|
---|
| 1145 | .arg(min, 2, 10, QChar('0'))
|
---|
| 1146 | .arg(int(sec), 2, 10, QChar('0'));
|
---|
| 1147 | }
|
---|
[4021] | 1148 |
|
---|
| 1149 | return datStr;
|
---|
| 1150 | }
|
---|
| 1151 |
|
---|
| 1152 | // RINEX Format String
|
---|
| 1153 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 1154 | QString t_ephGPS::toString(double version) const {
|
---|
| 1155 |
|
---|
[4029] | 1156 | QString rnxStr = rinexDateStr(_TOC, _prn, version);
|
---|
[4013] | 1157 |
|
---|
[4021] | 1158 | QTextStream out(&rnxStr);
|
---|
| 1159 |
|
---|
[4013] | 1160 | out << QString("%1%2%3\n")
|
---|
| 1161 | .arg(_clock_bias, 19, 'e', 12)
|
---|
| 1162 | .arg(_clock_drift, 19, 'e', 12)
|
---|
| 1163 | .arg(_clock_driftrate, 19, 'e', 12);
|
---|
| 1164 |
|
---|
[4015] | 1165 | QString fmt = version < 3.0 ? " %1%2%3%4\n" : " %1%2%3%4\n";
|
---|
| 1166 |
|
---|
| 1167 | out << QString(fmt)
|
---|
[4013] | 1168 | .arg(_IODE, 19, 'e', 12)
|
---|
| 1169 | .arg(_Crs, 19, 'e', 12)
|
---|
| 1170 | .arg(_Delta_n, 19, 'e', 12)
|
---|
| 1171 | .arg(_M0, 19, 'e', 12);
|
---|
| 1172 |
|
---|
[4015] | 1173 | out << QString(fmt)
|
---|
[4013] | 1174 | .arg(_Cuc, 19, 'e', 12)
|
---|
| 1175 | .arg(_e, 19, 'e', 12)
|
---|
| 1176 | .arg(_Cus, 19, 'e', 12)
|
---|
| 1177 | .arg(_sqrt_A, 19, 'e', 12);
|
---|
| 1178 |
|
---|
[4015] | 1179 | out << QString(fmt)
|
---|
[4018] | 1180 | .arg(_TOEsec, 19, 'e', 12)
|
---|
[4013] | 1181 | .arg(_Cic, 19, 'e', 12)
|
---|
| 1182 | .arg(_OMEGA0, 19, 'e', 12)
|
---|
| 1183 | .arg(_Cis, 19, 'e', 12);
|
---|
| 1184 |
|
---|
[4015] | 1185 | out << QString(fmt)
|
---|
[4013] | 1186 | .arg(_i0, 19, 'e', 12)
|
---|
| 1187 | .arg(_Crc, 19, 'e', 12)
|
---|
| 1188 | .arg(_omega, 19, 'e', 12)
|
---|
| 1189 | .arg(_OMEGADOT, 19, 'e', 12);
|
---|
| 1190 |
|
---|
[4015] | 1191 | out << QString(fmt)
|
---|
[4018] | 1192 | .arg(_IDOT, 19, 'e', 12)
|
---|
| 1193 | .arg(_L2Codes, 19, 'e', 12)
|
---|
| 1194 | .arg(_TOEweek, 19, 'e', 12)
|
---|
| 1195 | .arg(_L2PFlag, 19, 'e', 12);
|
---|
[4013] | 1196 |
|
---|
[4015] | 1197 | out << QString(fmt)
|
---|
[4018] | 1198 | .arg(_ura, 19, 'e', 12)
|
---|
[4013] | 1199 | .arg(_health, 19, 'e', 12)
|
---|
| 1200 | .arg(_TGD, 19, 'e', 12)
|
---|
| 1201 | .arg(_IODC, 19, 'e', 12);
|
---|
| 1202 |
|
---|
[4015] | 1203 | out << QString(fmt)
|
---|
[4018] | 1204 | .arg(_TOT, 19, 'e', 12)
|
---|
| 1205 | .arg(_fitInterval, 19, 'e', 12)
|
---|
[4024] | 1206 | .arg("", 19, QChar(' '))
|
---|
| 1207 | .arg("", 19, QChar(' '));
|
---|
[4013] | 1208 |
|
---|
| 1209 | return rnxStr;
|
---|
| 1210 | }
|
---|
[4023] | 1211 |
|
---|
| 1212 | // RINEX Format String
|
---|
| 1213 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 1214 | QString t_ephGlo::toString(double version) const {
|
---|
| 1215 |
|
---|
[4029] | 1216 | QString rnxStr = rinexDateStr(_TOC-_gps_utc, _prn, version);
|
---|
[4023] | 1217 |
|
---|
| 1218 | QTextStream out(&rnxStr);
|
---|
| 1219 |
|
---|
| 1220 | out << QString("%1%2%3\n")
|
---|
| 1221 | .arg(-_tau, 19, 'e', 12)
|
---|
| 1222 | .arg(_gamma, 19, 'e', 12)
|
---|
| 1223 | .arg(_tki, 19, 'e', 12);
|
---|
| 1224 |
|
---|
| 1225 | QString fmt = version < 3.0 ? " %1%2%3%4\n" : " %1%2%3%4\n";
|
---|
| 1226 |
|
---|
| 1227 | out << QString(fmt)
|
---|
| 1228 | .arg(_x_pos, 19, 'e', 12)
|
---|
| 1229 | .arg(_x_velocity, 19, 'e', 12)
|
---|
| 1230 | .arg(_x_acceleration, 19, 'e', 12)
|
---|
| 1231 | .arg(_health, 19, 'e', 12);
|
---|
| 1232 |
|
---|
| 1233 | out << QString(fmt)
|
---|
| 1234 | .arg(_y_pos, 19, 'e', 12)
|
---|
| 1235 | .arg(_y_velocity, 19, 'e', 12)
|
---|
| 1236 | .arg(_y_acceleration, 19, 'e', 12)
|
---|
| 1237 | .arg(_frequency_number, 19, 'e', 12);
|
---|
| 1238 |
|
---|
| 1239 | out << QString(fmt)
|
---|
| 1240 | .arg(_z_pos, 19, 'e', 12)
|
---|
| 1241 | .arg(_z_velocity, 19, 'e', 12)
|
---|
| 1242 | .arg(_z_acceleration, 19, 'e', 12)
|
---|
| 1243 | .arg(_E, 19, 'e', 12);
|
---|
| 1244 |
|
---|
| 1245 | return rnxStr;
|
---|
| 1246 | }
|
---|
| 1247 |
|
---|
| 1248 | // RINEX Format String
|
---|
| 1249 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 1250 | QString t_ephGal::toString(double version) const {
|
---|
| 1251 |
|
---|
[4029] | 1252 | QString rnxStr = rinexDateStr(_TOC, _prn, version);
|
---|
[4023] | 1253 |
|
---|
| 1254 | QTextStream out(&rnxStr);
|
---|
| 1255 |
|
---|
| 1256 | out << QString("%1%2%3\n")
|
---|
| 1257 | .arg(_clock_bias, 19, 'e', 12)
|
---|
| 1258 | .arg(_clock_drift, 19, 'e', 12)
|
---|
| 1259 | .arg(_clock_driftrate, 19, 'e', 12);
|
---|
| 1260 |
|
---|
| 1261 | QString fmt = version < 3.0 ? " %1%2%3%4\n" : " %1%2%3%4\n";
|
---|
| 1262 |
|
---|
| 1263 | out << QString(fmt)
|
---|
| 1264 | .arg(_IODnav, 19, 'e', 12)
|
---|
| 1265 | .arg(_Crs, 19, 'e', 12)
|
---|
| 1266 | .arg(_Delta_n, 19, 'e', 12)
|
---|
| 1267 | .arg(_M0, 19, 'e', 12);
|
---|
| 1268 |
|
---|
| 1269 | out << QString(fmt)
|
---|
| 1270 | .arg(_Cuc, 19, 'e', 12)
|
---|
| 1271 | .arg(_e, 19, 'e', 12)
|
---|
| 1272 | .arg(_Cus, 19, 'e', 12)
|
---|
| 1273 | .arg(_sqrt_A, 19, 'e', 12);
|
---|
| 1274 |
|
---|
| 1275 | out << QString(fmt)
|
---|
| 1276 | .arg(_TOEsec, 19, 'e', 12)
|
---|
| 1277 | .arg(_Cic, 19, 'e', 12)
|
---|
| 1278 | .arg(_OMEGA0, 19, 'e', 12)
|
---|
| 1279 | .arg(_Cis, 19, 'e', 12);
|
---|
| 1280 |
|
---|
| 1281 | out << QString(fmt)
|
---|
| 1282 | .arg(_i0, 19, 'e', 12)
|
---|
| 1283 | .arg(_Crc, 19, 'e', 12)
|
---|
| 1284 | .arg(_omega, 19, 'e', 12)
|
---|
| 1285 | .arg(_OMEGADOT, 19, 'e', 12);
|
---|
| 1286 |
|
---|
[5532] | 1287 | int dataSource = 0;
|
---|
[5542] | 1288 | double HS = 0.0;
|
---|
[5539] | 1289 | if ( (_flags & GALEPHF_INAV) == GALEPHF_INAV ) {
|
---|
| 1290 | dataSource |= (1<<0);
|
---|
[5540] | 1291 | dataSource |= (1<<9);
|
---|
[5542] | 1292 | HS = _E5bHS;
|
---|
[5539] | 1293 | }
|
---|
| 1294 | else if ( (_flags & GALEPHF_FNAV) == GALEPHF_FNAV ) {
|
---|
| 1295 | dataSource |= (1<<1);
|
---|
[5540] | 1296 | dataSource |= (1<<8);
|
---|
[5542] | 1297 | HS = _E5aHS;
|
---|
[5539] | 1298 | }
|
---|
[4023] | 1299 | out << QString(fmt)
|
---|
[5532] | 1300 | .arg(_IDOT, 19, 'e', 12)
|
---|
| 1301 | .arg(double(dataSource), 19, 'e', 12)
|
---|
| 1302 | .arg(_TOEweek, 19, 'e', 12)
|
---|
| 1303 | .arg(0.0, 19, 'e', 12);
|
---|
[4023] | 1304 |
|
---|
| 1305 | out << QString(fmt)
|
---|
| 1306 | .arg(_SISA, 19, 'e', 12)
|
---|
[5542] | 1307 | .arg(HS, 19, 'e', 12)
|
---|
[4023] | 1308 | .arg(_BGD_1_5A, 19, 'e', 12)
|
---|
| 1309 | .arg(_BGD_1_5B, 19, 'e', 12);
|
---|
| 1310 |
|
---|
| 1311 | out << QString(fmt)
|
---|
| 1312 | .arg(_TOT, 19, 'e', 12)
|
---|
[4024] | 1313 | .arg("", 19, QChar(' '))
|
---|
| 1314 | .arg("", 19, QChar(' '))
|
---|
| 1315 | .arg("", 19, QChar(' '));
|
---|
[4023] | 1316 |
|
---|
| 1317 | return rnxStr;
|
---|
| 1318 | }
|
---|
| 1319 |
|
---|