Changeset 6812 in ntrip for trunk/BNC/src/ephemeris.cpp
- Timestamp:
- May 5, 2015, 3:44:39 PM (9 years ago)
- Location:
- trunk/BNC/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/src
- Property svn:ignore
-
old new 5 5 debug 6 6 release 7 html
-
- Property svn:ignore
-
trunk/BNC/src/ephemeris.cpp
r6809 r6812 259 259 } 260 260 } 261 }262 263 // Set GPS Satellite Position264 ////////////////////////////////////////////////////////////////////////////265 void t_ephGPS::set(const gpsephemeris* ee) {266 267 _receptDateTime = currentDateAndTimeGPS();268 269 if (PRN_GPS_START <= ee->satellite && ee->satellite <= PRN_GPS_END) {270 _prn.set('G', ee->satellite);271 }272 else if (PRN_QZSS_START <= ee->satellite && ee->satellite <= PRN_QZSS_END) {273 _prn.set('J', ee->satellite - PRN_QZSS_START + 1);274 }275 else {276 _checkState = bad;277 return;278 }279 280 _TOC.set(ee->GPSweek, ee->TOC);281 _clock_bias = ee->clock_bias;282 _clock_drift = ee->clock_drift;283 _clock_driftrate = ee->clock_driftrate;284 285 _IODE = ee->IODE;286 _Crs = ee->Crs;287 _Delta_n = ee->Delta_n;288 _M0 = ee->M0;289 290 _Cuc = ee->Cuc;291 _e = ee->e;292 _Cus = ee->Cus;293 _sqrt_A = ee->sqrt_A;294 295 _TOEsec = ee->TOE;296 _Cic = ee->Cic;297 _OMEGA0 = ee->OMEGA0;298 _Cis = ee->Cis;299 300 _i0 = ee->i0;301 _Crc = ee->Crc;302 _omega = ee->omega;303 _OMEGADOT = ee->OMEGADOT;304 305 _IDOT = ee->IDOT;306 _L2Codes = 0.0;307 _TOEweek = ee->GPSweek;308 _L2PFlag = 0.0;309 310 _ura = accuracyFromIndex(ee->URAindex, type());311 312 _health = ee->SVhealth;313 _TGD = ee->TGD;314 _IODC = ee->IODC;315 316 _TOT = 0.9999e9;317 _fitInterval = 0.0;318 261 } 319 262 … … 570 513 } 571 514 572 // Set Glonass Ephemeris573 ////////////////////////////////////////////////////////////////////////////574 void t_ephGlo::set(const glonassephemeris* ee) {575 576 _receptDateTime = currentDateAndTimeGPS();577 578 _prn.set('R', ee->almanac_number);579 580 int ww = ee->GPSWeek;581 int tow = ee->GPSTOW;582 updatetime(&ww, &tow, ee->tb*1000, 0); // Moscow -> GPS583 584 // Check the day once more585 // -----------------------586 bool timeChanged = false;587 {588 const double secPerDay = 24 * 3600.0;589 const double secPerWeek = 7 * secPerDay;590 int ww_old = ww;591 int tow_old = tow;592 int currentWeek;593 double currentSec;594 currentGPSWeeks(currentWeek, currentSec);595 bncTime currentTime(currentWeek, currentSec);596 bncTime hTime(ww, (double) tow);597 598 if (hTime - currentTime > secPerDay/2.0) {599 timeChanged = true;600 tow -= int(secPerDay);601 if (tow < 0) {602 tow += int(secPerWeek);603 ww -= 1;604 }605 }606 else if (hTime - currentTime < -secPerDay/2.0) {607 timeChanged = true;608 tow += int(secPerDay);609 if (tow > secPerWeek) {610 tow -= int(secPerWeek);611 ww += 1;612 }613 }614 615 if (false && timeChanged && BNC_CORE->mode() == t_bncCore::batchPostProcessing) {616 bncTime newHTime(ww, (double) tow);617 cout << "GLONASS " << ee->almanac_number << " Time Changed at "618 << currentTime.datestr() << " " << currentTime.timestr()619 << endl620 << "old: " << hTime.datestr() << " " << hTime.timestr()621 << endl622 << "new: " << newHTime.datestr() << " " << newHTime.timestr()623 << endl624 << "eph: " << ee->GPSWeek << " " << ee->GPSTOW << " " << ee->tb625 << endl626 << "ww, tow (old): " << ww_old << " " << tow_old627 << endl628 << "ww, tow (new): " << ww << " " << tow629 << endl << endl;630 }631 }632 633 bncTime hlpTime(ww, (double) tow);634 unsigned year, month, day;635 hlpTime.civil_date(year, month, day);636 _gps_utc = gnumleap(year, month, day);637 638 _TOC.set(ww, tow);639 _E = ee->E;640 _tau = ee->tau;641 _gamma = ee->gamma;642 _x_pos = ee->x_pos;643 _x_velocity = ee->x_velocity;644 _x_acceleration = ee->x_acceleration;645 _y_pos = ee->y_pos;646 _y_velocity = ee->y_velocity;647 _y_acceleration = ee->y_acceleration;648 _z_pos = ee->z_pos;649 _z_velocity = ee->z_velocity;650 _z_acceleration = ee->z_acceleration;651 _health = 0;652 _frequency_number = ee->frequency_number;653 _tki = ee->tk-3*60*60; if (_tki < 0) _tki += 86400;654 655 // Initialize status vector656 // ------------------------657 _tt = _TOC;658 659 _xv(1) = _x_pos * 1.e3;660 _xv(2) = _y_pos * 1.e3;661 _xv(3) = _z_pos * 1.e3;662 _xv(4) = _x_velocity * 1.e3;663 _xv(5) = _y_velocity * 1.e3;664 _xv(6) = _z_velocity * 1.e3;665 }666 667 515 // Compute Glonass Satellite Position (virtual) 668 516 //////////////////////////////////////////////////////////////////////////// … … 805 653 return; 806 654 } 807 _flags = 0;808 655 809 656 // RINEX Format … … 893 740 } else { 894 741 if (int(datasource) & (1<<8)) { 895 _flags |= GALEPHF_FNAV; 742 _fnav = true; 743 _inav = false; 896 744 } else if (int(datasource) & (1<<9)) { 897 _flags |= GALEPHF_INAV; 745 _fnav = false; 746 _inav = true; 898 747 } 899 748 } … … 909 758 } else { 910 759 // Bit 0 911 if (int(SVhealth) & (1<<0)) { 912 _flags |= GALEPHF_E1DINVALID; 913 } 760 _e1DataInValid = (int(SVhealth) & (1<<0)); 914 761 // Bit 1-2 915 762 _E1_bHS = double((int(SVhealth) >> 1) & 0x3); 916 763 // Bit 3 917 if (int(SVhealth) & (1<<3)) { 918 _flags |= GALEPHF_E5ADINVALID; 919 } 764 _e5aDataInValid = (int(SVhealth) & (1<<3)); 920 765 // Bit 4-5 921 766 _E5aHS = double((int(SVhealth) >> 4) & 0x3); 922 767 // Bit 6 923 if (int(SVhealth) & (1<<6)) { 924 _flags |= GALEPHF_E5BDINVALID; 925 } 768 _e5bDataInValid = (int(SVhealth) & (1<<6)); 926 769 // Bit 7-8 927 770 _E5bHS = double((int(SVhealth) >> 7) & 0x3); 928 771 929 772 if (prnStr.at(0) == 'E') { 930 _prn.set('E', prnStr.mid(1,2).toInt(), _flags); 931 } 932 else { 933 _prn.set('E', prnStr.mid(1,2).toInt(), _flags); 773 _prn.set('E', prnStr.mid(1,2).toInt(), _inav ? 1 : 0); 934 774 } 935 775 } … … 943 783 } 944 784 } 945 }946 947 // Set Galileo Satellite Position948 ////////////////////////////////////////////////////////////////////////////949 void t_ephGal::set(const galileoephemeris* ee) {950 951 _receptDateTime = currentDateAndTimeGPS();952 953 _flags = ee->flags;954 _prn.set('E', ee->satellite, _flags);955 956 _TOC.set(ee->Week, ee->TOC);957 _clock_bias = ee->clock_bias;958 _clock_drift = ee->clock_drift;959 _clock_driftrate = ee->clock_driftrate;960 961 _IODnav = ee->IODnav;962 _Crs = ee->Crs;963 _Delta_n = ee->Delta_n;964 _M0 = ee->M0;965 966 _Cuc = ee->Cuc;967 _e = ee->e;968 _Cus = ee->Cus;969 _sqrt_A = ee->sqrt_A;970 971 _TOEsec = _TOC.gpssec();972 // _TOEsec = ee->TOE; // TODO:973 974 _Cic = ee->Cic;975 _OMEGA0 = ee->OMEGA0;976 _Cis = ee->Cis;977 978 _i0 = ee->i0;979 _Crc = ee->Crc;980 _omega = ee->omega;981 _OMEGADOT = ee->OMEGADOT;982 983 _IDOT = ee->IDOT;984 _TOEweek = ee->Week;985 986 _SISA = accuracyFromIndex(ee->SISA, type());987 _E5aHS = ee->E5aHS;988 _E5bHS = ee->E5bHS;989 _E1_bHS = ee->E1_HS;990 _BGD_1_5A = ee->BGD_1_5A;991 _BGD_1_5B = ee->BGD_1_5B;992 993 _TOT = 0.9999e9;994 785 } 995 786 … … 1124 915 double BGD_1_5A = _BGD_1_5A; 1125 916 double BGD_1_5B = _BGD_1_5B; 1126 if ((_flags & GALEPHF_FNAV) == GALEPHF_FNAV) {917 if (_fnav) { 1127 918 dataSource |= (1<<1); 1128 919 dataSource |= (1<<8); … … 1130 921 // SVhealth 1131 922 // Bit 3 : E5a DVS 1132 if ( (_flags & GALEPHF_E5ADINVALID) == GALEPHF_E5ADINVALID) {923 if (_e5aDataInValid) { 1133 924 SVhealth |= (1<<3); 1134 925 } … … 1145 936 } 1146 937 } 1147 else if ((_flags & GALEPHF_INAV) == GALEPHF_INAV) {938 else if(_inav) { 1148 939 // Bit 2 and 0 are set because from MT1046 the data source cannot be determined 1149 940 // and RNXv3.03 says both can be set if the navigation messages were merged … … 1153 944 // SVhealth 1154 945 // Bit 0 : E1-B DVS 1155 if ( (_flags & GALEPHF_E1DINVALID) == GALEPHF_E1DINVALID) {946 if (_e1DataInValid) { 1156 947 SVhealth |= (1<<0); 1157 948 } … … 1168 959 } 1169 960 // Bit 3 : E5a DVS 1170 if ( (_flags & GALEPHF_E5ADINVALID) == GALEPHF_E5ADINVALID) {961 if (_e5aDataInValid) { 1171 962 SVhealth |= (1<<3); 1172 963 } … … 1183 974 } 1184 975 // Bit 6 : E5b DVS 1185 if ( (_flags & GALEPHF_E5BDINVALID) == GALEPHF_E5BDINVALID) {976 if (_e5bDataInValid) { 1186 977 SVhealth |= (1<<6); 1187 978 } … … 1322 1113 } 1323 1114 1324 // Set SBAS Satellite Position1325 ////////////////////////////////////////////////////////////////////////////1326 void t_ephSBAS::set(const sbasephemeris* ee) {1327 1328 _prn.set('S', ee->satellite - PRN_SBAS_START + 20);1329 _TOC.set(ee->GPSweek_TOE, double(ee->TOE));1330 1331 _IODN = ee->IODN;1332 _TOW = ee->TOW;1333 1334 _agf0 = ee->agf0;1335 _agf1 = ee->agf1;1336 1337 _x_pos = ee->x_pos;1338 _x_velocity = ee->x_velocity;1339 _x_acceleration = ee->x_acceleration;1340 1341 _y_pos = ee->y_pos;1342 _y_velocity = ee->y_velocity;1343 _y_acceleration = ee->y_acceleration;1344 1345 _z_pos = ee->z_pos;1346 _z_velocity = ee->z_velocity;1347 _z_acceleration = ee->z_acceleration;1348 1349 _ura = accuracyFromIndex(ee->URA, type());1350 1351 _health = 0;1352 }1353 1354 1115 // Compute SBAS Satellite Position (virtual) 1355 1116 //////////////////////////////////////////////////////////////////////////// … … 1426 1187 // ------------ 1427 1188 int fieldLen = 19; 1428 double TOEw;1429 1189 1430 1190 int pos[4]; … … 1461 1221 } 1462 1222 1463 _TOC _bdt.set(year, month, day, hour, min, sec);1223 _TOC.setBDS(year, month, day, hour, min, sec); 1464 1224 1465 1225 if ( readDbl(line, pos[1], fieldLen, _clock_bias ) || … … 1494 1254 1495 1255 else if ( iLine == 3 ) { 1496 if ( readDbl(line, pos[0], fieldLen, _TOEs 1256 if ( readDbl(line, pos[0], fieldLen, _TOEsec ) || 1497 1257 readDbl(line, pos[1], fieldLen, _Cic ) || 1498 1258 readDbl(line, pos[2], fieldLen, _OMEGA0) || … … 1515 1275 else if ( iLine == 5 ) { 1516 1276 if ( readDbl(line, pos[0], fieldLen, _IDOT ) || 1517 readDbl(line, pos[2], fieldLen, TOEw)) {1277 readDbl(line, pos[2], fieldLen, _TOEweek)) { 1518 1278 _checkState = bad; 1519 1279 return; … … 1535 1295 else if ( iLine == 7 ) { 1536 1296 double aodc; 1537 if ( readDbl(line, pos[0], fieldLen, _TOT s) ||1297 if ( readDbl(line, pos[0], fieldLen, _TOT) || 1538 1298 readDbl(line, pos[1], fieldLen, aodc) ) { 1539 1299 _checkState = bad; 1540 1300 return; 1541 1301 } 1542 if (_TOT s== 0.9999e9) { // 0.9999e9 means not known (RINEX standard)1543 _TOT s = _TOEs;1302 if (_TOT == 0.9999e9) { // 0.9999e9 means not known (RINEX standard) 1303 _TOT = _TOEsec; 1544 1304 } 1545 1305 _AODC = int(aodc); 1546 1306 } 1547 1307 } 1548 1549 TOEw += 1356; // BDT -> GPS week number1550 _TOE_bdt.set(int(TOEw), _TOEs);1551 1552 // GPS->BDT1553 // --------1554 _TOC = _TOC_bdt + 14.0;1555 _TOE = _TOE_bdt + 14.0;1556 1308 1557 1309 // remark: actually should be computed from second_tot 1558 1310 // but it seems to be unreliable in RINEX files 1559 _TOT = _TOC; 1560 } 1561 1562 // Set BDS Satellite Position 1563 //////////////////////////////////////////////////////////////////////////// 1564 void t_ephBDS::set(const bdsephemeris* ee) { 1565 1566 // RTCM usage: set RINEX File entries to zero 1567 // ------------------------------------------ 1568 _TOTs = 0.0; 1569 _TOEs = 0.0; 1570 1571 _receptDateTime = currentDateAndTimeGPS(); 1572 1573 _prn.set('C', ee->satellite - PRN_BDS_START + 1); 1574 1575 _TOE_bdt.set(1356 + ee->BDSweek, ee->TOE); 1576 _TOE = _TOE_bdt + 14.0; 1577 1578 _TOC_bdt.set(1356 + ee->BDSweek, ee->TOC); 1579 _TOC = _TOC_bdt + 14.0; 1580 1581 _AODE = ee->AODE; 1582 _AODC = ee->AODC; 1583 1584 _clock_bias = ee->clock_bias; 1585 _clock_drift = ee->clock_drift; 1586 _clock_driftrate = ee->clock_driftrate; 1587 1588 _Crs = ee->Crs; 1589 _Delta_n = ee->Delta_n; 1590 _M0 = ee->M0; 1591 1592 _Cuc = ee->Cuc; 1593 _e = ee->e; 1594 _Cus = ee->Cus; 1595 _sqrt_A = ee->sqrt_A; 1596 1597 _Cic = ee->Cic; 1598 _OMEGA0 = ee->OMEGA0; 1599 _Cis = ee->Cis; 1600 1601 _i0 = ee->i0; 1602 _Crc = ee->Crc; 1603 _omega = ee->omega; 1604 _OMEGADOT = ee->OMEGADOT; 1605 1606 _IDOT = ee->IDOT; 1607 1608 _URA = accuracyFromIndex(ee->URAI, type()); 1609 _SatH1 = (ee->flags & BDSEPHF_SATH1) ? 1: 0; 1610 _TGD1 = ee->TGD_B1_B3; 1611 _TGD2 = ee->TGD_B2_B3; 1311 _TOT = _TOC.bdssec(); 1612 1312 } 1613 1313 … … 1746 1446 QString t_ephBDS::toString(double version) const { 1747 1447 1748 QString rnxStr = rinexDateStr(_TOC _bdt, _prn, version);1448 QString rnxStr = rinexDateStr(_TOC-14.0, _prn, version); 1749 1449 1750 1450 QTextStream out(&rnxStr); … … 1769 1469 .arg(_sqrt_A, 19, 'e', 12); 1770 1470 1771 double toes = _TOEs ;1471 double toes = _TOEsec; 1772 1472 if (!toes) { // RTCM stream input 1773 toes = _TOE _bdt.gpssec();1473 toes = _TOE.bdssec(); 1774 1474 } 1775 1475 out << QString(fmt) … … 1788 1488 .arg(_IDOT, 19, 'e', 12) 1789 1489 .arg(0.0, 19, 'e', 12) 1790 .arg(double(_TOE _bdt.gpsw() - 1356.0),19, 'e', 12)1490 .arg(double(_TOE.bdsw()), 19, 'e', 12) 1791 1491 .arg(0.0, 19, 'e', 12); 1792 1492 … … 1797 1497 .arg(_TGD2, 19, 'e', 12); 1798 1498 1799 double tots = _TOT s;1499 double tots = _TOT; 1800 1500 if (!tots) { // RTCM stream input 1801 tots = _TOE _bdt.gpssec();1501 tots = _TOE.bdssec(); 1802 1502 } 1803 1503 out << QString(fmt) … … 1808 1508 return rnxStr; 1809 1509 } 1810
Note:
See TracChangeset
for help on using the changeset viewer.