[openrtm-commit:02186] r891 - in trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC: src/jp/go/aist/rtm/RTC src/jp/go/aist/rtm/RTC/RTC tests/src/jp/go/aist/rtm/RTC/RTC

openrtm @ openrtm.org openrtm @ openrtm.org
2016年 12月 22日 (木) 13:21:32 JST


Author: win-ei
Date: 2016-12-22 13:21:32 +0900 (Thu, 22 Dec 2016)
New Revision: 891

Modified:
   trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/RTC/ComponentObserverConsumer.java
   trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/RTObject_impl.java
   trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/RTC/ComponentObserverConsumerTest.java
Log:
[FSM4RTC]Fixed bugs.

Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/RTC/ComponentObserverConsumer.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/RTC/ComponentObserverConsumer.java	2016-12-17 12:23:45 UTC (rev 890)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/RTC/ComponentObserverConsumer.java	2016-12-22 04:21:32 UTC (rev 891)
@@ -775,9 +775,7 @@
             }
         }
         public void onActivated(int ec_id, ReturnCode_t ret) {
-        //public void onActivated(PostComponentActionListenerArgument arg) {
             onGeneric("ACTIVE:", ec_id, ret);
-            //onGeneric("ACTIVE:", arg.m_exec_handle,arg.m_ret);
         }
         public void onDeactivated(int ec_id, ReturnCode_t ret) {
             onGeneric("INACTIVE:", ec_id, ret);

Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/RTObject_impl.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/RTObject_impl.java	2016-12-17 12:23:45 UTC (rev 890)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/RTObject_impl.java	2016-12-22 04:21:32 UTC (rev 891)
@@ -4519,7 +4519,8 @@
                 try {
                     Class clazz = m_obj.getClass();
 
-                    m_method = clazz.getMethod(memfunc,int.class, RTC.ReturnCode_t.class);
+                    //m_method = clazz.getMethod(memfunc,int.class, RTC.ReturnCode_t.class);
+                    m_method = clazz.getDeclaredMethod(memfunc,int.class, RTC.ReturnCode_t.class);
 
                 }
                 catch(java.lang.Exception e){
@@ -6010,7 +6011,7 @@
                 try {
                     Class clazz = m_obj.getClass();
 
-                    m_method = clazz.getMethod(memfunc,String.class,String.class);
+                    m_method = clazz.getMethod(memfunc,String.class);
 
                 }
                 catch(java.lang.Exception e){

Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/RTC/ComponentObserverConsumerTest.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/RTC/ComponentObserverConsumerTest.java	2016-12-17 12:23:45 UTC (rev 890)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/RTC/ComponentObserverConsumerTest.java	2016-12-22 04:21:32 UTC (rev 891)
@@ -9,18 +9,30 @@
 import jp.go.aist.rtm.RTC.RtcNewFunc;
 import jp.go.aist.rtm.RTC.RtcDeleteFunc;
 
+import jp.go.aist.rtm.RTC.port.InPort;
+import jp.go.aist.rtm.RTC.port.OutPort;
+
+import jp.go.aist.rtm.RTC.util.DataRef;
+import jp.go.aist.rtm.RTC.util.IntegerHolder;
 import jp.go.aist.rtm.RTC.util.Properties;
 import jp.go.aist.rtm.RTC.util.POAUtil;
 
-import _SDOPackage.ServiceProfile;
+import _SDOPackage.Configuration;
+import _SDOPackage.ConfigurationSet;
 import _SDOPackage.NameValue;
+import _SDOPackage.NVListHolder;
 import _SDOPackage.SDOServiceHelper;
+import _SDOPackage.ServiceProfile;
 
+import RTC.ConnectorProfile;
+import RTC.ConnectorProfileHolder;
 import RTC.ComponentObserver;
 import RTC.ComponentObserverPOA;
 import RTC.ComponentObserverHelper;
+import RTC.PortService;
 import RTC.StatusKind;
 import RTC.StatusKindHolder;
+import RTC.TimedLong;
 import RTC.ReturnCode_t;
 import RTC.ExecutionContextListHolder;
 
@@ -46,6 +58,125 @@
     private POA m_pPOA;
 
     // sample code
+    public class SampleComponent2 extends DataFlowComponentBase {
+        @Override
+        protected ReturnCode_t onAborting(int ec_id) {
+            System.out.println("Sample:onAborting");
+            return super.onAborting(ec_id);
+        }
+
+        @Override
+        protected ReturnCode_t onActivated(int ec_id) {
+            System.out.println("Sample:onActivated");
+            try {
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+            return super.onActivated(ec_id);
+        }
+
+        @Override
+        protected ReturnCode_t onDeactivated(int ec_id) {
+            System.out.println("Sample:onDeactivated");
+            return super.onDeactivated(ec_id);
+        }
+
+        @Override
+        protected ReturnCode_t onError(int ec_id) {
+            System.out.println("Sample:onError");
+            return super.onError(ec_id);
+        }
+
+        @Override
+        protected ReturnCode_t onExecute(int ec_id) {
+            System.out.println("Sample:onExecute");
+            return super.onExecute(ec_id);
+        }
+
+        @Override
+        protected ReturnCode_t onFinalize() {
+            System.out.println("Sample:onFinalize");
+            return super.onFinalize();
+        }
+
+        @Override
+        protected ReturnCode_t onInitialize() {
+            System.out.println("Sample:onInitialize");
+
+            return super.onInitialize();
+        }
+
+        @Override
+        protected ReturnCode_t onRateChanged(int ec_id) {
+            System.out.println("Sample:onRateChanged");
+            return super.onRateChanged(ec_id);
+        }
+
+        @Override
+        protected ReturnCode_t onReset(int ec_id) {
+            System.out.println("Sample:onReset");
+            return super.onReset(ec_id);
+        }
+
+        @Override
+        protected ReturnCode_t onShutdown(int ec_id) {
+            System.out.println("Sample:onShutdown");
+            return super.onShutdown(ec_id);
+        }
+
+        @Override
+        protected ReturnCode_t onStartup(int ec_id) {
+            System.out.println("Sample:onStartup");
+            return super.onStartup(ec_id);
+        }
+
+        @Override
+        protected ReturnCode_t onStateUpdate(int ec_id) {
+            System.out.println("Sample:onStateUpdate");
+            return super.onStateUpdate(ec_id);
+        }
+
+        public SampleComponent2(Manager manager) {
+            super(manager);
+            m_mgr = manager;
+        }
+        protected Manager m_ngr;
+    }
+
+    public class SampleComponent2New implements RtcNewFunc {
+        public DataFlowComponentBase createRtc(Manager mgr) {
+            return new SampleComponent2(mgr);
+        }
+    }
+
+    public class SampleComponent2Delete implements RtcDeleteFunc {
+        public void deleteRtc(RTObject_impl rtcBase) {
+            rtcBase = null;
+        }
+    }
+
+    public class loadSample2 implements ModuleInitProc {
+        private int m_counter = 0;
+        private int m_counter2 = 0;
+
+        public void SampleMethod() {
+            System.out.println("Sample Method invoked.");
+        }
+        public void myModuleInit(Manager mgr) {
+            m_counter++;
+        }
+        public int getInitProcCount() {
+            return m_counter;
+        }
+        public void resetInitProcCount() {
+            m_counter = 0;
+        }
+        public void addInitProcCount() {
+            m_counter++;
+        }
+    }
+
+    // sample code
     public class SampleComponent extends DataFlowComponentBase {
         @Override
         protected ReturnCode_t onAborting(int ec_id) {
@@ -56,12 +187,20 @@
         @Override
         protected ReturnCode_t onActivated(int ec_id) {
             System.out.println("Sample:onActivated");
+            try {
+                addOutPort("out", m_outOut);
+                addInPort("in", m_inIn);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
             return super.onActivated(ec_id);
         }
 
         @Override
         protected ReturnCode_t onDeactivated(int ec_id) {
             System.out.println("Sample:onDeactivated");
+            removeOutPort(m_outOut);
+            removeInPort(m_inIn);
             return super.onDeactivated(ec_id);
         }
 
@@ -74,6 +213,44 @@
         @Override
         protected ReturnCode_t onExecute(int ec_id) {
             System.out.println("Sample:onExecute");
+            System.out.println("m_counter="+m_counter);
+            ++m_counter;
+            if(m_counter == 1) {
+                ConnectorProfile prof = new ConnectorProfile();
+                prof.connector_id = "";
+                prof.name = "connector0";
+                prof.ports = new PortService[2];
+                prof.ports = get_ports();
+                NVListHolder nvholder = new NVListHolder();
+                NameValue[] value = new NameValue[3];
+                nvholder.value = prof.properties;
+                org.omg.CORBA.Any any0 = m_mgr.getORB().create_any();
+                any0.insert_string("corba_cdr");
+                value[0] = new NameValue("dataport.interface_type",any0);
+
+                org.omg.CORBA.Any any1 = m_mgr.getORB().create_any();
+                any1.insert_string("push");
+                value[1] = new NameValue("dataport.dataflow_type",any1);
+
+                org.omg.CORBA.Any any2 = m_mgr.getORB().create_any();
+                any2.insert_string("flush");
+                value[2] = new NameValue("dataport.subscription_type",any2);
+
+                prof.properties = value;
+                ConnectorProfileHolder proflist = new ConnectorProfileHolder();
+                proflist.value = prof; 
+
+                m_inIn.connect(proflist);
+            }
+            if(m_counter == 2) {
+                m_inIn.disconnect_all();
+            }
+            if(m_counter > 3) {
+                m_counter = 0;
+                System.out.println("0 divs");
+                int id = m_counter /0;
+                System.out.println("0 divs !");
+            }
             return super.onExecute(ec_id);
         }
 
@@ -86,6 +263,7 @@
         @Override
         protected ReturnCode_t onInitialize() {
             System.out.println("Sample:onInitialize");
+
             return super.onInitialize();
         }
 
@@ -121,7 +299,22 @@
 
         public SampleComponent(Manager manager) {
             super(manager);
+            m_mgr = manager;
+            m_out_val = new TimedLong(new RTC.Time(0,0),0);
+            m_out = new DataRef<TimedLong>(m_out_val);
+            m_outOut = new OutPort<TimedLong>("out", m_out);
+            m_in_val = new TimedLong(new RTC.Time(0,0),0);
+            m_in = new DataRef<TimedLong>(m_in_val);
+            m_inIn = new InPort<TimedLong>("in", m_in);
         }
+        protected Manager m_ngr;
+        protected TimedLong m_out_val;
+        protected DataRef<TimedLong> m_out;
+        protected OutPort<TimedLong> m_outOut;
+        protected TimedLong m_in_val;
+        protected DataRef<TimedLong> m_in;
+        protected InPort<TimedLong> m_inIn;
+        int m_counter = 0;
     }
 
     public class SampleComponentNew implements RtcNewFunc {
@@ -237,6 +430,7 @@
      *</pre>
      */
     public void test_test001() {
+/*
         System.out.println("test_test001");
         ComponentObserverProviderMock obs = new ComponentObserverProviderMock();
 
@@ -315,6 +509,7 @@
              //do nothing
         }
         System.out.println("....");
+*/
     }   
     /**
      *<pre>
@@ -369,8 +564,6 @@
             fail();
         }
         manager.activateManager();
-        //manager.clearModulesFactories();
-        ///manager.clearModules();
         String component_conf[] = {
                 "implementation_id", "Sample",
                 "type_name",         "",
@@ -383,30 +576,111 @@
                 "language",          "",
                 "lang_type",         "",
                 "conf",              "",
+                "conf.default.int_param0", "0",
                 ""
         };
+        String component_conf2[] = {
+                "implementation_id", "Sample2",
+                "type_name",         "",
+                "description",       "",
+                "version",           "",
+                "vendor",            "",
+                "category",          "",
+                "activity_type",     "",
+                "max_instance",      "",
+                "language",          "",
+                "lang_type",         "",
+                "conf",              "",
+                ""
+        };
         Properties prop = new Properties(component_conf);
         manager.registerFactory(prop, new SampleComponentNew(), new SampleComponentDelete());
-        //Vector<String> complist = manager.getModulesFactories();
         RTObject_impl rtobj = manager.createComponent("Sample");
 
 
-
         ComponentObserverConsumer coc = new ComponentObserverConsumer();
         coc.init(rtobj,sprof);
 
+
         ExecutionContextListHolder ecs = new ExecutionContextListHolder();
         ecs.value = rtobj.get_owned_contexts();
+
+        //ECAction onAttached ATTACHED:
+        ecs.value[0].add_component(rtobj.getObjRef());
+
+        //ECAction onDetached DETACHED:
+//        ecs.value[0].remove_component(rtobj.getObjRef());
+
+        ecs.value[0].stop();
+        //ECAction onStartup STARTUP:
+        ecs.value[0].start();
+
+        //ECAction onRateChanged RATE_CHANGED:
+        ecs.value[0].set_rate(1000.0);
+
+        try { 
+            Configuration conf = rtobj.get_configuration();
+            ConfigurationSet confset = conf.get_active_configuration_set();
+            //ConfigAction setConfigSet SET_CONFIG_SET
+            conf.set_configuration_set_values(confset);
+
+            ConfigurationSet confset2 = confset; 
+            confset2.id = "test002";
+            //ConfigAction addConfigSet ADD_CONFIG_SET:
+            conf.add_configuration_set(confset2);
+
+            ConfigurationSet confset3 = confset; 
+            confset3.id = "test003";
+            conf.add_configuration_set(confset3);
+
+            //ConfigAction activateConfigSet ACTIVATE_CONFIG_SET:
+            conf.activate_configuration_set("test002");
+
+            //ConfigAction removeConfigSet REMOVE_CONFIG_SET: 
+            conf.remove_configuration_set("test003");
+            
+            IntegerHolder int_param0 = new IntegerHolder();
+            int_param0.value = 1000;
+            //ConfigAction updateConfigParam UPDATE_CONFIG_PARAM
+            rtobj.bindParameter("int_param0", int_param0, "0");
+
+            //ConfigAction updateConfigSet UPDATE_CONFIG_SET: 
+            rtobj.updateParameters("test002");
+
+        }
+        catch (Exception ex) {
+       }
+       
+
+        //CompStatMsg onActivated ACTIVE
         ecs.value[0].activate_component(rtobj.getObjRef());
 
+
+
+
         System.out.println("wait");
-        try{
-            Thread.sleep(5);
+        for(;;){
+            try{
+                Thread.sleep(5);
+            }
+            catch(InterruptedException ex){
+                 //do nothing
+            }
+            if(ecs.value[0].get_component_state(rtobj.getObjRef()).value()== 
+                RTC.LifeCycleState._ERROR_STATE){
+                System.out.println("reset");
+
+                //CompStatMsg onRset INACTIVE
+                ecs.value[0].reset_component(rtobj.getObjRef());
+                break;
+            }
         }
-        catch(InterruptedException ex){
-             //do nothing
-        }
+        ecs.value[0].activate_component(rtobj.getObjRef());
+
+        //CompStatMsg onDeactivated INACTIVE
         ecs.value[0].deactivate_component(rtobj.getObjRef());
+
+        ecs.value[0].stop();
         try{
             Thread.sleep(100);
         }



More information about the openrtm-commit mailing list