00001
00010 #include "hrpsys/util/VectorConvert.h"
00011 #include "NullComponent.h"
00012
00013
00014
00015 static const char* nullcomponent_spec[] =
00016 {
00017 "implementation_id", "NullComponent",
00018 "type_name", "NullComponent",
00019 "description", "null component",
00020 "version", HRPSYS_PACKAGE_VERSION,
00021 "vendor", "AIST",
00022 "category", "example",
00023 "activity_type", "DataFlowComponent",
00024 "max_instance", "10",
00025 "language", "C++",
00026 "lang_type", "compile",
00027
00028 "conf.default.string", "test",
00029 "conf.default.intvec", "1,2,3",
00030 "conf.default.double", "1.234",
00031
00032 ""
00033 };
00034
00035
00036 NullComponent::NullComponent(RTC::Manager* manager)
00037 : RTC::DataFlowComponentBase(manager),
00038
00039 m_dataIn("dataIn", m_data),
00040 m_dataOut("dataOut", m_data),
00041 m_NullServicePort("NullService"),
00042
00043 dummy(0)
00044 {
00045 std::cout << "NullComponent::NullComponent()" << std::endl;
00046 m_data.data = 0;
00047 }
00048
00049 NullComponent::~NullComponent()
00050 {
00051 std::cout << "NullComponent::~NullComponent()" << std::endl;
00052 }
00053
00054
00055
00056 RTC::ReturnCode_t NullComponent::onInitialize()
00057 {
00058 std::cout << m_profile.instance_name << ": onInitialize()" << std::endl;
00059
00060
00061 bindParameter("string", confstring, "testtest");
00062 bindParameter("intvec", confintvec, "4,5,6,7");
00063 bindParameter("double", confdouble, "4.567");
00064
00065
00066
00067
00068
00069
00070 addInPort("dataIn", m_dataIn);
00071
00072
00073 addOutPort("dataOut", m_dataOut);
00074
00075
00076 m_NullServicePort.registerProvider("service0", "NullService", m_NullService);
00077
00078
00079
00080
00081 addPort(m_NullServicePort);
00082
00083
00084
00085 RTC::Properties& prop = getProperties();
00086 std::cout << "prop[\"testconf\"] = " << prop["testconf"] << std::endl;
00087
00088 return RTC::RTC_OK;
00089 }
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114 RTC::ReturnCode_t NullComponent::onActivated(RTC::UniqueId ec_id)
00115 {
00116 std::cout << m_profile.instance_name<< ": onActivated(" << ec_id << ")" << std::endl;
00117 return RTC::RTC_OK;
00118 }
00119
00120 RTC::ReturnCode_t NullComponent::onDeactivated(RTC::UniqueId ec_id)
00121 {
00122 std::cout << m_profile.instance_name<< ": onDeactivated(" << ec_id << ")" << std::endl;
00123 return RTC::RTC_OK;
00124 }
00125
00126 RTC::ReturnCode_t NullComponent::onExecute(RTC::UniqueId ec_id)
00127 {
00128 std::cout << m_profile.instance_name<< ": onExecute(" << ec_id << "), data = " << m_data.data << std::endl;
00129 std::cout << "confstring = " << confstring << std::endl;
00130 std::cout << "confintvec = ";
00131 for (unsigned int i=0; i<confintvec.size(); i++){
00132 std::cout << confintvec[i] << " ";
00133 }
00134 std::cout << std::endl;
00135 std::cout << "confdouble = " << confdouble << std::endl;
00136
00137 while (m_dataIn.isNew()){
00138 m_dataIn.read();
00139 std::cout << m_profile.instance_name << ": read(), data = " << m_data.data << std::endl;
00140 }
00141 m_data.data += 1;
00142
00143 m_dataOut.write();
00144 return RTC::RTC_OK;
00145 }
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184 extern "C"
00185 {
00186
00187 void NullComponentInit(RTC::Manager* manager)
00188 {
00189 RTC::Properties profile(nullcomponent_spec);
00190 manager->registerFactory(profile,
00191 RTC::Create<NullComponent>,
00192 RTC::Delete<NullComponent>);
00193 }
00194
00195 };
00196
00197