SamplePDComp.cpp
Go to the documentation of this file.
1 // -*- C++ -*-
2 /*
3  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
4  * All rights reserved. This program is made available under the terms of the
5  * Eclipse Public License v1.0 which accompanies this distribution, and is
6  * available at http://www.eclipse.org/legal/epl-v10.html
7  * Contributors:
8  * National Institute of Advanced Industrial Science and Technology (AIST)
9  * General Robotix Inc.
10  */
19 #include <rtm/Manager.h>
20 #include <iostream>
21 #include <string>
22 #include "SamplePD.h"
23 
24 
25 void MyModuleInit(RTC::Manager* manager)
26 {
27  SamplePDInit(manager);
28  RTC::RtcBase* comp;
29 
30  // Create a component
31  comp = manager->createComponent("SamplePD");
32 
33 
34  // Example
35  // The following procedure is examples how handle RT-Components.
36  // These should not be in this function.
37 
38  // Get the component's object reference
39  RTC::RTObject_var rtobj;
40  rtobj = RTC::RTObject::_narrow(manager->getPOA()->servant_to_reference(comp));
41 
42  // Get the port list of the component
43  PortServiceList* portlist;
44  portlist = rtobj->get_ports();
45 
46  // getting port profiles
47  std::cout << "Number of Ports: ";
48  std::cout << portlist->length() << std::endl << std::endl;
49  for (CORBA::ULong i(0), n(portlist->length()); i < n; ++i)
50  {
51  PortService_ptr port;
52  port = (*portlist)[i];
53  std::cout << "Port" << i << " (name): ";
54  std::cout << port->get_port_profile()->name << std::endl;
55 
56  RTC::PortInterfaceProfileList iflist;
57  iflist = port->get_port_profile()->interfaces;
58  std::cout << "---interfaces---" << std::endl;
59  for (CORBA::ULong i(0), n(iflist.length()); i < n; ++i)
60  {
61  std::cout << "I/F name: ";
62  std::cout << iflist[i].instance_name << std::endl;
63  std::cout << "I/F type: ";
64  std::cout << iflist[i].type_name << std::endl;
65  const char* pol;
66  pol = iflist[i].polarity == 0 ? "PROVIDED" : "REQUIRED";
67  std::cout << "Polarity: " << pol << std::endl;
68  }
69  std::cout << "---properties---" << std::endl;
70  NVUtil::dump(port->get_port_profile()->properties);
71  std::cout << "----------------" << std::endl << std::endl;
72  }
73 
74  return;
75 }
76 
77 int main (int argc, char** argv)
78 {
80  manager = RTC::Manager::init(argc, argv);
81 
82  // Initialize manager
83  manager->init(argc, argv);
84 
85  // Set module initialization proceduer
86  // This procedure will be invoked in activateManager() function.
88 
89  // Activate manager and register to naming service
90  manager->activateManager();
91 
92  // run the manager in blocking mode
93  // runManager(false) is the default.
94  manager->runManager();
95 
96  // If you want to run the manager in non-blocking mode, do like this
97  // manager->runManager(true);
98 
99  return 0;
100 }
int main(int argc, char **argv)
Sample PD component.
RTObject_impl * createComponent(const char *comp_args)
PortableServer::POA_ptr getPOA()
void runManager(bool no_block=false)
manager
virtual PortServiceList * get_ports()
DLL_EXPORT void SamplePDInit(RTC::Manager *manager)
Definition: SamplePD.cpp:272
png_uint_32 i
Definition: png.h:2735
static Manager * init(int argc, char **argv)
void dump(const SDOPackage::NVList &nv)
bool activateManager()
std::vector< IPortService *> PortServiceList
void setModuleInitProc(ModuleInitProc proc)
void MyModuleInit(RTC::Manager *manager)


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Thu Sep 8 2022 02:24:05