RTSample.cpp
Go to the documentation of this file.
00001 // -*- C++ -*-
00007 #include "RTSample.h"
00008 
00009 // Module specification
00010 // <rtc-template block="module_spec">
00011 static const char* rtsample_spec[] =
00012   {
00013     "implementation_id", "RTSample",
00014     "type_name",         "RTSample",
00015     "description",       "Realtime periodic execution example component",
00016     "version",           "1.0",
00017     "vendor",            "Noriaki Ando, AIST",
00018     "category",          "example",
00019     "activity_type",     "PERIODIC",
00020     "kind",              "DataFlowComponent",
00021     "max_instance",      "10",
00022     "language",          "C++",
00023     "lang_type",         "compile",
00024     // Configuration variables
00025     ""
00026   };
00027 // </rtc-template>
00028 
00029 RTSample::RTSample(RTC::Manager* manager)
00030     // <rtc-template block="initializer">
00031   : RTC::DataFlowComponentBase(manager)
00032     // </rtc-template>
00033 {
00034 }
00035 
00036 RTSample::~RTSample()
00037 {
00038 }
00039 
00040 
00041 RTC::ReturnCode_t RTSample::onInitialize()
00042 {
00043   // Registration: InPort/OutPort/Service
00044   // <rtc-template block="registration">
00045   // Set InPort buffers
00046 
00047   // Set OutPort buffer
00048 
00049   // Set service provider to Ports
00050 
00051   // Set service consumers to Ports
00052 
00053   // Set CORBA Service Ports
00054 
00055   // </rtc-template>
00056 
00057   // <rtc-template block="bind_config">
00058   // Bind variables and configuration variable
00059 
00060   // </rtc-template>
00061   return RTC::RTC_OK;
00062 }
00063 
00064 
00065 /*
00066 RTC::ReturnCode_t RTSample::onFinalize()
00067 {
00068   return RTC::RTC_OK;
00069 }
00070 */
00071 /*
00072 RTC::ReturnCode_t RTSample::onStartup(RTC::UniqueId ec_id)
00073 {
00074   return RTC::RTC_OK;
00075 }
00076 */
00077 /*
00078 RTC::ReturnCode_t RTSample::onShutdown(RTC::UniqueId ec_id)
00079 {
00080   return RTC::RTC_OK;
00081 }
00082 */
00083 
00084 RTC::ReturnCode_t RTSample::onActivated(RTC::UniqueId ec_id)
00085 {
00086   m_tm.tick();
00087   return RTC::RTC_OK;
00088 }
00089 
00090 
00091 RTC::ReturnCode_t RTSample::onDeactivated(RTC::UniqueId ec_id)
00092 {
00093   double tm_max, tm_min, tm_mean, tm_stddev;
00094   m_tm.getStatistics(tm_max, tm_min, tm_mean, tm_stddev);
00095   std::cout << "max:    " << tm_max * 1000 << " [ms]" << std::endl;
00096   std::cout << "min:    " << tm_min * 1000 << " [ms]" << std::endl;
00097   std::cout << "mean:   " << tm_mean * 1000 << " [ms]" << std::endl;
00098   std::cout << "stddev: " << tm_stddev * 1000 << " [ms]" << std::endl;
00099   return RTC::RTC_OK;
00100 }
00101 
00102 
00103 RTC::ReturnCode_t RTSample::onExecute(RTC::UniqueId ec_id)
00104 {
00105   static int count;
00106   m_tm.tack();
00107   m_tm.tick();
00108 
00109   if (count > 1000)
00110     {
00111       count = 0;
00112       double tm_max, tm_min, tm_mean, tm_stddev;
00113       m_tm.getStatistics(tm_max, tm_min, tm_mean, tm_stddev);
00114       std::cout << "max:    " << tm_max * 1000 << " [ms]" << std::endl;
00115       std::cout << "min:    " << tm_min * 1000 << " [ms]" << std::endl;
00116       std::cout << "mean:   " << tm_mean * 1000 << " [ms]" << std::endl;
00117       std::cout << "stddev: " << tm_stddev * 1000 << " [ms]" << std::endl;
00118     }
00119 
00120   ++count;
00121   return RTC::RTC_OK;
00122 }
00123 
00124 /*
00125 RTC::ReturnCode_t RTSample::onAborting(RTC::UniqueId ec_id)
00126 {
00127   return RTC::RTC_OK;
00128 }
00129 */
00130 /*
00131 RTC::ReturnCode_t RTSample::onError(RTC::UniqueId ec_id)
00132 {
00133   return RTC::RTC_OK;
00134 }
00135 */
00136 /*
00137 RTC::ReturnCode_t RTSample::onReset(RTC::UniqueId ec_id)
00138 {
00139   return RTC::RTC_OK;
00140 }
00141 */
00142 /*
00143 RTC::ReturnCode_t RTSample::onStateUpdate(RTC::UniqueId ec_id)
00144 {
00145   return RTC::RTC_OK;
00146 }
00147 */
00148 /*
00149 RTC::ReturnCode_t RTSample::onRateChanged(RTC::UniqueId ec_id)
00150 {
00151   return RTC::RTC_OK;
00152 }
00153 */
00154 
00155 
00156 extern "C"
00157 {
00158  
00159   void RTSampleInit(RTC::Manager* manager)
00160   {
00161     coil::Properties profile(rtsample_spec);
00162     manager->registerFactory(profile,
00163                              RTC::Create<RTSample>,
00164                              RTC::Delete<RTSample>);
00165   }
00166   
00167 };
00168 
00169 
00170 


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Sat Jun 8 2019 18:49:06