- Timestamp:
- Apr 22, 2012, 6:50:49 PM (13 years ago)
- Location:
- trunk/BNC
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/RTCM3/ephemeris.cpp
r4017 r4018 15 15 using namespace std; 16 16 17 #define PI 3.141592653589818 // Returns nearest integer value19 ////////////////////////////////////////////////////////////////////////////20 static double NearestInt(double fl, double * remain)21 {22 bool isneg = fl < 0.0;23 double intval;24 if(isneg) fl *= -1.0;25 intval = (double)((unsigned long)(fl+0.5));26 if(isneg) {fl *= -1.0; intval *= -1.0;}27 if(remain)28 *remain = fl-intval;29 return intval;30 } /* NearestInt() */31 32 17 // Returns CRC24 33 18 //////////////////////////////////////////////////////////////////////////// 34 static unsigned long CRC24(long size, const unsigned char *buf) 35 { 19 static unsigned long CRC24(long size, const unsigned char *buf) { 36 20 unsigned long crc = 0; 37 int i; 38 39 while(size--) 40 { 21 int ii; 22 while (size--) { 41 23 crc ^= (*buf++) << (16); 42 for(i = 0; i < 8; i++) 43 { 24 for(ii = 0; ii < 8; ii++) { 44 25 crc <<= 1; 45 if (crc & 0x1000000)26 if (crc & 0x1000000) { 46 27 crc ^= 0x01864cfb; 28 } 47 29 } 48 30 } 49 31 return crc; 50 } /* CRC24 */51 52 //53 ////////////////////////////////////////////////////////////////////////////54 bool t_eph::isNewerThan(const t_eph* eph) const {55 if (_GPSweek > eph->_GPSweek ||56 (_GPSweek == eph->_GPSweek && _GPSweeks > eph->_GPSweeks)) {57 return true;58 }59 else {60 return false;61 }62 32 } 63 33 … … 68 38 _prn = QString("G%1").arg(ee->satellite, 2, 10, QChar('0')); 69 39 70 // TODO: check if following two lines are correct 71 _GPSweek = ee->GPSweek; 72 _GPSweeks = ee->TOE; 73 74 _TOW = ee->TOW; 75 _TOC = ee->TOC; 76 _TOE = ee->TOE; 77 _IODE = ee->IODE; 78 _IODC = ee->IODC; 79 40 _TOC.set(ee->GPSweek, ee->TOC); 80 41 _clock_bias = ee->clock_bias; 81 42 _clock_drift = ee->clock_drift; 82 43 _clock_driftrate = ee->clock_driftrate; 83 44 45 _IODE = ee->IODE; 84 46 _Crs = ee->Crs; 85 47 _Delta_n = ee->Delta_n; 86 48 _M0 = ee->M0; 49 87 50 _Cuc = ee->Cuc; 88 51 _e = ee->e; 89 52 _Cus = ee->Cus; 90 53 _sqrt_A = ee->sqrt_A; 54 55 _TOEsec = ee->TOE; 91 56 _Cic = ee->Cic; 92 57 _OMEGA0 = ee->OMEGA0; 93 58 _Cis = ee->Cis; 59 94 60 _i0 = ee->i0; 95 61 _Crc = ee->Crc; 96 62 _omega = ee->omega; 97 63 _OMEGADOT = ee->OMEGADOT; 64 98 65 _IDOT = ee->IDOT; 99 66 _L2Codes = 0.0; 67 _TOEweek = ee->TOW; 68 _L2PFlag = 0.0; 69 70 _ura = 0.0; 71 _health = ee->SVhealth; 100 72 _TGD = ee->TGD; 73 _IODC = ee->IODC; 74 75 _TOT = 0.9999e9; 76 _fitInterval = 0.0; 101 77 102 78 _ok = true; 103 104 /* FIXME: convert URAindex and flags! */105 _ura = 0;106 _L2Codes = 0;107 _L2PFlag = 0;108 _health = ee->SVhealth;109 79 } 110 80 … … 112 82 //////////////////////////////////////////////////////////////////////////// 113 83 void t_ephGPS::position(int GPSweek, double GPSweeks, 114 115 116 117 static const double secPerWeek = 7 * 86400.0; 84 double* xc, 85 double* vv) const { 86 87 118 88 static const double omegaEarth = 7292115.1467e-11; 119 89 static const double gmWGS = 398.6005e12; … … 128 98 129 99 double n0 = sqrt(gmWGS/(a0*a0*a0)); 130 double tk = GPSweeks - _TOE; 131 if (GPSweek != _GPSweek) {132 tk += (GPSweek - _GPSweek) * secPerWeek;133 } 100 101 bncTime tt(GPSweek, GPSweeks); 102 double tk = tt - bncTime(_TOEweek, _TOEsec); 103 134 104 double n = n0 + _Delta_n; 135 105 double M = _M0 + n*tk; … … 150 120 double yp = r*sin(u); 151 121 double OM = _OMEGA0 + (_OMEGADOT - omegaEarth)*tk - 152 omegaEarth*_TOE ;122 omegaEarth*_TOEsec; 153 123 154 124 double sinom = sin(OM); … … 160 130 xc[2] = yp*sini; 161 131 162 double tc = GPSweeks - _TOC; 163 if (GPSweek != _GPSweek) { 164 tc += (GPSweek - _GPSweek) * secPerWeek; 165 } 132 double tc = tt - _TOC; 166 133 xc[3] = _clock_bias + _clock_drift*tc + _clock_driftrate*tc*tc; 167 134 … … 192 159 // Relativistic Correction 193 160 // ----------------------- 194 // xc(4) -= 4.442807633e-10 * _e * sqrt(a0) *sin(E);195 161 xc[3] -= 2.0 * (xc[0]*vv[0] + xc[1]*vv[1] + xc[2]*vv[2]) / t_CST::c / t_CST::c; 196 162 } … … 198 164 // build up RTCM3 for GPS 199 165 //////////////////////////////////////////////////////////////////////////// 200 #define GPSTOINT(type, value) static_cast<type>( NearestInt(value,0))166 #define GPSTOINT(type, value) static_cast<type>(round(value)) 201 167 202 168 #define GPSADDBITS(a, b) {bitbuffer = (bitbuffer<<(a)) \ … … 205 171 while(numbits >= 8) { \ 206 172 buffer[size++] = bitbuffer>>(numbits-8);numbits -= 8;}} 173 207 174 #define GPSADDBITSFLOAT(a,b,c) {long long i = GPSTOINT(long long,(b)/(c)); \ 208 175 GPSADDBITS(a,i)}; 209 176 210 int t_ephGPS::RTCM3(unsigned char *buffer) 211 { 177 int t_ephGPS::RTCM3(unsigned char *buffer) { 212 178 213 179 unsigned char *startbuffer = buffer; … … 267 233 GPSADDBITS(12, 1019) 268 234 GPSADDBITS(6,_prn.right((_prn.length()-1)).toInt()) 269 GPSADDBITS(10, _ GPSweek)235 GPSADDBITS(10, _TOC.gpsw()) 270 236 GPSADDBITS(4, _ura) 271 237 GPSADDBITS(2,_L2Codes) 272 GPSADDBITSFLOAT(14, _IDOT, PI/static_cast<double>(1<<30)238 GPSADDBITSFLOAT(14, _IDOT, M_PI/static_cast<double>(1<<30) 273 239 /static_cast<double>(1<<13)) 274 240 GPSADDBITS(8, _IODE) 275 GPSADDBITS(16, static_cast<int>(_TOC )>>4)241 GPSADDBITS(16, static_cast<int>(_TOC.gpssec())>>4) 276 242 GPSADDBITSFLOAT(8, _clock_driftrate, 1.0/static_cast<double>(1<<30) 277 243 /static_cast<double>(1<<25)) … … 282 248 GPSADDBITS(10, _IODC) 283 249 GPSADDBITSFLOAT(16, _Crs, 1.0/static_cast<double>(1<<5)) 284 GPSADDBITSFLOAT(16, _Delta_n, PI/static_cast<double>(1<<30)250 GPSADDBITSFLOAT(16, _Delta_n, M_PI/static_cast<double>(1<<30) 285 251 /static_cast<double>(1<<13)) 286 GPSADDBITSFLOAT(32, _M0, PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))252 GPSADDBITSFLOAT(32, _M0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1)) 287 253 GPSADDBITSFLOAT(16, _Cuc, 1.0/static_cast<double>(1<<29)) 288 254 GPSADDBITSFLOAT(32, _e, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<3)) 289 255 GPSADDBITSFLOAT(16, _Cus, 1.0/static_cast<double>(1<<29)) 290 256 GPSADDBITSFLOAT(32, _sqrt_A, 1.0/static_cast<double>(1<<19)) 291 GPSADDBITS(16, static_cast<int>(_TOE )>>4)257 GPSADDBITS(16, static_cast<int>(_TOEsec)>>4) 292 258 GPSADDBITSFLOAT(16, _Cic, 1.0/static_cast<double>(1<<29)) 293 GPSADDBITSFLOAT(32, _OMEGA0, PI/static_cast<double>(1<<30)259 GPSADDBITSFLOAT(32, _OMEGA0, M_PI/static_cast<double>(1<<30) 294 260 /static_cast<double>(1<<1)) 295 261 GPSADDBITSFLOAT(16, _Cis, 1.0/static_cast<double>(1<<29)) 296 GPSADDBITSFLOAT(32, _i0, PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))262 GPSADDBITSFLOAT(32, _i0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1)) 297 263 GPSADDBITSFLOAT(16, _Crc, 1.0/static_cast<double>(1<<5)) 298 GPSADDBITSFLOAT(32, _omega, PI/static_cast<double>(1<<30)264 GPSADDBITSFLOAT(32, _omega, M_PI/static_cast<double>(1<<30) 299 265 /static_cast<double>(1<<1)) 300 GPSADDBITSFLOAT(24, _OMEGADOT, PI/static_cast<double>(1<<30)266 GPSADDBITSFLOAT(24, _OMEGADOT, M_PI/static_cast<double>(1<<30) 301 267 /static_cast<double>(1<<13)) 302 268 GPSADDBITSFLOAT(8, _TGD, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<1)) … … 358 324 double* xc, double* vv) const { 359 325 360 static const double secPerWeek = 7 * 86400.0;361 326 static const double nominalStep = 10.0; 362 327 … … 364 329 memset(vv, 0, 3*sizeof(double)); 365 330 366 double dtPos = GPSweeks - _tt; 367 if (GPSweek != _GPSweek) { 368 dtPos += (GPSweek - _GPSweek) * secPerWeek; 369 } 331 double dtPos = bncTime(GPSweek, GPSweeks) - _tt; 370 332 371 333 int nSteps = int(fabs(dtPos) / nominalStep) + 1; … … 377 339 acc[2] = _z_acceleration * 1.e3; 378 340 for (int ii = 1; ii <= nSteps; ii++) { 379 _xv = rungeKutta4(_tt , _xv, step, acc, glo_deriv);380 _tt +=step;341 _xv = rungeKutta4(_tt.gpssec(), _xv, step, acc, glo_deriv); 342 _tt = _tt + step; 381 343 } 382 344 … … 393 355 // Clock Correction 394 356 // ---------------- 395 double dtClk = GPSweeks - _GPSweeks; 396 if (GPSweek != _GPSweek) { 397 dtClk += (GPSweek - _GPSweek) * secPerWeek; 398 } 357 double dtClk = bncTime(GPSweek, GPSweeks) - _TOC; 399 358 xc[3] = -_tau + _gamma * dtClk; 400 359 } … … 403 362 //////////////////////////////////////////////////////////////////////////// 404 363 int t_ephGlo::IOD() const { 405 bncTime tGPS(_GPSweek, _GPSweeks); 406 bncTime tMoscow = tGPS - _gps_utc + 3 * 3600.0; 364 bncTime tMoscow = _TOC - _gps_utc + 3 * 3600.0; 407 365 return int(tMoscow.daysec() / 900); 408 366 } … … 472 430 _gps_utc = gnumleap(year, month, day); 473 431 474 _GPSweek = ww; 475 _GPSweeks = tow; 432 _TOC.set(ww, tow); 476 433 _E = ee->E; 477 434 _tau = ee->tau; … … 492 449 // Initialize status vector 493 450 // ------------------------ 494 _tt = _ GPSweeks;451 _tt = _TOC; 495 452 496 453 _xv(1) = _x_pos * 1.e3; … … 506 463 // build up RTCM3 for GLONASS 507 464 //////////////////////////////////////////////////////////////////////////// 508 #define GLONASSTOINT(type, value) static_cast<type>( NearestInt(value,0))465 #define GLONASSTOINT(type, value) static_cast<type>(round(value)) 509 466 510 467 #define GLONASSADDBITS(a, b) {bitbuffer = (bitbuffer<<(a)) \ … … 549 506 GLONASSADDBITS(1, _health) 550 507 GLONASSADDBITS(1, 0) 551 unsigned long long timeofday = (static_cast<int>(_tt +3*60*60-_gps_utc)%86400);508 unsigned long long timeofday = (static_cast<int>(_tt.gpssec()+3*60*60-_gps_utc)%86400); 552 509 GLONASSADDBITS(7, timeofday/60/15) 553 510 GLONASSADDBITSFLOATM(24, _x_velocity*1000, 1000.0/static_cast<double>(1<<20)) … … 597 554 _prn = QString("E%1").arg(ee->satellite, 2, 10, QChar('0')); 598 555 599 _GPSweek = ee->Week; 600 _GPSweeks = ee->TOE; 601 602 _TOC = ee->TOC; 603 _TOE = ee->TOE; 604 _IODnav = ee->IODnav; 605 556 _TOC.set(ee->Week, ee->TOC); 606 557 _clock_bias = ee->clock_bias; 607 558 _clock_drift = ee->clock_drift; 608 559 _clock_driftrate = ee->clock_driftrate; 609 560 561 _IODnav = ee->IODnav; 610 562 _Crs = ee->Crs; 611 563 _Delta_n = ee->Delta_n; 612 564 _M0 = ee->M0; 565 613 566 _Cuc = ee->Cuc; 614 567 _e = ee->e; 615 568 _Cus = ee->Cus; 616 569 _sqrt_A = ee->sqrt_A; 570 571 _TOEsec = ee->TOE; 617 572 _Cic = ee->Cic; 618 573 _OMEGA0 = ee->OMEGA0; 619 574 _Cis = ee->Cis; 575 620 576 _i0 = ee->i0; 621 577 _Crc = ee->Crc; 622 578 _omega = ee->omega; 623 579 _OMEGADOT = ee->OMEGADOT; 580 624 581 _IDOT = ee->IDOT; 582 _TOEweek = ee->Week; 583 625 584 _SISA = ee->SISA; 585 _E5aHS = ee->E5aHS; 626 586 _BGD_1_5A = ee->BGD_1_5A; 627 587 _BGD_1_5B = ee->BGD_1_5B; 628 _E5aHS = ee->E5aHS; 588 589 _TOT = 0.9999e9; 629 590 630 591 _ok = true; … … 634 595 //////////////////////////////////////////////////////////////////////////// 635 596 void t_ephGal::position(int GPSweek, double GPSweeks, 636 double* xc, 637 double* vv) const { 638 639 static const double secPerWeek = 7 * 86400.0; 597 double* xc, 598 double* vv) const { 599 640 600 static const double omegaEarth = 7292115.1467e-11; 641 601 static const double gmWGS = 398.6005e12; … … 650 610 651 611 double n0 = sqrt(gmWGS/(a0*a0*a0)); 652 double tk = GPSweeks - _TOE; 653 if (GPSweek != _GPSweek) {654 tk += (GPSweek - _GPSweek) * secPerWeek;655 } 612 613 bncTime tt(GPSweek, GPSweeks); 614 double tk = tt - bncTime(_TOC.gpsw(), _TOEsec); 615 656 616 double n = n0 + _Delta_n; 657 617 double M = _M0 + n*tk; … … 672 632 double yp = r*sin(u); 673 633 double OM = _OMEGA0 + (_OMEGADOT - omegaEarth)*tk - 674 omegaEarth*_TOE;634 omegaEarth*_TOEsec; 675 635 676 636 double sinom = sin(OM); … … 682 642 xc[2] = yp*sini; 683 643 684 double tc = GPSweeks - _TOC; 685 if (GPSweek != _GPSweek) { 686 tc += (GPSweek - _GPSweek) * secPerWeek; 687 } 644 double tc = tt - _TOC; 688 645 xc[3] = _clock_bias + _clock_drift*tc + _clock_driftrate*tc*tc; 689 646 … … 720 677 // build up RTCM3 for Galileo 721 678 //////////////////////////////////////////////////////////////////////////// 722 #define GALILEOTOINT(type, value) static_cast<type>( NearestInt(value, 0))679 #define GALILEOTOINT(type, value) static_cast<type>(round(value)) 723 680 724 681 #define GALILEOADDBITS(a, b) {bitbuffer = (bitbuffer<<(a)) \ … … 739 696 GALILEOADDBITS(12, /*inav ? 1046 :*/ 1045) 740 697 GALILEOADDBITS(6, _prn.right((_prn.length()-1)).toInt()) 741 GALILEOADDBITS(12, _ GPSweek)698 GALILEOADDBITS(12, _TOC.gpsw()) 742 699 GALILEOADDBITS(10, _IODnav) 743 700 GALILEOADDBITS(8, _SISA) 744 GALILEOADDBITSFLOAT(14, _IDOT, PI/static_cast<double>(1<<30)701 GALILEOADDBITSFLOAT(14, _IDOT, M_PI/static_cast<double>(1<<30) 745 702 /static_cast<double>(1<<13)) 746 GALILEOADDBITS(14, _TOC /60)703 GALILEOADDBITS(14, _TOC.gpssec()/60) 747 704 GALILEOADDBITSFLOAT(6, _clock_driftrate, 1.0/static_cast<double>(1<<30) 748 705 /static_cast<double>(1<<29)) … … 752 709 /static_cast<double>(1<<4)) 753 710 GALILEOADDBITSFLOAT(16, _Crs, 1.0/static_cast<double>(1<<5)) 754 GALILEOADDBITSFLOAT(16, _Delta_n, PI/static_cast<double>(1<<30)711 GALILEOADDBITSFLOAT(16, _Delta_n, M_PI/static_cast<double>(1<<30) 755 712 /static_cast<double>(1<<13)) 756 GALILEOADDBITSFLOAT(32, _M0, PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))713 GALILEOADDBITSFLOAT(32, _M0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1)) 757 714 GALILEOADDBITSFLOAT(16, _Cuc, 1.0/static_cast<double>(1<<29)) 758 715 GALILEOADDBITSFLOAT(32, _e, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<3)) 759 716 GALILEOADDBITSFLOAT(16, _Cus, 1.0/static_cast<double>(1<<29)) 760 717 GALILEOADDBITSFLOAT(32, _sqrt_A, 1.0/static_cast<double>(1<<19)) 761 GALILEOADDBITS(14, _TOE /60)718 GALILEOADDBITS(14, _TOEsec/60) 762 719 GALILEOADDBITSFLOAT(16, _Cic, 1.0/static_cast<double>(1<<29)) 763 GALILEOADDBITSFLOAT(32, _OMEGA0, PI/static_cast<double>(1<<30)720 GALILEOADDBITSFLOAT(32, _OMEGA0, M_PI/static_cast<double>(1<<30) 764 721 /static_cast<double>(1<<1)) 765 722 GALILEOADDBITSFLOAT(16, _Cis, 1.0/static_cast<double>(1<<29)) 766 GALILEOADDBITSFLOAT(32, _i0, PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))723 GALILEOADDBITSFLOAT(32, _i0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1)) 767 724 GALILEOADDBITSFLOAT(16, _Crc, 1.0/static_cast<double>(1<<5)) 768 GALILEOADDBITSFLOAT(32, _omega, PI/static_cast<double>(1<<30)725 GALILEOADDBITSFLOAT(32, _omega, M_PI/static_cast<double>(1<<30) 769 726 /static_cast<double>(1<<1)) 770 GALILEOADDBITSFLOAT(24, _OMEGADOT, PI/static_cast<double>(1<<30)727 GALILEOADDBITSFLOAT(24, _OMEGADOT, M_PI/static_cast<double>(1<<30) 771 728 /static_cast<double>(1<<13)) 772 729 GALILEOADDBITSFLOAT(10, _BGD_1_5A, 1.0/static_cast<double>(1<<30) … … 784 741 GALILEOADDBITS(1, /*flags & MNFGALEPHF_E5ADINVALID*/0) 785 742 } 786 _TOE = 0.9999E9;787 GALILEOADDBITS(20, _TOE )743 _TOEsec = 0.9999E9; 744 GALILEOADDBITS(20, _TOEsec) 788 745 789 746 GALILEOADDBITS(/*inav ? 1 :*/ 3, 0) /* fill up */ … … 846 803 } 847 804 848 bncTime hlpTime; 849 hlpTime.set(year, month, day, hour, min, sec); 850 _GPSweek = hlpTime.gpsw(); 851 _GPSweeks = hlpTime.gpssec(); 852 _TOC = _GPSweeks; 805 _TOC.set(year, month, day, hour, min, sec); 853 806 854 807 if ( readDbl(line, pos[1], fieldLen, _clock_bias ) || … … 878 831 879 832 else if ( iLine == 3 ) { 880 if ( readDbl(line, pos[0], fieldLen, _TOE 833 if ( readDbl(line, pos[0], fieldLen, _TOEsec) || 881 834 readDbl(line, pos[1], fieldLen, _Cic ) || 882 835 readDbl(line, pos[2], fieldLen, _OMEGA0) || … … 896 849 897 850 else if ( iLine == 5 ) { 898 double dummy, TOEw; 899 if ( readDbl(line, pos[0], fieldLen, _IDOT) || 900 readDbl(line, pos[1], fieldLen, dummy) || 901 readDbl(line, pos[2], fieldLen, TOEw ) || 902 readDbl(line, pos[3], fieldLen, dummy) ) { 851 if ( readDbl(line, pos[0], fieldLen, _IDOT ) || 852 readDbl(line, pos[1], fieldLen, _L2Codes) || 853 readDbl(line, pos[2], fieldLen, _TOEweek ) || 854 readDbl(line, pos[3], fieldLen, _L2PFlag) ) { 903 855 return; 904 856 } … … 906 858 907 859 else if ( iLine == 6 ) { 908 double dummy; 909 if ( readDbl(line, pos[0], fieldLen, dummy ) || 860 if ( readDbl(line, pos[0], fieldLen, _ura ) || 910 861 readDbl(line, pos[1], fieldLen, _health) || 911 862 readDbl(line, pos[2], fieldLen, _TGD ) || … … 916 867 917 868 else if ( iLine == 7 ) { 918 double TOT;919 if ( readDbl(line, pos[0], fieldLen, TOT) ) {869 if ( readDbl(line, pos[0], fieldLen, _TOT) || 870 readDbl(line, pos[1], fieldLen, _fitInterval) ) { 920 871 return; 921 872 } … … 972 923 } 973 924 974 bncTime hlpTime;975 hlpTime.set(year, month, day, hour, min, sec);976 977 925 _gps_utc = gnumleap(year, month, day); 978 hlpTime = hlpTime + _gps_utc; 979 980 _GPSweek = hlpTime.gpsw(); 981 _GPSweeks = hlpTime.gpssec(); 982 983 _tki = 0.0; // TODO ? 984 985 double second_tot; 986 if ( readDbl(line, pos[1], fieldLen, _tau ) || 987 readDbl(line, pos[2], fieldLen, _gamma ) || 988 readDbl(line, pos[3], fieldLen, second_tot) ) { 926 927 _TOC.set(year, month, day, hour, min, sec); 928 _TOC = _TOC + _gps_utc; 929 930 if ( readDbl(line, pos[1], fieldLen, _tau ) || 931 readDbl(line, pos[2], fieldLen, _gamma) || 932 readDbl(line, pos[3], fieldLen, _tki ) ) { 989 933 return; 990 934 } … … 1023 967 // Initialize status vector 1024 968 // ------------------------ 1025 _tt = _GPSweeks; 1026 1027 _xv.ReSize(6); 1028 969 _tt = _TOC; 970 _xv.ReSize(6); 1029 971 _xv(1) = _x_pos * 1.e3; 1030 972 _xv(2) = _y_pos * 1.e3; … … 1062 1004 QString rnxStr; 1063 1005 1064 bncTime tt(_GPSweek, _GPSweeks);1065 1006 unsigned year, month, day, hour, min; 1066 double sec;1067 tt.civil_date(year, month, day);1068 tt.civil_time(hour, min, sec);1007 double sec; 1008 _TOC.civil_date(year, month, day); 1009 _TOC.civil_time(hour, min, sec); 1069 1010 1070 1011 QTextStream out(&rnxStr); … … 1110 1051 1111 1052 out << QString(fmt) 1112 .arg(_TOE ,19, 'e', 12)1053 .arg(_TOEsec, 19, 'e', 12) 1113 1054 .arg(_Cic, 19, 'e', 12) 1114 1055 .arg(_OMEGA0, 19, 'e', 12) … … 1122 1063 1123 1064 out << QString(fmt) 1124 .arg(_IDOT, 19, 'e', 12)1125 .arg( 0.0,19, 'e', 12)1126 .arg( 0.0,19, 'e', 12)1127 .arg( 0.0,19, 'e', 12);1065 .arg(_IDOT, 19, 'e', 12) 1066 .arg(_L2Codes, 19, 'e', 12) 1067 .arg(_TOEweek, 19, 'e', 12) 1068 .arg(_L2PFlag, 19, 'e', 12); 1128 1069 1129 1070 out << QString(fmt) 1130 .arg( 0.0,19, 'e', 12)1071 .arg(_ura, 19, 'e', 12) 1131 1072 .arg(_health, 19, 'e', 12) 1132 1073 .arg(_TGD, 19, 'e', 12) … … 1134 1075 1135 1076 out << QString(fmt) 1136 .arg( 0.0,19, 'e', 12)1137 .arg( 0.0, 19, 'e', 12)1077 .arg(_TOT, 19, 'e', 12) 1078 .arg(_fitInterval, 19, 'e', 12) 1138 1079 .arg("") 1139 1080 .arg(""); -
trunk/BNC/RTCM3/ephemeris.h
r4013 r4018 6 6 #include <stdio.h> 7 7 #include <string> 8 #include "bnctime.h" 8 9 extern "C" { 9 10 #include "rtcm3torinex.h" … … 15 16 enum e_type {unknown, GPS, GLONASS, Galileo}; 16 17 17 static bool earlierTime(const t_eph* eph1, const t_eph* eph2) {18 if (eph1->_GPSweek < eph2->_GPSweek) {19 return true;20 }21 else if (eph1->_GPSweek == eph2->_GPSweek) {22 return eph1->_GPSweeks < eph2->_GPSweeks;23 }24 else {25 return false;26 }27 }28 29 18 t_eph() {_ok = false;} 30 19 virtual ~t_eph() {}; 31 20 21 static bool earlierTime(const t_eph* eph1, const t_eph* eph2) { 22 return eph1->_TOC < eph2->_TOC; 23 } 24 32 25 virtual e_type type() const = 0; 33 34 26 virtual QString toString(double version) const = 0; 35 36 bool ok() const {return _ok;} 37 bool isNewerThan(const t_eph* eph) const; 38 QString prn() const {return _prn;} 39 void setReceptDateTime(const QDateTime& dateTime) { 27 virtual void position(int GPSweek, double GPSweeks, 28 double* xc, double* vv) const = 0; 29 virtual int IOD() const = 0; 30 virtual int RTCM3(unsigned char *) = 0; 31 32 bool ok() const {return _ok;} 33 bncTime TOC() const {return _TOC;} 34 bool isNewerThan(const t_eph* eph) const { 35 return earlierTime(this, eph); 36 } 37 QString prn() const {return _prn;} 38 void setReceptDateTime(const QDateTime& dateTime) { 40 39 _receptDateTime = dateTime; 41 40 } 42 41 const QDateTime& receptDateTime() const {return _receptDateTime;} 43 44 int GPSweek() const { return _GPSweek; }45 double GPSweeks() const { return _GPSweeks; }46 47 virtual void position(int GPSweek, double GPSweeks,48 double* xc, double* vv) const = 0;49 42 50 43 void position(int GPSweek, double GPSweeks, … … 52 45 double tmp_xx[4]; 53 46 double tmp_vv[4]; 54 55 47 position(GPSweek, GPSweeks, tmp_xx, tmp_vv); 56 48 … … 61 53 } 62 54 63 virtual int IOD() const = 0;64 65 virtual int RTCM3(unsigned char *) = 0;66 67 55 protected: 68 56 QString _prn; 69 int _GPSweek; 70 double _GPSweeks; 57 bncTime _TOC; 71 58 QDateTime _receptDateTime; 72 59 bool _ok; … … 84 71 virtual QString toString(double version) const; 85 72 86 double TOC() const {return _TOC;}87 88 73 void set(const gpsephemeris* ee); 89 74 … … 97 82 98 83 private: 99 double _TOW; // [s] 100 double _TOC; // [s] 101 double _TOE; // [s] 102 double _IODE; 103 double _IODC; 104 84 double _clock_bias; // [s] 85 double _clock_drift; // [s/s] 86 double _clock_driftrate; // [s/s^2] 87 88 double _IODE; 89 double _Crs; // [m] 90 double _Delta_n; // [rad/s] 91 double _M0; // [rad] 92 93 double _Cuc; // [rad] 94 double _e; // 95 double _Cus; // [rad] 96 double _sqrt_A; // [m^0.5] 97 98 double _TOEsec; // [s] 99 double _Cic; // [rad] 100 double _OMEGA0; // [rad] 101 double _Cis; // [rad] 102 103 double _i0; // [rad] 104 double _Crc; // [m] 105 double _omega; // [rad] 106 double _OMEGADOT; // [rad/s] 107 108 double _IDOT; // [rad/s] 109 double _L2Codes; // Codes on L2 channel 110 double _TOEweek; 111 double _L2PFlag; // L2 P data flag 112 113 double _ura; // SV accuracy 114 double _health; // SV health 115 double _TGD; // [s] 116 double _IODC; 117 118 double _TOT; // Transmisstion time 119 double _fitInterval; // Fit interval 120 }; 121 122 class t_ephGlo : public t_eph { 123 public: 124 t_ephGlo() { _xv.ReSize(6); } 125 t_ephGlo(float rnxVersion, const QStringList& lines); 126 127 virtual ~t_ephGlo() {} 128 129 virtual e_type type() const {return t_eph::GLONASS;} 130 131 virtual QString toString(double version) const; 132 133 virtual void position(int GPSweek, double GPSweeks, 134 double* xc, 135 double* vv) const; 136 137 virtual int IOD() const; 138 139 virtual int RTCM3(unsigned char *); 140 141 void set(const glonassephemeris* ee); 142 143 int slotNum() const {return int(_frequency_number);} 144 145 private: 146 static ColumnVector glo_deriv(double /* tt */, const ColumnVector& xv, 147 double* acc); 148 149 mutable bncTime _tt; // time 150 mutable ColumnVector _xv; // status vector (position, velocity) at time _tt 151 152 double _gps_utc; 153 double _tau; // [s] 154 double _gamma; // 155 double _tki; // message frame time 156 157 double _x_pos; // [km] 158 double _x_velocity; // [km/s] 159 double _x_acceleration; // [km/s^2] 160 double _health; // 0 = O.K. 161 162 double _y_pos; // [km] 163 double _y_velocity; // [km/s] 164 double _y_acceleration; // [km/s^2] 165 double _frequency_number; // ICD-GLONASS data position 166 167 double _z_pos; // [km] 168 double _z_velocity; // [km/s] 169 double _z_acceleration; // [km/s^2] 170 double _E; // Age of Information [days] 171 }; 172 173 class t_ephGal : public t_eph { 174 public: 175 t_ephGal() { } 176 t_ephGal(float rnxVersion, const QStringList& lines); 177 virtual ~t_ephGal() {} 178 179 virtual QString toString(double version) const; 180 181 virtual e_type type() const {return t_eph::Galileo;} 182 183 void set(const galileoephemeris* ee); 184 185 virtual void position(int GPSweek, double GPSweeks, 186 double* xc, 187 double* vv) const; 188 189 virtual int IOD() const { return static_cast<int>(_IODnav); } 190 191 virtual int RTCM3(unsigned char *); 192 193 private: 105 194 double _clock_bias; // [s] 106 195 double _clock_drift; // [s/s] 107 196 double _clock_driftrate; // [s/s^2] 108 197 198 double _IODnav; 109 199 double _Crs; // [m] 110 200 double _Delta_n; // [rad/s] 111 201 double _M0; // [rad] 202 112 203 double _Cuc; // [rad] 113 204 double _e; // 114 205 double _Cus; // [rad] 115 206 double _sqrt_A; // [m^0.5] 207 208 double _TOEsec; // [s] 116 209 double _Cic; // [rad] 117 210 double _OMEGA0; // [rad] 118 211 double _Cis; // [rad] 212 119 213 double _i0; // [rad] 120 214 double _Crc; // [m] 121 215 double _omega; // [rad] 122 216 double _OMEGADOT; // [rad/s] 217 123 218 double _IDOT; // [rad/s] 124 125 double _TGD; // [s] 126 double _health; // SV health 127 double _ura; // SV accuracy 128 double _L2PFlag; // L2 P data flag 129 double _L2Codes; // Codes on L2 channel 130 }; 131 132 class t_ephGlo : public t_eph { 133 public: 134 t_ephGlo() { _xv.ReSize(6); } 135 t_ephGlo(float rnxVersion, const QStringList& lines); 136 137 virtual ~t_ephGlo() {} 138 139 virtual e_type type() const {return t_eph::GLONASS;} 140 141 virtual QString toString(double version) const; 142 143 virtual void position(int GPSweek, double GPSweeks, 144 double* xc, 145 double* vv) const; 146 147 virtual int IOD() const; 148 149 virtual int RTCM3(unsigned char *); 150 151 void set(const glonassephemeris* ee); 152 153 int slotNum() const {return int(_frequency_number);} 154 155 private: 156 static ColumnVector glo_deriv(double /* tt */, const ColumnVector& xv, 157 double* acc); 158 159 mutable double _tt; // time in seconds of GPSweek 160 mutable ColumnVector _xv; // status vector (position, velocity) at time _tt 161 162 double _gps_utc; 163 double _E; // [days] 164 double _tau; // [s] 165 double _gamma; // 166 double _x_pos; // [km] 167 double _x_velocity; // [km/s] 168 double _x_acceleration; // [km/s^2] 169 double _y_pos; // [km] 170 double _y_velocity; // [km/s] 171 double _y_acceleration; // [km/s^2] 172 double _z_pos; // [km] 173 double _z_velocity; // [km/s] 174 double _z_acceleration; // [km/s^2] 175 double _health; // 0 = O.K. 176 double _frequency_number; // ICD-GLONASS data position 177 double _tki; // message frame time 178 }; 179 180 class t_ephGal : public t_eph { 181 public: 182 t_ephGal() { } 183 t_ephGal(float rnxVersion, const QStringList& lines); 184 virtual ~t_ephGal() {} 185 186 virtual QString toString(double version) const; 187 188 virtual e_type type() const {return t_eph::Galileo;} 189 190 double TOC() const {return _TOC;} 191 192 void set(const galileoephemeris* ee); 193 194 virtual void position(int GPSweek, double GPSweeks, 195 double* xc, 196 double* vv) const; 197 198 virtual int IOD() const { return static_cast<int>(_IODnav); } 199 200 virtual int RTCM3(unsigned char *); 201 202 private: 203 double _IODnav; 204 double _TOC; // [s] 205 double _TOE; // [s] 206 double _clock_bias; // [s] 207 double _clock_drift; // [s/s] 208 double _clock_driftrate; // [s/s^2] 209 double _Crs; // [m] 210 double _Delta_n; // [rad/s] 211 double _M0; // [rad] 212 double _Cuc; // [rad] 213 double _e; // 214 double _Cus; // [rad] 215 double _sqrt_A; // [m^0.5] 216 double _Cic; // [rad] 217 double _OMEGA0; // [rad] 218 double _Cis; // [rad] 219 double _i0; // [rad] 220 double _Crc; // [m] 221 double _omega; // [rad] 222 double _OMEGADOT; // [rad/s] 223 double _IDOT; // [rad/s] 219 // 220 double _TOEweek; 221 // spare 222 223 int _SISA; // Signal In Space Accuracy 224 int _E5aHS; // E5a Health Status 224 225 double _BGD_1_5A; // group delay [s] 225 226 double _BGD_1_5B; // group delay [s] 226 int _SISA; // Signal In Space Accuracy 227 int _E5aHS; // E5a Health Status 228 227 228 double _TOT; // [s] 229 229 }; 230 230 -
trunk/BNC/bncephuser.cpp
r3752 r4018 81 81 if (_eph.contains(prn)) { 82 82 t_ephGPS* eLast = static_cast<t_ephGPS*>(_eph.value(prn)->last); 83 if ( (eLast->GPSweek() < gpseph.GPSweek) || 84 (eLast->GPSweek() == gpseph.GPSweek && 85 eLast->TOC() < gpseph.TOC) ) { 83 bncTime toc(gpseph.GPSweek, gpseph.TOC); 84 if (eLast->TOC() < toc) { 86 85 delete static_cast<t_ephGPS*>(_eph.value(prn)->prev); 87 86 _eph.value(prn)->prev = _eph.value(prn)->last; … … 110 109 updatetime(&ww, &tow, gloeph.tb*1000, 0); // Moscow -> GPS 111 110 t_ephGlo* eLast = static_cast<t_ephGlo*>(_eph.value(prn)->last); 112 if (eLast->GPSweek() < ww ||113 (eLast->GPSweek() == ww && eLast->GPSweeks() < tow)) {111 bncTime toc(ww, tow); 112 if (eLast->TOC() < toc) { 114 113 delete static_cast<t_ephGlo*>(_eph.value(prn)->prev); 115 114 _eph.value(prn)->prev = _eph.value(prn)->last; … … 135 134 if (_eph.contains(prn)) { 136 135 t_ephGal* eLast = static_cast<t_ephGal*>(_eph.value(prn)->last); 137 if ( (eLast->GPSweek() < galeph.Week) || 138 (eLast->GPSweek() == galeph.Week && 139 eLast->TOC() < galeph.TOC) ) { 136 bncTime toc(galeph.Week, galeph.TOC); 137 if (eLast->TOC() < toc) { 140 138 delete static_cast<t_ephGal*>(_eph.value(prn)->prev); 141 139 _eph.value(prn)->prev = _eph.value(prn)->last; -
trunk/BNC/rinex/rnxnavfile.cpp
r4013 r4018 223 223 t_eph* eph = *it; 224 224 225 bncTime ephTime(eph->GPSweek(), eph->GPSweeks()); 226 double dt = ephTime - tt; 225 double dt = eph->TOC() - tt; 227 226 228 227 if (dt < 2*3600.0) {
Note:
See TracChangeset
for help on using the changeset viewer.