Go to the documentation of this file.00001
00007 #include "RTSample.h"
00008
00009
00010
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
00025 ""
00026 };
00027
00028
00029 RTSample::RTSample(RTC::Manager* manager)
00030
00031 : RTC::DataFlowComponentBase(manager)
00032
00033 {
00034 }
00035
00036 RTSample::~RTSample()
00037 {
00038 }
00039
00040
00041 RTC::ReturnCode_t RTSample::onInitialize()
00042 {
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061 return RTC::RTC_OK;
00062 }
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
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
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
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