SeqIn.cpp
Go to the documentation of this file.
1 // -*- C++ -*-
10 #include "SeqIn.h"
11 #include <iostream>
12 
13 // Connector Listener Dump Flag
15 
16 // Module specification
17 // <rtc-template block="module_spec">
18 static const char* seqin_spec[] =
19  {
20  "implementation_id", "SeqIn",
21  "type_name", "SequenceInComponent",
22  "description", "Sequence InPort component",
23  "version", "1.0",
24  "vendor", "Noriaki Ando, AIST",
25  "category", "example",
26  "activity_type", "DataFlowComponent",
27  "max_instance", "10",
28  "language", "C++",
29  "lang_type", "compile",
30  ""
31  };
32 // </rtc-template>
33 
35  : RTC::DataFlowComponentBase(manager),
36  // <rtc-template block="initializer">
37  m_OctetIn("Octet", m_Octet),
38  m_ShortIn("Short", m_Short),
39  m_LongIn("Long", m_Long),
40  m_FloatIn("Float", m_Float),
41  m_DoubleIn("Double", m_Double),
42  m_OctetSeqIn("OctetSeq", m_OctetSeq),
43  m_ShortSeqIn("ShortSeq", m_ShortSeq),
44  m_LongSeqIn("LongSeq", m_LongSeq),
45  m_FloatSeqIn("FloatSeq", m_FloatSeq),
46  m_DoubleSeqIn("DoubleSeq", m_DoubleSeq)
47 
48  // </rtc-template>
49 {
50 }
51 
53 {
54 }
55 
56 
57 
59 {
60  // Registration: InPort/OutPort/Service
61  // <rtc-template block="registration">
62  // Set InPort buffers
63  addInPort("Octet", m_OctetIn);
64  addInPort("Short", m_ShortIn);
65  addInPort("Long", m_LongIn);
66  addInPort("Float", m_FloatIn);
67  addInPort("Double", m_DoubleIn);
68  addInPort("OctetSeq", m_OctetSeqIn);
69  addInPort("ShortSeq", m_ShortSeqIn);
70  addInPort("LongSeq", m_LongSeqIn);
71  addInPort("FloatSeq", m_FloatSeqIn);
72  addInPort("DoubleSeq", m_DoubleSeqIn);
73 
74  // check m_LongIn port only
76  new DataListener("ON_BUFFER_WRITE"));
78  new DataListener("ON_BUFFER_FULL"));
80  new DataListener("ON_BUFFER_WRITE_TIMEOUT"));
82  new DataListener("ON_BUFFER_OVERWRITE"));
84  new DataListener("ON_BUFFER_READ"));
86  new DataListener("ON_SEND"));
88  new DataListener("ON_RECEIVED"));
90  new DataListener("ON_RECEIVER_FULL"));
92  new DataListener("ON_RECEIVER_TIMEOUT"));
93 
95  new ConnListener("ON_BUFFER_EMPTY"));
97  new ConnListener("ON_BUFFER_READ_TIMEOUT"));
99  new ConnListener("ON_SENDER_EMPTY"));
101  new ConnListener("ON_SENDER_TIMEOUT"));
103  new ConnListener("ON_SENDER_ERROR"));
105  new ConnListener("ON_CONNECT"));
107  new ConnListener("ON_DISCONNECT"));
108 
109  // Set OutPort buffer
110 
111  // Set service provider to Ports
112 
113  // Set service consumers to Ports
114 
115  // Set CORBA Service Ports
116 
117  // </rtc-template>
118 
119  return RTC::RTC_OK;
120 }
121 
122 
123 /*
124 RTC::ReturnCode_t SeqIn::onFinalize()
125 {
126  return RTC::RTC_OK;
127 }
128 */
129 
130 /*
131 RTC::ReturnCode_t SeqIn::onStartup(RTC::UniqueId ec_id)
132 {
133  return RTC::RTC_OK;
134 }
135 */
136 
137 /*
138 RTC::ReturnCode_t SeqIn::onShutdown(RTC::UniqueId ec_id)
139 {
140  return RTC::RTC_OK;
141 }
142 */
143 
144 /*
145 RTC::ReturnCode_t SeqIn::onActivated(RTC::UniqueId ec_id)
146 {
147  return RTC::RTC_OK;
148 }
149 */
150 
151 /*
152 RTC::ReturnCode_t SeqIn::onDeactivated(RTC::UniqueId ec_id)
153 {
154  return RTC::RTC_OK;
155 }
156 */
157 
158 
160 {
161  m_DoubleIn.read();
162  m_FloatIn.read();
163  m_LongIn.read();
164  m_ShortIn.read();
165  m_OctetIn.read();
167  m_FloatSeqIn.read();
168  m_LongSeqIn.read();
169  m_ShortSeqIn.read();
170  m_OctetSeqIn.read();
171 
172  int h_col(4);
173  int col(13);
174  int all_col = h_col + (col * 5);
175  int all_row(0);
176 
177  int d_size(1);
178  int f_size(1);
179  int l_size(1);
180  int s_size(1);
181  int o_size(1);
182 
183  int ds_size(m_DoubleSeq.data.length());
184  int fs_size(m_FloatSeq.data.length());
185  int ls_size(m_LongSeq.data.length());
186  int ss_size(m_ShortSeq.data.length());
187  int os_size(m_OctetSeq.data.length());
188 
189  int max_size;
190 
191  std::vector<int> in_size;
192  std::vector<int>::iterator it;
193  in_size.reserve(10);
194  in_size.push_back(d_size);
195  in_size.push_back(f_size);
196  in_size.push_back(l_size);
197  in_size.push_back(s_size);
198  in_size.push_back(o_size);
199  in_size.push_back(ds_size);
200  in_size.push_back(fs_size);
201  in_size.push_back(ls_size);
202  in_size.push_back(ss_size);
203  in_size.push_back(os_size);
204 
205  it = std::max_element(in_size.begin(), in_size.end());
206 
207  max_size = *it;
208 
209  std::cout.width(h_col + (col * 5));
210  std::cout.fill('-');
211  std::cout << "-" << std::endl; all_row++;
212 
213  std::cout.width(h_col);
214  std::cout.setf(std::ios::right, std::ios::adjustfield);
215  std::cout.fill(' ');
216  std::cout << " ";
217  std::cout.width(col);
218  std::cout.setf(std::ios::right, std::ios::adjustfield);
219  std::cout.fill(' ');
220  std::cout << "Double";
221  std::cout.width(col);
222  std::cout.setf(std::ios::right, std::ios::adjustfield);
223  std::cout.fill(' ');
224  std::cout << "Float";
225  std::cout.width(col);
226  std::cout.setf(std::ios::right, std::ios::adjustfield);
227  std::cout.fill(' ');
228  std::cout << "Long";
229  std::cout.width(col);
230  std::cout.setf(std::ios::right, std::ios::adjustfield);
231  std::cout.fill(' ');
232  std::cout << "Short";
233  std::cout.width(col);
234  std::cout.setf(std::ios::right, std::ios::adjustfield);
235  std::cout.fill(' ');
236  std::cout << "Octet";
237  std::cout << std::endl; all_row++;
238 
239  std::cout.width(all_col);
240  std::cout.fill('-');
241  std::cout << "-" << std::endl; all_row++;
242 
243  for (int i = 0; i < (all_col - 10)/ 2; i++)
244  std::cout << " ";
245  std::cout << "Basic type";
246  for (int i = 0; i < (all_col - 10)/ 2; i++)
247  std::cout << " ";
248  std::cout << std::endl; all_row++;
249 
250  std::cout.width(h_col + (col * 5));
251  std::cout.fill('-');
252  std::cout << "-" << std::endl; all_row++;
253 
254  std::cout.width(h_col);
255  std::cout.setf(std::ios::right, std::ios::adjustfield);
256  std::cout.fill(' ');
257  std::cout << " ";
258  std::cout.width(col);
259  std::cout.setf(std::ios::right, std::ios::adjustfield);
260  std::cout.fill(' ');
261  std::cout << m_Double.data;
262  std::cout.width(col);
263  std::cout.setf(std::ios::right, std::ios::adjustfield);
264  std::cout.fill(' ');
265  std::cout << m_Float.data;
266  std::cout.width(col);
267  std::cout.setf(std::ios::right, std::ios::adjustfield);
268  std::cout.fill(' ');
269  std::cout << m_Long.data;
270  std::cout.width(col);
271  std::cout.setf(std::ios::right, std::ios::adjustfield);
272  std::cout.fill(' ');
273  std::cout << m_Short.data;
274  std::cout.width(col);
275  std::cout.setf(std::ios::right, std::ios::adjustfield);
276  std::cout.fill(' ');
277  std::cout << int(m_Octet.data) << "[";
278  if (int(m_Octet.data) < 0x20 || int(m_Octet.data) > 0x7e)
279  {
280  std::cout << " " << "]";
281  }
282  else
283  {
284  std::cout << m_Octet.data << "]";
285  }
286  std::cout << std::endl; all_row++;
287 
288  std::cout.width(all_col);
289  std::cout.fill('-');
290  std::cout << "-" << std::endl; all_row++;
291 
292  for (int i = 0; i < (all_col - 13)/ 2; i++)
293  std::cout << " ";
294  std::cout << "Sequence type";
295  for (int i = 0; i < (all_col - 13)/ 2; i++)
296  std::cout << " ";
297  std::cout << std::endl; all_row++;
298 
299  std::cout.width(all_col);
300  std::cout.fill('-');
301  std::cout << "-" << std::endl; all_row++;
302 
303  for (int i = 0; i < max_size; i++)
304  {
305  std::cout.width(h_col - 2);
306  std::cout.setf(std::ios::right, std::ios::adjustfield);
307  std::cout.fill(' ');
308  std::cout << i;
309  std::cout.width(2);
310  std::cout << ": ";
311 
312  std::cout.width(col);
313  std::cout.setf(std::ios::right, std::ios::adjustfield);
314  std::cout.fill(' ');
315  if (i < ds_size)
316  {
317  std::cout << m_DoubleSeq.data[i];
318  }
319  else
320  {
321  std::cout << "-";
322  }
323 
324  std::cout.width(col);
325  std::cout.setf(std::ios::right, std::ios::adjustfield);
326  std::cout.fill(' ');
327  if (i < fs_size)
328  {
329  std::cout << m_FloatSeq.data[i];
330  }
331  else
332  {
333  std::cout << "-";
334  }
335 
336  std::cout.width(col);
337  std::cout.setf(std::ios::right, std::ios::adjustfield);
338  std::cout.fill(' ');
339  if (i < ls_size)
340  {
341  std::cout << m_LongSeq.data[i];
342  }
343  else
344  {
345  std::cout << "-";
346  }
347 
348  std::cout.width(col);
349  std::cout.setf(std::ios::right, std::ios::adjustfield);
350  std::cout.fill(' ');
351  if (i < ss_size)
352  {
353  std::cout << m_ShortSeq.data[i];
354  }
355  else
356  {
357  std::cout << "-";
358  }
359 
360  std::cout.width(col);
361  std::cout.setf(std::ios::right, std::ios::adjustfield);
362  std::cout.fill(' ');
363  if (i < os_size)
364  {
365  std::cout << int(m_OctetSeq.data[i]) << "[";
366  if (int(m_OctetSeq.data[i]) < 0x20 || int(m_OctetSeq.data[i]) > 0x7e)
367  {
368  std::cout << " " << "]";
369  }
370  else
371  {
372  std::cout << m_OctetSeq.data[i] << "]";
373  }
374  }
375  else
376  {
377  std::cout << "-";
378  }
379 
380  std::cout << std::endl; all_row++;
381  }
382 
383  // Connector Listener Dump check
385  {
386  for (int i = 0 ; i < all_row; i++)
387  {
388  std::cout << "\r";
389  }
390  }
391 
392  return RTC::RTC_OK;
393 }
394 
395 
396 /*
397 RTC::ReturnCode_t SeqIn::onAborting(RTC::UniqueId ec_id)
398 {
399  return RTC::RTC_OK;
400 }
401 */
402 
403 /*
404 RTC::ReturnCode_t SeqIn::onError(RTC::UniqueId ec_id)
405 {
406  return RTC::RTC_OK;
407 }
408 */
409 
410 /*
411 RTC::ReturnCode_t SeqIn::onReset(RTC::UniqueId ec_id)
412 {
413  return RTC::RTC_OK;
414 }
415 */
416 
417 /*
418 RTC::ReturnCode_t SeqIn::onStateUpdate(RTC::UniqueId ec_id)
419 {
420  return RTC::RTC_OK;
421 }
422 */
423 
424 /*
425 RTC::ReturnCode_t SeqIn::onRateChanged(RTC::UniqueId ec_id)
426 {
427  return RTC::RTC_OK;
428 }
429 */
430 
431 
432 
433 extern "C"
434 {
435 
437  {
438  coil::Properties profile(seqin_spec);
439  manager->registerFactory(profile,
440  RTC::Create<SeqIn>,
441  RTC::Delete<SeqIn>);
442  }
443 
444 };
InPort< TimedShortSeq > m_ShortSeqIn
Definition: SeqIn.h:174
TimedLong m_Long
Definition: SeqIn.h:165
RT-Component.
TimedFloat m_Float
Definition: SeqIn.h:167
TimedFloatSeq m_FloatSeq
Definition: SeqIn.h:177
InPort< TimedOctet > m_OctetIn
Definition: SeqIn.h:162
InPort< TimedOctetSeq > m_OctetSeqIn
Definition: SeqIn.h:172
DataFlowComponentBase class.
ReturnCode_t
Definition: doil.h:53
~SeqIn()
Definition: SeqIn.cpp:52
InPort< TimedShort > m_ShortIn
Definition: SeqIn.h:164
Manager class.
Definition: Manager.h:80
bool g_Listener_dump_enabled
Definition: SeqIn.cpp:14
InPort< TimedFloat > m_FloatIn
Definition: SeqIn.h:168
TimedLongSeq m_LongSeq
Definition: SeqIn.h:175
TimedOctetSeq m_OctetSeq
Definition: SeqIn.h:171
virtual RTC::ReturnCode_t onInitialize()
Callback function to initialize.
Definition: SeqIn.cpp:58
TimedShortSeq m_ShortSeq
Definition: SeqIn.h:173
ExecutionContextHandle_t UniqueId
void SeqInInit(RTC::Manager *manager)
Definition: SeqIn.cpp:436
virtual RTC::ReturnCode_t onExecute(RTC::UniqueId ec_id)
Callback function to execute periodically.
Definition: SeqIn.cpp:159
InPort< TimedLongSeq > m_LongSeqIn
Definition: SeqIn.h:176
Sequence InPort component.
static const char * seqin_spec[]
Definition: SeqIn.cpp:18
void addConnectorListener(ConnectorListenerType callback_type, ConnectorListener *listener, bool autoclean=true)
Adding ConnectorListener type listener.
Definition: InPortBase.cpp:386
InPort< TimedLong > m_LongIn
Definition: SeqIn.h:166
TimedDoubleSeq m_DoubleSeq
Definition: SeqIn.h:179
InPort< TimedDoubleSeq > m_DoubleSeqIn
Definition: SeqIn.h:180
Class represents a set of properties.
Definition: Properties.h:101
SeqIn(RTC::Manager *manager)
Definition: SeqIn.cpp:34
InPort< TimedDouble > m_DoubleIn
Definition: SeqIn.h:170
TimedShort m_Short
Definition: SeqIn.h:163
bool addInPort(const char *name, InPortBase &inport)
[local interface] Register DataInPort
Definition: RTObject.cpp:1604
TimedOctet m_Octet
Definition: SeqIn.h:161
void addConnectorDataListener(ConnectorDataListenerType listener_type, ConnectorDataListener *listener, bool autoclean=true)
Adding BufferDataListener type listener.
Definition: InPortBase.cpp:347
bool registerFactory(coil::Properties &profile, RtcNewFunc new_func, RtcDeleteFunc delete_func)
Register RT-Component Factory.
Definition: Manager.cpp:433
InPort< TimedFloatSeq > m_FloatSeqIn
Definition: SeqIn.h:178
TimedDouble m_Double
Definition: SeqIn.h:169
bool read()
Readout the value from DataPort.
Definition: InPort.h:378


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Thu Jun 6 2019 19:26:00