51 namespace multisense {
61 #define timeradd(a, b, result) \ 64 (result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \ 65 (result)->tv_usec = (a)->tv_usec + (b)->tv_usec; \ 66 if ((result)->tv_usec >= 1000000) \ 69 (result)->tv_usec -= 1000000; \ 75 #define timersub(a, b, result) \ 78 (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ 79 (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ 80 if ((result)->tv_usec < 0) \ 83 (result)->tv_usec += 1000000; \ 94 static ULARGE_INTEGER initOffsetSecondsSince1970 ()
96 SYSTEMTIME epochTimeAsSystemTime = { 1970, 1, 0, 1, 0, 0, 0, 0 };
97 FILETIME epochTimeAsFileTime;
98 SystemTimeToFileTime (&epochTimeAsSystemTime, &epochTimeAsFileTime);
100 ULARGE_INTEGER epochTime;
101 epochTime.LowPart = epochTimeAsFileTime.dwLowDateTime;
102 epochTime.HighPart = epochTimeAsFileTime.dwHighDateTime;
107 ULARGE_INTEGER TimeStamp::offsetSecondsSince1970 = initOffsetSecondsSince1970 ();
117 this->
time.tv_sec = 0;
118 this->
time.tv_usec = 0;
126 this->
time.tv_sec = seconds;
127 this->
time.tv_usec = microSeconds;
135 this->
time.tv_sec = (long)(nanoseconds / 1000000000);
137 int64_t usec = (nanoseconds - (
static_cast<int64_t
>(this->
time.tv_sec) * 1000000000)) / 1000;
138 this->
time.tv_usec =
static_cast<int32_t
>(usec);
154 this->
time.tv_sec = value.tv_sec;
155 this->
time.tv_usec = value.tv_usec;
163 this->
time.tv_sec = seconds;
164 this->
time.tv_usec = microSeconds;
167 #ifndef SENSORPOD_FIRMWARE 190 FILETIME currentTimeAsFileTime;
191 GetSystemTimeAsFileTime (¤tTimeAsFileTime);
193 ULARGE_INTEGER currentTimeAsLargeInteger;
194 currentTimeAsLargeInteger.LowPart = currentTimeAsFileTime.dwLowDateTime;
195 currentTimeAsLargeInteger.HighPart = currentTimeAsFileTime.dwHighDateTime;
196 currentTimeAsLargeInteger.QuadPart -= offsetSecondsSince1970.QuadPart;
198 timeStamp.
time.tv_sec =
static_cast<long> (currentTimeAsLargeInteger.QuadPart / 10000000);
199 timeStamp.
time.tv_usec =
static_cast<long> ((currentTimeAsLargeInteger.QuadPart -
static_cast<int64_t
>(timeStamp.
time.tv_sec) * 10000000) / 10);
203 #if defined (USE_MONOTONIC_CLOCK) 208 if (0 != clock_gettime(CLOCK_MONOTONIC, &ts))
213 TIMESPEC_TO_TIMEVAL(&timeStamp.
time, &ts);
215 gettimeofday(&timeStamp.
time, 0);
223 #endif // SENSORPOD_FIRMWARE 230 return this->
time.tv_sec;
238 return this->
time.tv_usec;
243 return static_cast<int64_t
>(this->
time.tv_sec) * 1000000000 + static_cast<int64_t>(this->
time.tv_usec) * 1000;
248 struct timeval tmp_time;
250 tmp_time.tv_usec = 0;
251 timeradd(&this->
time, &other.
time, &tmp_time);
257 struct timeval tmp_time;
259 tmp_time.tv_usec = 0;
260 timersub(&this->
time, &other.
time, &tmp_time);
266 *
this = *
this + other;
272 *
this = *
this - other;
#define CRL_EXCEPTION(fmt,...)
ros::Time * timeStamp(M &m)
int64_t getNanoSeconds() const
TimeStamp & operator+=(TimeStamp const &other)
TimeStamp & operator-=(TimeStamp const &other)
static TimeStamp getCurrentTime()
int32_t getMicroSeconds() const
TimeStamp operator+(TimeStamp const &other) const
void set(const struct timeval &value)
TimeStamp operator-(TimeStamp const &other) const
int32_t getSeconds() const