14 TimerComponent::TimerComponent( std::string name )
15 :
TaskContext( name, PreOperational ), port_timers(32), mtimeoutEvent(
"timeout"),
16 mtimer( port_timers, mtimeoutEvent, name ),
24 this->
addOperation(
"arm", &os::Timer::arm , &
mtimer,
RTT::ClientThread).doc(
"Arm a single shot timer.").arg(
"timerId",
"A numeric id of the timer to arm.").arg(
"delay",
"The delay in seconds before it fires.");
25 this->
addOperation(
"startTimer", &os::Timer::startTimer , &
mtimer,
RTT::ClientThread).doc(
"Start a periodic timer.").arg(
"timerId",
"A numeric id of the timer to start.").arg(
"period",
"The period in seconds.");
26 this->
addOperation(
"killTimer", &os::Timer::killTimer , &
mtimer,
RTT::ClientThread).doc(
"Kill (disable) an armed or started timer.").arg(
"timerId",
"A numeric id of the timer to kill.");
27 this->
addOperation(
"isArmed", &os::Timer::isArmed , &
mtimer,
RTT::ClientThread).doc(
"Check if a given timer is armed or started.").arg(
"timerId",
"A numeric id of the timer to check.");
28 this->
addOperation(
"setMaxTimers", &os::Timer::setMaxTimers , &
mtimer,
RTT::ClientThread).doc(
"Raise or lower the maximum amount of timers.").arg(
"timers",
"The largest amount of timers. The highest timerId is max-1.");
29 this->
addOperation(
waitForCommand ).doc(
"Wait until a timer expires.").arg(
"timerId",
"A numeric id of the timer to wait for.");
30 this->
addOperation(
waitCommand ).doc(
"Arm and wait until that timer expires.").arg(
"timerId",
"A numeric id of the timer to arm and to wait for.").arg(
"delay",
"The delay in seconds before the timer expires.");
31 this->
addPort(
mtimeoutEvent).
doc(
"This port is written each time ANY timer expires. The timer id is the value sent in this port. This port is for backwards compatibility only. It is advised to use the timer_* ports.");
34 port_name<<
"timer_"<<i;
36 this->
addPort(*(
port_timers[i])).
doc(
string(
"This port is written each time ")+port_name.
str()+string(
" expires. The timer id is the value sent in this port."));
virtual os::ThreadInterface * getThread() const
bool isArmed(TimerId timer_id) const
RTT::Operation< bool(RTT::os::Timer::TimerId, double)> waitCommand
RTT::Operation< bool(RTT::os::Timer::TimerId)> waitForCommand
bool wait(RTT::os::Timer::TimerId id, double seconds)
bool waitFor(RTT::os::Timer::TimerId id)
OutputPort< RTT::os::Timer::TimerId > mtimeoutEvent
std::vector< OutputPort< RTT::os::Timer::TimerId > * > port_timers
A Component interface to the Real-Time types::Toolkit's timer. It must be configured with a Activity ...
base::PortInterface & addPort(const std::string &name, base::PortInterface &port)
bool waitFor(RTT::os::Timer::TimerId id)
bool arm(TimerId timer_id, Seconds wait_time)
ORO_LIST_COMPONENT_TYPE(OCL::logging::Appender)
bool isTimerExpired(RTT::os::Timer::TimerId id) const
virtual ~TimerComponent()
PortInterface & doc(const std::string &desc)
Operation< Signature > & addOperation(Operation< Signature > &op)
ORO_CREATE_COMPONENT_TYPE()