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


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Sat Jun 8 2019 18:49:05