SampleLFComp.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 "SampleLF.h"
23 
24 
25 void MyModuleInit(RTC::Manager* manager)
26 {
27  SampleLFInit(manager);
28  RTC::RtcBase* comp;
29 
30  // Create a component
31  comp = manager->createComponent("SampleLF");
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 }
RTObject_impl * createComponent(const char *comp_args)
PortableServer::POA_ptr getPOA()
int main(int argc, char **argv)
void runManager(bool no_block=false)
manager
virtual PortServiceList * get_ports()
png_uint_32 i
Definition: png.h:2735
DLL_EXPORT void SampleLFInit(RTC::Manager *manager)
Definition: SampleLF.cpp:350
static Manager * init(int argc, char **argv)
void dump(const SDOPackage::NVList &nv)
bool activateManager()
void MyModuleInit(RTC::Manager *manager)
NewSample LF component.
std::vector< IPortService * > PortServiceList
void setModuleInitProc(ModuleInitProc proc)


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sat Apr 13 2019 02:14:25