hrpEC.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 #ifndef hrpEC_h
3 #define hrpEC_h
4 
5 #include <rtm/RTC.h>
6 
7 #include <coil/Mutex.h>
8 #include <coil/Condition.h>
9 #include <coil/Task.h>
10 
11 #include <rtm/Manager.h>
13 
14 #include "hrpsys/idl/ExecutionProfileService.hh"
15 
16 #ifdef __QNX__
17 using std::fprintf;
18 #endif
19 
20 namespace RTC
21 {
23 #ifndef OPENRTM_VERSION_TRUNK
24  : public virtual PeriodicExecutionContext,
25 #else
26  : public virtual RTC_exp::PeriodicExecutionContext,
27 #endif
28  public virtual POA_OpenHRP::ExecutionProfileService,
29  public virtual PortableServer::RefCountServantBase
30  {
31  public:
33  virtual ~hrpExecutionContext();
34  virtual int svc(void);
35 #ifdef OPENRTM_VERSION_TRUNK
36  virtual void tick(){}
37 #endif
38  void activate ();
39 
40  OpenHRP::ExecutionProfileService::Profile *getProfile();
41  OpenHRP::ExecutionProfileService::ComponentProfile getComponentProfile(RTC::LightweightRTObject_ptr obj);
42  void resetProfile();
43  //
44  bool enterRT();
45  bool exitRT();
46  bool waitForNextPeriod();
47  private:
48  template <class T>
49  void getProperty(coil::Properties& prop, const char* key, T& value)
50  {
51  if (prop.findNode(key) != 0)
52  {
53  T tmp;
54  if (coil::stringTo(tmp, prop[key].c_str()))
55  {
56  value = tmp;
57  }
58  }
59  }
60  void printRTCProcessingTime (std::vector<double>& processes)
61  {
62  fprintf(stderr, "[hrpEC] ");
63  for (unsigned int i=0; i< processes.size(); i++){
64  fprintf(stderr, "%s(%4.2f), ", rtc_names[i].c_str(),processes[i]*1e3);
65  }
66  fprintf(stderr, "[ms]\n");
67  };
68  int svc_wrapped (void);
69 
70  OpenHRP::ExecutionProfileService::Profile m_profile;
71  struct timeval m_tv;
73  int m_cpu;
74  std::vector<std::string> rtc_names;
75  volatile bool m_thread_pending;
76  };
77 };
78 
79 extern "C"
80 {
82 };
83 
84 #endif // hrpEC_h
85 
OpenHRP::ExecutionProfileService::Profile * getProfile()
bool stringTo(To &val, const char *str)
std::vector< std::string > rtc_names
Definition: hrpEC.h:74
manager
void printRTCProcessingTime(std::vector< double > &processes)
Definition: hrpEC.h:60
struct timeval m_tv
Definition: hrpEC.h:71
png_uint_32 i
volatile bool m_thread_pending
Definition: hrpEC.h:75
virtual int svc(void)
void getProperty(coil::Properties &prop, const char *key, T &value)
Definition: hrpEC.h:49
Properties *const findNode(const std::string &key) const
void hrpExecutionContextInit(RTC::Manager *manager)
OpenHRP::ExecutionProfileService::ComponentProfile getComponentProfile(RTC::LightweightRTObject_ptr obj)
obj
OpenHRP::ExecutionProfileService::Profile m_profile
Definition: hrpEC.h:70


hrpsys
Author(s): AIST, Fumio Kanehiro
autogenerated on Thu May 6 2021 02:41:50