NullComponent.cpp
Go to the documentation of this file.
1 // -*- C++ -*-
10 #include "hrpsys/util/VectorConvert.h"
11 #include "NullComponent.h"
12 
13 // Module specification
14 // <rtc-template block="module_spec">
15 static const char* nullcomponent_spec[] =
16  {
17  "implementation_id", "NullComponent",
18  "type_name", "NullComponent",
19  "description", "null component",
20  "version", HRPSYS_PACKAGE_VERSION,
21  "vendor", "AIST",
22  "category", "example",
23  "activity_type", "DataFlowComponent",
24  "max_instance", "10",
25  "language", "C++",
26  "lang_type", "compile",
27  // Configuration variables
28  "conf.default.string", "test",
29  "conf.default.intvec", "1,2,3",
30  "conf.default.double", "1.234",
31 
32  ""
33  };
34 // </rtc-template>
35 
37  : RTC::DataFlowComponentBase(manager),
38  // <rtc-template block="initializer">
39  m_dataIn("dataIn", m_data),
40  m_dataOut("dataOut", m_data),
41  m_NullServicePort("NullService"),
42  // </rtc-template>
43  dummy(0)
44 {
45  std::cout << "NullComponent::NullComponent()" << std::endl;
46  m_data.data = 0;
47 }
48 
50 {
51  std::cout << "NullComponent::~NullComponent()" << std::endl;
52 }
53 
54 
55 
56 RTC::ReturnCode_t NullComponent::onInitialize()
57 {
58  std::cout << m_profile.instance_name << ": onInitialize()" << std::endl;
59  // <rtc-template block="bind_config">
60  // Bind variables and configuration variable
61  bindParameter("string", confstring, "testtest");
62  bindParameter("intvec", confintvec, "4,5,6,7");
63  bindParameter("double", confdouble, "4.567");
64 
65  // </rtc-template>
66 
67  // Registration: InPort/OutPort/Service
68  // <rtc-template block="registration">
69  // Set InPort buffers
70  addInPort("dataIn", m_dataIn);
71 
72  // Set OutPort buffer
73  addOutPort("dataOut", m_dataOut);
74 
75  // Set service provider to Ports
76  m_NullServicePort.registerProvider("service0", "NullService", m_NullService);
77 
78  // Set service consumers to Ports
79 
80  // Set CORBA Service Ports
82 
83  // </rtc-template>
84 
86  std::cout << "prop[\"testconf\"] = " << prop["testconf"] << std::endl;
87 
88  return RTC::RTC_OK;
89 }
90 
91 
92 
93 /*
94 RTC::ReturnCode_t NullComponent::onFinalize()
95 {
96  return RTC::RTC_OK;
97 }
98 */
99 
100 /*
101 RTC::ReturnCode_t NullComponent::onStartup(RTC::UniqueId ec_id)
102 {
103  return RTC::RTC_OK;
104 }
105 */
106 
107 /*
108 RTC::ReturnCode_t NullComponent::onShutdown(RTC::UniqueId ec_id)
109 {
110  return RTC::RTC_OK;
111 }
112 */
113 
115 {
116  std::cout << m_profile.instance_name<< ": onActivated(" << ec_id << ")" << std::endl;
117  return RTC::RTC_OK;
118 }
119 
121 {
122  std::cout << m_profile.instance_name<< ": onDeactivated(" << ec_id << ")" << std::endl;
123  return RTC::RTC_OK;
124 }
125 
126 RTC::ReturnCode_t NullComponent::onExecute(RTC::UniqueId ec_id)
127 {
128  std::cout << m_profile.instance_name<< ": onExecute(" << ec_id << "), data = " << m_data.data << std::endl;
129  std::cout << "confstring = " << confstring << std::endl;
130  std::cout << "confintvec = ";
131  for (unsigned int i=0; i<confintvec.size(); i++){
132  std::cout << confintvec[i] << " ";
133  }
134  std::cout << std::endl;
135  std::cout << "confdouble = " << confdouble << std::endl;
136 
137  while (m_dataIn.isNew()){
138  m_dataIn.read();
139  std::cout << m_profile.instance_name << ": read(), data = " << m_data.data << std::endl;
140  }
141  m_data.data += 1;
142 
143  m_dataOut.write();
144  return RTC::RTC_OK;
145 }
146 
147 /*
148 RTC::ReturnCode_t NullComponent::onAborting(RTC::UniqueId ec_id)
149 {
150  return RTC::RTC_OK;
151 }
152 */
153 
154 /*
155 RTC::ReturnCode_t NullComponent::onError(RTC::UniqueId ec_id)
156 {
157  return RTC::RTC_OK;
158 }
159 */
160 
161 /*
162 RTC::ReturnCode_t NullComponent::onReset(RTC::UniqueId ec_id)
163 {
164  return RTC::RTC_OK;
165 }
166 */
167 
168 /*
169 RTC::ReturnCode_t NullComponent::onStateUpdate(RTC::UniqueId ec_id)
170 {
171  return RTC::RTC_OK;
172 }
173 */
174 
175 /*
176 RTC::ReturnCode_t NullComponent::onRateChanged(RTC::UniqueId ec_id)
177 {
178  return RTC::RTC_OK;
179 }
180 */
181 
182 
183 
184 extern "C"
185 {
186 
188  {
190  manager->registerFactory(profile,
191  RTC::Create<NullComponent>,
192  RTC::Delete<NullComponent>);
193  }
194 
195 };
196 
197 
ComponentProfile m_profile
png_infop png_charpp int png_charpp profile
virtual RTC::ReturnCode_t onActivated(RTC::UniqueId ec_id)
InPort< TimedDouble > m_dataIn
virtual ~NullComponent()
Destructor.
null component
RTC::CorbaPort m_NullServicePort
png_uint_32 i
coil::Properties & getProperties()
bool addOutPort(const char *name, OutPortBase &outport)
NullComponent(RTC::Manager *manager)
Constructor.
ExecutionContextHandle_t UniqueId
bool bindParameter(const char *param_name, VarType &var, const char *def_val, bool(*trans)(VarType &, const char *)=coil::stringTo)
TimedDouble m_data
void NullComponentInit(RTC::Manager *manager)
virtual RTC::ReturnCode_t onDeactivated(RTC::UniqueId ec_id)
prop
virtual RTC::ReturnCode_t onExecute(RTC::UniqueId ec_id)
OutPort< TimedDouble > m_dataOut
static const char * nullcomponent_spec[]
virtual bool isNew()
bool addPort(PortBase &port)
virtual bool write(DataType &value)
std::string confstring
NullService_impl m_NullService
bool addInPort(const char *name, InPortBase &inport)
std::vector< int > confintvec
bool registerFactory(coil::Properties &profile, RtcNewFunc new_func, RtcDeleteFunc delete_func)
virtual RTC::ReturnCode_t onInitialize()
bool registerProvider(const char *instance_name, const char *type_name, PortableServer::RefCountServantBase &provider)


hrpsys
Author(s): AIST, Fumio Kanehiro
autogenerated on Thu May 6 2021 02:41:50