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