24 #include <utils/time/clock.h> 25 #include <utils/time/time.h> 26 #include <utils/time/wait.h> 51 desired_loop_time_ = desired_loop_time_usec;
54 until_systime_ =
new Time();
62 delete until_systime_;
71 *until_ += desired_loop_time_;
73 *until_systime_ += desired_loop_time_;
84 long int remaining_usec = (*until_ - *now_).in_usec();
85 while (remaining_usec > 0) {
86 usleep(remaining_usec);
88 remaining_usec = (*until_ - *now_).in_usec();
102 long int remaining_usec = (*until_systime_ - *now_).in_usec();
103 while (remaining_usec > 0) {
104 usleep(remaining_usec);
106 remaining_usec = (*until_systime_ - *now_).in_usec();
121 struct timeval start, now;
122 long int remaining_usec = usec;
123 gettimeofday(&start, NULL);
125 usleep(remaining_usec);
126 gettimeofday(&now, NULL);
127 }
while ((remaining_usec = usec -
time_diff_usec(now, start)) > 0);
144 struct timeval start, now;
145 long int remaining_usec = usec;
148 usleep(remaining_usec);
150 }
while ((remaining_usec = usec -
time_diff_usec(now, start)) > 0);
void wait()
Wait until minimum loop time has been reached.
static Clock * instance()
Clock initializer.
void get_time(struct timeval *tv) const
Returns the time of the selected time source.
TimeWait(Clock *clock, long int desired_loop_time_usec)
Constructor.
Fawkes library namespace.
void get_systime(struct timeval *tv) const
Returns the system time.
This is supposed to be the central clock in Fawkes.
A class for handling time.
void wait_systime()
Wait until minimum loop time has been reached in real time.
long int time_diff_usec(const timeval &a, const timeval &b)
Get difference between two time structs in microseconds.
void mark_start()
Mark start of loop.