Controller.cpp
Go to the documentation of this file.
1 // -*- C++ -*-
7 #include "Controller.h"
8 
9 // Module specification
10 // <rtc-template block="module_spec">
11 static const char* controller_spec[] =
12  {
13  "implementation_id", "Controller",
14  "type_name", "Controller",
15  "description", "Controller component",
16  "version", "1.0",
17  "vendor", "Noriaki Ando, AIST",
18  "category", "example",
19  "activity_type", "SPORADIC",
20  "kind", "DataFlowComponent",
21  "max_instance", "10",
22  "language", "C++",
23  "lang_type", "compile",
24  // Configuration variables
25  ""
26  };
27 // </rtc-template>
28 
30  // <rtc-template block="initializer">
31  : RTC::DataFlowComponentBase(manager),
32  m_inIn("in", m_in),
33  m_outOut("out", m_out)
34  // </rtc-template>
35 {
36 }
37 
39 {
40 }
41 
42 
44 {
45  // Registration: InPort/OutPort/Service
46  // <rtc-template block="registration">
47  // Set InPort buffers
48  addInPort("in", m_inIn);
49 
50  // Set OutPort buffer
51  addOutPort("out", m_outOut);
52 
53  // Set service provider to Ports
54 
55  // Set service consumers to Ports
56 
57  // Set CORBA Service Ports
58 
59  // </rtc-template>
60 
61  // <rtc-template block="bind_config">
62  // Bind variables and configuration variable
63 
64  // </rtc-template>
65  return RTC::RTC_OK;
66 }
67 
68 
69 /*
70 RTC::ReturnCode_t Controller::onFinalize()
71 {
72  return RTC::RTC_OK;
73 }
74 */
75 /*
76 RTC::ReturnCode_t Controller::onStartup(RTC::UniqueId ec_id)
77 {
78  return RTC::RTC_OK;
79 }
80 */
81 /*
82 RTC::ReturnCode_t Controller::onShutdown(RTC::UniqueId ec_id)
83 {
84  return RTC::RTC_OK;
85 }
86 */
87 /*
88 RTC::ReturnCode_t Controller::onActivated(RTC::UniqueId ec_id)
89 {
90  return RTC::RTC_OK;
91 }
92 */
93 /*
94 RTC::ReturnCode_t Controller::onDeactivated(RTC::UniqueId ec_id)
95 {
96  return RTC::RTC_OK;
97 }
98 */
99 
100 
102 {
103  if (m_inIn.isNew()) {
104  m_inIn.read();
105  std::cout << "Controller Received data: " << m_in.data << std::endl;
106  m_out.data = m_in.data * 2;
107  m_outOut.write();
108  }
109  return RTC::RTC_OK;
110 }
111 
112 
113 /*
114 RTC::ReturnCode_t Controller::onAborting(RTC::UniqueId ec_id)
115 {
116  return RTC::RTC_OK;
117 }
118 */
119 /*
120 RTC::ReturnCode_t Controller::onError(RTC::UniqueId ec_id)
121 {
122  return RTC::RTC_OK;
123 }
124 */
125 /*
126 RTC::ReturnCode_t Controller::onReset(RTC::UniqueId ec_id)
127 {
128  return RTC::RTC_OK;
129 }
130 */
131 /*
132 RTC::ReturnCode_t Controller::onStateUpdate(RTC::UniqueId ec_id)
133 {
134  return RTC::RTC_OK;
135 }
136 */
137 /*
138 RTC::ReturnCode_t Controller::onRateChanged(RTC::UniqueId ec_id)
139 {
140  return RTC::RTC_OK;
141 }
142 */
143 
144 
145 extern "C"
146 {
147 
149  {
151  manager->registerFactory(profile,
152  RTC::Create<Controller>,
153  RTC::Delete<Controller>);
154  }
155 
156 };
157 
158 
159 
static const char * controller_spec[]
Definition: Controller.cpp:11
RT-Component.
virtual RTC::ReturnCode_t onExecute(RTC::UniqueId ec_id)
Callback function to execute periodically.
Definition: Controller.cpp:101
DataFlowComponentBase class.
ReturnCode_t
Definition: doil.h:53
TimedFloat m_out
Definition: Controller.h:99
Manager class.
Definition: Manager.h:80
InPort< TimedFloat > m_inIn
Definition: Controller.h:93
bool addOutPort(const char *name, OutPortBase &outport)
[local interface] Register DataOutPort
Definition: RTObject.cpp:1645
void ControllerInit(RTC::Manager *manager)
Definition: Controller.cpp:148
ExecutionContextHandle_t UniqueId
OutPort< TimedFloat > m_outOut
Definition: Controller.h:100
Class represents a set of properties.
Definition: Properties.h:101
Controller component *.
virtual bool isNew()
Check whether the data is newest.
Definition: InPort.h:225
virtual bool write(DataType &value)
Write data.
Definition: OutPort.h:203
virtual RTC::ReturnCode_t onInitialize()
Callback function to initialize.
Definition: Controller.cpp:43
bool addInPort(const char *name, InPortBase &inport)
[local interface] Register DataInPort
Definition: RTObject.cpp:1604
TimedFloat m_in
Definition: Controller.h:92
Controller(RTC::Manager *manager)
Definition: Controller.cpp:29
bool registerFactory(coil::Properties &profile, RtcNewFunc new_func, RtcDeleteFunc delete_func)
Register RT-Component Factory.
Definition: Manager.cpp:433
bool read()
Readout the value from DataPort.
Definition: InPort.h:378


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