プロジェクト

全般

プロフィール

ModuleNameComp.java

katami, 2018/03/02 09:12

 
1
// -*- Java -*-
2
/*!
3
 * @file ModuleNameComp.java
4
 * @brief Standalone component
5
 * @date $Date$
6
 *
7
 * $Id$
8
 */
9

    
10
import jp.go.aist.rtm.RTC.Manager;
11
import jp.go.aist.rtm.RTC.ModuleInitProc;
12
import jp.go.aist.rtm.RTC.RTObject_impl;
13
import jp.go.aist.rtm.RTC.util.Properties;
14

    
15
/**
16
 * ModuleNameComp
17
 * <p>
18
 * Standalone component Class
19
 *
20
 */
21
public class ModuleNameComp implements ModuleInitProc {
22

    
23
    public void myModuleInit(Manager mgr) {
24
      Properties prop = new Properties(ModuleName.component_conf);
25
      mgr.registerFactory(prop, new ModuleName(), new ModuleName());
26

    
27
      // Create a component
28
      RTObject_impl comp = mgr.createComponent("ModuleName");
29
      if( comp==null ) {
30
          System.err.println("Component create failed.");
31
          System.exit(0);
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
//      Manager manager = Manager.instance();
40
//      RTObject rtobj = null;
41
//      try {
42
//          rtobj = RTObjectHelper.narrow(manager.getPOA().servant_to_reference(comp));
43
//      } catch (ServantNotActive e) {
44
//          e.printStackTrace();
45
//      } catch (WrongPolicy e) {
46
//          e.printStackTrace();
47
//      }
48
//
49
//      // Get the port list of the component
50
//      PortListHolder portlist = new PortListHolder();
51
//      portlist.value = rtobj.get_ports();
52
//
53
//      // getting port profiles
54
//      System.out.println( "Number of Ports: " );
55
//      System.out.println( portlist.value.length );
56
//      for( int intIdx=0;intIdx<portlist.value.length;++intIdx ) {
57
//          Port port = portlist.value[intIdx];
58
//          System.out.println( "Port" + intIdx + " (name): ");
59
//          System.out.println( port.get_port_profile().name );
60
//        
61
//          PortInterfaceProfileListHolder iflist = new PortInterfaceProfileListHolder();
62
//          iflist.value = port.get_port_profile().interfaces;
63
//          System.out.println( "---interfaces---" );
64
//          for( int intIdx2=0;intIdx2<iflist.value.length;++intIdx2 ) {
65
//              System.out.println( "I/F name: " );
66
//              System.out.println( iflist.value[intIdx2].instance_name  );
67
//              System.out.println( "I/F type: " );
68
//              System.out.println( iflist.value[intIdx2].type_name );
69
//              if( iflist.value[intIdx2].polarity==PortInterfacePolarity.PROVIDED ) {
70
//                  System.out.println( "Polarity: PROVIDED" );
71
//              } else {
72
//                  System.out.println( "Polarity: REQUIRED" );
73
//              }
74
//          }
75
//          System.out.println( "---properties---" );
76
//          NVUtil.dump( new NVListHolder(port.get_port_profile().properties) );
77
//          System.out.println( "----------------" );
78
//      }
79
    }
80

    
81
    public static void main(String[] args) {
82
        // Initialize manager
83
        final Manager manager = Manager.init(args);
84

    
85
        // Set module initialization procedure
86
        // This procedure will be invoked in activateManager() function.
87
        ModuleNameComp init = new ModuleNameComp();
88
        manager.setModuleInitProc(init);
89

    
90
        // Activate manager and register to naming service
91
        manager.activateManager();
92

    
93
        // run the manager in blocking mode
94
        // runManager(false) is the default.
95
        manager.runManager();
96

    
97
        // If you want to run the manager in non-blocking mode, do like this
98
        // manager.runManager(true);
99
    }
100

    
101
}