[openrtm-commit:00779] r540 - in branches/work/OpenRTM-aist-Python/OpenRTM_aist: . test
openrtm @ openrtm.org
openrtm @ openrtm.org
2012年 3月 14日 (水) 17:39:40 JST
Author: kurihara
Date: 2012-03-14 17:39:40 +0900 (Wed, 14 Mar 2012)
New Revision: 540
Modified:
branches/work/OpenRTM-aist-Python/OpenRTM_aist/ExtTrigExecutionContext.py
branches/work/OpenRTM-aist-Python/OpenRTM_aist/OpenHRPExecutionContext.py
branches/work/OpenRTM-aist-Python/OpenRTM_aist/test/test_ExtTrigExecutionContext.py
Log:
ExtTrigExecutionContext and OpenHRPExecutionContext have been updated. refs #2323
Modified: branches/work/OpenRTM-aist-Python/OpenRTM_aist/ExtTrigExecutionContext.py
===================================================================
--- branches/work/OpenRTM-aist-Python/OpenRTM_aist/ExtTrigExecutionContext.py 2012-03-14 08:33:13 UTC (rev 539)
+++ branches/work/OpenRTM-aist-Python/OpenRTM_aist/ExtTrigExecutionContext.py 2012-03-14 08:39:40 UTC (rev 540)
@@ -20,9 +20,9 @@
import time
import OpenRTM_aist
+import OpenRTM, OpenRTM__POA, RTC, RTC__POA
-
##
# @if jp
# @class ExtTrigExecutionContext
@@ -37,11 +37,12 @@
# @else
# @class ExtTrigExecutionContext
# @endif
-class ExtTrigExecutionContext(OpenRTM_aist.PeriodicExecutionContext):
+class ExtTrigExecutionContext(OpenRTM_aist.ExecutionContextBase,
+ OpenRTM__POA.ExtTrigExecutionContextService,
+ OpenRTM_aist.Task):
"""
"""
-
##
# @if jp
# @brief コンストラクタ
@@ -54,62 +55,407 @@
# @brief Constructor
# @endif
def __init__(self):
- OpenRTM_aist.PeriodicExecutionContext.__init__(self)
- self._worker = self.Worker()
- self._rtcout = OpenRTM_aist.Manager.instance().getLogbuf("rtobject.exttrig_ec")
+ self._rtcout = OpenRTM_aist.Manager.instance().getLogbuf("rtobject.exttrig_async_ec")
+ self._rtcout.RTC_TRACE("ExtTrigExecutionContext.__init__()")
+ OpenRTM_aist.ExecutionContextBase.__init__(self,"exttrig_async_ec")
+ OpenRTM_aist.Task.__init__(self)
+ # getting my reference
+ self.setObjRef(self._this())
+
+ # profile initialization
+ self.setKind(RTC.PERIODIC)
+ self.setRate(OpenRTM_aist.DEFAULT_EXECUTION_RATE)
+
+ self._rtcout.RTC_DEBUG("Actual period: %d [sec], %d [usec]",
+ (self._profile.getPeriod().sec(), self._profile.getPeriod().usec()))
+ self._svc = False
+ self._workerthread = self.Worker()
+ self._svcmutex = threading.RLock()
+ return
+
+
+ def __del__(self):
+ self._rtcout.RTC_TRACE("ExtTrigExecutionContext.__del__()")
+ guard = OpenRTM_aist.ScopedLock(self._svcmutex)
+ self._svc = False
+ del guard
+
+ guard = OpenRTM_aist.ScopedLock(self._workerthread._mutex)
+ self._workerthread._cond.acquire()
+ self._workerthread._ticked = True
+ self._workerthread._cond.notify()
+ self._workerthread._cond.release()
+ del guard
+ self.wait()
+ Task.__del__(self)
+ return
+
+
##
+ # Start activity
+ # ACE_Task class method over ride.
+ # ------------------------------------------------------------
+
+ ##
# @if jp
- # @brief 処理を1ステップ進める
- #
- # ExecutionContextの処理を1周期分進める。
- #
- # @param self
- #
+ # @brief ExecutionContext用アクティビティスレッドを生成する
# @else
- #
+ # @brief Generate internal activity thread for ExecutionContext
# @endif
+ # int ExtTrigExecutionContext::open(void *args)
+ def open(self, *args):
+ self._rtcout.RTC_TRACE("open()")
+ self.activate()
+ return 0
+
+
+ ##
+ # @if jp
+ # @brief 各 Component の処理を呼び出す。
+ # @else
+ # @brief Invoke each component's operation
+ # @endif
+ # int ExtTrigExecutionContext::svc(void)
+ def svc(self):
+ self._rtcout.RTC_TRACE("svc()")
+
+ toSTR_ = lambda x: "True" if x else "False"
+
+ while self.threadRunning():
+ guard = OpenRTM_aist.ScopedLock(self._workerthread._mutex)
+ self._rtcout.RTC_DEBUG("Start of worker invocation. ticked = %s",
+ toSTR_(self._workerthread._ticked))
+
+ while not self._workerthread._ticked:
+ self._workerthread._cond.wait() # wait for tick
+ self._rtcout.RTC_DEBUG("Thread was woken up.")
+
+ if not self._workerthread._ticked:
+ continue
+ del guard
+
+ t0_ = OpenRTM_aist.Time()
+ OpenRTM_aist.ExecutionContextBase.invokeWorkerPreDo(self)
+ OpenRTM_aist.ExecutionContextBase.invokeWorkerDo(self)
+ OpenRTM_aist.ExecutionContextBase.invokeWorkerPostDo(self)
+ t1_ = OpenRTM_aist.Time()
+ guard = OpenRTM_aist.ScopedLock(self._workerthread._mutex)
+ self._workerthread._ticked = False
+ del guard
+
+ period_ = self.getPeriod()
+
+ exctm_ = (t1_ - t0_).getTime().toDouble()
+ slptm_ = period_.toDouble() - exctm_
+ self._rtcout.RTC_PARANOID("Period: %f [s]", period_.toDouble())
+ self._rtcout.RTC_PARANOID("Execution: %f [s]", exctm_)
+ self._rtcout.RTC_PARANOID("Sleep: %f [s]", slptm_)
+
+ t2_ = OpenRTM_aist.Time()
+
+ if period_.toDouble() > ((t1_ - t0_).getTime().toDouble()):
+ self._rtcout.RTC_PARANOID("sleeping...")
+ slptm_ = period_.toDouble() - (t1_ - t0_).getTime().toDouble()
+ time.sleep(slptm_)
+
+ t3_ = OpenRTM_aist.Time()
+ self._rtcout.RTC_PARANOID("Slept: %f [s]", (t3_ - t2_).getTime().toDouble())
+ return 0
+
+
+ ##
+ # @if jp
+ # @brief ExecutionContext 用のスレッド実行関数
+ # @else
+ # @brief Thread execution function for ExecutionContext
+ # @endif
+ # int ExtTrigExecutionContext::close(unsigned long flags)
+ def close(self, flags):
+ self._rtcout.RTC_TRACE("close()")
+ # At this point, this component have to be finished.
+ # Current state and Next state should be RTC_EXITING.
+ return 0
+
+
+ #============================================================
+ # ExtTrigExecutionContextService
+ #============================================================
+
+ ##
+ # @if jp
+ # @brief 処理を1ステップ進める
+ # @else
+ # @brief Move forward one step of ExecutionContext
+ # @endif
+ # void ExtTrigExecutionContext::tick()
+ # throw (CORBA::SystemException)
def tick(self):
self._rtcout.RTC_TRACE("tick()")
- if not self._worker._cond.acquire():
+ if not self.isRunning():
+ self._rtcout.RTC_DEBUG("EC is not running. do nothing.")
return
- self._worker._called = True
- self._worker._cond.notify()
- self._worker._cond.release()
+
+ guard = OpenRTM_aist.ScopedLock(self._workerthread._mutex)
+ self._workerthread._ticked = True
+ self._workerthread._cond.acquire()
+ self._workerthread._cond.notify()
+ self._workerthread._cond.release()
+ self._rtcout.RTC_PARANOID("EC was ticked. Signal was sent to worker thread.")
+ del guard
return
+
+ #============================================================
+ # ExecutionContextService
+ #============================================================
+
##
# @if jp
- # @brief 各 Component の処理を呼び出す。
- #
- # ExecutionContext に attach されている各 Component の処理を呼び出す。
- # 全 Component の処理を呼び出した後、次の呼出が発生するまで休止する。
- #
- # @param self
- #
+ # @brief ExecutionContext 実行状態確認関数
# @else
- #
+ # @brief Check for ExecutionContext running state
# @endif
- #
- def svc(self):
- self._rtcout.RTC_TRACE("svc()")
- flag = True
+ # CORBA::Boolean ExtTrigExecutionContext::is_running()
+ # throw (CORBA::SystemException)
+ def is_running(self):
+ return OpenRTM_aist.ExecutionContextBase.isRunning(self)
- while flag:
- sec_ = float(self._period.usec())/1000000.0
- self._worker._cond.acquire()
- while not self._worker._called and self._running:
- self._worker._cond.wait()
- if self._worker._called:
- self._worker._called = False
- for comp in self._comps:
- comp._sm.worker()
- self._worker._cond.release()
- flag = self._running
+ ##
+ # @if jp
+ # @brief ExecutionContext の実行を開始
+ # @else
+ # @brief Start the ExecutionContext
+ # @endif
+ # RTC::ReturnCode_t ExtTrigExecutionContext::start()
+ # throw (CORBA::SystemException)
+ def start(self):
+ return OpenRTM_aist.ExecutionContextBase.start(self)
+
##
# @if jp
+ # @brief ExecutionContext の実行を停止
+ # @else
+ # @brief Stop the ExecutionContext
+ # @endif
+ # RTC::ReturnCode_t ExtTrigExecutionContext::stop()
+ # throw (CORBA::SystemException)
+ def stop(self):
+ return OpenRTM_aist.ExecutionContextBase.stop(self)
+
+
+ ##
+ # @if jp
+ # @brief ExecutionContext の実行周期(Hz)を取得する
+ # @else
+ # @brief Get execution rate(Hz) of ExecutionContext
+ # @endif
+ # CORBA::Double ExtTrigExecutionContext::get_rate()
+ # throw (CORBA::SystemException)
+ def get_rate(self):
+ return OpenRTM_aist.ExecutionContextBase.getRate(self)
+
+
+ ##
+ # @if jp
+ # @brief ExecutionContext の実行周期(Hz)を設定する
+ # @else
+ # @brief Set execution rate(Hz) of ExecutionContext
+ # @endif
+ # RTC::ReturnCode_t ExtTrigExecutionContext::set_rate(CORBA::Double rate)
+ # throw (CORBA::SystemException)
+ def set_rate(self, rate):
+ return OpenRTM_aist.ExecutionContextBase.setRate(self, rate)
+
+
+ ##
+ # @if jp
+ # @brief RTコンポーネントを追加する
+ # @else
+ # @brief Add an RT-Component
+ # @endif
+ # RTC::ReturnCode_t
+ # ExtTrigExecutionContext::add_component(RTC::LightweightRTObject_ptr comp)
+ # throw (CORBA::SystemException)
+ def add_component(self, comp):
+ return OpenRTM_aist.ExecutionContextBase.addComponent(self, comp)
+
+
+ ##
+ # @if jp
+ # @brief コンポーネントをコンポーネントリストから削除する
+ # @else
+ # @brief Remove the RT-Component from participant list
+ # @endif
+ # RTC::ReturnCode_t ExtTrigExecutionContext::
+ # remove_component(RTC::LightweightRTObject_ptr comp)
+ # throw (CORBA::SystemException)
+ def remove_component(self, comp):
+ return OpenRTM_aist.ExecutionContextBase.removeComponent(self, comp)
+
+
+ ##
+ # @if jp
+ # @brief RTコンポーネントをアクティブ化する
+ # @else
+ # @brief Activate an RT-Component
+ # @endif
+ # RTC::ReturnCode_t ExtTrigExecutionContext::
+ # activate_component(RTC::LightweightRTObject_ptr comp)
+ # throw (CORBA::SystemException)
+ def activate_component(self, comp):
+ return OpenRTM_aist.ExecutionContextBase.activateComponent(self, comp)
+
+
+ ##
+ # @if jp
+ # @brief RTコンポーネントを非アクティブ化する
+ # @else
+ # @brief Deactivate an RT-Component
+ # @endif
+ # RTC::ReturnCode_t ExtTrigExecutionContext::
+ # deactivate_component(RTC::LightweightRTObject_ptr comp)
+ # throw (CORBA::SystemException)
+ def deactivate_component(self, comp):
+ return OpenRTM_aist.ExecutionContextBase.deactivateComponent(self, comp)
+
+
+ ##
+ # @if jp
+ # @brief RTコンポーネントをリセットする
+ # @else
+ # @brief Reset the RT-Component
+ # @endif
+ # RTC::ReturnCode_t ExtTrigExecutionContext::
+ # reset_component(RTC::LightweightRTObject_ptr comp)
+ # throw (CORBA::SystemException)
+ def reset_component(self, comp):
+ return OpenRTM_aist.ExecutionContextBase.resetComponent(self, comp)
+
+
+ ##
+ # @if jp
+ # @brief RTコンポーネントの状態を取得する
+ # @else
+ # @brief Get RT-Component's state
+ # @endif
+ # RTC::LifeCycleState ExtTrigExecutionContext::
+ # get_component_state(RTC::LightweightRTObject_ptr comp)
+ # throw (CORBA::SystemException)
+ def get_component_state(self, comp):
+ return OpenRTM_aist.ExecutionContextBase.getComponentState(self, comp)
+
+
+ ##
+ # @if jp
+ # @brief ExecutionKind を取得する
+ # @else
+ # @brief Get the ExecutionKind
+ # @endif
+ # RTC::ExecutionKind ExtTrigExecutionContext::get_kind()
+ # throw (CORBA::SystemException)
+ def get_kind(self):
+ return OpenRTM_aist.ExecutionContextBase.getKind(self)
+
+
+ #------------------------------------------------------------
+ # ExecutionContextService interfaces
+ #------------------------------------------------------------
+
+ ##
+ # @if jp
+ # @brief ExecutionContextProfile を取得する
+ # @else
+ # @brief Get the ExecutionContextProfile
+ # @endif
+ # RTC::ExecutionContextProfile* ExtTrigExecutionContext::get_profile()
+ # throw (CORBA::SystemException)
+ def get_profile(self):
+ return OpenRTM_aist.ExecutionContextBase.getProfile(self)
+
+
+ #============================================================
+ # protected functions
+ #============================================================
+
+ ##
+ # @brief onStarted() template function
+ # RTC::ReturnCode_t ExtTrigExecutionContext::onStarted()
+ def onStarted(self):
+ # change EC thread state
+ guard = OpenRTM_aist.ScopedLock(self._svcmutex)
+ if not self._svc:
+ # If start() is called first time, start the worker thread.
+ self._svc = True
+ self.open(0)
+
+ return RTC.RTC_OK
+
+
+ ##
+ # @brief onWaitingActivated() template function
+ # RTC::ReturnCode_t ExtTrigExecutionContext::
+ # onWaitingActivated(RTC_impl::RTObjectStateMachine* comp, long int count)
+ def onWaitingActivated(self, comp, count):
+ self._rtcout.RTC_TRACE("onWaitingActivated(count = %d)", count)
+ self._rtcout.RTC_PARANOID("curr: %s, next: %s",
+ (self.getStateString(comp.getStates().curr),
+ self.getStateString(comp.getStates().next)))
+ # Now comp's next state must be ACTIVE state
+ # If worker thread is stopped, restart worker thread.
+ guard = OpenRTM_aist.ScopedLock(self._workerthread._mutex)
+ self._workerthread._ticked = True
+ self._workerthread._cond.acquire()
+ self._workerthread._cond.notify()
+ self._workerthread._cond.release()
+ return RTC.RTC_OK
+
+
+ ##
+ # @brief onWaitingDeactivated() template function
+ # RTC::ReturnCode_t ExtTrigExecutionContext::
+ # onWaitingDeactivated(RTC_impl::RTObjectStateMachine* comp, long int count)
+ def onWaitingDeactivated(self, comp, count):
+ self._rtcout.RTC_TRACE("onWaitingDeactivated(count = %d)", count)
+ self._rtcout.RTC_PARANOID("curr: %s, next: %s",
+ (self.getStateString(comp.getStates().curr),
+ self.getStateString(comp.getStates().next)))
+ guard = OpenRTM_aist.ScopedLock(self._workerthread._mutex)
+ self._workerthread._ticked = True
+ self._workerthread._cond.acquire()
+ self._workerthread._cond.notify()
+ self._workerthread._cond.release()
+ return RTC.RTC_OK
+
+
+ ##
+ # @brief onWaitingReset() template function
+ # RTC::ReturnCode_t ExtTrigExecutionContext::
+ # onWaitingReset(RTC_impl::RTObjectStateMachine* comp, long int count)
+ def onWaitingReset(self, comp, count):
+ self._rtcout.RTC_TRACE("onWaitingReset(count = %d)", count)
+ self._rtcout.RTC_PARANOID("curr: %s, next: %s",
+ (self.getStateString(comp.getStates().curr),
+ self.getStateString(comp.getStates().next)))
+ guard = OpenRTM_aist.ScopedLock(self._workerthread._mutex)
+ self._workerthread._ticked = True
+ self._workerthread._cond.acquire()
+ self._workerthread._cond.notify()
+ self._workerthread._cond.release()
+ return RTC.RTC_OK
+
+
+ # bool threadRunning()
+ def threadRunning(self):
+ guard = OpenRTM_aist.ScopedLock(self._svcmutex)
+ return self._svc
+
+
+
+ ##
+ # @if jp
# @class Worker
# @brief ExecutionContext 駆動クラス
#
@@ -138,7 +484,7 @@
def __init__(self):
self._mutex = threading.RLock()
self._cond = threading.Condition(self._mutex)
- self._called = False
+ self._ticked = False
@@ -153,6 +499,6 @@
#
# @endif
def ExtTrigExecutionContextInit(manager):
- manager.registerECFactory("ExtTrigExecutionContext",
- OpenRTM_aist.ExtTrigExecutionContext,
- OpenRTM_aist.ECDelete)
+ OpenRTM_aist.ExecutionContextFactory.instance().addFactory("ExtTrigExecutionContext",
+ OpenRTM_aist.ExtTrigExecutionContext,
+ OpenRTM_aist.ECDelete)
Modified: branches/work/OpenRTM-aist-Python/OpenRTM_aist/OpenHRPExecutionContext.py
===================================================================
--- branches/work/OpenRTM-aist-Python/OpenRTM_aist/OpenHRPExecutionContext.py 2012-03-14 08:33:13 UTC (rev 539)
+++ branches/work/OpenRTM-aist-Python/OpenRTM_aist/OpenHRPExecutionContext.py 2012-03-14 08:39:40 UTC (rev 540)
@@ -14,25 +14,260 @@
# Advanced Industrial Science and Technology (AIST), Japan
# All rights reserved.
+import threading
+import time
import OpenRTM_aist
+import OpenRTM, OpenRTM__POA, RTC, RTC__POA
-class OpenHRPExecutionContext(OpenRTM_aist.PeriodicExecutionContext):
- def __init__(self):
- OpenRTM_aist.PeriodicExecutionContext.__init__(self)
- return
+class OpenHRPExecutionContext(OpenRTM_aist.ExecutionContextBase,
+ OpenRTM__POA.ExtTrigExecutionContextService):
+ """
+ """
+ def __init__(self):
+ self._rtcout = OpenRTM_aist.Manager.instance().getLogbuf("rtobject.exttrig_sync_ec")
+ self._rtcout.RTC_TRACE("OpenHRPExecutionContext.__init__()")
+ OpenRTM_aist.ExecutionContextBase.__init__(self, "exttrig_sync_ec")
- def tick(self):
- for comp in self._comps:
- comp._sm.worker()
+ self.setObjRef(self._this())
+ self.setKind(RTC.PERIODIC)
+ self.setRate(OpenRTM_aist.DEFAULT_EXECUTION_RATE)
+ self._rtcout.RTC_DEBUG("Actual rate: %d [sec], %d [usec]",
+ (self._profile.getPeriod().sec(), self._profile.getPeriod().usec()))
+ self._tickmutex = threading.RLock()
+ self._count = 0
+ return
- def svc(self):
- return 0
+ def __del__(self):
+ self._rtcout.RTC_TRACE("OpenHRPExecutionContext().__del__()")
+ return
+
+ #============================================================
+ # OpenHRPExecutionContextService
+ #============================================================
+ ##
+ # @if jp
+ # @brief 処理を1ステップ進める
+ # @else
+ # @brief Move forward one step of ExecutionContext
+ # @endif
+ def tick(self):
+ self._rtcout.RTC_TRACE("tick()")
+ if not self.isRunning():
+ return
+
+ guard = OpenRTM_aist.ScopedLock(self._tickmutex)
+
+ OpenRTM_aist.ExecutionContextBase.invokeWorkerPreDo(self) # update state
+ t0 = OpenRTM_aist.Time()
+ OpenRTM_aist.ExecutionContextBase.invokeWorkerDo(self)
+ t1 = OpenRTM_aist.Time()
+ OpenRTM_aist.ExecutionContextBase.invokeWorkerPostDo(self)
+ t2 = OpenRTM_aist.Time()
+
+ period = self.getPeriod()
+
+ if self._count > 1000:
+ excdotm = (t1 - t0).getTime().toDouble()
+ excpdotm = (t2 - t1).getTime().toDouble()
+ slptm = period.toDouble() - (t2 - t0).getTime().toDouble()
+ self._rtcout.RTC_PARANOID("Period: %f [s]", period.toDouble())
+ self._rtcout.RTC_PARANOID("Exec-Do: %f [s]", excdotm)
+ self._rtcout.RTC_PARANOID("Exec-PostDo: %f [s]", excpdotm)
+ self._rtcout.RTC_PARANOID("Sleep: %f [s]", slptm)
+
+ t3 = OpenRTM_aist.Time()
+ if period.toDouble() > (t2 - t0).getTime().toDouble():
+ if self._count > 1000:
+ self._rtcout.RTC_PARANOID("sleeping...")
+ slptm = period.toDouble() - (t2 - t0).getTime().toDouble()
+ time.sleep(slptm)
+
+ if self._count > 1000:
+ t4 = OpenRTM_aist.Time()
+ self._rtcout.RTC_PARANOID("Slept: %f [s]", (t4 - t3).getTime().toDouble())
+ self._count = 0
+
+ self._count += 1
+ return
+
+
+ #============================================================
+ # ExecutionContextService
+ #============================================================
+ ##
+ # @if jp
+ # @brief ExecutionContext 実行状態確認関数
+ # @else
+ # @brief Check for ExecutionContext running state
+ # @endif
+ # CORBA::Boolean OpenHRPExecutionContext::is_running()
+ # throw (CORBA::SystemException)
+ def is_running(self):
+ return OpenRTM_aist.ExecutionContextBase.isRunning(self)
+
+
+ ##
+ # @if jp
+ # @brief ExecutionContext の実行を開始
+ # @else
+ # @brief Start the ExecutionContext
+ # @endif
+ # RTC::ReturnCode_t OpenHRPExecutionContext::start()
+ # throw (CORBA::SystemException)
+ def start(self):
+ return OpenRTM_aist.ExecutionContextBase.start(self)
+
+
+ ##
+ # @if jp
+ # @brief ExecutionContext の実行を停止
+ # @else
+ # @brief Stop the ExecutionContext
+ # @endif
+ # RTC::ReturnCode_t OpenHRPExecutionContext::stop()
+ # throw (CORBA::SystemException)
+ def stop(self):
+ return OpenRTM_aist.ExecutionContextBase.stop(self)
+
+
+ ##
+ # @if jp
+ # @brief ExecutionContext の実行周期(Hz)を取得する
+ # @else
+ # @brief Get execution rate(Hz) of ExecutionContext
+ # @endif
+ # CORBA::Double OpenHRPExecutionContext::get_rate()
+ # throw (CORBA::SystemException)
+ def get_rate(self):
+ return OpenRTM_aist.ExecutionContextBase.getRate(self)
+
+
+ ##
+ # @if jp
+ # @brief ExecutionContext の実行周期(Hz)を設定する
+ # @else
+ # @brief Set execution rate(Hz) of ExecutionContext
+ # @endif
+ # RTC::ReturnCode_t OpenHRPExecutionContext::set_rate(CORBA::Double rate)
+ # throw (CORBA::SystemException)
+ def set_rate(self, rate):
+ return OpenRTM_aist.ExecutionContextBase.setRate(self, rate)
+
+
+ ##
+ # @if jp
+ # @brief RTコンポーネントを追加する
+ # @else
+ # @brief Add an RT-Component
+ # @endif
+ # RTC::ReturnCode_t
+ # OpenHRPExecutionContext::add_component(RTC::LightweightRTObject_ptr comp)
+ # throw (CORBA::SystemException)
+ def add_component(self, comp):
+ return OpenRTM_aist.ExecutionContextBase.addComponent(self, comp)
+
+
+ ##
+ # @if jp
+ # @brief コンポーネントをコンポーネントリストから削除する
+ # @else
+ # @brief Remove the RT-Component from participant list
+ # @endif
+ # RTC::ReturnCode_t OpenHRPExecutionContext::
+ # remove_component(RTC::LightweightRTObject_ptr comp)
+ # throw (CORBA::SystemException)
+ def remove_component(self, comp):
+ return OpenRTM_aist.ExecutionContextBase.removeComponent(self, comp)
+
+
+ ##
+ # @if jp
+ # @brief RTコンポーネントをアクティブ化する
+ # @else
+ # @brief Activate an RT-Component
+ # @endif
+ # RTC::ReturnCode_t OpenHRPExecutionContext::
+ # activate_component(RTC::LightweightRTObject_ptr comp)
+ # throw (CORBA::SystemException)
+ def activate_component(self, comp):
+ return OpenRTM_aist.ExecutionContextBase.activateComponent(self, comp)
+
+
+ ##
+ # @if jp
+ # @brief RTコンポーネントを非アクティブ化する
+ # @else
+ # @brief Deactivate an RT-Component
+ # @endif
+ # RTC::ReturnCode_t OpenHRPExecutionContext::
+ # deactivate_component(RTC::LightweightRTObject_ptr comp)
+ # throw (CORBA::SystemException)
+ def deactivate_component(self, comp):
+ return OpenRTM_aist.ExecutionContextBase.deactivateComponent(self, comp)
+
+
+ ##
+ # @if jp
+ # @brief RTコンポーネントをリセットする
+ # @else
+ # @brief Reset the RT-Component
+ # @endif
+ # RTC::ReturnCode_t OpenHRPExecutionContext::
+ # reset_component(RTC::LightweightRTObject_ptr comp)
+ # throw (CORBA::SystemException)
+ def reset_component(self, comp):
+ return OpenRTM_aist.ExecutionContextBase.resetComponent(self, comp)
+
+
+ ##
+ # @if jp
+ # @brief RTコンポーネントの状態を取得する
+ # @else
+ # @brief Get RT-Component's state
+ # @endif
+ # RTC::LifeCycleState OpenHRPExecutionContext::
+ # get_component_state(RTC::LightweightRTObject_ptr comp)
+ # throw (CORBA::SystemException)
+ # get_component_state(RTC::LightweightRTObject_ptr comp)
+ # throw (CORBA::SystemException)
+ def get_component_state(self, comp):
+ return OpenRTM_aist.ExecutionContextBase.getComponentState(self, comp)
+
+
+ ##
+ # @if jp
+ # @brief ExecutionKind を取得する
+ # @else
+ # @brief Get the ExecutionKind
+ # @endif
+ # RTC::ExecutionKind OpenHRPExecutionContext::get_kind()
+ # throw (CORBA::SystemException)
+ def get_kind(self):
+ return OpenRTM_aist.ExecutionContextBase.getKind(self)
+
+
+ #------------------------------------------------------------
+ # ExecutionContextService interfaces
+ #------------------------------------------------------------
+ ##
+ # @if jp
+ # @brief ExecutionContextProfile を取得する
+ # @else
+ # @brief Get the ExecutionContextProfile
+ # @endif
+ # RTC::ExecutionContextProfile* OpenHRPExecutionContext::get_profile()
+ # throw (CORBA::SystemException)
+ def get_profile(self):
+ return OpenRTM_aist.ExecutionContextBase.getProfile(self)
+
+
def OpenHRPExecutionContextInit(manager):
- manager.registerECFactory("OpenHRPExecutionContext",
- OpenRTM_aist.OpenHRPExecutionContext,
- OpenRTM_aist.ECDelete)
+ OpenRTM_aist.ExecutionContextFactory.instance().addFactory("OpenHRPExecutionContext",
+ OpenRTM_aist.OpenHRPExecutionContext,
+ OpenRTM_aist.ECDelete)
+ return
Modified: branches/work/OpenRTM-aist-Python/OpenRTM_aist/test/test_ExtTrigExecutionContext.py
===================================================================
--- branches/work/OpenRTM-aist-Python/OpenRTM_aist/test/test_ExtTrigExecutionContext.py 2012-03-14 08:33:13 UTC (rev 539)
+++ branches/work/OpenRTM-aist-Python/OpenRTM_aist/test/test_ExtTrigExecutionContext.py 2012-03-14 08:39:40 UTC (rev 540)
@@ -45,6 +45,7 @@
self._dfp._poa._get_the_POAManager().activate()
self.etec = ExtTrigExecutionContext()
#self.etec = ExtTrigExecutionContext(self._dfp._ref)
+ return
def tearDown(self):
OpenRTM_aist.Manager.instance().shutdownManager()
@@ -56,6 +57,8 @@
def test_run(self):
self.assertEqual(self.etec.start(),RTC.RTC_OK)
self.assertEqual(self.etec.add_component(self._dfp._this()),RTC.RTC_OK)
+ self.etec.start()
+ self.etec.invokeWorker()
self.assertEqual(self.etec.activate_component(self._dfp._this()),RTC.RTC_OK)
import time
time.sleep(1)
@@ -72,9 +75,12 @@
th.join()
self._dfp._poa.deactivate_object(self._dfp._poa.servant_to_id(self.etec))
self._dfp._poa.deactivate_object(self._dfp._poa.servant_to_id(self._dfp))
+ self.etec.stop()
+ return
def stop(self):
self.etec.stop()
+ return
############### test #################
if __name__ == '__main__':
openrtm-commit メーリングリストの案内