Epoch.hpp

Go to the documentation of this file.
00001 #pragma ident "$Id: Epoch.hpp 1163 2008-03-28 13:01:33Z snelsen $"
00002 
00003 
00004 
00010 #ifndef GPSTK_EPOCH_HPP
00011 #define GPSTK_EPOCH_HPP
00012 
00013 //============================================================================
00014 //
00015 //  This file is part of GPSTk, the GPS Toolkit.
00016 //
00017 //  The GPSTk is free software; you can redistribute it and/or modify
00018 //  it under the terms of the GNU Lesser General Public License as published
00019 //  by the Free Software Foundation; either version 2.1 of the License, or
00020 //  any later version.
00021 //
00022 //  The GPSTk is distributed in the hope that it will be useful,
00023 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00024 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00025 //  GNU Lesser General Public License for more details.
00026 //
00027 //  You should have received a copy of the GNU Lesser General Public
00028 //  License along with GPSTk; if not, write to the Free Software Foundation,
00029 //  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00030 //  
00031 //  Copyright 2004, The University of Texas at Austin
00032 //
00033 //============================================================================
00034 
00035 //============================================================================
00036 //
00037 //This software developed by Applied Research Laboratories at the University of
00038 //Texas at Austin, under contract to an agency or agencies within the U.S. 
00039 //Department of Defense. The U.S. Government retains all rights to use,
00040 //duplicate, distribute, disclose, or release this software. 
00041 //
00042 //Pursuant to DoD Directive 523024 
00043 //
00044 // DISTRIBUTION STATEMENT A: This software has been approved for public 
00045 //                           release, distribution is unlimited.
00046 //
00047 //=============================================================================
00048 
00049 #include "MathBase.hpp"
00050 #include "Exception.hpp"
00051 #include "StringUtils.hpp"
00052 
00053 #include "GPSZcount.hpp"
00054 #include "CommonTime.hpp"
00055 #include "TimeTag.hpp"
00056 #include "SystemTime.hpp"
00057 #include "YDSTime.hpp"
00058 
00059 namespace gpstk
00060 {
00063 
00119    class Epoch
00120    {
00121    public:
00128       NEW_EXCEPTION_CLASS(EpochException, gpstk::Exception);
00129       
00134       NEW_EXCEPTION_CLASS(FormatException, gpstk::Exception);
00135       
00143 
00144       static const double ONE_NSEC_TOLERANCE;
00146       static const double ONE_USEC_TOLERANCE;
00148       static const double ONE_MSEC_TOLERANCE;
00150       static const double ONE_SEC_TOLERANCE;
00152       static const double ONE_MIN_TOLERANCE;
00154       static const double ONE_HOUR_TOLERANCE;
00155       
00157       static double EPOCH_TOLERANCE;
00158       
00160       static const Epoch BEGINNING_OF_TIME;
00162       static const Epoch END_OF_TIME;
00163 
00165       static std::string PRINT_FORMAT;
00167       
00169 
00170 
00171       static double setEpochTolerance(double tol)
00172          throw()
00173       { return EPOCH_TOLERANCE = tol; }
00174 
00176       static double getEpochTolerance() 
00177          throw()
00178       { return EPOCH_TOLERANCE; }
00179    
00187       Epoch& setTolerance(double tol)
00188          throw();
00189 
00194       double getTolerance() throw()
00195       { return tolerance; }
00197 
00199 
00200 
00211       Epoch(const TimeTag& tt = SystemTime())
00212          throw(EpochException);
00213 
00218       Epoch(const CommonTime& ct)
00219          throw();
00220 
00230       Epoch(const TimeTag& tt,
00231             short year)
00232          throw(EpochException);
00233 
00237       Epoch(const GPSZcount& gzc)
00238          throw();
00239       
00240          // Other Constructors:
00241          // gps 29-bit zcount w/ epoch determined by current system time
00242          //     (GPSZcount29 + SystemTime)
00243 
00245       ~Epoch()
00246          throw()
00247       {}
00249 
00251 
00252 
00253       Epoch(const Epoch &right)
00254          throw();
00255 
00257       Epoch& operator=(const Epoch& right)
00258          throw();
00260       
00262 
00263 
00268       double operator-(const Epoch& right) const
00269          throw();
00270 
00276       Epoch operator+(double sec) const
00277          throw(EpochException);
00278 
00284       Epoch operator-(double sec) const
00285          throw(EpochException);
00286 
00292       Epoch& operator+=(double sec)
00293          throw(EpochException);
00294 
00300       Epoch& operator-=(double sec)
00301          throw(EpochException);
00302 
00308       Epoch& addSeconds(double seconds)
00309          throw(EpochException);
00310 
00316       Epoch& addSeconds(long seconds)
00317          throw(EpochException);
00318 
00324       Epoch& addMilliSeconds(long msec)
00325          throw(EpochException);
00326 
00332       Epoch& addMicroSeconds(long usec)
00333          throw(EpochException);
00335 
00337 
00338       bool operator==(const Epoch &right) const
00339          throw();
00340       bool operator!=(const Epoch &right) const
00341          throw();
00342       bool operator<(const Epoch &right) const
00343          throw();
00344       bool operator>(const Epoch &right) const
00345          throw();
00346       bool operator<=(const Epoch &right) const
00347          throw();
00348       bool operator>=(const Epoch &right) const
00349          throw();
00351 
00353 
00354 
00355 
00356 
00357       template <class TimeTagType>
00358       TimeTagType get() const
00359          throw(EpochException);
00360 
00364       inline long double JD() const
00365          throw(EpochException);
00366 
00370       inline long double MJD() const
00371          throw(EpochException);
00372 
00374       inline short year() const
00375          throw(EpochException);
00376 
00378       inline short month() const
00379          throw(EpochException);
00380 
00382       inline short day() const
00383          throw(EpochException);
00384 
00386       inline short dow() const
00387          throw(EpochException);
00388 
00390       inline short hour() const
00391          throw(EpochException);
00392 
00394       inline short minute() const
00395          throw(EpochException);
00396 
00398       inline double second() const
00399          throw(EpochException);
00400 
00402       inline double sod() const
00403          throw(EpochException);
00404 
00406       inline short GPSweek10() const
00407          throw(EpochException);
00408 
00410       inline long GPSzcount() const
00411          throw(EpochException);
00412 
00414       inline long GPSzcountFloor() const
00415          throw(EpochException);
00416 
00422       inline unsigned long GPSzcount32() const
00423          throw(EpochException);
00424 
00426       inline unsigned long GPSzcount32Floor() const
00427          throw(EpochException);
00428 
00430       inline double GPSsow() const
00431          throw(EpochException);
00432 
00434       inline short GPSweek() const
00435          throw(EpochException);
00436 
00438       inline short doy() const
00439          throw(EpochException);
00440 
00444       inline long double getMJDasLongDouble() const
00445          throw(EpochException);
00446 
00448       inline struct timeval unixTime() const
00449          throw(EpochException);
00450 
00452       operator GPSZcount() const
00453          throw(EpochException);
00454 
00456       operator CommonTime() const
00457          throw();
00458 
00462 
00468       Epoch& set(const TimeTag& tt = SystemTime())
00469          throw(EpochException);
00470       
00476       Epoch& set(const TimeTag& tt,
00477                  short year)
00478          throw(EpochException);
00479       
00485       Epoch& set(const CommonTime& c)
00486          throw();
00487 
00491       Epoch& set(const GPSZcount& z)
00492          throw(EpochException);
00493 
00500       Epoch& setTime(const CommonTime& ct)
00501          throw(EpochException);
00502 
00509       Epoch& setDate(const CommonTime& ct)
00510          throw(EpochException);
00511 
00516       Epoch& setLocalTime()
00517          throw(EpochException);
00518 
00519          // other sets:
00520          // ymdhms
00521          // week and sow (if week is 10-bit, set epoch from system time)
00522          // week and zcount (if week is 10-bit, set epoch from system time) 
00523          // week, zcount, year (if week is 10-bit, set epoch from given year)
00524          // week, sow, year  (if week is 10-bit, set epoch from given year)
00525          // gps 29-bit zcount (epoch determined by system time)
00526          // gps full week and sow
00527          // gps full week and zcount
00528          // year, doy, sod
00529          // long double mjd
00530          // double mjd
00531          // Unix struct timeval
00532          // ANSI time
00533          // YMD, (year/doy) w/ time unchanged
00534          // HMS, sod w/ date unchanged
00536 
00538 
00539 
00540 
00541 
00591       Epoch& scanf(const std::string& str, 
00592                    const std::string& fmt)
00593          throw(StringUtils::StringException);
00594 
00595          // if you can see this, ignore the \'s below, as they are for
00596          // the nasty html-ifying of doxygen.  Browsers try and
00597          // interpret the % and they get all messed up.
00643       std::string printf(const std::string& fmt = PRINT_FORMAT) const
00644          throw(StringUtils::StringException);
00646 
00647    private:
00649 
00650 
00651 
00652       CommonTime core;
00653       
00655       double tolerance;    
00656       
00659       short whichGPSEpoch(int week, int year) const
00660          throw(EpochException);
00662    };   // end class Epoch
00663 
00665 
00666 
00672    std::ostream& operator<<( std::ostream& s,
00673                              const Epoch& t );
00675 
00676 
00677 }  // namespace gpstk
00678 
00679 #endif   // GPSTK_EPOCH_HPP

Generated on Tue May 22 03:30:58 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1