00001 // -*- C++ -*- 00017 #include <rtm/Manager.h> 00018 #include <iostream> 00019 #include <string> 00020 #include <stdlib.h> 00021 #include "MotorControl.h" 00022 00023 00024 void MyModuleInit(RTC::Manager* manager) 00025 { 00026 MotorControlInit(manager); 00027 RTC::RtcBase* comp; 00028 00029 // Create a component 00030 comp = manager->createComponent("MotorControl"); 00031 00032 if (comp==NULL) 00033 { 00034 std::cerr << "Component create failed." << std::endl; 00035 abort(); 00036 } 00037 00038 // Example 00039 // The following procedure is examples how handle RT-Components. 00040 // These should not be in this function. 00041 00042 // Get the component's object reference 00043 // RTC::RTObject_var rtobj; 00044 // rtobj = RTC::RTObject::_narrow(manager->getPOA()->servant_to_reference(comp)); 00045 00046 // Get the port list of the component 00047 // PortServiceList* portlist; 00048 // portlist = rtobj->get_ports(); 00049 00050 // getting port profiles 00051 // std::cout << "Number of Ports: "; 00052 // std::cout << portlist->length() << std::endl << std::endl; 00053 // for (CORBA::ULong i(0), n(portlist->length()); i < n; ++i) 00054 // { 00055 // PortService_ptr port; 00056 // port = (*portlist)[i]; 00057 // std::cout << "Port" << i << " (name): "; 00058 // std::cout << port->get_port_profile()->name << std::endl; 00059 // 00060 // RTC::PortInterfaceProfileList iflist; 00061 // iflist = port->get_port_profile()->interfaces; 00062 // std::cout << "---interfaces---" << std::endl; 00063 // for (CORBA::ULong i(0), n(iflist.length()); i < n; ++i) 00064 // { 00065 // std::cout << "I/F name: "; 00066 // std::cout << iflist[i].instance_name << std::endl; 00067 // std::cout << "I/F type: "; 00068 // std::cout << iflist[i].type_name << std::endl; 00069 // const char* pol; 00070 // pol = iflist[i].polarity == 0 ? "PROVIDED" : "REQUIRED"; 00071 // std::cout << "Polarity: " << pol << std::endl; 00072 // } 00073 // std::cout << "---properties---" << std::endl; 00074 // NVUtil::dump(port->get_port_profile()->properties); 00075 // std::cout << "----------------" << std::endl << std::endl; 00076 // } 00077 00078 return; 00079 } 00080 00081 int main (int argc, char** argv) 00082 { 00083 RTC::Manager* manager; 00084 manager = RTC::Manager::init(argc, argv); 00085 00086 // Initialize manager 00087 manager->init(argc, argv); 00088 00089 // Set module initialization proceduer 00090 // This procedure will be invoked in activateManager() function. 00091 manager->setModuleInitProc(MyModuleInit); 00092 00093 // Activate manager and register to naming service 00094 manager->activateManager(); 00095 00096 // run the manager in blocking mode 00097 // runManager(false) is the default. 00098 manager->runManager(); 00099 00100 // If you want to run the manager in non-blocking mode, do like this 00101 // manager->runManager(true); 00102 00103 return 0; 00104 }