50 namespace multisense {
67 static ULARGE_INTEGER initOffsetSecondsSince1970 ()
69 SYSTEMTIME epochTimeAsSystemTime = { 1970, 1, 0, 1, 0, 0, 0, 0 };
70 FILETIME epochTimeAsFileTime;
71 SystemTimeToFileTime (&epochTimeAsSystemTime, &epochTimeAsFileTime);
73 ULARGE_INTEGER epochTime;
74 epochTime.LowPart = epochTimeAsFileTime.dwLowDateTime;
75 epochTime.HighPart = epochTimeAsFileTime.dwHighDateTime;
80 ULARGE_INTEGER TimeStamp::offsetSecondsSince1970 = initOffsetSecondsSince1970 ();
90 this->
time.tv_sec = 0;
91 this->
time.tv_usec = 0;
107 this->
time.tv_sec = (int) value;
108 this->
time.tv_usec = (int) ((value - this->
time.tv_sec) * 1000000);
116 this->
time.tv_sec = value.tv_sec;
117 this->
time.tv_usec = value.tv_usec;
147 double localTimeAtPps = local.tv_sec + (local.tv_usec / 1000000.0);
148 double remoteTimeAtPps = remote.tv_sec + (remote.tv_usec / 1000000.0);
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 - timeStamp.
time.tv_sec * 10000000) / 10);
202 gettimeofday(&timeStamp.
time, 0);
215 double currentTime = (double) timeStamp;
219 timeStamp = currentTime;
228 #endif // SENSORPOD_FIRMWARE 235 return this->
time.tv_sec;
243 return this->
time.tv_usec;
250 TimeStamp::operator double()
const 252 return this->
time.tv_sec + (this->
time.tv_usec / 1000000.0);
260 this->
time.tv_sec = ((
unsigned long) timeStamp);
261 this->
time.tv_usec = ((
unsigned long) ((timeStamp - this->
time.tv_sec) * 1000000));
273 this->
time.tv_sec += other.
time.tv_sec;
274 this->
time.tv_usec += other.
time.tv_usec;
282 this->
time.tv_sec -= other.
time.tv_sec;
283 this->
time.tv_usec -= other.
time.tv_usec;
291 while(this->
time.tv_usec < 0) {
292 this->
time.tv_usec += 1000000;
293 this->
time.tv_sec -= 1;
296 while(this->
time.tv_usec >= 1000000) {
297 this->
time.tv_usec -= 1000000;
298 this->
time.tv_sec += 1;
static double timeSynchronizationOffset
TimeStamp & operator=(double timeStamp)
ros::Time * timeStamp(M &m)
uint32_t getSeconds() const
void set(struct timeval &value)
static double getTimeSynchronizationOffset()
TimeStamp & operator+=(TimeStamp const &other)
TimeStamp & operator-=(TimeStamp const &other)
static TimeStamp getCurrentTime()
static void setTimeAtPps(TimeStamp &local, TimeStamp &remote)
uint32_t getMicroSeconds() const