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... | |
Friends | |
class | Clock |
fawkes::Time::Time | ( | ) |
Constructor.
Sets time to the current time.
Definition at line 98 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 110 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 126 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 143 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 159 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 176 of file time.cpp.
References fawkes::Clock::get_time().
fawkes::Time::Time | ( | const Time & | t | ) |
Copy constructor.
t | time to copy |
Definition at line 187 of file time.cpp.
References TIMESTR_SIZE.
fawkes::Time::Time | ( | const Time * | t | ) |
Copy constructor.
t | time to copy |
Definition at line 204 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 |
Definition at line 343 of file time.cpp.
Referenced by is_zero().
|
inline |
|
inline |
Get nanoseconds.
Definition at line 113 of file time.h.
Referenced by RosLaserScanThread::bb_interface_data_changed(), RosTfThread::bb_interface_reader_removed(), GossipExampleSenderThread::loop(), RosPointCloudThread::loop(), RosSkillerThread::loop(), RosMoveBaseThread::once(), and fawkes::tf::TimeCache::TimeCache().
|
inline |
Get seconds.
Definition at line 110 of file time.h.
Referenced by fawkes::BlackBoardInterfaceListContent::append_interface(), RosLaserScanThread::bb_interface_data_changed(), RosTfThread::bb_interface_reader_removed(), BlackboardCLIPSFeature::clips_context_destroyed(), fawkes::CLIPSEnvManager::environments(), RosClockThread::finalize(), fawkes::WebviewAccessLog::log(), OpenPRSAgentThread::loop(), GossipExampleSenderThread::loop(), RobotinoRosJointsThread::loop(), RosImagesThread::loop(), RosPointCloudThread::loop(), RosSkillerThread::loop(), RosMoveBaseThread::once(), and fawkes::tf::TimeCache::TimeCache().
|
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::Message::mark_enqueued(), and BBLoggerThread::set_threadlist().
|
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(), RosPointCloudThread::loop(), fawkes::Clock::native_to_time(), and firevision::SharedMemoryImageBuffer::set_capture_time().
|
inline |
Get microseconds.
Definition at line 112 of file time.h.
Referenced by fawkes::BlackBoardInterfaceListContent::append_interface(), BlackboardCLIPSFeature::clips_context_destroyed(), fawkes::CLIPSEnvManager::environments(), RosClockThread::finalize(), OpenPRSAgentThread::loop(), RobotinoRosJointsThread::loop(), RosImagesThread::loop(), and fawkes::tf::TimeCache::TimeCache().
long fawkes::Time::in_msec | ( | ) | const |
Convert the stored time into milli-seconds.
Definition at line 242 of file time.cpp.
Referenced by MongoLogBlackboardThread::bb_interface_created(), XabslEngineThread::current_time(), firevision::ImageWidget::get_image_num(), PointCloudDBStoreThread::loop(), 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 232 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::LaserOccupancyGrid::get_cell_costs(), VisLocalizationThread::init(), VisLocalizationThread::loop(), BBLogReplayThread::loop(), RobotinoSimThread::loop(), fawkes::LaserOccupancyGrid::reset_old(), fawkes::tf::BufferCore::set_transform(), and fawkes::tf::TimeCache::TimeCache().
long fawkes::Time::in_usec | ( | ) | const |
Convert the stored time into micro-seconds.
Definition at line 252 of file time.cpp.
Referenced by wait(), and wait_systime().
|
inline |
Check if time is zero.
Definition at line 116 of file time.h.
References add(), operator!=(), operator+(), operator+=(), operator-(), operator-=(), operator<(), operator<=(), operator=(), operator==(), operator>(), operator>=(), set_clock(), set_time(), stamp(), stamp_systime(), str(), str_r(), wait(), and wait_systime().
Referenced by fawkes::tf::TimeCache::clone(), FvRetrieverThread::init(), ColliThread::loop(), and fawkes::tf::TimeCache::TimeCache().
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 OpenNiContextThread::init(), NaoQiButtonThread::init(), RosTfThread::init(), KatanaActThread::init(), and is_zero().
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::Interface::buffer_timestamp(), fawkes::Clock::ext_to_realtime(), RosTfThread::init(), KatanaActThread::init(), is_zero(), fawkes::Clock::native_to_time(), fawkes::Message::operator=(), fawkes::Watch::pause(), fawkes::Watch::reset(), fawkes::Message::set_from_chunk(), 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.
References fawkes::Clock::get_time().
Referenced by MongoLogBlackboardThread::bb_interface_created(), fawkes::dynamic_reply_free_cb(), OpenRobotinoComThread::get_act_velocity(), fawkes::OpenPRSAspectIniFin::init(), TimeTrackerMainLoopThread::init(), OpenNiContextThread::init(), RosPointCloudThread::init(), NaoQiButtonThread::init(), is_zero(), SickTiM55xEthernetAcquisitionThread::loop(), LaseEdlAcquisitionThread::loop(), HokuyoUrgAcquisitionThread::loop(), TimeTrackerMainLoopThread::loop(), HokuyoUrgGbxAcquisitionThread::loop(), CruizCoreXG1010AcquisitionThread::loop(), RosImagesThread::loop(), FvRetrieverThread::loop(), OpenNiContextThread::loop(), RosPointCloudThread::loop(), NaoQiButtonThread::loop(), BBLogReplayThread::loop(), MongoLogImagesThread::loop(), RosSkillerThread::loop(), XabslEngineThread::loop(), RosTfThread::loop(), NavGraphThread::loop(), Bumblebee2Thread::loop(), KatanaActThread::loop(), fawkes::Message::mark_enqueued(), PointCloudDBMergePipeline< pcl::PointXYZ >::merge(), fawkes::Clock::now(), LaserDeadSpotCalibrator::num_detected_spots(), BBLogReplayThread::once(), SickTiM55xCommonAcquisitionThread::parse_datagram(), PTUJoystickControl::run(), BBLoggerThread::set_threadlist(), fawkes::Interface::set_timestamp(), fawkes::tf::TimeCache::TimeCache(), and wait().
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.
References fawkes::Clock::get_systime().
Referenced by OpenNiDepthThread::init(), OpenNiImageThread::init(), OpenNiPointCloudThread::init(), is_zero(), 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.
References TIMESTR_SIZE.
Referenced by fawkes::tf::Transformer::all_frames_as_dot(), is_zero(), ROSTalkerPubThread::loop(), and WebviewBlackBoardRequestProcessor::process_request().
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 901 of file time.cpp.
References TIMESTR_SIZE.
Referenced by is_zero().
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 in_usec(), and stamp().
Referenced by is_zero(), and 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.
References fawkes::Clock::get_systime(), and in_usec().
Referenced by is_zero(), and FestivalSynthThread::say().
|
static |