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