SampleSVComp.cpp
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 /*
00003  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
00004  * All rights reserved. This program is made available under the terms of the
00005  * Eclipse Public License v1.0 which accompanies this distribution, and is
00006  * available at http://www.eclipse.org/legal/epl-v10.html
00007  * Contributors:
00008  * National Institute of Advanced Industrial Science and Technology (AIST)
00009  * General Robotix Inc.
00010  */
00019 #include <rtm/Manager.h>
00020 #include <iostream>
00021 #include <string>
00022 #include "SampleSV.h"
00023 
00024 
00025 void MyModuleInit(RTC::Manager* manager)
00026 {
00027   SampleSVInit(manager);
00028   RTC::RtcBase* comp;
00029 
00030   // Create a component
00031   comp = manager->createComponent("SampleSV");
00032 
00033 
00034   // Example
00035   // The following procedure is examples how handle RT-Components.
00036   // These should not be in this function.
00037 
00038   // Get the component's object reference
00039  RTC::RTObject_var rtobj;
00040  rtobj = RTC::RTObject::_narrow(manager->getPOA()->servant_to_reference(comp));
00041 
00042   // Get the port list of the component
00043  PortServiceList* portlist;
00044  portlist = rtobj->get_ports();
00045 
00046   // getting port profiles
00047  std::cout << "Number of Ports: ";
00048  std::cout << portlist->length() << std::endl << std::endl;
00049  for (CORBA::ULong i(0), n(portlist->length()); i < n; ++i)
00050  {
00051          PortService_ptr port;
00052    port = (*portlist)[i];
00053    std::cout << "Port" << i << " (name): ";
00054    std::cout << port->get_port_profile()->name << std::endl;
00055 
00056    RTC::PortInterfaceProfileList iflist;
00057    iflist = port->get_port_profile()->interfaces;
00058    std::cout << "---interfaces---" << std::endl;
00059    for (CORBA::ULong i(0), n(iflist.length()); i < n; ++i)
00060    {
00061      std::cout << "I/F name: ";
00062      std::cout << iflist[i].instance_name << std::endl;
00063      std::cout << "I/F type: ";
00064      std::cout << iflist[i].type_name << std::endl;
00065      const char* pol;
00066      pol = iflist[i].polarity == 0 ? "PROVIDED" : "REQUIRED";
00067      std::cout << "Polarity: " << pol << std::endl;
00068    }
00069    std::cout << "---properties---" << std::endl;
00070    NVUtil::dump(port->get_port_profile()->properties);
00071    std::cout << "----------------" << std::endl << std::endl;
00072  }
00073 
00074   return;
00075 }
00076 
00077 int main (int argc, char** argv)
00078 {
00079   RTC::Manager* manager;
00080   manager = RTC::Manager::init(argc, argv);
00081 
00082   // Initialize manager
00083   manager->init(argc, argv);
00084 
00085   // Set module initialization proceduer
00086   // This procedure will be invoked in activateManager() function.
00087   manager->setModuleInitProc(MyModuleInit);
00088 
00089   // Activate manager and register to naming service
00090   manager->activateManager();
00091 
00092   // run the manager in blocking mode
00093   // runManager(false) is the default.
00094   manager->runManager();
00095 
00096   // If you want to run the manager in non-blocking mode, do like this
00097   // manager->runManager(true);
00098 
00099   return 0;
00100 }


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Thu Apr 11 2019 03:30:19