Changeset 6812 in ntrip for trunk/BNC/src/bnctime.cpp


Ignore:
Timestamp:
May 5, 2015, 3:44:39 PM (9 years ago)
Author:
stoecker
Message:

integrate RTCM3 parsing into BNC and directly fill target structures, add doxygen documentation

Location:
trunk/BNC/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/src

    • Property svn:ignore
      •  

        old new  
        55debug
        66release
         7html
  • trunk/BNC/src/bnctime.cpp

    r5886 r6812  
    5353//
    5454//////////////////////////////////////////////////////////////////////////////
     55bncTime &bncTime::set(int msec) {
     56  int week;
     57  double sec;
     58
     59  currentGPSWeeks(week, sec);
     60  if(msec/1000.0 < sec - 86400.0)
     61    ++week;
     62  return set(week, msec/1000.0);
     63}
     64
     65//
     66//////////////////////////////////////////////////////////////////////////////
     67bncTime &bncTime::setTOD(int msec) {
     68  int week;
     69  double sec;
     70
     71  currentGPSWeeks(week, sec);
     72  int intsec = sec;
     73  int day = intsec/(24*60*60);
     74  int tod = (intsec%(24*60*60))*1000;
     75  if(msec > 19*60*60*1000 && tod < 5*60*60*1000)
     76    --day;
     77  else if(msec < 5*60*60 && tod > 19*60*60*1000)
     78    ++day;
     79  msec += day*24*60*60*1000;
     80  if(msec < 0.0) {
     81    msec += 7*24*60*60*1000;
     82    --week;
     83  }
     84
     85  return set(week, msec/1000.0);
     86}
     87
     88//
     89//////////////////////////////////////////////////////////////////////////////
     90bncTime &bncTime::setTk(int msec) {
     91  int week;
     92  double sec;
     93  int intsec;
     94
     95  currentGPSWeeks(week, sec);
     96  intsec = sec;
     97  updatetime(&week, &intsec, msec, 0); /* Moscow -> GPS */
     98  sec = intsec+(msec%1000)/1000.0;
     99  return set(week, sec);
     100}
     101
     102//
     103//////////////////////////////////////////////////////////////////////////////
     104bncTime &bncTime::setBDS(int msec) {
     105  int week;
     106  double sec;
     107
     108  msec += 14000;
     109  if(msec >= 7*24*60*60*1000)
     110    msec -= 7*24*60*60*1000;
     111  currentGPSWeeks(week, sec);
     112  if(msec/1000.0 < sec - 86400.0)
     113    ++week;
     114  return set(week, msec/1000.0);
     115}
     116
     117//
     118//////////////////////////////////////////////////////////////////////////////
    55119bncTime& bncTime::setmjd(double daysec, int mjd) {
    56120  _sec = daysec;
     
    105169}
    106170
     171//
     172//////////////////////////////////////////////////////////////////////////////
     173unsigned int bncTime::bdsw() const {
     174  double   gsec;
     175  long     gpsw;
     176  jdgp(_mjd, gsec, gpsw);
     177  if(gsec <= 14.0)
     178    gpsw -= 1;
     179  return (int)gpsw-1356;
     180}
     181
     182//
     183//////////////////////////////////////////////////////////////////////////////
     184double bncTime::bdssec() const {
     185  double   gsec;
     186  long     gpsw;
     187  jdgp(_mjd, gsec, gpsw);
     188  if(gsec <= 14.0)
     189    gsec += 7.0*24.0*60.0*60.0-14.0;
     190  else
     191    gsec -= 14.0;
     192  return gsec + _sec;
     193}
     194
    107195//
    108196//////////////////////////////////////////////////////////////////////////////
    109197bool bncTime::operator!=(const bncTime &time1) const {
    110   if ( ((*this) - time1) != 0.0 ) {
     198  if ( fabs((*this) - time1) > 0.000000000001 ) {
    111199    return true;
    112200  }
     
    119207//////////////////////////////////////////////////////////////////////////////
    120208bool bncTime::operator==(const bncTime &time1) const {
    121   if ( ((*this) - time1) == 0.0 ) {
     209  if ( fabs((*this) - time1) < 0.000000000001 ) {
    122210    return true;
    123211  }
     
    294382//
    295383//////////////////////////////////////////////////////////////////////////////
    296 bncTime::operator string() const {
     384bncTime::operator std::string() const {
    297385  return datestr() + '_' + timestr();
    298386}
     
    303391                      int hour, int min, double sec) {
    304392  return set(year, month, day, hour*3600 + min*60 + sec);
     393}
     394
     395//
     396//////////////////////////////////////////////////////////////////////////////
     397bncTime& bncTime::setBDS(int year, int month, int day,
     398                      int hour, int min, double sec) {
     399  return set(year, month, day, hour*3600 + min*60 + sec+14.0);
    305400}
    306401
Note: See TracChangeset for help on using the changeset viewer.