AutoTestIn.cpp
Go to the documentation of this file.
00001 // -*- C++ -*-
00009 #include <iomanip>
00010 #include "AutoTestIn.h"
00011 
00012 // Module specification
00013 // <rtc-template block="module_spec">
00014 static const char* autotestin_spec[] =
00015   {
00016     "implementation_id", "AutoTestIn",
00017     "type_name",         "AutoTestIn",
00018     "description",       "Sample component for auto-test",
00019     "version",           "1.0.0",
00020     "vendor",            "AIST",
00021     "category",          "example",
00022     "activity_type",     "PERIODIC",
00023     "kind",              "DataFlowComponent",
00024     "max_instance",      "1",
00025     "language",          "C++",
00026     "lang_type",         "compile",
00027     "exec_cxt.periodic.rate", "1.0",
00028     ""
00029   };
00030 // </rtc-template>
00031 
00036 AutoTestIn::AutoTestIn(RTC::Manager* manager)
00037     // <rtc-template block="initializer">
00038   : RTC::DataFlowComponentBase(manager),
00039     m_inIn("in", m_in),
00040     m_seqinIn("seqin", m_seqin),
00041     m_MyServicePort("MyService")
00042 
00043     // </rtc-template>
00044 {
00045 }
00046 
00050 AutoTestIn::~AutoTestIn()
00051 {
00052 }
00053 
00054 
00055 
00056 RTC::ReturnCode_t AutoTestIn::onInitialize()
00057 {
00058   // Registration: InPort/OutPort/Service
00059   // <rtc-template block="registration">
00060   // Set InPort buffers
00061   addInPort("in", m_inIn);
00062   addInPort("seqin", m_seqinIn);
00063   
00064   // Set OutPort buffer
00065   
00066   // Set service provider to Ports
00067   m_MyServicePort.registerProvider("myservice0", "MyService", m_myservice0);
00068   
00069   // Set service consumers to Ports
00070   
00071   // Set CORBA Service Ports
00072   addPort(m_MyServicePort);
00073   
00074   // </rtc-template>
00075 
00076   return RTC::RTC_OK;
00077 }
00078 
00079 /*
00080 RTC::ReturnCode_t AutoTestIn::onFinalize()
00081 {
00082   return RTC::RTC_OK;
00083 }
00084 */
00085 
00086 /*
00087 RTC::ReturnCode_t AutoTestIn::onStartup(RTC::UniqueId ec_id)
00088 {
00089   return RTC::RTC_OK;
00090 }
00091 */
00092 
00093 /*
00094 RTC::ReturnCode_t AutoTestIn::onShutdown(RTC::UniqueId ec_id)
00095 {
00096   return RTC::RTC_OK;
00097 }
00098 */
00099 
00100 
00101 RTC::ReturnCode_t AutoTestIn::onActivated(RTC::UniqueId ec_id)
00102 {
00103  //書き出すファイルを開く
00104   fout.open("received-data");
00105   if (!fout){
00106     std::cout << "Can not open received-data..." << std::endl;
00107   }  
00108   m_msg = "";
00109   return RTC::RTC_OK;
00110 }
00111 
00112 
00113 RTC::ReturnCode_t AutoTestIn::onDeactivated(RTC::UniqueId ec_id)
00114 {
00115   fout.close();
00116   m_myservice0.reset_message();
00117   return RTC::RTC_OK;
00118 }
00119 
00120 
00121 RTC::ReturnCode_t AutoTestIn::onExecute(RTC::UniqueId ec_id)
00122 {
00123   if (m_msg == "") {
00124     m_msg = m_myservice0.get_echo_message();
00125   }
00126 
00127   if ( m_inIn.isNew() && m_seqinIn.isNew() && m_msg != ""){
00128       m_inIn.read(); 
00129       m_seqinIn.read();
00130 
00131       fout << std::fixed;
00132       fout << std::showpoint;
00133       fout << std::setprecision(6);
00134       /*
00135       std::cout << std::fixed;
00136       std::cout << std::showpoint;
00137       std::cout << std::setprecision(1);
00138       std::cout << m_in.data << std::endl;
00139       std::cout << "flen : " << m_in.data << std::endl;
00140       */
00141       fout << m_in.data << std::endl;
00142 
00143       /*
00144       std::cout << "FloatSeqIn//////////////////////////////////////////" << std::endl;
00145       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;
00146 
00147       */
00148       fout <<  m_seqin.data[0] << " " << m_seqin.data[1]<< " "<<m_seqin.data[2] << " " << m_seqin.data[3] << " " << m_seqin.data[4] <<  std::endl;
00149 
00150  
00151       //      std::cout << "echo//////////////////////////////////////////" << std::endl;
00152       //std::cout << coil::eraseBothEndsBlank(m_myservice0.get_echo()) << std::endl;
00153       //std::cout << strlen(coil::eraseBothEndsBlank(m_myservice0.get_echo())) << std::endl;
00154       fout << m_msg <<  std::endl;
00155       m_msg = "";
00156   }
00157   return RTC::RTC_OK;
00158 }
00159 
00160 /*
00161 RTC::ReturnCode_t AutoTestIn::onAborting(RTC::UniqueId ec_id)
00162 {
00163   return RTC::RTC_OK;
00164 }
00165 */
00166 
00167 /*
00168 RTC::ReturnCode_t AutoTestIn::onError(RTC::UniqueId ec_id)
00169 {
00170   return RTC::RTC_OK;
00171 }
00172 */
00173 
00174 /*
00175 RTC::ReturnCode_t AutoTestIn::onReset(RTC::UniqueId ec_id)
00176 {
00177   return RTC::RTC_OK;
00178 }
00179 */
00180 
00181 /*
00182 RTC::ReturnCode_t AutoTestIn::onStateUpdate(RTC::UniqueId ec_id)
00183 {
00184   return RTC::RTC_OK;
00185 }
00186 */
00187 
00188 /*
00189 RTC::ReturnCode_t AutoTestIn::onRateChanged(RTC::UniqueId ec_id)
00190 {
00191   return RTC::RTC_OK;
00192 }
00193 */
00194 
00195 
00196 
00197 extern "C"
00198 {
00199  
00200   void AutoTestInInit(RTC::Manager* manager)
00201   {
00202     coil::Properties profile(autotestin_spec);
00203     manager->registerFactory(profile,
00204                              RTC::Create<AutoTestIn>,
00205                              RTC::Delete<AutoTestIn>);
00206   }
00207   
00208 };
00209 
00210 


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Thu Aug 27 2015 14:16:37