TimerComponent.hpp
Go to the documentation of this file.
00001 #ifndef ORO_TIMER_COMPONENT_HPP
00002 #define ORO_TIMER_COMPONENT_HPP
00003 
00004 
00005 #include <rtt/os/TimeService.hpp>
00006 #include <rtt/TaskContext.hpp>
00007 #include <rtt/os/Timer.hpp>
00008 #include <rtt/OutputPort.hpp>
00009 
00010 #include <rtt/RTT.hpp>
00011 #include <ocl/OCL.hpp>
00012 
00013 namespace OCL
00014 {
00021     class TimerComponent
00022         : public RTT::TaskContext
00023     {
00024     protected:
00028         struct TimeoutCatcher : public os::Timer {
00029             RTT::OutputPort<RTT::os::Timer::TimerId>& me;
00030             std::vector<RTT::OutputPort<RTT::os::Timer::TimerId>* >& m_port_timers;
00031             TimeoutCatcher(std::vector<RTT::OutputPort<RTT::os::Timer::TimerId>* >& port_timers, RTT::OutputPort<RTT::os::Timer::TimerId>&  op) :
00032                 os::Timer(port_timers.size(), ORO_SCHED_RT, os::HighestPriority),
00033                 me(op),
00034                 m_port_timers(port_timers)
00035             {}
00036             virtual void timeout(os::Timer::TimerId id) {
00037                 m_port_timers[id]->write(id);
00038                 me.write(id);
00039             }
00040         };
00041 
00042         std::vector<OutputPort<RTT::os::Timer::TimerId>* > port_timers;
00043         OutputPort<RTT::os::Timer::TimerId> mtimeoutEvent;
00044         TimeoutCatcher mtimer;
00045 
00050         bool startHook();
00051         void updateHook();
00052         void stopHook();
00053 
00057         RTT::Operation<bool(RTT::os::Timer::TimerId)> waitForCommand;
00058 
00062         RTT::Operation<bool(RTT::os::Timer::TimerId, double)> waitCommand;
00063 
00067         bool waitFor(RTT::os::Timer::TimerId id);
00068 
00072         bool wait(RTT::os::Timer::TimerId id, double seconds);
00073 
00077         bool isTimerExpired(RTT::os::Timer::TimerId id) const;
00078     public:
00082         TimerComponent( std::string name = "os::Timer" );
00083 
00084         virtual ~TimerComponent();
00085     };
00086 
00087 }
00088 
00089 #endif


ocl
Author(s): OCL Development Team
autogenerated on Sat Jun 8 2019 18:48:55