SimpleIO/ConsoleOut.cpp
Go to the documentation of this file.
1 // -*- C++ -*-
10 #include "ConsoleOut.h"
11 
12 // Module specification
13 // <rtc-template block="module_spec">
14 static const char* consoleout_spec[] =
15  {
16  "implementation_id", "ConsoleOut",
17  "type_name", "ConsoleOut",
18  "description", "Console output component",
19  "version", "1.0",
20  "vendor", "Noriaki Ando, AIST",
21  "category", "example",
22  "activity_type", "DataFlowComponent",
23  "max_instance", "10",
24  "language", "C++",
25  "lang_type", "compile",
26  ""
27  };
28 // </rtc-template>
29 
31  : RTC::DataFlowComponentBase(manager),
32  // <rtc-template block="initializer">
33  m_inIn("in", m_in)
34 
35  // </rtc-template>
36 {
37  // Registration: InPort/OutPort/Service
38  // <rtc-template block="registration">
39  // Set InPort buffers
40 
41  // Set OutPort buffer
42 
43  // Set service provider to Ports
44 
45  // Set service consumers to Ports
46 
47  // Set CORBA Service Ports
48 
49  // </rtc-template>
50 
51 }
52 
54 {
55 }
56 
57 
59 {
60  addInPort("in", m_inIn);
61 
63  new DataListener("ON_BUFFER_WRITE"));
65  new DataListener("ON_BUFFER_FULL"));
67  new DataListener("ON_BUFFER_WRITE_TIMEOUT"));
69  new DataListener("ON_BUFFER_OVERWRITE"));
71  new DataListener("ON_BUFFER_READ"));
73  new DataListener("ON_SEND"));
75  new DataListener("ON_RECEIVED"));
77  new DataListener("ON_RECEIVER_FULL"));
79  new DataListener("ON_RECEIVER_TIMEOUT"));
80 
82  new ConnListener("ON_BUFFER_EMPTY"));
84  new ConnListener("ON_BUFFER_READ_TIMEOUT"));
86  new ConnListener("ON_SENDER_EMPTY"));
88  new ConnListener("ON_SENDER_TIMEOUT"));
90  new ConnListener("ON_SENDER_ERROR"));
92  new ConnListener("ON_CONNECT"));
94  new ConnListener("ON_DISCONNECT"));
95 
96 
97  return RTC::RTC_OK;
98 }
99 
101 {
102  if (m_inIn.isNew())
103  {
104  m_inIn.read();
105  std::cout << "Received: " << m_in.data << std::endl;
106  std::cout << "TimeStamp: " << m_in.tm.sec << "[s] ";
107  std::cout << m_in.tm.nsec << "[ns]" << std::endl;
108  }
109  coil::usleep(1000);
110 
111  return RTC::RTC_OK;
112 }
113 
114 
115 extern "C"
116 {
117 
119  {
120 // RTC::Properties profile(consoleout_spec);
122  manager->registerFactory(profile,
123  RTC::Create<ConsoleOut>,
124  RTC::Delete<ConsoleOut>);
125  }
126 
127 };
128 
129 
DataFlowComponentBase class.
ReturnCode_t
Definition: doil.h:53
static const char * consoleout_spec[]
Manager class.
Definition: Manager.h:80
ExecutionContextHandle_t UniqueId
void addConnectorListener(ConnectorListenerType callback_type, ConnectorListener *listener, bool autoclean=true)
Adding ConnectorListener type listener.
Definition: InPortBase.cpp:386
virtual RTC::ReturnCode_t onInitialize()
Callback function to initialize.
virtual RTC::ReturnCode_t onExecute(RTC::UniqueId ec_id)
Callback function to execute periodically.
Class represents a set of properties.
Definition: Properties.h:101
ConsoleOut(RTC::Manager *manager)
virtual bool isNew()
Check whether the data is newest.
Definition: InPort.h:225
bool addInPort(const char *name, InPortBase &inport)
[local interface] Register DataInPort
Definition: RTObject.cpp:1604
InPort< TimedLong > m_inIn
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
void ConsoleOutInit(RTC::Manager *manager)
bool read()
Readout the value from DataPort.
Definition: InPort.h:378
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:51