[openrtm-commit:01641] r742 - in branches/RELENG_1_1: . jp.go.aist.rtm.RTC jp.go.aist.rtm.RTC/idl jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext
openrtm @ openrtm.org
openrtm @ openrtm.org
2015年 10月 29日 (木) 15:49:41 JST
Author: kawauchi
Date: 2015-10-29 15:49:41 +0900 (Thu, 29 Oct 2015)
New Revision: 742
Added:
branches/RELENG_1_1/jp.go.aist.rtm.RTC/idl/Logger.idl
branches/RELENG_1_1/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/LoggerConsumer.java
branches/RELENG_1_1/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/RTObjectStateMachine.java
branches/RELENG_1_1/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/ExecutionContextWorker.java
Modified:
branches/RELENG_1_1/
branches/RELENG_1_1/jp.go.aist.rtm.RTC/
branches/RELENG_1_1/jp.go.aist.rtm.RTC/build.xml
branches/RELENG_1_1/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/DefaultConfiguration.java
branches/RELENG_1_1/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/Manager.java
branches/RELENG_1_1/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/RTObject_impl.java
branches/RELENG_1_1/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/StateMachine.java
Log:
[compat,merge] r662,663,670,672,673 merged from trunk.
Property changes on: branches/RELENG_1_1
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/RELENG_1_0_0:60-401
/branches/work/ConfigurationCallback:631-635
/branches/work/ForComponentActionListener:521-522
/branches/work/ForComponentObserverConsumer:534-543
/branches/work/ForConfigurationListener:524-526
/branches/work/ForFileNameservice:623-628
/branches/work/ForLogFormat:518-519
/branches/work/ForPortConnectListener:528-532
/branches/work/ForSDOServiceAdminClass:505-507
/branches/work/SourceSharing:591-603
/branches/work/ToGetProperties:545-548
/branches/work/ToIFR_ID:509-514
/trunk:621-622,629-658
+ /branches/RELENG_1_0_0:60-401
/branches/work/ConfigurationCallback:631-635
/branches/work/ForComponentActionListener:521-522
/branches/work/ForComponentObserverConsumer:534-543
/branches/work/ForConfigurationListener:524-526
/branches/work/ForFileNameservice:623-628
/branches/work/ForLogFormat:518-519
/branches/work/ForPortConnectListener:528-532
/branches/work/ForSDOServiceAdminClass:505-507
/branches/work/LoggerService:666-669
/branches/work/SourceSharing:591-603
/branches/work/ToGetProperties:545-548
/branches/work/ToIFR_ID:509-514
/trunk:621-622,629-658,662-663,670,672-673
Property changes on: branches/RELENG_1_1/jp.go.aist.rtm.RTC
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/RELENG_1_0/jp.go.aist.rtm.RTC:408-498
/branches/RELENG_1_0_0/jp.go.aist.rtm.RTC:60-401
/branches/work/ConfigurationCallback/jp.go.aist.rtm.RTC:631-635
/branches/work/ForComponentActionListener/jp.go.aist.rtm.RTC:521-522
/branches/work/ForComponentObserverConsumer/jp.go.aist.rtm.RTC:534-543
/branches/work/ForConfigurationListener/jp.go.aist.rtm.RTC:524-526
/branches/work/ForFileNameservice/jp.go.aist.rtm.RTC:623-628
/branches/work/ForLogFormat/jp.go.aist.rtm.RTC:518-519
/branches/work/ForPortConnectListener/jp.go.aist.rtm.RTC:528-532
/branches/work/ForSDOServiceAdminClass/jp.go.aist.rtm.RTC:505-507
/branches/work/SourceSharing/jp.go.aist.rtm.RTC:591-603
/branches/work/ToGetProperties/jp.go.aist.rtm.RTC:545-548
/branches/work/ToIFR_ID/jp.go.aist.rtm.RTC:509-514
/trunk/jp.go.aist.rtm.RTC:621-622,629-658
+ /branches/RELENG_1_0/jp.go.aist.rtm.RTC:408-498
/branches/RELENG_1_0_0/jp.go.aist.rtm.RTC:60-401
/branches/work/ConfigurationCallback/jp.go.aist.rtm.RTC:631-635
/branches/work/ForComponentActionListener/jp.go.aist.rtm.RTC:521-522
/branches/work/ForComponentObserverConsumer/jp.go.aist.rtm.RTC:534-543
/branches/work/ForConfigurationListener/jp.go.aist.rtm.RTC:524-526
/branches/work/ForFileNameservice/jp.go.aist.rtm.RTC:623-628
/branches/work/ForLogFormat/jp.go.aist.rtm.RTC:518-519
/branches/work/ForPortConnectListener/jp.go.aist.rtm.RTC:528-532
/branches/work/ForSDOServiceAdminClass/jp.go.aist.rtm.RTC:505-507
/branches/work/LoggerService/jp.go.aist.rtm.RTC:666-669
/branches/work/SourceSharing/jp.go.aist.rtm.RTC:591-603
/branches/work/ToGetProperties/jp.go.aist.rtm.RTC:545-548
/branches/work/ToIFR_ID/jp.go.aist.rtm.RTC:509-514
/trunk/jp.go.aist.rtm.RTC:621-622,629-658,662-663,670,672-673
Modified: branches/RELENG_1_1/jp.go.aist.rtm.RTC/build.xml
===================================================================
--- branches/RELENG_1_1/jp.go.aist.rtm.RTC/build.xml 2015-10-29 06:36:36 UTC (rev 741)
+++ branches/RELENG_1_1/jp.go.aist.rtm.RTC/build.xml 2015-10-29 06:49:41 UTC (rev 742)
@@ -117,6 +117,8 @@
<property name="idl.ComponentObserver" value="${idl.path}/ComponentObserver.idl" />
+ <property name="idl.Logger" value="${idl.path}/Logger.idl" />
+
<property name="idl.test.CorbaConsumer" value="${idl.path.tests}/CorbaConsumer/Hello.idl" />
<property name="idl.test.CorbaPort" value="${idl.path.tests}/CorbaPort/MyService.idl" />
@@ -474,6 +476,12 @@
</exec>
+ <exec executable="${java.home}\..\bin\idlj">
+
+ <arg line="-v -fall -td ${source} -i ${idl.path} -emitAll ${idl.Logger}"/>
+
+ </exec>
+
</target>
Copied: branches/RELENG_1_1/jp.go.aist.rtm.RTC/idl/Logger.idl (from rev 670, trunk/jp.go.aist.rtm.RTC/idl/Logger.idl)
===================================================================
--- branches/RELENG_1_1/jp.go.aist.rtm.RTC/idl/Logger.idl (rev 0)
+++ branches/RELENG_1_1/jp.go.aist.rtm.RTC/idl/Logger.idl 2015-10-29 06:49:41 UTC (rev 742)
@@ -0,0 +1,388 @@
+// -*- IDL -*-
+/*!
+ * @file Logger.idl
+ * @brief Component logger SDO service
+ * @date $Date$
+ * @author Noriaki Ando <n-ando at aist.go.jp>
+ *
+ * Copyright (C) 2011
+ * Noriaki Ando
+ * Intelligent Systems Research Institute,
+ * National Institute of
+ * Advanced Industrial Science and Technology (AIST), Japan
+ * All rights reserved.
+ *
+ * $Id$
+ *
+ */
+
+#include <BasicDataType.idl>
+#include <SDOPackage.idl>
+/*!
+ * @if jp
+ * @brief コンポーネントログ収集サービスインターフェース
+ *
+ * コンポーネントのログ情報を外部から取得するためのインターフェース。コ
+ * ンポーネントに対して、本SDOサービスオブジェクトをアタッチすることで、
+ * コンポーネントが出力するログを外部から取得することができる。
+ *
+ * @since 1.1
+ *
+ * @else
+ * @brief Component logging service interface
+ *
+ * This interface defines logging service of an RT-Component from
+ * outside. Attaching this service interface to an RT-Component, you
+ * can get logging information from the RT-Component.
+ *
+ * @since 1.1
+ * @endif
+ *
+ */
+module OpenRTM
+{
+ /*!
+ * @if jp
+ *
+ * @brief ログレベル
+ *
+ * ログレベル。ログレベルは9段階あり、それぞれ以下の意味を持つ。
+ *
+ * - SILENT : ロギング機能をオフにするための疑似レベル
+ * - ERROR : エラーが発生したことを意味するログレベル
+ * - WARN : エラーではないが注意すべき警告を意味するログレベル
+ * - INFO : 付加的な情報を提供するためのログレベル
+ * - NORMAL : 通常の情報を提供するためのログレベル
+ * - DEBUG : デバッグ情報を提供する際のログレベル
+ * - TRACE : トレースレベルの情報を提供する際のログレベル
+ * - VERBOSE : トレース情報以上に詳細な情報を提供する際のログレベル
+ * - PARANOID: リアルタイム周期処理実行時等の情報を提供するログレベル
+ *
+ * @else
+ *
+ * @brief Log level
+ *
+ * This enumeration defines log levels. The log level consists of
+ * nine levels, and each level means the following meaning.
+ *
+ * - SILENT : Pseudo log level to stop logging function.
+ * - ERROR : This log level means that an error event is occurring.
+ * - WARN : This log level means that a warning event is occurring.
+ * - INFO : This log level used to notify information.
+ * - NORMAL : This log level means that an event is normal thing.
+ * - DEBUG : This log level used to notify debugging information.
+ * - TRACE : This log level used to notify trace information.
+ * - VERBOSE : This log level used to notify more detailed information.
+ * - PARANOID: This is used only to notify information in real-time loop.
+ *
+ * @endif
+ */
+ enum LogLevel
+ {
+ SILENT,
+ ERROR,
+ WARN,
+ INFO,
+ NORMAL,
+ DEBUG,
+ TRACE,
+ VERBOSE,
+ PARANOID
+ };
+
+ /*!
+ * @if jp
+ * @brief ログレコード構造体
+ *
+ * ログメッセージを含むログ情報を保持する構造体
+ *
+ * @else
+ * @brief Log record structure
+ *
+ * This struct defines logging information including log message.
+ *
+ * @endif
+ *
+ */
+ struct LogRecord
+ {
+ /*!
+ * @if jp
+ * @brief 時刻
+ * タイムスタンプ
+ * @else
+ * @brief Time
+ * Time stump.
+ * @endif
+ */
+ RTC::Time time;
+
+ /*!
+ * @if jp
+ * @brief ロガー名
+ * ログを書きこんだロガーオブジェクト名
+ * @else
+ * @brief logger name
+ * The logger name which writes this record.
+ * @endif
+ */
+ string loggername;
+
+ /*!
+ * @if jp
+ * @brief ログレベル
+ * このレコードのログレベル
+ * @else
+ * @brief Log level
+ * The log level of this record
+ * @endif
+ */
+ LogLevel level;
+
+ /*!
+ * @if jp
+ * @brief メッセージ
+ * ログメッセージ
+ * @else
+ * @brief Message
+ * Log message.
+ * @endif
+ */
+ string message;
+ };
+
+
+ /*!
+ * @if jp
+ *
+ * @interface Logger インターフェース
+ *
+ * 個別のRTCのログ情報を取得するためのサービスインターフェース。SDO
+ * Service として対象となるRTC/SDOに対してアタッチされ、RTC/SDOのログ
+ * 情報を外部から取得する。実際の処理シーケンスは以下の通りである。
+ *
+ * -# SDO::get_configuration() により Configuration オブジェクトを取得
+ * -# Configuration::add_service_profile() によりTool側の
+ * Logger を ServiceProfile により RTC に与える。
+ * ServiceProfile のメンバーは以下のように設定すること
+ * - id: UUID など一意なIDを設定する。削除時にも必要になるので、Tool
+ * 側ではIDを保持しておかなければならない。
+ * - interface_type: 当該サービスのIFRのIDを文字列として指定。RTC側で
+ * はこの文字列により当該サービスオブジェクトを受け入れるか決定す
+ * るため指定は必須となる。
+ * - properties: RTC側のサービスの受け入れ側に通知するプロパティを設
+ * 定する。このサービスでは、下記のログレベル関連のプロパティを
+ * 指定する。
+ * - service: SDOService オブジェクトの参照を指定する。
+ * -# RTC側でロガーへの書き込みが有った場合には publish() オペレーション
+ * が LogRecord 構造体としてログメッセージやタイムスタンプをサー
+ * ビス側に通知する。サービスを保持する側では、LogRecord内の情報
+ * をファイルに書き込む、表示する等の方法で利用することができる。
+ * -# RTC側が終了するときには、close() オペレーションが呼び出されるの
+ * で、サービス提供側は適切な終了処理を行う必要がある。close()が呼
+ * ばれた場合は、remove_service_profile() により明示的にサービスを
+ * 削除する必要はない。またRTC側ではclose() を呼んだ後は、当該サー
+ * ビスに関する情報やリソースを適切に開放しなければならない。
+ * -# ツール等のサービス提供側が終了する場合などは、
+ * remove_service_profile() オペレーションを呼び出し、当該RTC上の
+ * リソースを適切に開放する必要がある。RTC側は、
+ * remove_service_profile() が呼び出された際には、当該ロギングに関
+ * するリソースを適切に開放する必要がある。
+ *
+ * 上記のプロセスを下記シーケンス図に示す。
+ *
+ * <pre>
+ *
+ * [RTC] [Configuration] [Logger] [Tool]
+ * | | | |
+ * | | get_configuration() | |
+ * |<------------------------------------------------|
+ * | | | |
+ * | | add_service_profile(prof) |
+ * | |<-----------------------------------|
+ * | | | |
+ * | | publish(logrecord) | |
+ * |----------------------------------->| |
+ * | | publish(logrecord) | |
+ * |----------------------------------->| |
+ * | | : | |
+ * | | : | |
+ * | | 1) RTCが先に終了するとき |
+ * | | : | |
+ * | | [close()] | |
+ * |----------------------------------->| |
+ * | | : | |
+ * | | 2) ツールがロギングを終了するとき |
+ * | | : | |
+ * | | remove_service_profile(id) |
+ * | |<-----------------------------------|
+ * | | | |
+ * | | x x
+ *
+ * </pre>
+ *
+ * なお、ServiceProfile::properties に指定するプロパティとしては、
+ *
+ * - logger.log_level: (ERROR, WARN, INFO, NORMAL, DEBUG, TRACE, VERBOSE,
+ * PARANOID)
+ * - logger.filter: logger name or "ALL"
+ *
+ * がある、
+ *
+ * - logger.log_level: ERROR, WARN, INFO, NORMAL, DEBUG, TRACE,
+ * VERBOSE またはPARANOID のうち一つを指定する。無指定の場合は
+ * NORMAL と同等となる。指定されたレベルと同等あるいはそれより重要
+ * な情報がロギングされる。すなわち、それぞれのログレベルを指定した
+ * 際に出力されるログは以下の関係になる。
+ * - ERROR : (ERROR)
+ * - WARN : (ERROR, WARN)
+ * - INFO : (ERROR, WARN, INFO)
+ * - NORMAL : (ERROR, WARN, INFO, NORMAL)
+ * - DEBUG : (ERROR, WARN, INFO, NORMAL, DEBUG)
+ * - TRACE : (ERROR, WARN, INFO, NORMAL, DEBUG, TRACE)
+ * - VERBOSE : (ERROR, WARN, INFO, NORMAL, DEBUG, TRACE, VERBOSE)
+ * - PARANOID: (ERROR, WARN, INFO, NORMAL, DEBUG, TRACE, VERBOSE, PARA)
+ * - logger.filter: RTC内部は、RTC本体、データポート、サービスポート
+ * 等それぞれのオブジェクトにロガーオブジェクトが存在する。このプロ
+ * パティはロギングする対象のロガーオブジェクトをカンマ区切りで指定
+ * する。または、ALLを指定することでRTC配下のすべてのロギングオブジェ
+ * クトからのメッセージを受信する。無指定の場合はALLと同等になる。
+ *
+ * @else
+ * @class
+ *
+ * @interface Logger interface
+ *
+ * This interface defines logging service for each RT-Component.
+ * This service would be attached to a target RTC/SDO, and provides
+ * functionality to collect log information from remote
+ * applications. Actual process sequences are the following.
+ *
+ * -# Get configuration object by SDO::get_configuration()
+ * -# Attach Logger object with ServiceProfile by
+ * Configuration::add_service_profile(). ServiceProfile should be
+ * set as follows.
+ * - id: An unique ID like UUID. This ID is used when this service
+ * is removed. Tools or applications should keep the ID for
+ * this.
+ * - interface_type: Specify this service's IFR ID in string. This
+ * string is used to search available service in the RTC,
+ * and if it matches with available SDO services, this
+ * service is accepted.
+ * - properties: This member specifies properties to notify
+ * information to the target RTC. The following properties
+ * for log level and others would be specified in this
+ * properties.
+ *
+ * - service: A SDOService object reference is specified.
+ * -# When logging occurs in the RTC side, the "publish()" operation
+ * notifies a log message, time stump and so on to the service
+ * provider as a LogRecord structure. The service provider can
+ * use notified information for example writing to files and
+ * showing them on the display.
+ * -# When RTC is terminated, the "close()" operation is called, and
+ * the service provider has to terminate the logging service
+ * properly. In this case, tools and applications that have
+ * service provider do not need to call remove_service_profile()
+ * and remove the service explicitly. After calling close()
+ * operation, the RTC has to release the service profile and
+ * resources.
+ * -# When tools and applications terminate services, they have to
+ * call remove_service_profile() operation, and have to release
+ * resources in the target RTC. When remove_service_profile() is
+ * called, the RTC have to release service profile and resources
+ * for this service.
+ *
+ * The following diagram shows above mentioned sequence.
+ *
+ * <pre>
+ *
+ * [RTC] [Configuration] [Logger] [Tool]
+ * | | | |
+ * | | get_configuration() | |
+ * |<------------------------------------------------|
+ * | | | |
+ * | | add_service_profile(prof) |
+ * | |<-----------------------------------|
+ * | | | |
+ * | | publish(logrecord) | |
+ * |----------------------------------->| |
+ * | | publish(logrecord) | |
+ * |----------------------------------->| |
+ * | | : | |
+ * | | : | |
+ * | | 1) When RTC is terminated |
+ * | | : | |
+ * | | [close()] | |
+ * |----------------------------------->| |
+ * | | : | |
+ * | | 2) When tool terminates logging |
+ * | | : | |
+ * | | remove_service_profile(id) |
+ * | |<-----------------------------------|
+ * | | | |
+ * | | x x
+ *
+ * </pre>
+ *
+ * So far, the following properties for ServiceProfile::properties
+ * are available.
+ *
+ * - logger.log_level: (ERROR, WARN, INFO, NORMAL, DEBUG, TRACE, VERBOSE,
+ * PARANOID)
+ * - logger.filter: logger name or "ALL"
+ *
+ *
+ * - logger.log_level: One of ERROR, WARN, INFO, NORMAL, DEBUG,
+ * TRACE, VERBOSE or PARANOID can be specified. If no
+ * properties are specified, it will be NORMAL. Log messages
+ * equals and/or more important specified log level would be
+ * published. The following list shows the relation between
+ * specified level and published level.
+ * - ERROR : (ERROR)
+ * - WARN : (ERROR, WARN)
+ * - INFO : (ERROR, WARN, INFO)
+ * - NORMAL : (ERROR, WARN, INFO, NORMAL)
+ * - DEBUG : (ERROR, WARN, INFO, NORMAL, DEBUG)
+ * - TRACE : (ERROR, WARN, INFO, NORMAL, DEBUG, TRACE)
+ * - VERBOSE : (ERROR, WARN, INFO, NORMAL, DEBUG, TRACE, VERBOSE)
+ * - PARANOID: (ERROR, WARN, INFO, NORMAL, DEBUG, TRACE, VERBOSE, PARA)
+ * - logger.filter: Some logger objects exist in some object of an
+ * RTC such as RTC body, data port, service port and so on.
+ * Some logger objects exist in some object of an RTC such as
+ * RTC body, data port, service port and so on. This properties
+ * specify target logger names separated with commas. If ALL is
+ * specified, all the logger's messages under the target RTC's
+ * logger would be published. If no property is specified, all
+ * the messages will be published.
+ *
+ * @endif
+ *
+ */
+ interface Logger
+ : SDOPackage::SDOService
+ {
+ /*!
+ * @if jp
+ * @brief ログメッセージ配信
+ * ログメッセージを配信する
+ * @else
+ * @brief Publish log message
+ * This operation publishes log message.
+ * @endif
+ */
+ oneway void publish(in LogRecord record);
+
+ /*!
+ * @if jp
+ * @brief サービスの終了
+ * ロギングサービスの終了を通知する
+ * @else
+ * @brief Terminate service
+ * This operation notifies logging service.
+ * @endif
+ */
+ void close();
+ };
+};
+
Modified: branches/RELENG_1_1/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/DefaultConfiguration.java
===================================================================
--- branches/RELENG_1_1/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/DefaultConfiguration.java 2015-10-29 06:36:36 UTC (rev 741)
+++ branches/RELENG_1_1/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/DefaultConfiguration.java 2015-10-29 06:49:41 UTC (rev 742)
@@ -50,7 +50,9 @@
"corba.nameservice.replace_endpoint", "NO",
"exec_cxt.periodic.type", "jp.go.aist.rtm.RTC.executionContext.PeriodicExecutionContext",
"exec_cxt.periodic.rate", "1000",
- "exec_cxt.evdriven.type", "jp.go.aist.rtm.RTC.executionContext.EventDrivenExecutionContext",
+ "exec_cxt.sync_transition", "YES",
+ "exec_cxt.transition_timeout", "0.5",
+ //"exec_cxt.evdriven.type", "jp.go.aist.rtm.RTC.executionContext.EventDrivenExecutionContext",
"manager.modules.load_path", "./",
"manager.modules.abs_path_allowed", "YES",
"manager.is_master", "NO",
Copied: branches/RELENG_1_1/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/LoggerConsumer.java (from rev 670, trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/LoggerConsumer.java)
===================================================================
--- branches/RELENG_1_1/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/LoggerConsumer.java (rev 0)
+++ branches/RELENG_1_1/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/LoggerConsumer.java 2015-10-29 06:49:41 UTC (rev 742)
@@ -0,0 +1,118 @@
+package jp.go.aist.rtm.RTC;
+
+import OpenRTM.Logger;
+import OpenRTM.LoggerHelper;
+
+import _SDOPackage.NVListHolder;
+
+import jp.go.aist.rtm.RTC.port.CorbaConsumer;
+import jp.go.aist.rtm.RTC.util.CallbackFunction;
+import jp.go.aist.rtm.RTC.util.NVUtil;
+import jp.go.aist.rtm.RTC.util.Properties;
+ /**
+ *
+ *
+ *
+ */
+public class LoggerConsumer implements SdoServiceConsumerBase, CallbackFunction, ObjectCreator<SdoServiceConsumerBase>, ObjectDestructor{
+ /**
+ * {@.ja ctor of LoggerConsumer}
+ * {@.en ctor of LoggerConsumer}
+ */
+ public LoggerConsumer(){
+ m_rtobj = null;
+ }
+
+
+ /**
+ * {@.ja åæå}
+ * {@.en Initialization}
+ */
+ public boolean init(RTObject_impl rtobj,
+ final _SDOPackage.ServiceProfile profile){
+
+ if (!m_observer.setObject(LoggerHelper.narrow(profile.service))) {
+ // narrowing failed
+ return false;
+ }
+
+ m_rtobj = rtobj;
+ m_profile = profile;
+ //
+ NVListHolder nvholder =
+ new NVListHolder(profile.properties);
+ Properties prop = new Properties();
+ NVUtil.copyToProperties(prop, nvholder);
+ return true;
+ }
+
+ /**
+ * {@.ja ååæå}
+ * {@.en Re-initialization}
+ */
+ public boolean reinit(final _SDOPackage.ServiceProfile profile){
+ if (!m_observer._ptr()._is_equivalent(profile.service)) {
+ CorbaConsumer<Logger> tmp = new CorbaConsumer<Logger>();
+ if (!tmp.setObject(profile.service)) {
+ return false;
+ }
+ m_observer.releaseObject();
+ m_observer.setObject(profile.service);
+ }
+ m_profile= profile;
+ //
+ NVListHolder nvholder =
+ new NVListHolder(profile.properties);
+ Properties prop = new Properties();
+ NVUtil.copyToProperties(prop, nvholder);
+ return true;
+ }
+
+ /**
+ * {@.ja ServiceProfile ãåå¾ãã}
+ * {@.en getting ServiceProfile}
+ */
+ public final _SDOPackage.ServiceProfile getProfile() {
+ return m_profile;
+ }
+
+ /**
+ * {@.ja çµäºå¦ç}
+ * {@.en Finalization}
+ */
+ public void finalize(){
+ }
+ //============================================================
+ // Heartbeat related functions
+ /**
+ * {@.ja }
+ * {@.en }
+ */
+ public void doOperate(){
+ }
+
+ /**
+ * <p> creator_ </p>
+ *
+ * @return Object Created instances
+ *
+ */
+ public SdoServiceConsumerBase creator_() {
+ return new ComponentObserverConsumer();
+ }
+ /**
+ * <p> destructor_ </p>
+ *
+ * @param obj The target instances for destruction
+ *
+ */
+ public void destructor_(Object obj) {
+ obj = null;
+ }
+ private RTObject_impl m_rtobj;
+ private _SDOPackage.ServiceProfile m_profile;
+ private CorbaConsumer<OpenRTM.Logger> m_observer =
+ new CorbaConsumer<OpenRTM.Logger>(OpenRTM.Logger.class);
+
+};
+
Modified: branches/RELENG_1_1/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/Manager.java
===================================================================
--- branches/RELENG_1_1/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/Manager.java 2015-10-29 06:36:36 UTC (rev 741)
+++ branches/RELENG_1_1/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/Manager.java 2015-10-29 06:49:41 UTC (rev 742)
@@ -978,6 +978,14 @@
"exec_cxt.periodic.type",
"exec_cxt.periodic.rate",
"exec_cxt.evdriven.type",
+ "exec_cxt.sync_transition",
+ "exec_cxt.sync_activation",
+ "exec_cxt.sync_deactivation",
+ "exec_cxt.sync_reset",
+ "exec_cxt.transition_timeout",
+ "exec_cxt.activation_timeout",
+ "exec_cxt.deactivation_timeout",
+ "exec_cxt.reset_timeout",
"logger.enable",
"logger.log_level",
"naming.enable",
@@ -987,8 +995,11 @@
};
for (int ic=0; inherit_prop[ic].length() != 0; ++ic) {
- prop.setProperty(inherit_prop[ic],
- m_config.getProperty(inherit_prop[ic]));
+
+ String key = inherit_prop[ic];
+ if (m_config.findNode(key) != null) {
+ prop.setProperty(key,m_config.getProperty(key));
+ }
}
comp = factory.create(this);
Copied: branches/RELENG_1_1/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/RTObjectStateMachine.java (from rev 673, trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/RTObjectStateMachine.java)
===================================================================
--- branches/RELENG_1_1/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/RTObjectStateMachine.java (rev 0)
+++ branches/RELENG_1_1/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/RTObjectStateMachine.java 2015-10-29 06:49:41 UTC (rev 742)
@@ -0,0 +1,436 @@
+package jp.go.aist.rtm.RTC;
+
+import jp.go.aist.rtm.RTC.log.Logbuf;
+
+import RTC.ComponentAction;
+import RTC.ComponentActionHelper;
+import RTC.DataFlowComponentAction;
+import RTC.DataFlowComponentActionHelper;
+import RTC.FsmParticipantAction;
+import RTC.FsmParticipantActionHelper;
+import RTC.LifeCycleState;
+import RTC.LightweightRTObject;
+import RTC.MultiModeComponentAction;
+import RTC.MultiModeComponentActionHelper;
+import RTC.ReturnCode_t;
+
+public class RTObjectStateMachine {
+ private static final int NUM_OF_LIFECYCLESTATE = 4;
+ /**
+ * {@.ja ã³ã³ã¹ãã©ã¯ã¿}
+ * {@.en Constructor}
+ *
+ */
+ public RTObjectStateMachine(int id, LightweightRTObject comp){
+ m_id = id;
+ m_rtobj = (LightweightRTObject)comp._duplicate();
+ m_sm = new StateMachine<LifeCycleState,
+ RTObjectStateMachine>(NUM_OF_LIFECYCLESTATE);
+ m_ca = false;
+ m_dfc = false;
+ m_fsm = false;
+ m_mode = false;
+ m_caVar = null;
+ m_dfcVar = null;
+ m_fsmVar = null;
+ m_modeVar = null;
+ // Setting Action callback objects
+ setComponentAction(comp);
+ setDataFlowComponentAction(comp);
+ setFsmParticipantAction(comp);
+ setMultiModeComponentAction(comp);
+ // Setting callback functions to StateMachine
+ m_sm.setListener(this);
+ m_sm.setEntryAction (LifeCycleState.ACTIVE_STATE,
+ new onActivated());
+ m_sm.setDoAction (LifeCycleState.ACTIVE_STATE,
+ new onExecute());
+ m_sm.setPostDoAction(LifeCycleState.ACTIVE_STATE,
+ new onStateUpdate());
+ m_sm.setExitAction (LifeCycleState.ACTIVE_STATE,
+ new onDeactivated());
+ m_sm.setEntryAction (LifeCycleState.ERROR_STATE,
+ new onAborting());
+ m_sm.setDoAction (LifeCycleState.ERROR_STATE,
+ new onError());
+ m_sm.setExitAction (LifeCycleState.ERROR_STATE,
+ new onReset());
+ // Setting inital state
+ StateHolder<LifeCycleState> st = new StateHolder<LifeCycleState>();
+ st.prev = LifeCycleState.INACTIVE_STATE;
+ st.curr = LifeCycleState.INACTIVE_STATE;
+ st.next = LifeCycleState.INACTIVE_STATE;
+ m_sm.setStartState(st);
+ m_sm.goTo(LifeCycleState.INACTIVE_STATE);
+ }
+ private RTObjectStateMachine(final RTObjectStateMachine rtobjsm){
+ }
+ /**
+ * {@.ja onActivatedã¢ã¯ã·ã§ã³å®ç¾©ç¨æ½è±¡ã¯ã©ã¹}
+ */
+ private class onActivated implements StateAction {
+ public void doAction(StateHolder state) {
+ if (!m_ca) {
+ return;
+ }
+ if (m_caVar.on_activated(m_id) != ReturnCode_t.RTC_OK) {
+ m_sm.goTo(LifeCycleState.ERROR_STATE);
+ return;
+ }
+ return;
+ }
+ }
+ /**
+ * {@.ja onExecuteã¢ã¯ã·ã§ã³å®ç¾©ç¨æ½è±¡ã¯ã©ã¹}
+ */
+ private class onExecute implements StateAction {
+ public void doAction(StateHolder state) {
+ if (!m_dfc) {
+ return;
+ }
+ if (m_dfcVar.on_execute(m_id) != ReturnCode_t.RTC_OK) {
+ m_sm.goTo(LifeCycleState.ERROR_STATE);
+ return;
+ }
+ return;
+ }
+ }
+ /**
+ * {@.ja onStateUpdateã¢ã¯ã·ã§ã³å®ç¾©ç¨æ½è±¡ã¯ã©ã¹}
+ */
+ private class onStateUpdate implements StateAction {
+ public void doAction(StateHolder state) {
+ if (!m_dfc) {
+ return;
+ }
+ if (m_dfcVar.on_state_update(m_id) != ReturnCode_t.RTC_OK) {
+ m_sm.goTo(LifeCycleState.ERROR_STATE);
+ return;
+ }
+ return;
+ }
+ }
+ /**
+ * {@.ja onDeactivatedã¢ã¯ã·ã§ã³å®ç¾©ç¨æ½è±¡ã¯ã©ã¹}
+ */
+ private class onDeactivated implements StateAction {
+ public void doAction(StateHolder state) {
+ if (!m_ca) {
+ return;
+ }
+ m_caVar.on_deactivated(m_id);
+ }
+ }
+ /**
+ * {@.ja onAbortingã¢ã¯ã·ã§ã³å®ç¾©ç¨æ½è±¡ã¯ã©ã¹}
+ */
+ private class onAborting implements StateAction {
+ public void doAction(StateHolder state) {
+ if (!m_ca) {
+ return;
+ }
+ m_caVar.on_error(m_id);
+ }
+ }
+ /**
+ * {@.ja onErrorã¢ã¯ã·ã§ã³å®ç¾©ç¨æ½è±¡ã¯ã©ã¹}
+ */
+ private class onError implements StateAction {
+ public void doAction(StateHolder state) {
+ if (!m_ca) {
+ return;
+ }
+ m_caVar.on_error(m_id);
+ }
+ }
+ /**
+ * {@.ja onResetã¢ã¯ã·ã§ã³å®ç¾©ç¨æ½è±¡ã¯ã©ã¹}
+ */
+ private class onReset implements StateAction {
+ public void doAction(StateHolder state) {
+ if (!m_ca) {
+ return;
+ }
+ if (m_caVar.on_reset(m_id) != ReturnCode_t.RTC_OK) {
+ m_sm.goTo(LifeCycleState.ERROR_STATE);
+ return;
+ }
+ return;
+ }
+ }
+
+
+ // functions for stored RTObject reference
+ /**
+ *
+ */
+ public LightweightRTObject getRTObject() {
+ return (LightweightRTObject)m_rtobj._duplicate();
+ }
+ /**
+ *
+ */
+ public boolean isEquivalent(LightweightRTObject comp) {
+ return m_rtobj._is_equivalent(comp);
+ }
+ /**
+ *
+ */
+ public int getExecutionContextHandle() {
+ return m_id;
+ }
+
+ // RTC::ComponentAction operations
+ /**
+ *
+ */
+ public void onStartup(){
+ if (!m_ca) {
+ return;
+ }
+ m_caVar.on_startup(m_id);
+ }
+ /**
+ *
+ */
+ public void onShutdown(){
+ if (!m_ca) {
+ return;
+ }
+ m_caVar.on_shutdown(m_id);
+ }
+ /**
+ *
+ */
+ public void onActivated(final StateHolder<LifeCycleState> st) {
+ if (!m_ca) {
+ return;
+ }
+ if (m_caVar.on_activated(m_id) != ReturnCode_t.RTC_OK) {
+ m_sm.goTo(LifeCycleState.ERROR_STATE);
+ return;
+ }
+ return;
+ }
+ /**
+ *
+ */
+ public void onDeactivated(final StateHolder<LifeCycleState> st) {
+ if (!m_ca) {
+ return;
+ }
+ m_caVar.on_deactivated(m_id);
+ }
+ /**
+ *
+ */
+ public void onAborting(final StateHolder<LifeCycleState> st) {
+ if (!m_ca) {
+ return;
+ }
+ m_caVar.on_error(m_id);
+ }
+ /**
+ *
+ */
+ public void onError(final StateHolder<LifeCycleState> st){
+ if (!m_ca) {
+ return;
+ }
+ m_caVar.on_error(m_id);
+ }
+ /**
+ *
+ */
+ public void onReset(final StateHolder<LifeCycleState> st){
+ if (!m_ca) {
+ return;
+ }
+ if (m_caVar.on_reset(m_id) != ReturnCode_t.RTC_OK) {
+ m_sm.goTo(LifeCycleState.ERROR_STATE);
+ return;
+ }
+ return;
+
+ }
+
+ // RTC::DataflowComponentAction
+ /**
+ *
+ */
+ public void onExecute(final StateHolder<LifeCycleState> st){
+ if (!m_dfc) {
+ return;
+ }
+ if (m_dfcVar.on_execute(m_id) != ReturnCode_t.RTC_OK) {
+ m_sm.goTo(LifeCycleState.ERROR_STATE);
+ return;
+ }
+ return;
+ }
+ /**
+ *
+ */
+ public void onStateUpdate(final StateHolder<LifeCycleState> st){
+ if (!m_dfc) {
+ return;
+ }
+ if (m_dfcVar.on_state_update(m_id) != ReturnCode_t.RTC_OK) {
+ m_sm.goTo(LifeCycleState.ERROR_STATE);
+ return;
+ }
+ return;
+ }
+ /**
+ *
+ */
+ public void onRateChanged(){
+ if (!m_dfc) {
+ return;
+ }
+ if (m_dfcVar.on_rate_changed(m_id) != ReturnCode_t.RTC_OK) {
+ m_sm.goTo(LifeCycleState.ERROR_STATE);
+ return;
+ }
+ return;
+ }
+
+ // FsmParticipantAction
+ /**
+ *
+ */
+ public void onAction(final StateHolder<LifeCycleState> st){
+ if (!m_fsm) {
+ return;
+ }
+ if (m_fsmVar.on_action(m_id) != ReturnCode_t.RTC_OK) {
+ m_sm.goTo(LifeCycleState.ERROR_STATE);
+ return;
+ }
+ return;
+ }
+
+ // MultiModeComponentAction
+ /**
+ *
+ */
+ public void onModeChanged(final StateHolder<LifeCycleState> st){
+ if (!m_mode) {
+ return;
+ }
+ if (m_modeVar.on_mode_changed(m_id) != ReturnCode_t.RTC_OK) {
+ m_sm.goTo(LifeCycleState.ERROR_STATE);
+ return;
+ }
+ return;
+ }
+
+ // Getting state of the context
+ /**
+ *
+ */
+ public LifeCycleState getState(){
+ return m_sm.getState();
+ }
+ /**
+ *
+ */
+ public StateHolder<LifeCycleState> getStates(){
+ return m_sm.getStates();
+ }
+ /**
+ *
+ */
+ public boolean isCurrentState(LifeCycleState state){
+ if(getState() == state){
+ return true;
+ }
+ return false;
+ }
+ /**
+ *
+ */
+ public boolean isNextState(LifeCycleState state){
+ if(m_sm.getStates().next == state){
+ return true;
+ }
+ return false;
+ }
+ /**
+ *
+ */
+ public void goTo(LifeCycleState state){
+ m_sm.goTo(state);
+ }
+
+ // Workers
+ /**
+ *
+ */
+ public void workerPreDo(){
+ m_sm.worker_pre();
+ }
+ /**
+ *
+ */
+ public void workerDo(){
+ m_sm.worker_do();
+ }
+ /**
+ *
+ */
+ public void workerPostDo(){
+ m_sm.worker_post();
+ }
+
+ protected void setComponentAction(final LightweightRTObject comp) {
+ m_caVar = ComponentActionHelper.narrow(comp);
+ if (m_caVar!=null) {
+ m_ca = true;
+ }
+ }
+ protected void setDataFlowComponentAction(final LightweightRTObject comp){
+ m_dfcVar = DataFlowComponentActionHelper.narrow(comp);
+ if (m_dfcVar!=null) {
+ m_dfc = true;
+ }
+ }
+ protected void setFsmParticipantAction(final LightweightRTObject comp){
+ m_fsmVar = FsmParticipantActionHelper.narrow(comp);
+ if (m_fsmVar!=null) {
+ m_fsm = true;
+ }
+ }
+ protected void setMultiModeComponentAction(final LightweightRTObject comp){
+ m_modeVar = MultiModeComponentActionHelper.narrow(comp);
+ if (m_modeVar!=null) {
+ m_mode = true;
+ }
+ }
+
+ /**
+ * {@.ja ãã¬ã¼ã¹ããªã¼ã }
+ * {@.en Logger stream}
+ */
+ private Logbuf rtcout;
+ // ExecutionContext id
+ private int m_id;
+ // Associated RTObject reference
+ private LightweightRTObject m_rtobj;
+ // State machine
+ private StateMachine<LifeCycleState,
+ RTObjectStateMachine> m_sm;
+ private boolean m_ca;
+ private boolean m_dfc;
+ private boolean m_fsm;
+ private boolean m_mode;
+ private ComponentAction m_caVar;
+ private DataFlowComponentAction m_dfcVar;
+ private FsmParticipantAction m_fsmVar;
+ private MultiModeComponentAction m_modeVar;
+
+ // char dara[1000];
+ // Component action invoker
+
+}
+
Modified: branches/RELENG_1_1/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/RTObject_impl.java
===================================================================
--- branches/RELENG_1_1/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/RTObject_impl.java 2015-10-29 06:36:36 UTC (rev 741)
+++ branches/RELENG_1_1/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/RTObject_impl.java 2015-10-29 06:49:41 UTC (rev 742)
@@ -134,6 +134,7 @@
m_pPOA = manager.getPOA();
m_portAdmin = new PortAdmin(manager.getORB(), manager.getPOA());
m_created = true;
+ m_exiting = false;
m_properties = new Properties(default_conf);
m_configsets = new ConfigAdmin(m_properties.getNode("conf"));
m_readAll = false;
@@ -182,6 +183,7 @@
m_pPOA = poa;
m_portAdmin = new PortAdmin(orb, poa);
m_created = true;
+ m_exiting = false;
m_properties = new Properties(default_conf);
m_configsets = new ConfigAdmin(m_properties.getNode("conf"));
m_readAll = false;
@@ -744,6 +746,9 @@
if( m_created ) {
return ReturnCode_t.PRECONDITION_NOT_MET;
}
+ if (!m_exiting) {
+ return ReturnCode_t.PRECONDITION_NOT_MET;
+ }
// Return RTC::PRECONDITION_NOT_MET,
// When the component is registered in ExecutionContext.
//if(m_ecMine.value.length != 0 || m_ecOther.value.length != 0)
@@ -806,6 +811,9 @@
if (m_created) {
return ReturnCode_t.PRECONDITION_NOT_MET;
}
+ if (m_exiting) {
+ return ReturnCode_t.RTC_OK;
+ }
// deactivate myself on owned EC
CORBA_SeqUtil.for_each(m_ecMine,
new deactivate_comps((LightweightRTObject)m_objref._duplicate()));
@@ -827,6 +835,7 @@
m_ecOther.value[ic].remove_component(this._this());
}
}
+ m_exiting = true;
ReturnCode_t ret = this._finalize();
return ret;
}
@@ -5955,6 +5964,7 @@
}
if( m_pManager != null) {
+ rtcout.println(Logbuf.DEBUG, "Cleanup on Manager");
m_pManager.notifyFinalized(this);
}
}
Modified: branches/RELENG_1_1/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/StateMachine.java
===================================================================
--- branches/RELENG_1_1/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/StateMachine.java 2015-10-29 06:36:36 UTC (rev 741)
+++ branches/RELENG_1_1/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/StateMachine.java 2015-10-29 06:49:41 UTC (rev 742)
@@ -412,6 +412,25 @@
}
/**
+ * {@.ja ç¶æ
ãåå¾ãã}
+ * {@.en Gets states}
+ * <p>
+ * {@.ja ç¶æ
æ
å ±ãåå¾ããã
+ * ç¾å¨ã®ç¶æ
ãï¼ã¤åã®ç¶æ
ãé·ç§»äºå®ã®ç¶æ
ãåå¾ãããã¨ãã§ããã}
+ * {@.en Get state information.
+ * Get the current state, the previous state and the next state to
+ * be expected to transfer.}
+ *
+ * @return
+ * {@.ja ç¶æ
æ
å ±}
+ * {@.en State information}
+ *
+ */
+ public StateHolder<STATE> getStates() {
+ return m_states;
+ }
+
+ /**
* {@.ja ç¾å¨ã®ç¶æ
ãåå¾ãã}
* {@.en Get current state}
*
Copied: branches/RELENG_1_1/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/ExecutionContextWorker.java (from rev 673, trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/ExecutionContextWorker.java)
===================================================================
--- branches/RELENG_1_1/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/ExecutionContextWorker.java (rev 0)
+++ branches/RELENG_1_1/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/ExecutionContextWorker.java 2015-10-29 06:49:41 UTC (rev 742)
@@ -0,0 +1,700 @@
+package jp.go.aist.rtm.RTC.executionContext;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import jp.go.aist.rtm.RTC.RTObject_impl;
+import jp.go.aist.rtm.RTC.RTObjectStateMachine;
+import jp.go.aist.rtm.RTC.util.TimeValue;
+import jp.go.aist.rtm.RTC.log.Logbuf;
+
+import RTC.ExecutionContextService;
+import RTC.LifeCycleState;
+import RTC.LightweightRTObject;
+import RTC.ReturnCode_t;
+ /**
+ * {@.ja PeriodicExecutionContext ã¯ã©ã¹}
+ * {@.en PeriodicExecutionContext class}
+ * <p>
+ * {@.ja Periodic Sampled Data Processing(å¨æå®è¡ç¨)ExecutionContextã¯ã©ã¹ã}
+ * {@.en Periodic Sampled Data Processing (for the execution cycles)
+ * ExecutionContext class}
+ */
+public class ExecutionContextWorker {
+
+ /**
+ * {@.ja ããã©ã«ãã³ã³ã¹ãã©ã¯ã¿}
+ * {@.en Default Constructor}
+ * <p>
+ * {@.ja ããã©ã«ãã³ã³ã¹ãã©ã¯ã¿
+ * ãããã¡ã¤ã«ã«ä»¥ä¸ã®é
ç®ãè¨å®ããã
+ * - kind : PERIODIC
+ * - rate : 0.0}
+ * {@.en Default Constructor
+ * Set the following items to profile.
+ * - kind : PERIODIC
+ * - rate : 0.0}
+ */
+ public ExecutionContextWorker() {
+ rtcout = new Logbuf("ec_worker");
+ m_running = false;
+ rtcout.println(Logbuf.TRACE, "ExecutionContextWorker()");
+ }
+ //============================================================
+ // Object reference to EC
+ //============================================================
+ public void setECRef(ExecutionContextService ref) {
+ m_ref = (ExecutionContextService)ref._duplicate();
+ }
+ public ExecutionContextService getECRef(){
+ return (ExecutionContextService)m_ref._duplicate();
+ }
+
+ //============================================================
+ // ExecutionContext
+ //============================================================
+ /**
+ * {@.ja ExecutionContext å®è¡ç¶æ
確èªé¢æ°}
+ * {@.en Check for ExecutionContext running state}
+ * <p>
+ * {@.ja ãã®æä½ã¯ ExecutionContext ã Runnning ç¶æ
ã®å ´åã« true ãè¿ãã
+ * Executioncontext ã Running ã®éãå½è©² Executioncontext ã«åå ã
+ * ã¦ããå
¨ã¦ã®ã¢ã¯ãã£ãRTã³ã³ãã¼ãã³ãããExecutionContext ã®å®
+ * è¡ç¨®é¡ã«å¿ãã¦å®è¡ãããã}
+ * {@.en 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
+ * {@.ja ç¶æ
確èªé¢æ°(åä½ä¸:trueãåæ¢ä¸:false)}
+ * {@.en Check state function (Running:trueãStopping:false)}
+ *
+ */
+ public boolean isRunning() {
+ rtcout.println(Logbuf.TRACE, "isRunning()");
+ return m_running;
+ }
+
+ /**
+ * {@.ja ExecutionContext ã®å®è¡ãéå§}
+ * {@.en Start the ExecutionContext}
+ * <p>
+ * {@.ja ExecutionContext ã®å®è¡ç¶æ
ã Runnning ã¨ããããã®ãªã¯ã¨ã¹ãã
+ * çºè¡ãããExecutionContext ã®ç¶æ
ãé·ç§»ããã¨
+ * ComponentAction::on_startup ãå¼ã³åºããããåå ãã¦ããRTã³ã³ãã¼
+ * ãã³ãããåæåãããã¾ã§ ExecutionContext ãéå§ãããã¨ã¯ã§ã
+ * ãªããExecutionContext ã¯è¤æ°åéå§/åæ¢ãç¹°ãè¿ããã¨ãã§ããã}
+ * {@.en 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
+ * {@.ja ReturnCode_t åã®ãªã¿ã¼ã³ã³ã¼ã}
+ * {@.en The return code of ReturnCode_t type}
+ *
+ */
+ public ReturnCode_t start() {
+ rtcout.println(Logbuf.TRACE, "start()");
+ synchronized (m_mutex){
+ if (m_running) {
+ rtcout.println(Logbuf.WARN,
+ "ExecutionContext is already running.");
+ return ReturnCode_t.PRECONDITION_NOT_MET;
+ }
+ // invoke ComponentAction::on_startup for each comps.
+ for (int ic=0; ic < m_comps.size(); ++ic) {
+ m_comps.get(ic).onStartup();
+ }
+ rtcout.println(Logbuf.DEBUG, m_comps.size()
+ + " components started.");
+ // change EC thread state
+ m_running = true;
+
+ return ReturnCode_t.RTC_OK;
+ }
+ }
+
+ /**
+ * {@.ja ExecutionContext ã®å®è¡ãåæ¢}
+ * {@.en Stop the ExecutionContext}
+ * <p>
+ * {@.ja ExecutionContext ã®ç¶æ
ã Stopped ã¨ããããã®ãªã¯ã¨ã¹ããçºè¡ã
+ * ããé·ç§»ãçºçããå ´åã¯ãComponentAction::on_shutdown ãå¼ã³åº
+ * ããããåå ãã¦ããRTã³ã³ãã¼ãã³ããçµäºããåã«
+ * ExecutionContext ãåæ¢ããå¿
è¦ããããExecutionContext ã¯è¤æ°å
+ * éå§/åæ¢ãç¹°ãè¿ããã¨ãã§ããã}
+ * {@.en 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
+ * {@.ja ReturnCode_t åã®ãªã¿ã¼ã³ã³ã¼ã}
+ * {@.en The return code of ReturnCode_t type}
+ *
+ */
+ public ReturnCode_t stop(){
+ rtcout.println(Logbuf.TRACE, "stop()");
+ synchronized (m_mutex){
+ if (!m_running) {
+ rtcout.println(Logbuf.WARN,
+ "ExecutionContext is already stopped.");
+ return ReturnCode_t.PRECONDITION_NOT_MET;
+ }
+ // stop thread
+ m_running = false;
+
+ // invoke on_shutdown for each comps.
+ for (int ic=0; ic < m_comps.size(); ++ic) {
+ m_comps.get(ic).onShutdown();
+ }
+ return ReturnCode_t.RTC_OK;
+ }
+ }
+
+ /**
+ * {@.ja RTã³ã³ãã¼ãã³ããã¢ã¯ãã£ãåãã}
+ * {@.en Activate an RT-component}
+ * <p>
+ * {@.ja Inactive ç¶æ
ã«ããRTã³ã³ãã¼ãã³ããActive ã«é·ç§»ãããã¢ã¯ãã£
+ * ãåããããã®æä½ãå¼ã°ããçµæãon_activate ãå¼ã³åºããããæ
+ * å®ããRTã³ã³ãã¼ãã³ããåå è
ãªã¹ãã«å«ã¾ããªãå ´åã¯ã
+ * BAD_PARAMETER ãè¿ããããæå®ããRTã³ã³ãã¼ãã³ãã®ç¶æ
ã
+ * Inactive 以å¤ã®å ´åã¯ãPRECONDITION_NOT_MET ãè¿ãããã}
+ * {@.en 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
+ * {@.ja ã¢ã¯ãã£ãå対象RTã³ã³ãã¼ãã³ã}
+ * {@.en The target RT-Component for activation}
+ *
+ * @return
+ * {@.ja ReturnCode_t åã®ãªã¿ã¼ã³ã³ã¼ã}
+ * {@.en The return code of ReturnCode_t type}
+ *
+ */
+ public ReturnCode_t activateComponent(LightweightRTObject comp,
+ RTObjectStateMachine rtobj) {
+ rtcout.println(Logbuf.TRACE, "activateComponent()");
+ synchronized (m_mutex){
+ RTObjectStateMachine obj = findComponent(comp);
+ if (obj == null) {
+ rtcout.println(Logbuf.ERROR,
+ "Given RTC is not participant of this EC.");
+ return ReturnCode_t.BAD_PARAMETER;
+ }
+ rtcout.println(Logbuf.DEBUG, "Component found in the EC.");
+ if (!(obj.isCurrentState(LifeCycleState.INACTIVE_STATE))) {
+ rtcout.println(Logbuf.ERROR,
+ "State of the RTC is not INACTIVE_STATE.");
+ return ReturnCode_t.PRECONDITION_NOT_MET;
+ }
+ rtcout.println(Logbuf.DEBUG,
+ "Component is in INACTIVE state. Going to ACTIVE state.");
+ obj.goTo(LifeCycleState.ACTIVE_STATE);
+ rtobj = obj;
+ rtcout.println(Logbuf.DEBUG,"activateComponent() done.");
+ return ReturnCode_t.RTC_OK;
+ }
+ }
+ public ReturnCode_t waitActivateComplete(RTObjectStateMachine rtobj,
+ TimeValue timeout,
+ long cycle) {
+ return ReturnCode_t.RTC_OK;
+ }
+ public ReturnCode_t waitActivateComplete(RTObjectStateMachine rtobj) {
+ return waitActivateComplete(rtobj,new TimeValue(1.0),1000);
+ }
+ public ReturnCode_t waitActivateComplete(RTObjectStateMachine rtobj,
+ TimeValue timeout ) {
+ return waitActivateComplete(rtobj,timeout,1000);
+ };
+ public ReturnCode_t waitActivateComplete(RTObjectStateMachine rtobj,
+ long cycle) {
+ return waitActivateComplete(rtobj,new TimeValue(1.0),cycle);
+ }
+ /**
+ * {@.ja RTã³ã³ãã¼ãã³ããéã¢ã¯ãã£ãåãã}
+ * {@.en Deactivate an RT-component}
+ * <p>
+ * {@.ja Inactive ç¶æ
ã«ããRTã³ã³ãã¼ãã³ããéã¢ã¯ãã£ãåããInactive
+ * ã«é·ç§»ãããããã®æä½ãå¼ã°ããçµæãon_deactivate ãå¼ã³åºãã
+ * ããæå®ããRTã³ã³ãã¼ãã³ããåå è
ãªã¹ãã«å«ã¾ããªãå ´åã¯ã
+ * BAD_PARAMETER ãè¿ããããæå®ããRTã³ã³ãã¼ãã³ãã®ç¶æ
ã
+ * Active 以å¤ã®å ´åã¯ãPRECONDITION_NOT_MET ãè¿ãããã}
+ * {@.en 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
+ * {@.ja éã¢ã¯ãã£ãå対象RTã³ã³ãã¼ãã³ã}
+ * {@.en The target RT-Component for deactivate}
+ *
+ * @return
+ * {@.ja ReturnCode_t åã®ãªã¿ã¼ã³ã³ã¼ã}
+ * {@.en The return code of ReturnCode_t type}
+ *
+ */
+ public ReturnCode_t deactivateComponent(LightweightRTObject comp,
+ RTObjectStateMachine rtobj){
+ rtcout.println(Logbuf.TRACE, "deactivateComponent()");
+ synchronized (m_mutex){
+ rtobj = findComponent(comp);
+ if (rtobj == null) {
+ rtcout.println(Logbuf.ERROR,
+ "Given RTC is not participant of this EC.");
+ return ReturnCode_t.BAD_PARAMETER;
+ }
+ if (!(rtobj.isCurrentState(LifeCycleState.ACTIVE_STATE))) {
+ rtcout.println(Logbuf.ERROR,
+ "State of the RTC is not ACTIVE_STATE.");
+ return ReturnCode_t.PRECONDITION_NOT_MET;
+ }
+ rtobj.goTo(LifeCycleState.INACTIVE_STATE);
+ return ReturnCode_t.RTC_OK;
+ }
+ }
+ public ReturnCode_t waitDeactivateComplete(RTObjectStateMachine rtobj,
+ TimeValue timeout,
+ long cycle) {
+ return ReturnCode_t.RTC_OK;
+ }
+ public ReturnCode_t waitDeactivateComplete(RTObjectStateMachine rtobj,
+ TimeValue timeout) {
+ return waitDeactivateComplete(rtobj,timeout,1000);
+ }
+ public ReturnCode_t waitDeactivateComplete(RTObjectStateMachine rtobj,
+ long cycle){
+ return waitDeactivateComplete(rtobj,new TimeValue(1.0),cycle);
+ }
+ public ReturnCode_t waitDeactivateComplete(RTObjectStateMachine rtobj){
+ return waitDeactivateComplete(rtobj, new TimeValue(1.0),1000);
+ }
+
+ /**
+ * {@.ja RTã³ã³ãã¼ãã³ãããªã»ãããã}
+ * {@.en Reset the RT-component}
+ * <p>
+ * {@.ja Error ç¶æ
ã®RTã³ã³ãã¼ãã³ãã®å¾©å¸°ã試ã¿ãããã®æä½ãå¼ã°ããçµ
+ * æãon_reset ãå¼ã³åºããããæå®ããRTã³ã³ãã¼ãã³ããåå è
ãª
+ * ã¹ãã«å«ã¾ããªãå ´åã¯ãBAD_PARAMETER ãè¿ããããæå®ããRTã³ã³
+ * ãã¼ãã³ãã®ç¶æ
ã Error 以å¤ã®å ´åã¯ãPRECONDITION_NOT_MET ãè¿
+ * ãããã}
+ * {@.en 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
+ * {@.ja ãªã»ãã対象RTã³ã³ãã¼ãã³ã}
+ * {@.en The target RT-Component for reset}
+ *
+ * @return
+ * {@.ja ReturnCode_t åã®ãªã¿ã¼ã³ã³ã¼ã}
+ * {@.en The return code of ReturnCode_t type}
+ *
+ */
+ public ReturnCode_t resetComponent(LightweightRTObject comp,
+ RTObjectStateMachine rtobj) {
+ rtcout.println(Logbuf.TRACE, "resetComponent()");
+ synchronized (m_mutex){
+
+ rtobj = findComponent(comp);
+ if (rtobj == null) {
+ rtcout.println(Logbuf.ERROR,
+ "Given RTC is not participant of this EC.");
+ return ReturnCode_t.BAD_PARAMETER;
+ }
+ if (!(rtobj.isCurrentState(LifeCycleState.ERROR_STATE))) {
+ rtcout.println(Logbuf.ERROR,
+ "State of the RTC is not ERROR_STATE.");
+ return ReturnCode_t.PRECONDITION_NOT_MET;
+ }
+ rtobj.goTo(LifeCycleState.INACTIVE_STATE);
+ return ReturnCode_t.RTC_OK;
+ }
+ }
+ public ReturnCode_t waitResetComplete(RTObjectStateMachine rtobj,
+ TimeValue timeout,
+ long cycle) {
+ return ReturnCode_t.RTC_OK;
+ }
+ public ReturnCode_t waitResetComplete(RTObjectStateMachine rtobj,
+ TimeValue timeout){
+ return waitResetComplete(rtobj, timeout, 1000);
+ }
+ public ReturnCode_t waitResetComplete(RTObjectStateMachine rtobj,
+ long cycle) {
+ return waitResetComplete(rtobj, new TimeValue(1.0), cycle);
+ }
+ public ReturnCode_t waitResetComplete(RTObjectStateMachine rtobj) {
+ return waitResetComplete(rtobj, new TimeValue(1.0), 1000);
+ }
+
+ /**
+ * {@.ja RTã³ã³ãã¼ãã³ãã®ç¶æ
ãåå¾ãã}
+ * {@.en Get RT-component's state}
+ * <p>
+ * {@.ja æå®ããRTã³ã³ãã¼ãã³ãã®ç¶æ
(LifeCycleState)ãåå¾ãããæå®ã
+ * ãRTã³ã³ãã¼ãã³ããåå è
ãªã¹ãã«å«ã¾ããªãå ´åã¯ã
+ * UNKNOWN_STATE ãè¿ãããã}
+ * {@.en 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
+ * {@.ja ç¶æ
åå¾å¯¾è±¡RTã³ã³ãã¼ãã³ã}
+ * {@.en The target RT-Component to get the state}
+ *
+ * @return
+ * {@.ja ç¾å¨ã®ç¶æ
(LifeCycleState)}
+ * {@.en The current state of the target RT-Component(LifeCycleState)}
+ *
+ */
+ public LifeCycleState getComponentState(LightweightRTObject comp) {
+ rtcout.println(Logbuf.TRACE, "getComponentState()");
+ synchronized (m_mutex){
+ RTObjectStateMachine rtobj = findComponent(comp);
+ if (rtobj == null) {
+ rtcout.println(Logbuf.WARN,
+ "Given RTC is not participant of this EC.");
+ return LifeCycleState.CREATED_STATE;
+ }
+ LifeCycleState state = rtobj.getState();
+ rtcout.println(Logbuf.DEBUG,
+ "getComponentState() = "
+ + getStateString(state)
+ + " done" );
+ return state;
+ }
+ }
+ public final String getStateString(LifeCycleState state) {
+ final String st[] = {
+ "CREATED_STATE",
+ "INACTIVE_STATE",
+ "ACTIVE_STATE",
+ "ERROR_STATE"
+ };
+ return st[state.value()];
+ }
+ /**
+ * {@.ja RTã³ã³ãã¼ãã³ãã追å ãã}
+ * {@.en Add an RT-component}
+ * <p>
+ * {@.ja æå®ããRTã³ã³ãã¼ãã³ããåå è
ãªã¹ãã«è¿½å ããã追å ãããRTã³
+ * ã³ãã¼ãã³ã㯠attach_context ãå¼ã°ããInactive ç¶æ
ã«é·ç§»ããã
+ * æå®ãããRTã³ã³ãã¼ãã³ããnullã®å ´åã¯ãBAD_PARAMETER ãè¿ãã
+ * ããæå®ãããRTã³ã³ãã¼ãã³ãã DataFlowComponent 以å¤ã®å ´åã¯ã
+ * BAD_PARAMETER ãè¿ãããã}
+ * {@.en 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
+ * {@.ja 追å 対象RTã³ã³ãã¼ãã³ã}
+ * {@.en The target RT-Component for add}
+ *
+ * @return
+ * {@.ja ReturnCode_t åã®ãªã¿ã¼ã³ã³ã¼ã}
+ * {@.en The return code of ReturnCode_t type}
+ *
+ */
+ public ReturnCode_t addComponent(LightweightRTObject comp) {
+ rtcout.println(Logbuf.TRACE, "addComponent()");
+ if (comp==null) {
+ rtcout.println(Logbuf.ERROR, "nil reference is given.");
+ return ReturnCode_t.BAD_PARAMETER;
+ }
+ try {
+ synchronized (m_mutex){
+ ExecutionContextService ec = getECRef();
+ int id = comp.attach_context(ec);
+ m_addedComps.add(new RTObjectStateMachine(id, comp));
+ }
+ }
+ catch (Exception ex) {
+ rtcout.println(Logbuf.ERROR, "addComponent() failed.");
+ return ReturnCode_t.RTC_ERROR;
+ }
+ rtcout.println(Logbuf.DEBUG, "addComponent() succeeded.");
+ return ReturnCode_t.RTC_OK;
+ }
+
+ /**
+ * {@.ja ã³ã³ãã¼ãã³ãããã¤ã³ãããã}
+ * {@.en Bind the component.}
+ * <p>
+ * {@.ja ã³ã³ãã¼ãã³ãããã¤ã³ãããã}
+ * {@.en Bind the component.}
+ *
+ * @param rtc
+ * {@.ja RTã³ã³ãã¼ãã³ã}
+ * {@.en RT-Component's instances}
+ * @return
+ * {@.ja ReturnCode_t åã®ãªã¿ã¼ã³ã³ã¼ã}
+ * {@.en The return code of ReturnCode_t type}
+ */
+ public ReturnCode_t bindComponent(RTObject_impl rtc) {
+ rtcout.println(Logbuf.TRACE, "bindComponent()");
+ synchronized (m_mutex){
+ if (rtc == null) {
+ rtcout.println(Logbuf.ERROR, "NULL pointer is given.");
+ return ReturnCode_t.BAD_PARAMETER;
+ }
+ ExecutionContextService ec = getECRef();
+ int id = rtc.bindContext(ec);
+ if (id < 0 || id > RTObject_impl.ECOTHER_OFFSET) {
+ // id should be owned context id < ECOTHER_OFFSET
+ rtcout.println(Logbuf.ERROR,
+ "bindContext returns invalid id: "+id);
+ return ReturnCode_t.RTC_ERROR;
+ }
+ rtcout.println(Logbuf.DEBUG,
+ "bindContext returns id = "+id);
+
+ // rtc is owner of this EC
+ LightweightRTObject comp
+ = (LightweightRTObject)rtc.getObjRef()._duplicate();
+ // RTObjectStateMachine o(id, comp);
+ m_comps.add(new RTObjectStateMachine(id, comp));
+ rtcout.println(Logbuf.DEBUG,"bindComponent() succeeded.");
+ return ReturnCode_t.RTC_OK;
+ }
+ }
+ /**
+ * {@.ja RTã³ã³ãã¼ãã³ããåå è
ãªã¹ãããåé¤ãã}
+ * {@.en Remove the RT-Component from participant list}
+ * <p>
+ * {@.ja æå®ããRTã³ã³ãã¼ãã³ããåå è
ãªã¹ãããåé¤ãããåé¤ããã
+ * RTã³ã³ãã¼ãã³ã㯠detach_context ãå¼ã°ãããæå®ãããRTã³ã³ãã¼
+ * ãã³ããåå è
ãªã¹ãã«ç»é²ããã¦ããªãå ´åã¯ãBAD_PARAMETER ãè¿
+ * ãããã}
+ * {@.en 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
+ * {@.ja åé¤å¯¾è±¡RTã³ã³ãã¼ãã³ã}
+ * {@.en The target RT-Component for delete}
+ *
+ * @return
+ * {@.ja ReturnCode_t åã®ãªã¿ã¼ã³ã³ã¼ã}
+ * {@.en The return code of ReturnCode_t type}
+ *
+ */
+ public ReturnCode_t removeComponent(LightweightRTObject comp) {
+ rtcout.println(Logbuf.TRACE,"removeComponent()");
+ if (comp==null) {
+ rtcout.println(Logbuf.ERROR,"nil reference is given.");
+ return ReturnCode_t.BAD_PARAMETER;
+ }
+
+ synchronized (m_mutex){
+ RTObjectStateMachine rtobj = findComponent(comp);
+
+ if (rtobj == null) {
+ rtcout.println(Logbuf.ERROR,
+ "no RTC found in this context.");
+ return ReturnCode_t.BAD_PARAMETER;
+ }
+ synchronized (m_removedMutex){
+ m_removedComps.add(rtobj);
+
+ return ReturnCode_t.RTC_OK;
+ }
+ }
+ }
+ public RTObjectStateMachine findComponent(LightweightRTObject comp) {
+ for (int ic=0; ic < m_comps.size() ; ++ic) {
+ if(m_comps.get(ic).isEquivalent(comp)) {
+ return m_comps.get(ic);
+ }
+ }
+ return null;
+ }
+
+ public boolean isAllCurrentState(LifeCycleState state) {
+ synchronized (m_mutex){
+ for (int ic=0; ic < m_comps.size(); ++ic) {
+ if (!m_comps.get(ic).isCurrentState(state)) {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+ public boolean isAllNextState(LifeCycleState state){
+ synchronized (m_mutex){
+ for (int ic=0; ic < m_comps.size(); ++ic) {
+ if (!m_comps.get(ic).isNextState(state)) {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+ public boolean isOneOfCurrentState(LifeCycleState state){
+ synchronized (m_mutex){
+ for (int ic=0; ic < m_comps.size(); ++ic) {
+ if (m_comps.get(ic).isCurrentState(state)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+ public boolean isOneOfNextState(LifeCycleState state){
+ synchronized (m_mutex){
+ for (int ic=0; ic < m_comps.size(); ++ic) {
+ if (m_comps.get(ic).isNextState(state)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+
+ public void invokeWorker(){
+ rtcout.println(Logbuf.PARANOID,"invokeWorker()");
+ // m_comps never changes its size here
+ int len = m_comps.size();
+ for (int ic=0; ic < len; ++ic) {
+ m_comps.get(ic).workerPreDo();
+ }
+ for (int ic=0; ic < len; ++ic) {
+ m_comps.get(ic).workerDo();
+ }
+ for (int ic=0; ic < len; ++ic) {
+ m_comps.get(ic).workerPostDo();
+ }
+ updateComponentList();
+ }
+ public void invokeWorkerPreDo(){
+ rtcout.println(Logbuf.PARANOID,"invokeWorkerPreDo()");
+ // m_comps never changes its size here
+ int len = m_comps.size();
+ for (int ic=0; ic < len; ++ic) {
+ m_comps.get(ic).workerPreDo();
+ }
+ }
+ public void invokeWorkerDo(){
+ rtcout.println(Logbuf.PARANOID,"invokeWorkerDo()");
+ // m_comps never changes its size here
+ int len = m_comps.size();
+ for (int ic=0; ic < len; ++ic) {
+ m_comps.get(ic).workerDo();
+ }
+ }
+ public void invokeWorkerPostDo(){
+ rtcout.println(Logbuf.PARANOID,"invokeWorkerPostDo()");
+ // m_comps never changes its size here
+ int len = m_comps.size();
+ for (int ic=0; ic < len; ++ic) {
+ m_comps.get(ic).workerPostDo();
+ }
+ // m_comps might be changed here
+ updateComponentList();
+ }
+
+
+
+ protected void updateComponentList() {
+ synchronized (m_mutex) {
+ synchronized (m_addedMutex) {// adding component
+ for (int ic=0; ic < m_addedComps.size(); ++ic) {
+ m_comps.add(m_addedComps.get(ic));
+ rtcout.println(Logbuf.TRACE,"Component added.");
+ }
+ m_addedComps.clear();
+ }
+ synchronized (m_removedMutex) {// removing component
+ for (int ic=0; ic < m_removedComps.size(); ++ic) {
+ RTObjectStateMachine rtobj = m_removedComps.get(ic);
+ LightweightRTObject lwrtobj = rtobj.getRTObject();
+ lwrtobj.detach_context(rtobj.getExecutionContextHandle());
+ Iterator it = m_comps.iterator();
+ while (it.hasNext()) {
+ if(rtobj == (RTObjectStateMachine)it.next()){
+ m_comps.remove(it);
+ }
+ }
+ rtobj = null;
+ rtcout.println(Logbuf.TRACE,"Component deleted.");
+ }
+ m_removedComps.clear();
+ }
+ }
+ }
+
+
+
+ /*!
+ * @if jp
+ * @brief ã³ã³ãã¼ãã³ãæ¤ç´¢ç¨ãã¡ã³ã¯ã¿
+ * @else
+ * @brief Functor to find the component
+ * @endif
+ */
+// struct find_comp
+// {
+// RTC::LightweightRTObject_var m_comp;
+// find_comp(RTC::LightweightRTObject_ptr comp)
+// : m_comp(RTC::LightweightRTObject::_duplicate(comp)) {}
+// boolean operator()(RTObjectStateMachine* comp)
+// {
+// return comp->isEquivalent(m_comp);
+// }
+// };
+
+ //------------------------------------------------------------
+ // member variables
+ /**
+ * {@.ja ãã¬ã¼ã¹ããªã¼ã }
+ * {@.en Logger stream}
+ */
+ protected Logbuf rtcout;
+
+ protected ExecutionContextService m_ref;
+
+ /**
+ * {@.ja ExecutionContext ã®å®è¡ç¶æ
}
+ * {@.en The running state of ExecutionContext}
+ * true: running, false: stopped
+ */
+ protected boolean m_running;
+
+ /**
+ * {@.ja ã³ã³ãã¼ãã³ãã®åå è
ãªã¹ã}
+ * {@.en List of the participating component}
+ */
+ protected ArrayList<RTObjectStateMachine> m_comps;
+ protected String m_mutex;
+ protected ArrayList<RTObjectStateMachine> m_addedComps;
+ protected String m_addedMutex;
+ ArrayList<RTObjectStateMachine> m_removedComps;
+ protected String m_removedMutex;
+
+};
More information about the openrtm-commit
mailing list