ConsoleOut.cpp
Go to the documentation of this file.
00001 // -*- C++ -*-
00010 #include "ConsoleOut.h"
00011 
00012 // Module specification
00013 // <rtc-template block="module_spec">
00014 static const char* consoleout_spec[] =
00015   {
00016     "implementation_id", "ConsoleOut",
00017     "type_name",         "ConsoleOut",
00018     "description",       "Console output component",
00019     "version",           "1.0",
00020     "vendor",            "Noriaki Ando, AIST",
00021     "category",          "example",
00022     "activity_type",     "DataFlowComponent",
00023     "max_instance",      "10",
00024     "language",          "C++",
00025     "lang_type",         "compile",
00026     ""
00027   };
00028 // </rtc-template>
00029 
00030 ConsoleOut::ConsoleOut(RTC::Manager* manager)
00031   : RTC::DataFlowComponentBase(manager),
00032     // <rtc-template block="initializer">
00033     m_inIn("in", m_in)
00034     
00035     // </rtc-template>
00036 {
00037   // Registration: InPort/OutPort/Service
00038   // <rtc-template block="registration">
00039   // Set InPort buffers
00040   
00041   // Set OutPort buffer
00042   
00043   // Set service provider to Ports
00044   
00045   // Set service consumers to Ports
00046   
00047   // Set CORBA Service Ports
00048   
00049   // </rtc-template>
00050 
00051 }
00052 
00053 ConsoleOut::~ConsoleOut()
00054 {
00055 }
00056 
00057 
00058 RTC::ReturnCode_t ConsoleOut::onInitialize()
00059 {
00060   addInPort("in", m_inIn);
00061  
00062   m_inIn.addConnectorDataListener(ON_BUFFER_WRITE,
00063                                     new DataListener("ON_BUFFER_WRITE"));
00064   m_inIn.addConnectorDataListener(ON_BUFFER_FULL, 
00065                                     new DataListener("ON_BUFFER_FULL"));
00066   m_inIn.addConnectorDataListener(ON_BUFFER_WRITE_TIMEOUT, 
00067                                     new DataListener("ON_BUFFER_WRITE_TIMEOUT"));
00068   m_inIn.addConnectorDataListener(ON_BUFFER_OVERWRITE, 
00069                                     new DataListener("ON_BUFFER_OVERWRITE"));
00070   m_inIn.addConnectorDataListener(ON_BUFFER_READ, 
00071                                     new DataListener("ON_BUFFER_READ"));
00072   m_inIn.addConnectorDataListener(ON_SEND, 
00073                                     new DataListener("ON_SEND"));
00074   m_inIn.addConnectorDataListener(ON_RECEIVED,
00075                                     new DataListener("ON_RECEIVED"));
00076   m_inIn.addConnectorDataListener(ON_RECEIVER_FULL, 
00077                                     new DataListener("ON_RECEIVER_FULL"));
00078   m_inIn.addConnectorDataListener(ON_RECEIVER_TIMEOUT, 
00079                                     new DataListener("ON_RECEIVER_TIMEOUT"));
00080 
00081   m_inIn.addConnectorListener(ON_BUFFER_EMPTY,
00082                                     new ConnListener("ON_BUFFER_EMPTY"));
00083   m_inIn.addConnectorListener(ON_BUFFER_READ_TIMEOUT,
00084                                     new ConnListener("ON_BUFFER_READ_TIMEOUT"));
00085   m_inIn.addConnectorListener(ON_SENDER_EMPTY,
00086                                     new ConnListener("ON_SENDER_EMPTY"));
00087   m_inIn.addConnectorListener(ON_SENDER_TIMEOUT,
00088                                     new ConnListener("ON_SENDER_TIMEOUT"));
00089   m_inIn.addConnectorListener(ON_SENDER_ERROR,
00090                                     new ConnListener("ON_SENDER_ERROR"));
00091   m_inIn.addConnectorListener(ON_CONNECT,
00092                                     new ConnListener("ON_CONNECT"));
00093   m_inIn.addConnectorListener(ON_DISCONNECT,
00094                                     new ConnListener("ON_DISCONNECT"));
00095 
00096 
00097  return RTC::RTC_OK;
00098 }
00099 
00100 RTC::ReturnCode_t ConsoleOut::onExecute(RTC::UniqueId ec_id)
00101 {
00102   if (m_inIn.isNew())
00103     {
00104       m_inIn.read();
00105       std::cout << "Received: " << m_in.data << std::endl;
00106       std::cout << "TimeStamp: " << m_in.tm.sec << "[s] ";
00107       std::cout << m_in.tm.nsec << "[ns]" << std::endl;
00108     }
00109   coil::usleep(1000);
00110 
00111   return RTC::RTC_OK;
00112 }
00113 
00114 
00115 extern "C"
00116 {
00117  
00118   void ConsoleOutInit(RTC::Manager* manager)
00119   {
00120 //    RTC::Properties profile(consoleout_spec);
00121     coil::Properties profile(consoleout_spec);
00122     manager->registerFactory(profile,
00123                              RTC::Create<ConsoleOut>,
00124                              RTC::Delete<ConsoleOut>);
00125   }
00126   
00127 };
00128 
00129 


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