[openrtm-commit:01781] r779 - in trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC: src/RTMExamples/SimpleIO src/jp/go/aist/rtm/RTC/util tests/src/jp/go/aist/rtm/RTC/util

openrtm @ openrtm.org openrtm @ openrtm.org
2016年 2月 28日 (日) 05:50:31 JST


Author: win-ei
Date: 2016-02-28 05:50:31 +0900 (Sun, 28 Feb 2016)
New Revision: 779

Modified:
   trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/SimpleIO/get_actual_ec.java
   trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/util/RTShellUtil.java
   trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/util/RTShellUtilTest.java
Log:
Fixed bugs.

Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/SimpleIO/get_actual_ec.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/SimpleIO/get_actual_ec.java	2016-02-27 18:05:55 UTC (rev 778)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/SimpleIO/get_actual_ec.java	2016-02-27 20:50:31 UTC (rev 779)
@@ -2,11 +2,15 @@
 
 import java.lang.Thread;
 
+
+import RTMExamples.SimpleService.MyServiceConsumer;
+
 import jp.go.aist.rtm.RTC.Manager;
 import jp.go.aist.rtm.RTC.ModuleInitProc;
 import jp.go.aist.rtm.RTC.RTObject_impl;
 import jp.go.aist.rtm.RTC.CorbaNaming;
 import jp.go.aist.rtm.RTC.RTObject_impl;
+import jp.go.aist.rtm.RTC.executionContext.ExecutionContextWorker;
 import jp.go.aist.rtm.RTC.port.CorbaConsumer;
 import jp.go.aist.rtm.RTC.util.CORBA_SeqUtil;
 import jp.go.aist.rtm.RTC.util.NVUtil;
@@ -25,6 +29,7 @@
 import OpenRTM.DataFlowComponent;
 import RTC.ExecutionContext;
 import RTC.ExecutionContextListHolder;
+import RTC.LifeCycleState;
 import RTC.PortService;
 import RTC.PortServiceListHolder;
 import RTC.RTObject;
@@ -39,7 +44,13 @@
         
         final Manager manager = Manager.init(args);
 
+        // 
+        // 
+        // 
         manager.activateManager();
+        // 
+        // 
+        //
         Properties prop_out = new Properties(ConsoleOut.component_conf);
         manager.registerFactory(prop_out, new ConsoleOut(), new ConsoleOut());
         RTObject_impl out_impl = manager.createComponent("ConsoleOut");
@@ -47,6 +58,7 @@
         {
             System.out.println("ConsoleOut is null.");
         }
+        //
         Properties prop_in = new Properties(ConsoleIn.component_conf);
         manager.registerFactory(prop_in, new ConsoleIn(), new ConsoleIn());
         RTObject_impl in_impl = manager.createComponent("ConsoleIn");
@@ -54,18 +66,40 @@
         {
             System.out.println("ConsoleIn is null.");
         }
+        //
+        Properties prop_out_seq = new Properties(MyServiceConsumer.component_conf);
+        manager.registerFactory(prop_out_seq, 
+                new MyServiceConsumer(), new MyServiceConsumer());
+        RTObject_impl out_seq_impl 
+            = manager.createComponent("MyServiceConsumer");
+        if(out_seq_impl==null)
+        {
+            System.out.println("MyServiceConsumer is null.");
+        }
+        //
+        //
+        //
         manager.runManager(true);
-
+        // 
+        // 
+        // 
         ExecutionContextListHolder eclisto = new ExecutionContextListHolder();
         eclisto.value = new ExecutionContext[0];
         eclisto.value =  out_impl.get_owned_contexts();
         System.out.println( "eclisto.value.length : "+ eclisto.value.length);
-
+        //
         ExecutionContextListHolder eclisti = new ExecutionContextListHolder();
         eclisti.value = new ExecutionContext[0];
         eclisti.value =  in_impl.get_owned_contexts();
         System.out.println( "eclisti.value.length : "+ eclisti.value.length);
-
+        // 
+        ExecutionContextListHolder eclistseq = new ExecutionContextListHolder();
+        eclistseq.value = new ExecutionContext[0];
+        eclistseq.value =  out_seq_impl.get_owned_contexts();
+        System.out.println( "eclistseq.value.length : "+ eclistseq.value.length);
+        //
+        // bind
+        //
         out_impl.bindContext(eclisti.value[0]);
         eclisto.value =  out_impl.get_owned_contexts();
         System.out.println( "eclisto.value.length : "+ eclisto.value.length);
@@ -91,13 +125,18 @@
             e.printStackTrace();
         }
 
-        // activate ConsoleOut0
+        // 
         ExecutionContextListHolder eclist = new ExecutionContextListHolder();
         eclist.value = new ExecutionContext[0];
         RTObject conoutRef = conout._ptr();
         eclist.value =  conoutRef.get_owned_contexts();
         System.out.println( "eclist.value.length : "+ eclist.value.length);
 
+
+        //
+        // get_actual_ec
+        //
+        System.out.println( "-get_actual_ec");
         ExecutionContext ec = RTShellUtil.get_actual_ec(conoutRef,0);
         assert ec.equals(eclisto.value[0]);
         if(ec.equals(eclisto.value[0])) {
@@ -115,7 +154,315 @@
         else{
              System.out.println( "NG");
         }
+        ec = RTShellUtil.get_actual_ec(conoutRef,2);
+        assert ec == null;
+        if(ec==null) {
+             System.out.println( "OK");
+        }
+        else{
+             System.out.println( "NG");
+        }
 
+        //
+        // get_ec_id
+        //
+        System.out.println( "-get_ec_id");
+        int id = RTShellUtil.get_ec_id(conoutRef, eclisto.value[0]);
+        System.out.println( "id : " + id );
+        assert id == 0;
+        if(id == 0){
+             System.out.println( "OK");
+        }
+        else{
+             System.out.println( "NG");
+        }
+        id = RTShellUtil.get_ec_id(conoutRef, eclisto.value[1]);
+        System.out.println( "id : " + id );
+        assert id == 1;
+        if(id == 1){
+             System.out.println( "OK");
+        }
+        else{
+             System.out.println( "NG");
+        }
+        id = RTShellUtil.get_ec_id(conoutRef, null);
+        System.out.println( "id : " + id );
+        assert id == -1;
+        if(id == -1){
+             System.out.println( "OK");
+        }
+        else{
+             System.out.println( "NG");
+        }
+        id = RTShellUtil.get_ec_id(null, eclisto.value[1]);
+        System.out.println( "id : " + id );
+        assert id == -1;
+        if(id == -1){
+             System.out.println( "OK");
+        }
+        else{
+             System.out.println( "NG");
+        }
+        id = RTShellUtil.get_ec_id(conoutRef, eclistseq.value[0]);
+        System.out.println( "id : " + id );
+        assert id == -1;
+        if(id == -1){
+             System.out.println( "OK");
+        }
+        else{
+             System.out.println( "NG");
+        }
+        //
+        // activate
+        //
+        {
+        System.out.println( "-activate/deactivate");
+        ReturnCode_t ret = RTShellUtil.activate(null, 0);
+        assert ret == ReturnCode_t.BAD_PARAMETER;
+        if(ret == ReturnCode_t.BAD_PARAMETER){
+             System.out.println( "OK");
+        }
+        else{
+             System.out.println( "NG");
+        }
+        ret = RTShellUtil.activate(conoutRef, 3);
+        assert ret == ReturnCode_t.BAD_PARAMETER;
+        if(ret == ReturnCode_t.BAD_PARAMETER){
+             System.out.println( "OK");
+        }
+        else{
+             System.out.println( "NG");
+        }
+        ret = RTShellUtil.deactivate(null, 0);
+        assert ret == ReturnCode_t.BAD_PARAMETER;
+        if(ret == ReturnCode_t.BAD_PARAMETER){
+             System.out.println( "OK");
+        }
+        else{
+             System.out.println( "NG");
+        }
+        ret = RTShellUtil.deactivate(conoutRef, 3);
+        assert ret == ReturnCode_t.BAD_PARAMETER;
+        if(ret == ReturnCode_t.BAD_PARAMETER){
+             System.out.println( "OK");
+        }
+        else{
+             System.out.println( "NG");
+        }
+        ret = RTShellUtil.activate(conoutRef, 0);
+        assert ret == ReturnCode_t.RTC_OK;
+        if(ret == ReturnCode_t.RTC_OK){
+             System.out.println( "OK");
+        }
+        else{
+             System.out.println( "NG");
+        }
+        ret = RTShellUtil.deactivate(conoutRef, 0);
+        assert ret == ReturnCode_t.RTC_OK;
+        if(ret == ReturnCode_t.RTC_OK){
+             System.out.println( "OK");
+        }
+        else{
+             System.out.println( "NG");
+        }
+/*
+        ret = RTShellUtil.activate(conoutRef, 1);
+        assert ret == ReturnCode_t.RTC_OK;
+        if(ret == ReturnCode_t.RTC_OK){
+             System.out.println( "OK");
+        }
+        else{
+             System.out.println( "NG");
+        }
+        ret = RTShellUtil.deactivate(conoutRef, 1);
+        assert ret == ReturnCode_t.RTC_OK;
+        if(ret == ReturnCode_t.RTC_OK){
+             System.out.println( "OK");
+        }
+        else{
+             System.out.println( "NG");
+        }
+*/
+
+        }
+        //
+        // get_state
+        //
+        //"CREATED_STATE",
+        //"INACTIVE_STATE",
+        //"ACTIVE_STATE",
+        //"ERROR_STATE"
+        {
+        System.out.println( "-get_state");
+        // 
+        try{
+            Thread.sleep(500); 
+        }
+        catch(InterruptedException e){
+        }
+
+
+        LifeCycleState ret = RTShellUtil.get_state(conoutRef, 0);
+        String str_ret = getStateString(ret);
+        System.out.println(str_ret);
+        assert str_ret.equals("INACTIVE_STATE");
+        if(str_ret.equals("INACTIVE_STATE")){
+             System.out.println( "OK");
+        }
+        else{
+             System.out.println( "NG");
+        }
+        //
+        RTShellUtil.activate(conoutRef, 0);
+        try{
+            Thread.sleep(500); 
+        }
+        catch(InterruptedException e){
+        }
+        ret = RTShellUtil.get_state(conoutRef, 0);
+        str_ret = getStateString(ret);
+        System.out.println(str_ret);
+        assert str_ret.equals("ACTIVE_STATE");
+        if(str_ret.equals("ACTIVE_STATE")){
+             System.out.println( "OK");
+        }
+        else{
+             System.out.println( "NG");
+        }
+        //
+        RTShellUtil.deactivate(conoutRef, 0);
+        try{
+            Thread.sleep(500); 
+        }
+        catch(InterruptedException e){
+        }
+        ret = RTShellUtil.get_state(conoutRef, 0);
+        str_ret = getStateString(ret);
+        assert str_ret.equals("INACTIVE_STATE");
+        if(str_ret.equals("INACTIVE_STATE")){
+             System.out.println( "OK");
+        }
+        else{
+             System.out.println( "NG");
+        }
+        System.out.println(str_ret);
+        //
+        ret = RTShellUtil.get_state(null, 0);
+        str_ret = getStateString(ret);
+        assert str_ret.equals("ERROR_STATE");
+        if(str_ret.equals("ERROR_STATE")){
+             System.out.println( "OK");
+        }
+        else{
+             System.out.println( "NG");
+        }
+        System.out.println(str_ret);
+        //
+        ret = RTShellUtil.get_state(conoutRef, 3);
+        str_ret = getStateString(ret);
+        assert str_ret.equals("ERROR_STATE");
+        if(str_ret.equals("ERROR_STATE")){
+             System.out.println( "OK");
+        }
+        else{
+             System.out.println( "NG");
+        }
+        System.out.println(str_ret);
+
+        }
+        //
+        // is_in_active
+        //
+        {
+        System.out.println( "-is_in_active");
+        if(!RTShellUtil.is_in_active(conoutRef, 0)){
+             System.out.println( "OK");
+        }
+        else{
+             System.out.println( "NG");
+        }
+        //
+        RTShellUtil.activate(conoutRef, 0);
+        try{
+            Thread.sleep(500); 
+        }
+        catch(InterruptedException e){
+        }
+        if(RTShellUtil.is_in_active(conoutRef, 0)){
+             System.out.println( "OK");
+        }
+        else{
+             System.out.println( "NG");
+        }
+        //
+        RTShellUtil.deactivate(conoutRef, 0);
+        try{
+            Thread.sleep(500); 
+        }
+        catch(InterruptedException e){
+        }
+        if(!RTShellUtil.is_in_active(conoutRef, 0)){
+             System.out.println( "OK");
+        }
+        else{
+             System.out.println( "NG");
+        }
+        //
+        if(!RTShellUtil.is_in_active(null, 0)){
+             System.out.println( "OK");
+        }
+        else{
+             System.out.println( "NG");
+        }
+        if(!RTShellUtil.is_in_active(conoutRef, 3)){
+             System.out.println( "OK");
+        }
+        else{
+             System.out.println( "NG");
+        }
+
+        }
+        //
+        // get_default_rate/set_default_rate
+        //
+        {
+
+        System.out.println( "-get_default_rate/set_default_rate");
+        double ret = RTShellUtil.get_default_rate(conoutRef);
+        if(ret == 1000.0){
+             System.out.println( "OK");
+        }
+        else{
+             System.out.println( "NG");
+        }
+        RTShellUtil.set_default_rate(conoutRef, 500.0);
+        ret = RTShellUtil.get_default_rate(conoutRef);
+        if(ret == 500.0){
+             System.out.println( "OK");
+        }
+        else{
+             System.out.println( "NG");
+        }
+        ret = RTShellUtil.get_default_rate(null);
+        ReturnCode_t code = RTShellUtil.set_default_rate(null, 500.0);
+        if(code == ReturnCode_t.BAD_PARAMETER){
+             System.out.println( "OK");
+        }
+        else{
+             System.out.println( "NG");
+        }
+ 
+
+        }
     }
+    public static String getStateString(LifeCycleState state) {
+      final String st[] = {
+        "CREATED_STATE",
+        "INACTIVE_STATE",
+        "ACTIVE_STATE",
+        "ERROR_STATE"
+      };
+        return st[state.value()]; 
+    }
 }
 

Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/util/RTShellUtil.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/util/RTShellUtil.java	2016-02-27 18:05:55 UTC (rev 778)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/util/RTShellUtil.java	2016-02-27 20:50:31 UTC (rev 779)
@@ -206,10 +206,14 @@
      *   {@.en ExecutionContext}
      *
      * @return 
-     *   {@.ja 実行コンテキストのID 指定した実行コンテキストがRTコンポーネントに関連付けられていなかった場合は-1を返す}
+     *   {@.ja 実行コンテキストのID 
+     * 指定した実行コンテキストがRTコンポーネントに
+     * 関連付けられていなかった場合は-1を返す}
+     *   {@.en ID of ExecutionContext}
      *
      */
     public static int get_ec_id(RTObject rtc, ExecutionContext ec){
+
         if(rtc == null){
             return -1;
         }
@@ -225,7 +229,7 @@
         ExecutionContext[] eclist_pec = rtc.get_participating_contexts();
         for(int ic=0;ic<eclist_pec.length;++ic){
             if(eclist_pec[ic] != null){
-                if(eclist[ic]._is_equivalent(ec)){
+                if(eclist_pec[ic]._is_equivalent(ec)){
                     return ic+RTObject_impl.ECOTHER_OFFSET;
                 }
             }
@@ -527,8 +531,8 @@
      *   {@.ja 対象のRTコンポーネント}
      *   {@.en Target RT-Component's instances}
      * 
-     * @param 
-     *   {@.ja ec_id 実行コンテキストのID}
+     * @param ec_id 
+     *   {@.ja 実行コンテキストのID}
      *   {@.en ExecutionContext handle}
      * 
      * @return 
@@ -1125,11 +1129,11 @@
      *   {@.ja 設定}
      *   {@.en connection properties}
      * 
-     * @param port0 
+     * @param port 
      *   {@.ja 対象のポート}
      *   {@.en Target Port}
      * 
-     * @param port1 
+     * @param target_ports 
      *   {@.ja 対象のポートのリスト}
      *   {@.en List of connected ports}
      *
@@ -1290,7 +1294,7 @@
      *   {@.ja 対象のポート}
      *   {@.en Target Port}
      * 
-     * @param name 
+     * @param id
      *   {@.ja コネクタID}
      *   {@.en connector id}
      * 
@@ -1386,12 +1390,13 @@
     }
     /**
      *
-     * {@.ja 指定したコンフィギュレーションセット名、パラメータ名のコンフィギュレーションパラメータを取得}
+     * {@.ja 指定したコンフィギュレーションセット名、パラメータ名の
+     * コンフィギュレーションパラメータを取得}
      * {@.en Get Configuration object}
      * <p>
      * {@.ja コンポーネントのプロパティ取得}
      * 
-     * @param conf 
+     * @param rtc 
      *   {@.ja コンフィギュレーション}
      *   {@.en Configuration}
      * 

Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/util/RTShellUtilTest.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/util/RTShellUtilTest.java	2016-02-27 18:05:55 UTC (rev 778)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/util/RTShellUtilTest.java	2016-02-27 20:50:31 UTC (rev 779)
@@ -42,50 +42,62 @@
 import RTC.PortService;
 import RTC.PortServiceListHolder;
 import RTC.RTObject;
+import RTC.RTObjectHolder;
 import RTC.RTObjectHelper;
 import RTC.ReturnCode_t;
 import _SDOPackage.NVListHolder;
 import _SDOPackage.NameValue;
 
 public class RTShellUtilTest extends TestCase {
-    private Manager m_mgr;
-    private RTObject m_conoutRef;
+    private Manager m_manager;
+    private ORB m_orb;
+    private CorbaConsumer<DataFlowComponent> m_conout =
+            new CorbaConsumer<DataFlowComponent>(DataFlowComponent.class);
+    private RTObjectHolder m_conoutRef
+                    = new RTObjectHolder();
+    //private RTObject m_conoutRef;
     private ExecutionContextListHolder m_eclisto 
                     = new ExecutionContextListHolder();
+    private ExecutionContextListHolder m_eclistseq 
+                    = new ExecutionContextListHolder();
 
+    private RTObject_impl m_out_impl;
     protected void setUp() throws Exception {
         super.setUp();
 
         String[] args = new String[0];
-        Manager manager = Manager.init(null);
+        //Manager manager = Manager.init(null);
+        Manager m_manager = Manager.init(null);
         // 
         // 
         // 
-        manager.activateManager();
+        m_manager.activateManager();
         // 
         // 
         //
         Properties prop_out = new Properties(ConsoleOut.component_conf);
-        manager.registerFactory(prop_out, new ConsoleOut(), new ConsoleOut());
-        RTObject_impl out_impl = manager.createComponent("ConsoleOut");
-        if(out_impl==null)
+        m_manager.registerFactory(prop_out, 
+                new ConsoleOut(), new ConsoleOut());
+        //RTObject_impl out_impl = m_manager.createComponent("ConsoleOut");
+        m_out_impl = m_manager.createComponent("ConsoleOut");
+        if(m_out_impl==null)
         {
             System.out.println("ConsoleOut is null.");
         }
         //
         Properties prop_in = new Properties(ConsoleIn.component_conf);
-        manager.registerFactory(prop_in, new ConsoleIn(), new ConsoleIn());
-        RTObject_impl in_impl = manager.createComponent("ConsoleIn");
+        m_manager.registerFactory(prop_in, new ConsoleIn(), new ConsoleIn());
+        RTObject_impl in_impl = m_manager.createComponent("ConsoleIn");
         if(in_impl==null)
         {
             System.out.println("ConsoleIn is null.");
         }
         //
         Properties prop_out_seq = new Properties(MyServiceConsumer.component_conf);
-        manager.registerFactory(prop_out_seq, 
+        m_manager.registerFactory(prop_out_seq, 
                 new MyServiceConsumer(), new MyServiceConsumer());
         RTObject_impl out_seq_impl 
-            = manager.createComponent("MyServiceConsumer");
+            = m_manager.createComponent("MyServiceConsumer");
         if(out_seq_impl==null)
         {
             System.out.println("MyServiceConsumer is null.");
@@ -93,13 +105,13 @@
         //
         //
         //
-        manager.runManager(true);
+        m_manager.runManager(true);
         // 
         // 
         // 
         //ExecutionContextListHolder eclisto = new ExecutionContextListHolder();
         m_eclisto.value = new ExecutionContext[0];
-        m_eclisto.value =  out_impl.get_owned_contexts();
+        m_eclisto.value =  m_out_impl.get_owned_contexts();
         System.out.println( "m_eclisto.value.length : "
                 + m_eclisto.value.length);
         //
@@ -108,31 +120,32 @@
         eclisti.value =  in_impl.get_owned_contexts();
         System.out.println( "eclisti.value.length : "+ eclisti.value.length);
         // 
-        ExecutionContextListHolder eclistseq = new ExecutionContextListHolder();
-        eclistseq.value = new ExecutionContext[0];
-        eclistseq.value =  out_seq_impl.get_owned_contexts();
-        System.out.println( "eclistseq.value.length : "+ eclistseq.value.length);
+        //ExecutionContextListHolder eclistseq = new ExecutionContextListHolder();
+        m_eclistseq.value = new ExecutionContext[0];
+        m_eclistseq.value =  out_seq_impl.get_owned_contexts();
+        System.out.println( "m_eclistseq.value.length : "+ m_eclistseq.value.length);
         //
         // bind
         //
-        out_impl.bindContext(eclisti.value[0]);
-        m_eclisto.value =  out_impl.get_owned_contexts();
+        m_out_impl.bindContext(eclisti.value[0]);
+        m_eclisto.value =  m_out_impl.get_owned_contexts();
         System.out.println( "m_eclisto.value.length : "
                 + m_eclisto.value.length);
 
-        ORB orb = ORBUtil.getOrb();
+        //ORB orb = ORBUtil.getOrb();
+        m_orb = ORBUtil.getOrb();
         CorbaNaming naming = null;
         try {
-            naming = new CorbaNaming(orb, "localhost:2809");
+            naming = new CorbaNaming(m_orb, "localhost:2809");
         } catch (Exception e) {
             e.printStackTrace();
         }
         
-        CorbaConsumer<DataFlowComponent> conout =
-            new CorbaConsumer<DataFlowComponent>(DataFlowComponent.class);
+        //CorbaConsumer<DataFlowComponent> conout =
+        //    new CorbaConsumer<DataFlowComponent>(DataFlowComponent.class);
         // find ConsoleOut0 component
         try {
-            conout.setObject(naming.resolve(".host_cxt/ConsoleOut0.rtc"));
+            m_conout.setObject(naming.resolve(".host_cxt/ConsoleOut0.rtc"));
         } catch (NotFound e) {
             e.printStackTrace();
         } catch (CannotProceed e) {
@@ -144,10 +157,15 @@
         // 
         ExecutionContextListHolder eclist = new ExecutionContextListHolder();
         eclist.value = new ExecutionContext[0];
-        m_conoutRef = conout._ptr();
-        eclist.value =  m_conoutRef.get_owned_contexts();
+        m_conoutRef.value = m_conout._ptr();
+        eclist.value =  m_conoutRef.value.get_owned_contexts();
         System.out.println( "eclist.value.length : "+ eclist.value.length);
 
+        try{
+            Thread.sleep(500); 
+        }
+        catch(InterruptedException e){
+        }
     }
 
     protected void tearDown() throws Exception {
@@ -159,18 +177,97 @@
      * 
      */
     public void test_get_actual_ec() {
-        ExecutionContext ec = RTShellUtil.get_actual_ec(m_conoutRef,0);
-        assertTrue(ec.equals(m_eclisto.value[0]));
+        ExecutionContext ec = RTShellUtil.get_actual_ec(m_conoutRef.value,0);
+        assertTrue(ec._is_equivalent(m_eclisto.value[0]));
 
-        ec = RTShellUtil.get_actual_ec(m_conoutRef,1);
-        assertTrue(ec.equals(m_eclisto.value[1]));
+        ec = RTShellUtil.get_actual_ec(m_conoutRef.value,1);
+        assertTrue(ec._is_equivalent(m_eclisto.value[1]));
 
-        ec = RTShellUtil.get_actual_ec(m_conoutRef,2);
+        ec = RTShellUtil.get_actual_ec(m_conoutRef.value,2);
         assertTrue(ec == null);
 
         ec = RTShellUtil.get_actual_ec(null,0);
         assertTrue(ec == null);
 
     }
+    /**
+     *
+     * 
+     */
+    public void test_get_ec_id(){
+        System.out.println( "110 : " );
+        ExecutionContext[] list = m_conoutRef.value.get_owned_contexts();
+        System.out.println( "115 : " +list.length);
+        System.out.println( "116 : " +m_eclisto.value.length);
+        if(list[0]._is_equivalent(m_eclisto.value[0])){
+           System.out.println( "120 : " );
+        }
+        if(list[0] == m_eclisto.value[0]){
+           System.out.println( "130 : " );
+        }
+        System.out.println( "140 : " );
+        int id = RTShellUtil.get_ec_id(m_conoutRef.value, m_eclisto.value[0]);
+        System.out.println( "id : " + id );
+        assertTrue(id == 0);
+
+        id = RTShellUtil.get_ec_id(m_conoutRef.value, m_eclisto.value[1]);
+        System.out.println( "id : " + id );
+        assertTrue(id == 1);
+
+        id = RTShellUtil.get_ec_id(m_conoutRef.value, null);
+        System.out.println( "id : " + id );
+        assertTrue(id == -1);
+
+        id = RTShellUtil.get_ec_id(null, m_eclisto.value[1]);
+        System.out.println( "id : " + id );
+        assertTrue(id == -1);
+
+        id = RTShellUtil.get_ec_id(m_conoutRef.value, m_eclistseq.value[0]);
+        System.out.println( "id : " + id );
+        assertTrue(id == -1);
+    }
+    /**
+     *
+     * 
+     */
+    public void test_activate_deactivate(){
+        ReturnCode_t ret = RTShellUtil.activate(null, 0);
+        assertTrue(ret == ReturnCode_t.BAD_PARAMETER);
+
+        ret = RTShellUtil.activate(m_conoutRef.value, 3);
+        assertTrue(ret == ReturnCode_t.BAD_PARAMETER);
+
+        ret = RTShellUtil.deactivate(null, 0);
+        assertTrue(ret == ReturnCode_t.BAD_PARAMETER);
+
+        ret = RTShellUtil.deactivate(m_conoutRef.value, 3);
+        assertTrue(ret == ReturnCode_t.BAD_PARAMETER);
+
+        try{
+            Thread.sleep(500); 
+        }
+        catch(InterruptedException e){
+        }
+
+        ret = RTShellUtil.activate(m_conoutRef.value, 0);
+        assertTrue(ret == ReturnCode_t.RTC_OK);
+
+        try{
+            Thread.sleep(500); 
+        }
+        catch(InterruptedException e){
+        }
+
+        ret = RTShellUtil.deactivate(m_conoutRef.value, 0);
+        assertTrue(ret == ReturnCode_t.RTC_OK);
+/*
+        ret = RTShellUtil.activate(m_conoutRef.value, 1);
+        assertTrue(ret == ReturnCode_t.RTC_OK);
+
+        ret = RTShellUtil.deactivate(m_conoutRef.value, 1);
+        assertTrue(ret == ReturnCode_t.RTC_OK);
+*/
+    }
+
 }
 



More information about the openrtm-commit mailing list