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