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                 me(op),
00033                 os::Timer(port_timers.size(), ORO_SCHED_RT, os::HighestPriority), m_port_timers(port_timers)
00034             {}
00035             virtual void timeout(os::Timer::TimerId id) {
00036                 m_port_timers[id]->write(id);
00037                 me.write(id);
00038             }
00039         };
00040 
00041         std::vector<OutputPort<RTT::os::Timer::TimerId>* > port_timers;
00042         OutputPort<RTT::os::Timer::TimerId> mtimeoutEvent;
00043         TimeoutCatcher mtimer;
00044 
00049         bool startHook();
00050         void updateHook();
00051         void stopHook();
00052 
00056         RTT::Operation<bool(RTT::os::Timer::TimerId)> waitForCommand;
00057 
00061         RTT::Operation<bool(RTT::os::Timer::TimerId, double)> waitCommand;
00062 
00066         bool waitFor(RTT::os::Timer::TimerId id);
00067 
00071         bool wait(RTT::os::Timer::TimerId id, double seconds);
00072 
00076         bool isTimerExpired(RTT::os::Timer::TimerId id) const;
00077     public:
00081         TimerComponent( std::string name = "os::Timer" );
00082 
00083         virtual ~TimerComponent();
00084     };
00085 
00086 }
00087 
00088 #endif


ocl
Author(s): OCL Development Team
autogenerated on Mon Oct 6 2014 03:16:37