[openrtm-commit:00668] r2313 - in trunk/OpenRTM-aist/src/ext/ec/logical_time: . example
openrtm @ openrtm.org
openrtm @ openrtm.org
2012年 2月 7日 (火) 12:02:45 JST
Author: n-ando
Date: 2012-02-07 12:02:45 +0900 (Tue, 07 Feb 2012)
New Revision: 2313
Added:
trunk/OpenRTM-aist/src/ext/ec/logical_time/LogicalTimeTriggeredEC.cpp
trunk/OpenRTM-aist/src/ext/ec/logical_time/LogicalTimeTriggeredEC.h
trunk/OpenRTM-aist/src/ext/ec/logical_time/Makefile.am
trunk/OpenRTM-aist/src/ext/ec/logical_time/example/
trunk/OpenRTM-aist/src/ext/ec/logical_time/example/LTTSample.conf
trunk/OpenRTM-aist/src/ext/ec/logical_time/example/LTTSample.cpp
trunk/OpenRTM-aist/src/ext/ec/logical_time/example/LTTSample.h
trunk/OpenRTM-aist/src/ext/ec/logical_time/example/LTTSampleComp.cpp
trunk/OpenRTM-aist/src/ext/ec/logical_time/example/Makefile.am
trunk/OpenRTM-aist/src/ext/ec/logical_time/example/TriggerApp.cpp
trunk/OpenRTM-aist/src/ext/ec/logical_time/example/rtc.conf
trunk/OpenRTM-aist/src/ext/ec/logical_time/example/run.sh
Log:
[compat,impl/header,func] Initial version of LogicalTimeTriggeredEC has been implemented. refs #2304
Added: trunk/OpenRTM-aist/src/ext/ec/logical_time/LogicalTimeTriggeredEC.cpp
===================================================================
--- trunk/OpenRTM-aist/src/ext/ec/logical_time/LogicalTimeTriggeredEC.cpp (rev 0)
+++ trunk/OpenRTM-aist/src/ext/ec/logical_time/LogicalTimeTriggeredEC.cpp 2012-02-07 03:02:45 UTC (rev 2313)
@@ -0,0 +1,566 @@
+// -*- C++ -*-
+/*!
+ * @file LogicalTimeTriggeredEC.cpp
+ * @brief LogicalTimeTriggeredEC class
+ * @date $Date: 2008-01-14 07:49:14 $
+ * @author Noriaki Ando <n-ando at aist.go.jp>
+ *
+ * Copyright (C) 2007-2008
+ * Noriaki Ando
+ * Task-intelligence Research Group,
+ * Intelligent Systems Research Institute,
+ * National Institute of
+ * Advanced Industrial Science and Technology (AIST), Japan
+ * All rights reserved.
+ *
+ * $Id: LogicalTimeTriggeredEC.cpp 2307 2012-02-05 21:29:15Z n-ando $
+ *
+ */
+
+#include <coil/TimeValue.h>
+#include <coil/Guard.h>
+#include <coil/ClockManager.h>
+
+#include <rtm/ECFactory.h>
+#include <rtm/RTObjectStateMachine.h>
+#include <LogicalTimeTriggeredEC.h>
+
+namespace RTC
+{
+ /*!
+ * @if jp
+ * @brief コンストラクタ
+ * @else
+ * @brief Constructor
+ * @endif
+ */
+ LogicalTimeTriggeredEC::LogicalTimeTriggeredEC()
+ : ExecutionContextBase("exttrig_async_ec"),
+ rtclog("exttrig_async_ec"),
+ m_clock(coil::ClockManager::instance().getClock("logical")),
+ m_syncTick(true), m_count(0),
+ m_svc(false)
+ {
+ RTC_TRACE(("LogicalTimeTriggeredEC()"));
+
+ // getting my reference
+ setObjRef(this->_this());
+
+ // profile initialization
+ setKind(RTC::PERIODIC);
+ setRate(DEFAULT_EXECUTION_RATE);
+
+ RTC_DEBUG(("Actual period: %d [sec], %d [usec]",
+ m_profile.getPeriod().sec(), m_profile.getPeriod().usec()));
+ }
+
+ /*!
+ * @if jp
+ * @brief デストラクタ
+ * @else
+ * @brief Destructor
+ * @endif
+ */
+ LogicalTimeTriggeredEC::~LogicalTimeTriggeredEC()
+ {
+ RTC_TRACE(("~LogicalTimeTriggeredEC()"));
+ {
+ {
+ Guard guard(m_svcmutex);
+ m_svc = false;
+ }
+ {
+ Guard guard(m_worker.mutex_);
+ m_worker.ticked_ = true;
+ m_worker.cond_.signal();
+ }
+ }
+ wait();
+ }
+
+ void LogicalTimeTriggeredEC::init(coil::Properties& props)
+ {
+ RTC_TRACE(("init()"));
+ ExecutionContextBase::init(props);
+ if (props.findNode("sync_tick") != NULL)
+ {
+ m_syncTick = coil::toBool(props["sync_tick"], "YES", "NO", true);
+ RTC_DEBUG(("Tick mode: %s",
+ m_syncTick ? "Synchronous" : "Asynchronous"));
+ }
+ RTC_DEBUG(("init() done"));
+
+ }
+
+ /*------------------------------------------------------------
+ * Start activity
+ * ACE_Task class method over ride.
+ *------------------------------------------------------------*/
+ /*!
+ * @if jp
+ * @brief ExecutionContext用アクティビティスレッドを生成する
+ * @else
+ * @brief Generate internal activity thread for ExecutionContext
+ * @endif
+ */
+ int LogicalTimeTriggeredEC::open(void *args)
+ {
+ RTC_TRACE(("open()"));
+ activate();
+ return 0;
+ }
+
+ /*!
+ * @if jp
+ * @brief 各 Component の処理を呼び出す。
+ * @else
+ * @brief Invoke each component's operation
+ * @endif
+ */
+ int LogicalTimeTriggeredEC::svc(void)
+ {
+ RTC_TRACE(("svc()"));
+ unsigned int count(0);
+ do
+ {
+ {
+ Guard gurad(m_worker.mutex_);
+ RTC_DEBUG(("Start of worker invocation. ticked = %s",
+ m_worker.ticked_ ? "true" : "false"));
+ while (!m_worker.ticked_)
+ {
+ m_worker.cond_.wait(); // wait for tick
+ RTC_DEBUG(("Thread was woken up."));
+ }
+ if (!m_worker.ticked_) { continue; }
+ }
+ coil::TimeValue t0(coil::gettimeofday());
+ ExecutionContextBase::invokeWorkerPreDo();
+ ExecutionContextBase::invokeWorkerDo();
+ ExecutionContextBase::invokeWorkerPostDo();
+ coil::TimeValue t1(coil::gettimeofday());
+ {
+ Guard gurad(m_worker.mutex_);
+ m_worker.ticked_ = false;
+ }
+ coil::TimeValue period(getPeriod());
+ if (1) //count > 1000)
+ {
+ RTC_PARANOID(("Period: %f [s]", (double)period));
+ RTC_PARANOID(("Execution: %f [s]", (double)(t1 - t0)));
+ RTC_PARANOID(("Sleep: %f [s]", (double)(period - (t1 - t0))));
+ }
+ coil::TimeValue t2(coil::gettimeofday());
+ if (period > (t1 - t0))
+ {
+ if (1 /*count > 1000*/) { RTC_PARANOID(("sleeping...")); }
+ coil::sleep((coil::TimeValue)(period - (t1 - t0)));
+ }
+ if (1) //count > 1000)
+ {
+ coil::TimeValue t3(coil::gettimeofday());
+ RTC_PARANOID(("Slept: %f [s]", (double)(t3 - t2)));
+ count = 0;
+ }
+ ++count;
+ } while (threadRunning());
+
+ return 0;
+ }
+
+ /*!
+ * @if jp
+ * @brief ExecutionContext 用のスレッド実行関数
+ * @else
+ * @brief Thread execution function for ExecutionContext
+ * @endif
+ */
+ int LogicalTimeTriggeredEC::close(unsigned long flags)
+ {
+ RTC_TRACE(("close()"));
+ // At this point, this component have to be finished.
+ // Current state and Next state should be RTC_EXITING.
+ return 0;
+ }
+
+ //============================================================
+ // LogicalTimeTriggeredECService
+ //============================================================
+ /*!
+ * @if jp
+ * @brief 処理を1ステップ進める
+ * @else
+ * @brief Move forward one step of ExecutionContext
+ * @endif
+ */
+ void LogicalTimeTriggeredEC::
+ tick(::CORBA::ULong sec, ::CORBA::ULong usec)
+ throw (CORBA::SystemException)
+ {
+ RTC_TRACE(("tick(sec = %d, usec = %d)", sec, usec));
+ coil::TimeValue time(sec, usec);
+ m_clock.settime(time);
+
+ if (!isRunning())
+ {
+ RTC_DEBUG(("EC is not running. do nothing."))
+ return;
+ }
+
+ if (m_syncTick) // Synchronous tick mode
+ {
+ invokeWorker();
+ }
+ else // Asynchronous tick mode
+ {
+ Guard guard(m_worker.mutex_);
+ m_worker.ticked_ = true;
+ m_worker.cond_.signal();
+ RTC_PARANOID(("EC was ticked. Signal was sent to worker thread."));
+ }
+ return;
+ }
+
+
+
+ void LogicalTimeTriggeredEC::
+ get_time(::CORBA::ULong& sec, ::CORBA::ULong& usec)
+ throw (CORBA::SystemException)
+ {
+ coil::TimeValue time(m_clock.gettime());
+ sec = time.sec();
+ usec = time.usec();
+ }
+
+ //============================================================
+ // ExecutionContextService
+ //============================================================
+ /*!
+ * @if jp
+ * @brief ExecutionContext 実行状態確認関数
+ * @else
+ * @brief Check for ExecutionContext running state
+ * @endif
+ */
+ CORBA::Boolean LogicalTimeTriggeredEC::is_running()
+ throw (CORBA::SystemException)
+ {
+ return ExecutionContextBase::isRunning();
+ }
+
+ /*!
+ * @if jp
+ * @brief ExecutionContext の実行を開始
+ * @else
+ * @brief Start the ExecutionContext
+ * @endif
+ */
+ RTC::ReturnCode_t LogicalTimeTriggeredEC::start()
+ throw (CORBA::SystemException)
+ {
+ return ExecutionContextBase::start();
+ }
+
+ /*!
+ * @if jp
+ * @brief ExecutionContext の実行を停止
+ * @else
+ * @brief Stop the ExecutionContext
+ * @endif
+ */
+ RTC::ReturnCode_t LogicalTimeTriggeredEC::stop()
+ throw (CORBA::SystemException)
+ {
+ return ExecutionContextBase::stop();
+ }
+
+
+
+ /*!
+ * @if jp
+ * @brief ExecutionContext の実行周期(Hz)を取得する
+ * @else
+ * @brief Get execution rate(Hz) of ExecutionContext
+ * @endif
+ */
+ CORBA::Double LogicalTimeTriggeredEC::get_rate()
+ throw (CORBA::SystemException)
+ {
+ return ExecutionContextBase::getRate();
+ }
+
+ /*!
+ * @if jp
+ * @brief ExecutionContext の実行周期(Hz)を設定する
+ * @else
+ * @brief Set execution rate(Hz) of ExecutionContext
+ * @endif
+ */
+ RTC::ReturnCode_t LogicalTimeTriggeredEC::set_rate(CORBA::Double rate)
+ throw (CORBA::SystemException)
+ {
+ return ExecutionContextBase::setRate(rate);
+ }
+
+ /*!
+ * @if jp
+ * @brief RTコンポーネントを追加する
+ * @else
+ * @brief Add an RT-Component
+ * @endif
+ */
+ RTC::ReturnCode_t
+ LogicalTimeTriggeredEC::add_component(RTC::LightweightRTObject_ptr comp)
+ throw (CORBA::SystemException)
+ {
+ return ExecutionContextBase::addComponent(comp);
+ }
+
+ /*!
+ * @if jp
+ * @brief コンポーネントをコンポーネントリストから削除する
+ * @else
+ * @brief Remove the RT-Component from participant list
+ * @endif
+ */
+ RTC::ReturnCode_t LogicalTimeTriggeredEC::
+ remove_component(RTC::LightweightRTObject_ptr comp)
+ throw (CORBA::SystemException)
+ {
+ return ExecutionContextBase::removeComponent(comp);
+ }
+
+ /*!
+ * @if jp
+ * @brief RTコンポーネントをアクティブ化する
+ * @else
+ * @brief Activate an RT-Component
+ * @endif
+ */
+ RTC::ReturnCode_t LogicalTimeTriggeredEC::
+ activate_component(RTC::LightweightRTObject_ptr comp)
+ throw (CORBA::SystemException)
+ {
+ return ExecutionContextBase::activateComponent(comp);
+ }
+
+ /*!
+ * @if jp
+ * @brief RTコンポーネントを非アクティブ化する
+ * @else
+ * @brief Deactivate an RT-Component
+ * @endif
+ */
+ RTC::ReturnCode_t LogicalTimeTriggeredEC::
+ deactivate_component(RTC::LightweightRTObject_ptr comp)
+ throw (CORBA::SystemException)
+ {
+ return ExecutionContextBase::deactivateComponent(comp);
+ }
+
+ /*!
+ * @if jp
+ * @brief RTコンポーネントをリセットする
+ * @else
+ * @brief Reset the RT-Component
+ * @endif
+ */
+ RTC::ReturnCode_t LogicalTimeTriggeredEC::
+ reset_component(RTC::LightweightRTObject_ptr comp)
+ throw (CORBA::SystemException)
+ {
+ return ExecutionContextBase::resetComponent(comp);
+ }
+
+ /*!
+ * @if jp
+ * @brief RTコンポーネントの状態を取得する
+ * @else
+ * @brief Get RT-Component's state
+ * @endif
+ */
+ RTC::LifeCycleState LogicalTimeTriggeredEC::
+ get_component_state(RTC::LightweightRTObject_ptr comp)
+ throw (CORBA::SystemException)
+ {
+ return ExecutionContextBase::getComponentState(comp);
+ }
+
+ /*!
+ * @if jp
+ * @brief ExecutionKind を取得する
+ * @else
+ * @brief Get the ExecutionKind
+ * @endif
+ */
+ RTC::ExecutionKind LogicalTimeTriggeredEC::get_kind()
+ throw (CORBA::SystemException)
+ {
+ return ExecutionContextBase::getKind();
+ }
+
+ //------------------------------------------------------------
+ // ExecutionContextService interfaces
+ //------------------------------------------------------------
+ /*!
+ * @if jp
+ * @brief ExecutionContextProfile を取得する
+ * @else
+ * @brief Get the ExecutionContextProfile
+ * @endif
+ */
+ RTC::ExecutionContextProfile* LogicalTimeTriggeredEC::get_profile()
+ throw (CORBA::SystemException)
+ {
+ return ExecutionContextBase::getProfile();
+ }
+
+ //============================================================
+ // protected functions
+ //============================================================
+ /*!
+ * @brief calling worker
+ */
+ void LogicalTimeTriggeredEC::invokeWorker()
+ {
+ RTC_TRACE(("invokeWorker()"));
+ if (!isRunning()) { return; }
+ Guard guard(m_tickmutex);
+
+ ExecutionContextBase::invokeWorkerPreDo(); // update state
+ coil::TimeValue t0(coil::gettimeofday());
+ ExecutionContextBase::invokeWorkerDo();
+ coil::TimeValue t1(coil::gettimeofday());
+ ExecutionContextBase::invokeWorkerPostDo();
+ coil::TimeValue t2(coil::gettimeofday());
+
+ coil::TimeValue period(getPeriod());
+ if (m_count > 1000)
+ {
+ RTC_PARANOID(("Period: %f [s]", (double)period));
+ RTC_PARANOID(("Exec-Do: %f [s]", (double)(t1 - t0)));
+ RTC_PARANOID(("Exec-PostDo: %f [s]", (double)(t2 - t1)));
+ RTC_PARANOID(("Sleep: %f [s]", (double)(period - (t2 - t0))));
+ }
+ coil::TimeValue t3(coil::gettimeofday());
+ if (period > (t2 - t0))
+ {
+ if (m_count > 1000) { RTC_PARANOID(("sleeping...")); }
+ coil::sleep((coil::TimeValue)(period - (t2 - t0)));
+ }
+ if (m_count > 1000)
+ {
+ coil::TimeValue t4(coil::gettimeofday());
+ RTC_PARANOID(("Slept: %f [s]", (double)(t4 - t3)));
+ m_count = 0;
+ }
+ ++m_count;
+ return;
+ }
+ /*!
+ * @brief onStarted() template function
+ */
+ RTC::ReturnCode_t LogicalTimeTriggeredEC::onStarted()
+ {
+ // change EC thread state
+ Guard gurad(m_svcmutex);
+ if (m_syncTick) { return RTC::RTC_OK; }
+ if (!m_svc)
+ { // If start() is called first time, start the worker thread.
+ m_svc = true;
+ this->open(0);
+ }
+ return RTC::RTC_OK;
+ }
+
+ /*!
+ * @brief onWaitingActivated() template function
+ */
+ RTC::ReturnCode_t LogicalTimeTriggeredEC::
+ onWaitingActivated(RTC_impl::RTObjectStateMachine* comp, long int count)
+ {
+ RTC_TRACE(("onWaitingActivated(count = %d)", count));
+ RTC_PARANOID(("curr: %s, next: %s",
+ getStateString(comp->getStates().curr),
+ getStateString(comp->getStates().next)));
+ // Now comp's next state must be ACTIVE state
+ // If worker thread is stopped, restart worker thread.
+
+ if (m_syncTick) // Synchronous tick mode
+ {
+ }
+ else // Asynchronous tick mode
+ {
+ Guard guard(m_worker.mutex_);
+ m_worker.ticked_ = true;
+ m_worker.cond_.signal();
+ }
+ return RTC::RTC_OK;
+ }
+
+
+ /*!
+ * @brief onWaitingDeactivated() template function
+ */
+ RTC::ReturnCode_t LogicalTimeTriggeredEC::
+ onWaitingDeactivated(RTC_impl::RTObjectStateMachine* comp, long int count)
+ {
+ RTC_TRACE(("onWaitingDeactivated(count = %d)", count));
+ RTC_PARANOID(("curr: %s, next: %s",
+ getStateString(comp->getStates().curr),
+ getStateString(comp->getStates().next)));
+ if (m_syncTick) // Synchronous tick mode
+ {
+ }
+ else // Asynchronous tick mode
+ {
+ Guard guard(m_worker.mutex_);
+ m_worker.ticked_ = true;
+ m_worker.cond_.signal();
+ }
+ return RTC::RTC_OK;
+ }
+
+ /*!
+ * @brief onWaitingReset() template function
+ */
+ RTC::ReturnCode_t LogicalTimeTriggeredEC::
+ onWaitingReset(RTC_impl::RTObjectStateMachine* comp, long int count)
+ {
+ RTC_TRACE(("onWaitingReset(count = %d)", count));
+ RTC_PARANOID(("curr: %s, next: %s",
+ getStateString(comp->getStates().curr),
+ getStateString(comp->getStates().next)));
+ if (m_syncTick) // Synchronous tick mode
+ {
+ }
+ else // Asynchronous tick mode
+ {
+ Guard guard(m_worker.mutex_);
+ m_worker.ticked_ = true;
+ m_worker.cond_.signal();
+ }
+ return RTC::RTC_OK;
+ }
+};
+
+
+extern "C"
+{
+ /*!
+ * @if jp
+ * @brief 当該 ExecutionContext 用Factoryクラスの登録。
+ * @else
+ * @brief Register Factory class for this ExecutionContext
+ * @endif
+ */
+ void LogicalTimeTriggeredECInit(RTC::Manager* manager)
+ {
+ RTC::ExecutionContextFactory::
+ instance().addFactory("ltt_ec",
+ ::coil::Creator< ::RTC::ExecutionContextBase,
+ ::RTC::LogicalTimeTriggeredEC>,
+ ::coil::Destructor< ::RTC::ExecutionContextBase,
+ ::RTC::LogicalTimeTriggeredEC>);
+ }
+};
Added: trunk/OpenRTM-aist/src/ext/ec/logical_time/LogicalTimeTriggeredEC.h
===================================================================
--- trunk/OpenRTM-aist/src/ext/ec/logical_time/LogicalTimeTriggeredEC.h (rev 0)
+++ trunk/OpenRTM-aist/src/ext/ec/logical_time/LogicalTimeTriggeredEC.h 2012-02-07 03:02:45 UTC (rev 2313)
@@ -0,0 +1,729 @@
+// -*- C++ -*-
+/*!
+ * @file LogicalTimeTriggeredEC.h
+ * @brief LogicalTimeTriggeredEC class
+ * @date $Date: 2008-01-14 07:49:16 $
+ * @author Noriaki Ando <n-ando at aist.go.jp>
+ *
+ * Copyright (C) 2007,2012
+ * Intelligent Systems Research Institute,
+ * National Institute of
+ * Advanced Industrial Science and Technology (AIST), Japan
+ * All rights reserved.
+ *
+ * $Id: LogicalTimeTriggeredEC.h 2307 2012-02-05 21:29:15Z n-ando $
+ *
+ */
+
+#ifndef RTC_EXTTRIGEXECUTIONCONTEXT_H
+#define RTC_EXTTRIGEXECUTIONCONTEXT_H
+
+#include <rtm/RTC.h>
+
+#include <coil/Mutex.h>
+#include <coil/Condition.h>
+#include <coil/Task.h>
+#include <coil/ClockManager.h>
+
+#include <rtm/ExecutionContextBase.h>
+#include <LogicalTimeTriggeredECSkel.h>
+
+#ifdef WIN32
+#pragma warning( disable : 4290 )
+#endif
+
+namespace coil
+{
+ class IClock;
+};
+namespace RTC
+{
+ /*!
+ * @if jp
+ * @class LogicalTimeTriggeredEC
+ * @brief ステップ実行が可能な ExecutionContext クラス
+ *
+ * 1周期毎の実行が可能なPeriodic Sampled Data Processing(周期実行用)
+ * ExecutionContextクラス。
+ * 外部からのメソッド呼びだしによって時間が1周期づつ進む。
+ *
+ * @since 0.4.0
+ *
+ * @else
+ * @brief ExecutionContext class that enables one step execution
+ *
+ * ExecutionContext class that can execute every one cycle for Periodic
+ * Sampled Data Processing.
+ * Time(Tick) advances one cycle by invoking method externally.
+ *
+ * @since 0.4.0
+ *
+ * @endif
+ */
+ class LogicalTimeTriggeredEC
+ : public virtual POA_OpenRTM::LogicalTimeTriggeredEC,
+ public virtual PortableServer::RefCountServantBase,
+ public RTC::ExecutionContextBase,
+ public coil::Task
+ {
+ typedef coil::Mutex Mutex;
+ typedef coil::Condition<Mutex> Condition;
+ typedef coil::Guard<coil::Mutex> Guard;
+ public:
+ /*!
+ * @if jp
+ * @brief コンストラクタ
+ *
+ * コンストラクタ
+ *
+ * @else
+ * @brief Constructor
+ *
+ * Constructor
+ *
+ * @endif
+ */
+ LogicalTimeTriggeredEC();
+
+ /*!
+ * @if jp
+ * @brief デストラクタ
+ *
+ * デストラクタ
+ *
+ * @else
+ * @brief Destructor
+ *
+ * Destructor
+ *
+ * @endif
+ */
+ virtual ~LogicalTimeTriggeredEC(void);
+
+ /*!
+ * @if jp
+ * @brief ExecutionContextの処理を進める
+ *
+ * ExecutionContextの処理を1周期分進める。
+ *
+ * @else
+ * @brief Proceed with tick of ExecutionContext
+ *
+ * Proceed with tick of ExecutionContext for one period.
+ *
+ * @endif
+ */
+ void init(coil::Properties& props);
+
+ /*!
+ * @if jp
+ * @brief ExecutionContext用アクティビティスレッドを生成する
+ *
+ * Executioncontext 用の内部アクティビティスレッドを生成し起動する。
+ * これは coil::Task サービスクラスメソッドのオーバーライド。
+ *
+ * @param args 通常は0
+ *
+ * @return 生成処理実行結果
+ *
+ * @else
+ *
+ * @brief Generate internal activity thread for ExecutionContext
+ *
+ * Generate internal activity thread and run. This is coil::Task
+ * class method's override.
+ *
+ * @param args Usually give 0
+ *
+ * @return The generation result
+ *
+ * @endif
+ */
+ virtual int open(void *args);
+
+ /*!
+ * @if jp
+ * @brief 各 Component の処理を呼び出す。
+ *
+ * ExecutionContext に attach されている各 Component の処理を呼び出す。
+ * 全 Component の処理を呼び出した後、次の呼出が発生するまで休止する。
+ *
+ * @return 処理結果
+ *
+ * @else
+ * @brief Invoke each component's operation
+ *
+ * Invoke each component's operation which is attached this
+ * ExecutionContext. Stop until the next operation is invoked
+ * after all component operations are invoked.
+ *
+ * @return Operation result
+ *
+ * @endif
+ */
+ virtual int svc(void);
+
+ /*!
+ * @if jp
+ * @brief ExecutionContext 用のスレッド実行関数
+ *
+ * ExecutionContext 用のスレッド終了時に呼ばれる。コンポーネントオ
+ * ブジェクトの非アクティブ化、マネージャへの通知を行う。これは
+ * coil::Task サービスクラスメソッドのオーバーライド。
+ *
+ * @param flags 終了処理フラグ
+ *
+ * @return 終了処理結果
+ *
+ * @else
+ *
+ * @brief Thread execution function for ExecutionContext
+ *
+ * This function is invoked when activity thread for
+ * ExecutionContext exits. Deactivate the component object and
+ * notify it to manager. This is coil::Task class method's
+ * override.
+ *
+ * @param flags Flag of the close
+ *
+ * @return The close result
+ *
+ * @endif
+ */
+ virtual int close(unsigned long flags);
+
+ //============================================================
+ // LogicalTimeTriggeredECService
+ //============================================================
+ /*!
+ * @if jp
+ * @brief 処理を1ステップ進める
+ *
+ * ExecutionContextの処理を1周期分進める。
+ *
+ * @else
+ * @brief Move forward one step of ExecutionContext
+ *
+ * Move forward one step of the ExecutionContext processing.
+ *
+ * @endif
+ */
+ virtual void tick(::CORBA::ULong sec, ::CORBA::ULong usec)
+ throw (CORBA::SystemException);
+ virtual void get_time(::CORBA::ULong& sec, ::CORBA::ULong& usec)
+ throw (CORBA::SystemException);
+
+ //============================================================
+ // ExecutionContextService
+ //============================================================
+ /*!
+ * @if jp
+ * @brief ExecutionContext 実行状態確認関数
+ *
+ * この操作は ExecutionContext が Runnning 状態の場合に true を返す。
+ * Executioncontext が Running の間、当該 Executioncontext に参加し
+ * ている全てのアクティブRTコンポーネントが、ExecutionContext の実
+ * 行種類に応じて実行される。
+ *
+ * @return 状態確認関数(動作中:true、停止中:false)
+ *
+ * @else
+ *
+ * @brief Check for ExecutionContext running state
+ *
+ * This operation shall return true if the context is in the
+ * Running state. While the context is Running, all Active RTCs
+ * participating in the context shall be executed according to the
+ * context’s execution kind.
+ *
+ * @return Check state function (Running:true、Stopping:false)
+ *
+ * @endif
+ */
+ virtual CORBA::Boolean is_running(void)
+ throw (CORBA::SystemException);
+
+ /*!
+ * @if jp
+ * @brief ExecutionContext の実行を開始
+ *
+ * ExecutionContext の実行状態を Runnning とするためのリクエストを
+ * 発行する。ExecutionContext の状態が遷移すると
+ * ComponentAction::on_startup が呼び出される。参加しているRTコンポー
+ * ネントが、初期化されるまで ExecutionContext を開始することはでき
+ * ない。ExecutionContext は複数回開始/停止を繰り返すことができる。
+ *
+ * @return ReturnCode_t 型のリターンコード
+ *
+ * @else
+ *
+ * @brief Start the ExecutionContext
+ *
+ * Request that the context enter the Running state. Once the
+ * state transition occurs, the ComponentAction::on_startup
+ * operation will be invoked. An execution context may not be
+ * started until the RT-Components that participate in it have
+ * been initialized. An execution context may be started and
+ * stopped multiple times.
+ *
+ * @return The return code of ReturnCode_t type
+ *
+ * @endif
+ */
+ virtual RTC::ReturnCode_t start(void)
+ throw (CORBA::SystemException);
+
+ /*!
+ * @if jp
+ * @brief ExecutionContext の実行を停止
+ *
+ * ExecutionContext の状態を Stopped とするためのリクエストを発行す
+ * る。遷移が発生した場合は、ComponentAction::on_shutdown が呼び出
+ * される。参加しているRTコンポーネントが終了する前に
+ * ExecutionContext を停止する必要がある。ExecutionContext は複数回
+ * 開始/停止を繰り返すことができる。
+ *
+ * @return ReturnCode_t 型のリターンコード
+ *
+ * @else
+ *
+ * @brief Stop the ExecutionContext
+ *
+ * Request that the context enter the Stopped state. Once the
+ * transition occurs, the ComponentAction::on_shutdown operation
+ * will be invoked. An execution context must be stopped before
+ * the RT components that participate in it are finalized. An
+ * execution context may be started and stopped multiple times.
+ *
+ * @return The return code of ReturnCode_t type
+ *
+ * @endif
+ */
+ virtual RTC::ReturnCode_t stop(void)
+ throw (CORBA::SystemException);
+
+ /*!
+ * @if jp
+ * @brief ExecutionContext の実行周期(Hz)を取得する
+ *
+ * Active 状態にてRTコンポーネントが実行される周期(単位:Hz)を取得す
+ * る。
+ *
+ * @return 処理周期(単位:Hz)
+ *
+ * @else
+ *
+ * @brief Get execution rate(Hz) of ExecutionContext
+ *
+ * This operation shall return the rate (in hertz) at which its
+ * Active participating RTCs are being invoked.
+ *
+ * @return Execution cycle(Unit:Hz)
+ *
+ * @endif
+ */
+ virtual CORBA::Double get_rate(void)
+ throw (CORBA::SystemException);
+
+ /*!
+ * @if jp
+ * @brief ExecutionContext の実行周期(Hz)を設定する
+ *
+ * Active 状態にてRTコンポーネントが実行される周期(単位:Hz)を設定す
+ * る。実行周期の変更は、DataFlowComponentAction の
+ * on_rate_changed によって各RTコンポーネントに伝達される。
+ *
+ * @param rate 処理周期(単位:Hz)
+ *
+ * @return ReturnCode_t 型のリターンコード
+ *
+ * @else
+ *
+ * @brief Set execution rate(Hz) of ExecutionContext
+ *
+ * This operation shall set the rate (in hertz) at which this
+ * context’s Active participating RTCs are being called. If the
+ * execution kind of the context is PERIODIC, a rate change shall
+ * result in the invocation of on_rate_changed on any RTCs
+ * realizing DataFlowComponentAction that are registered with any
+ * RTCs participating in the context.
+ *
+ * @param rate Execution cycle(Unit:Hz)
+ *
+ * @return The return code of ReturnCode_t type
+ *
+ * @endif
+ */
+ virtual RTC::ReturnCode_t set_rate(CORBA::Double rate)
+ throw (CORBA::SystemException);
+
+ /*!
+ * @if jp
+ * @brief RTコンポーネントをアクティブ化する
+ *
+ * Inactive 状態にあるRTコンポーネントをActive に遷移させ、アクティ
+ * ブ化する。この操作が呼ばれた結果、on_activate が呼び出される。指
+ * 定したRTコンポーネントが参加者リストに含まれない場合は、
+ * BAD_PARAMETER が返される。指定したRTコンポーネントの状態が
+ * Inactive 以外の場合は、PRECONDITION_NOT_MET が返される。
+ *
+ * @param comp アクティブ化対象RTコンポーネント
+ *
+ * @return ReturnCode_t 型のリターンコード
+ *
+ * @else
+ *
+ * @brief Activate an RT-component
+ *
+ * The given participant RTC is Inactive and is therefore not
+ * being invoked according to the execution context’s execution
+ * kind. This operation shall cause the RTC to transition to the
+ * Active state such that it may subsequently be invoked in this
+ * execution context. The callback on_activate shall be called as
+ * a result of calling this operation. This operation shall not
+ * return until the callback has returned, and shall result in an
+ * error if the callback does.
+ *
+ * @param comp The target RT-Component for activation
+ *
+ * @return The return code of ReturnCode_t type
+ *
+ * @endif
+ */
+ virtual RTC::ReturnCode_t
+ activate_component(RTC::LightweightRTObject_ptr comp)
+ throw (CORBA::SystemException);
+
+ /*!
+ * @if jp
+ * @brief RTコンポーネントを非アクティブ化する
+ *
+ * Inactive 状態にあるRTコンポーネントを非アクティブ化し、Inactive
+ * に遷移させる。この操作が呼ばれた結果、on_deactivate が呼び出され
+ * る。指定したRTコンポーネントが参加者リストに含まれない場合は、
+ * BAD_PARAMETER が返される。指定したRTコンポーネントの状態が
+ * Active 以外の場合は、PRECONDITION_NOT_MET が返される。
+ *
+ * @param comp 非アクティブ化対象RTコンポーネント
+ *
+ * @return ReturnCode_t 型のリターンコード
+ *
+ * @else
+ *
+ * @brief Deactivate an RT-component
+ *
+ * The given RTC is Active in the execution context. Cause it to
+ * transition to the Inactive state such that it will not be
+ * subsequently invoked from the context unless and until it is
+ * activated again. The callback on_deactivate shall be called as
+ * a result of calling this operation. This operation shall not
+ * return until the callback has returned, and shall result in an
+ * error if the callback does.
+ *
+ * @param comp The target RT-Component for deactivate
+ *
+ * @return The return code of ReturnCode_t type
+ *
+ * @endif
+ */
+ virtual RTC::ReturnCode_t
+ deactivate_component(RTC::LightweightRTObject_ptr comp)
+ throw (CORBA::SystemException);
+
+ /*!
+ * @if jp
+ * @brief RTコンポーネントをリセットする
+ *
+ * Error 状態のRTコンポーネントの復帰を試みる。この操作が呼ばれた結
+ * 果、on_reset が呼び出される。指定したRTコンポーネントが参加者リ
+ * ストに含まれない場合は、BAD_PARAMETER が返される。指定したRTコン
+ * ポーネントの状態が Error 以外の場合は、PRECONDITION_NOT_MET が返
+ * される。
+ *
+ * @param comp リセット対象RTコンポーネント
+ *
+ * @return ReturnCode_t 型のリターンコード
+ *
+ * @else
+ *
+ * @brief Reset the RT-component
+ *
+ * Attempt to recover the RTC when it is in Error. The
+ * ComponentAction::on_reset callback shall be invoked. This
+ * operation shall not return until the callback has returned, and
+ * shall result in an error if the callback does. If possible, the
+ * RTC developer should implement that callback such that the RTC
+ * may be returned to a valid state.
+ *
+ * @param comp The target RT-Component for reset
+ *
+ * @return The return code of ReturnCode_t type
+ *
+ * @endif
+ */
+ virtual RTC::ReturnCode_t
+ reset_component(RTC::LightweightRTObject_ptr comp)
+ throw (CORBA::SystemException);
+
+ /*!
+ * @if jp
+ * @brief RTコンポーネントの状態を取得する
+ *
+ * 指定したRTコンポーネントの状態(LifeCycleState)を取得する。指定し
+ * たRTコンポーネントが参加者リストに含まれない場合は、
+ * UNKNOWN_STATE が返される。
+ *
+ * @param comp 状態取得対象RTコンポーネント
+ *
+ * @return 現在の状態(LifeCycleState)
+ *
+ * @else
+ *
+ * @brief Get RT-component's state
+ *
+ * This operation shall report the LifeCycleState of the given
+ * participant RTC. UNKNOWN_STATE will be returned, if the given
+ * RT-Component is not inclued in the participant list.
+ *
+ * @param comp The target RT-Component to get the state
+ *
+ * @return The current state of the target RT-Component(LifeCycleState)
+ *
+ * @endif
+ */
+ virtual RTC::LifeCycleState
+ get_component_state(RTC::LightweightRTObject_ptr comp)
+ throw (CORBA::SystemException);
+
+ /*!
+ * @if jp
+ * @brief ExecutionKind を取得する
+ *
+ * 本 ExecutionContext の ExecutionKind を取得する
+ *
+ * @return ExecutionKind
+ *
+ * @else
+ *
+ * @brief Get the ExecutionKind
+ *
+ * This operation shall report the execution kind of the execution
+ * context.
+ *
+ * @return ExecutionKind
+ *
+ * @endif
+ */
+ virtual RTC::ExecutionKind get_kind(void)
+ throw (CORBA::SystemException);
+
+ /*!
+ * @if jp
+ * @brief RTコンポーネントを追加する
+ *
+ * 指定したRTコンポーネントを参加者リストに追加する。追加されたRTコ
+ * ンポーネントは attach_context が呼ばれ、Inactive 状態に遷移する。
+ * 指定されたRTコンポーネントがnullの場合は、BAD_PARAMETER が返され
+ * る。指定されたRTコンポーネントが DataFlowComponent 以外の場合は、
+ * BAD_PARAMETER が返される。
+ *
+ * @param comp 追加対象RTコンポーネント
+ *
+ * @return ReturnCode_t 型のリターンコード
+ *
+ * @else
+ *
+ * @brief Add an RT-component
+ *
+ * The operation causes the given RTC to begin participating in
+ * the execution context. The newly added RTC will receive a call
+ * to LightweightRTComponent::attach_context and then enter the
+ * Inactive state. BAD_PARAMETER will be invoked, if the given
+ * RT-Component is null or if the given RT-Component is other than
+ * DataFlowComponent.
+ *
+ * @param comp The target RT-Component for add
+ *
+ * @return The return code of ReturnCode_t type
+ *
+ * @endif
+ */
+ virtual RTC::ReturnCode_t add_component(RTC::LightweightRTObject_ptr comp)
+ throw (CORBA::SystemException);
+
+ /*!
+ * @if jp
+ * @brief RTコンポーネントを参加者リストから削除する
+ *
+ * 指定したRTコンポーネントを参加者リストから削除する。削除された
+ * RTコンポーネントは detach_context が呼ばれる。指定されたRTコンポー
+ * ネントが参加者リストに登録されていない場合は、BAD_PARAMETER が返
+ * される。
+ *
+ * @param comp 削除対象RTコンポーネント
+ *
+ * @return ReturnCode_t 型のリターンコード
+ *
+ * @else
+ *
+ * @brief Remove the RT-Component from participant list
+ *
+ * This operation causes a participant RTC to stop participating in the
+ * execution context.
+ * The removed RTC will receive a call to
+ * LightweightRTComponent::detach_context.
+ * BAD_PARAMETER will be returned, if the given RT-Component is not
+ * participating in the participant list.
+ *
+ * @param comp The target RT-Component for delete
+ *
+ * @return The return code of ReturnCode_t type
+ *
+ * @endif
+ */
+ virtual RTC::ReturnCode_t
+ remove_component(RTC::LightweightRTObject_ptr comp)
+ throw (CORBA::SystemException);
+
+ /*!
+ * @if jp
+ * @brief ExecutionContextProfile を取得する
+ *
+ * 本 ExecutionContext のプロファイルを取得する。
+ *
+ * @return ExecutionContextProfile
+ *
+ * @else
+ *
+ * @brief Get the ExecutionContextProfile
+ *
+ * This operation provides a profile “descriptor” for the execution
+ * context.
+ *
+ * @return ExecutionContextProfile
+ *
+ * @endif
+ */
+ virtual RTC::ExecutionContextProfile* get_profile(void)
+ throw (CORBA::SystemException);
+
+ protected:
+ /*!
+ * @brief calling worker
+ */
+ void invokeWorker();
+ /*!
+ * @brief onStarted() template function
+ */
+ virtual RTC::ReturnCode_t onStarted();
+ /*!
+ * @brief onWaitingActivated() template function
+ */
+ virtual RTC::ReturnCode_t
+ onWaitingActivated(RTC_impl::RTObjectStateMachine* comp, long int count);
+ /*!
+ * @brief onWaitingDeactivated() template function
+ */
+ virtual RTC::ReturnCode_t
+ onWaitingDeactivated(RTC_impl::RTObjectStateMachine* comp, long int count);
+ /*!
+ * @brief onWaitingReset() template function
+ */
+ virtual RTC::ReturnCode_t
+ onWaitingReset(RTC_impl::RTObjectStateMachine* comp, long int count);
+
+ private:
+ bool threadRunning()
+ {
+ Guard guard(m_svcmutex);
+ return m_svc;
+ }
+ /*!
+ * @if jp
+ * @brief ロガーストリーム
+ * @else
+ * @brief Logger stream
+ * @endif
+ */
+ RTC::Logger rtclog;
+ /*!
+ * @if jp
+ * @brief Logical clock
+ * @else
+ * @brief Logical clock
+ * @endif
+ */
+ coil::IClock& m_clock;
+ /*!
+ * @if jp
+ * @brief Synchronous tick flag
+ * @else
+ * @brief Synchronous tick flag
+ * @endif
+ */
+ bool m_syncTick;
+ /*!
+ * @if jp
+ * @brief Tick counter
+ * @else
+ * @brief Tick counter
+ * @endif
+ */
+ unsigned int m_count;
+ /*!
+ * @if jp
+ * @brief ExecutionContext のスレッド実行フラグ
+ * @else
+ * @brief The thread running flag of ExecutionContext
+ * @endif
+ */
+ bool m_svc;
+ Mutex m_svcmutex;
+ Mutex m_tickmutex;
+
+ /*!
+ * @if jp
+ * @brief worker 用状態変数クラス
+ * @else
+ * @brief Condition variable class for worker
+ * @endif
+ */
+ struct Worker
+ {
+ Worker() : cond_(mutex_), ticked_(false) {};
+ Mutex mutex_;
+ Condition cond_;
+ bool ticked_;
+ };
+ // A condition variable for external triggered worker
+ Worker m_worker;
+
+ }; // class LogicalTimeTriggeredEC
+}; // namespace RTC
+
+#ifdef WIN32
+#pragma warning( default : 4290 )
+#endif
+
+
+extern "C"
+{
+ /*!
+ * @if jp
+ * @brief 当該 ExecutionContext 用Factoryクラスの登録。
+ *
+ * このExecutionContextを生成するFactoryクラスを
+ * ExecutionContext管理用ObjectManagerに登録する。
+ *
+ * @else
+ * @brief Register Factory class for this ExecutionContext
+ *
+ * Register the Factory class to create this ExecutionContext
+ * to the ObjectManager for management ExecutionContext
+ *
+ * @endif
+ */
+ void LogicalTimeTriggeredECInit(RTC::Manager* manager);
+};
+
+#endif // RTC_EXTTRIGEXECUTIONCONTEXT_H
Added: trunk/OpenRTM-aist/src/ext/ec/logical_time/Makefile.am
===================================================================
--- trunk/OpenRTM-aist/src/ext/ec/logical_time/Makefile.am (rev 0)
+++ trunk/OpenRTM-aist/src/ext/ec/logical_time/Makefile.am 2012-02-07 03:02:45 UTC (rev 2313)
@@ -0,0 +1,154 @@
+## -*- Makefile -*-
+##---------------------------------------------------------------------------
+## Makefile.am for ART-Linux execution context
+##
+## $Id: Makefile.am 1429 2009-07-06 08:28:25Z hakuta $
+##---------------------------------------------------------------------------
+
+AUTOMAKE_OPTIONS = 1.9
+
+SUBDIRS = . example
+
+IDLC = @IDLC@
+IDLFLAGS = @IDL_FLAGS@ -I$(top_srcdir)/src/lib/rtm/idl
+LIBS = @LIBS@
+
+AM_CPPFLAGS=-I$(top_srcdir)/src/lib -I$(top_srcdir)/src/lib/coil/include -I$(top_srcdir)/src/lib/rtm/idl
+AM_LDFLAGS=-L$(top_builddir) -L$(top_builddir)/src/lib/rtm -L$(top_builddir)/src/lib/rtm/idl
+
+#------------------------------------------------------------
+# Some rules for IDL compile
+#------------------------------------------------------------
+SUFFIXES = .o .so .idl Skel.cpp Stub.cpp Stub.o Skel.o
+
+WRAPPER = $(top_builddir)/utils/rtm-skelwrapper/rtm-skelwrapper
+WRAPPER_FLAGS = --include-dir="" --skel-suffix=Skel --stub-suffix=Stub
+
+.idlSkel.cpp:
+ echo $(PROVIDER_OBJ)
+ $(IDLC) $(IDLFLAGS) $<
+ PYTHONPATH="$(top_srcdir)/build:$(PYTHONPATH)" \
+ PATH="$(top_srcdir)/utils/rtm-config:$(PATH)" \
+ $(WRAPPER) $(WRAPPER_FLAGS) --idl-file=$<
+
+.idlStub.cpp:
+ $(IDLC) $(IDLFLAGS) $<
+ PYTHONPATH="$(PYTHONPATH):$(top_srcdir)/build" \
+ PATH="$(top_srcdir)/utils/rtm-config:$(PATH)" \
+ $(WRAPPER) $(WRAPPER_FLAGS) --idl-file=$<
+
+#------------------------------------------------------------
+# Source list
+#------------------------------------------------------------
+IDL_SOURCES = LogicalTimeTriggeredEC.idl
+
+OBSERVER_DIST_SRC = LogicalTimeTriggeredEC.cpp
+OBSERVER_NODIST_SRC = $(IDL_SOURCES:.idl=Stub.cpp)
+OBSERVER_SRC = $(OBSERVER_DIST_SRC) $(OBSERVER_NODIST_SRC)
+
+OBSERVER_DIST_H = $(OBSERVER_DIST_SRC:.cpp=.h)
+OBSERVER_NODIST_H = $(OBSERVER_NODIST_SRC:.cpp=.h)
+OBSERVER_H = $(OBSERVER_DIST_H) $(OBSERVER_NODIST_H)
+
+#------------------------------------------------------------
+# Object list
+#------------------------------------------------------------
+OBSERVER_OBJ=$(OBSERVER_DIST_SRC:.cpp=.o)
+
+#------------------------------------------------------------
+# Targets
+#------------------------------------------------------------
+# Targets directories
+socompdir = $(rtm_sdodir)
+
+# Loadable Module
+noinst_LTLIBRARIES = libLogicalTimeTriggeredECSkel.la libLogicalTimeTriggeredECStub.la
+nodist_libLogicalTimeTriggeredECSkel_la_SOURCES = $(IDL_SOURCES:.idl=Skel.cpp)
+nodist_libLogicalTimeTriggeredECStub_la_SOURCES = $(IDL_SOURCES:.idl=Stub.cpp)
+
+socomp_LTLIBRARIES = LogicalTimeTriggeredEC.la
+
+dist_LogicalTimeTriggeredEC_la_SOURCES = \
+ $(OBSERVER_DIST_SRC) $(OBSERVER_DIST_H)
+LogicalTimeTriggeredEC_la_LDFLAGS = -module
+LogicalTimeTriggeredEC_la_DEPENDENCIES = libLogicalTimeTriggeredECStub.la
+LogicalTimeTriggeredEC_la_LIBADD = \
+ libLogicalTimeTriggeredECStub.la \
+ $(top_builddir)/src/lib/rtm/libRTC.la \
+ $(top_builddir)/src/lib/coil/lib/libcoil.la
+
+#------------------------------------------------------------
+# Extra distributed files
+#------------------------------------------------------------
+EXTRA_DIST = $(IDL_SOURCES)
+
+ALL_SRC = $(OBSERVER_SRC)
+
+#------------------------------------------------------------
+# File list for deb/ports packages
+#------------------------------------------------------------
+lst:
+ echo $(ALL_SRC) > src.lst
+ echo $(EXTRA_DIST) > other.lst
+
+#------------------------------------------------------------
+# Visual Studio Project
+#------------------------------------------------------------
+win32_builddir=$(top_builddir)/win32/OpenRTM-aist/ext/sdo/observer
+PROJNAME=LogicalTimeTriggeredEC
+
+vcproj: vc8proj vc9proj vc10proj
+
+vc8proj:
+ $(top_builddir)/build/vcprojtool.py vcproj \
+ --type DLL \
+ --vcversion "8.00" \
+ --projectname "$(PROJNAME)" \
+ --version $(RTM_VERSION) \
+ --out $(win32_builddir)/$(PROJNAME)Dll_vc8.vcproj \
+ --yaml $(top_builddir)/examples/rtcdll.vcproj.yaml \
+ --source $(OBSERVER_SRC) \
+ --header $(OBSERVER_H)
+ qkc -sm $(win32_builddir)/$(PROJNAME)Dll_vc8.vcproj
+
+vc9proj:
+ $(top_builddir)/build/vcprojtool.py vcproj \
+ --type DLL \
+ --vcversion "9.00" \
+ --projectname "$(PROJNAME)" \
+ --version $(RTM_VERSION) \
+ --out $(win32_builddir)/$(PROJNAME)Dll_vc9.vcproj \
+ --yaml $(top_builddir)/examples/rtcdll.vcproj.yaml \
+ --source $(OBSERVER_SRC) \
+ --header $(OBSERVER_H)
+ qkc -sm $(win32_builddir)/$(PROJNAME)Dll_vc9.vcproj
+
+vc10proj:
+ $(top_builddir)/build/vcxprojtool.py vcxproj \
+ --type DLL \
+ --vcversion "10.00" \
+ --projectname "$(PROJNAME)" \
+ --version $(RTM_VERSION) \
+ --out $(win32_builddir)/$(PROJNAME)Dll_vc10.vcxproj \
+ --yaml $(top_builddir)/examples/rtcdll.vcproj.yaml \
+ --source $(OBSERVER_SRC) \
+ --header $(OBSERVER_H)
+ qkc -sm $(win32_builddir)/$(PROJNAME)Dll_vc10.vcxproj
+
+
+dist-hook: lst vcproj
+
+
+clean_objs:
+ rm -f $(OBJS)
+
+clean_skelstub:
+ rm -f *Skel.h *Skel.cpp
+ rm -f *Stub.h *Stub.cpp
+ rm -f *.hh *SK.cc
+ rm -f *S.cpp *S.h *_T.cpp *_T.h *.inl
+
+clean-local: clean_objs clean_skelstub
+ rm -f *.bak *.rpo *.sym lib*.*_pure_*
+ rm -f *.lst *core *~ *loT *.log
+ rm -f Makefile.old
Added: trunk/OpenRTM-aist/src/ext/ec/logical_time/example/LTTSample.conf
===================================================================
--- trunk/OpenRTM-aist/src/ext/ec/logical_time/example/LTTSample.conf (rev 0)
+++ trunk/OpenRTM-aist/src/ext/ec/logical_time/example/LTTSample.conf 2012-02-07 03:02:45 UTC (rev 2313)
@@ -0,0 +1,4 @@
+exec_cxt.periodic.type: ltt_ec
+exec_cxt.periodic.rate: 1000
+exec_cxt.sync_transition: NO
+ec.ltt_ec.sync_tick: NO
Added: trunk/OpenRTM-aist/src/ext/ec/logical_time/example/LTTSample.cpp
===================================================================
--- trunk/OpenRTM-aist/src/ext/ec/logical_time/example/LTTSample.cpp (rev 0)
+++ trunk/OpenRTM-aist/src/ext/ec/logical_time/example/LTTSample.cpp 2012-02-07 03:02:45 UTC (rev 2313)
@@ -0,0 +1,88 @@
+// -*- C++ -*-
+/*!
+ * @file LTTSample.cpp
+ * @brief Console input component
+ * $Date: 2007-04-13 14:59:11 $
+ *
+ * $Id: LTTSample.cpp 1661 2010-01-15 09:12:51Z kurihara $
+ */
+
+#include "LTTSample.h"
+#include <iostream>
+
+// Module specification
+// <rtc-template block="module_spec">
+static const char* consolein_spec[] =
+ {
+ "implementation_id", "LTTSample",
+ "type_name", "LTTSample",
+ "description", "Console input component",
+ "version", "1.0",
+ "vendor", "Noriaki Ando, AIST",
+ "category", "example",
+ "activity_type", "DataFlowComponent",
+ "max_instance", "10",
+ "language", "C++",
+ "lang_type", "compile",
+ ""
+ };
+// </rtc-template>
+
+LTTSample::LTTSample(RTC::Manager* manager)
+ : RTC::DataFlowComponentBase(manager),
+ // <rtc-template block="initializer">
+ m_outOut("out", m_out)
+ // </rtc-template>
+{
+}
+
+LTTSample::~LTTSample()
+{
+}
+
+
+RTC::ReturnCode_t LTTSample::onInitialize()
+{
+ // Registration: InPort/OutPort/Service
+ // <rtc-template block="registration">
+ // Set InPort buffers
+
+ // Set OutPort buffer
+ addOutPort("out", m_outOut);
+
+ // Set service provider to Ports
+
+ // Set service consumers to Ports
+
+ // Set CORBA Service Ports
+
+ // </rtc-template>
+
+ return RTC::RTC_OK;
+}
+
+RTC::ReturnCode_t LTTSample::onExecute(RTC::UniqueId ec_id)
+{
+ std::cout << "Please input number: ";
+ std::cin >> m_out.data;
+ std::cout << "Sending to subscriber: " << m_out.data << std::endl;
+ m_outOut.write();
+
+ return RTC::RTC_OK;
+}
+
+
+extern "C"
+{
+
+ void LTTSampleInit(RTC::Manager* manager)
+ {
+ coil::Properties profile(consolein_spec);
+ manager->registerFactory(profile,
+ RTC::Create<LTTSample>,
+ RTC::Delete<LTTSample>);
+ }
+
+};
+
+
Added: trunk/OpenRTM-aist/src/ext/ec/logical_time/example/LTTSample.h
===================================================================
--- trunk/OpenRTM-aist/src/ext/ec/logical_time/example/LTTSample.h (rev 0)
+++ trunk/OpenRTM-aist/src/ext/ec/logical_time/example/LTTSample.h 2012-02-07 03:02:45 UTC (rev 2313)
@@ -0,0 +1,127 @@
+// -*- C++ -*-
+/*!
+ * @file LTTSample.h
+ * @brief Console input component
+ * @date $Date: 2008-02-29 04:54:45 $
+ *
+ * $Id: LTTSample.h 1402 2009-06-24 05:46:53Z hakuta $
+ */
+
+#ifndef CONSOLEIN_H
+#define CONSOLEIN_H
+
+#include <rtm/idl/BasicDataTypeSkel.h>
+#include <rtm/Manager.h>
+#include <rtm/DataFlowComponentBase.h>
+#include <rtm/CorbaPort.h>
+#include <rtm/DataInPort.h>
+#include <rtm/DataOutPort.h>
+
+// Service implementation headers
+// <rtc-template block="service_impl_h">
+
+// </rtc-template>
+
+// Service Consumer stub headers
+// <rtc-template block="consumer_stub_h">
+
+// </rtc-template>
+
+using namespace RTC;
+
+class LTTSample
+ : public RTC::DataFlowComponentBase
+{
+ public:
+ LTTSample(RTC::Manager* manager);
+ ~LTTSample();
+
+ // The initialize action (on CREATED->ALIVE transition)
+ // formaer rtc_init_entry()
+ virtual RTC::ReturnCode_t onInitialize();
+
+ // The finalize action (on ALIVE->END transition)
+ // formaer rtc_exiting_entry()
+ // virtual RTC::ReturnCode_t onFinalize();
+
+ // The startup action when ExecutionContext startup
+ // former rtc_starting_entry()
+ // virtual RTC::ReturnCode_t onStartup(RTC::UniqueId ec_id);
+
+ // The shutdown action when ExecutionContext stop
+ // former rtc_stopping_entry()
+ // virtual RTC::ReturnCode_t onShutdown(RTC::UniqueId ec_id);
+
+ // The activated action (Active state entry action)
+ // former rtc_active_entry()
+ // virtual RTC::ReturnCode_t onActivated(RTC::UniqueId ec_id);
+
+ // The deactivated action (Active state exit action)
+ // former rtc_active_exit()
+ // virtual RTC::ReturnCode_t onDeactivated(RTC::UniqueId ec_id);
+
+ // The execution action that is invoked periodically
+ // former rtc_active_do()
+ virtual RTC::ReturnCode_t onExecute(RTC::UniqueId ec_id);
+
+ // The aborting action when main logic error occurred.
+ // former rtc_aborting_entry()
+ // virtual RTC::ReturnCode_t onAborting(RTC::UniqueId ec_id);
+
+ // The error action in ERROR state
+ // former rtc_error_do()
+ // virtual RTC::ReturnCode_t onError(RTC::UniqueId ec_id);
+
+ // The reset action that is invoked resetting
+ // This is same but different the former rtc_init_entry()
+ // virtual RTC::ReturnCode_t onReset(RTC::UniqueId ec_id);
+
+ // The state update action that is invoked after onExecute() action
+ // no corresponding operation exists in OpenRTm-aist-0.2.0
+ // virtual RTC::ReturnCode_t onStateUpdate(RTC::UniqueId ec_id);
+
+ // The action that is invoked when execution context's rate is changed
+ // no corresponding operation exists in OpenRTm-aist-0.2.0
+ // virtual RTC::ReturnCode_t onRateChanged(RTC::UniqueId ec_id);
+
+
+ protected:
+ // DataInPort declaration
+ // <rtc-template block="inport_declare">
+
+ // </rtc-template>
+
+
+ // DataOutPort declaration
+ // <rtc-template block="outport_declare">
+ TimedLong m_out;
+ OutPort<TimedLong> m_outOut;
+
+ // </rtc-template>
+
+ // CORBA Port declaration
+ // <rtc-template block="corbaport_declare">
+
+ // </rtc-template>
+
+ // Service declaration
+ // <rtc-template block="service_declare">
+
+ // </rtc-template>
+
+ // Consumer declaration
+ // <rtc-template block="consumer_declare">
+
+ // </rtc-template>
+
+ private:
+
+};
+
+
+extern "C"
+{
+ DLL_EXPORT void LTTSampleInit(RTC::Manager* manager);
+};
+
+#endif // CONSOLEIN_H
Added: trunk/OpenRTM-aist/src/ext/ec/logical_time/example/LTTSampleComp.cpp
===================================================================
--- trunk/OpenRTM-aist/src/ext/ec/logical_time/example/LTTSampleComp.cpp (rev 0)
+++ trunk/OpenRTM-aist/src/ext/ec/logical_time/example/LTTSampleComp.cpp 2012-02-07 03:02:45 UTC (rev 2313)
@@ -0,0 +1,128 @@
+// -*- C++ -*-
+/*!
+ * @file LTTSampleComp.cpp
+ * @brief Standalone component
+ * @date $Date: 2008-01-14 07:45:55 $
+ *
+ * $Id: LTTSampleComp.cpp 778 2008-07-29 04:59:25Z n-ando $
+ */
+
+#include <rtm/Manager.h>
+#include <iostream>
+#include <string>
+#include "LTTSample.h"
+#include <rtm/NVUtil.h>
+#include "../LogicalTimeTriggeredECStub.h"
+
+
+void MyModuleInit(RTC::Manager* manager)
+{
+ LTTSampleInit(manager);
+ RTC::RtcBase* comp;
+
+ // Create a component
+ std::cout << "Creating a component: \"LTTSample\"....";
+ comp = manager->createComponent("LTTSample");
+ std::cout << "succeed." << std::endl;
+
+ RTC::ComponentProfile_var prof;
+ prof = comp->get_component_profile();
+ std::cout << "=================================================" << std::endl;
+ std::cout << " Component Profile" << std::endl;
+ std::cout << "-------------------------------------------------" << std::endl;
+ std::cout << "InstanceID: " << prof->instance_name << std::endl;
+ std::cout << "Implementation: " << prof->type_name << std::endl;
+ std::cout << "Description: " << prof->description << std::endl;
+ std::cout << "Version: " << prof->version << std::endl;
+ std::cout << "Maker: " << prof->vendor << std::endl;
+ std::cout << "Category: " << prof->category << std::endl;
+ std::cout << " Other properties " << std::endl;
+ NVUtil::dump(prof->properties);
+ std::cout << "=================================================" << std::endl;
+
+ PortServiceList* portlist;
+ portlist = comp->get_ports();
+
+ for (CORBA::ULong i(0), n(portlist->length()); i < n; ++i)
+ {
+ PortService_ptr port;
+ port = (*portlist)[i];
+ std::cout << "================================================="
+ << std::endl;
+ std::cout << "Port" << i << " (name): ";
+ std::cout << port->get_port_profile()->name << std::endl;
+ std::cout << "-------------------------------------------------"
+ << std::endl;
+ RTC::PortInterfaceProfileList iflist;
+ iflist = port->get_port_profile()->interfaces;
+
+ for (CORBA::ULong i(0), n(iflist.length()); i < n; ++i)
+ {
+ std::cout << "I/F name: ";
+ std::cout << iflist[i].instance_name << std::endl;
+ std::cout << "I/F type: ";
+ std::cout << iflist[i].type_name << std::endl;
+ const char* pol;
+ pol = iflist[i].polarity == 0 ? "PROVIDED" : "REQUIRED";
+ std::cout << "Polarity: " << pol << std::endl;
+ }
+ std::cout << "- properties -" << std::endl;
+ NVUtil::dump(port->get_port_profile()->properties);
+ std::cout << "-------------------------------------------------" << std::endl;
+ }
+ return;
+}
+
+
+
+int main (int argc, char** argv)
+{
+ RTC::Manager* manager;
+ manager = RTC::Manager::init(argc, argv);
+
+ // Set module initialization proceduer
+ // This procedure will be invoked in activateManager() function.
+ manager->setModuleInitProc(MyModuleInit);
+
+ // Activate manager and register to naming service
+ manager->activateManager();
+
+ // run the manager in blocking mode
+ // runManager(false) is the default.
+ manager->runManager(true);
+
+ // If you want to run the manager in non-blocking mode, do like this
+ // manager->runManager(true);
+
+ RTC::RTObject_impl* rtobj = manager->getComponent("LTTSample0");
+ if (rtobj == NULL)
+ {
+ std::cerr << "rtobj is NULL" << std::endl;
+ abort();
+ }
+ RTC::ExecutionContextList_var eclist = rtobj->get_owned_contexts();
+ std::cout << "EC list: " << eclist->length() <<std::endl;
+
+ if (CORBA::is_nil(eclist[0]))
+ {
+ std::cerr << "EC is nil" << std::endl;
+ abort();
+ }
+
+ OpenRTM::LogicalTimeTriggeredEC_var ttlec;
+ ttlec = OpenRTM::LogicalTimeTriggeredEC::_narrow(eclist[0]);
+ if (CORBA::is_nil(ttlec))
+ {
+ std::cerr << "TTL EC is nil" << std::endl;
+ abort();
+ }
+ for (size_t i(0); i < 100; ++i)
+ {
+ ttlec->tick(i, i * 1000);
+ CORBA::ULong sec, usec;
+ ttlec->get_time(sec, usec);
+ std::cout << "time: " << sec << " [s] " << usec << " [usec]" << std::endl;
+ }
+ manager->shutdown();
+ return 0;
+}
Added: trunk/OpenRTM-aist/src/ext/ec/logical_time/example/Makefile.am
===================================================================
--- trunk/OpenRTM-aist/src/ext/ec/logical_time/example/Makefile.am (rev 0)
+++ trunk/OpenRTM-aist/src/ext/ec/logical_time/example/Makefile.am 2012-02-07 03:02:45 UTC (rev 2313)
@@ -0,0 +1,165 @@
+## -*- Makefile -*-
+##---------------------------------------------------------------------------
+## Makefile.am for ConsoleIn/ConsoleOut components
+##
+## $Id: Makefile.am 2086 2011-05-09 04:46:15Z fsi-katami $
+##---------------------------------------------------------------------------
+
+AUTOMAKE_OPTIONS = 1.4
+
+AM_CPPFLAGS=-I$(top_srcdir)/src/lib -I$(top_srcdir)/src/lib/coil/include -I$(top_srcdir)/src/lib/rtm/idl
+AM_LDFLAGS=-L$(top_builddir) -L$(top_builddir)/src/lib/rtm -L$(top_builddir)/src/lib/rtm/idl
+
+#------------------------------------------------------------
+# Targets
+#------------------------------------------------------------
+# Targets directories
+exampledir = $(rtm_exampledir)
+socompdir = $(exampledir)/rtc
+sourcedir = $(exampledir)/src/ExtTrigger
+
+# Standalone RTCs
+example_PROGRAMS = LTTSampleComp TriggerApp
+example_DATA = rtc.conf
+
+LTTSampleComp_SOURCES = LTTSampleComp.cpp LTTSample.cpp LTTSample.h
+LTTSampleComp_LDADD = $(top_builddir)/src/lib/rtm/libRTC.la \
+ $(top_builddir)/src/lib/coil/lib/libcoil.la \
+ ../libLogicalTimeTriggeredECSkel.la
+LTTSampleComp_LDFLAGS = -L$(top_builddir)/src/lib/rtm/.libs
+
+TriggerApp_SOURCES = TriggerApp.cpp
+TriggerApp_LDADD = \
+ $(top_builddir)/src/lib/rtm/libRTC.la \
+ $(top_builddir)/src/lib/coil/lib/libcoil.la \
+ ../libLogicalTimeTriggeredECSkel.la
+TriggerApp_LDFLAGS = -L$(top_builddir)/src/lib/rtm/.libs
+
+# Example sources
+source_DATA = $(ALL_SRC) $(EXTRA_DIST)
+
+#------------------------------------------------------------
+# Extra distributed files
+#------------------------------------------------------------
+EXTRA_DIST = \
+ run.sh \
+ rtc.conf
+
+ALL_SRC = \
+ $(LTTSampleComp_SOURCES) \
+ $(TriggerApp_SOURCES)
+
+#------------------------------------------------------------
+# File list for deb/ports packages
+#------------------------------------------------------------
+#lst:
+# echo $(ALL_SRC) > src.lst
+# echo $(EXTRA_DIST) > other.lst
+
+#------------------------------------------------------------
+# Visual Studio Project
+#------------------------------------------------------------
+win32_builddir=$(top_builddir)/win32/OpenRTM-aist/examples/LTTSample
+
+vcproj: vc8proj vc9proj vc10proj
+
+vc8proj:
+ $(top_builddir)/build/vcprojtool.py vcproj \
+ --type EXE \
+ --vcversion "8.00" \
+ --projectname "LTTSampleComp" \
+ --version $(RTM_VERSION) \
+ --out $(win32_builddir)/LTTSample_vc8.vcproj \
+ --yaml ../rtc.vcproj.yaml \
+ --source LTTSample.cpp LTTSampleComp.cpp \
+ --header LTTSample.h
+ qkc -sm $(win32_builddir)/LTTSample_vc8.vcproj
+ $(top_builddir)/build/vcprojtool.py vcproj \
+ --type DLL \
+ --vcversion "8.00" \
+ --projectname "LTTSample" \
+ --version $(RTM_VERSION) \
+ --out $(win32_builddir)/LTTSampleDll_vc8.vcproj \
+ --yaml ../rtcdll.vcproj.yaml \
+ --source LTTSample.cpp \
+ --header LTTSample.h
+ qkc -sm $(win32_builddir)/LTTSampleDll_vc8.vcproj
+ $(top_builddir)/build/vcprojtool.py vcproj \
+ --type EXE \
+ --vcversion "8.00" \
+ --projectname "TriggerApp" \
+ --version $(RTM_VERSION) \
+ --out $(win32_builddir)/TriggerApp_vc8.vcproj \
+ --yaml ../rtc.vcproj.yaml \
+ --source TriggerApp.cpp
+ qkc -sm $(win32_builddir)/TriggerApp_vc8.vcproj
+
+vc9proj:
+ $(top_builddir)/build/vcprojtool.py vcproj \
+ --type EXE \
+ --vcversion "9.00" \
+ --projectname "LTTSampleComp" \
+ --version $(RTM_VERSION) \
+ --out $(win32_builddir)/LTTSample_vc9.vcproj \
+ --yaml ../rtc.vcproj.yaml \
+ --source LTTSample.cpp LTTSampleComp.cpp \
+ --header LTTSample.h
+ qkc -sm $(win32_builddir)/LTTSample_vc9.vcproj
+ $(top_builddir)/build/vcprojtool.py vcproj \
+ --type DLL \
+ --vcversion "9.00" \
+ --projectname "LTTSample" \
+ --version $(RTM_VERSION) \
+ --out $(win32_builddir)/LTTSampleDll_vc9.vcproj \
+ --yaml ../rtcdll.vcproj.yaml \
+ --source LTTSample.cpp \
+ --header LTTSample.h
+ qkc -sm $(win32_builddir)/LTTSampleDll_vc9.vcproj
+ $(top_builddir)/build/vcprojtool.py vcproj \
+ --type EXE \
+ --vcversion "9.00" \
+ --projectname "TriggerAppComp" \
+ --version $(RTM_VERSION) \
+ --out $(win32_builddir)/TriggerApp_vc9.vcproj \
+ --yaml ../rtc.vcproj.yaml \
+ --source TriggerApp.cpp
+ qkc -sm $(win32_builddir)/TriggerApp_vc9.vcproj
+
+vc10proj:
+ $(top_builddir)/build/vcxprojtool.py vcxproj \
+ --type EXE \
+ --vcversion "10.00" \
+ --projectname "LTTSampleComp" \
+ --version $(RTM_VERSION) \
+ --out $(win32_builddir)/LTTSample_vc10.vcxproj \
+ --yaml ../rtc.vcxproj.yaml \
+ --source LTTSample.cpp LTTSampleComp.cpp \
+ --header LTTSample.h
+ qkc -sm $(win32_builddir)/LTTSample_vc10.vcxproj
+ $(top_builddir)/build/vcxprojtool.py vcxproj \
+ --type DLL \
+ --vcversion "10.00" \
+ --projectname "LTTSample" \
+ --version $(RTM_VERSION) \
+ --out $(win32_builddir)/LTTSampleDll_vc10.vcxproj \
+ --yaml ../rtcdll.vcxproj.yaml \
+ --source LTTSample.cpp \
+ --header LTTSample.h
+ qkc -sm $(win32_builddir)/LTTSampleDll_vc10.vcxproj
+ $(top_builddir)/build/vcxprojtool.py vcxproj \
+ --type EXE \
+ --vcversion "10.00" \
+ --projectname "TriggerAppComp" \
+ --version $(RTM_VERSION) \
+ --out $(win32_builddir)/TriggerApp_vc10.vcxproj \
+ --yaml ../rtc.vcxproj.yaml \
+ --source TriggerApp.cpp
+ qkc -sm $(win32_builddir)/TriggerApp_vc10.vcxproj
+
+dist-hook: lst
+
+clean-local:
+ rm -f \
+ *.bak *.rpo *.sym lib*.*_pure_* *.lst \
+ Makefile.old *core *~ *.so *.log
+ rm -f $(example_PROGRAMS)
Added: trunk/OpenRTM-aist/src/ext/ec/logical_time/example/TriggerApp.cpp
===================================================================
--- trunk/OpenRTM-aist/src/ext/ec/logical_time/example/TriggerApp.cpp (rev 0)
+++ trunk/OpenRTM-aist/src/ext/ec/logical_time/example/TriggerApp.cpp 2012-02-07 03:02:45 UTC (rev 2313)
@@ -0,0 +1,226 @@
+// -*- C++ -*-
+/*!
+ * @file ConnectorComp.cpp
+ * @brief connector application
+ * @date $Date: 2008-01-13 07:24:05 $
+ *
+ * Copyright (c) 2003-2007 Noriaki Ando <n-ando at aist.go.jp>
+ * Task-intelligence Research Group,
+ * Intelligent System Research Institute,
+ * National Institute of Industrial Science (AIST), Japan
+ * All rights reserved.
+ *
+ * $Id: ConnectorComp.cpp 1429 2009-07-06 08:28:25Z hakuta $
+ */
+
+#include <iostream>
+#include <vector>
+#include <string>
+#include <rtm/idl/OpenRTMSkel.h>
+#include <rtm/CorbaNaming.h>
+#include <rtm/RTObject.h>
+#include <rtm/NVUtil.h>
+#include <rtm/CORBA_SeqUtil.h>
+#include <rtm/CorbaConsumer.h>
+#include <assert.h>
+#include <coil/stringutil.h>
+
+
+using namespace RTC;
+
+void usage()
+{
+ std::cout << std::endl;
+ std::cout << "usage: ConnectorCompExt [options].." << std::endl;
+ std::cout << std::endl;
+ std::cout << " --flush ";
+ std::cout << ": Set subscription type flush" << std::endl;
+ std::cout << " --new ";
+ std::cout << ": Set subscription type new" << std::endl;
+ std::cout << " --periodic [Hz] ";
+ std::cout << ": Set subscription type periodic" << std::endl;
+ std::cout << " --policy [any] ";
+ std::cout << ": Set push policy ALL or FIFO or SKIP or NEW" << std::endl;
+ std::cout << " --skip [n] ";
+ std::cout << ": Set skip count 0..n" << std::endl;
+ std::cout << std::endl;
+ std::cout << "exsample:" << std::endl;
+ std::cout << " ConnectorCompExt --flush" << std::endl;
+ std::cout << " ConnectorCompExt --new" << std::endl;
+ std::cout << " ConnectorCompExt --new --policy ALL" << std::endl;
+ std::cout << " ConnectorCompExt --new --policy SKIP --skip 100" << std::endl;
+ std::cout << " ConnectorCompExt --periodic 10" << std::endl;
+ std::cout << " ConnectorCompExt --periodic 10 --policy FIFO" << std::endl;
+ std::cout << " ConnectorCompExt --periodic 10 --policy NEW" << std::endl;
+ std::cout << std::endl;
+}
+
+int main (int argc, char** argv)
+{
+ int _argc(0);
+ char** _argv(0);
+
+ std::string subs_type("flush");
+ std::string period("1.0");
+ std::string push_policy("");
+ std::string skip_count("1");
+ if (argc < 2)
+ {
+ usage();
+ exit(1);
+ }
+
+ for (int i = 1; i < argc; ++i)
+ {
+ std::string arg(argv[i]);
+ coil::normalize(arg);
+ if (arg == "--flush") subs_type = "flush";
+ else if (arg == "--new") subs_type = "new";
+ else if (arg == "--periodic")
+ {
+ subs_type = "periodic";
+ if (++i < argc) period = argv[i];
+ else period = "1.0";
+ }
+ else if (arg == "--help")
+ {
+ usage();
+ exit(1);
+ }
+ else if (arg == "--policy")
+ {
+ if (++i < argc)
+ {
+ std::string arg2(argv[i]);
+ coil::normalize(arg2);
+ push_policy = arg2;
+ }
+ else push_policy = "new";
+ }
+ else if (arg == "--skip")
+ {
+ if (++i < argc) skip_count = argv[i];
+ else skip_count = "0";
+ }
+ else
+ {
+ subs_type = "flush";
+ }
+ }
+
+ std::cout << "Subscription Type: " << subs_type << std::endl;
+ if (period != "")
+ std::cout << "Period: " << period << " [Hz]" << std::endl;
+ std::cout << "push policy: " << push_policy << std::endl;
+ std::cout << "skip count: " << skip_count << std::endl;
+
+
+ CORBA::ORB_var orb = CORBA::ORB_init(_argc, _argv);
+ CorbaNaming naming(orb, "localhost:9876");
+
+ CorbaConsumer<RTObject> conin, conout;
+ CorbaConsumer<OpenRTM::ExtTrigExecutionContextService> ec0, ec1;
+
+ PortServiceList_var pin;
+ PortServiceList_var pout;
+
+ // find ConsoleIn0 component
+ conin.setObject(naming.resolve("ConsoleIn0.rtc"));
+
+ // get ports
+ pin = conin->get_ports();
+ pin[(CORBA::ULong)0]->disconnect_all();
+ assert(pin->length() > 0);
+ // activate ConsoleIn0
+ ExecutionContextList_var eclisti;
+ eclisti = conin->get_owned_contexts();
+ eclisti[(CORBA::ULong)0]->activate_component(RTObject::_duplicate(conin._ptr()));
+ ec0.setObject(eclisti[(CORBA::ULong)0]);
+
+ // find ConsoleOut0 component
+ conout.setObject(naming.resolve("ConsoleOut0.rtc"));
+ // get ports
+ pout = conout->get_ports();
+ pout[(CORBA::ULong)0]->disconnect_all();
+ assert(pout->length() > 0);
+ // activate ConsoleOut0
+ ExecutionContextList_var eclisto;
+ eclisto = conout->get_owned_contexts();
+ eclisto[(CORBA::ULong)0]->activate_component(RTObject::_duplicate(conout._ptr()));
+ ec1.setObject(eclisto[(CORBA::ULong)0]);
+
+ // connect ports
+ ConnectorProfile prof;
+ prof.connector_id = "";
+ prof.name = CORBA::string_dup("connector0");
+ prof.ports.length(2);
+ prof.ports[0] = pin[(CORBA::ULong)0];
+ prof.ports[1] = pout[(CORBA::ULong)0];
+ CORBA_SeqUtil::push_back(prof.properties,
+ NVUtil::newNV("dataport.interface_type",
+ "corba_cdr"));
+ CORBA_SeqUtil::push_back(prof.properties,
+ NVUtil::newNV("dataport.dataflow_type",
+ "push"));
+ if (subs_type != "")
+ CORBA_SeqUtil::push_back(prof.properties,
+ NVUtil::newNV("dataport.subscription_type",
+ subs_type.c_str()));
+ else
+ CORBA_SeqUtil::push_back(prof.properties,
+ NVUtil::newNV("dataport.subscription_type",
+ "flush"));
+ if (subs_type == "periodic" && period != "")
+ CORBA_SeqUtil::push_back(prof.properties,
+ NVUtil::newNV("dataport.publisher.push_rate",
+ period.c_str()));
+ if (push_policy != "")
+ CORBA_SeqUtil::push_back(prof.properties,
+ NVUtil::newNV("dataport.publisher.push_policy",
+ push_policy.c_str()));
+ if (push_policy == "skip" && skip_count != "")
+ CORBA_SeqUtil::push_back(prof.properties,
+ NVUtil::newNV("dataport.publisher.skip_count",
+ skip_count.c_str()));
+
+ ReturnCode_t ret;
+ ret = pin[(CORBA::ULong)0]->connect(prof);
+ assert(ret == RTC::RTC_OK);
+
+ std::cout << "Connector ID: " << prof.connector_id << std::endl;
+ NVUtil::dump(prof.properties);
+
+ std::string cmd;
+ while (1)
+ {
+ try
+ {
+ std::cout << std::endl;
+ std::cout << std::endl;
+ std::cout << "0: tick ConsoleIn component" << std::endl;
+ std::cout << "1: tick ConsoleOut component" << std::endl;
+ std::cout << "2: tick both components" << std::endl;
+ std::cout << "cmd? >";
+ std::cin >> cmd;
+ if (cmd == "0")
+ {
+ ec0->tick();
+ }
+ else if (cmd == "1")
+ {
+ ec1->tick();
+ }
+ else if (cmd == "2")
+ {
+ ec0->tick();
+ ec1->tick();
+ }
+ }
+ catch (...)
+ {
+ }
+ }
+ orb->destroy();
+ exit(1);
+}
+
Added: trunk/OpenRTM-aist/src/ext/ec/logical_time/example/rtc.conf
===================================================================
--- trunk/OpenRTM-aist/src/ext/ec/logical_time/example/rtc.conf (rev 0)
+++ trunk/OpenRTM-aist/src/ext/ec/logical_time/example/rtc.conf 2012-02-07 03:02:45 UTC (rev 2313)
@@ -0,0 +1,14 @@
+corba.nameservers: localhost
+naming.formats: %n.rtc
+logger.log_level: PARANOID
+logger.date_format: %b %d %H:%M:%S.%Q.%q
+logger.clock_type: logical
+exec_cxt.periodic.type: ltt_ec
+exec_cxt.periodic.rate: 1000
+exec_cxt.sync_transition: NO
+manager.modules.load_path: ../.libs, ../../../local_service/nameservice_file/.libs
+manager.modules.preload: LogicalTimeTriggeredEC.so
+manager.modules.abs_path_allowed: yes
+manager.local_service.modules: FileNameservice.so
+ec.ltt_ec.sync_tick: YES
+example.LTTSample.config_file: LTTSample.conf
Added: trunk/OpenRTM-aist/src/ext/ec/logical_time/example/run.sh
===================================================================
--- trunk/OpenRTM-aist/src/ext/ec/logical_time/example/run.sh (rev 0)
+++ trunk/OpenRTM-aist/src/ext/ec/logical_time/example/run.sh 2012-02-07 03:02:45 UTC (rev 2313)
@@ -0,0 +1,56 @@
+#!/bin/sh
+#
+# @file run.sh
+# @brief SimpleIO example startup script
+# @date $Date: 2007-04-27 06:12:53 $
+#
+# Copyright (c) 2003-2007 Noriaki Ando <n-ando at aist.go.jp>
+# Task-intelligence Research Group,
+# Intelligent System Research Institute,
+# National Institute of Industrial Science (AIST), Japan
+# All rights reserved.
+#
+# $Id: run.sh 1421 2009-07-01 07:19:36Z hakuta $
+#
+
+nsport='9876'
+hostname=`hostname`
+
+
+term=`which kterm`
+
+if test "x$term" = "x" ; then
+ term=`which xterm`
+fi
+
+if test "x$term" = "x" ; then
+ term=`which uxterm`
+fi
+
+if test "x$term" = "x" ; then
+ term=`which gnome-terminal`
+fi
+
+if test "x$term" = "x" ; then
+ echo "No terminal program (kterm/xterm/gnome-terminal) exists."
+ exit
+fi
+
+../../utils/rtm-naming/rtm-naming $nsport
+
+echo 'corba.nameservers: '$hostname':'$nsport > ./rtc.conf
+echo 'naming.formats: %n.rtc' >> ./rtc.conf
+echo 'logger.log_level: TRACE' >> ./rtc.conf
+echo 'exec_cxt.periodic.type: ExtTrigExecutionContext' >> ./rtc.conf
+echo 'exec_cxt.periodic.rate: 1000' >> ./rtc.conf
+
+$term -e ./ConsoleInCompExt &
+$term -e ./ConsoleOutCompExt &
+
+sleep 5
+./ConnectorCompExt
+
+#sleep 10
+#nspid=`ps -ax | grep 9876 | awk '{print $1}'`
+#kill $nspid
+#echo 'Naming service was stopped.'
openrtm-commit メーリングリストの案内