provides utility functions for getting the current time
More...
#include <ArmarXCore/core/time/TimeUtil.h>
provides utility functions for getting the current time
Definition at line 130 of file TimeUtil.h.
◆ TimeUtil()
◆ GetTime() [1/2]
IceUtil::Time GetTime |
( |
bool |
forceSystemTime | ) |
|
|
static |
get the current time
- Parameters
-
forceSystemTime | If true, this function will always return the time of the system and never the virtual time. |
- Returns
- the current time
Depending on if a TimeServer is used, the system time or the TimeServer time is returned
Definition at line 54 of file TimeUtil.cpp.
◆ GetTime() [2/2]
Get the current time.
- Parameters
-
timeMode | Time mode to be used. |
- Returns
- The current time considering timeMode
Definition at line 42 of file TimeUtil.cpp.
◆ GetTimeServer()
◆ GetTimeSince() [1/2]
IceUtil::Time GetTimeSince |
( |
IceUtil::Time |
referenceTime, |
|
|
bool |
forceSystemTime |
|
) |
| |
|
static |
Get the difference between the current time and a reference time.
- Parameters
-
referenceTime | Reference point in time. |
forceSystemTime | If true, this function will always return the time of the system and never the virtual time. |
- Returns
- Current timestamp minus the given reference time to get the delta.
Definition at line 71 of file TimeUtil.cpp.
◆ GetTimeSince() [2/2]
Get the difference between the current time and a reference time.
- Parameters
-
referenceTime | Reference point in time. |
timeMode | Time mode to be used. |
- Returns
- Current timestamp minus the given reference time to get the delta.
Definition at line 66 of file TimeUtil.cpp.
◆ HasTimeServer()
check if we have been initialized with a Timeserver
Definition at line 114 of file TimeUtil.cpp.
◆ MSSleep()
void MSSleep |
( |
int |
durationMS | ) |
|
|
static |
lock the calling thread for a given duration (like usleep(...) but using Timeserver time)
- Parameters
-
durationMS | how long to sleep in milliseconds |
Definition at line 94 of file TimeUtil.cpp.
◆ NanoSleep()
int NanoSleep |
( |
long |
usec | ) |
|
|
static |
Nanosleep convenience function.
- Note
- This function does not use virtual time!
Definition at line 153 of file TimeUtil.cpp.
◆ SetTimeServer()
◆ Sleep() [1/3]
static void Sleep |
( |
float |
seconds | ) |
|
|
inlinestatic |
◆ Sleep() [2/3]
void Sleep |
( |
IceUtil::Time |
duration | ) |
|
|
static |
lock the calling thread for a given duration (like usleep(...) but using Timeserver time)
- Parameters
-
duration | how long to sleep |
Sleep for the given duration using timeserver time. Granularity is limited to 1 ms when a Timeserver is running (else 1 us).
Definition at line 76 of file TimeUtil.cpp.
◆ Sleep() [3/3]
static void Sleep |
( |
std::chrono::duration< Rep, Period > |
d | ) |
|
|
inlinestatic |
lock the calling thread for a given duration (like usleep(...) but using Timeserver time)
- Parameters
-
duration | how long to sleep |
Sleep for the given duration using timeserver time. Granularity is limited to 1 ms when a Timeserver is running (else 1 us).
Definition at line 186 of file TimeUtil.h.
◆ SleepMS()
static void SleepMS |
( |
float |
milliseconds | ) |
|
|
inlinestatic |
◆ SleepUS()
static void SleepUS |
( |
float |
microseconds | ) |
|
|
inlinestatic |
◆ toStringDate()
std::string toStringDate |
( |
const IceUtil::Time & |
time | ) |
|
|
static |
Return a date string like "2020-01-31" (Y-M-D).
Definition at line 162 of file TimeUtil.cpp.
◆ toStringDateTime()
std::string toStringDateTime |
( |
const IceUtil::Time & |
time | ) |
|
|
static |
Return a date & time string like "2020-01-31_15-30-05" (Y-M-D_H-M-S).
Definition at line 172 of file TimeUtil.cpp.
◆ toStringTime()
std::string toStringTime |
( |
const IceUtil::Time & |
time | ) |
|
|
static |
Return a time string like "15-30-05" (H-M-S).
Definition at line 167 of file TimeUtil.cpp.
◆ USleep()
like timed_wait on boost condition_variables, but with timeserver support
The implementation only checks for timeout periodically (see granularity parameter), so precision is limited
- Parameters
-
cond | the boost::condition_variable to wait on (as shared_ptr) |
lock | an already locked unique_lock |
duration | timeout |
granularity | how often timeout is checked, default is to use a tenth of duration |
- Returns
- false, if the thread was unlocked due to a timeout, else true Usleep convenience function that uses internally nanosleep.
- Note
- This function does not use virtual time!
Definition at line 148 of file TimeUtil.cpp.
◆ WaitForNextTick()
block until the next tick of the timeserver.
Noop if no timeserver in use.
Can be used to pause execution if the timeserver is paused. If the timeserver is runing, this may block for up to one tick interval (typically 1ms).
Definition at line 104 of file TimeUtil.cpp.
◆ timeServerPtr
The documentation for this class was generated from the following files: