00001 #ifndef ORO_TIMER_COMPONENT_HPP
00002 #define ORO_TIMER_COMPONENT_HPP
00003
00004
00005 #include <rtt/Event.hpp>
00006 #include <rtt/TimeService.hpp>
00007 #include <rtt/Command.hpp>
00008 #include <rtt/TaskContext.hpp>
00009 #include <rtt/Timer.hpp>
00010
00011 #include <rtt/RTT.hpp>
00012 #include <ocl/OCL.hpp>
00013
00014 namespace OCL
00015 {
00022 class TimerComponent
00023 : public RTT::TaskContext,
00024 public RTT::Timer
00025 {
00026 protected:
00027 RTT::Event <void(RTT::Timer::TimerId)> mtimeoutEvent;
00028
00033 bool configureHook();
00034 bool startHook();
00035 void updateHook();
00036 void stopHook();
00037 void cleanupHook();
00038
00042 RTT::Command<bool(RTT::Timer::TimerId)> waitForCommand;
00043
00047 RTT::Command<bool(RTT::Timer::TimerId, double)> waitCommand;
00048
00052 bool waitFor(RTT::Timer::TimerId id);
00053
00057 bool wait(RTT::Timer::TimerId id, double seconds);
00058
00062 bool isTimerExpired(RTT::Timer::TimerId id) const;
00063 public:
00067 TimerComponent( std::string name = "Timer" );
00068
00069 virtual ~TimerComponent();
00070
00071 virtual void timeout(RTT::Timer::TimerId id);
00072
00073 virtual bool stop();
00074
00078 double getTime() const;
00079
00083 double secondsSince(double stamp) const;
00084
00085 };
00086
00087 }
00088
00089 #endif