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