[openrtm-commit:00611] r651 - in branches/work/DesignChangeOfEC/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC: . executionContext

openrtm @ openrtm.org openrtm @ openrtm.org
2012年 1月 23日 (月) 17:57:30 JST


Author: fsi-katami
Date: 2012-01-23 17:57:29 +0900 (Mon, 23 Jan 2012)
New Revision: 651

Added:
   branches/work/DesignChangeOfEC/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/ExecutionContextProfile.java
Removed:
   branches/work/DesignChangeOfEC/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/CorbaObjectManager.java
Modified:
   branches/work/DesignChangeOfEC/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/Manager.java
   branches/work/DesignChangeOfEC/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/RTObject_impl.java
   branches/work/DesignChangeOfEC/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/ExecutionContextBase.java
   branches/work/DesignChangeOfEC/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/PeriodicExecutionContext.java
Log:
Daily check in. refs #2322  

Deleted: branches/work/DesignChangeOfEC/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/CorbaObjectManager.java
===================================================================
--- branches/work/DesignChangeOfEC/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/CorbaObjectManager.java	2012-01-20 08:35:46 UTC (rev 650)
+++ branches/work/DesignChangeOfEC/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/CorbaObjectManager.java	2012-01-23 08:57:29 UTC (rev 651)
@@ -1,81 +0,0 @@
-package jp.go.aist.rtm.RTC;
-
-import jp.go.aist.rtm.RTC.executionContext.ExecutionContextBase;
-
-import org.omg.CORBA.ORB;
-import org.omg.PortableServer.POA;
-import org.omg.PortableServer.Servant;
-import org.omg.PortableServer.POAPackage.ObjectNotActive;
-import org.omg.PortableServer.POAPackage.ServantAlreadyActive;
-import org.omg.PortableServer.POAPackage.ServantNotActive;
-import org.omg.PortableServer.POAPackage.WrongPolicy;
-
-import RTC.ExecutionContextServiceHelper;
-import RTC.RTObjectHelper;
-
-
-/**
- * <p>CorbaObjectManagerクラスです。
- * CORBA オブジェクトをアクティブ化、非アクティブ化します。</p>
- */
-class CorbaObjectManager {
-    /**
-     * <p>コンストラクタです。</p>
-     *
-     * @param orb ORB
-     * @param poa POA
-     */
-    public CorbaObjectManager(ORB orb, POA poa) {
-        m_pPOA = poa;
-    }
-
-    /**
-     * <p>CORBA オブジェクト(RTObjct)をアクティブ化します。</p>
-     *
-     * @param comp  アクティブ化対象RTObject
-     *
-     * @exception ServantAlreadyActive 対象Servantがすでにactivate済み
-     * @exception WrongPolicy POA でサポートされていないポリシーを使用
-     * @exception ObjectNotActive 指定された oid を持つオブジェクトが Active Object Map にない場合 
-     */
-    public void activate(RTObject_impl comp) 
-            throws ServantAlreadyActive, WrongPolicy, ObjectNotActive {
-        if( comp.m_objref==null ) {
-            byte[] id = m_pPOA.activate_object(comp);
-            comp.setObjRef(RTObjectHelper.narrow(m_pPOA.id_to_reference(id)));
-        }
-    }
-
-    /**
-     * <p>CORBA オブジェクト(ExecutionContext)をアクティブ化します。</p>
-     *
-     * @param comp  アクティブ化対象ExecutionContext
-     *
-     * @exception ServantAlreadyActive 対象Servantがすでにactivate済み
-     * @exception WrongPolicy POA でサポートされていないポリシーを使用
-     * @exception ObjectNotActive 指定された oid を持つオブジェクトが Active Object Map にない場合 
-     */
-    public void activate(ExecutionContextBase comp) throws ServantAlreadyActive, WrongPolicy, ObjectNotActive {
-        byte[] id = m_pPOA.activate_object(comp.getObjRef());
-        comp.setObjRef(ExecutionContextServiceHelper.narrow(m_pPOA.id_to_reference(id)));
-    }
-    /**
-     * <p>CORBA オブジェクトを非アクティブ化します。</p>
-     *
-     * @param comp  非アクティブ化対象オブジェクト
-     *
-     * @exception ServantAlreadyActive 対象Servantがactivate化されていない
-     * @exception WrongPolicy POA でサポートされていないポリシーを使用
-     * @exception ObjectNotActive 指定された oid を持つオブジェクトが Active Object Map にない場合
-     * 
-     */
-    public void deactivate(Servant comp) throws ServantNotActive, WrongPolicy, ObjectNotActive {
-        byte[] id = m_pPOA.servant_to_id(comp);
-        m_pPOA.deactivate_object(id);
-    }
-
-    /**
-     * POA
-     */
-    private POA m_pPOA;
-}

Modified: branches/work/DesignChangeOfEC/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/Manager.java
===================================================================
--- branches/work/DesignChangeOfEC/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/Manager.java	2012-01-20 08:35:46 UTC (rev 650)
+++ branches/work/DesignChangeOfEC/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/Manager.java	2012-01-23 08:57:29 UTC (rev 651)
@@ -2630,7 +2630,8 @@
         
         for (int i=0, len=m_ecs.size(); i < len; ++i) {
             try {
-                m_pPOA.deactivate_object(m_pPOA.servant_to_id(m_ecs.elementAt(i).getObjRef()));
+                //m_pPOA.deactivate_object(m_pPOA.servant_to_id(m_ecs.elementAt(i).getObjRef()));
+                m_pPOA.deactivate_object(m_pPOA.servant_to_id((RTC.ExecutionContextServicePOA)m_ecs.get(i)));
                 
             } catch (Exception e) {
                 rtcout.println(Logbuf.DEBUG, "Exception: Caught unknown Exception in Manager.shutdownComponents().");
@@ -3189,7 +3190,7 @@
      * {@.ja CORBA Object Manager}
      * {@.en CORBA Object Manager}
      */
-    protected CorbaObjectManager m_objManager;
+    //protected CorbaObjectManager m_objManager;
     /**
      * {@.ja Timer Object}
      * {@.en Timer Object}

Modified: branches/work/DesignChangeOfEC/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/RTObject_impl.java
===================================================================
--- branches/work/DesignChangeOfEC/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/RTObject_impl.java	2012-01-20 08:35:46 UTC (rev 650)
+++ branches/work/DesignChangeOfEC/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/RTObject_impl.java	2012-01-23 08:57:29 UTC (rev 651)
@@ -3918,7 +3918,8 @@
             try {
                 m_eclist.elementAt(i).getObjRef().stop();
 		m_eclist.elementAt(i).finalizeExecutionContext();
-                m_pPOA.deactivate_object(m_pPOA.servant_to_id(m_eclist.elementAt(i).getObjRef()));
+//                m_pPOA.deactivate_object(m_pPOA.servant_to_id(m_eclist.elementAt(i).getObjRef()));
+                m_pPOA.deactivate_object(m_pPOA.servant_to_id((RTC.ExecutionContextServicePOA)m_eclist.get(i)));
             }
             catch(Exception ex) {
             }

Modified: branches/work/DesignChangeOfEC/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/ExecutionContextBase.java
===================================================================
--- branches/work/DesignChangeOfEC/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/ExecutionContextBase.java	2012-01-20 08:35:46 UTC (rev 650)
+++ branches/work/DesignChangeOfEC/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/ExecutionContextBase.java	2012-01-23 08:57:29 UTC (rev 651)
@@ -5,7 +5,6 @@
 import RTC.ExecutionContextService;
 import OpenRTM.ExtTrigExecutionContextServicePOA;
 
-import jp.go.aist.rtm.RTC.ExecutionContextProfile;
 import jp.go.aist.rtm.RTC.RTObject_impl;
 import jp.go.aist.rtm.RTC.util.Properties;
 import RTC.ExecutionKind;
@@ -15,16 +14,19 @@
  * <p>Periodic Sampled Data Processing(周期実行用)ExecutionContextのベースとなる
  * 抽象クラスです。</p>
  */
-public abstract class ExecutionContextBase 
- implements ECNewDeleteFunc {
+//public abstract class ExecutionContextBase 
+// implements ECNewDeleteFunc {
+public interface ExecutionContextBase extends ECNewDeleteFunc {
 
     /**
      * {@.ja ExecutionContextクラスの初期化関数}
      * {@.en Initialization function of ExecutionContext class}
      */
+    public void init(Properties props);
+/* 
     public void init(Properties props) {
     }
-
+*/
     /**
      * {@.ja CORBA オブジェクト参照の取得}
      * {@.en Get the reference to the CORBA object}
@@ -39,9 +41,12 @@
      *   {@.en The reference to CORBA object}
      *
      */
+    public void setObjRef(final ExecutionContextService ref);
+/* 
     public void setObjRef(final ExecutionContextService ref) {
         m_profile.setObjRef(ref);
     }
+*/
     
     /**
      * <p> bindComponent </p>
@@ -50,7 +55,8 @@
      * @return ReturnCode_t
      * 
      */
-    public abstract ReturnCode_t bindComponent(RTObject_impl rtc);
+    public ReturnCode_t bindComponent(RTObject_impl rtc);
+//    public abstract ReturnCode_t bindComponent(RTObject_impl rtc);
 
     /**
      * {@.ja CORBA オブジェクト参照の取得}
@@ -66,10 +72,12 @@
      *   {@.en The reference to CORBA object}
      *
      */
+    public ExecutionContextService getObjRef();
+/* 
     public ExecutionContextService getObjRef() {
       return m_profile.getObjRef();
     }
-
+*/
     /**
      * {@.ja ExecutionContext の実行周期(Hz)を設定する}
      * {@.en Set execution rate(Hz) of ExecutionContext}
@@ -97,10 +105,12 @@
      *         BAD_PARAMETER: Invalid value. The value might be negative.}
      *
      */
+    public ReturnCode_t setRate(double rate);
+/*
     public ReturnCode_t setRate(double rate) {
       return m_profile.setRate(rate);
     }
-
+*/
     /**
      * {@.ja ExecutionContext の実行周期(Hz)を取得する}
      * {@.en Get execution rate(Hz) of ExecutionContext}
@@ -115,10 +125,12 @@
      *   {@.en Execution cycle(Unit:Hz)}
      *
      */
+    public double getRate();
+/*  
     public double getRate()  {
       return m_profile.getRate();
     }
-
+*/
     /**
      * {@.ja ExecutionKind を文字列化する}
      * {@.en Converting ExecutionKind enum to string}
@@ -136,11 +148,19 @@
      *   {@en String of ExecutionKind}
      *
      */
+    public String getKindString(ExecutionKind kind);
+/*
     public final String getKindString(ExecutionKind kind) {
       return m_profile.getKindString(kind);
     }
+*/
+    public boolean finalizeExecutionContext();
+//    public abstract boolean finalizeExecutionContext();
+    public ExecutionContextProfile m_profile 
+                                    = new ExecutionContextProfile();
+/*
+    protected ExecutionContextProfile m_profile 
+                                    = new ExecutionContextProfile();
+*/
 
-    public abstract boolean finalizeExecutionContext();
-    protected ExecutionContextProfile m_profile;
-
 }

Added: branches/work/DesignChangeOfEC/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/ExecutionContextProfile.java
===================================================================
--- branches/work/DesignChangeOfEC/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/ExecutionContextProfile.java	                        (rev 0)
+++ branches/work/DesignChangeOfEC/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/ExecutionContextProfile.java	2012-01-23 08:57:29 UTC (rev 651)
@@ -0,0 +1,570 @@
+package jp.go.aist.rtm.RTC.executionContext;
+
+import jp.go.aist.rtm.RTC.log.Logbuf;
+import jp.go.aist.rtm.RTC.util.CORBA_SeqUtil;
+import jp.go.aist.rtm.RTC.util.equalFunctor;
+import jp.go.aist.rtm.RTC.util.NVUtil;
+import jp.go.aist.rtm.RTC.util.Properties;
+import jp.go.aist.rtm.RTC.util.TimeValue;
+import RTC.ExecutionContextService;
+//import RTC.ExecutionContextProfile;
+import RTC.ExecutionKind;
+import RTC.ExecutionKindHolder;
+import RTC.LightweightRTObject;
+import RTC.ReturnCode_t;
+import RTC.RTCListHolder;
+import RTC.RTObject;
+import RTC.RTObjectHelper;
+import _SDOPackage.NVListHolder;
+  /**
+   * {@.ja ExecutionContextProfile クラス}
+   * {@.en ExecutionContextProfile class}
+   * <p>
+   * {@.ja Periodic Sampled Data Processing(周期実行用)ExecutionContextクラス。}
+   * {@.en Periodic Sampled Data Processing (for the execution cycles)
+   * ExecutionContext class}
+   */
+public class ExecutionContextProfile {
+    public final double DEEFAULT_PERIOD = 0.000001;
+
+    /**
+     * {@.ja デフォルトコンストラクタ}
+     * {@.en Default Constructor}
+     * <p>
+     * {@.ja デフォルトコンストラクタ
+     * プロファイルに以下の項目を設定する。
+     *  - kind : PERIODIC
+     *  - rate : 0.0}
+     * {@.en Default Constructor
+     * Set the following items to profile.
+     *  - kind : PERIODIC
+     *  - rate : 0.0}
+     */
+    public ExecutionContextProfile(ExecutionKind kind) {
+        rtcout = new Logbuf("periodic_ecprofile");
+        m_period = new TimeValue(DEEFAULT_PERIOD);
+        m_ref = null;
+        rtcout.println(Logbuf.TRACE, "ExecutionContextProfile()");
+        rtcout.println(Logbuf.DEBUG, "Actual rate: "
+                                    + m_period.sec()
+                                    + " [sec], "
+                                    + m_period.usec()
+                                    + " [usec]");
+        // profile initialization
+        m_profile.kind = kind;
+        m_profile.rate = 1.0 / m_period.toDouble();
+        m_profile.owner = null;
+        m_profile.participants = new RTObject[0];
+        m_profile.properties = new _SDOPackage.NameValue[0];
+    }
+    public ExecutionContextProfile(){
+        this(ExecutionKind.PERIODIC);
+    }
+    /**
+     * {@.ja CORBA オブジェクト参照の取得}
+     * {@.en Get the reference to the CORBA object}
+     * <p>
+     * {@.ja 本オブジェクトの ExecutioncontextService としての CORBA オブジェ
+     * クト参照を取得する。}
+     * {@.en Get the reference to the CORBA object as
+     * ExecutioncontextService of this object.}
+     *
+     * @return 
+     *   {@.ja CORBA オブジェクト参照}
+     *   {@.en The reference to CORBA object}
+     */
+    public void setObjRef(ExecutionContextService ec_ptr){
+        rtcout.println(Logbuf.TRACE, "setObjRef()");
+        synchronized (m_profile){
+            m_ref = (ExecutionContextService)ec_ptr._duplicate();
+        }
+    }
+
+    /**
+     * {@.ja CORBA オブジェクト参照の取得}
+     * {@.en Get the reference to the CORBA object}
+     * <p>
+     * {@.ja 本オブジェクトの ExecutioncontextService としての CORBA オブジェ
+     * クト参照を取得する。}
+     * {@.en Get the reference to the CORBA object as
+     * ExecutioncontextService of this object.}
+     *
+     * @return 
+     *   {@.ja CORBA オブジェクト参照}
+     *   {@.en The reference to CORBA object}
+     *
+     */
+    public ExecutionContextService getObjRef(){
+        rtcout.println(Logbuf.TRACE, "getObjRef()");
+        synchronized (m_profile){
+            return (ExecutionContextService)m_ref._duplicate();
+        }
+    }
+
+    /**
+     * {@.ja ExecutionContext の実行周期(Hz)を設定する}
+     * {@.en Set execution rate(Hz) of ExecutionContext}
+     * <p>
+     * {@.ja Active 状態にてRTコンポーネントが実行される周期(単位:Hz)を設定す
+     * る。実行周期の変更は、DataFlowComponentAction の
+     * on_rate_changed によって各RTコンポーネントに伝達される。}
+     * {@.en This operation shall set the rate (in hertz) at which this
+     * context’s Active participating RTCs are being called.  If the
+     * execution kind of the context is PERIODIC, a rate change shall
+     * result in the invocation of on_rate_changed on any RTCs
+     * realizing DataFlowComponentAction that are registered with any
+     * RTCs participating in the context.}
+     *
+     * @param rate 
+     *   {@.ja 処理周期(単位:Hz)}
+     *   {@.en Execution cycle(Unit:Hz)}
+     *
+     * @return 
+     *   {@.ja ReturnCode_t 型のリターンコード
+     *         RTC_OK: 正常終了
+     *         BAD_PARAMETER: 設定値が負の値}
+     *   {@.en The return code of ReturnCode_t type
+     *         RTC_OK: Succeed
+     *         BAD_PARAMETER: Invalid value. The value might be negative.}
+     *
+     */
+    public ReturnCode_t setRate(double rate) {
+        rtcout.println(Logbuf.TRACE, "set_rate("+rate+")");
+        if (rate < 0.0) { 
+            return ReturnCode_t.BAD_PARAMETER; 
+        }
+
+        synchronized (m_profile){
+            m_profile.rate = rate;
+            m_period = new TimeValue(1.0/rate);
+            return ReturnCode_t.RTC_OK;
+        }
+    }
+    public ReturnCode_t setPeriod(double period) {
+        rtcout.println(Logbuf.TRACE, "setPeriod("+period+" [sec])");
+        if (period < 0.0) { 
+            return ReturnCode_t.BAD_PARAMETER; 
+        }
+
+        synchronized (m_profile){
+            m_profile.rate = 1.0 / period;
+            m_period = new TimeValue(period);
+            return ReturnCode_t.RTC_OK;
+        }
+    }
+    public ReturnCode_t setPeriod(TimeValue period) {
+        rtcout.println(Logbuf.TRACE, "setPeriod("+period.toDouble()+" [sec])");
+        if (period.toDouble() < 0.0) { 
+            return ReturnCode_t.BAD_PARAMETER; 
+        }
+
+        synchronized (m_profile){
+            m_profile.rate = 1.0 / period.toDouble();
+            m_period = period;
+            return ReturnCode_t.RTC_OK;
+        }
+    }
+
+    /**
+     * {@.ja ExecutionContext の実行周期(Hz)を取得する}
+     * {@.en Get execution rate(Hz) of ExecutionContext}
+     * <p>
+     * {@.ja Active 状態にてRTコンポーネントが実行される周期(単位:Hz)を取得す
+     * る。}
+     * {@.en This operation shall return the rate (in hertz) at which its
+     * Active participating RTCs are being invoked.}
+     *
+     * @return 
+     *   {@.ja 処理周期(単位:Hz)}
+     *   {@.en Execution cycle(Unit:Hz)}
+     *
+     */
+    public double getRate() {
+        rtcout.println(Logbuf.TRACE, "get_rate()");
+        synchronized (m_profile){
+            return m_profile.rate;
+        }
+    }
+    public TimeValue getPeriod(){
+        rtcout.println(Logbuf.TRACE, "getPeriod()");
+        synchronized (m_profile){
+            return m_period;
+        }
+    }
+
+    /**
+     * {@.ja ExecutionKind を文字列化する}
+     * {@.en Converting ExecutionKind enum to string }
+     * <p>
+     * {@.ja ExecutionKind で定義されている PERIODIC, EVENT_DRIVEN,
+     * OTHER を文字列化する。}
+     * {@.en This function converts enumeration (PERIODIC, EVENT_DRIVEN,
+     * OTHER) defined in RTC::ExecutionKind to string.}
+     *
+     * @param kind 
+     *   {@.ja ExecutionKind}
+     *   {@.en ExecutionKind}
+     * @return 
+     *   {@.en 文字列化されたExecutionKind}
+     *   {@.en String of ExecutionKind}
+     *
+     */
+    public final String getKindString(ExecutionKind kind){
+        ExecutionKindHolder ekh = new ExecutionKindHolder(kind);
+        try {
+            return ekh._type().name();
+        }
+        catch(Exception ex) {
+            return "";
+        }
+    }
+    public final String getKindString() {
+      return getKindString(m_profile.kind);
+    }
+
+    /**
+     * {@.ja ExecutionKind を設定する}
+     * {@.en Set the ExecutionKind}
+     * <p>
+     * {@.ja この ExecutionContext の ExecutionKind を設定する}
+     * {@.en This operation sets the kind of the execution context.}
+     *
+     * @param kind 
+     *   {@.ja ExecutionKind}
+     *   {@.en ExecutionKind}
+     *
+     */
+    public ReturnCode_t setKind(ExecutionKind kind) {
+        rtcout.println(Logbuf.TRACE, "setKind("+getKindString(kind)+")");
+        synchronized (m_profile){
+            m_profile.kind = kind;
+            return ReturnCode_t.RTC_OK;
+        }
+    }
+
+    /**
+     * {@.ja ExecutionKind を取得する}
+     * {@.en Get the ExecutionKind}
+     * <p>
+     * {@.ja 本 ExecutionContext の ExecutionKind を取得する}
+     * {@.en This operation shall report the execution kind of the execution
+     * context.}
+     *
+     * @return 
+     *   {@.ja ExecutionKind}
+     *   {@.en ExecutionKind}
+     */
+    public ExecutionKind getKind() {
+        rtcout.println(Logbuf.TRACE, getKindString(m_profile.kind)
+                                        + " = getKind()");
+        return m_profile.kind;
+    }
+
+    /**
+     * {@.ja Ownerコンポーネントをセットする。}
+     * {@.en Setting owner component of the execution context}
+     * <p>
+     * {@.ja このECのOwnerとなるRTCをセットする。}
+     * {@.en This function sets an RT-Component to be owner of the 
+     * execution context.}
+     *
+     * @param comp 
+     *   {@.ja OwnerとなるRTコンポーネント}
+     *   {@.en an owner RT-Component of this execution context}
+     * @return 
+     *   {@.ja ReturnCode_t 型のリターンコード}
+     *   {@.en The return code of ReturnCode_t type}
+     */
+    public ReturnCode_t setOwner(LightweightRTObject comp) {
+        rtcout.println(Logbuf.TRACE, "setOwner()");
+        if (comp==null) {
+            rtcout.println(Logbuf.ERROR,"nil reference is given.");
+            return ReturnCode_t.BAD_PARAMETER;
+        }
+        RTObject rtobj;
+        rtobj = RTObjectHelper.narrow(comp);
+        if (rtobj==null) {
+            rtcout.println(Logbuf.ERROR,"Narrowing failed.");
+            return ReturnCode_t.RTC_ERROR;
+          }
+        m_profile.owner = (RTObject)m_profile.owner._duplicate();
+        return ReturnCode_t.RTC_OK;
+    }
+
+    /**
+     * {@.ja Ownerコンポーネントの参照を取得する}
+     * {@.en Getting a reference of the owner component}
+     * <p>
+     * {@.ja このECのOwnerであるRTCの参照を取得する。}
+     * {@.en This function returns a reference of the owner RT-Component of
+     * this execution context}
+     *
+     * @return 
+     *   {@.ja OwnerRTコンポーネントの参照}
+     *   {@.en a reference of the owner RT-Component}
+     */
+    public final RTObject getOwner() {
+        rtcout.println(Logbuf.TRACE, "getOwner()");
+        return (RTObject)m_profile.owner._duplicate();
+    }
+
+    /**
+     * {@.ja RTコンポーネントを追加する}
+     * {@.en Add an RT-component}
+     * <p>
+     * {@.ja 指定したRTコンポーネントを参加者リストに追加する。追加されたRTコ
+     * ンポーネントは attach_context が呼ばれ、Inactive 状態に遷移する。
+     * 指定されたRTコンポーネントがnullの場合は、BAD_PARAMETER が返され
+     * る。指定されたRTコンポーネントが DataFlowComponent 以外の場合は、
+     * BAD_PARAMETER が返される。}
+     * {@.en The operation causes the given RTC to begin participating in
+     * the execution context.  The newly added RTC will receive a call
+     * to LightweightRTComponent::attach_context and then enter the
+     * Inactive state.  BAD_PARAMETER will be invoked, if the given
+     * RT-Component is null or if the given RT-Component is other than
+     * DataFlowComponent.}
+     *
+     * @param comp 
+     *   {@.ja 追加対象RTコンポーネント}
+     *   {@.en The target RT-Component for add}
+     *
+     * @return 
+     *   {@.ja ReturnCode_t 型のリターンコード}
+     *   {@.en The return code of ReturnCode_t type}
+     */
+    public ReturnCode_t addComponent(LightweightRTObject comp) {
+        rtcout.println(Logbuf.TRACE,"addComponent()");
+        if (comp==null) {
+            rtcout.println(Logbuf.ERROR,"A nil reference was given.");
+            return ReturnCode_t.BAD_PARAMETER;
+        }
+        RTObject rtobj = RTObjectHelper.narrow(comp);
+        if (rtobj==null) {
+            rtcout.println(Logbuf.ERROR,"Narrowing was failed.");
+            return ReturnCode_t.RTC_ERROR;
+        }
+        RTCListHolder holder = new RTCListHolder(m_profile.participants);
+        CORBA_SeqUtil.push_back(holder, rtobj);
+        m_profile.participants = holder.value;
+        return ReturnCode_t.RTC_OK;
+    }
+
+    /**
+     * {@.ja RTコンポーネントを参加者リストから削除する}
+     * {@.en Remove the RT-Component from participant list}
+     * <p>
+     * {@.ja 指定したRTコンポーネントを参加者リストから削除する。削除された
+     * RTコンポーネントは detach_context が呼ばれる。指定されたRTコンポー
+     * ネントが参加者リストに登録されていない場合は、BAD_PARAMETER が返
+     * される。}
+     * {@.en This operation causes a participant RTC to stop participating 
+     * in the execution context.
+     * The removed RTC will receive a call to
+     * LightweightRTComponent::detach_context.
+     * BAD_PARAMETER will be returned, if the given RT-Component is not
+     * participating in the participant list.}
+     *
+     * @param comp 
+     *   {@.ja 削除対象RTコンポーネント}
+     *   {@.en The target RT-Component for delete}
+     *
+     * @return 
+     *   {@.ja ReturnCode_t 型のリターンコード}
+     *   {@.en The return code of ReturnCode_t type}
+     *
+     */
+    public ReturnCode_t removeComponent(LightweightRTObject comp) {
+        rtcout.println(Logbuf.TRACE,"removeComponent()");
+        if (comp==null) {
+            rtcout.println(Logbuf.ERROR,"A nil reference was given.");
+            return ReturnCode_t.BAD_PARAMETER;
+        }
+        RTObject rtobj = RTObjectHelper.narrow(comp);
+        if (rtobj==null) {
+            rtcout.println(Logbuf.ERROR,"Narrowing was failed.");
+            return ReturnCode_t.RTC_ERROR;
+        }
+        synchronized (m_profile) {
+            RTCListHolder holder = new RTCListHolder(m_profile.participants); 
+            int index;
+            index = CORBA_SeqUtil.find(holder,
+                                  new find_participant(rtobj));
+            if (index < 0) {
+                rtcout.println(Logbuf.ERROR,
+                            "The given RTObject does not exist in the EC.");
+                return ReturnCode_t.BAD_PARAMETER;
+            }
+            CORBA_SeqUtil.erase(holder, index);
+            m_profile.participants = holder.value;
+        }
+        return ReturnCode_t.RTC_OK;
+    }
+
+    /**
+     * {@.ja RTコンポーネントの参加者リストを取得する}
+     * {@.en Getting participant RTC list}
+     * <p>
+     * {@.ja 現在登録されている参加者RTCのリストを取得する。}
+     * {@.en This function returns a list of participant RTC of the 
+     * execution context.}
+     *
+     * @return 
+     *   {@.ja 参加者RTCのリスト}
+     *   {@.en Participants RTC list}
+     *
+     */
+    public final RTObject[] getComponentList() {
+        rtcout.println(Logbuf.TRACE,"getComponentList("
+                                    + m_profile.participants.length
+                                    +")");
+        return m_profile.participants;
+    }
+
+    /**
+     * {@.ja Propertiesをセットする}
+     * {@.en Setting Properties}
+     * <p>
+     * {@.ja ExecutionContextProfile::properties をセットする。}
+     * {@.en This function sets ExecutionContextProfile::properties by
+     * Properties.}
+     *
+     * @param props 
+     *   {@.ja ExecutionContextProfile::properties にセットするプロパティー}
+     *   {@.en Properties to be set to ExecutionContextProfile::properties.}
+     */
+    public void setProperties(Properties props) {
+        rtcout.println(Logbuf.TRACE,"setProperties()");
+        String str = new String();
+        str = props._dump(str,props,0);
+        rtcout.println(Logbuf.TRACE,str);
+        synchronized (m_profile) {
+            NVListHolder holder = new NVListHolder(m_profile.properties);
+            NVUtil.copyFromProperties(holder, props);
+            m_profile.properties = holder.value;
+        }
+    }
+
+    /**
+     * {@.ja Propertiesを取得する}
+     * {@.en Setting Properties}
+     * <p>
+     * {@.ja ExecutionContextProfile::properties を取得する。}
+     *
+     * @return
+     *   {@.ja Propertiesに変換されたExecutionContextProfile::properties}
+     *   {@.en This function sets ExecutionContextProfile::properties by
+     * Properties.}
+     *
+     */
+    public final Properties getProperties() {
+        rtcout.println(Logbuf.TRACE,"getProperties()");
+        Properties props  = new Properties(); 
+        synchronized (m_profile) {
+            NVListHolder holder = new NVListHolder(m_profile.properties);
+            NVUtil.copyToProperties(props, holder);
+            String str = new String();
+            str = props._dump(str,props,0);
+            rtcout.println(Logbuf.TRACE,str);
+        }
+        return props;
+    }
+
+    /**
+     * {@.ja Profileを取得する}
+     * {@.en Getting Profile}
+     * <p>
+     * {@.ja RTC::ExecutionContextProfile を取得する。取得した
+     * ExecutionContextProfile の所有権は呼び出し側にある。取得されたオ
+     * ブジェクトが不要になった場合、呼び出し側が開放する責任を負う。}
+     * {@.en This function gets RTC::ExecutionContextProfile.  The ownership
+     * of the obtained ExecutionContextProfile is given to caller. The
+     * caller should release obtained object when it is unneccessary
+     * anymore.}
+     *
+     * @return 
+     *   {@.ja RTC::ExecutionContextProfile}
+     *   {@.en RTC::ExecutionContextProfile}
+     *
+     */
+    public RTC.ExecutionContextProfile getProfile() {
+        rtcout.println(Logbuf.TRACE,"getProfile()");
+        RTC.ExecutionContextProfile p;
+        synchronized (m_profile){
+            p = new RTC.ExecutionContextProfile(m_profile.kind,
+                                                m_profile.rate,
+                                                m_profile.owner,
+                                                m_profile.participants,
+                                                m_profile.properties);
+        }
+        return p;
+    
+    }
+
+
+    /**
+     * {@.ja ExecutionContextProfileをロックする}
+     * {@.en Getting a lock of RTC::ExecutionContextProfile}
+     * <p>
+     * {@.ja このオブジェクトが管理する RTC::ExecutionContextProfile をロックする。
+     * ロックが不要になった際にはunlock()でロックを解除しなければならない。}
+     * {@.en This function locks  RTC::ExecutionContextProfile in the object.
+     * The lock should be released when the lock is unneccessary.}
+     *
+     */
+    public void lock() {
+        //m_profileMutex.lock();
+    } 
+
+    /**
+     * {@.ja ExecutionContextProfileをアンロックする}
+     * {@.en Release a lock of the RTC::ExecutionContextProfile}
+     * <p>
+     * {@.ja このオブジェクトが管理する RTC::ExecutionContextProfile をアンロッ
+     * クする。}
+     * {@.en This function release the lock of RTC::ExecutionContextProfile
+     * in the object.}
+     *
+     */
+    public void unlock() {
+        //m_profileMutex.unlock();
+    }
+
+    /**
+     * {@.ja Logger}
+     * {@.en Logger}
+     */
+    private Logbuf rtcout;
+    /**
+     * {@.ja ECProfile}
+     * {@.en ECProfile}
+     */
+    private RTC.ExecutionContextProfile m_profile;
+
+    /**
+     * {@.ja mutex of ExecutionContextProfile}
+     * {@.en mutex ExecutionContextProfile}
+     */
+    //private String m_profileMutex = new String();
+
+    /**
+     * {@.ja ExecutionContext の実行周期}
+     * {@.en Execution cycle of ExecutionContext}
+     */
+    private TimeValue m_period;
+
+    /**
+     * {@.ja ExecutionContextService オブジェクトへの参照}
+     * {@.en Reference to ExecutionContextService object}
+     */
+    private ExecutionContextService m_ref;
+
+    private class find_participant  implements equalFunctor {
+        private RTObject m_comp;
+        public find_participant(RTObject comp) {
+            m_comp = (RTObject)comp._duplicate();
+        }
+        public boolean equalof(final java.lang.Object comp) {
+            return m_comp._is_equivalent((RTObject)comp);
+        }
+    };
+}; // class ExecutionContextProfile

Modified: branches/work/DesignChangeOfEC/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/PeriodicExecutionContext.java
===================================================================
--- branches/work/DesignChangeOfEC/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/PeriodicExecutionContext.java	2012-01-20 08:35:46 UTC (rev 650)
+++ branches/work/DesignChangeOfEC/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/PeriodicExecutionContext.java	2012-01-23 08:57:29 UTC (rev 651)
@@ -11,6 +11,8 @@
 import jp.go.aist.rtm.RTC.util.CORBA_SeqUtil;
 import jp.go.aist.rtm.RTC.util.NVUtil;
 import jp.go.aist.rtm.RTC.util.POAUtil;
+import jp.go.aist.rtm.RTC.util.Properties;
+import jp.go.aist.rtm.RTC.util.TimeValue;
 import jp.go.aist.rtm.RTC.util.equalFunctor;
 import OpenRTM.DataFlowComponent;
 import OpenRTM.DataFlowComponentHelper;
@@ -18,6 +20,7 @@
 import RTC.ExecutionContextProfileHolder;
 import RTC.ExecutionContextService;
 import RTC.ExecutionContextServiceHelper;
+import RTC.ExecutionContextServicePOA;
 import RTC.ExecutionKind;
 import RTC.LifeCycleState;
 import RTC.LightweightRTObject;
@@ -28,8 +31,10 @@
  * <p>Periodic Sampled Data Processing(周期実行用)ExecutionContextクラスです。</p>
  */
 
-public class PeriodicExecutionContext extends ExecutionContextBase implements Runnable ,  {
+//public class PeriodicExecutionContext extends  ExtTrigExecutionContextServicePOA implements Runnable, ExecutionContextBase {
+public class PeriodicExecutionContext extends  ExecutionContextServicePOA implements Runnable, ExecutionContextBase {
 
+
     /**
      * {@.ja デフォルトコンストラクタ}
      * {@.en Default Constructor}
@@ -58,11 +63,18 @@
         m_ref = (ExecutionContextService)this.__this();
 
 
+        m_profile.setPeriod(new TimeValue(1.0 / rate));
+        m_profile.setKind(ExecutionKind.PERIODIC);
+        //m_profile.setRate(1.0 / ExecutionContextProfile.DEEFAULT_PERIOD);
+        m_profile.setRate(1.0 / m_profile.DEEFAULT_PERIOD);
+
+/*
         m_profile.kind = ExecutionKind.PERIODIC;
         m_profile.rate = 0.0;
         m_profile.owner = (RTC.RTObject)null;
         m_profile.participants = new RTC.RTObject[0];
         m_profile.properties = new _SDOPackage.NameValue[0];
+*/
     }
 
     /**
@@ -107,19 +119,29 @@
         m_svc = true;
         m_nowait = true;
 
-        if( rate==0 ) rate = (1.0/0.000001);//1000000Hz
-
+        if( rate==0 ) {
+            rate = (1.0/0.000001);//1000000Hz
+        }
         m_usec = (long)(1000000/rate);
-        if( m_usec==0 ) m_nowait = true;
+        if( m_usec==0 ) {
+            m_nowait = true;
+        }
 
         m_ref = (ExecutionContextService)this.__this();
 
 
+        m_profile.setPeriod(new TimeValue(1.0 / rate));
+        m_profile.setKind(ExecutionKind.PERIODIC);
+        //m_profile.setRate(1.0 / ExecutionContextProfile.DEEFAULT_PERIOD);
+        m_profile.setRate(1.0 / m_profile.DEEFAULT_PERIOD);
+        m_profile.setOwner((LightweightRTObject)owner._duplicate());
+/*
         m_profile.kind = ExecutionKind.PERIODIC;
         m_profile.rate = rate;
         m_profile.owner = owner;
         m_profile.participants = new RTC.RTObject[0];
         m_profile.properties = new _SDOPackage.NameValue[0];
+*/
     }
 
     /**
@@ -177,12 +199,14 @@
      * 
      * @return ExecutionContextService
      */
+/*
     public ExecutionContextService getObjRef() {
 
         rtcout.println(Logbuf.TRACE, "PeriodicExecutionContext.getObjRef()");
 
         return m_ref;
     }
+*/
     /**
      * <p>本オブジェクトのExecutionContextServiceとしてのCORBAオブジェクト参照を設定します。</p>
      * 
@@ -344,9 +368,12 @@
 
         rtcout.println(Logbuf.TRACE, "PeriodicExecutionContext.get_rate()");
 
+        return m_profile.getRate();
+/*
         synchronized (m_profile) {
             return m_profile.rate;
         }
+*/
     }
 
     /**
@@ -360,11 +387,16 @@
 
         if( rate<=0.0 ) return ReturnCode_t.BAD_PARAMETER;
 
+        m_profile.setRate(rate);
+/*
         synchronized (m_profile) {
             m_profile.rate = rate;
         }
+*/
         this.m_usec = (long)(1000000/rate);
-        if( m_usec == 0 ) m_nowait = true;
+        if( m_usec == 0 ) {
+            m_nowait = true;
+        }
         for(int intIdx=0;intIdx<m_comps.size();intIdx++ ) {
             m_comps.elementAt(intIdx).invoke_on_rate_changed();
         }
@@ -476,7 +508,8 @@
 
         rtcout.println(Logbuf.TRACE, "PeriodicExecutionContext.get_kind()");
 
-        return m_profile.kind;
+        return m_profile.getKind();
+        //return m_profile.kind;
     }
 
     /**
@@ -525,11 +558,14 @@
             //
             m_comps.add(new Comp((LightweightRTObject)comp._duplicate(), 
                                 (DataFlowComponent)dfp._duplicate(), id));
+            m_profile.addComponent((LightweightRTObject)comp._duplicate());
+/*
             RTC.RTCListHolder holder
                         = new RTC.RTCListHolder(m_profile.participants);
             CORBA_SeqUtil.push_back(holder, 
                         RTC.RTObjectHelper.narrow(comp));
             m_profile.participants = holder.value;
+*/
             return ReturnCode_t.RTC_OK;
         } catch(Exception ex) {
             return ReturnCode_t.BAD_PARAMETER;
@@ -572,7 +608,8 @@
         m_comps.add(new Comp((LightweightRTObject)comp._duplicate(),
                              (DataFlowComponent)dfp._duplicate(),
                              id));
-        m_profile.owner = (DataFlowComponent)dfp._duplicate();
+        m_profile.setOwner((LightweightRTObject)dfp._duplicate());
+        //m_profile.owner = (DataFlowComponent)dfp._duplicate();
 
 
         return ReturnCode_t.RTC_OK;
@@ -616,7 +653,10 @@
                                         m_comps.elementAt(intIdx)._sm.ec_id);
                 m_comps.elementAt(intIdx)._ref = null;
                 m_comps.remove(m_comps.elementAt(intIdx));
-                rtcout.println(Logbuf.TRACE, "remove_component(): an RTC removed from this context.");
+                rtcout.println(Logbuf.TRACE, 
+                    "remove_component(): an RTC removed from this context.");
+                m_profile.removeComponent(comp);
+/*
                 RTC.RTObject rtcomp = RTC.RTObjectHelper.narrow(comp);
                 if(rtcomp == null){
                     rtcout.println(Logbuf.ERROR,"Invalid object reference."); 
@@ -636,6 +676,7 @@
                     CORBA_SeqUtil.erase(holder, (int)index);
                     m_profile.participants = holder.value;
                 }
+*/
                 return ReturnCode_t.RTC_OK;
             }
         }
@@ -651,15 +692,17 @@
      * 
      * @return ExecutionContextProfile
      */
-    public ExecutionContextProfile get_profile() {
+    public RTC.ExecutionContextProfile get_profile() {
 
         rtcout.println(Logbuf.TRACE, "PeriodicExecutionContext.get_profile()");
-
+        return m_profile.getProfile();
+/*
         ExecutionContextProfileHolder p;
         synchronized (m_profile) {
             p = new ExecutionContextProfileHolder(m_profile);
         }
         return p.value;
+*/
     }
 
     /**
@@ -1024,7 +1067,7 @@
     /**
      * <p>ExecutionContextProfileです。</p>
      */
-    protected ExecutionContextProfile m_profile = new ExecutionContextProfile();
+    //protected ExecutionContextProfile m_profile = new ExecutionContextProfile();
     /**
      * <p>ExecutionContextの動作周期です。</p>
      */
@@ -1077,4 +1120,115 @@
             return m_obj._is_equivalent((RTC.RTObject)object);
         }
     }
+
+    /**
+     * {@.ja ExecutionContextクラスの初期化関数}
+     * {@.en Initialization function of ExecutionContext class}
+     */
+    public void init(Properties props) {
+    }
+
+    /**
+     * {@.ja CORBA オブジェクト参照の取得}
+     * {@.en Get the reference to the CORBA object}
+     * <p>
+     * {@.ja 本オブジェクトの ExecutioncontextService としての CORBA オブジェ
+     * クト参照を取得する。}
+     * {@.en Get the reference to the CORBA object as
+     * ExecutioncontextService of this object.}
+     *
+     * @return 
+     *   {@.ja CORBA オブジェクト参照}
+     *   {@.en The reference to CORBA object}
+     *
+     */
+/*
+    public void setObjRef(final ExecutionContextService ref) {
+        m_profile.setObjRef(ref);
+    }
+*/
+    /**
+     * {@.ja CORBA オブジェクト参照の取得}
+     * {@.en Get the reference to the CORBA object}
+     * <p>
+     * {@.ja 本オブジェクトの ExecutioncontextService としての CORBA オブジェ
+     * クト参照を取得する。}
+     * {@.en Get the reference to the CORBA object as
+     * ExecutioncontextService of this object.}
+     *
+     * @return 
+     *   {@.ja CORBA オブジェクト参照}
+     *   {@.en The reference to CORBA object}
+     *
+     */
+    public ExecutionContextService getObjRef() {
+      return m_profile.getObjRef();
+    }
+    /**
+     * {@.ja ExecutionContext の実行周期(Hz)を設定する}
+     * {@.en Set execution rate(Hz) of ExecutionContext}
+     * <p>
+     * {@.ja Active 状態にてRTコンポーネントが実行される周期(単位:Hz)を設定す
+     * る。実行周期の変更は、DataFlowComponentAction の
+     * on_rate_changed によって各RTコンポーネントに伝達される。}
+     * {@.en This operation shall set the rate (in hertz) at which this
+     * context’s Active participating RTCs are being called.  If the
+     * execution kind of the context is PERIODIC, a rate change shall
+     * result in the invocation of on_rate_changed on any RTCs
+     * realizing DataFlowComponentAction that are registered with any
+     * RTCs participating in the context.}
+     *
+     * @param rate
+     *   {@.ja 処理周期(単位:Hz)}
+     *   {@.en Execution cycle(Unit:Hz)}
+     *
+     * @return 
+     *   {@.ja ReturnCode_t 型のリターンコード
+     *         RTC_OK: 正常終了
+     *         BAD_PARAMETER: 設定値が負の値}
+     *   {@.en The return code of ReturnCode_t type
+     *         RTC_OK: Succeed
+     *         BAD_PARAMETER: Invalid value. The value might be negative.}
+     *
+     */
+    public ReturnCode_t setRate(double rate) {
+      return m_profile.setRate(rate);
+    }
+    /**
+     * {@.ja ExecutionContext の実行周期(Hz)を取得する}
+     * {@.en Get execution rate(Hz) of ExecutionContext}
+     * <p>
+     * {@.ja Active 状態にてRTコンポーネントが実行される周期(単位:Hz)を取得す
+     * る。}
+     * {@.en This operation shall return the rate (in hertz) at which its
+     * Active participating RTCs are being invoked.}
+     *
+     * @return 
+     *   {@.ja 処理周期(単位:Hz)}
+     *   {@.en Execution cycle(Unit:Hz)}
+     *
+     */
+    public double getRate()  {
+      return m_profile.getRate();
+    }
+    /**
+     * {@.ja ExecutionKind を文字列化する}
+     * {@.en Converting ExecutionKind enum to string}
+     * <p>
+     * {@.ja RTC::ExecutionKind で定義されている PERIODIC, EVENT_DRIVEN,
+     * OTHER を文字列化する。}
+     * {@.en This function converts enumeration (PERIODIC, EVENT_DRIVEN,
+     * OTHER) defined in RTC::ExecutionKind to string.}
+     *
+     * @param kind 
+     *   {@.ja ExecutionKind}
+     *   {@.en ExecutionKind}
+     * @return 
+     *   {@.ja 文字列化されたExecutionKind}
+     *   {@en String of ExecutionKind}
+     *
+     */
+    public final String getKindString(ExecutionKind kind) {
+      return m_profile.getKindString(kind);
+    }
 }



openrtm-commit メーリングリストの案内