00001 #ifndef __OPENRTM_UTIL_H__ 00002 #define __OPENRTM_UTIL_H__ 00003 00004 #include <rtm/RTObject.h> 00005 00006 int connectPorts(RTC::PortService_ptr outPort, RTC::PortService_ptr inPort); 00007 void activateRtc(RTC::RtcBase* pRtc); 00008 void deactivateRtc(RTC::RtcBase* pRtc); 00009 const char *getServiceIOR(RTC::RTObject_var rtc, 00010 const char *sname); 00011 void setConfiguration(RTC::RTObject_var rtc, 00012 const std::string& name, const std::string& value); 00013 RTC::RTObject_var findRTC(const std::string &rtcName); 00014 00015 class ClockReceiver 00016 { 00017 public: 00018 ClockReceiver(OpenRTM::ExtTrigExecutionContextService_ptr i_ec, 00019 double i_period) : 00020 m_ec(i_ec), m_period(i_period), m_time(i_period){} 00021 void tick(double dt){ 00022 m_time += dt; 00023 if (m_time + dt/2 > m_period){ 00024 m_ec->tick(); 00025 m_time -= m_period; 00026 } 00027 } 00028 private: 00029 OpenRTM::ExtTrigExecutionContextService_ptr m_ec; 00030 double m_period; 00031 double m_time; 00032 }; 00033 00034 00035 #endif