[openrtm-commit:00613] r653 - in branches/work/DesignChangeOfEC/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC: . executionContext
openrtm @ openrtm.org
openrtm @ openrtm.org
2012年 1月 25日 (水) 17:53:20 JST
Author: fsi-katami
Date: 2012-01-25 17:53:20 +0900 (Wed, 25 Jan 2012)
New Revision: 653
Added:
branches/work/DesignChangeOfEC/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/ExecutionContextFactory.java
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/StateMachine.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/ExecutionContextProfile.java
branches/work/DesignChangeOfEC/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/OpenHRPExecutionContext.java
branches/work/DesignChangeOfEC/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/PeriodicExecutionContext.java
Log:
Daily check in. refs #2322
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-25 08:34:34 UTC (rev 652)
+++ branches/work/DesignChangeOfEC/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/RTObject_impl.java 2012-01-25 08:53:20 UTC (rev 653)
@@ -1,10 +1,12 @@
package jp.go.aist.rtm.RTC;
import java.util.Vector;
+import java.util.Set;
import java.lang.reflect.Method;
import jp.go.aist.rtm.RTC.SDOPackage.Configuration_impl;
import jp.go.aist.rtm.RTC.executionContext.ExecutionContextBase;
+import jp.go.aist.rtm.RTC.executionContext.ExecutionContextFactory;
import jp.go.aist.rtm.RTC.port.CorbaPort;
import jp.go.aist.rtm.RTC.port.InPort;
import jp.go.aist.rtm.RTC.port.InPortBase;
@@ -657,22 +659,53 @@
String ec_args = new String();
+ String ec_type = m_properties.getProperty("exec_cxt.periodic.type");
ec_args += m_properties.getProperty("exec_cxt.periodic.type");
ec_args += "?";
ec_args += "rate=" + m_properties.getProperty("exec_cxt.periodic.rate");
+ ExecutionContextFactory<ExecutionContextBase,String> factory
+ = ExecutionContextFactory.instance();
ExecutionContextBase ec;
+ ec = factory.createObject(ec_type);
+ if (ec == null) {
+ rtcout.println(Logbuf.ERROR,"EC ("
+ + ec_type
+ + ") creation failed.");
+ Set ecs = ExecutionContextFactory.instance().getIdentifiers();
+ rtcout.println(Logbuf.DEBUG,"Available EC list: "
+ + ecs.toString() );
+ return ReturnCode_t.RTC_ERROR;
+/*
+ coil::vstring ecs;
+ ecs = RTC::ExecutionContextFactory::instance().getIdentifiers();
+ RTC_DEBUG(("Available EC list: %s",
+ coil::flatten(ecs).c_str()));
+ return RTC::RTC_ERROR;
+*/
+ }
+ rtcout.println(Logbuf.DEBUG,"EC (" + ec_type + ") created.");
+// RTC_DEBUG(("EC (%s) created.", ec_type.c_str()));
+/*
ec = Manager.instance().createContext(ec_args);
if (ec == null) {
return ReturnCode_t.RTC_ERROR;
}
- ec.getObjRef().set_rate(Double.valueOf(m_properties.getProperty("exec_cxt.periodic.rate")).doubleValue());
+*/
+ //ec.getObjRef().set_rate(Double.valueOf(m_properties.getProperty("exec_cxt.periodic.rate")).doubleValue());
m_eclist.add(ec);
ExecutionContextService ecv;
ecv = ec.getObjRef();
if (ecv == null) {
+ rtcout.println(Logbuf.ERROR,
+ "Getting object reference of ec failed.");
return ReturnCode_t.RTC_ERROR;
}
+ double ec_rate = Double.valueOf(m_properties.getProperty("exec_cxt.periodic.rate")).doubleValue();
+ ecv.set_rate(ec_rate);
+ rtcout.println(Logbuf.DEBUG,"Execution context rate is set to "
+ + ec_rate + ".");
+
ec.bindComponent(this);
ReturnCode_t ret;
@@ -685,6 +718,7 @@
// -- entering alive state --
// at least one EC must be attached
if (m_ecMine.value.length == 0) {
+ rtcout.println(Logbuf.ERROR, "No EC of this RTC.");
return ReturnCode_t.PRECONDITION_NOT_MET;
}
for(int intIdx=0; intIdx < m_ecMine.value.length; ++intIdx) {
@@ -3915,11 +3949,16 @@
rtcout.println(Logbuf.TRACE, "RTObject_impl.finalizeContexts()");
for(int i=0, len=m_eclist.size(); i < len; ++i) {
+ m_eclist.get(i).getObjRef().stop();
try {
- m_eclist.elementAt(i).getObjRef().stop();
- m_eclist.elementAt(i).finalizeExecutionContext();
+ RTC.ExecutionContextServicePOA servant;
+ servant = (RTC.ExecutionContextServicePOA)m_eclist.get(i);
+// 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((RTC.ExecutionContextServicePOA)m_eclist.get(i)));
+ rtcout.println(Logbuf.DEBUG, "Deactivating Execution Context.");
+ m_pPOA.deactivate_object(m_pPOA.servant_to_id(servant));
+ rtcout.println(Logbuf.DEBUG, "Deactivating EC done.");
}
catch(Exception ex) {
}
Modified: branches/work/DesignChangeOfEC/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/StateMachine.java
===================================================================
--- branches/work/DesignChangeOfEC/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/StateMachine.java 2012-01-25 08:34:34 UTC (rev 652)
+++ branches/work/DesignChangeOfEC/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/StateMachine.java 2012-01-25 08:53:20 UTC (rev 653)
@@ -527,7 +527,66 @@
}
}
}
+ //============================================================
+ // divided worker functions
+ // The following divided worker functions have to be used together.
+ // - worker_pre()
+ // - worker_do()
+ // - worker_post()
+ //
+ public void worker_pre() {
+ StateHolder state;
+
+ synchronized (m_states) {
+ state = new StateHolder(m_states);
+ }
+ if (state.curr == state.next) {
+ if( m_predo.get(state.curr) != null ) {
+ m_predo.get(state.curr).doAction(state);
+ }
+ return;
+ }
+ // State changed
+ if( m_exit.get(state.curr) != null ) {
+ m_exit.get(state.curr).doAction(state);
+ }
+
+ synchronized (m_states) {
+ state = new StateHolder(m_states);
+ }
+ if( state.curr != state.next ) {
+ state.curr = state.next;
+ if( m_entry.get(state.curr)!=null ) {
+ m_entry.get(state.curr).doAction(state);
+ }
+ update_curr((STATE)state.curr);
+ }
+ }
+
+ public void worker_do() {
+ StateHolder state;
+
+ synchronized (m_states) {
+ state = new StateHolder(m_states);
+ }
+ if( m_do.get(state.curr) != null ) {
+ m_do.get(state.curr).doAction(state);
+ }
+
+ }
+
+ public void worker_post() {
+ StateHolder state;
+
+ synchronized (m_states) {
+ state = new StateHolder(m_states);
+ }
+ if( m_postdo.get(state.curr) != null ) {
+ m_postdo.get(state.curr).doAction(state);
+ }
+ }
+
private boolean need_trans() {
synchronized (m_states) {
return m_states.curr != m_states.next;
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-25 08:34:34 UTC (rev 652)
+++ branches/work/DesignChangeOfEC/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/ExecutionContextBase.java 2012-01-25 08:53:20 UTC (rev 653)
@@ -28,17 +28,17 @@
}
*/
/**
- * {@.ja CORBA オブジェクト参照の取得}
- * {@.en Get the reference to the CORBA object}
+ * {@.ja CORBA オブジェクトの設定}
+ * {@.en Sets the reference to the CORBA object}
* <p>
* {@.ja 本オブジェクトの ExecutioncontextService としての CORBA オブジェ
- * クト参照を取得する。}
- * {@.en Get the reference to the CORBA object as
+ * クトを設定する。}
+ * {@.en Sets the reference to the CORBA object as
* ExecutioncontextService of this object.}
*
- * @return
- * {@.ja CORBA オブジェクト参照}
- * {@.en The reference to CORBA object}
+ * @param ref
+ * {@.ja オブジェクトリファレンス}
+ * {@.en The object reference}
*
*/
public void setObjRef(final ExecutionContextService ref);
@@ -145,7 +145,7 @@
* {@.en ExecutionKind}
* @return
* {@.ja 文字列化されたExecutionKind}
- * {@en String of ExecutionKind}
+ * {@.en String of ExecutionKind}
*
*/
public String getKindString(ExecutionKind kind);
Added: branches/work/DesignChangeOfEC/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/ExecutionContextFactory.java
===================================================================
--- branches/work/DesignChangeOfEC/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/ExecutionContextFactory.java (rev 0)
+++ branches/work/DesignChangeOfEC/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/ExecutionContextFactory.java 2012-01-25 08:53:20 UTC (rev 653)
@@ -0,0 +1,34 @@
+package jp.go.aist.rtm.RTC.executionContext;
+
+import jp.go.aist.rtm.RTC.FactoryGlobal;
+/**
+ * {@.ja ExecutionContext用ファクトリの実装}
+ * {@.en Implement of factory for ExecutionContext}
+ */
+
+public class ExecutionContextFactory<ABSTRACTCLASS,IDENTIFIER> extends FactoryGlobal<ABSTRACTCLASS,IDENTIFIER> {
+
+ /**
+ * {@.ja コンストラクタ。}
+ * {@.en Constructor}
+ */
+ private ExecutionContextFactory() {
+
+ }
+ /**
+ * {@.ja インスタンス生成。}
+ * {@.en Create instance}
+ *
+ * <p>
+ * {@.ja インスタンスを生成する。}
+ *
+ * @return
+ * {@.ja インスタンス}
+ * {@.en ExecutionContextFactory object}
+ *
+ */
+ public static ExecutionContextFactory instance() {
+ return (ExecutionContextFactory)instance("jp.go.aist.rtm.RTC.executionContext.ExecutionContextFactory");
+ }
+}
+
Modified: 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 2012-01-25 08:34:34 UTC (rev 652)
+++ branches/work/DesignChangeOfEC/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/ExecutionContextProfile.java 2012-01-25 08:53:20 UTC (rev 653)
@@ -25,7 +25,7 @@
* ExecutionContext class}
*/
public class ExecutionContextProfile {
- public final double DEEFAULT_PERIOD = 0.000001;
+ public static final double DEEFAULT_PERIOD = 0.000001;
/**
* {@.ja デフォルトコンストラクタ}
@@ -61,17 +61,17 @@
this(ExecutionKind.PERIODIC);
}
/**
- * {@.ja CORBA オブジェクト参照の取得}
- * {@.en Get the reference to the CORBA object}
+ * {@.ja CORBA オブジェクトの設定}
+ * {@.en Sets the reference to the CORBA object}
* <p>
* {@.ja 本オブジェクトの ExecutioncontextService としての CORBA オブジェ
- * クト参照を取得する。}
- * {@.en Get the reference to the CORBA object as
+ * クトを設定する。}
+ * {@.en Sets the reference to the CORBA object as
* ExecutioncontextService of this object.}
*
- * @return
- * {@.ja CORBA オブジェクト参照}
- * {@.en The reference to CORBA object}
+ * @param ec_ptr
+ * {@.ja オブジェクトリファレンス}
+ * {@.en The object reference}
*/
public void setObjRef(ExecutionContextService ec_ptr){
rtcout.println(Logbuf.TRACE, "setObjRef()");
Modified: branches/work/DesignChangeOfEC/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/OpenHRPExecutionContext.java
===================================================================
--- branches/work/DesignChangeOfEC/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/OpenHRPExecutionContext.java 2012-01-25 08:34:34 UTC (rev 652)
+++ branches/work/DesignChangeOfEC/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/OpenHRPExecutionContext.java 2012-01-25 08:53:20 UTC (rev 653)
@@ -1,6 +1,8 @@
package jp.go.aist.rtm.RTC.executionContext;
import jp.go.aist.rtm.RTC.Manager;
+import jp.go.aist.rtm.RTC.ObjectCreator;
+import jp.go.aist.rtm.RTC.ObjectDestructor;
import org.omg.CORBA.SystemException;
@@ -9,8 +11,9 @@
*
*/
public class OpenHRPExecutionContext
- extends PeriodicExecutionContext implements Runnable{
-
+// extends PeriodicExecutionContext implements Runnable{
+extends PeriodicExecutionContext
+implements Runnable, ObjectCreator<ExecutionContextBase>, ObjectDestructor, ExecutionContextBase{
/**
* <p> Constructor </p>
*/
@@ -72,12 +75,42 @@
private Worker m_worker = new Worker();
/**
+ * {@.ja OpenHRPExecutionContext を生成する}
+ * {@.en Creats OpenHRPExecutionContext}
+ *
+ * @return
+ * {@.ja 生成されたOpenHRPExecutionContext}
+ * {@.en Object Created instances}
+ *
+ *
+ */
+ public OpenHRPExecutionContext creator_() {
+ return new OpenHRPExecutionContext();
+ }
+ /**
+ * {@.ja Object を破棄する}
+ * {@.en Destructs Object}
+ *
+ * @param obj
+ * {@.ja 破棄するインタスタンス}
+ * {@.en The target instances for destruction}
+ *
+ */
+ public void destructor_(Object obj) {
+ obj = null;
+ }
+ /**
* <p> OpenHRPExecutionContextInit </p>
*
* @param manager Manager
*/
public static void OpenHRPExecutionContextInit(Manager manager) {
- manager.registerECFactory("jp.go.aist.rtm.RTC.executionContext.OpenHRPExecutionContext");
+// manager.registerECFactory("jp.go.aist.rtm.RTC.executionContext.OpenHRPExecutionContext");
+ ExecutionContextFactory<ExecutionContextBase,String> factory
+ = ExecutionContextFactory.instance();
+ factory.addFactory("SynchExtTriggerEC",
+ new OpenHRPExecutionContext(),
+ new OpenHRPExecutionContext());
}
/**
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-25 08:34:34 UTC (rev 652)
+++ branches/work/DesignChangeOfEC/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/PeriodicExecutionContext.java 2012-01-25 08:53:20 UTC (rev 653)
@@ -60,13 +60,13 @@
m_usec = (long)(1000000/rate);
- m_ref = (ExecutionContextService)this.__this();
+ //m_ref = (ExecutionContextService)this.__this();
+ m_profile.setObjRef((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.setRate(1.0 / jp.go.aist.rtm.RTC.executionContext.ExecutionContextProfile.DEEFAULT_PERIOD);
/*
m_profile.kind = ExecutionKind.PERIODIC;
@@ -127,13 +127,13 @@
m_nowait = true;
}
- m_ref = (ExecutionContextService)this.__this();
+ //m_ref = (ExecutionContextService)this.__this();
+ m_profile.setObjRef((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.setRate(1.0 / jp.go.aist.rtm.RTC.executionContext.ExecutionContextProfile.DEEFAULT_PERIOD);
m_profile.setOwner((LightweightRTObject)owner._duplicate());
/*
m_profile.kind = ExecutionKind.PERIODIC;
@@ -252,7 +252,9 @@
}
if (m_worker.running_) {
for (int intIdx=0; intIdx < m_comps.size(); ++intIdx) {
- m_comps.elementAt(intIdx).invoke();
+ m_comps.get(intIdx).invoke_work_pre();
+ m_comps.get(intIdx).invoke_work_do();
+ m_comps.get(intIdx).invoke_work_post();
}
}
}
@@ -400,6 +402,11 @@
for(int intIdx=0;intIdx<m_comps.size();intIdx++ ) {
m_comps.elementAt(intIdx).invoke_on_rate_changed();
}
+ rtcout.println(Logbuf.DEBUG, "Actual period: "
+ + m_profile.getPeriod().sec()
+ + " [sec], "
+ + m_profile.getPeriod().usec()
+ + " [usec]");
return ReturnCode_t.RTC_OK;
}
@@ -506,7 +513,8 @@
*/
public ExecutionKind get_kind() {
- rtcout.println(Logbuf.TRACE, "PeriodicExecutionContext.get_kind()");
+ rtcout.println(Logbuf.TRACE, "PeriodicExecutionContext.get_kind() ="
+ + m_profile.getKindString());
return m_profile.getKind();
//return m_profile.kind;
@@ -838,6 +846,15 @@
public void worker() {
m_sm.worker();
}
+ public void worker_pre() {
+ m_sm.worker_pre();
+ }
+ public void worker_do() {
+ m_sm.worker_do();
+ }
+ public void worker_post() {
+ m_sm.worker_post();
+ }
/**
* <p>現在の状態を取得します。</p>
@@ -998,6 +1015,24 @@
this._sm.worker();
}
/**
+ * <p>ExecutionContextから呼び出されるメソッドです。</p>
+ */
+ public void invoke_work_pre(){
+ this._sm.worker_pre();
+ }
+ /**
+ * <p>ExecutionContextから呼び出されるメソッドです。</p>
+ */
+ public void invoke_work_do(){
+ this._sm.worker_do();
+ }
+ /**
+ * <p>ExecutionContextから呼び出されるメソッドです。</p>
+ */
+ public void invoke_work_post(){
+ this._sm.worker_post();
+ }
+ /**
* <p>StartUp時に呼び出されるメソッドです。</p>
*/
public void invoke_on_startup(){
@@ -1225,7 +1260,7 @@
* {@.en ExecutionKind}
* @return
* {@.ja 文字列化されたExecutionKind}
- * {@en String of ExecutionKind}
+ * {@.en String of ExecutionKind}
*
*/
public final String getKindString(ExecutionKind kind) {
openrtm-commit メーリングリストの案内