RTT::os::Timer Class Reference
#include <Timer.hpp>
List of all members.
Detailed Description
This class allows to define a timer object which can be armed in single shot and periodic mode. In Order to use this class, derive your class from Timer and implement the timeout() method. The resolution of this class depends completely on the timer resolution of the underlying operating system.
If you do not attach an activity, the Timer will create a thread of its own and start it. That thread will be stopped and cleaned up when the Timer is destroyed.
Definition at line 66 of file Timer.hpp.
Member Typedef Documentation
A positive numeric ID representing a timer.
Definition at line 73 of file Timer.hpp.
Index in vector is the timer id. 1st Time is the absolute time upon which the timer expires. 2nd Time is the optional period of the timer.
Definition at line 85 of file Timer.hpp.
Constructor & Destructor Documentation
RTT::Timer::Timer |
( |
TimerId |
max_timers, |
|
|
int |
scheduler = -1 , |
|
|
int |
priority = 0 | |
|
) |
| | |
Create a timer object which can hold max_timers timers. A Timer must be executed in a non periodic thread (or the main thread) or it will refuse to start. If scheduler is set to -1 (default) no thread is created and you need to attach a thread yourself to this Timer.
- Parameters:
-
| max_timers | The initial amount of timers this Timer can monitor. Keep as low as possible. See also setMaxTimers(). |
| scheduler | The Orocos scheduler type for this timer. ORO_SCHED_OTHER or ORO_SCHED_RT or -1 to attach your own thread. |
| priority | The priority within the scheduler of this timer. |
Definition at line 119 of file Timer.cpp.
Member Function Documentation
Arm a timer to fire once over wait_time seconds.
- Parameters:
-
| timer_id | The number of the timer, starting from zero. |
| wait_time | The time in seconds from now, when the timer should expire. This is a floating point number. |
- See also:
- killTimer to disable it before it fires.
Definition at line 166 of file Timer.cpp.
bool RTT::Timer::breakLoop |
( |
|
) |
[protected, virtual] |
This method is called by the framework to break out of the loop() method. Reimplement this method to signal loop() to return and return true on success. When this method is not reimplemented by you, it will always return false, denoting that the loop can not be broken. If breakLoop() returns true, the caller will wait until loop() returns.
- Returns:
- true if the loop could be notified to return.
Reimplemented from RTT::base::RunnableInterface.
Definition at line 112 of file Timer.cpp.
void RTT::Timer::finalize |
( |
|
) |
[protected, virtual] |
bool RTT::Timer::initialize |
( |
|
) |
[protected, virtual] |
bool RTT::Timer::isArmed |
( |
TimerId |
timer_id |
) |
const |
Check if a given timer id is armed.
- Parameters:
-
| timer_id | The number of the timer, starting from zero. |
Definition at line 186 of file Timer.cpp.
bool RTT::Timer::killTimer |
( |
TimerId |
timer_id |
) |
|
Disable an armed timer.
- Parameters:
-
| timer_id | The number of the timer, starting from zero. |
Definition at line 213 of file Timer.cpp.
void RTT::Timer::loop |
( |
|
) |
[protected, virtual] |
void RTT::Timer::setMaxTimers |
( |
TimerId |
max |
) |
|
Change the maximum number of timers in this object. Any added timer with id >= max will be removed.
Definition at line 141 of file Timer.cpp.
Start a periodic timer which starts first over period seconds and then every period seconds.
- Parameters:
-
| timer_id | The number of the timer, starting from zero. |
| period | The period when the timer should expire. This is a floating point number. |
- See also:
- killTimer to disable it again.
Definition at line 147 of file Timer.cpp.
void RTT::Timer::step |
( |
|
) |
[protected, virtual] |
void RTT::Timer::timeout |
( |
TimerId |
timer_id |
) |
[virtual] |
This function is called each time an armed or periodic timer expires. The user must implement this method to catch the time outs.
- Parameters:
-
| timer_id | The number of the timer that expired. |
Definition at line 136 of file Timer.cpp.
double RTT::Timer::timeRemaining |
( |
TimerId |
timer_id |
) |
const |
Returns the remaining time before this timer elapses.
- Return values:
-
| 0.0 | if the timer is not armed or has already elapsed. |
- Returns:
- the remaining time in seconds.
Definition at line 197 of file Timer.cpp.
Member Data Documentation
The documentation for this class was generated from the following files: