[openrtm-commit:02628] r3000 - trunk/OpenRTM-aist/src/lib/rtm
openrtm @ openrtm.org
openrtm @ openrtm.org
2017年 6月 12日 (月) 17:14:36 JST
Author: miyamoto
Date: 2017-06-12 17:14:36 +0900 (Mon, 12 Jun 2017)
New Revision: 3000
Added:
trunk/OpenRTM-aist/src/lib/rtm/SimulatorExecutionContext.cpp
trunk/OpenRTM-aist/src/lib/rtm/SimulatorExecutionContext.h
Modified:
trunk/OpenRTM-aist/src/lib/rtm/Makefile.am
trunk/OpenRTM-aist/src/lib/rtm/OpenHRPExecutionContext.h
Log:
[incompat, Choreonoid] add SimulatorExecutionContext
Modified: trunk/OpenRTM-aist/src/lib/rtm/Makefile.am
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/Makefile.am 2017-06-04 23:53:03 UTC (rev 2999)
+++ trunk/OpenRTM-aist/src/lib/rtm/Makefile.am 2017-06-12 08:14:36 UTC (rev 3000)
@@ -89,7 +89,8 @@
SdoConfiguration.cpp \
SdoServiceAdmin.cpp \
SdoOrganization.cpp \
- PeriodicECSharedComposite.cpp
+ PeriodicECSharedComposite.cpp\
+ SimulatorExecutionContext.cpp
PORT_SRC = \
InPortConnector.cpp \
Modified: trunk/OpenRTM-aist/src/lib/rtm/OpenHRPExecutionContext.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/OpenHRPExecutionContext.h 2017-06-04 23:53:03 UTC (rev 2999)
+++ trunk/OpenRTM-aist/src/lib/rtm/OpenHRPExecutionContext.h 2017-06-12 08:14:36 UTC (rev 3000)
@@ -488,17 +488,21 @@
virtual RTC::ExecutionContextProfile* get_profile(void)
throw (CORBA::SystemException);
protected:
- // template virtual functions adding/removing component
- /*!
- * @brief onAddedComponent() template function
- */
- virtual RTC::ReturnCode_t
+ // template virtual functions adding/removing component
+ /*!
+ * @brief onAddedComponent() template function
+ */
+ virtual RTC::ReturnCode_t
onAddedComponent(RTC::LightweightRTObject_ptr rtobj);
- /*!
- * @brief onRemovedComponent() template function
- */
- virtual RTC::ReturnCode_t
+ /*!
+ * @brief onRemovedComponent() template function
+ */
+ virtual RTC::ReturnCode_t
onRemovedComponent(RTC::LightweightRTObject_ptr rtobj);
+ /*!
+ * @brief Mutex to gurad tick() reenter.
+ */
+ coil::Mutex m_tickmutex;
private:
/*!
* @if jp
@@ -513,10 +517,7 @@
* @brief A counter for log message in worker
*/
unsigned int m_count;
- /*!
- * @brief Mutex to gurad tick() reenter.
- */
- coil::Mutex m_tickmutex;
+
}; // class OpenHRPExecutionContext
}; // namespace RTC
Added: trunk/OpenRTM-aist/src/lib/rtm/SimulatorExecutionContext.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/SimulatorExecutionContext.cpp (rev 0)
+++ trunk/OpenRTM-aist/src/lib/rtm/SimulatorExecutionContext.cpp 2017-06-12 08:14:36 UTC (rev 3000)
@@ -0,0 +1,136 @@
+#include "SimulatorExecutionContext.h"
+#include <rtm/ECFactory.h>
+
+#ifdef OPENRTM_VERSION110
+#else
+#include <rtm/RTObjectStateMachine.h>
+#endif
+
+
+
+namespace RTC
+{
+
+ SimulatorExecutionContext::SimulatorExecutionContext()
+ : RTC::OpenHRPExecutionContext()
+ {
+
+
+
+ }
+
+
+ SimulatorExecutionContext::~SimulatorExecutionContext()
+ {
+
+ }
+
+
+
+ RTC::ReturnCode_t SimulatorExecutionContext::
+ activate_component(RTC::LightweightRTObject_ptr comp)
+ throw (CORBA::SystemException)
+ {
+ Guard guard(m_tickmutex);
+
+ RTC_impl::RTObjectStateMachine* rtobj = m_worker.findComponent(comp);
+
+ if (rtobj == NULL)
+ {
+ return RTC::BAD_PARAMETER;
+ }
+ if (!(rtobj->isCurrentState(RTC::INACTIVE_STATE)))
+ {
+ return RTC::PRECONDITION_NOT_MET;
+ }
+ m_syncActivation = false;
+
+ RTC::ReturnCode_t ret = ExecutionContextBase::activateComponent(comp);
+ invokeWorkerPreDo();
+ if ((rtobj->isCurrentState(RTC::ACTIVE_STATE)))
+ {
+ return RTC::RTC_OK;
+ }
+ return RTC::RTC_ERROR;
+
+ }
+
+
+ RTC::ReturnCode_t SimulatorExecutionContext::
+ deactivate_component(RTC::LightweightRTObject_ptr comp)
+ throw (CORBA::SystemException)
+ {
+ Guard guard(m_tickmutex);
+
+ RTC_impl::RTObjectStateMachine* rtobj = m_worker.findComponent(comp);
+
+ if (rtobj == NULL)
+ {
+ return RTC::BAD_PARAMETER;
+ }
+ if (!(rtobj->isCurrentState(RTC::ACTIVE_STATE)))
+ {
+ return RTC::PRECONDITION_NOT_MET;
+ }
+ m_syncDeactivation = false;
+ RTC::ReturnCode_t ret = ExecutionContextBase::deactivateComponent(comp);
+ invokeWorkerPreDo();
+ invokeWorkerDo();
+ invokeWorkerPostDo();
+
+ if ((rtobj->isCurrentState(RTC::INACTIVE_STATE)))
+ {
+ return RTC::RTC_OK;
+ }
+ return RTC::RTC_ERROR;
+
+ }
+
+ RTC::ReturnCode_t SimulatorExecutionContext::
+ reset_component(RTC::LightweightRTObject_ptr comp)
+ throw (CORBA::SystemException)
+ {
+ Guard guard(m_tickmutex);
+
+ RTC_impl::RTObjectStateMachine* rtobj = m_worker.findComponent(comp);
+
+ if (rtobj == NULL)
+ {
+ return RTC::BAD_PARAMETER;
+ }
+ if (!(rtobj->isCurrentState(RTC::ERROR_STATE)))
+ {
+ return RTC::PRECONDITION_NOT_MET;
+ }
+ m_syncReset = false;
+ RTC::ReturnCode_t ret = ExecutionContextBase::resetComponent(comp);
+ invokeWorkerPreDo();
+ invokeWorkerDo();
+ invokeWorkerPostDo();
+
+ if ((rtobj->isCurrentState(RTC::INACTIVE_STATE)))
+ {
+ return RTC::RTC_OK;
+ }
+ return RTC::RTC_ERROR;
+
+
+ }
+
+};
+
+
+
+
+extern "C"
+{
+ void SimulatorExecutionContextInit(RTC::Manager* manager)
+ {
+ RTC::ExecutionContextFactory::
+ instance().addFactory("SimulatorExecutionContext",
+ ::coil::Creator< ::RTC::ExecutionContextBase,
+ ::RTC::SimulatorExecutionContext>,
+ ::coil::Destructor< ::RTC::ExecutionContextBase,
+ ::RTC::SimulatorExecutionContext>);
+ }
+};
\ No newline at end of file
Added: trunk/OpenRTM-aist/src/lib/rtm/SimulatorExecutionContext.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/SimulatorExecutionContext.h (rev 0)
+++ trunk/OpenRTM-aist/src/lib/rtm/SimulatorExecutionContext.h 2017-06-12 08:14:36 UTC (rev 3000)
@@ -0,0 +1,50 @@
+#ifndef TEST_EC_H
+#define TEST_EC_H
+
+
+
+#include <coil/Mutex.h>
+#include <coil/Guard.h>
+#include <rtm/RTC.h>
+#include <rtm/ExecutionContextBase.h>
+#include <rtm/OpenHRPExecutionContext.h>
+
+
+namespace RTC
+{
+ class SimulatorExecutionContext
+ : public virtual RTC::OpenHRPExecutionContext
+ {
+ typedef coil::Mutex Mutex;
+ typedef coil::Guard<coil::Mutex> Guard;
+ public:
+ SimulatorExecutionContext();
+ virtual ~SimulatorExecutionContext(void);
+
+ virtual RTC::ReturnCode_t
+ activate_component(RTC::LightweightRTObject_ptr comp)
+ throw (CORBA::SystemException);
+ virtual RTC::ReturnCode_t
+ deactivate_component(RTC::LightweightRTObject_ptr comp)
+ throw (CORBA::SystemException);
+ virtual RTC::ReturnCode_t
+ reset_component(RTC::LightweightRTObject_ptr comp)
+ throw (CORBA::SystemException);
+
+ private:
+
+ };
+};
+
+
+
+#ifdef WIN32
+#pragma warning( default : 4290 )
+#endif
+
+extern "C"
+{
+ DLL_EXPORT void SimulatorExecutionContextInit(RTC::Manager* manager);
+};
+
+#endif
\ No newline at end of file
More information about the openrtm-commit
mailing list