ConfigSample.cpp
Go to the documentation of this file.
1 // -*- C++ -*-
10 #include "ConfigSample.h"
11 #include "VectorConvert.h"
12 
13 // Module specification
14 // <rtc-template block="module_spec">
15 static const char* configsample_spec[] =
16  {
17  "implementation_id", "ConfigSample",
18  "type_name", "ConfigSample",
19  "description", "Configuration example component",
20  "version", "1.0",
21  "vendor", "Noriaki Ando, 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.int_param0", "0",
29  "conf.default.int_param1", "1",
30  "conf.default.double_param0", "0.11",
31  "conf.default.double_param1", "9.9",
32  "conf.default.str_param0", "hoge",
33  "conf.default.str_param1", "dara",
34  "conf.default.vector_param0", "0.0,1.0,2.0,3.0,4.0",
35 
36  ""
37  };
38 // </rtc-template>
39 
40 char ticktack()
41 {
42  static int i(0);
43  const char* c = "/-\\|";
44  i = (i + 1) % 4;
45  return c[i];
46 }
47 
48 
50  : RTC::DataFlowComponentBase(manager)
51  // <rtc-template block="initializer">
52 
53  // </rtc-template>
54 {
55 }
56 
58 {
59 }
60 
61 
63 {
64  // Registration: InPort/OutPort/Service
65  // <rtc-template block="registration">
66  // Set InPort buffers
67 
68  // Set OutPort buffer
69 
70  // Set service provider to Ports
71 
72  // Set service consumers to Ports
73 
74  // Set CORBA Service Ports
75 
76  // </rtc-template>
77 
78  // <rtc-template block="bind_config">
79  // Bind variables and configuration variable
80  bindParameter("int_param0", m_int_param0, "0");
81  bindParameter("int_param1", m_int_param1, "1");
82  bindParameter("double_param0", m_double_param0, "0.11");
83  bindParameter("double_param1", m_double_param1, "9.9");
84  bindParameter("str_param0", m_str_param0, "hoge");
85  bindParameter("str_param1", m_str_param1, "dara");
86  bindParameter("vector_param0", m_vector_param0, "0.0,1.0,2.0,3.0,4.0");
87 
88  // </rtc-template>
89 
90  std::cout << std::endl;
91  std::cout << "Please change configuration values from RtcLink" << std::endl;
92  std::cout << std::endl;
93 
94  return RTC::RTC_OK;
95 }
96 
97 
98 
99 /*
100 RTC::ReturnCode_t ConfigSample::onFinalize()
101 {
102  return RTC::RTC_OK;
103 }
104 */
105 
106 /*
107 RTC::ReturnCode_t ConfigSample::onStartup(RTC::UniqueId ec_id)
108 {
109  return RTC::RTC_OK;
110 }
111 */
112 
113 /*
114 RTC::ReturnCode_t ConfigSample::onShutdown(RTC::UniqueId ec_id)
115 {
116  return RTC::RTC_OK;
117 }
118 */
119 
120 /*
121 RTC::ReturnCode_t ConfigSample::onActivated(RTC::UniqueId ec_id)
122 {
123  return RTC::RTC_OK;
124 }
125 */
126 
127 /*
128 RTC::ReturnCode_t ConfigSample::onDeactivated(RTC::UniqueId ec_id)
129 {
130  return RTC::RTC_OK;
131 }
132 */
133 
134 
136 {
137  static int maxlen(0);
138  int curlen(0);
139  const char* c = " ";
140  if (true)
141  {
142  std::cout << "---------------------------------------" << std::endl;
143  std::cout << " Active Configuration Set: ";
144  std::cout << m_configsets.getActiveId() << c << std::endl;
145  std::cout << "---------------------------------------" << std::endl;
146 
147  std::cout << "int_param0: " << m_int_param0 << c << std::endl;
148  std::cout << "int_param1: " << m_int_param1 << c << std::endl;
149  std::cout << "double_param0: " << m_double_param0 << c << std::endl;
150  std::cout << "double_param1: " << m_double_param1 << c << std::endl;
151  std::cout << "str_param0: " << m_str_param0 << c << std::endl;
152  std::cout << "str_param1: " << m_str_param1 << c << std::endl;
153  for (int i(0), len(m_vector_param0.size()); i < len; ++i)
154  {
155  std::cout << "vector_param0[" << i << "]: ";
156  std::cout << m_vector_param0[i] << c << std::endl;
157  }
158  std::cout << "---------------------------------------" << std::endl;
159 
160  curlen = m_vector_param0.size();
161  maxlen = maxlen > curlen ? maxlen : curlen;
162  for (int i(0), len(maxlen - curlen); i < len; ++i)
163  {
164  std::cout << c << c << std::endl;
165  }
166 
167  std::cout << "Updating.... " << ticktack() << c << std::endl;
168 
169  for (int i(0), len(11 + maxlen); i < len; ++i)
170  {
171  std::cout << "\r";
172  }
173  }
174  if (m_int_param0 > 1000 && m_int_param0 < 1000000)
175  {
177  }
178  else
179  {
180  coil::usleep(100000);
181  }
182  return RTC::RTC_OK;
183 }
184 
185 
186 /*
187 RTC::ReturnCode_t ConfigSample::onAborting(RTC::UniqueId ec_id)
188 {
189  return RTC::RTC_OK;
190 }
191 */
192 
193 /*
194 RTC::ReturnCode_t ConfigSample::onError(RTC::UniqueId ec_id)
195 {
196  return RTC::RTC_OK;
197 }
198 */
199 
200 /*
201 RTC::ReturnCode_t ConfigSample::onReset(RTC::UniqueId ec_id)
202 {
203  return RTC::RTC_OK;
204 }
205 */
206 
207 /*
208 RTC::ReturnCode_t ConfigSample::onStateUpdate(RTC::UniqueId ec_id)
209 {
210  return RTC::RTC_OK;
211 }
212 */
213 
214 /*
215 RTC::ReturnCode_t ConfigSample::onRateChanged(RTC::UniqueId ec_id)
216 {
217  return RTC::RTC_OK;
218 }
219 */
220 
221 
222 
223 extern "C"
224 {
225 
227  {
229  manager->registerFactory(profile,
230  RTC::Create<ConfigSample>,
231  RTC::Delete<ConfigSample>);
232  }
233 
234 };
235 
236 
RT-Component.
DataFlowComponentBase class.
ReturnCode_t
Definition: doil.h:53
std::string m_str_param1
Definition: ConfigSample.h:96
Manager class.
Definition: Manager.h:80
std::string m_str_param0
Definition: ConfigSample.h:95
Configuration example component.
double m_double_param0
Definition: ConfigSample.h:93
virtual RTC::ReturnCode_t onInitialize()
Callback function to initialize.
static const char * configsample_spec[]
ExecutionContextHandle_t UniqueId
char ticktack()
std::vector< double > m_vector_param0
Definition: ConfigSample.h:97
bool bindParameter(const char *param_name, VarType &var, const char *def_val, bool(*trans)(VarType &, const char *)=coil::stringTo)
Setup for configuration parameters.
Definition: RTObject.h:2251
ConfigSample(RTC::Manager *manager)
ConfigAdmin m_configsets
Configuration Administrator Object.
Definition: RTObject.h:4696
virtual RTC::ReturnCode_t onExecute(RTC::UniqueId ec_id)
Callback function to execute periodically.
void ConfigSampleInit(RTC::Manager *manager)
Class represents a set of properties.
Definition: Properties.h:101
const char * getActiveId(void)
Get ID of active configuration set.
Definition: ConfigAdmin.h:796
double m_double_param1
Definition: ConfigSample.h:94
bool registerFactory(coil::Properties &profile, RtcNewFunc new_func, RtcDeleteFunc delete_func)
Register RT-Component Factory.
Definition: Manager.cpp:433
int usleep(useconds_t usec)
Stop a processing at specified micro second time.
Definition: ace/coil/Time.h:51


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Mon Jun 10 2019 14:07:50