[openrtm-commit:02204] r902 - in trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC: . executionContext jfsm/machine

openrtm @ openrtm.org openrtm @ openrtm.org
2017年 1月 12日 (木) 02:35:41 JST


Author: win-ei
Date: 2017-01-12 02:35:39 +0900 (Thu, 12 Jan 2017)
New Revision: 902

Modified:
   trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/RTObjectStateMachine.java
   trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/EventDrivenExecutionContext.java
   trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/jfsm/machine/MachineBase.java
Log:
[FSM4RTC]Fixed bugs.  refs #3772

Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/RTObjectStateMachine.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/RTObjectStateMachine.java	2017-01-11 10:27:38 UTC (rev 901)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/RTObjectStateMachine.java	2017-01-11 17:35:39 UTC (rev 902)
@@ -34,9 +34,10 @@
         m_dfcVar  = null;
         m_fsmVar  = null;
         m_modeVar = null;
-		m_rtobjPtr = null;
-		m_measure = false;
-		m_count = 0;
+        m_rtobjPtr = null;
+        m_fsmobjPtr = null;
+        m_measure = false;
+        m_count = 0;
         // Setting Action callback objects
         setComponentAction(comp);
         setDataFlowComponentAction(comp);
@@ -58,6 +59,10 @@
                              new onError());
         m_sm.setExitAction  (LifeCycleState.ERROR_STATE,
                              new onReset());
+
+        m_sm.setDoAction    (LifeCycleState.ACTIVE_STATE,
+                             new onAction());
+
         // Setting inital state
         StateHolder<LifeCycleState> st = new StateHolder<LifeCycleState>();
         st.prev = LifeCycleState.INACTIVE_STATE;
@@ -240,6 +245,22 @@
             return;
         }
     }
+    /**
+     * {@.ja onActionアクション定義用抽象クラス}
+     */
+    private class onAction implements StateAction {
+        public void doAction(StateHolder state) {
+            if (!m_fsm) { 
+                return; 
+            }
+            ReturnCode_t ret = m_fsmVar.on_action(m_id);
+            if (ret != ReturnCode_t.RTC_OK) {
+                m_sm.goTo(LifeCycleState.ERROR_STATE);
+                return;
+            }
+            return;
+        }
+    }
 
 
     // functions for stored RTObject reference
@@ -580,11 +601,12 @@
     private DataFlowComponentAction  m_dfcVar;
     private FsmParticipantAction     m_fsmVar;
     private MultiModeComponentAction m_modeVar;
-	private RTObject_impl m_rtobjPtr;
-	private boolean m_measure;
-	private TimeMeasure m_svtMeasure = new TimeMeasure();
-	private TimeMeasure m_refMeasure = new TimeMeasure();
-	private int m_count;
+    private RTObject_impl m_rtobjPtr;
+    private FsmParticipantBase m_fsmobjPtr;
+    private boolean m_measure;
+    private TimeMeasure m_svtMeasure = new TimeMeasure();
+    private TimeMeasure m_refMeasure = new TimeMeasure();
+    private int m_count;
     //    char dara[1000];
     // Component action invoker
     

Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/EventDrivenExecutionContext.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/EventDrivenExecutionContext.java	2017-01-11 10:27:38 UTC (rev 901)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/EventDrivenExecutionContext.java	2017-01-11 17:35:39 UTC (rev 902)
@@ -17,11 +17,11 @@
 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 RTC.ExecutionContextService;
 import RTC.ExecutionContextServiceHelper;
 import RTC.ExecutionContextServicePOA;
 import RTC.ExecutionKind;
+import RTC.FsmParticipant;
 import RTC.LifeCycleState;
 import RTC.LightweightRTObject;
 import RTC.ReturnCode_t;
@@ -49,11 +49,11 @@
      * <p>
      * {@.ja デフォルトコンストラクタ
      * プロファイルに以下の項目を設定する。
-     *  - kind : PERIODIC
+     *  - kind : EVENT_DRIVEN
      *  - rate : 0.0}
      * {@.en Default Constructor
      * Set the following items to profile.
-     *  - kind : PERIODIC
+     *  - kind : EVENT_DRIVEN
      *  - rate : 0.0}
      */
     public EventDrivenExecutionContext() {
@@ -62,10 +62,12 @@
         m_svc = false;
         m_nowait = false;
         setObjRef((ExecutionContextService)this.__this());
-        setKind(ExecutionKind.PERIODIC);
+        setKind(ExecutionKind.EVENT_DRIVEN);
+/*
         setRate(1000);
         rtcout.println(Logbuf.DEBUG, "Actual period: " + m_profile.getPeriod().sec() + " [sec], "
                 + m_profile.getPeriod().usec() + " [usec]");
+*/
     }
 
 
@@ -99,7 +101,7 @@
         rtcout.println(Logbuf.TRACE, "EventDrivenExecutionContext.setObjRef()");
         m_worker.setECRef(ref);
         m_profile.setObjRef(ref);
-		m_ref = ref;
+        m_ref = ref;
     }
 
     /**
@@ -223,6 +225,7 @@
      * 
      * @return 実行判定結果
      */
+    @Override
     public boolean is_running() {
         return isRunning();
     }
@@ -476,6 +479,7 @@
      * 
      * @return 実行結果
      */
+    @Override
     public ReturnCode_t start() {
 
         rtcout.println(Logbuf.TRACE, "EventDrivenExecutionContext.start()");
@@ -508,6 +512,7 @@
      * 
      * @return 実行結果
      */
+    @Override
     public ReturnCode_t stop(){
 
         rtcout.println(Logbuf.TRACE, "EventDrivenExecutionContext.stop()");
@@ -538,6 +543,7 @@
      * 
      * @return 実行周期(Hz)
      */
+    @Override
     public double get_rate() {
 
         rtcout.println(Logbuf.TRACE, "EventDrivenExecutionContext.get_rate()");
@@ -555,6 +561,7 @@
      * 
      * @param rate 実行周期(Hz)
      */
+    @Override
     public ReturnCode_t set_rate(double rate) {
 
         rtcout.println(Logbuf.TRACE, "EventDrivenExecutionContext.set_rate("+rate+")");
@@ -586,6 +593,7 @@
      * 
      * @return 実行結果
      */
+    @Override
     public ReturnCode_t activate_component(LightweightRTObject comp) {
 
         rtcout.println(Logbuf.TRACE, "EventDrivenExecutionContext.activate_component()");
@@ -695,6 +703,7 @@
      * 
      * @return 実行結果
      */
+    @Override
     public ReturnCode_t deactivate_component(LightweightRTObject comp) {
 
         rtcout.println(Logbuf.TRACE, "EventDrivenExecutionContext.deactivate_component()");
@@ -803,6 +812,7 @@
      * 
      * @return 実行結果
      */
+    @Override
     public ReturnCode_t reset_component(LightweightRTObject comp){
 
         rtcout.println(Logbuf.TRACE, "EventDrivenExecutionContext.reset_component()");
@@ -911,6 +921,7 @@
      * 
      * @return コンポーネント状態
      */
+    @Override
     public LifeCycleState get_component_state(LightweightRTObject comp) {
 
         rtcout.println(Logbuf.TRACE, "EventDrivenExecutionContext.get_component_state()");
@@ -937,6 +948,7 @@
      * 
      * @return ExecutionKind
      */
+    @Override
     public ExecutionKind get_kind() {
 
         rtcout.println(Logbuf.TRACE, "EventDrivenExecutionContext.get_kind() ="
@@ -980,6 +992,7 @@
      *
      *
      */
+    @Override
     public ReturnCode_t add_component(LightweightRTObject comp) {
 
         rtcout.println(Logbuf.TRACE, 
@@ -1070,6 +1083,7 @@
      *   {@.en The return code of ReturnCode_t type}
      *
      */
+    @Override
     public ReturnCode_t remove_component(LightweightRTObject comp) {
 
         rtcout.println(Logbuf.TRACE, 
@@ -1127,7 +1141,7 @@
     }
 
     /**
-     * <p>DataFlowComponentのAction定義用抽象クラスです。</p>
+     * <p>FsmParticipantComponentのAction定義用抽象クラスです。</p>
      */
     protected abstract class DFPBase {
         /**
@@ -1141,13 +1155,13 @@
             m_sm.setListener(this);
             StateHolder st = new StateHolder();
             m_sm.setEntryAction(LifeCycleState.ACTIVE_STATE, new onActivated());
-            m_sm.setDoAction(LifeCycleState.ACTIVE_STATE, new onExecute());
-            m_sm.setPostDoAction(LifeCycleState.ACTIVE_STATE, new onStateUpdate());
             m_sm.setExitAction(LifeCycleState.ACTIVE_STATE, new onDeactivated());
             m_sm.setEntryAction(LifeCycleState.ERROR_STATE, new onAborting());
             m_sm.setDoAction(LifeCycleState.ERROR_STATE, new onError());
             m_sm.setExitAction(LifeCycleState.ERROR_STATE, new onReset());
 
+            m_sm.setDoAction(LifeCycleState.ACTIVE_STATE, new onAction());
+
             st.prev = LifeCycleState.INACTIVE_STATE;
             st.curr = LifeCycleState.INACTIVE_STATE;
             st.next = LifeCycleState.INACTIVE_STATE;
@@ -1163,22 +1177,6 @@
             }
         }
         /**
-         * <p>onExecuteアクション定義用抽象クラスです。</p>
-         */
-        private class onExecute implements StateAction {
-            public void doAction(StateHolder state) {
-                on_execute(state);
-            }
-        }
-        /**
-         * <p>onStateUpdateアクション定義用抽象クラスです。</p>
-         */
-        private class onStateUpdate implements StateAction {
-            public void doAction(StateHolder state) {
-                on_state_update(state);
-            }
-        }
-        /**
          * <p>onDeactivatedアクション定義用抽象クラスです。</p>
          */
         private class onDeactivated implements StateAction {
@@ -1210,6 +1208,14 @@
                 on_reset(state);
             }
         }
+        /**
+         * <p>onActionアクション定義用抽象クラスです。</p>
+         */
+        private class onAction implements StateAction {
+            public void doAction(StateHolder state) {
+                on_action(state);
+            }
+        }
 
         /**
          * <p>ExecutionContextのstart時に呼ばれる抽象メソッドです。</p>
@@ -1241,19 +1247,10 @@
          */
         public abstract void on_reset(final StateHolder st);
         /**
-         * <p>コンポーネント実行時に呼ばれる抽象メソッドです。</p>
+         * <p>action時に呼ばれる抽象メソッドです。</p>
          */
-        public abstract void on_execute(final StateHolder st);
+        public abstract void on_action(final StateHolder st);
         /**
-         * <p>コンポーネントの実行時に呼ばれる抽象メソッドです。</p>
-         */
-        public abstract void on_state_update(final StateHolder st);
-
-        /**
-         * <p>ExecutionContextの実行周期変更時に呼ばれる抽象メソッドです。</p>
-         */
-        public abstract void on_rate_changed();
-        /**
          * <p>ExecutionContextの状態遷移用ワーカーです。</p>
          */
         public void worker() {
@@ -1290,7 +1287,7 @@
     }
 
     /**
-     * <p>DataFlowComponentのAction定義用抽象クラスです。</p>
+     * <p>FsmParticipantのAction定義用抽象クラスです。</p>
      */
     protected class DFP extends DFPBase {
         /**
@@ -1299,7 +1296,7 @@
          * @param obj 対象コンポーネント
          * @param id ExecutionContextのID
          */
-        public DFP(DataFlowComponent obj, int id) {
+        public DFP(FsmParticipant obj, int id) {
             super(id);
             m_obj = obj;
         }
@@ -1358,32 +1355,16 @@
             return;
         }
         /**
-         * <p>onExecuteアクション定義用メソッドです。</p>
+         * <p>onActionアクション定義用メソッドです。</p>
          */
-        public void on_execute(final StateHolder st) {
-            if( m_obj.on_execute(ec_id) != ReturnCode_t.RTC_OK) {
+        public void on_action(final StateHolder st) {
+            if( m_obj.on_action(ec_id) != ReturnCode_t.RTC_OK) {
                 m_sm.goTo(LifeCycleState.ERROR_STATE);
                 return;
             }  
             return;
         }
-        /**
-         * <p>onStateUpdateアクション定義用メソッドです。</p>
-         */
-        public void on_state_update(final StateHolder st) {
-            if( m_obj.on_state_update(ec_id) != ReturnCode_t.RTC_OK) {
-                m_sm.goTo(LifeCycleState.ERROR_STATE);
-                return;
-            }
-            return;
-        }
-        /**
-         * <p>onRateChangedアクション定義用メソッドです。</p>
-         */
-        public void on_rate_changed() {
-            m_obj.on_rate_changed(ec_id);
-        }
-        private DataFlowComponent m_obj; 
+        private FsmParticipant m_obj; 
     }
 
     /**
@@ -1397,7 +1378,7 @@
          * @param dfp ExecutionContextの対象StateMachine
          * @param id ExecutionContextのID
          */
-        public Comp(LightweightRTObject ref, DataFlowComponent dfp, int id) {
+        public Comp(LightweightRTObject ref, FsmParticipant dfp, int id) {
             this._ref = ref;
             this._sm = new DFP(dfp, id);
         }
@@ -1458,12 +1439,6 @@
             this._sm.on_shutdown();
         }
         /**
-         * <p>RateChanged時に呼び出されるメソッドです。</p>
-         */
-        public void invoke_on_rate_changed(){
-            this._sm.on_rate_changed();
-        }
-        /**
          * <p>StateMachine管理対象コンポーネントです。</p>
          */
         public LightweightRTObject _ref;
@@ -1709,6 +1684,7 @@
      *         BAD_PARAMETER: Invalid value. The value might be negative.}
      *
      */
+    @Override
     public ReturnCode_t setRate(double rate) {
       return m_profile.setRate(rate);
     }
@@ -1891,12 +1867,9 @@
         rtcout.println(Logbuf.DEBUG, "Configuration " + key +" not found.");
         return false;
     }
-    /*!
-     * @if jp
-     * @brief Propertiesから実行コンテキストをセットする
-     * @else
-     * @brief Setting execution rate from given properties.
-     * @endif
+    /**
+     * {@.ja Propertiesから実行コンテキストをセットする}
+     * {@.en Setting execution rate from given properties.}
      */
     public boolean setExecutionRate(Properties props)
     {

Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/jfsm/machine/MachineBase.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/jfsm/machine/MachineBase.java	2017-01-11 10:27:38 UTC (rev 901)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/jfsm/machine/MachineBase.java	2017-01-11 17:35:39 UTC (rev 902)
@@ -8,6 +8,7 @@
 import java.util.Iterator;
 import java.util.Map;
 
+import jp.go.aist.rtm.RTC.ExtendedFsmServiceProvider;
 import jp.go.aist.rtm.RTC.jfsm.Event;
 import jp.go.aist.rtm.RTC.jfsm.State;
 import jp.go.aist.rtm.RTC.jfsm.StateDef;
@@ -15,7 +16,7 @@
 //import org.slf4j.LoggerFactory;
 import jp.go.aist.rtm.RTC.log.Logbuf;
 
-public class MachineBase {
+public class MachineBase extends ExtendedFsmServiceProvider {
 
     //private static final Logger LOGGER = LoggerFactory.getLogger(MachineBase.class);
 



More information about the openrtm-commit mailing list