[openrtm-commit:02048] r2778 - trunk/OpenRTM-aist/src/lib/rtm

openrtm @ openrtm.org openrtm @ openrtm.org
2016年 10月 13日 (木) 01:51:33 JST


Author: n-ando
Date: 2016-10-13 01:51:33 +0900 (Thu, 13 Oct 2016)
New Revision: 2778

Modified:
   trunk/OpenRTM-aist/src/lib/rtm/ExecutionContextBase.cpp
   trunk/OpenRTM-aist/src/lib/rtm/ExecutionContextBase.h
   trunk/OpenRTM-aist/src/lib/rtm/ExecutionContextWorker.cpp
   trunk/OpenRTM-aist/src/lib/rtm/ExecutionContextWorker.h
   trunk/OpenRTM-aist/src/lib/rtm/RTObjectStateMachine.cpp
   trunk/OpenRTM-aist/src/lib/rtm/RTObjectStateMachine.h
Log:
[incompat,RELENG_1_2] onRateChagned (on_rate_changed()) operation should be called when EC rate is changed. refs #3652

Modified: trunk/OpenRTM-aist/src/lib/rtm/ExecutionContextBase.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/ExecutionContextBase.cpp	2016-10-12 14:54:12 UTC (rev 2777)
+++ trunk/OpenRTM-aist/src/lib/rtm/ExecutionContextBase.cpp	2016-10-12 16:51:33 UTC (rev 2778)
@@ -228,6 +228,12 @@
         RTC_ERROR(("Setting execution rate failed. %f", rate));
         return ret;
       }
+    ret = m_worker.rateChanged();
+    if (ret != RTC::RTC_OK)
+      {
+        RTC_ERROR(("Invoking on_rate_changed() for each RTC failed."));
+        return ret;
+      }
     ret = onSetRate(rate);
     if (ret != RTC::RTC_OK)
       {

Modified: trunk/OpenRTM-aist/src/lib/rtm/ExecutionContextBase.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/ExecutionContextBase.h	2016-10-12 14:54:12 UTC (rev 2777)
+++ trunk/OpenRTM-aist/src/lib/rtm/ExecutionContextBase.h	2016-10-12 16:51:33 UTC (rev 2778)
@@ -345,8 +345,15 @@
    *  }
    * </pre>
    *
-   * ExecutionContextの基底クラス。
-   *
+   * [ExecutionContextBase]
+   * <>
+   *  |
+   *  +--(1 1) [ExecutionContextWorker ] : EC の worker
+   *  |         <>
+   *  |          +--(1 0..) [RTObjectStateMachine] : StateMachine
+   *  |
+   *  +--(1 1) [ExecutionContextProfile] : EC Profileの管理
+   * 
    * @since 0.4.0
    *
    * @else

Modified: trunk/OpenRTM-aist/src/lib/rtm/ExecutionContextWorker.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/ExecutionContextWorker.cpp	2016-10-12 14:54:12 UTC (rev 2777)
+++ trunk/OpenRTM-aist/src/lib/rtm/ExecutionContextWorker.cpp	2016-10-12 16:51:33 UTC (rev 2778)
@@ -136,7 +136,27 @@
     return RTC::RTC_OK;
   }
 
+  /*!
+   * @if jp
+   * @brief ExecutionContext の周期が変化した
+   * @else
+   * @brief Changing execution rate of the ExecutionContext
+   * @endif
+   */
+  RTC::ReturnCode_t ExecutionContextWorker::rateChanged(void)
+  {
+    RTC_TRACE(("rateChanged()"));
+    // invoke on_shutdown for each comps.
+    RTC::ReturnCode_t ret(RTC::RTC_OK);
+    for (size_t i(0); i < m_comps.size(); ++i)
+      {
+        RTC::ReturnCode_t tmp = m_comps[i]->onRateChanged();
+        if (tmp != RTC::RTC_OK) { ret = tmp; }
+      }
+    return ret;
+  }
 
+
   /*!
    * @if jp
    * @brief RTコンポーネントをアクティブ化する

Modified: trunk/OpenRTM-aist/src/lib/rtm/ExecutionContextWorker.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/ExecutionContextWorker.h	2016-10-12 14:54:12 UTC (rev 2777)
+++ trunk/OpenRTM-aist/src/lib/rtm/ExecutionContextWorker.h	2016-10-12 16:51:33 UTC (rev 2778)
@@ -37,7 +37,7 @@
 namespace RTC
 {
   class RTObject_impl;
-};  
+};
 namespace RTC_impl
 {
   class RTObjectStateMachine;
@@ -251,6 +251,35 @@
 
     /*!
      * @if jp
+     * @brief ExecutionContext の実行周期が変更された
+     *
+     * ExecutionContext の実行周期が変更された場合のコールバックを呼び
+     * 出す。ECの実装クラスの set_rate() オペレーションが呼び出された場
+     * 合、ExecutionContextProfile::setRate() が呼び出され、プロファイ
+     * ルの周期値が更新されるとともに、この関数が呼ばれ、
+     * RTObjectStateMachine::onRateChagned() が呼び出される。
+     *
+     * @return ReturnCode_t 型のリターンコード
+     *
+     * @else
+     *
+     * @brief Execution rate of ExecutionContext chnaged
+     *
+     * A call back for execution rate chang when ExecutionContext's
+     * execution rate. If set_rate() operation is called,
+     * ExecutionContextProfile::setRate() will be called, execution
+     * rate in the profile will be updated, and
+     * RTObjectStateMachine::onRateChagned() will be called with this
+     * member function.
+     *
+     * @return The return code of ReturnCode_t type
+     *
+     * @endif
+     */
+    RTC::ReturnCode_t rateChanged();
+
+    /*!
+     * @if jp
      * @brief RTコンポーネントをアクティブ化する
      *
      * Inactive 状態にあるRTコンポーネントをActive に遷移させ、アクティ

Modified: trunk/OpenRTM-aist/src/lib/rtm/RTObjectStateMachine.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/RTObjectStateMachine.cpp	2016-10-12 14:54:12 UTC (rev 2777)
+++ trunk/OpenRTM-aist/src/lib/rtm/RTObjectStateMachine.cpp	2016-10-12 16:51:33 UTC (rev 2778)
@@ -385,25 +385,26 @@
     return;
   }
 
-  void RTObjectStateMachine::onRateChanged(void)
+  RTC::ReturnCode_t RTObjectStateMachine::onRateChanged(void)
   {
     // call Servant
     if (m_rtobjPtr != NULL)
       {
-        if (m_rtobjPtr->on_rate_changed(m_id) != RTC::RTC_OK)
+        RTC::ReturnCode_t ret = m_rtobjPtr->on_rate_changed(m_id);
+        if (ret != RTC::RTC_OK)
           {
             m_sm.goTo(RTC::ERROR_STATE);
           }
-        return;
+        return ret;
       }
     // call Object reference
-    if (!m_dfc) { return; }
-    if (m_dfcVar->on_rate_changed(m_id) != RTC::RTC_OK)
+    if (!m_dfc) { return RTC::RTC_ERROR; }
+    RTC::ReturnCode_t ret = m_dfcVar->on_rate_changed(m_id);
+    if (ret != RTC::RTC_OK)
       {
         m_sm.goTo(RTC::ERROR_STATE);
-        return;
       }
-    return;
+    return ret;
   }
 
   // FsmParticipantAction

Modified: trunk/OpenRTM-aist/src/lib/rtm/RTObjectStateMachine.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/RTObjectStateMachine.h	2016-10-12 14:54:12 UTC (rev 2777)
+++ trunk/OpenRTM-aist/src/lib/rtm/RTObjectStateMachine.h	2016-10-12 16:51:33 UTC (rev 2778)
@@ -72,7 +72,7 @@
     // RTC::DataflowComponentAction
     void onExecute(const ExecContextStates& st);
     void onStateUpdate(const ExecContextStates& st);
-    void onRateChanged(void);
+    RTC::ReturnCode_t onRateChanged(void);
 
     // FsmParticipantAction
     void onAction(const ExecContextStates& st);



More information about the openrtm-commit mailing list