NullComponent.cpp
Go to the documentation of this file.
00001 // -*- C++ -*-
00010 #include "hrpsys/util/VectorConvert.h"
00011 #include "NullComponent.h"
00012 
00013 // Module specification
00014 // <rtc-template block="module_spec">
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     // Configuration variables
00028     "conf.default.string", "test",
00029     "conf.default.intvec", "1,2,3",
00030     "conf.default.double", "1.234",
00031 
00032     ""
00033   };
00034 // </rtc-template>
00035 
00036 NullComponent::NullComponent(RTC::Manager* manager)
00037   : RTC::DataFlowComponentBase(manager),
00038     // <rtc-template block="initializer">
00039     m_dataIn("dataIn", m_data),
00040     m_dataOut("dataOut", m_data),
00041     m_NullServicePort("NullService"),
00042     // </rtc-template>
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   // <rtc-template block="bind_config">
00060   // Bind variables and configuration variable
00061   bindParameter("string", confstring, "testtest");
00062   bindParameter("intvec", confintvec, "4,5,6,7");
00063   bindParameter("double", confdouble, "4.567");
00064   
00065   // </rtc-template>
00066 
00067   // Registration: InPort/OutPort/Service
00068   // <rtc-template block="registration">
00069   // Set InPort buffers
00070   addInPort("dataIn", m_dataIn);
00071 
00072   // Set OutPort buffer
00073   addOutPort("dataOut", m_dataOut);
00074   
00075   // Set service provider to Ports
00076   m_NullServicePort.registerProvider("service0", "NullService", m_NullService);
00077   
00078   // Set service consumers to Ports
00079   
00080   // Set CORBA Service Ports
00081   addPort(m_NullServicePort);
00082   
00083   // </rtc-template>
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 RTC::ReturnCode_t NullComponent::onFinalize()
00095 {
00096   return RTC::RTC_OK;
00097 }
00098 */
00099 
00100 /*
00101 RTC::ReturnCode_t NullComponent::onStartup(RTC::UniqueId ec_id)
00102 {
00103   return RTC::RTC_OK;
00104 }
00105 */
00106 
00107 /*
00108 RTC::ReturnCode_t NullComponent::onShutdown(RTC::UniqueId ec_id)
00109 {
00110   return RTC::RTC_OK;
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 RTC::ReturnCode_t NullComponent::onAborting(RTC::UniqueId ec_id)
00149 {
00150   return RTC::RTC_OK;
00151 }
00152 */
00153 
00154 /*
00155 RTC::ReturnCode_t NullComponent::onError(RTC::UniqueId ec_id)
00156 {
00157   return RTC::RTC_OK;
00158 }
00159 */
00160 
00161 /*
00162 RTC::ReturnCode_t NullComponent::onReset(RTC::UniqueId ec_id)
00163 {
00164   return RTC::RTC_OK;
00165 }
00166 */
00167 
00168 /*
00169 RTC::ReturnCode_t NullComponent::onStateUpdate(RTC::UniqueId ec_id)
00170 {
00171   return RTC::RTC_OK;
00172 }
00173 */
00174 
00175 /*
00176 RTC::ReturnCode_t NullComponent::onRateChanged(RTC::UniqueId ec_id)
00177 {
00178   return RTC::RTC_OK;
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 


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