[openrtm-commit:02053] r721 - trunk/OpenRTM-aist-Python/OpenRTM_aist

openrtm @ openrtm.org openrtm @ openrtm.org
2016年 10月 13日 (木) 15:17:11 JST


Author: miyamoto
Date: 2016-10-13 15:17:11 +0900 (Thu, 13 Oct 2016)
New Revision: 721

Modified:
   trunk/OpenRTM-aist-Python/OpenRTM_aist/ExecutionContextBase.py
   trunk/OpenRTM-aist-Python/OpenRTM_aist/ExecutionContextWorker.py
   trunk/OpenRTM-aist-Python/OpenRTM_aist/RTObjectStateMachine.py
Log:
[compat,bugfix] refs #3649

Modified: trunk/OpenRTM-aist-Python/OpenRTM_aist/ExecutionContextBase.py
===================================================================
--- trunk/OpenRTM-aist-Python/OpenRTM_aist/ExecutionContextBase.py	2016-10-06 09:52:57 UTC (rev 720)
+++ trunk/OpenRTM-aist-Python/OpenRTM_aist/ExecutionContextBase.py	2016-10-13 06:17:11 UTC (rev 721)
@@ -595,11 +595,19 @@
       self._rtcout.RTC_ERROR("Setting execution rate failed. %f", rate)
       return ret_
 
+    ret_ = self._worker.rateChanged()
+    if ret_ != RTC.RTC_OK:
+      self._rtcout.RTC_ERROR("Invoking on_rate_changed() for each RTC failed.")
+      return ret_
+
     ret_ = self.onSetRate(rate)
     if ret_ != RTC.RTC_OK:
       self._rtcout.RTC_ERROR("onSetRate(%f) failed.", rate)
       return ret_
 
+
+    
+
     self._rtcout.RTC_INFO("setRate(%f) done", rate)
     return ret_
 

Modified: trunk/OpenRTM-aist-Python/OpenRTM_aist/ExecutionContextWorker.py
===================================================================
--- trunk/OpenRTM-aist-Python/OpenRTM_aist/ExecutionContextWorker.py	2016-10-06 09:52:57 UTC (rev 720)
+++ trunk/OpenRTM-aist-Python/OpenRTM_aist/ExecutionContextWorker.py	2016-10-13 06:17:11 UTC (rev 721)
@@ -231,8 +231,30 @@
       
     del guard
     return RTC.RTC_OK
+  #
+  # @if jp
+  # @brief ExecutionContext の周期が変化した
+  # @return ReturnCode_t 型のリターンコード
+  #
+  # @else
+  #
+  # @brief Changing execution rate of the ExecutionContext
+  #
+  # @return The return code of ReturnCode_t type
+  #
+  # @endif
+  # RTC::ReturnCode_t rateChanged(void);
+  def rateChanged(self):
+    self._rtcout.RTC_TRACE("rateChanged()")
+    guard = OpenRTM_aist.ScopedLock(self._mutex)
+    ret = RTC.RTC_OK
+    for comp in self._comps:
+      tmp = comp.onRateChanged()
+      if tmp != RTC.RTC_OK:
+        ret = tmp
+    del guard
+    return ret
 
-
   ##
   # @if jp
   # @brief RTコンポーネントをアクティブ化する
@@ -743,3 +765,4 @@
 
     self._removedComps = []
     return
+

Modified: trunk/OpenRTM-aist-Python/OpenRTM_aist/RTObjectStateMachine.py
===================================================================
--- trunk/OpenRTM-aist-Python/OpenRTM_aist/RTObjectStateMachine.py	2016-10-06 09:52:57 UTC (rev 720)
+++ trunk/OpenRTM-aist-Python/OpenRTM_aist/RTObjectStateMachine.py	2016-10-13 06:17:11 UTC (rev 721)
@@ -43,6 +43,7 @@
     self._dfcVar  = None
     self._fsmVar  = None
     self._modeVar = None
+    self._rtObjPtr = None
 
     # Setting Action callback objects
     self.setComponentAction(comp)
@@ -111,6 +112,9 @@
   # RTC::ComponentAction operations
   # void onStartup(void);
   def onStartup(self):
+    if self._rtObjPtr:
+      self._rtObjPtr.on_startup(self._id)
+      return
     if not self._ca:
       return
     self._caVar.on_startup(self._id)
@@ -118,6 +122,10 @@
 
   # void onShutdown(void);
   def onShutdown(self):
+    if self._rtObjPtr:
+      self._rtObjPtr.on_shutdown(self._id)
+      return
+    
     if not self._ca:
       return
     self._caVar.on_shutdown(self._id)
@@ -125,6 +133,11 @@
 
   # void onActivated(const ExecContextStates& st);
   def onActivated(self, st):
+    if self._rtObjPtr:
+      if self._rtObjPtr.on_activated(self._id) != RTC.RTC_OK:
+        self._sm.goTo(RTC.ERROR_STATE)
+      return
+    
     if not self._ca:
       return
     if self._caVar.on_activated(self._id) != RTC.RTC_OK:
@@ -133,6 +146,10 @@
 
   # void onDeactivated(const ExecContextStates& st);
   def onDeactivated(self, st):
+    if self._rtObjPtr:
+      self._rtObjPtr.on_deactivated(self._id)
+      return
+    
     if not self._ca:
       return
     self._caVar.on_deactivated(self._id)
@@ -140,13 +157,21 @@
 
   # void onAborting(const ExecContextStates& st);
   def onAborting(self, st):
+    if self._rtObjPtr:
+      self._rtObjPtr.on_aborting(self._id)
+      return
+    
     if not self._ca:
       return
-    self._caVar.on_error(self._id)
+    self._caVar.on_aborting(self._id)
     return
 
   # void onError(const ExecContextStates& st);
   def onError(self, st):
+    if self._rtObjPtr:
+      self._rtObjPtr.on_error(self._id)
+      return
+    
     if not self._ca:
       return
     self._caVar.on_error(self._id)
@@ -154,6 +179,11 @@
 
   # void onReset(const ExecContextStates& st);
   def onReset(self, st):
+    if self._rtObjPtr:
+      if self._rtObjPtr.on_reset(self._id) != RTC.RTC_OK:
+        self._sm.goTo(RTC.ERROR_STATE)
+      return
+    
     if not self._ca:
       return
     if self._caVar.on_reset(self._id) != RTC.RTC_OK:
@@ -163,6 +193,11 @@
   # RTC::DataflowComponentAction
   # void onExecute(const ExecContextStates& st);
   def onExecute(self, st):
+    if self._rtObjPtr:
+      if self._rtObjPtr.on_execute(self._id) != RTC.RTC_OK:
+        self._sm.goTo(RTC.ERROR_STATE)
+      return
+    
     if not self._dfc:
       return
     
@@ -172,6 +207,11 @@
 
   # void onStateUpdate(const ExecContextStates& st);
   def onStateUpdate(self, st):
+    if self._rtObjPtr:
+      if self._rtObjPtr.on_state_update(self._id) != RTC.RTC_OK:
+        self._sm.goTo(RTC.ERROR_STATE)
+      return
+    
     if not self._dfc:
       return
     
@@ -179,14 +219,21 @@
       self._sm.goTo(RTC.ERROR_STATE)
     return
 
-  # void onRateChanged(void);
+  # RTC::ReturnCode_t onRateChanged(void);
   def onRateChanged(self):
+    if self._rtObjPtr:
+      ret = self._rtObjPtr.on_rate_changed(self._id)
+      if ret != RTC.RTC_OK:
+        self._sm.goTo(RTC.ERROR_STATE)
+      return ret
+    
     if not self._dfc:
-      return
+      return RTC.RTC_ERROR
     
-    if self._dfcVar.on_rate_changed(self._id) != RTC.RTC_OK:
+    ret = self._dfcVar.on_rate_changed(self._id)
+    if ret != RTC.RTC_OK:
       self._sm.goTo(RTC.ERROR_STATE)
-    return
+    return ret
 
   # FsmParticipantAction
   # void onAction(const ExecContextStates& st);
@@ -246,8 +293,18 @@
   # void setComponentAction(const RTC::LightweightRTObject_ptr comp);
   def setComponentAction(self, comp):
     self._caVar = comp._narrow(RTC.ComponentAction)
-    if not CORBA.is_nil(self._caVar):
-      self._ca = True
+    if CORBA.is_nil(self._caVar):
+      return
+    self._ca = True
+    
+    poa = OpenRTM_aist.Manager.instance().getPOA()
+    try:
+      self._rtObjPtr = poa.reference_to_servant(comp)
+    except CORBA.SystemException, ex:
+      self._rtObjPtr = None
+    except:
+      self._rtObjPtr = None
+      
     return
 
   # void setDataFlowComponentAction(const RTC::LightweightRTObject_ptr comp);



More information about the openrtm-commit mailing list