Fawkes API
Fawkes Development Version
|
A class for handling time. More...
#include <>>
Public Member Functions | |
Time () | |
Constructor. | |
Time (const timeval *tv) | |
Constructor. | |
Time (long sec, long usec, Clock *clock=0) | |
Constructor. | |
Time (long ms) | |
Constructor. | |
Time (double sec) | |
Constructor. | |
Time (Clock *clock) | |
Constructor. | |
Time (const Time &t) | |
Copy constructor. | |
Time (const Time *t) | |
Copy constructor. | |
~Time () | |
Destructor. | |
double | in_sec () const |
Convet time to seconds. | |
long | in_msec () const |
Convert the stored time into milli-seconds. | |
long | in_usec () const |
Convert the stored time into micro-seconds. | |
const timeval * | get_timeval () const |
Obtain the timeval where the time is stored. | |
long | get_sec () const |
Get seconds. | |
long | get_msec () const |
Get milliseconds. | |
long | get_usec () const |
Get microseconds. | |
long | get_nsec () const |
Get nanoseconds. | |
void | get_timestamp (long &sec, long &usec) const |
Get time stamp. | |
bool | is_zero () const |
Check if time is zero. | |
void | set_time (const timeval *tv) |
Sets the time. | |
void | set_time (long int sec, long int usec) |
Sets the time. | |
void | set_time (long ms) |
Sets the time. | |
void | set_time (double sec) |
Sets the time. | |
void | set_time (const Time &t) |
Set time to given time. | |
void | set_time (const Time *t) |
Set time to given time. | |
void | set_clock (Clock *clock) |
Set clock for this instance. | |
void | add (double seconds) |
Add seconds. | |
Time & | stamp () |
Set this time to the current time. | |
Time & | stamp_systime () |
Set this time to the current system time. | |
Time | operator+ (const double sec) const |
Operator that adds times. | |
Time | operator+ (const long int usec) const |
Operator to add usec value. | |
Time | operator+ (const Time &t) const |
Operator that adds times. | |
Time | operator+ (const Time *t) const |
Operator that adds times. | |
Time | operator- (const Time &t) const |
Operator that substracts one Time from another. | |
double | operator- (const Time *t) const |
Operator that substracts one Time from another. | |
Time | operator- (const long int usec) const |
Operator that subtracts some time. | |
Time | operator- (const double sec) const |
Operator that subtracts some time. | |
Time & | operator+= (const long int usec) |
+= operator | |
Time & | operator+= (const Time &t) |
+= operator | |
Time & | operator+= (const double sec) |
+= operator for double seconds | |
Time & | operator-= (const Time &t) |
-= operator. | |
Time & | operator-= (const double sec) |
-= operator. | |
Time & | operator-= (const long int usec) |
-= operator. | |
Time & | operator= (const Time &t) |
Assign operator. | |
bool | operator== (const Time &t) const |
Check equality of times. | |
bool | operator== (const Time *t) const |
Check equality of times. | |
bool | operator!= (const Time &t) const |
Check inequality of times. | |
bool | operator!= (const Time *t) const |
Check inequality of times. | |
bool | operator> (const Time &t) const |
Greater than operator. | |
bool | operator> (const Time *t) const |
Greater than operator. | |
bool | operator>= (const Time &t) const |
Greater than or equal to operator. | |
bool | operator>= (const Time *t) const |
Greater than or equal to operator. | |
bool | operator< (const Time &t) const |
Less than operator. | |
bool | operator< (const Time *t) const |
Less than operator. | |
bool | operator<= (const Time &t) const |
Less than or equal to operator. | |
bool | operator<= (const Time *t) const |
Less than or equal to operator. | |
void | wait () |
Wait (sleep) for this time. | |
void | wait_systime () |
Wait (sleep) for this system time. | |
const char * | str (bool utc=false) const |
Output function. | |
void | str_r (char *s, bool utc=false) |
Output function. |
Static Public Attributes | |
static const unsigned int | TIMESTR_SIZE = 26 |
Maximum size of string returned by str() and the minimum size of the string passwd to str_r(). |
Friends | |
class | Clock |
fawkes::Time::Time | ( | ) |
fawkes::Time::Time | ( | const timeval * | tv | ) |
fawkes::Time::Time | ( | long | sec, |
long | usec, | ||
Clock * | clock = 0 |
||
) |
Constructor.
Sets time to the given time. Basically the same as setting from a timeval struct but the components are given separately.
sec | time in seconds since the epoch (or time range) |
usec | fractions in microseconds added to sec |
clock | optional clock to use, if NULL Clock::instance() will be used |
fawkes::Time::Time | ( | long | ms | ) |
fawkes::Time::Time | ( | double | s | ) |
fawkes::Time::Time | ( | Clock * | clock | ) |
Constructor.
This constructor uses the supplied clock for setting the time. The time is set to the current time.
clock | clock |
Definition at line 176 of file time.cpp.
References fawkes::Clock::get_time().
fawkes::Time::Time | ( | const Time & | t | ) |
fawkes::Time::Time | ( | const Time * | t | ) |
void fawkes::Time::add | ( | double | seconds | ) |
Add seconds.
The effect is equivalent to operator+=(const double sec), but this can be used when the operator is not available (i.e. wrapper languages) and it does not return itself.
seconds | time in seconds to add |
|
inline |
|
inline |
Get nanoseconds.
Definition at line 113 of file time.h.
Referenced by RosLaserScanThread::bb_interface_data_changed(), RosTfThread::bb_interface_data_changed(), and RosPointCloudThread::loop().
|
inline |
Get seconds.
Definition at line 110 of file time.h.
Referenced by RosLaserScanThread::bb_interface_data_changed(), RosTfThread::bb_interface_data_changed(), RobotinoRosJointsThread::loop(), RosImagesThread::loop(), and RosPointCloudThread::loop().
|
inline |
Get time stamp.
sec | upon return contains seconds stored in time stamp |
usec | upon return contains microseconds stored in time stamp |
Definition at line 114 of file time.h.
Referenced by fawkes::Interface::write().
|
inline |
Obtain the timeval where the time is stored.
Definition at line 109 of file time.h.
Referenced by BBLoggerThread::BBLoggerThread(), BlackBoardLoggerPlugin::BlackBoardLoggerPlugin(), fawkes::Clock::ext_to_realtime(), fawkes::SimulatorTimeSource::get_time(), and firevision::SharedMemoryImageBuffer::set_capture_time().
|
inline |
Get microseconds.
Definition at line 112 of file time.h.
Referenced by fawkes::PointCloudManager::PointCloudStorageAdapter< PointT >::get_time(), RobotinoRosJointsThread::loop(), and RosImagesThread::loop().
long fawkes::Time::in_msec | ( | ) | const |
Convert the stored time into milli-seconds.
Definition at line 242 of file time.cpp.
Referenced by fawkes::WorldInfoDataContainer::check_timeout(), and XabslEngineThread::current_time().
double fawkes::Time::in_sec | ( | ) | const |
Convet time to seconds.
Convert the stored time in a floating point number representing the number of seconds. For a time the integral part is the number of seconds since the epoch, for ranges you get the value as a float second.
Definition at line 232 of file time.cpp.
Referenced by fawkes::SimulatorTimeSource::conv_to_realtime(), and BBLogReplayThread::loop().
long fawkes::Time::in_usec | ( | ) | const |
|
inline |
Check if time is zero.
Definition at line 116 of file time.h.
Referenced by FvRetrieverThread::init().
bool fawkes::Time::operator!= | ( | const Time & | t | ) | const |
bool fawkes::Time::operator!= | ( | const Time * | t | ) | const |
Time fawkes::Time::operator+ | ( | const double | sec | ) | const |
Time fawkes::Time::operator+ | ( | const long int | usec | ) | const |
Time & fawkes::Time::operator+= | ( | const long int | usec | ) |
Time & fawkes::Time::operator+= | ( | const double | sec | ) |
double fawkes::Time::operator- | ( | const Time * | t | ) | const |
Operator that substracts one Time from another.
t | the Time that is substracted |
Definition at line 460 of file time.cpp.
References fawkes::time_diff_sec().
Time fawkes::Time::operator- | ( | const long int | usec | ) | const |
Time fawkes::Time::operator- | ( | const double | sec | ) | const |
Time & fawkes::Time::operator-= | ( | const double | sec | ) |
Time & fawkes::Time::operator-= | ( | const long int | usec | ) |
bool fawkes::Time::operator< | ( | const Time & | t | ) | const |
bool fawkes::Time::operator< | ( | const Time * | t | ) | const |
bool fawkes::Time::operator<= | ( | const Time & | t | ) | const |
bool fawkes::Time::operator<= | ( | const Time * | t | ) | const |
bool fawkes::Time::operator== | ( | const Time & | t | ) | const |
bool fawkes::Time::operator== | ( | const Time * | t | ) | const |
bool fawkes::Time::operator> | ( | const Time & | t | ) | const |
bool fawkes::Time::operator> | ( | const Time * | t | ) | const |
bool fawkes::Time::operator>= | ( | const Time & | t | ) | const |
bool fawkes::Time::operator>= | ( | const Time * | t | ) | const |
void fawkes::Time::set_clock | ( | Clock * | clock | ) |
Set clock for this instance.
clock | clock to use from now on |
Definition at line 329 of file time.cpp.
Referenced by StaticTransformsThread::init(), OpenNiContextThread::init(), NaoQiButtonThread::init(), KatanaActThread::init(), and fawkes::Interface::set_clock().
void fawkes::Time::set_time | ( | const timeval * | tv | ) |
Sets the time.
tv | set the time to this value |
Definition at line 262 of file time.cpp.
Referenced by fawkes::Clock::ext_to_realtime(), fawkes::PointCloudManager::PointCloudStorageAdapter< PointT >::get_time(), StaticTransformsThread::init(), KatanaActThread::init(), fawkes::Watch::pause(), fawkes::Interface::read(), fawkes::Watch::reset(), fawkes::Watch::start(), and fawkes::Watch::stop().
void fawkes::Time::set_time | ( | long int | sec, |
long int | usec | ||
) |
void fawkes::Time::set_time | ( | long | ms | ) |
void fawkes::Time::set_time | ( | double | s | ) |
void fawkes::Time::set_time | ( | const Time & | t | ) |
void fawkes::Time::set_time | ( | const Time * | t | ) |
Time & fawkes::Time::stamp | ( | ) |
Set this time to the current time.
Definition at line 783 of file time.cpp.
Referenced by RosLaserScanThread::bb_interface_data_changed(), RosTfThread::bb_interface_data_changed(), fawkes::WorldInfoDataContainer::check_timeout(), TimeTrackerMainLoopThread::init(), OpenNiContextThread::init(), NaoQiButtonThread::init(), AmclThread::init(), TimeTrackerMainLoopThread::loop(), StaticTransformsThread::loop(), RosImagesThread::loop(), OpenNiContextThread::loop(), FvRetrieverThread::loop(), NaoQiButtonThread::loop(), BBLogReplayThread::loop(), XabslEngineThread::loop(), KatanaActThread::loop(), AmclThread::loop(), fawkes::Clock::now(), BBLogReplayThread::once(), fawkes::Interface::set_timestamp(), wait(), and fawkes::Interface::write().
Time & fawkes::Time::stamp_systime | ( | ) |
Set this time to the current system time.
This bypasses any possibly registered time source. Use with care and only where you really need the system time.
Definition at line 800 of file time.cpp.
Referenced by OpenNiDepthThread::init(), OpenNiImageThread::init(), OpenNiPointCloudThread::init(), and fawkes::FawkesMainThread::loop().
const char * fawkes::Time::str | ( | bool | utc = false | ) | const |
Output function.
utc | true to get type formatted in UTC, otherwise local time |
Definition at line 872 of file time.cpp.
Referenced by ROSTalkerPubThread::loop(), and WebviewBlackBoardRequestProcessor::process_request().
void fawkes::Time::str_r | ( | char * | s, |
bool | utc = false |
||
) |
void fawkes::Time::wait | ( | ) |
Wait (sleep) for this time.
This waits for as much time as this instance provides. Note that you have to make sure that you call this on a sensible time range. You probably do not want to wait for almost 40 years when passing a time point...
Definition at line 817 of file time.cpp.
References stamp().
Referenced by BBLogReplayThread::loop().
void fawkes::Time::wait_systime | ( | ) |
Wait (sleep) for this system time.
This waits for as much time as this instance provides. Unlike wait() this method calculates the time in system time, althouh the main clock may run slower for example in a simulation. Note that you have to make sure that you call this on a sensible time range. You probably do not want to wait for almost 40 years when passing a time point...
Definition at line 842 of file time.cpp.
Referenced by FestivalSynthThread::say().
|
static |