hrpEC.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #ifndef hrpEC_h
00003 #define hrpEC_h
00004 
00005 #include <rtm/RTC.h>
00006 
00007 #include <coil/Mutex.h>
00008 #include <coil/Condition.h>
00009 #include <coil/Task.h>
00010 
00011 #include <rtm/Manager.h>
00012 #include <rtm/PeriodicExecutionContext.h>
00013 
00014 #include "hrpsys/idl/ExecutionProfileService.hh"
00015 
00016 #ifdef __QNX__
00017 using std::fprintf;
00018 #endif
00019 
00020 namespace RTC
00021 {
00022   class hrpExecutionContext
00023 #ifndef OPENRTM_VERSION_TRUNK
00024       : public virtual PeriodicExecutionContext,
00025 #else
00026       : public virtual RTC_exp::PeriodicExecutionContext,
00027 #endif
00028         public virtual POA_OpenHRP::ExecutionProfileService,
00029         public virtual PortableServer::RefCountServantBase
00030   {
00031   public:
00032     hrpExecutionContext();
00033     virtual ~hrpExecutionContext();
00034     virtual int svc(void);
00035 #ifdef OPENRTM_VERSION_TRUNK
00036     virtual void tick(){}
00037 #endif
00038     void activate ();
00039 
00040     OpenHRP::ExecutionProfileService::Profile *getProfile();
00041     OpenHRP::ExecutionProfileService::ComponentProfile getComponentProfile(RTC::LightweightRTObject_ptr obj);
00042     void resetProfile();
00043     //
00044     bool enterRT();
00045     bool exitRT();
00046     bool waitForNextPeriod();
00047   private:
00048     template <class T>
00049     void getProperty(coil::Properties& prop, const char* key, T& value)
00050     {
00051     if (prop.findNode(key) != 0)
00052       {
00053         T tmp;
00054         if (coil::stringTo(tmp, prop[key].c_str()))
00055           {
00056             value = tmp;
00057           }
00058       }
00059     }
00060     void printRTCProcessingTime (std::vector<double>& processes)
00061     {
00062       fprintf(stderr, "[hrpEC] ");
00063       for (unsigned int i=0; i< processes.size(); i++){
00064         fprintf(stderr, "%s(%4.2f), ", rtc_names[i].c_str(),processes[i]*1e3);
00065       }
00066       fprintf(stderr, "[ms]\n");
00067     };
00068     int svc_wrapped (void);
00069 
00070     OpenHRP::ExecutionProfileService::Profile m_profile;
00071     struct timeval m_tv;
00072     int m_priority;
00073     int m_cpu;
00074     std::vector<std::string> rtc_names;
00075     volatile bool m_thread_pending;
00076   };
00077 };
00078 
00079 extern "C"
00080 {
00081   void hrpExecutionContextInit(RTC::Manager* manager);
00082 };
00083 
00084 #endif // hrpEC_h
00085 


hrpsys
Author(s): AIST, Fumio Kanehiro
autogenerated on Wed May 15 2019 05:02:18