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 
00039     OpenHRP::ExecutionProfileService::Profile *getProfile();
00040     OpenHRP::ExecutionProfileService::ComponentProfile getComponentProfile(RTC::LightweightRTObject_ptr obj);
00041     void resetProfile();
00042     //
00043     bool enterRT();
00044     bool exitRT();
00045     bool waitForNextPeriod();
00046   private:
00047     template <class T>
00048     void getProperty(coil::Properties& prop, const char* key, T& value)
00049     {
00050     if (prop.findNode(key) != 0)
00051       {
00052         T tmp;
00053         if (coil::stringTo(tmp, prop[key].c_str()))
00054           {
00055             value = tmp;
00056           }
00057       }
00058     }
00059     void printRTCProcessingTime (std::vector<double>& processes)
00060     {
00061       fprintf(stderr, "[hrpEC] ");
00062       for (unsigned int i=0; i< processes.size(); i++){
00063         fprintf(stderr, "%s(%4.2f), ", rtc_names[i].c_str(),processes[i]*1e3);
00064       }
00065       fprintf(stderr, "[ms]\n");
00066     };
00067     OpenHRP::ExecutionProfileService::Profile m_profile;
00068     struct timeval m_tv;
00069     int m_priority;
00070     std::vector<std::string> rtc_names;
00071   };
00072 };
00073 
00074 extern "C"
00075 {
00076   void hrpExecutionContextInit(RTC::Manager* manager);
00077 };
00078 
00079 #endif // hrpEC_h
00080 


hrpsys
Author(s): AIST, Fumio Kanehiro
autogenerated on Wed Sep 6 2017 02:35:55