ConsoleIn.cpp
Go to the documentation of this file.
00001 // -*- C++ -*-
00010 #include "ConsoleIn.h"
00011 #include <iostream>
00012 
00013 // Module specification
00014 // <rtc-template block="module_spec">
00015 static const char* consolein_spec[] =
00016   {
00017     "implementation_id", "ConsoleIn",
00018     "type_name",         "ConsoleIn",
00019     "description",       "Console input component",
00020     "version",           "1.0",
00021     "vendor",            "Noriaki Ando, AIST",
00022     "category",          "example",
00023     "activity_type",     "DataFlowComponent",
00024     "max_instance",      "10",
00025     "language",          "C++",
00026     "lang_type",         "compile",
00027     ""
00028   };
00029 // </rtc-template>
00030 
00031 ConsoleIn::ConsoleIn(RTC::Manager* manager)
00032   : RTC::DataFlowComponentBase(manager),
00033     // <rtc-template block="initializer">
00034     m_outOut("out", m_out)
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 ConsoleIn::~ConsoleIn()
00054 {
00055 }
00056 
00057 
00058 RTC::ReturnCode_t ConsoleIn::onInitialize()
00059 {
00060   addOutPort("out", m_outOut);
00061 
00062   m_outOut.addConnectorDataListener(ON_BUFFER_WRITE,
00063                                     new DataListener("ON_BUFFER_WRITE"));
00064   m_outOut.addConnectorDataListener(ON_BUFFER_FULL, 
00065                                     new DataListener("ON_BUFFER_FULL"));
00066   m_outOut.addConnectorDataListener(ON_BUFFER_WRITE_TIMEOUT, 
00067                                     new DataListener("ON_BUFFER_WRITE_TIMEOUT"));
00068   m_outOut.addConnectorDataListener(ON_BUFFER_OVERWRITE, 
00069                                     new DataListener("ON_BUFFER_OVERWRITE"));
00070   m_outOut.addConnectorDataListener(ON_BUFFER_READ, 
00071                                     new DataListener("ON_BUFFER_READ"));
00072   m_outOut.addConnectorDataListener(ON_SEND, 
00073                                     new DataListener("ON_SEND"));
00074   m_outOut.addConnectorDataListener(ON_RECEIVED,
00075                                     new DataListener("ON_RECEIVED"));
00076   m_outOut.addConnectorDataListener(ON_RECEIVER_FULL, 
00077                                     new DataListener("ON_RECEIVER_FULL"));
00078   m_outOut.addConnectorDataListener(ON_RECEIVER_TIMEOUT, 
00079                                     new DataListener("ON_RECEIVER_TIMEOUT"));
00080 
00081   m_outOut.addConnectorListener(ON_BUFFER_EMPTY,
00082                                     new ConnListener("ON_BUFFER_EMPTY"));
00083   m_outOut.addConnectorListener(ON_BUFFER_READ_TIMEOUT,
00084                                     new ConnListener("ON_BUFFER_READ_TIMEOUT"));
00085   m_outOut.addConnectorListener(ON_SENDER_EMPTY,
00086                                     new ConnListener("ON_SENDER_EMPTY"));
00087   m_outOut.addConnectorListener(ON_SENDER_TIMEOUT,
00088                                     new ConnListener("ON_SENDER_TIMEOUT"));
00089   m_outOut.addConnectorListener(ON_SENDER_ERROR,
00090                                     new ConnListener("ON_SENDER_ERROR"));
00091   m_outOut.addConnectorListener(ON_CONNECT,
00092                                     new ConnListener("ON_CONNECT"));
00093   m_outOut.addConnectorListener(ON_DISCONNECT,
00094                                     new ConnListener("ON_DISCONNECT"));
00095 
00096 
00097   return RTC::RTC_OK;
00098 }
00099 RTC::ReturnCode_t ConsoleIn::onExecute(RTC::UniqueId ec_id)
00100 {
00101   std::cout << "Please input number: ";
00102   std::cin >> m_out.data;
00103   if (m_out.data == 666) return RTC::RTC_ERROR;
00104   m_outOut.write();
00105 
00106   return RTC::RTC_OK;
00107 }
00108 
00109 
00110 extern "C"
00111 {
00112  
00113   void ConsoleInInit(RTC::Manager* manager)
00114   {
00115     RTC::Properties profile(consolein_spec);
00116     manager->registerFactory(profile,
00117                              RTC::Create<ConsoleIn>,
00118                              RTC::Delete<ConsoleIn>);
00119   }
00120   
00121 };
00122 
00123 


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