AutoTestIn.cpp
Go to the documentation of this file.
1 // -*- C++ -*-
9 #include <iomanip>
10 #include "AutoTestIn.h"
11 
12 // Module specification
13 // <rtc-template block="module_spec">
14 static const char* autotestin_spec[] =
15  {
16  "implementation_id", "AutoTestIn",
17  "type_name", "AutoTestIn",
18  "description", "Sample component for auto-test",
19  "version", "1.0.0",
20  "vendor", "AIST",
21  "category", "example",
22  "activity_type", "PERIODIC",
23  "kind", "DataFlowComponent",
24  "max_instance", "1",
25  "language", "C++",
26  "lang_type", "compile",
27  "exec_cxt.periodic.rate", "1.0",
28  ""
29  };
30 // </rtc-template>
31 
37  // <rtc-template block="initializer">
38  : RTC::DataFlowComponentBase(manager),
39  m_inIn("in", m_in),
40  m_seqinIn("seqin", m_seqin),
41  m_MyServicePort("MyService")
42 
43  // </rtc-template>
44 {
45 }
46 
51 {
52 }
53 
54 
55 
57 {
58  // Registration: InPort/OutPort/Service
59  // <rtc-template block="registration">
60  // Set InPort buffers
61  addInPort("in", m_inIn);
62  addInPort("seqin", m_seqinIn);
63 
64  // Set OutPort buffer
65 
66  // Set service provider to Ports
67  m_MyServicePort.registerProvider("myservice0", "MyService", m_myservice0);
68 
69  // Set service consumers to Ports
70 
71  // Set CORBA Service Ports
73 
74  // </rtc-template>
75 
76  return RTC::RTC_OK;
77 }
78 
79 /*
80 RTC::ReturnCode_t AutoTestIn::onFinalize()
81 {
82  return RTC::RTC_OK;
83 }
84 */
85 
86 /*
87 RTC::ReturnCode_t AutoTestIn::onStartup(RTC::UniqueId ec_id)
88 {
89  return RTC::RTC_OK;
90 }
91 */
92 
93 /*
94 RTC::ReturnCode_t AutoTestIn::onShutdown(RTC::UniqueId ec_id)
95 {
96  return RTC::RTC_OK;
97 }
98 */
99 
100 
102 {
103  //書き出すファイルを開く
104  fout.open("received-data");
105  if (!fout){
106  std::cout << "Can not open received-data..." << std::endl;
107  }
108  m_msg = "";
109  return RTC::RTC_OK;
110 }
111 
112 
114 {
115  fout.close();
117  return RTC::RTC_OK;
118 }
119 
120 
122 {
123  if (m_msg == "") {
125  }
126 
127  if ( m_inIn.isNew() && m_seqinIn.isNew() && m_msg != ""){
128  m_inIn.read();
129  m_seqinIn.read();
130 
131  fout << std::fixed;
132  fout << std::showpoint;
133  fout << std::setprecision(6);
134  /*
135  std::cout << std::fixed;
136  std::cout << std::showpoint;
137  std::cout << std::setprecision(1);
138  std::cout << m_in.data << std::endl;
139  std::cout << "flen : " << m_in.data << std::endl;
140  */
141  fout << m_in.data << std::endl;
142 
143  /*
144  std::cout << "FloatSeqIn//////////////////////////////////////////" << std::endl;
145  std::cout << "Received: " << m_seqin.data[0] << " " << m_seqin.data[1] << " " << m_seqin.data[2] << " " << m_seqin.data[3] << " " << m_seqin.data[4] <<std::endl;
146 
147  */
148  fout << m_seqin.data[0] << " " << m_seqin.data[1]<< " "<<m_seqin.data[2] << " " << m_seqin.data[3] << " " << m_seqin.data[4] << std::endl;
149 
150 
151  // std::cout << "echo//////////////////////////////////////////" << std::endl;
152  //std::cout << coil::eraseBothEndsBlank(m_myservice0.get_echo()) << std::endl;
153  //std::cout << strlen(coil::eraseBothEndsBlank(m_myservice0.get_echo())) << std::endl;
154  fout << m_msg << std::endl;
155  m_msg = "";
156  }
157  return RTC::RTC_OK;
158 }
159 
160 /*
161 RTC::ReturnCode_t AutoTestIn::onAborting(RTC::UniqueId ec_id)
162 {
163  return RTC::RTC_OK;
164 }
165 */
166 
167 /*
168 RTC::ReturnCode_t AutoTestIn::onError(RTC::UniqueId ec_id)
169 {
170  return RTC::RTC_OK;
171 }
172 */
173 
174 /*
175 RTC::ReturnCode_t AutoTestIn::onReset(RTC::UniqueId ec_id)
176 {
177  return RTC::RTC_OK;
178 }
179 */
180 
181 /*
182 RTC::ReturnCode_t AutoTestIn::onStateUpdate(RTC::UniqueId ec_id)
183 {
184  return RTC::RTC_OK;
185 }
186 */
187 
188 /*
189 RTC::ReturnCode_t AutoTestIn::onRateChanged(RTC::UniqueId ec_id)
190 {
191  return RTC::RTC_OK;
192 }
193 */
194 
195 
196 
197 extern "C"
198 {
199 
201  {
203  manager->registerFactory(profile,
204  RTC::Create<AutoTestIn>,
205  RTC::Delete<AutoTestIn>);
206  }
207 
208 };
209 
210 
std::ofstream fout
Definition: AutoTestIn.h:264
InPort< TimedFloat > m_inIn
Definition: AutoTestIn.h:228
AutoTestIn(RTC::Manager *manager)
constructor
Definition: AutoTestIn.cpp:36
RT-Component.
DataFlowComponentBase class.
ReturnCode_t
Definition: doil.h:53
Manager class.
Definition: Manager.h:80
TimedFloat m_in
Definition: AutoTestIn.h:225
std::string m_msg
Definition: AutoTestIn.h:265
virtual RTC::ReturnCode_t onActivated(RTC::UniqueId ec_id)
Callback function to activate.
Definition: AutoTestIn.cpp:101
MyServiceSVC_impl m_myservice0
Definition: AutoTestIn.h:254
ExecutionContextHandle_t UniqueId
std::string get_echo_message()
Sample component for auto-test.
TimedFloatSeq m_seqin
Definition: AutoTestIn.h:229
Class represents a set of properties.
Definition: Properties.h:101
virtual bool isNew()
Check whether the data is newest.
Definition: InPort.h:225
bool addPort(PortBase &port)
[local interface] Register Port
Definition: RTObject.cpp:1558
virtual RTC::ReturnCode_t onExecute(RTC::UniqueId ec_id)
Callback function to execute periodically.
Definition: AutoTestIn.cpp:121
virtual RTC::ReturnCode_t onDeactivated(RTC::UniqueId ec_id)
Callback function to deactivate.
Definition: AutoTestIn.cpp:113
virtual RTC::ReturnCode_t onInitialize()
Callback function to initialize.
Definition: AutoTestIn.cpp:56
RTC::CorbaPort m_MyServicePort
Definition: AutoTestIn.h:246
bool addInPort(const char *name, InPortBase &inport)
[local interface] Register DataInPort
Definition: RTObject.cpp:1604
void AutoTestInInit(RTC::Manager *manager)
Definition: AutoTestIn.cpp:200
bool registerFactory(coil::Properties &profile, RtcNewFunc new_func, RtcDeleteFunc delete_func)
Register RT-Component Factory.
Definition: Manager.cpp:433
InPort< TimedFloatSeq > m_seqinIn
Definition: AutoTestIn.h:232
bool read()
Readout the value from DataPort.
Definition: InPort.h:378
~AutoTestIn()
destructor
Definition: AutoTestIn.cpp:50
bool registerProvider(const char *instance_name, const char *type_name, PortableServer::RefCountServantBase &provider)
Register the provider.
Definition: CorbaPort.cpp:90
static const char * autotestin_spec[]
Definition: AutoTestIn.cpp:14


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Thu Jun 6 2019 19:25:57