Fawkes API Fawkes Development Version
|
A class for handling time. More...
#include <>>
Public Member Functions | |
Time () | |
Constructor. More... | |
Time (const timeval *tv) | |
Constructor. More... | |
Time (long sec, long usec, Clock *clock=0) | |
Constructor. More... | |
Time (long ms) | |
Constructor. More... | |
Time (double sec) | |
Constructor. More... | |
Time (Clock *clock) | |
Constructor. More... | |
Time (const Time &t) | |
Copy constructor. More... | |
Time (const Time *t) | |
Copy constructor. More... | |
~Time () | |
Destructor. More... | |
double | in_sec () const |
Convet time to seconds. More... | |
long | in_msec () const |
Convert the stored time into milli-seconds. More... | |
long | in_usec () const |
Convert the stored time into micro-seconds. More... | |
const timeval * | get_timeval () const |
Obtain the timeval where the time is stored. More... | |
long | get_sec () const |
Get seconds. More... | |
long | get_msec () const |
Get milliseconds. More... | |
long | get_usec () const |
Get microseconds. More... | |
long | get_nsec () const |
Get nanoseconds. More... | |
void | get_timestamp (long &sec, long &usec) const |
Get time stamp. More... | |
bool | is_zero () const |
Check if time is zero. More... | |
void | set_time (const timeval *tv) |
Sets the time. More... | |
void | set_time (long int sec, long int usec) |
Sets the time. More... | |
void | set_time (long ms) |
Sets the time. More... | |
void | set_time (double sec) |
Sets the time. More... | |
void | set_time (const Time &t) |
Set time to given time. More... | |
void | set_time (const Time *t) |
Set time to given time. More... | |
void | set_clock (Clock *clock) |
Set clock for this instance. More... | |
void | add (double seconds) |
Add seconds. More... | |
Time & | stamp () |
Set this time to the current time. More... | |
Time & | stamp_systime () |
Set this time to the current system time. More... | |
Time | operator+ (const double sec) const |
Operator that adds times. More... | |
Time | operator+ (const long int usec) const |
Operator to add usec value. More... | |
Time | operator+ (const Time &t) const |
Operator that adds times. More... | |
Time | operator+ (const Time *t) const |
Operator that adds times. More... | |
Time | operator- (const Time &t) const |
Operator that substracts one Time from another. More... | |
double | operator- (const Time *t) const |
Operator that substracts one Time from another. More... | |
Time | operator- (const long int usec) const |
Operator that subtracts some time. More... | |
Time | operator- (const double sec) const |
Operator that subtracts some time. More... | |
Time & | operator+= (const long int usec) |
+= operator More... | |
Time & | operator+= (const Time &t) |
+= operator More... | |
Time & | operator+= (const double sec) |
+= operator for double seconds More... | |
Time & | operator-= (const Time &t) |
-= operator. More... | |
Time & | operator-= (const double sec) |
-= operator. More... | |
Time & | operator-= (const long int usec) |
-= operator. More... | |
Time & | operator= (const Time &t) |
Assign operator. More... | |
bool | operator== (const Time &t) const |
Check equality of times. More... | |
bool | operator== (const Time *t) const |
Check equality of times. More... | |
bool | operator!= (const Time &t) const |
Check inequality of times. More... | |
bool | operator!= (const Time *t) const |
Check inequality of times. More... | |
bool | operator> (const Time &t) const |
Greater than operator. More... | |
bool | operator> (const Time *t) const |
Greater than operator. More... | |
bool | operator>= (const Time &t) const |
Greater than or equal to operator. More... | |
bool | operator>= (const Time *t) const |
Greater than or equal to operator. More... | |
bool | operator< (const Time &t) const |
Less than operator. More... | |
bool | operator< (const Time *t) const |
Less than operator. More... | |
bool | operator<= (const Time &t) const |
Less than or equal to operator. More... | |
bool | operator<= (const Time *t) const |
Less than or equal to operator. More... | |
void | wait () |
Wait (sleep) for this time. More... | |
void | wait_systime () |
Wait (sleep) for this system time. More... | |
const char * | str (bool utc=false) const |
Output function. More... | |
void | str_r (char *s, bool utc=false) |
Output function. More... | |
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(). More... | |
fawkes::Time::Time | ( | ) |
Constructor.
Sets time to the current time.
Definition at line 93 of file time.cpp.
References fawkes::Clock::get_time(), and fawkes::Clock::instance().
fawkes::Time::Time | ( | const timeval * | tv | ) |
Constructor.
Sets time to the given time.
tv | the Time object is initialized with the time given in this timeval |
Definition at line 104 of file time.cpp.
References fawkes::Clock::instance().
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 |
Definition at line 119 of file time.cpp.
References fawkes::Clock::instance().
fawkes::Time::Time | ( | long | ms | ) |
Constructor.
Sets time to given number of ms, use for time range.
ms | the Time object is initialized to the time given in milli-seconds |
Definition at line 135 of file time.cpp.
References fawkes::Clock::instance().
fawkes::Time::Time | ( | double | s | ) |
Constructor.
Sets time to given number of ms, use for time range.
s | the Time object is initialized to the time given in seconds |
Definition at line 150 of file time.cpp.
References fawkes::Clock::instance().
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 166 of file time.cpp.
References fawkes::Clock::get_time().
fawkes::Time::Time | ( | const Time & | t | ) |
Copy constructor.
t | time to copy |
Definition at line 176 of file time.cpp.
References TIMESTR_SIZE.
fawkes::Time::Time | ( | const Time * | t | ) |
Copy constructor.
t | time to copy |
Definition at line 192 of file time.cpp.
References TIMESTR_SIZE.
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 132 of file time.h.
Referenced by RosLaserScanThread::bb_interface_data_refreshed(), GossipExampleSenderThread::loop(), and RosSkillerThread::loop().
|
inline |
Get seconds.
Definition at line 117 of file time.h.
Referenced by fawkes::BlackBoardInterfaceListContent::append_interface(), RosLaserScanThread::bb_interface_data_refreshed(), fawkes::WebviewAccessLog::log(), GossipExampleSenderThread::loop(), OpenPRSAgentThread::loop(), RobotinoRosJointsThread::loop(), RosImagesThread::loop(), and RosSkillerThread::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 137 of file time.h.
Referenced by fawkes::Message::mark_enqueued(), and fawkes::Interface::write().
|
inline |
Obtain the timeval where the time is stored.
Definition at line 112 of file time.h.
Referenced by BBLoggerThread::BBLoggerThread(), BlackBoardLoggerPlugin::BlackBoardLoggerPlugin(), fawkes::Clock::ext_to_realtime(), fawkes::SimulatorTimeSource::get_time(), RosPointCloudThread::loop(), fawkes::Clock::native_to_time(), and firevision::SharedMemoryImageBuffer::set_capture_time().
|
inline |
Get microseconds.
Definition at line 127 of file time.h.
Referenced by fawkes::BlackBoardInterfaceListContent::append_interface(), OpenPRSAgentThread::loop(), RobotinoRosJointsThread::loop(), and RosImagesThread::loop().
long fawkes::Time::in_msec | ( | ) | const |
Convert the stored time into milli-seconds.
Definition at line 228 of file time.cpp.
Referenced by XabslEngineThread::current_time(), MongoLogImagesThread::loop(), MongoLogPointCloudThread::loop(), and fawkes::tf::MongoDBTransformer::restore().
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 219 of file time.cpp.
Referenced by fawkes::NavGraphTimedReservationListEdgeConstraint::add_edge(), fawkes::NavGraphTimedReservationListNodeConstraint::add_node(), fawkes::tf::Transformer::all_frames_as_dot(), fawkes::SimulatorTimeSource::conv_to_realtime(), fawkes::SyncPointCallStats::get_call_frequency(), fawkes::SyncPointCallStats::get_waittime_average(), ClockPlexilTimeAdapter::getCurrentTime(), VisLocalizationThread::init(), BBLogReplayThread::loop(), VisLocalizationThread::loop(), BBLogFile::print_entry(), fawkes::tf::BufferCore::set_transform(), ClockPlexilTimeAdapter::setThresholds(), and fawkes::gpp::GologppFawkesBackend::time().
long fawkes::Time::in_usec | ( | ) | const |
Convert the stored time into micro-seconds.
Definition at line 237 of file time.cpp.
Referenced by wait(), and wait_systime().
|
inline |
Check if time is zero.
Definition at line 143 of file time.h.
Referenced by fawkes::tf::TimeCache::clone(), FvRetrieverThread::init(), and PlexilTimerThread::loop().
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 double | sec | ) |
Time & fawkes::Time::operator+= | ( | const long int | usec | ) |
Time fawkes::Time::operator- | ( | const double | sec | ) | const |
Time fawkes::Time::operator- | ( | const long int | usec | ) | const |
double fawkes::Time::operator- | ( | const Time * | t | ) | const |
Operator that substracts one Time from another.
t | the Time that is substracted |
Definition at line 422 of file time.cpp.
References fawkes::time_diff_sec().
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 308 of file time.cpp.
Referenced by AmclThread::init(), KatanaActThread::init(), NaoQiButtonThread::init(), OpenNiContextThread::init(), RosTfThread::init(), and fawkes::Interface::set_clock().
void fawkes::Time::set_time | ( | const Time & | t | ) |
void fawkes::Time::set_time | ( | const Time * | t | ) |
void fawkes::Time::set_time | ( | const timeval * | tv | ) |
Sets the time.
tv | set the time to this value |
Definition at line 246 of file time.cpp.
Referenced by fawkes::Interface::buffer_timestamp(), firevision::SharedMemoryCamera::capture(), firevision::V4L2Camera::capture(), fawkes::Clock::ext_to_realtime(), KatanaActThread::init(), RosTfThread::init(), PlexilTimerThread::loop(), fawkes::Clock::native_to_time(), fawkes::Message::operator=(), fawkes::Watch::pause(), PlexilTimerThread::PlexilTimerThread(), fawkes::Interface::read(), fawkes::Interface::read_from_buffer(), BBLogFile::read_next(), fawkes::Watch::reset(), BBLogFile::rewind(), fawkes::Message::set_from_chunk(), fawkes::Watch::start(), and fawkes::Watch::stop().
void fawkes::Time::set_time | ( | double | s | ) |
void fawkes::Time::set_time | ( | long int | sec, |
long int | usec | ||
) |
void fawkes::Time::set_time | ( | long | ms | ) |
Time & fawkes::Time::stamp | ( | ) |
Set this time to the current time.
Definition at line 704 of file time.cpp.
References fawkes::Clock::get_time().
Referenced by RosLaserScanThread::bb_interface_data_refreshed(), firevision::V4L2Camera::capture(), OpenRobotinoComThread::get_act_velocity(), AmclThread::init(), NaoQiButtonThread::init(), OpenNiContextThread::init(), RosPointCloudThread::init(), TimeTrackerMainLoopThread::init(), fawkes::OpenPRSAspectIniFin::init(), AmclThread::loop(), BBLogReplayThread::loop(), Bumblebee2Thread::loop(), CruizCoreXG1010AcquisitionThread::loop(), KatanaActThread::loop(), SickTiM55xEthernetAcquisitionThread::loop(), HokuyoUrgAcquisitionThread::loop(), HokuyoUrgGbxAcquisitionThread::loop(), MongoLogImagesThread::loop(), NaoQiButtonThread::loop(), NavGraphThread::loop(), OpenNiContextThread::loop(), FvRetrieverThread::loop(), RosImagesThread::loop(), RosNavigatorThread::loop(), RosPointCloudThread::loop(), RosSkillerThread::loop(), RosTfThread::loop(), TimeTrackerMainLoopThread::loop(), XabslEngineThread::loop(), fawkes::Message::mark_enqueued(), PointCloudDBMergePipeline< PointType >::merge(), fawkes::Clock::now(), BBLogReplayThread::once(), SickTiM55xCommonAcquisitionThread::parse_datagram(), 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 720 of file time.cpp.
References fawkes::Clock::get_systime().
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 790 of file time.cpp.
References TIMESTR_SIZE.
Referenced by fawkes::tf::Transformer::all_frames_as_dot(), ROSTalkerPubThread::loop(), and BBLogFile::print_info().
void fawkes::Time::str_r | ( | char * | s, |
bool | utc = false |
||
) |
Output function.
This is the thread-safe version of str().
s | pointer to a string of at least TIMESTR_SIZE bytes. |
utc | true to get type formatted in UTC, otherwise local time |
Definition at line 819 of file time.cpp.
References TIMESTR_SIZE.
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 736 of file time.cpp.
References in_usec(), and 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 760 of file time.cpp.
References fawkes::Clock::get_systime(), and in_usec().
Referenced by JoystickAcquisitionThread::loop(), and FestivalSynthThread::say().
|
static |