PathConsumerImpl.java
Go to the documentation of this file.
1 // -*- Java -*-
10 package jp.go.aist.hrp.simulator;
11 
13 
14 import RTC.ComponentProfile;
15 import RTC.ConnectorProfile;
16 import RTC.ConnectorProfileHolder;
17 import RTC.ExecutionContext;
18 import RTC.LifeCycleState;
19 import RTC.PortService;
20 import RTC.RTObject;
21 import RTC.ReturnCode_t;
23 import jp.go.aist.rtm.RTC.DataFlowComponentBase;
24 import jp.go.aist.rtm.RTC.Manager;
25 import jp.go.aist.rtm.RTC.port.ConnectionCallback;
26 import jp.go.aist.rtm.RTC.port.CorbaConsumer;
27 import jp.go.aist.rtm.RTC.port.CorbaPort;
28 
29 public class PathConsumerImpl extends DataFlowComponentBase{
30 
31  public PathConsumerImpl(Manager manager) {
32  super(manager);
33  // <rtc-template block="initializer">
34  m_PathPlannerPort = new CorbaPort("PathPlanner");
35  // </rtc-template>
36 
37  // Registration: InPort/OutPort/Service
38  // <rtc-template block="registration">
39  // Set InPort buffers
40 
41  // Set OutPort buffer
42 
43  // Set service provider to Ports
44 
45  // Set service consumers to Ports
46  m_PathPlannerPort.registerConsumer("Path", "PathPlanner", m_PathBase);
47  m_PathPlannerPort.setOnConnected( new ConnectionCallback() {
48  public void run(ConnectorProfileHolder arg0) {
49  ConnectorProfile[] connectorProfiles = m_PathPlannerPort.get_connector_profiles();
50  for(ConnectorProfile connectorProfile : connectorProfiles){
51  PortService[] portServices = connectorProfile.ports;
52  for(PortService portService : portServices){
53  RTObject rtObject = portService.get_port_profile().owner;
54  String typeName = rtObject.get_component_profile().type_name;
55  if(typeName.equals("Path")){
56  ExecutionContext[] executionContexts = rtObject.get_owned_contexts();
57  for(ExecutionContext executionContext : executionContexts){
58  if(executionContext.get_component_state(rtObject) != LifeCycleState.ACTIVE_STATE){
59  if(executionContext.activate_component(rtObject) == ReturnCode_t.RTC_OK)
60  ;
61  else
62  item_.connectedCallback(false);
63  }
65  return;
66  }
67 
68  }
69  }
70  }
71  item_.connectedCallback(false);
72  }
73  });
74  m_PathPlannerPort.setOnDisconnected( new ConnectionCallback() {
75  public void run(ConnectorProfileHolder arg0) {
76  item_.connectedCallback(false);
77  }
78  });
79 
80  // Set CORBA Service Ports
81  registerPort(m_PathPlannerPort);
82 
83  // </rtc-template>
84  }
85 
86  // The initialize action (on CREATED->ALIVE transition)
87  // formaer rtc_init_entry()
88 // @Override
89 // protected ReturnCode_t onInitialize() {
90 // return super.onInitialize();
91 // }
92  // The finalize action (on ALIVE->END transition)
93  // formaer rtc_exiting_entry()
94 // @Override
95 // protected ReturnCode_t onFinalize() {
96 // return super.onFinalize();
97 // }
98  //
99  // The startup action when ExecutionContext startup
100  // former rtc_starting_entry()
101 // @Override
102 // protected ReturnCode_t onStartup(int ec_id) {
103 // return super.onStartup(ec_id);
104 // }
105  //
106  // The shutdown action when ExecutionContext stop
107  // former rtc_stopping_entry()
108 // @Override
109 // protected ReturnCode_t onShutdown(int ec_id) {
110 // return super.onShutdown(ec_id);
111 // }
112  //
113  // The activated action (Active state entry action)
114  // former rtc_active_entry()
115 // @Override
116 // protected ReturnCode_t onActivated(int ec_id) {
117 // return super.onActivated(ec_id);
118 // }
119  //
120  // The deactivated action (Active state exit action)
121  // former rtc_active_exit()
122 // @Override
123 // protected ReturnCode_t onDeactivated(int ec_id) {
124 // return super.onDeactivated(ec_id);
125 // }
126  //
127  // The execution action that is invoked periodically
128  // former rtc_active_do()
129 // @Override
130 // protected ReturnCode_t onExecute(int ec_id) {
131 // return super.onExecute(ec_id);
132 // }
133  //
134  // The aborting action when main logic error occurred.
135  // former rtc_aborting_entry()
136 // @Override
137 // public ReturnCode_t onAborting(int ec_id) {
138 // return super.onAborting(ec_id);
139 // }
140  //
141  // The error action in ERROR state
142  // former rtc_error_do()
143 // @Override
144 // public ReturnCode_t onError(int ec_id) {
145 // return super.onError(ec_id);
146 // }
147  //
148  // The reset action that is invoked resetting
149  // This is same but different the former rtc_init_entry()
150 // @Override
151 // protected ReturnCode_t onReset(int ec_id) {
152 // return super.onReset(ec_id);
153 // }
154  //
155  // The state update action that is invoked after onExecute() action
156  // no corresponding operation exists in OpenRTm-aist-0.2.0
157 // @Override
158 // protected ReturnCode_t onStateUpdate(int ec_id) {
159 // return super.onStateUpdate(ec_id);
160 // }
161  //
162  // The action that is invoked when execution context's rate is changed
163  // no corresponding operation exists in OpenRTm-aist-0.2.0
164 // @Override
165 // protected ReturnCode_t onRateChanged(int ec_id) {
166 // return super.onRateChanged(ec_id);
167 // }
168 //
169  // DataInPort declaration
170  // <rtc-template block="inport_declare">
171 
172  // </rtc-template>
173 
174  // DataOutPort declaration
175  // <rtc-template block="outport_declare">
176 
177  // </rtc-template>
178 
179  // CORBA Port declaration
180  // <rtc-template block="corbaport_declare">
182 
183  // </rtc-template>
184 
185  // Service declaration
186  // <rtc-template block="service_declare">
187 
188  // </rtc-template>
189 
190  // Consumer declaration
191  // <rtc-template block="consumer_declare">
192  protected CorbaConsumer<PathPlanner> m_PathBase = new CorbaConsumer<PathPlanner>(PathPlanner.class);
193  protected PathPlanner m_Path;
194 
196 
198  item_ = item;
199  }
200 }
#define null
our own NULL pointer
Definition: IceTypes.h:57
ReturnCode_t
def run(tree, args)
void setConnectedCallback(GrxPathPlanningAlgorithmItem item)
LifeCycleState


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:04