Time.hpp
Go to the documentation of this file.
1 #include "sick_scan/sick_scan_base.h" /* Base definitions included in all header files, added by add_sick_scan_base_header.py. Do not edit this line. */
2 // Time.hpp
3 //
4 // created: June 6, 2011
5 //
6 // Mit "-lrt" linken!!
7 //
8 
9 #ifndef TIME_HPP
10 #define TIME_HPP
11 
12 
14 #ifdef WIN32
15 #include <sys/timeb.h>
16 #include <winsock2.h> // For struct timeval
17 #else
18 #include <sys/time.h>
19 #endif
20 #include <time.h>
21 
22 // Eine Zeitspanne, in [s]
24 {
25 public:
26  TimeDuration();
28 
29  void set(double seconds) { m_duration = seconds; }
30  inline UINT32 total_milliseconds();
31  inline TimeDuration& operator=(const double& seconds);
32 
33  double m_duration; // Zeit, in [s]
34 };
35 
36 // Fuer td = x;
38 {
40  return *this;
41 }
42 
43 // Zeitspanne als [ms]
45 {
46  UINT32 ms = (UINT32)((m_duration * 1000.0) + 0.5);
47  return ms;
48 }
49 
50 
51 class Time
52 {
53 public:
54  Time();
55  Time(timeval time);
56  ~Time();
57 
58  void set(double time);
59  void set(timeval time);
60  void set(UINT64 ntpSeconds, UINT32 ntpFractionalSeconds);
61  void set(UINT64 ntpTime);
62  double seconds();
64 
65  static Time now(); // Returns the current time
66 
67  Time operator+(const TimeDuration& dur) const;
68  Time& operator+=(const Time& other);
69  Time operator+(const Time& other) const;
70  Time operator-(const Time& other) const;
71  Time operator-(const double& seconds) const;
72  bool operator>=(const Time& other) const;
73  bool operator<(const Time& other) const;
74  bool operator==(const Time& other) const;
75 
76  std::string toString() const;
77  std::string toLongString() const;
78 
80 
81 private:
82  timeval m_time; // Zeit, in [s]
83 
84  static const double m_secondFractionNTPtoNanoseconds; // = 2^-32 * 1e9
85  static const double m_nanosecondsToSecondFractionNTP; // = 2^32 * 1e-9
86 };
87 
88 
89 #endif // TIME_HPP
Time::m_secondFractionNTPtoNanoseconds
static const double m_secondFractionNTPtoNanoseconds
Definition: Time.hpp:84
Time::now
static Time now()
Definition: Time.cpp:193
Time::operator+=
Time & operator+=(const Time &other)
Definition: Time.cpp:148
Time::toLongString
std::string toLongString() const
Definition: Time.cpp:74
Time::secondsFrom1900to1970
static const UINT64 secondsFrom1900to1970
Definition: Time.hpp:79
Time::operator>=
bool operator>=(const Time &other) const
Definition: Time.cpp:204
Time::toString
std::string toString() const
Definition: Time.cpp:63
Time::operator+
Time operator+(const TimeDuration &dur) const
Definition: Time.cpp:179
BasicDatatypes.hpp
Time::m_time
timeval m_time
Definition: Time.hpp:82
Time::~Time
~Time()
Definition: Time.cpp:55
Time::set
void set(double time)
Definition: Time.cpp:92
UINT64
uint64_t UINT64
Definition: BasicDatatypes.hpp:70
TimeDuration::set
void set(double seconds)
Definition: Time.hpp:29
TimeDuration::TimeDuration
TimeDuration()
Definition: Time.cpp:37
Time::operator-
Time operator-(const Time &other) const
Definition: Time.cpp:255
TimeDuration::m_duration
double m_duration
Definition: Time.hpp:33
TimeDuration::TimeDuration
TimeDuration(double seconds)
Definition: Time.hpp:27
Time
Definition: Time.hpp:51
TimeDuration
Definition: Time.hpp:23
ROS::seconds
double seconds(ROS::Duration duration)
Definition: ros_wrapper.cpp:180
sick_scan_base.h
Time::total_milliseconds
UINT32 total_milliseconds()
Definition: Time.cpp:137
Time::operator<
bool operator<(const Time &other) const
Definition: Time.cpp:222
Time::Time
Time()
Definition: Time.cpp:50
UINT32
uint32_t UINT32
Definition: BasicDatatypes.hpp:72
Time::m_nanosecondsToSecondFractionNTP
static const double m_nanosecondsToSecondFractionNTP
Definition: Time.hpp:85
Time::operator==
bool operator==(const Time &other) const
Definition: Time.cpp:242
TimeDuration::operator=
TimeDuration & operator=(const double &seconds)
Definition: Time.hpp:37
TimeDuration::total_milliseconds
UINT32 total_milliseconds()
Definition: Time.hpp:44
Time::seconds
double seconds()
Definition: Time.cpp:128


sick_scan_xd
Author(s): Michael Lehning , Jochen Sprickerhof , Martin Günther
autogenerated on Fri Oct 25 2024 02:47:12