2 #include "hrpsys/io/iob.h" 3 #ifdef OPENRTM_VERSION_TRUNK 4 #include <rtm/RTObjectStateMachine.h> 8 #define ENABLE_DEBUG_PRINT (false) 27 std::cerr <<
"open_iob: failed to open" << std::endl;
31 std::cerr <<
"failed to lock iob" << std::endl;
35 #ifndef OPENRTM_VERSION_TRUNK 37 double period_sec = period_nsec/1e9;
40 double period_sec = (double)period;
41 long period_nsec = period_sec*1e9;
46 <<
"[ms], priority = " <<
m_priority <<
", cpu = " <<
m_cpu << std::endl;
47 struct timeval debug_tv1, debug_tv2, debug_tv3, debug_tv4, debug_tv5;
67 #define DELTA_SEC(start, end) (end.tv_sec - start.tv_sec + (end.tv_usec - start.tv_usec)/1e6) 77 #ifndef OPENRTM_VERSION_TRUNK 79 struct timeval tbegin, tend;
80 std::vector<double> processes(
m_comps.size());
81 gettimeofday(&tbegin, NULL);
82 for (
unsigned int i=0;
i<
m_comps.size();
i++){
84 gettimeofday(&tend, NULL);
90 struct timeval tbegin, tend;
91 const RTCList& list = getComponentList();
92 std::vector<double> processes(list.length());
93 gettimeofday(&tbegin, NULL);
94 for (
unsigned int i=0;
i< list.length();
i++){
95 RTC_impl::RTObjectStateMachine* rtobj =
m_worker.findComponent(list[
i]);
97 gettimeofday(&tend, NULL);
109 gettimeofday(&tv, NULL);
112 if (
m_profile.profiles.length() != processes.size()){
113 m_profile.profiles.length(processes.size());
114 for (
unsigned int i=0;
i<
m_profile.profiles.length();
i++){
120 for (
unsigned int i=0;
i<
m_profile.profiles.length();
i++){
121 #ifndef OPENRTM_VERSION_TRUNK 124 RTC_impl::RTObjectStateMachine* rtobj =
m_worker.findComponent(list[
i]);
127 OpenHRP::ExecutionProfileService::ComponentProfile &prof
129 double dt = processes[i];
131 prof.avg_process = (prof.avg_process*prof.count + dt)/(++prof.count);
133 if (prof.max_process < dt) prof.max_process = dt;
135 if (dt > period_sec*nsubstep){
138 fprintf(stderr,
"[hrpEC][%d.%6.6d] Timeover: processing time = %4.2f[ms]\n",
139 tv.tv_sec, tv.tv_usec, dt*1e3);
141 if (processes.size() !=
rtc_names.size()){
143 for (
unsigned int i=0;
i< processes.size();
i++){
144 #ifndef OPENRTM_VERSION_TRUNK 145 RTC::RTObject_var rtc = RTC::RTObject::_narrow(
m_comps[
i]._ref);
147 RTC::RTObject_var rtc = list[
i];
149 rtc_names.push_back(std::string(rtc->get_component_profile()->instance_name));
156 #ifndef OPENRTM_VERSION_TRUNK 158 gettimeofday(&debug_tv4, NULL);
159 fprintf(stderr,
"[hrpEC] [%d.%6.6d] Processing time breakdown : waitForNextPeriod %f[ms], warker (onExecute) %f[ms], ExecutionProfile %f[ms], time from prev cicle %f[ms]\n",
160 tv.tv_sec, tv.tv_usec,
166 if (loop % debug_count == (debug_count-1) &&
ENABLE_DEBUG_PRINT) gettimeofday(&debug_tv5, NULL);
169 }
while (isRunning());
180 OpenHRP::ExecutionProfileService::Profile *
ret 181 =
new OpenHRP::ExecutionProfileService::Profile;
188 #ifndef OPENRTM_VERSION_TRUNK 190 if (
m_comps[
i]._ref->_is_equivalent(obj)){
192 const RTCList& list = getComponentList();
193 for(
size_t i=0;
i<list.length();
i++){
194 RTC_impl::RTObjectStateMachine* rtobj =
m_worker.findComponent(list[
i]);
195 if(rtobj->isEquivalent(obj)){
200 throw OpenHRP::ExecutionProfileService::ExecutionProfileServiceException(
"no such component");
214 for(
unsigned int i = 0 ;
i <
m_profile.profiles.length() ;
i++ ){
OpenHRP::ExecutionProfileService::Profile * getProfile()
std::vector< Comp > m_comps
std::vector< std::string > rtc_names
#define DELTA_SEC(start, end)
int close_iob(void)
close connection with joint servo process
RTC::ReturnCode_t ret(RTC::Local::ReturnCode_t r)
void printRTCProcessingTime(std::vector< double > &processes)
int open_iob(void)
open connection with joint servo process
volatile bool m_thread_pending
int gettimeofday(struct timeval *tv, struct timezone *tz)
#define ENABLE_DEBUG_PRINT
virtual ~hrpExecutionContext()
int set_signal_period(long period_ns)
set the period of signals issued by wait_for_iob_signal()
int unlock_iob()
unlock access to iob
long get_signal_period()
get the period of signals issued by wait_for_iob_signal()
OpenHRP::ExecutionProfileService::ComponentProfile getComponentProfile(RTC::LightweightRTObject_ptr obj)
std::vector< IRTObject * > RTCList
virtual LifeCycleState get_component_state(LightweightRTObject_ptr comp)
int lock_iob()
lock access to iob
OpenHRP::ExecutionProfileService::Profile m_profile