[openrtm-commit:02348] r2899 - branches/FSM4RTC/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer

openrtm @ openrtm.org openrtm @ openrtm.org
2017年 1月 28日 (土) 23:39:18 JST


Author: n-ando
Date: 2017-01-28 23:39:18 +0900 (Sat, 28 Jan 2017)
New Revision: 2899

Modified:
   branches/FSM4RTC/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/ComponentObserverConsumer.cpp
   branches/FSM4RTC/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/ComponentObserverConsumer.h
Log:
[FSM4RTC] ComponentObserver implementation has been added. refs #3591

Modified: branches/FSM4RTC/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/ComponentObserverConsumer.cpp
===================================================================
--- branches/FSM4RTC/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/ComponentObserverConsumer.cpp	2017-01-28 14:36:25 UTC (rev 2898)
+++ branches/FSM4RTC/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/ComponentObserverConsumer.cpp	2017-01-28 14:39:18 UTC (rev 2899)
@@ -179,35 +179,35 @@
         coil::toUpper(observed[i]);
         if (observed[i] == "COMPONENT_PROFILE")
           {
-            flags[RTC::COMPONENT_PROFILE] = 1;
+            flags[RTC::COMPONENT_PROFILE] = true;
           }
         else if (observed[i] == "RTC_STATUS")
           {
-            flags[RTC::RTC_STATUS] = 1;
+            flags[RTC::RTC_STATUS] = true;
           }
         else if (observed[i] == "EC_STATUS")
           {
-            flags[RTC::EC_STATUS] = 1;
+            flags[RTC::EC_STATUS] = true;
           }
         else if (observed[i] == "PORT_PROFILE")
           {
-            flags[RTC::PORT_PROFILE] = 1;
+            flags[RTC::PORT_PROFILE] = true;
           }
         else if (observed[i] == "CONFIGURATION")
           {
-            flags[RTC::CONFIGURATION] = 1;
+            flags[RTC::CONFIGURATION] = true;
           }
         else if (observed[i] == "FSM_PROFILE")
           {
-            flags[RTC::FSM_PROFILE] = 1;
+            flags[RTC::FSM_PROFILE] = true;
           }
         else if (observed[i] == "FSM_STATUS")
           {
-            flags[RTC::FSM_STATUS] = 1;
+            flags[RTC::FSM_STATUS] = true;
           }
         else if (observed[i] == "FSM_STRUCTURE")
           {
-            flags[RTC::FSM_STRUCTURE] = 1;
+            flags[RTC::FSM_STRUCTURE] = true;
           }
         else if (observed[i] == "ALL")
           {
@@ -763,10 +763,47 @@
    */
   void ComponentObserverConsumer::setFSMStructureListeners()
   {
-    m_fsmaction.fsmActionListener = 
+    m_fsmaction.preOnFsmInitListener =
+      m_rtobj->addPreFsmActionListener(PRE_ON_INIT,
+                                       m_fsmaction,
+                                       &FSMAction::preInit);
+    m_fsmaction.preOnFsmEntryListener =
+      m_rtobj->addPreFsmActionListener(PRE_ON_ENTRY,
+                                       m_fsmaction,
+                                       &FSMAction::preEntry);
+    m_fsmaction.preOnFsmDoListener =
+      m_rtobj->addPreFsmActionListener(PRE_ON_DO,
+                                       m_fsmaction,
+                                       &FSMAction::preDo);
+    m_fsmaction.preOnFsmExitListener =
+      m_rtobj->addPreFsmActionListener(PRE_ON_EXIT,
+                                       m_fsmaction,
+                                       &FSMAction::preExit);
+    m_fsmaction.preOnFsmStateChangeListener =
       m_rtobj->addPreFsmActionListener(PRE_ON_STATE_CHANGE,
                                        m_fsmaction,
-                                       &FSMAction::updateFsmStatus);
+                                       &FSMAction::preStateChange);
+
+    m_fsmaction.postOnFsmInitListener =
+      m_rtobj->addPostFsmActionListener(POST_ON_INIT,
+                                       m_fsmaction,
+                                       &FSMAction::postInit);
+    m_fsmaction.postOnFsmEntryListener =
+      m_rtobj->addPostFsmActionListener(POST_ON_ENTRY,
+                                       m_fsmaction,
+                                       &FSMAction::postEntry);
+    m_fsmaction.postOnFsmDoListener =
+      m_rtobj->addPostFsmActionListener(POST_ON_DO,
+                                       m_fsmaction,
+                                       &FSMAction::postDo);
+    m_fsmaction.postOnFsmExitListener =
+      m_rtobj->addPostFsmActionListener(POST_ON_EXIT,
+                                        m_fsmaction,
+                                        &FSMAction::postExit);
+    m_fsmaction.postOnFsmStateChangeListener =
+      m_rtobj->addPostFsmActionListener(POST_ON_EXIT,
+                                        m_fsmaction,
+                                        &FSMAction::postStateChange);
   }
 
   /*!
@@ -778,6 +815,36 @@
    */
   void ComponentObserverConsumer::unsetFSMStructureListeners()
   {
+      m_rtobj->
+        removePreFsmActionListener(PRE_ON_INIT,
+                                   m_fsmaction.preOnFsmInitListener);
+      m_rtobj->
+        removePreFsmActionListener(PRE_ON_ENTRY,
+                                   m_fsmaction.preOnFsmEntryListener);
+      m_rtobj->
+        removePreFsmActionListener(PRE_ON_DO,
+                                   m_fsmaction.preOnFsmDoListener);
+      m_rtobj->
+        removePreFsmActionListener(PRE_ON_EXIT,
+                                   m_fsmaction.preOnFsmExitListener);
+      m_rtobj->
+        removePreFsmActionListener(PRE_ON_STATE_CHANGE,
+                                   m_fsmaction.preOnFsmStateChangeListener);
+      m_rtobj->
+        removePostFsmActionListener(POST_ON_INIT,
+                                    m_fsmaction.postOnFsmInitListener);
+      m_rtobj->
+        removePostFsmActionListener(POST_ON_ENTRY,
+                                    m_fsmaction.postOnFsmEntryListener);
+      m_rtobj->
+        removePostFsmActionListener(POST_ON_DO,
+                                    m_fsmaction.postOnFsmDoListener);
+      m_rtobj->
+        removePostFsmActionListener(POST_ON_EXIT,
+                                    m_fsmaction.postOnFsmExitListener);
+      m_rtobj->
+        removePostFsmActionListener(POST_ON_EXIT,
+                                    m_fsmaction.postOnFsmStateChangeListener);
   }
 
   //============================================================
@@ -859,8 +926,6 @@
         m_configMsg.activateConfigSetListener = NULL;
       }
   }
-  
-  
 }; // namespace RTC
 
 extern "C"

Modified: branches/FSM4RTC/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/ComponentObserverConsumer.h
===================================================================
--- branches/FSM4RTC/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/ComponentObserverConsumer.h	2017-01-28 14:36:25 UTC (rev 2898)
+++ branches/FSM4RTC/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/ComponentObserverConsumer.h	2017-01-28 14:39:18 UTC (rev 2899)
@@ -35,6 +35,89 @@
 
   /*!
    * @if jp
+   * @class ComponentObserverConsumer クラス
+   * @brief ComponentObserver モジュール
+   *
+   * コンポーネントの各種状態をComponentObserverサービスに対してコール
+   * バックするためのクラス。ツール等、コンポーネントの状態変化を知りた
+   * いエンティティがサービスプロバイダを当該コンポーネントに対してセッ
+   * トすると、対応する本コンシューマがアタッチされ、コンポーネントの状
+   * 態変化に応じて、update_status() オペレーションをSTATUS_KIND とヒン
+   * トを引数に呼び出す。本機能は、OMG の FSM4RTC仕様
+   * (formal/16-04-01) 7.2.4.2 ComponentObserver Interface に記述されて
+   * いる。
+   *
+   * STATUS_KIND には以下の種類がある。
+   *
+   * - COMPONENT_PROFILE: コンポーネントのプロファイル情報が変化
+   * - RTC_STATUS       : コンポーネントの状態 (Init, Alive) が変化
+   * - EC_STATUS        : ECの状態 (Inavtive, Active, Error) が変化
+   * - PORT_PROFILE     : ポートのプロファイルが変化
+   * - CONFIGURATION    : コンフィギュレーションが変化
+   * - RTC_HEARTBEAT    : RTCの生存確認のハートビード
+   * - EC_HEARTBEAT     : ECの生存確認のハートビート
+   * - FSM_PROFILE      : FSMのプロファイルが変化
+   * - FSM_STATUS       : FSMの状態が変化
+   * - FSM_STRUCTURE    : FSMの構造が変化
+   * - USER_DEFINED     : ユーザ定義
+   *
+   * \subsection COMPONENT_PROFILE COMPONENT_PROFILE
+   * コンポーネントのプロファイル情報が変化した際にこのタグ名(enum値)を
+   * 第1引数にして update_status() オペレーションが呼び出される。(未実装)
+   *
+   * \subsection RTC_STATUS RTC_STATUS
+   *
+   * コンポーネントの状態 (Init, Alive) が変化した際にこのタグ名
+   * (enum値)を第1引数にして update_status() オペレーションが呼び出され
+   * る。厳密にはECの状態であるが、Inavtive, Active, Error, Finalize の
+   * 4つの状態に変化したことを検知することができる。以下の状態変化時に、
+   * それぞれヒントとして以下の文字列とともにコールバックされる。
+   *
+   * - onActivated 呼び出し成功時:   ACTIVE: <EC id>
+   * - onDeactivated 呼び出し成功時: INACTIVE: <EC id>
+   * - onReset 呼び出し成功時:       INACTIVE: <EC id>
+   * - onAborting 呼び出し成功時:    ERROR: <EC id>
+   * - onFinalize 呼び出し成功時:    FINALIZE: <EC id>
+   *
+   * \subsection EC_STATUS EC_STATUS
+   *
+   * ECの状態 (Inavtive, Active, Error) が変化した際にこのタグ名(enum値)を
+   * 第1引数にして update_status() オペレーションが呼び出される。
+   *
+   * \subsection PORT_PROFILE PORT_PROFILE
+   * ポートのプロファイルが変化した際にこのタグ名(enum値)を
+   * 第1引数にして update_status() オペレーションが呼び出される。
+   *
+   * \subsection CONFIGURATION CONFIGURATION
+   * コンフィギュレーションが変化した際にこのタグ名(enum値)を
+   * 第1引数にして update_status() オペレーションが呼び出される。
+   *
+   * \subsection RTC_HEARTBEAT RTC_HEARTBEAT
+   * RTCの生存確認のハートビードした際にこのタグ名(enum値)を
+   * 第1引数にして update_status() オペレーションが呼び出される。
+   *
+   * \subsection EC_HEARTBEAT EC_HEARTBEAT
+   * ECの生存確認のハートビートした際にこのタグ名(enum値)を
+   * 第1引数にして update_status() オペレーションが呼び出される。
+   *
+   * \subsection FSM_PROFILE FSM_PROFILE
+   * FSMのプロファイルが変化した際にこのタグ名(enum値)を
+   * 第1引数にして update_status() オペレーションが呼び出される。
+   *
+   * \subsection FSM_STATUS FSM_STATUS
+   * FSMの状態が変化した際にこのタグ名(enum値)を
+   * 第1引数にして update_status() オペレーションが呼び出される。
+   *
+   * \subsection FSM_STRUCTURE FSM_STRUCTURE
+   * FSMの構造が変化した際にこのタグ名(enum値)を
+   * 第1引数にして update_status() オペレーションが呼び出される。
+   *
+   * \subsection USER_DEFINED USER_DEFINED
+   * ユーザ定義した際にこのタグ名(enum値)を
+   * 第1引数にして update_status() オペレーションが呼び出される。
+   *
+   *
+   *
    * @else
    * @endif
    */
@@ -631,9 +714,71 @@
         std::cout << "ComponentObserver::updateFsmStatus(" << state << ")" << std::endl; 
         m_coc.updateStatus(RTC::FSM_STATUS, state);
       }
+
+      void preInit(const char* state)
+      {
+        std::string msg(state); msg += " PRE_ON_INIT";
+        m_coc.updateStatus(RTC::FSM_STATUS, msg.c_str());
+      }
+      void preEntry(const char* state)
+      {
+        std::string msg(state); msg += " PRE_ONENTRY";
+        m_coc.updateStatus(RTC::FSM_STATUS, msg.c_str());
+      }
+      void preDo(const char* state)
+      {
+        std::string msg(state); msg += " PRE_ON_DO";
+        m_coc.updateStatus(RTC::FSM_STATUS, msg.c_str());
+      }
+      void preExit(const char* state)
+      {
+        std::string msg(state); msg += " PRE_ON_EXIT";
+        m_coc.updateStatus(RTC::FSM_STATUS, msg.c_str());
+      }
+      void preStateChange(const char* state)
+      {
+        std::string msg(state); msg += " PRE_ON_STATE_CHANGE";
+        m_coc.updateStatus(RTC::FSM_STATUS, msg.c_str());
+      }
+
+      void postInit(const char* state, ReturnCode_t ret)
+      {
+        std::string msg(state); msg += " POST_ON_INIT";
+        m_coc.updateStatus(RTC::FSM_STATUS, msg.c_str());
+      }
+      void postEntry(const char* state, ReturnCode_t ret)
+      {
+        std::string msg(state); msg += " POST_ONENTRY";
+        m_coc.updateStatus(RTC::FSM_STATUS, msg.c_str());
+      }
+      void postDo(const char* state, ReturnCode_t ret)
+      {
+        std::string msg(state); msg += " POST_ON_DO";
+        m_coc.updateStatus(RTC::FSM_STATUS, msg.c_str());
+      }
+      void postExit(const char* state, ReturnCode_t ret)
+      {
+        std::string msg(state); msg += " POST_ON_EXIT";
+        m_coc.updateStatus(RTC::FSM_STATUS, msg.c_str());
+      }
+      void postStateChange(const char* state, ReturnCode_t ret)
+      {
+        std::string msg(state); msg += " POST_ON_STATE_CHNAGE";
+        m_coc.updateStatus(RTC::FSM_STATUS, msg.c_str());
+      }
+
+      // Listener object's pointer holder
+      PreFsmActionListener* preOnFsmInitListener;
+      PreFsmActionListener* preOnFsmEntryListener;
+      PreFsmActionListener* preOnFsmDoListener;
+      PreFsmActionListener* preOnFsmExitListener;
+      PreFsmActionListener* preOnFsmStateChangeListener;
       
-      // Listener object's pointer holder
-      PreFsmActionListener* fsmActionListener;
+      PostFsmActionListener* postOnFsmInitListener;
+      PostFsmActionListener* postOnFsmEntryListener;
+      PostFsmActionListener* postOnFsmDoListener;
+      PostFsmActionListener* postOnFsmExitListener;
+      PostFsmActionListener* postOnFsmStateChangeListener;
 
     private:
       ComponentObserverConsumer& m_coc;



More information about the openrtm-commit mailing list