Go to the documentation of this file.00001
00010 #include "ConsoleIn.h"
00011 #include <iostream>
00012
00013
00014
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
00030
00031 ConsoleIn::ConsoleIn(RTC::Manager* manager)
00032 : RTC::DataFlowComponentBase(manager),
00033
00034 m_outOut("out", m_out)
00035
00036 {
00037 }
00038
00039 ConsoleIn::~ConsoleIn()
00040 {
00041 }
00042
00043
00044 RTC::ReturnCode_t ConsoleIn::onInitialize()
00045 {
00046
00047
00048
00049
00050
00051 addOutPort("out", m_outOut);
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061 return RTC::RTC_OK;
00062 }
00063
00064 RTC::ReturnCode_t ConsoleIn::onExecute(RTC::UniqueId ec_id)
00065 {
00066 std::cout << "Please input number: ";
00067 std::cin >> m_out.data;
00068 std::cout << "Sending to subscriber: " << m_out.data << std::endl;
00069 m_outOut.write();
00070
00071 return RTC::RTC_OK;
00072 }
00073
00074
00075 extern "C"
00076 {
00077
00078 void ConsoleInInit(RTC::Manager* manager)
00079 {
00080 coil::Properties profile(consolein_spec);
00081 manager->registerFactory(profile,
00082 RTC::Create<ConsoleIn>,
00083 RTC::Delete<ConsoleIn>);
00084 }
00085
00086 };
00087
00088