[openrtm-commit:00560] r2269 - trunk/OpenRTM-aist/src/lib/rtm

openrtm @ openrtm.org openrtm @ openrtm.org
2012年 1月 9日 (月) 22:19:21 JST


Author: n-ando
Date: 2012-01-09 22:19:20 +0900 (Mon, 09 Jan 2012)
New Revision: 2269

Modified:
   trunk/OpenRTM-aist/src/lib/rtm/ExecutionContextProfile.cpp
   trunk/OpenRTM-aist/src/lib/rtm/ExecutionContextProfile.h
Log:
[incompatible] setPeriod() and getPeriod() functions have been added. Now execution rate and period can be set and got.


Modified: trunk/OpenRTM-aist/src/lib/rtm/ExecutionContextProfile.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/ExecutionContextProfile.cpp	2012-01-09 05:22:21 UTC (rev 2268)
+++ trunk/OpenRTM-aist/src/lib/rtm/ExecutionContextProfile.cpp	2012-01-09 13:19:20 UTC (rev 2269)
@@ -77,6 +77,8 @@
   void ExecutionContextProfile::
   setObjRef(RTC::ExecutionContextService_ptr ec_ptr)
   {
+    RTC_TRACE(("setObjRef()"));
+    Guard guard(m_profileMutex);
     m_ref = RTC::ExecutionContextService::_duplicate(ec_ptr);
   }
 
@@ -90,6 +92,8 @@
   RTC::ExecutionContextService_ptr
   ExecutionContextProfile::getObjRef(void) const
   {
+    RTC_TRACE(("getObjRef()"));
+    Guard guard(m_profileMutex);
     return RTC::ExecutionContextService::_duplicate(m_ref);
   }
 
@@ -110,7 +114,27 @@
     m_period = coil::TimeValue(1.0/rate);
     return RTC::RTC_OK;
   }
+  RTC::ReturnCode_t ExecutionContextProfile::setPeriod(double period)
+  {
+    RTC_TRACE(("setPeriod(%f [sec])", period));
+    if (period < 0.0) { return RTC::BAD_PARAMETER; }
 
+    Guard guard(m_profileMutex);
+    m_profile.rate = 1.0 / period;
+    m_period = coil::TimeValue(period);
+    return RTC::RTC_OK;
+  }
+  RTC::ReturnCode_t ExecutionContextProfile::setPeriod(coil::TimeValue period)
+  {
+    RTC_TRACE(("setPeriod(%f [sec])", (double)period));
+    if ((double)period < 0.0) { return RTC::BAD_PARAMETER; }
+
+    Guard guard(m_profileMutex);
+    m_profile.rate = 1.0 / (double)period;
+    m_period = period;
+    return RTC::RTC_OK;
+  }
+
   /*!
    * @if jp
    * @brief ExecutionContext の実行周期(Hz)を取得する
@@ -125,6 +149,13 @@
     return m_profile.rate;
   }
 
+  coil::TimeValue ExecutionContextProfile::getPeriod() const
+  {
+    RTC_TRACE(("getPeriod()"));
+    Guard guard(m_profileMutex);
+    return m_period;
+  }
+
   /*!
    * @if jp
    * @brief ExecutionKind を文字列化する

Modified: trunk/OpenRTM-aist/src/lib/rtm/ExecutionContextProfile.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/ExecutionContextProfile.h	2012-01-09 05:22:21 UTC (rev 2268)
+++ trunk/OpenRTM-aist/src/lib/rtm/ExecutionContextProfile.h	2012-01-09 13:19:20 UTC (rev 2269)
@@ -169,6 +169,8 @@
      * @endif
      */
     RTC::ReturnCode_t setRate(double rate);
+    RTC::ReturnCode_t setPeriod(double period);
+    RTC::ReturnCode_t setPeriod(coil::TimeValue period);
 
     /*!
      * @if jp
@@ -191,6 +193,7 @@
      * @endif
      */
     double getRate(void) const;
+    coil::TimeValue getPeriod(void) const;
 
     /*!
      * @if jp
@@ -215,6 +218,10 @@
      * @endif
      */
     const char* getKindString(RTC::ExecutionKind kind) const;
+    const char* getKindString() const
+    {
+      return getKindString(m_profile.kind);
+    }
 
     /*!
      * @if jp



openrtm-commit メーリングリストの案内