[openrtm-commit:03339] r3418 - trunk/OpenRTM-aist/src/lib/rtm
openrtm @ openrtm.org
openrtm @ openrtm.org
2018年 10月 9日 (火) 09:01:37 JST
Author: miyamoto
Date: 2018-10-09 09:01:37 +0900 (Tue, 09 Oct 2018)
New Revision: 3418
Added:
trunk/OpenRTM-aist/src/lib/rtm/MultilayerCompositeEC.cpp
trunk/OpenRTM-aist/src/lib/rtm/MultilayerCompositeEC.h
Modified:
trunk/OpenRTM-aist/src/lib/rtm/Manager.cpp
trunk/OpenRTM-aist/src/lib/rtm/PeriodicECSharedComposite.cpp
trunk/OpenRTM-aist/src/lib/rtm/PeriodicECSharedComposite.h
trunk/OpenRTM-aist/src/lib/rtm/PeriodicExecutionContext.cpp
Log:
[inconpat] Implementation of multilayer composite component.
Modified: trunk/OpenRTM-aist/src/lib/rtm/Manager.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/Manager.cpp 2018-10-08 23:58:57 UTC (rev 3417)
+++ trunk/OpenRTM-aist/src/lib/rtm/Manager.cpp 2018-10-09 00:01:37 UTC (rev 3418)
@@ -28,6 +28,7 @@
#include <rtm/ExtTrigExecutionContext.h>
#include <rtm/OpenHRPExecutionContext.h>
#include <rtm/PeriodicECSharedComposite.h>
+#include <rtm/MultilayerCompositeEC.h>
#include <rtm/RTCUtil.h>
#include <rtm/ManagerServant.h>
#include <coil/Properties.h>
@@ -1898,6 +1899,7 @@
ExtTrigExecutionContextInit(this);
OpenHRPExecutionContextInit(this);
SimulatorExecutionContextInit(this);
+ MultilayerCompositeECInit(this);
#ifdef RTM_OS_VXWORKS
VxWorksRTExecutionContextInit(this);
#ifndef __RTP__
Added: trunk/OpenRTM-aist/src/lib/rtm/MultilayerCompositeEC.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/MultilayerCompositeEC.cpp (rev 0)
+++ trunk/OpenRTM-aist/src/lib/rtm/MultilayerCompositeEC.cpp 2018-10-09 00:01:37 UTC (rev 3418)
@@ -0,0 +1,450 @@
+// -*- C++ -*-
+/*!
+ * @file MultilayerCompositeEC.cpp
+ * @brief
+ * @date $Date: 2018-10-03 15:44:03 $
+ * @author Nobuhiko Miyamoto <n-miyamoto at aist.go.jp>
+ *
+ * Copyright (C) 2018
+ * Robot Innovation Research Center,
+ * Intelligent Systems Research Institute,
+ * National Institute of
+ * Advanced Industrial Science and Technology (AIST), Japan
+ * All rights reserved.
+ *
+ *
+ */
+
+#include <coil/Time.h>
+#include <coil/TimeValue.h>
+
+
+#include <rtm/Manager.h>
+#include <rtm/RTObject.h>
+#include <rtm/MultilayerCompositeEC.h>
+#include <rtm/RTObjectStateMachine.h>
+#include <rtm/PeriodicTaskFactory.h>
+
+#ifdef RTM_OS_LINUX
+#define _GNU_SOURCE
+#include <pthread.h>
+#include <algorithm>
+#endif // RTM_OS_LINUX
+
+#include <string.h>
+#include <algorithm>
+#include <iostream>
+#include <string>
+
+#define DEEFAULT_PERIOD 0.000001
+namespace RTC_exp
+{
+ /*!
+ * @if jp
+ * @brief デフォルトコンストラクタ
+ * @else
+ * @brief Default constructor
+ * @endif
+ */
+ MultilayerCompositeEC::
+ MultilayerCompositeEC()
+ : PeriodicExecutionContext(), m_ownersm(NULL)
+ {
+ RTC_TRACE(("MultilayerCompositeEC()"));
+ }
+
+ /*!
+ * @if jp
+ * @brief デストラクタ
+ * @else
+ * @brief Destructor
+ * @endif
+ */
+ MultilayerCompositeEC::~MultilayerCompositeEC()
+ {
+ RTC_TRACE(("~MultilayerCompositeEC()"));
+ }
+
+ void MultilayerCompositeEC::init(coil::Properties& props)
+ {
+ PeriodicExecutionContext::init(props);
+
+ }
+
+
+ /*------------------------------------------------------------
+ * Run by a daemon thread to handle deferred processing
+ * ACE_Task class method over ride.
+ *------------------------------------------------------------*/
+ /*!
+ * @if jp
+ * @brief ExecutionContext 用のスレッド実行関数
+ * @else
+ * @brief Thread execution function for ExecutionContext
+ * @endif
+ */
+ int MultilayerCompositeEC::svc(void)
+ {
+ RTC_TRACE(("svc()"));
+ int count(0);
+
+ const RTC::RTObject_ptr owner = getOwner();
+ m_ownersm = m_worker.findComponent(owner);
+
+ do
+ {
+
+ m_ownersm->workerPreDo();
+ // Thread will stopped when all RTCs are INACTIVE.
+ // Therefore WorkerPreDo(updating state) have to be invoked
+ // before stopping thread.
+ {
+ Guard guard(m_workerthread.mutex_);
+ while (!m_workerthread.running_)
+ {
+ m_workerthread.cond_.wait();
+ }
+ }
+ coil::TimeValue t0(coil::clock());
+ m_ownersm->workerDo();
+ m_ownersm->workerPostDo();
+
+
+ for (std::vector<ChildTask*>::iterator task = m_tasklist.begin(); task != m_tasklist.end(); ++task)
+ {
+ (*task)->signal();
+ }
+
+ for (std::vector<ChildTask*>::iterator task = m_tasklist.begin(); task != m_tasklist.end(); ++task)
+ {
+ (*task)->join();
+ }
+
+
+ coil::TimeValue t1(coil::clock());
+
+ coil::TimeValue period(getPeriod());
+ if (count > 1000)
+ {
+ RTC_PARANOID(("Period: %f [s]", static_cast<double>(period)));
+ RTC_PARANOID(("Execution: %f [s]", static_cast<double>(t1 - t0)));
+ RTC_PARANOID(("Sleep: %f [s]",
+ static_cast<double>(period - (t1 - t0))));
+ int task_num = 0;
+ for (std::vector<ChildTask*>::iterator task = m_tasklist.begin(); task != m_tasklist.end(); ++task)
+ {
+ coil::TimeMeasure::Statistics st = (*task)->getExecStat();
+ RTC_PARANOID(("MAX(%d): %f [s]", task_num, st.max_interval));
+ RTC_PARANOID(("MIN(%d): %f [s]", task_num, st.min_interval));
+ RTC_PARANOID(("MEAN(%d): %f [s]", task_num, st.mean_interval));
+ RTC_PARANOID(("SD(%d): %f [s]", task_num, st.std_deviation));
+ task_num += 1;
+ }
+ }
+ coil::TimeValue t2(coil::clock());
+ if (!m_nowait && period > (t1 - t0))
+ {
+ if (count > 1000) { RTC_PARANOID(("sleeping...")); }
+ coil::sleep((coil::TimeValue)(period - (t1 - t0)));
+ }
+ if (count > 1000)
+ {
+ coil::TimeValue t3(coil::clock());
+ RTC_PARANOID(("Slept: %f [s]", static_cast<double>(t3 - t2)));
+ count = 0;
+ }
+ ++count;
+ } while (threadRunning());
+ RTC_DEBUG(("Thread terminated."));
+ return 0;
+ }
+
+
+ RTC::ReturnCode_t MultilayerCompositeEC::bindComponent(RTC::RTObject_impl* rtc)
+ {
+ RTC::ReturnCode_t ret = ExecutionContextBase::bindComponent(rtc);
+ ::RTC::Manager &mgr = ::RTC::Manager::instance();
+ std::string threads_str = rtc->getProperties()["conf.default.members"];
+ coil::vstring threads = coil::split(threads_str, "|");
+
+ for (coil::vstring::iterator thread = threads.begin(); thread != threads.end(); ++thread)
+ {
+ std::vector<RTC::LightweightRTObject_ptr> rtcs;
+ coil::vstring members = coil::split(*thread, ",");
+
+ for (coil::vstring::iterator member = members.begin(); member != members.end(); ++member)
+ {
+ std::string m = *member;
+ coil::eraseBothEndsBlank(m);
+
+ if (m.empty())
+ {
+ continue;
+ }
+ else
+ {
+
+ RTC::RTObject_impl* comp = mgr.getComponent(m.c_str());
+ if (comp == NULL)
+ {
+ RTC_ERROR(("no RTC found: %s", member));
+ continue;
+ }
+ RTC::RTObject_ptr rtobj = comp->getObjRef();
+ if (CORBA::is_nil(rtobj))
+ {
+ continue;
+ }
+ rtcs.push_back(rtobj);
+ }
+ }
+ addTask(rtcs);
+ }
+ return ret;
+
+ }
+
+ RTC_impl::RTObjectStateMachine* MultilayerCompositeEC::findComponent(RTC::LightweightRTObject_ptr comp)
+ {
+ return m_worker.findComponent(comp);
+ }
+
+ void MultilayerCompositeEC::addTask(std::vector<RTC::LightweightRTObject_ptr> rtcs)
+ {
+ std::string param = "ec";
+ param += coil::otos(m_tasklist.size());
+ coil::Properties tmp(m_profile.getProperties());
+
+ coil::Properties prop = tmp.getNode(param);
+
+ RTC::PeriodicTaskFactory& factory(RTC::PeriodicTaskFactory::instance());
+
+ coil::PeriodicTaskBase* task = factory.createObject(prop.getProperty("thread_type", "default"));
+ if (task == NULL)
+ {
+ RTC_ERROR(("Task creation failed: %s",
+ prop.getProperty("thread_type", "default").c_str()));
+ return;
+ }
+
+ ChildTask *ct = new ChildTask(task, this);
+
+ task->setTask(ct, &ChildTask::svc);
+ task->setPeriod(0.0);
+ task->executionMeasure(coil::toBool(prop["measurement.exec_time"],
+ "enable", "disable", true));
+
+
+ int ecount(1000);
+ if (coil::stringTo(ecount, prop["measurement.exec_count"].c_str()))
+ {
+ task->executionMeasureCount(ecount);
+ }
+
+ task->periodicMeasure(coil::toBool(prop["measurement.period_time"],
+ "enable", "disable", true));
+ int pcount(1000);
+ if (coil::stringTo(pcount, prop["measurement.period_count"].c_str()))
+ {
+ task->periodicMeasureCount(pcount);
+ }
+
+
+ for (std::vector<RTC::LightweightRTObject_ptr>::iterator rtc = rtcs.begin(); rtc != rtcs.end(); ++rtc)
+ {
+ addRTCToTask(ct, (*rtc));
+ }
+
+ m_tasklist.push_back(ct);
+
+ // Start task in suspended mode
+ task->suspend();
+ task->activate();
+ task->suspend();
+
+ }
+
+ void MultilayerCompositeEC::addRTCToTask(ChildTask* task, RTC::LightweightRTObject_ptr rtobj)
+ {
+ ::OpenRTM::DataFlowComponent_ptr comp = ::OpenRTM::DataFlowComponent::_narrow(rtobj);
+ SDOPackage::OrganizationList_var orglist = comp->get_owned_organizations();
+
+ if (orglist->length() == 0)
+ {
+ task->addComponent(rtobj);
+ }
+ for (CORBA::ULong i(0); i < orglist->length(); ++i)
+ {
+ SDOPackage::SDOList_var sdos = orglist[i]->get_members();
+ for (CORBA::ULong j(0); j < sdos->length(); ++j)
+ {
+ ::OpenRTM::DataFlowComponent_var dfc = ::OpenRTM::DataFlowComponent::_narrow(sdos[j].in());
+ addRTCToTask(task, dfc);
+ }
+ }
+
+ }
+
+ MultilayerCompositeEC::ChildTask::ChildTask(coil::PeriodicTaskBase* task, MultilayerCompositeEC* ec) :
+ m_task(task), m_ec(ec)
+ {
+
+ }
+
+ void MultilayerCompositeEC::ChildTask::addComponent(RTC::LightweightRTObject_ptr rtc)
+ {
+ m_rtcs.push_back(rtc);
+ }
+
+ void MultilayerCompositeEC::ChildTask::updateCompList()
+ {
+ std::vector<RTC::LightweightRTObject_ptr>::iterator rtc = m_rtcs.begin();
+ while (rtc != m_rtcs.end())
+ {
+ RTC_impl::RTObjectStateMachine* comp = m_ec->findComponent(*rtc);
+ if (comp != NULL)
+ {
+ rtc = m_rtcs.erase(rtc);
+ m_comps.push_back(comp);
+ }
+ else
+ {
+ ++rtc;
+ }
+ }
+ }
+
+ int MultilayerCompositeEC::ChildTask::svc()
+ {
+ {
+ Guard guard(m_worker.mutex_);
+ m_worker.running_ = true;
+ }
+
+ {
+ Guard guard(m_signal_worker.mutex_);
+
+ while (!m_signal_worker.running_)
+ {
+ m_signal_worker.cond_.wait();
+ }
+ m_signal_worker.running_ = false;
+
+ }
+
+
+
+
+ updateCompList();
+ for (std::vector<RTC_impl::RTObjectStateMachine*>::iterator comp = m_comps.begin(); comp != m_comps.end(); ++comp)
+ {
+ (*comp)->workerPreDo();
+ (*comp)->workerDo();
+ (*comp)->workerPostDo();
+ }
+
+ {
+ Guard guard(m_worker.mutex_);
+ m_worker.running_ = false;
+
+ m_worker.cond_.signal();
+
+
+ }
+
+ {
+ Guard guard(m_signal_worker.mutex_);
+ while (!m_signal_worker.running_){
+ m_signal_worker.cond_.wait();
+ }
+ m_signal_worker.running_ = false;
+ }
+
+
+
+ return 0;
+ }
+
+ void MultilayerCompositeEC::ChildTask::signal()
+ {
+
+ bool ret = false;
+ while (!ret)
+ {
+ m_task->signal();
+
+ {
+ Guard guard(m_worker.mutex_);
+ ret = m_worker.running_;
+ }
+ }
+ {
+ Guard guard(m_signal_worker.mutex_);
+ m_signal_worker.running_ = true;
+ m_signal_worker.cond_.signal();
+ }
+
+
+ }
+
+ void MultilayerCompositeEC::ChildTask::join()
+ {
+ {
+ Guard guard(m_worker.mutex_);
+ while (m_worker.running_)
+ {
+ m_worker.cond_.wait();
+ }
+ }
+
+ {
+ Guard guard(m_signal_worker.mutex_);
+ m_signal_worker.running_ = true;
+ m_signal_worker.cond_.signal();
+ }
+ }
+
+ coil::TimeMeasure::Statistics MultilayerCompositeEC::ChildTask::getPeriodStat()
+ {
+ return m_task->getPeriodStat();
+ }
+
+ coil::TimeMeasure::Statistics MultilayerCompositeEC::ChildTask::getExecStat()
+ {
+ return m_task->getExecStat();
+ }
+
+ void MultilayerCompositeEC::ChildTask::finalize()
+ {
+ m_task->resume();
+ m_task->finalize();
+
+ RTC::PeriodicTaskFactory::instance().deleteObject(m_task);
+ }
+
+}; // namespace RTC_exp
+
+extern "C"
+{
+ /*!
+ * @if jp
+ * @brief ECFactoryへの登録のための初期化関数
+ * @else
+ * @brief Initialization function to register to ECFactory
+ * @endif
+ */
+
+ void MultilayerCompositeECInit(RTC::Manager* manager)
+ {
+ RTC::ExecutionContextFactory::
+ instance().addFactory("MultilayerCompositeEC",
+ ::coil::Creator< ::RTC::ExecutionContextBase,
+ ::RTC_exp::MultilayerCompositeEC>,
+ ::coil::Destructor< ::RTC::ExecutionContextBase,
+ ::RTC_exp::MultilayerCompositeEC>);
+
+ coil::vstring ecs;
+ ecs = RTC::ExecutionContextFactory::instance().getIdentifiers();
+ }
+};
+
Added: trunk/OpenRTM-aist/src/lib/rtm/MultilayerCompositeEC.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/MultilayerCompositeEC.h (rev 0)
+++ trunk/OpenRTM-aist/src/lib/rtm/MultilayerCompositeEC.h 2018-10-09 00:01:37 UTC (rev 3418)
@@ -0,0 +1,201 @@
+// -*- C++ -*-
+/*!
+ * @file MultilayerCompositeEC.cpp
+ * @brief
+ * @date $Date: 2018-10-03 15:44:03 $
+ * @author Nobuhiko Miyamoto <n-miyamoto at aist.go.jp>
+ *
+ * Copyright (C) 2018
+ * Robot Innovation Research Center,
+ * Intelligent Systems Research Institute,
+ * National Institute of
+ * Advanced Industrial Science and Technology (AIST), Japan
+ * All rights reserved.
+ *
+ *
+ */
+
+#ifndef RTC_MULTILAYERCOMPOSITEEC_H
+#define RTC_MULTILAYERCOMPOSITEEC_H
+
+
+#include <rtm/PeriodicExecutionContext.h>
+#include <coil/PeriodicTask.h>
+
+
+
+#ifdef WIN32
+#pragma warning( disable : 4290 )
+#endif
+
+namespace RTC_exp
+{
+ /*!
+ * @if jp
+ * @class MultilayerCompositeEC
+ * @brief MultilayerCompositeEC クラス
+ *
+ * Periodic Sampled Data Processing(周期実行用)ExecutionContextクラス。
+ *
+ * @since 0.4.0
+ *
+ * @else
+ * @class MultilayerCompositeEC
+ * @brief MultilayerCompositeEC class
+ *
+ * Periodic Sampled Data Processing (for the execution cycles)
+ * ExecutionContext class
+ *
+ * @since 0.4.0
+ *
+ * @endif
+ */
+ class MultilayerCompositeEC
+ : public virtual RTC_exp::PeriodicExecutionContext
+ {
+ typedef coil::Guard<coil::Mutex> Guard;
+ public:
+ /*!
+ * @if jp
+ * @brief デフォルトコンストラクタ
+ *
+ * デフォルトコンストラクタ
+ * プロファイルに以下の項目を設定する。
+ * - kind : PERIODIC
+ * - rate : 0.0
+ *
+ * @else
+ * @brief Default Constructor
+ *
+ * Default Constructor
+ * Set the following items to profile.
+ * - kind : PERIODIC
+ * - rate : 0.0
+ *
+ * @endif
+ */
+ MultilayerCompositeEC();
+
+ /*!
+ * @if jp
+ * @brief デストラクタ
+ *
+ * デストラクタ
+ *
+ * @else
+ * @brief Destructor
+ *
+ * Destructor
+ *
+ * @endif
+ */
+ virtual ~MultilayerCompositeEC(void);
+
+ /*!
+ * @if jp
+ * @brief ExecutionContextの初期化を行う
+ *
+ * ExecutionContextの初期化処理
+ *
+ * @else
+ * @brief Initialize the ExecutionContext
+ *
+ * This operation initialize the ExecutionContext
+ *
+ * @endif
+ */
+ virtual void init(coil::Properties& props);
+
+
+ /*!
+ * @if jp
+ * @brief ExecutionContext 用のスレッド実行関数
+ *
+ * ExecutionContext 用のスレッド実行関数。登録されたコンポーネント
+ * の処理を呼び出す。
+ *
+ * @return 実行結果
+ *
+ * @else
+ * @brief Thread execution function for ExecutionContext
+ *
+ * Thread execution function for ExecutionContext. Invoke the
+ * registered components operation.
+ *
+ * @return The execution result
+ *
+ * @endif
+ */
+ virtual int svc(void);
+
+ /*!
+ * @if jp
+ * @brief コンポーネントをバインドする。
+ *
+ * コンポーネントをバインドする。
+ *
+ * @else
+ * @brief Bind the component.
+ *
+ * Bind the component.
+ *
+ * @endif
+ */
+ virtual RTC::ReturnCode_t bindComponent(RTC::RTObject_impl* rtc);
+
+
+ virtual RTC_impl::RTObjectStateMachine* findComponent(RTC::LightweightRTObject_ptr comp);
+ virtual void addTask(std::vector<RTC::LightweightRTObject_ptr> rtcs);
+
+
+
+ protected:
+ class ChildTask
+ {
+ public:
+ ChildTask(coil::PeriodicTaskBase* task, MultilayerCompositeEC* ec);
+ void addComponent(RTC::LightweightRTObject_ptr rtc);
+ void updateCompList();
+ virtual int svc();
+ void signal();
+ void join();
+ coil::TimeMeasure::Statistics getPeriodStat();
+ coil::TimeMeasure::Statistics getExecStat();
+ void finalize();
+ private:
+ std::vector<RTC::LightweightRTObject_ptr> m_rtcs;
+ coil::PeriodicTaskBase* m_task;
+ MultilayerCompositeEC* m_ec;
+ std::vector<RTC_impl::RTObjectStateMachine*> m_comps;
+ WorkerThreadCtrl m_worker;
+ WorkerThreadCtrl m_signal_worker;
+
+ };
+
+ virtual void addRTCToTask(ChildTask* task, RTC::LightweightRTObject_ptr rtobj);
+
+ std::vector<ChildTask*> m_tasklist;
+ RTC_impl::RTObjectStateMachine* m_ownersm;
+
+
+ }; // class MultilayerCompositeEC
+}; // namespace RTC_exp
+
+#ifdef WIN32
+#pragma warning( default : 4290 )
+#endif
+
+
+extern "C"
+{
+ /*!
+ * @if jp
+ * @brief ECFactoryへの登録のための初期化関数
+ * @else
+ * @brief Initialization function to register to ECFactory
+ * @endif
+ */
+ void MultilayerCompositeECInit(RTC::Manager* manager);
+};
+
+#endif // RTC_MULTILAYERCOMPOSITEEC_H
Modified: trunk/OpenRTM-aist/src/lib/rtm/PeriodicECSharedComposite.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/PeriodicECSharedComposite.cpp 2018-10-08 23:58:57 UTC (rev 3417)
+++ trunk/OpenRTM-aist/src/lib/rtm/PeriodicECSharedComposite.cpp 2018-10-09 00:01:37 UTC (rev 3418)
@@ -320,28 +320,36 @@
}
- // set ec to target RTC
- m_ec->add_component(member.rtobj_.in());
+ addRTCToEC(member.rtobj_.in());
- OrganizationList_var orglist = member.rtobj_->get_organizations();
- for (CORBA::ULong i(0); i < orglist->length(); ++i)
+
+ }
+
+ void PeriodicECOrganization::addRTCToEC(RTC::RTObject_var rtobj)
+ {
+ SDOPackage::OrganizationList_var orglist = rtobj->get_owned_organizations();
+ if (orglist->length() == 0)
{
- SDOList_var sdos = orglist[i]->get_members();
- for (CORBA::ULong j(0); j < sdos->length(); ++j)
+ // set ec to target RTC
+ m_ec->add_component(rtobj.in());
+ }
+
+ for (CORBA::ULong i(0); i < orglist->length(); ++i)
+ {
+ SDOPackage::SDOList_var sdos = orglist[i]->get_members();
+ for (CORBA::ULong j(0); j < sdos->length(); ++j)
{
#ifndef ORB_IS_RTORB
- ::OpenRTM::DataFlowComponent_var dfc;
- if (!sdoToDFC(sdos[j].in(), dfc.out())) { continue; }
+ ::OpenRTM::DataFlowComponent_var dfc;
+ if (!sdoToDFC(sdos[j].in(), dfc.out())) { continue; }
#else // ORB_IS_RTORB
- ::OpenRTM::DataFlowComponent_var dfc;
- ::OpenRTM::DataFlowComponent_ptr dfc_ptr(dfc);
- if (!sdoToDFC(sdos[j].in(), dfc_ptr)) { continue; }
+ ::OpenRTM::DataFlowComponent_var dfc;
+ ::OpenRTM::DataFlowComponent_ptr dfc_ptr(dfc);
+ if (!sdoToDFC(sdos[j].in(), dfc_ptr)) { continue; }
#endif // ORB_IS_RTORB
- m_ec->add_component(dfc.in());
+ addRTCToEC(dfc.in());
}
}
-
-
}
/*!
@@ -371,7 +379,7 @@
OrganizationList_var orglist = member.rtobj_->get_organizations();
for (CORBA::ULong i(0); i < orglist->length(); ++i)
{
- SDOList_var sdos = orglist[i]->get_members();
+ SDOPackage::SDOList_var sdos = orglist[i]->get_members();
for (CORBA::ULong j(0); j < sdos->length(); ++j)
{
#ifndef ORB_IS_RTORB
@@ -622,6 +630,11 @@
m_configsets.setOnSetConfigurationSet(new setCallback(m_org));
m_configsets.setOnAddConfigurationSet(new addCallback(m_org));
+ m_properties["exec_cxt.periodic.sync_transition"] = "NO";
+ m_properties["exec_cxt.periodic.sync_activation"] = "NO";
+ m_properties["exec_cxt.periodic.sync_deactivation"] = "NO";
+ m_properties["exec_cxt.periodic.sync_reset"] = "NO";
+
}
@@ -668,6 +681,9 @@
::SDOPackage::SDOList sdos;
for (int i(0), len(m_members.size()); i < len; ++i)
{
+ coil::replaceString(m_members[i], "|", "");
+ coil::eraseBothEndsBlank(m_members[i]);
+
RTObject_impl* rtc = mgr.getComponent(m_members[i].c_str());
if (rtc == NULL) {
continue;
@@ -707,13 +723,12 @@
ReturnCode_t PeriodicECSharedComposite::onActivated(RTC::UniqueId exec_handle)
{
RTC_TRACE(("onActivated(%d)", exec_handle));
- ::RTC::ExecutionContextList_var ecs(get_owned_contexts());
::SDOPackage::SDOList_var sdos(m_org->get_members());
for (::CORBA::ULong i(0), len(sdos->length()); i < len; ++i)
{
::RTC::RTObject_var rtc(::RTC::RTObject::_narrow(sdos[i]));
- ecs[CORBA::ULong(0)]->activate_component(rtc.in());
+ activateChildComp(rtc.in());
}
RTC_DEBUG(("%d member RTC%s activated.", sdos->length(),
sdos->length() == 1 ? " was" : "s were"));
@@ -720,6 +735,27 @@
return ::RTC::RTC_OK;
}
+ void PeriodicECSharedComposite::activateChildComp(RTC::RTObject_var rtobj)
+ {
+ ::RTC::ExecutionContextList_var ecs(get_owned_contexts());
+ SDOPackage::OrganizationList_var orglist = rtobj->get_owned_organizations();
+
+ if (orglist->length() == 0)
+ {
+ ecs[CORBA::ULong(0)]->activate_component(rtobj.in());
+ }
+
+ for (CORBA::ULong i(0); i < orglist->length(); ++i)
+ {
+ SDOPackage::SDOList_var child_sdos = orglist[i]->get_members();
+ for (CORBA::ULong j(0); j < child_sdos->length(); ++j)
+ {
+ ::RTC::RTObject_var child(::RTC::RTObject::_narrow(child_sdos[i]));
+ activateChildComp(child.in());
+ }
+ }
+ }
+
/*!
* @if jp
* @brief 非活性化処理用コールバック関数
Modified: trunk/OpenRTM-aist/src/lib/rtm/PeriodicECSharedComposite.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/PeriodicECSharedComposite.h 2018-10-08 23:58:57 UTC (rev 3417)
+++ trunk/OpenRTM-aist/src/lib/rtm/PeriodicECSharedComposite.h 2018-10-09 00:01:37 UTC (rev 3418)
@@ -247,6 +247,7 @@
* @endif
*/
void removeOrganizationFromTarget(Member& member);
+ void addRTCToEC(RTC::RTObject_var rtobj);
/*!
* @if jp
@@ -553,6 +554,7 @@
* @endif
*/
virtual ReturnCode_t onActivated(RTC::UniqueId exec_handle);
+ void activateChildComp(RTC::RTObject_var rtobj);
/*!
* @if jp
*
Modified: trunk/OpenRTM-aist/src/lib/rtm/PeriodicExecutionContext.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/PeriodicExecutionContext.cpp 2018-10-08 23:58:57 UTC (rev 3417)
+++ trunk/OpenRTM-aist/src/lib/rtm/PeriodicExecutionContext.cpp 2018-10-09 00:01:37 UTC (rev 3418)
@@ -194,6 +194,7 @@
}
++count;
} while (threadRunning());
+
RTC_DEBUG(("Thread terminated."));
return 0;
}
@@ -440,6 +441,7 @@
m_workerthread.running_ = false;
return RTC::RTC_OK;
}
+
// template virtual functions adding/removing component
/*!
* @brief onAddedComponent() template function
@@ -480,12 +482,15 @@
getStateString(comp->getStates().next)));
// Now comp's next state must be ACTIVE state
// If worker thread is stopped, restart worker thread.
- Guard guard(m_workerthread.mutex_);
- if (m_workerthread.running_ == false)
- {
- m_workerthread.running_ = true;
- m_workerthread.cond_.signal();
- }
+ if (isRunning())
+ {
+ Guard guard(m_workerthread.mutex_);
+ if (m_workerthread.running_ == false)
+ {
+ m_workerthread.running_ = true;
+ m_workerthread.cond_.signal();
+ }
+ }
return RTC::RTC_OK;
}
@@ -506,12 +511,15 @@
// Now comp's next state must be ACTIVE state
// If worker thread is stopped, restart worker thread.
- Guard guard(m_workerthread.mutex_);
- if (m_workerthread.running_ == false)
- {
- m_workerthread.running_ = true;
- m_workerthread.cond_.signal();
- }
+ if (isRunning())
+ {
+ Guard guard(m_workerthread.mutex_);
+ if (m_workerthread.running_ == false)
+ {
+ m_workerthread.running_ = true;
+ m_workerthread.cond_.signal();
+ }
+ }
return RTC::RTC_OK;
}
@@ -606,7 +614,6 @@
void PeriodicExecutionContext::setCpuAffinity(coil::Properties& props)
{
RTC_TRACE(("setCpuAffinity()"));
- std::cout << props;
std::string affinity;
getProperty(props, "cpu_affinity", affinity);
RTC_DEBUG(("CPU affinity property: %s", affinity.c_str()));
openrtm-commit メーリングリストの案内