PDcontrollerComp.cpp
Go to the documentation of this file.
1 // -*- C++ -*-
10 #include <rtm/Manager.h>
11 #include <iostream>
12 #include <string>
13 #include "PDcontroller.h"
14 
15 
16 void MyModuleInit(RTC::Manager* manager)
17 {
18  PDcontrollerInit(manager);
19  RTC::RtcBase* comp;
20 
21  // Create a component
22  comp = manager->createComponent("PDcontroller");
23 
24 
25  // Example
26  // The following procedure is examples how handle RT-Components.
27  // These should not be in this function.
28 
29  // Get the component's object reference
30  RTC::RTObject_var rtobj;
31  rtobj = RTC::RTObject::_narrow(manager->getPOA()->servant_to_reference(comp));
32 
33  // Get the port list of the component
34  PortServiceList* portlist;
35  portlist = rtobj->get_ports();
36 
37  // getting port profiles
38  std::cout << "Number of Ports: ";
39  std::cout << portlist->length() << std::endl << std::endl;
40  for (CORBA::ULong i(0), n(portlist->length()); i < n; ++i)
41  {
42  PortService_ptr port;
43  port = (*portlist)[i];
44  std::cout << "Port" << i << " (name): ";
45  std::cout << port->get_port_profile()->name << std::endl;
46 
47  RTC::PortInterfaceProfileList iflist;
48  iflist = port->get_port_profile()->interfaces;
49  std::cout << "---interfaces---" << std::endl;
50  for (CORBA::ULong i(0), n(iflist.length()); i < n; ++i)
51  {
52  std::cout << "I/F name: ";
53  std::cout << iflist[i].instance_name << std::endl;
54  std::cout << "I/F type: ";
55  std::cout << iflist[i].type_name << std::endl;
56  const char* pol;
57  pol = iflist[i].polarity == 0 ? "PROVIDED" : "REQUIRED";
58  std::cout << "Polarity: " << pol << std::endl;
59  }
60  std::cout << "---properties---" << std::endl;
61  NVUtil::dump(port->get_port_profile()->properties);
62  std::cout << "----------------" << std::endl << std::endl;
63  }
64 
65  return;
66 }
67 
68 int main (int argc, char** argv)
69 {
71  manager = RTC::Manager::init(argc, argv);
72 
73  // Initialize manager
74  manager->init(argc, argv);
75 
76  // Set module initialization proceduer
77  // This procedure will be invoked in activateManager() function.
79 
80  // Activate manager and register to naming service
81  manager->activateManager();
82 
83  // run the manager in blocking mode
84  // runManager(false) is the default.
85  manager->runManager();
86 
87  // If you want to run the manager in non-blocking mode, do like this
88  // manager->runManager(true);
89 
90  return 0;
91 }
RTObject_impl * createComponent(const char *comp_args)
PortableServer::POA_ptr getPOA()
void runManager(bool no_block=false)
int main(int argc, char **argv)
void MyModuleInit(RTC::Manager *manager)
manager
virtual PortServiceList * get_ports()
png_uint_32 i
static Manager * init(int argc, char **argv)
void PDcontrollerInit(RTC::Manager *manager)
n
void dump(const SDOPackage::NVList &nv)
bool activateManager()
Sample PD component.
std::vector< IPortService *> PortServiceList
void setModuleInitProc(ModuleInitProc proc)


hrpsys
Author(s): AIST, Fumio Kanehiro
autogenerated on Sat Dec 17 2022 03:52:20