Sensor.cpp
Go to the documentation of this file.
00001 // -*- C++ -*-
00007 #include "Sensor.h"
00008 
00009 // Module specification
00010 // <rtc-template block="module_spec">
00011 static const char* sensor_spec[] =
00012   {
00013     "implementation_id", "Sensor",
00014     "type_name",         "Sensor",
00015     "description",       "Sensor component",
00016     "version",           "1.0",
00017     "vendor",            "Noriaki Ando, AIST",
00018     "category",          "example",
00019     "activity_type",     "SPORADIC",
00020     "kind",              "DataFlowComponent",
00021     "max_instance",      "10",
00022     "language",          "C++",
00023     "lang_type",         "compile",
00024     // Configuration variables
00025     ""
00026   };
00027 // </rtc-template>
00028 
00029 Sensor::Sensor(RTC::Manager* manager)
00030     // <rtc-template block="initializer">
00031   : RTC::DataFlowComponentBase(manager),
00032     m_inIn("in", m_in),
00033     m_outOut("out", m_out)
00034 
00035     // </rtc-template>
00036 {
00037 }
00038 
00039 Sensor::~Sensor()
00040 {
00041 }
00042 
00043 
00044 RTC::ReturnCode_t Sensor::onInitialize()
00045 {
00046   // Registration: InPort/OutPort/Service
00047   // <rtc-template block="registration">
00048   // Set InPort buffers
00049   addInPort("in", m_inIn);
00050 
00051   // Set OutPort buffer
00052   addOutPort("out", m_outOut);
00053 
00054   // Set service provider to Ports
00055 
00056   // Set service consumers to Ports
00057 
00058   // Set CORBA Service Ports
00059 
00060   // </rtc-template>
00061 
00062   // <rtc-template block="bind_config">
00063   // Bind variables and configuration variable
00064 
00065   // </rtc-template>
00066   return RTC::RTC_OK;
00067 }
00068 
00069 
00070 /*
00071 RTC::ReturnCode_t Sensor::onFinalize()
00072 {
00073   return RTC::RTC_OK;
00074 }
00075 */
00076 /*
00077 RTC::ReturnCode_t Sensor::onStartup(RTC::UniqueId ec_id)
00078 {
00079   return RTC::RTC_OK;
00080 }
00081 */
00082 /*
00083 RTC::ReturnCode_t Sensor::onShutdown(RTC::UniqueId ec_id)
00084 {
00085   return RTC::RTC_OK;
00086 }
00087 */
00088 /*
00089 RTC::ReturnCode_t Sensor::onActivated(RTC::UniqueId ec_id)
00090 {
00091   return RTC::RTC_OK;
00092 }
00093 */
00094 /*
00095 RTC::ReturnCode_t Sensor::onDeactivated(RTC::UniqueId ec_id)
00096 {
00097   return RTC::RTC_OK;
00098 }
00099 */
00100 
00101 
00102 RTC::ReturnCode_t Sensor::onExecute(RTC::UniqueId ec_id)
00103 {
00104   if (m_inIn.isNew()) {
00105     m_inIn.read();
00106     std::cout << "Sensor Received data: " << m_in.data << std::endl;
00107     m_out.data = m_in.data * 2;
00108     m_outOut.write();
00109   }
00110   return RTC::RTC_OK;
00111 }
00112 
00113 
00114 /*
00115 RTC::ReturnCode_t Sensor::onAborting(RTC::UniqueId ec_id)
00116 {
00117   return RTC::RTC_OK;
00118 }
00119 */
00120 /*
00121 RTC::ReturnCode_t Sensor::onError(RTC::UniqueId ec_id)
00122 {
00123   return RTC::RTC_OK;
00124 }
00125 */
00126 /*
00127 RTC::ReturnCode_t Sensor::onReset(RTC::UniqueId ec_id)
00128 {
00129   return RTC::RTC_OK;
00130 }
00131 */
00132 /*
00133 RTC::ReturnCode_t Sensor::onStateUpdate(RTC::UniqueId ec_id)
00134 {
00135   return RTC::RTC_OK;
00136 }
00137 */
00138 /*
00139 RTC::ReturnCode_t Sensor::onRateChanged(RTC::UniqueId ec_id)
00140 {
00141   return RTC::RTC_OK;
00142 }
00143 */
00144 
00145 
00146 extern "C"
00147 {
00148  
00149   void SensorInit(RTC::Manager* manager)
00150   {
00151     coil::Properties profile(sensor_spec);
00152     manager->registerFactory(profile,
00153                              RTC::Create<Sensor>,
00154                              RTC::Delete<Sensor>);
00155   }
00156   
00157 };
00158 
00159 
00160 


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Sun Mar 26 2017 03:37:17