PathConsumerImpl.java
Go to the documentation of this file.
00001 // -*- Java -*-
00010 package jp.go.aist.hrp.simulator;
00011 
00012 import com.generalrobotix.ui.item.GrxPathPlanningAlgorithmItem;
00013 
00014 import RTC.ComponentProfile;
00015 import RTC.ConnectorProfile;
00016 import RTC.ConnectorProfileHolder;
00017 import RTC.ExecutionContext;
00018 import RTC.LifeCycleState;
00019 import RTC.PortService;
00020 import RTC.RTObject;
00021 import RTC.ReturnCode_t;
00022 import jp.go.aist.hrp.simulator.PathPlanner;
00023 import jp.go.aist.rtm.RTC.DataFlowComponentBase;
00024 import jp.go.aist.rtm.RTC.Manager;
00025 import jp.go.aist.rtm.RTC.port.ConnectionCallback;
00026 import jp.go.aist.rtm.RTC.port.CorbaConsumer;
00027 import jp.go.aist.rtm.RTC.port.CorbaPort;
00028 
00029 public class PathConsumerImpl extends DataFlowComponentBase{
00030 
00031         public PathConsumerImpl(Manager manager) {  
00032         super(manager);
00033         // <rtc-template block="initializer">
00034         m_PathPlannerPort = new CorbaPort("PathPlanner");
00035         // </rtc-template>
00036 
00037         // Registration: InPort/OutPort/Service
00038         // <rtc-template block="registration">
00039         // Set InPort buffers
00040         
00041         // Set OutPort buffer
00042         
00043         // Set service provider to Ports
00044         
00045         // Set service consumers to Ports
00046         m_PathPlannerPort.registerConsumer("Path", "PathPlanner", m_PathBase);
00047         m_PathPlannerPort.setOnConnected( new ConnectionCallback() {
00048                         public void run(ConnectorProfileHolder arg0) {
00049                                 ConnectorProfile[] connectorProfiles = m_PathPlannerPort.get_connector_profiles();
00050                                 for(ConnectorProfile connectorProfile : connectorProfiles){
00051                                         PortService[] portServices = connectorProfile.ports;
00052                                         for(PortService portService : portServices){
00053                                                 RTObject rtObject = portService.get_port_profile().owner;
00054                                                 String typeName = rtObject.get_component_profile().type_name;
00055                                                 if(typeName.equals("Path")){
00056                                                         ExecutionContext[] executionContexts = rtObject.get_owned_contexts();
00057                                                         for(ExecutionContext executionContext : executionContexts){
00058                                                                 if(executionContext.get_component_state(rtObject) != LifeCycleState.ACTIVE_STATE){
00059                                                                         if(executionContext.activate_component(rtObject) == ReturnCode_t.RTC_OK)
00060                                                                                 ;
00061                                                                         else
00062                                                                                 item_.connectedCallback(false);
00063                                                                 }
00064                                                                 item_.connectedCallback(true);
00065                                                                 return;
00066                                                         }
00067 
00068                                                 }
00069                                         }
00070                                 }
00071                                 item_.connectedCallback(false);
00072                         }
00073         });
00074         m_PathPlannerPort.setOnDisconnected( new ConnectionCallback() {
00075                         public void run(ConnectorProfileHolder arg0) {
00076                                 item_.connectedCallback(false);
00077                         }
00078         });
00079         
00080         // Set CORBA Service Ports
00081         registerPort(m_PathPlannerPort);
00082         
00083         // </rtc-template>
00084     }
00085 
00086     // The initialize action (on CREATED->ALIVE transition)
00087     // formaer rtc_init_entry() 
00088 //    @Override
00089 //    protected ReturnCode_t onInitialize() {
00090 //        return super.onInitialize();
00091 //    }
00092     // The finalize action (on ALIVE->END transition)
00093     // formaer rtc_exiting_entry()
00094 //    @Override
00095 //    protected ReturnCode_t onFinalize() {
00096 //        return super.onFinalize();
00097 //    }
00098     //
00099     // The startup action when ExecutionContext startup
00100     // former rtc_starting_entry()
00101 //    @Override
00102 //    protected ReturnCode_t onStartup(int ec_id) {
00103 //        return super.onStartup(ec_id);
00104 //    }
00105     //
00106     // The shutdown action when ExecutionContext stop
00107     // former rtc_stopping_entry()
00108 //    @Override
00109 //    protected ReturnCode_t onShutdown(int ec_id) {
00110 //        return super.onShutdown(ec_id);
00111 //    }
00112     //
00113     // The activated action (Active state entry action)
00114     // former rtc_active_entry()
00115 //    @Override
00116 //    protected ReturnCode_t onActivated(int ec_id) {
00117 //        return super.onActivated(ec_id);
00118 //    }
00119     //
00120     // The deactivated action (Active state exit action)
00121     // former rtc_active_exit()
00122 //    @Override
00123 //    protected ReturnCode_t onDeactivated(int ec_id) {
00124 //        return super.onDeactivated(ec_id);
00125 //    }
00126     //
00127     // The execution action that is invoked periodically
00128     // former rtc_active_do()
00129 //    @Override
00130 //    protected ReturnCode_t onExecute(int ec_id) {
00131 //        return super.onExecute(ec_id);
00132 //    }
00133     //
00134     // The aborting action when main logic error occurred.
00135     // former rtc_aborting_entry()
00136 //  @Override
00137 //  public ReturnCode_t onAborting(int ec_id) {
00138 //      return super.onAborting(ec_id);
00139 //  }
00140     //
00141     // The error action in ERROR state
00142     // former rtc_error_do()
00143 //    @Override
00144 //    public ReturnCode_t onError(int ec_id) {
00145 //        return super.onError(ec_id);
00146 //    }
00147     //
00148     // The reset action that is invoked resetting
00149     // This is same but different the former rtc_init_entry()
00150 //    @Override
00151 //    protected ReturnCode_t onReset(int ec_id) {
00152 //        return super.onReset(ec_id);
00153 //    }
00154     //
00155     // The state update action that is invoked after onExecute() action
00156     // no corresponding operation exists in OpenRTm-aist-0.2.0
00157 //    @Override
00158 //    protected ReturnCode_t onStateUpdate(int ec_id) {
00159 //        return super.onStateUpdate(ec_id);
00160 //    }
00161     //
00162     // The action that is invoked when execution context's rate is changed
00163     // no corresponding operation exists in OpenRTm-aist-0.2.0
00164 //    @Override
00165 //    protected ReturnCode_t onRateChanged(int ec_id) {
00166 //        return super.onRateChanged(ec_id);
00167 //    }
00168 //
00169     // DataInPort declaration
00170     // <rtc-template block="inport_declare">
00171     
00172     // </rtc-template>
00173 
00174     // DataOutPort declaration
00175     // <rtc-template block="outport_declare">
00176     
00177     // </rtc-template>
00178 
00179     // CORBA Port declaration
00180     // <rtc-template block="corbaport_declare">
00181     protected CorbaPort m_PathPlannerPort;
00182     
00183     // </rtc-template>
00184 
00185     // Service declaration
00186     // <rtc-template block="service_declare">
00187     
00188     // </rtc-template>
00189 
00190     // Consumer declaration
00191     // <rtc-template block="consumer_declare">
00192     protected CorbaConsumer<PathPlanner> m_PathBase = new CorbaConsumer<PathPlanner>(PathPlanner.class);
00193     protected PathPlanner m_Path;
00194   
00195     private GrxPathPlanningAlgorithmItem item_ = null;
00196 
00197         public void setConnectedCallback(GrxPathPlanningAlgorithmItem item) {
00198                 item_ = item;
00199         }
00200 }


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sun Apr 2 2017 03:43:56