[openrtm-commit:00359] r544 - in trunk: . 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/SDOPackage jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port

openrtm @ openrtm.org openrtm @ openrtm.org
2011年 8月 14日 (日) 11:50:38 JST


Author: fsi-katami
Date: 2011-08-14 11:50:37 +0900 (Sun, 14 Aug 2011)
New Revision: 544

Added:
   trunk/jp.go.aist.rtm.RTC/idl/ComponentObserver.idl
   trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/ComponentObserverConsumer.java
Modified:
   trunk/
   trunk/jp.go.aist.rtm.RTC/
   trunk/jp.go.aist.rtm.RTC/build.xml
   trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/DefaultConfiguration.java
   trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/FactoryGlobal.java
   trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/RTObject_impl.java
   trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/SDOPackage/Configuration_impl.java
   trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/SdoServiceAdmin.java
   trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/SdoServiceConsumerFactory.java
   trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/SdoServiceProviderFactory.java
   trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/CorbaConsumer.java
Log:
Implemented ComponentObserverConsumer. refs #2051


Property changes on: trunk
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/RELENG_1_0_0:60-401
/branches/work/ForComponentActionListener:521-522
/branches/work/ForConfigurationListener:524-526
/branches/work/ForLogFormat:518-519
/branches/work/ForPortConnectListener:528-532
/branches/work/ForSDOServiceAdminClass:505-507
/branches/work/ToIFR_ID:509-514
   + /branches/RELENG_1_0_0:60-401
/branches/work/ForComponentActionListener:521-522
/branches/work/ForComponentObserverConsumer:534-543
/branches/work/ForConfigurationListener:524-526
/branches/work/ForLogFormat:518-519
/branches/work/ForPortConnectListener:528-532
/branches/work/ForSDOServiceAdminClass:505-507
/branches/work/ToIFR_ID:509-514


Property changes on: trunk/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/ForComponentActionListener/jp.go.aist.rtm.RTC:521-522
/branches/work/ForConfigurationListener/jp.go.aist.rtm.RTC:524-526
/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/ToIFR_ID/jp.go.aist.rtm.RTC:509-514
   + /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/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/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/ToIFR_ID/jp.go.aist.rtm.RTC:509-514

Modified: trunk/jp.go.aist.rtm.RTC/build.xml
===================================================================
--- trunk/jp.go.aist.rtm.RTC/build.xml	2011-08-14 01:07:56 UTC (rev 543)
+++ trunk/jp.go.aist.rtm.RTC/build.xml	2011-08-14 02:50:37 UTC (rev 544)
@@ -97,6 +97,8 @@
 
 	<property name="idl.InterfaceDataTypes" value="${idl.path}/InterfaceDataTypes.idl" />
 
+	<property name="idl.ComponentObserver" value="${idl.path}/ComponentObserver.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" />
@@ -412,6 +414,12 @@
 
 		</exec>
 
+		<exec executable="${java.home}\..\bin\idlj">
+
+			<arg line="-v -fall -td ${source} -i ${idl.path} -emitAll ${idl.ComponentObserver}"/>
+
+		</exec>
+
 	</target>
 
 
Copied: trunk/jp.go.aist.rtm.RTC/idl/ComponentObserver.idl (from rev 543, branches/work/ForComponentObserverConsumer/jp.go.aist.rtm.RTC/idl/ComponentObserver.idl)
===================================================================
--- trunk/jp.go.aist.rtm.RTC/idl/ComponentObserver.idl	                        (rev 0)
+++ trunk/jp.go.aist.rtm.RTC/idl/ComponentObserver.idl	2011-08-14 02:50:37 UTC (rev 544)
@@ -0,0 +1,512 @@
+// -*- IDL -*-
+/*!
+ * @file ComponentObserver.idl
+ * @brief Component observer 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 <SDOPackage.idl>
+#include <RTC.idl>
+
+/*!
+ * @if jp
+ * @brief コンポーネント状態オブザーバインターフェース
+ *
+ * コンポーネントの状態を監視するためのオブザーバインターフェース。オブ
+ * ザーバパターンに従い、外部ツールがコンポーネントにオブザーバオブジェ
+ * クトをセットし、コンポーネントは各種内部状態変更時にをオブザーバオブ
+ * ジェクトをコールし、オブザーバに対して変更を通知する。
+ *
+ * @since 1.1
+ *
+ * @else
+ * @brief Component state observer interface
+ *
+ * This interface defines observer interface for component states.
+ * According to the observer pattern, tools which want to observe
+ * component state set observer objects to the RT-Component, and weh
+ * RT-Component changes its status, the observer object is called and
+ * notice the changes to tools.
+ *
+ *
+ * @since 1.1
+ * @endif
+ */
+module OpenRTM
+{
+  /*!
+   * @if jp
+   *
+   * @brief 更新された状態の種類
+   * 
+   * ターゲットRTCで更新された状態の種類を分類する列挙型。
+   * 
+   * @else
+   *
+   * @brief A kind of updated status
+   * 
+   * This is a enumeration type to classify updated status in target RTC.
+   *
+   * @endif
+   */
+  enum StatusKind
+  {
+    /*!
+     * @if jp
+     *
+     * @brief コンポーネントプロファイル
+     * 
+     * コンポーネントプロファイル RTC::ComponentProfile が更新されたこ
+     * とを示す列挙型。
+     *
+     * RTC::ComponentProfile のメンバーのうち、instance_name,
+     * type_name, description, version, vendor, category はRTC動作中に
+     * 変更されることはない。これらが変更された場合には、
+     * ComponentObserver::updatestatus() の hint には、それぞれのメンバー
+     * 名が文字列で指定される。また、parent に対する変更は通知されない。
+     * さらに、properties に対する変更は、hint に "<key0>, <key1>,
+     * ..." の形で通知される。
+     *
+     * port_profiles に対する変更は、後述の PORT_PROFILE によって通知さ
+     * れるため、COMPONENT_PROFILE では通知されない。
+     *
+     * @else
+     *
+     * @brief Component profile
+     * 
+     * This is enumeration member to specify that the target
+     * component's RTC::componentProfile has been changed.
+     *
+     * In the member of RTC::ComponentProfile, instance_name,
+     * type_name, description, version, vendor, category are not
+     * modified during RTC running. If these members are changed, each
+     * member's name is specified in the
+     * ComponentObserver::updateStatus() 's hint argument. And,
+     * modification to parent is not notified. In the properties, the
+     * modification is notified as "<key0>, <key1>, ..." in the hint
+     * argument.
+     * 
+     * The modification to port_profiles is not notified as
+     * COMPONENT_PROFILE becauase it is notified as PORT_PROFILE.
+     *
+     * @endif
+     */
+    COMPONENT_PROFILE,
+    /*!
+     * @if jp
+     *
+     * @brief コンポーネントの状態
+     * 
+     * コンポーネントの状態が変化したことを示す列挙子。
+     *
+     * RTCにはECの状態として、INACTIVE_STATE, ACTIVE_STATE,
+     * ERROR_STATE があるが、この状態が変化したことを通知するための列挙
+     * 子。
+     *
+     * ComponentObserver::updatestatus() の hint には、状態と、どの実行
+     * コンテキストで変化があったかを知らせる以下の文字列が hint に引数
+     * として与えられる。
+     *
+     * hint: (INACTIVE, ACTIVE, ERROR):<Execution Context ID>
+     * 例:
+     *   ACTIVE:0 (デフォルトコンテキストでRTCがアクティブになった)
+     *   ERROR:1002 (実行コンテキスト1002でRTCがエラーになった)
+     *
+     * @else
+     *
+     * @brief Component status
+     * 
+     * This is INACTIVE_STATE, ACTIVE_STATE,
+     * ERROR_STATE status, and this enumerator specify a status of RTC changed.
+     *
+     * A status and ExecutionContext's id is specified in the argument of 
+     * ComponentObserver::updateStatus() 's hint.
+     *
+     * hint: (INACTIVE, ACTIVE, ERROR):<Execution Context ID>
+     * Example:
+     *   ACTIVE:0 (RTC is activated in the default ExecuionContext)
+     *   ERROR:1002 (RTC go to ERROR state in the EC of id 1002)
+     *
+     * @endif
+     */
+    RTC_STATUS,
+    /*!
+     * @if jp
+     *
+     * @brief ExecutionContextの状態
+     * 
+     * ExecutionContextの状態が変化したことを示す列挙子。
+     *
+     * RTCにECが attach/detach/rate_change/startup/shutdown されたことを
+     * 示す列挙子。
+     *
+     * ComponentObserver::updatestatus() の hint には、
+     * attach/detach/rate_change/startup/shutdow のいずれが行われたかと、
+     * 対象となるECのidが与えられる。
+     *
+     * hint: (ATTACHED, DETACHED, RATE_CHANGED, STARTUP,
+     *        SHUTDOWN):<Execution Context ID>
+     *
+     * 例:
+     *   ATTACHED:1002 (ECがアタッチされ、そのIDは1002)
+     *
+     * @else
+     *
+     * @brief The stauts of ExecutionContext
+     * 
+     * This is enumerator notifies that ExecutionContext is
+     * attach/detach/rate_change/startup/shutdown.  Attach or detach
+     * operation and target ExecutionContext's id is given in the
+     * argument of ComponentObserver::updateStatus() 's hint.
+     *
+     * hint: (ATTACHED, DETACHED, RATE_CHANGED, STARTUP,
+     *        SHUTDOWN):<Execution Context ID>
+     *
+     * Example:
+     *   ATTACHED:1002 (EC is attached and its ID is 1002)
+     *
+     * @endif
+     */
+    EC_STATUS,
+    /*!
+     * @if jp
+     *
+     * @brief Portの状態
+     * 
+     * Portの状態が変化したことを示す列挙子。Portの追加、削除、接続、切
+     * 断が行われたことを示す。ComponentObserver::updatestatus() の
+     * hint には、いずれかのアクションが行われたかと、対象となるポート
+     * の名前が与えられる。
+     *
+     * hint: (ADD, REMOVE, CONNECT, DISCONNECT):<port name>
+     * 例:
+     *   CONNECT:velocity (velocity ポートで接続が確立された)
+     *
+     * @else
+     *
+     * @brief The stauts of ports
+     * 
+     * This is enumerator which notifies that port is added, removed,
+     * connected and/or disconnected.  Which action is performed and
+     * target port's name is given to the hint argument in
+     * ComponentObserver::updateStatus() operation.
+     *
+     * hint: (ADD, REMOVE, CONNECT, DISCONNECT):<port name>
+     * Example:
+     *   CONNECT:velocity (A connection established in the velocity port)
+     *
+     * @endif
+     */
+    PORT_PROFILE,
+    /*!
+     * @if jp
+     *
+     * @brief Configurationの状態
+     * 
+     * Configurationの状態が変化したことを示す列挙子。Configurationに対
+     * して、コンフィギュレーションパラメータが更新された
+     * (UPDATE_CONFIG_PARAM)、コンフィギュレーションがセット(更新)さ
+     * れた (SET_CONFIG_SET)、コンフィギュレーションセットが追加された
+     * (ADD_CONFIG_SET)、コンフィギュレーションが更新された
+     * (UPDATE_CONFIG_SET)、コンフィギュレーションセットが削除された
+     * (REMOVE_CONFIG_SET)、コンフィギュレーションセットがアクティブに
+     * された (ACTIVATE_CONFIG_SET) といったアクションがあったことが通
+     * 知される。
+     *
+     * - UPDATE_CONFIG_PARAM: <config set name>.<config param name>
+     *   - SDOPackage::Configuration::set_configuration_parameter
+     * - SET_CONFIG_SET: <config set name>
+     *   - SDOPackage::Configuration::set_configuration_set_values
+     * - ADD_CONFIG_SET: <config set name>
+     *   - SDOPackage::Configuration::add_configuration_set
+     * - UPDATE_CONFIG_SET: <config set name>
+     *   - 内部のコンフィグセットを実際の変数に反映する
+     * - REMOVE_CONFIG_SET: <config set name>
+     *   - SDOPackage::Configuration::remove_configuration_set
+     * - ACTIVATE_CONFIG_SET:  <config set name>
+     *   - SDOPackage::Configuration::activate_configuration_set
+     * 
+     * @else
+     *
+     * @brief The stauts of ports
+     * 
+     * This is enumerator which notifies that configuration is
+     * changed.  To the configuration, a configuration parameter has
+     * been updated (UPDATE_CONFIG_PARAM), a configuration-set is set
+     * (SET_CONFIG_SET), a configuration set has been updated
+     * (UPDATE_CONFIG_SET), a configuration set has been added
+     * (ADD_CONFIG_SET) or removed (REMOVE_CONFIG_SET), the active
+     * configuration set has been changed (ACTIVATE_CONFIG_SET), these
+     * actions would be notified.
+     *
+     * - UPDATE_CONFIG_PARAM: <config set name>.<config param name>
+     *   - SDOPackage::Configuration::set_configuration_parameter
+     * - SET_CONFIG_SET: <config set name>
+     *   - SDOPackage::Configuration::set_configuration_set_values
+     * - ADD_CONFIG_SET: <config set name>
+     *   - SDOPackage::Configuration::add_configuration_set
+     * - UPDATE_CONFIG_SET: <config set name>
+     *   - Apply configuration-set values into actual variables.
+     * - REMOVE_CONFIG_SET: <config set name>
+     *   - SDOPackage::Configuration::remove_configuration_set
+     * - ACTIVATE_CONFIG_SET:  <config set name>
+     *   - SDOPackage::Configuration::activate_configuration_set
+     *
+     * @endif
+     */
+    CONFIGURATION,
+    /*!
+     * @if jp
+     *
+     * @brief ハートビートイベント
+     * 
+     * 当該RTCが生存していることをオブザーバー側に通知する列挙子。
+     *
+     * ハートビートを利用するかどうか、およびハートビートの周期は、
+     * ServiceProfile::properties の以下のプロパティによって与えられる。
+     *
+     * heartbeat.enable: YES/NO
+     * heartbeat.interval: x [s]
+     * 
+     * @else
+     *
+     * @brief The stauts of ports
+     * 
+     * This enumerator is heart beat notification.
+     *
+     * Whether if the heart-beat function is used is specified in the
+     * ServiceProfile::properties as the following properties.
+     *
+     * heartbeat.enable: YES/NO
+     * heartbeat.interval: x [s]
+     *
+     * @endif
+     */
+    HEARTBEAT,
+
+    STATUS_KIND_NUM
+  };
+
+  /*!
+   * @if jp
+   *
+   * @interface ComponentObserver
+   * 
+   * RTCの各種状態の更新を知らせるためのオブザーバーオブジェクトのため
+   * のインターフェース。SDO Service として、対象となるRTC/SDOに対して
+   * アタッチされ、RTC/SDO内の状態が変更された場合に、変更された状態の
+   * 種類とヒントを同時に通知する。ツールなどで、ポーリングによらずRTC
+   * の状態の変化を知りたい場合などに利用する。
+   *
+   * 想定している利用方法は以下のとおりである。
+   *
+   * -# SDO::get_configuration() により Configuration オブジェクトを取得
+   * -# Configuration::add_service_profile() によりTool側の
+   *     ComponentObserver を ServiceProfile により RTC に与える。
+   *     ServiceProfile のメンバーは以下のように設定すること
+   *   - id: UUID など一意なIDを設定する。削除時にも必要になるので、Tool
+   *     側ではIDを保持しておかなければならない。
+   *   - interface_type: 当該サービスのIFRのIDを文字列として指定。RTC側で
+   *     はこの文字列により当該サービスオブジェクトを受け入れるか決定す
+   *     るため指定は必須となる。
+   *   - properties: RTC側のサービスの受け入れ側に通知するプロパティを設
+   *     定する。このサービスでは、下記の heartbeat 関連のプロパティを
+   *     指定する。
+   *    - service: SDOService オブジェクトの参照を指定する。
+   * -# RTC側で状態の変化があった場合に update_status() オペレーション
+   *     が StatusKind および hint の文字列とともに呼び出される。Tool側
+   *     では、StatusKind と hint に基づき RTC のある部分の状態が変化し
+   *     たことを知り、必要な処理を行う。
+   * -# 最終的にComponentObserverオブジェクトが不要になった場合には、
+   *     Configuration::remove_service_profile() を id とともに呼び出し
+   *     RTC から削除する。
+   *
+   * <pre>
+   * 
+   *   [RTC]    [Configuration]           [Observer]    [Tool]
+   *     |            |                       |            |
+   *     |            | get_configuration()   |            |
+   *     |<------------------------------------------------|
+   *     |            |                       |            |
+   *     |            | add_service_profile(prof)          |
+   *     |            |<-----------------------------------|
+   *     |            |                       |            |
+   *     |            | update_status(kind, hint)          |
+   *     |----------------------------------->|            |
+   *     |            | update_status(kind, hint)          |
+   *     |----------------------------------->|            |
+   *     |            |       :               |            |
+   *     |            |                       |            |
+   *     |            | remove_service_profile(id)         |
+   *     |            |<-----------------------------------|
+   *     |            |                       |            |
+   *     |            |                       x            x
+   *
+   * </pre>
+   *
+   * なお、ServiceProfile::properties に指定するプロパティとしては、
+   *
+   * - observed_status: ALL or kind of status
+   * - heartbeat.enable: YES/NO
+   * - heartbeat.interval: x [s]
+   * 
+   * がある。
+   * 
+   * - observed_staus: ALL または状態の種類をカンマ区切りで指定
+   *   監視する状態を指定する。指定可能な状態を表す文字列は、
+   *   COMPONENT_PROFILE, RTC_STATUS, EC_STATUS, PORT_PROFILE,
+   *   CONFIGURATION 5種類である。監視したい対象をカンマで区切り複数指
+   *   定することができる。また、すべての状態を監視する場合、ALL を指定
+   *   することができる。指定文字列は大文字、小文字を問わない。
+   *
+   * - heartbeat.interval: 秒単位で数値で指定
+   *   ハートビートを送信する周期を秒単位で指定する。なお、指定した秒数
+   *   でハートビートが必ず送信される保証はない。したがって、RTCが死ん
+   *   だかどうかを確認するには、heartbeat.interval 数回分の時間を待つ
+   *   必要がある。
+   *
+   * - heartbeat.enable: YES または NOで指定
+   *   Tool側では、状態に変化があるまで RTC が生存しているかどうか知る
+   *   ことはできないため、突然RTCが死んだ場合には、これを知ることがで
+   *   きない。そこで、HEART_BEAT イベントを周期的にRTC側から送らせるこ
+   *   とができる。ハートビートを有効にするか否かをこのオプションで指定
+   *   する。
+   * 
+   * 
+   * @else
+   *
+   * @interface ComponentObserver
+   * 
+   * This is an interface to notify various status changed in RTC to
+   * others.  This is attached into a target RTC/SDO as a SDO service,
+   * and if an RTC/SDO's status change, a kind of changed status and
+   * its hints are notified to observers.  For example, it can be used
+   * to notify RTC's status changed without polling in certain tools.
+   *
+   * An assumed usage is as follows.
+   *
+   * -# SDO::get_configuration() is called to get a Configuration object
+   *
+   * -# Configuration::add_service_profile() is called by Tool.
+   *     A ComponentObserver in a ServiceProfile is given to RTC.
+   *     ServiceProfile members should be set as follows.
+   *
+   *    - id: UUID and other unique ID should be specified. Since this ID
+   *      is used when the service is removed, tools should remember
+   *      this ID.
+   *
+   *    - interface_type: IFR ID should be specified here. Since the RTC
+   *      decides if the given SDO service object can be accepted by
+   *      using the interface_type string, this member is mandatory.
+   * 
+   *    - properties: This member specifies properties to be notified to
+   *      RTC side. In this service, the following heartbeat related
+   *      properties should be specified.
+   *
+   *    - service: SDOService object reference should be specified.
+   * 
+   * -# If some changes happen in RTC, the update_status() operation
+   *    is called with StatusKind and hint string. RTC's status change
+   *    is notified to tool and some processes would be performed by
+   *    the tool according to the StatusKind and hint.
+   *
+   * -# Finally, When the ComponentObserver object becomes
+   *     unnecessary, Configuration::remove_service_profile() is called
+   *     with id and it is removed from RTC.
+   *
+   * <pre>
+   * 
+   *   [RTC]    [Configuration]           [Observer]    [Tool]
+   *     |            |                       |            |
+   *     |            | get_configuration()   |            |
+   *     |<------------------------------------------------|
+   *     |            |                       |            |
+   *     |            | add_service_profile(prof)          |
+   *     |            |<-----------------------------------|
+   *     |            |                       |            |
+   *     |            | update_status(kind, hint)          |
+   *     |----------------------------------->|            |
+   *     |            | update_status(kind, hint)          |
+   *     |----------------------------------->|            |
+   *     |            |       :               |            |
+   *     |            |                       |            |
+   *     |            | remove_service_profile(id)         |
+   *     |            |<-----------------------------------|
+   *     |            |                       |            |
+   *     |            |                       x            x
+   *
+   * </pre>
+   *
+   * Properties which is specified in ServiceProfile::properties is as follows.
+   *
+   * - observed_status: ALL or kind of status
+   * - heartbeat.enable: YES/NO
+   * - heartbeat.interval: x [s]
+   * 
+   *
+   * - observed_staus: ALL or comma separated status kinds This
+   *   property specifies kind of status to be observed. Available
+   *   kind of statuses are COMPONENT_PROFILE, RTC_STATUS, EC_STATUS,
+   *   PORT_PROFILE, CONFIGURATION. You can specify comma-separated
+   *   status list to be observed. And if you want to observe all the
+   *   status, you just specify ALL instead of all the status kind
+   *   list. Uppercase, lowercase and mixture are allowed in the
+   *   specified status kind.
+   *
+   * - heartbeat.enable: YES or NO
+   *
+   *   Since tools cannot know whether the RTC is alive or not until
+   *   status change happens, if the RTC suddenly died, the tools
+   *   cannot know it forever. To eliminate this problems, Observer
+   *   object can send periodic heartbeat signals to observers. The
+   *   heartbeat.enable option specifies whether the functionality is
+   *   activated or not.
+   *
+   * - heartbeat.interval: Heartbeat interval should be specified in
+   *   seconds.  This specification does not guarantee that heartbeat
+   *   signals precisely send back to observer. Therefore if you need
+   *   to decide whether an RTC died or not, you have to wait for
+   *   several heartbeat signals.
+   *
+   * @endif
+   */
+  interface ComponentObserver
+    : SDOPackage::SDOService
+  {
+    /*!
+     * @if jp
+     *
+     * @brief 状態が更新されたことを知らせる
+     * 
+     * 状態が更新されたことを知らせるオペレーション。status_kind によっ
+     * て更新された状態の種類、hint によってどのような状態が変更された
+     * かに関するヒントが与えられる。
+     *
+     * @param status_kind: StatusKind 型の状態の種類
+     * @param hint; StatusKind 毎に決まる状態変更に関するヒント
+     *
+     * @else
+     *
+     * @brief Notifies the status updated
+     *
+     * This operation notifies the updated status. The status_kind
+     * notifies kind of updated status, and the hint give some hint
+     * about updated status.
+     *
+     * @endif
+     */
+    oneway void update_status(in StatusKind status_kind, in string hint);
+  };
+
+};

Copied: trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/ComponentObserverConsumer.java (from rev 543, branches/work/ForComponentObserverConsumer/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/ComponentObserverConsumer.java)
===================================================================
--- trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/ComponentObserverConsumer.java	                        (rev 0)
+++ trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/ComponentObserverConsumer.java	2011-08-14 02:50:37 UTC (rev 544)
@@ -0,0 +1,793 @@
+package jp.go.aist.rtm.RTC;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.lang.Exception;
+
+import OpenRTM.StatusKind;
+import OpenRTM.StatusKindHelper;
+import OpenRTM.StatusKindHolder;
+import OpenRTM.ComponentObserver;
+import OpenRTM.ComponentObserverHelper;
+
+import RTC.ReturnCode_t;
+
+import jp.go.aist.rtm.RTC.port.CorbaConsumer;
+import jp.go.aist.rtm.RTC.port.PortConnectListener;
+import jp.go.aist.rtm.RTC.port.PortConnectListenerType;
+import jp.go.aist.rtm.RTC.port.PortConnectRetListener;
+import jp.go.aist.rtm.RTC.port.PortConnectRetListenerType;
+
+import jp.go.aist.rtm.RTC.util.CallbackFunction;
+import jp.go.aist.rtm.RTC.util.DataRef;
+import jp.go.aist.rtm.RTC.util.ListenerBase;
+import jp.go.aist.rtm.RTC.util.NVUtil;
+import jp.go.aist.rtm.RTC.util.Properties;
+import jp.go.aist.rtm.RTC.util.StringUtil;
+import jp.go.aist.rtm.RTC.util.Timer;
+import jp.go.aist.rtm.RTC.util.TimeValue;
+
+import _SDOPackage.NVListHolder;
+import _SDOPackage.ServiceProfile;
+  /**
+   * 
+   * 
+   * 
+   */
+public class ComponentObserverConsumer implements SdoServiceConsumerBase, CallbackFunction, ObjectCreator<SdoServiceConsumerBase>, ObjectDestructor{
+    /**
+     * {@.ja ctor of ComponentObserverConsumer}
+     * {@.en ctor of ComponentObserverConsumer}
+     */
+    public ComponentObserverConsumer(){
+        m_rtobj = null;
+        m_compstat = new CompStatMsg(this);
+        m_portaction = new PortAction(this);
+        m_ecaction = new ECAction(this);
+        m_configMsg = new ConfigAction(this);
+        m_interval = new TimeValue(0, 100000);
+        m_heartbeat = false;
+        m_hblistenerid = null;
+        m_timer = new Timer(m_interval);
+        for (int ic = 0; ic < StatusKind._STATUS_KIND_NUM; ++ic) {
+            m_observed[ic] = false;
+        }
+    }
+
+
+    /**
+     * {@.ja 初期化}
+     * {@.en Initialization}
+     */
+    public boolean init(RTObject_impl rtobj,
+                      final _SDOPackage.ServiceProfile profile){
+
+        if (!m_observer.setObject(ComponentObserverHelper.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);
+        setHeartbeat(prop);
+        setListeners(prop);
+        return true;
+    }
+
+    /**
+     * {@.ja 再初期化}
+     * {@.en Re-initialization}
+     */
+    public boolean reinit(final _SDOPackage.ServiceProfile profile){
+        if (!m_observer._ptr()._is_equivalent(profile.service)) {
+            CorbaConsumer<ComponentObserver> tmp = new CorbaConsumer<ComponentObserver>();
+            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);
+        setHeartbeat(prop);
+        setListeners(prop);
+        return true;
+    }
+
+    /**
+     * {@.ja ServiceProfile を取得する}
+     * {@.en getting ServiceProfile}
+     */
+    public final _SDOPackage.ServiceProfile getProfile() {
+        return m_profile;
+    }
+    
+    /**
+     * {@.ja 終了処理}
+     * {@.en Finalization}
+     */
+    public void finalize(){
+        unsetComponentProfileListeners();
+        unsetComponentStatusListeners();
+        unsetPortProfileListeners();
+        unsetExecutionContextListeners();
+        unsetConfigurationListeners();
+        unsetHeartbeat();
+    }
+
+    /**
+     * {@.ja リモートオブジェクトコール}
+     * {@.en Calling remote object}
+     */
+    protected void updateStatus(StatusKind statuskind, final String msg) {
+        try {
+            m_observer._ptr().update_status(statuskind, msg);
+        }
+        catch (Exception e) {
+            m_rtobj.removeSdoServiceConsumer(m_profile.id);
+        }
+    }
+
+    /**
+     * {@.ja Kindを文字列へ変換する}
+     * {@.en Converting kind to string}
+     */
+    protected final String toString(StatusKind kind) {
+        StatusKindHolder holder = new StatusKindHolder(kind); 
+        try {
+            String ret = holder._type().member_name(kind.value()); 
+            return ret;
+        }
+        catch(Exception e){
+            return "";
+        }
+    }
+
+    /**
+     * {@.ja RTObjectへのリスナ接続処理}
+     * {@.en Connectiong listeners to RTObject}
+     */
+    protected void setListeners(Properties prop) {
+        if (prop.getProperty("observed_status").length()<1) {
+            prop.setProperty("observed_status", "ALL");
+        }
+
+        String[] observed = prop.getProperty("observed_status").split(",");
+        boolean[] flags = new boolean[StatusKind._STATUS_KIND_NUM];
+        StatusKindHolder holder = new StatusKindHolder(); 
+        for (int ic=0; ic < StatusKind._STATUS_KIND_NUM; ++ic) {
+            flags[ic] = false;
+        }
+        for (int ic=0; ic < observed.length; ++ic) {
+            observed[ic] = observed[ic].toUpperCase();
+            for(int jc=0; jc < StatusKind._STATUS_KIND_NUM; ++jc){
+                try { 
+                    if (observed[ic].equals(holder._type().member_name(jc))) {
+                        flags[jc] = true;
+                    }
+                }
+                catch(Exception e){
+                }
+            }
+            if (observed[ic].equals("ALL")) {
+                for (int jcc=0; jcc < StatusKind._STATUS_KIND_NUM; ++jcc) {
+                    flags[jcc] = true;
+                 }
+                break;
+            }
+        }
+ 
+        DataRef<Boolean> bflag = new DataRef<Boolean>(new Boolean(true));
+        bflag.v = new Boolean(m_observed[StatusKind._COMPONENT_PROFILE]);
+        switchListeners(flags[StatusKind._COMPONENT_PROFILE],
+                    bflag,
+                    this,
+                    "setComponentProfileListeners",
+                    "unsetComponentProfileListeners");
+        m_observed[StatusKind._COMPONENT_PROFILE] = bflag.v.booleanValue();
+
+        bflag.v = new Boolean(m_observed[StatusKind._RTC_STATUS]);
+        switchListeners(flags[StatusKind._RTC_STATUS],
+                    bflag,
+                    this,
+                    "setComponentStatusListeners",
+                    "unsetComponentStatusListeners");
+        m_observed[StatusKind._RTC_STATUS] = bflag.v.booleanValue();
+
+        bflag.v = new Boolean(m_observed[StatusKind._EC_STATUS]);
+        switchListeners(flags[StatusKind._EC_STATUS],
+                    bflag,
+                    this,
+                    "setExecutionContextListeners",
+                    "unsetExecutionContextListeners");
+        m_observed[StatusKind._EC_STATUS] = bflag.v.booleanValue();
+
+        bflag.v = new Boolean(m_observed[StatusKind._PORT_PROFILE]);
+        switchListeners(flags[StatusKind._PORT_PROFILE],
+                    bflag,
+                    this,
+                    "setPortProfileListeners",
+                    "unsetPortProfileListeners");
+        m_observed[StatusKind._PORT_PROFILE] = bflag.v.booleanValue();
+
+        bflag.v = new Boolean(m_observed[StatusKind._CONFIGURATION]);
+        switchListeners(flags[StatusKind._CONFIGURATION],
+                    bflag,
+                    this,
+                    "setConfigurationListeners",
+                    "unsetConfigurationListeners");
+        m_observed[StatusKind._CONFIGURATION] = bflag.v.booleanValue();
+
+    }
+    
+
+    /**
+     * {@.ja リスナ接続・切断スイッチング処理}
+     * {@.en Switching listeners connecting/disconnecting}
+     */
+    protected <DataType> 
+    void switchListeners(boolean next, DataRef<Boolean> pre,
+                         DataType obj,
+                         String setfunc, 
+                         String unsetfunc) {
+        if (!pre.v.booleanValue()  && next) {
+            try {
+                Class clazz = obj.getClass();
+                Method method = clazz.getDeclaredMethod(setfunc,null);
+                method.invoke(obj, null);
+            }
+            catch(Exception e){
+//                rtcout.println(Logbuf.WARN, 
+//                        "Exception caught."+e.toString());
+            }
+            pre.v = new Boolean(true);
+        }
+        else if (pre.v.booleanValue() && !next) {
+            try {
+                Class clazz = obj.getClass();
+                Method method = clazz.getDeclaredMethod(unsetfunc,null);
+                method.invoke(obj, null);
+            }
+            catch(Exception e){
+//                rtcout.println(Logbuf.WARN, 
+//                        "Exception caught."+e.toString());
+            }
+            pre.v = new Boolean(false);
+        }
+    }
+
+    //============================================================
+    // Heartbeat related functions
+    /**
+     * {@.ja ハートビートをオブザーバに伝える}
+     * {@.en Sending a heartbeart signal to observer}
+     */
+    //protected void heartbeat() {
+    public void doOperate(){
+        updateStatus(StatusKind.from_int(StatusKind._HEARTBEAT), "");
+    }
+
+    /**
+     * {@.ja ハートビートを設定する}
+     * {@.en Setting heartbeat}
+     */
+    protected void setHeartbeat(Properties prop) {
+        if (StringUtil.toBool(prop.getProperty("heartbeat.enable"), "YES", "NO", false)) {
+            String interval = prop.getProperty("heartbeat.interval");
+            if (interval.length()<1) {
+                m_interval.convert(1.0);
+            }
+            else {
+                m_interval.convert(Double.parseDouble(interval));
+            }
+            TimeValue tm;
+            tm = m_interval;
+            m_hblistenerid = m_timer.
+              //registerListenerObj(ComponentObserverConsumer.heartbeat, tm);
+              registerListenerObj(this, tm);
+            m_timer.start();
+        }
+        else {
+            if (m_heartbeat == true && m_hblistenerid != null) {
+                unsetHeartbeat();
+                m_timer.stop();
+            }
+        }
+    }
+
+    /**
+     * {@.ja ハートビートを解除する}
+     * {@.en Unsetting heartbeat}
+     */
+    protected void unsetHeartbeat(){
+        m_timer.unregisterListener(m_hblistenerid);
+        m_heartbeat = false;
+        m_hblistenerid = null;
+        m_timer.stop();
+    }
+
+    //============================================================
+    // Component status related functions
+    /**
+     * {@.ja RTC状態変化リスナの設定処理}
+     * {@.en Setting RTC status listeners}
+     */
+    protected void setComponentStatusListeners() {
+        if (m_compstat.activatedListener == null) {
+            m_compstat.activatedListener = 
+              m_rtobj.addPostComponentActionListener(PostComponentActionListenerType.POST_ON_ACTIVATED, m_compstat, "onActivated");
+        }
+        if (m_compstat.deactivatedListener == null) {
+            m_compstat.deactivatedListener = 
+              m_rtobj.addPostComponentActionListener(PostComponentActionListenerType.POST_ON_DEACTIVATED, m_compstat, "onDeactivated");
+        }
+        if (m_compstat.resetListener == null) {
+            m_compstat.resetListener = 
+              m_rtobj.addPostComponentActionListener(PostComponentActionListenerType.POST_ON_RESET, m_compstat, "onReset");
+        }
+        if (m_compstat.abortingListener == null) {
+            m_compstat.abortingListener = 
+              m_rtobj.addPostComponentActionListener(PostComponentActionListenerType.POST_ON_ABORTING, m_compstat, "onAborting");
+        }
+        if (m_compstat.finalizeListener == null) {
+            m_compstat.finalizeListener = 
+              m_rtobj.addPostComponentActionListener(PostComponentActionListenerType.POST_ON_FINALIZE, m_compstat, "onFinalize");
+        }
+    }
+
+    /**
+     * {@.ja RTC状態変化リスナの解除処理}
+     * {@.en Unsetting RTC status listeners}
+     */
+    protected void unsetComponentStatusListeners(){
+        if (m_compstat.activatedListener != null) {
+            m_rtobj.removePostComponentActionListener(PostComponentActionListenerType.POST_ON_ACTIVATED, m_compstat.activatedListener);
+            m_compstat.activatedListener = null;
+        }
+        if (m_compstat.deactivatedListener != null) {
+            m_rtobj.removePostComponentActionListener(PostComponentActionListenerType.POST_ON_DEACTIVATED, m_compstat.deactivatedListener);
+            m_compstat.deactivatedListener = null;
+        }
+        if (m_compstat.resetListener != null) {
+            m_rtobj.removePostComponentActionListener(PostComponentActionListenerType.POST_ON_RESET, m_compstat.resetListener);
+            m_compstat.resetListener = null;
+        }
+        if (m_compstat.abortingListener != null) {
+            m_rtobj.removePostComponentActionListener(PostComponentActionListenerType.POST_ON_ABORTING, m_compstat.abortingListener);
+            m_compstat.abortingListener = null;
+        }
+        if (m_compstat.finalizeListener != null) {
+            m_rtobj.removePostComponentActionListener(PostComponentActionListenerType.POST_ON_FINALIZE, m_compstat.finalizeListener);
+            m_compstat.finalizeListener = null;
+        }
+    }
+
+    //============================================================
+    // Port profile related functions
+    /**
+     * {@.ja Portプロファイル変化リスナの設定処理}
+     * {@.en Setting port profile listener}
+     */
+    protected void setPortProfileListeners(){
+        if (m_portaction.portAddListener == null) {
+            m_portaction.portAddListener =
+              m_rtobj.addPortActionListener(PortActionListenerType.ADD_PORT, m_portaction, "onAddPort");
+        }
+        if (m_portaction.portRemoveListener == null) {
+            m_portaction.portRemoveListener =
+              m_rtobj.addPortActionListener(PortActionListenerType.REMOVE_PORT, m_portaction, "onRemovePort");
+        }
+        if (m_portaction.portConnectListener == null) {
+            m_portaction.portConnectListener =
+              m_rtobj.addPortConnectRetListener(PortConnectRetListenerType.ON_CONNECTED, m_portaction, "onConnect");
+        }
+        if (m_portaction.portDisconnectListener == null) {
+            m_portaction.portDisconnectListener =
+              m_rtobj.addPortConnectRetListener(PortConnectRetListenerType.ON_DISCONNECTED, m_portaction, "onDisconnect");
+        }
+    }
+
+    /**
+     * {@.ja Portプロファイル変化リスナの解除処理}
+     * {@.en Unsetting port profile listener}
+     */
+    protected void unsetPortProfileListeners() {
+        if (m_portaction.portAddListener != null) {
+            m_rtobj.removePortActionListener(PortActionListenerType.ADD_PORT, m_portaction.portAddListener);
+            m_portaction.portAddListener = null;
+        }
+        if (m_portaction.portRemoveListener != null) {
+            m_rtobj.removePortActionListener(PortActionListenerType.REMOVE_PORT, m_portaction.portRemoveListener);
+            m_portaction.portRemoveListener = null;
+        }
+        if (m_portaction.portConnectListener != null) {
+            m_rtobj. removePortConnectRetListener(PortConnectRetListenerType.ON_CONNECTED, m_portaction.portConnectListener);
+            m_portaction.portConnectListener = null;
+        }
+        if (m_portaction.portDisconnectListener != null) {
+            m_rtobj.removePortConnectRetListener(PortConnectRetListenerType.ON_DISCONNECTED, m_portaction.portDisconnectListener);
+            m_portaction.portDisconnectListener = null;
+        }
+    }
+
+
+    //============================================================
+    // EC profile related functions
+    /**
+     * {@.ja ECの状態変化リスナの設定}
+     * {@.en Setting EC status listener}
+     */
+    protected void setExecutionContextListeners(){
+        if (m_ecaction.ecAttached == null) {
+            m_ecaction.ecAttached =
+              m_rtobj.addExecutionContextActionListener(ExecutionContextActionListenerType.EC_ATTACHED, m_ecaction, "onAttached");
+        }
+        if (m_ecaction.ecDetached == null) {
+            m_ecaction.ecDetached = 
+              m_rtobj.addExecutionContextActionListener(ExecutionContextActionListenerType.EC_DETACHED, m_ecaction, "onDetached");
+        }
+        if (m_ecaction.ecRatechanged == null) {
+            m_ecaction.ecRatechanged = 
+              m_rtobj.addPostComponentActionListener(PostComponentActionListenerType.POST_ON_RATE_CHANGED, m_ecaction, "onRateChanged");
+        }
+        if (m_ecaction.ecStartup == null) {
+            m_ecaction.ecStartup = 
+              m_rtobj.addPostComponentActionListener(PostComponentActionListenerType.POST_ON_STARTUP, m_ecaction, "onStartup");
+        }
+        if (m_ecaction.ecShutdown == null) {
+            m_ecaction.ecShutdown = 
+              m_rtobj.addPostComponentActionListener(PostComponentActionListenerType.POST_ON_SHUTDOWN, m_ecaction, "onShutdown");
+        }
+    }
+
+    /**
+     * {@.ja ECの状態変化リスナの解除}
+     * {@.en Unsetting EC status listener}
+     */
+    protected void unsetExecutionContextListeners() {
+        if (m_ecaction.ecAttached != null) {
+            m_rtobj.removeExecutionContextActionListener(ExecutionContextActionListenerType.EC_ATTACHED, m_ecaction.ecAttached);
+        }
+        if (m_ecaction.ecDetached != null) {
+            m_rtobj.removeExecutionContextActionListener(ExecutionContextActionListenerType.EC_ATTACHED, m_ecaction.ecDetached);
+        }
+        if (m_ecaction.ecRatechanged != null) {
+            m_rtobj.removePostComponentActionListener(PostComponentActionListenerType.POST_ON_RATE_CHANGED, m_ecaction.ecRatechanged);
+        }
+        if (m_ecaction.ecStartup != null) {
+            m_rtobj.removePostComponentActionListener(PostComponentActionListenerType.POST_ON_STARTUP, m_ecaction.ecStartup);
+        }
+        if (m_ecaction.ecShutdown != null) {
+            m_rtobj.removePostComponentActionListener(PostComponentActionListenerType.POST_ON_SHUTDOWN, m_ecaction.ecShutdown);
+        }
+    }
+
+
+    //============================================================
+    // ComponentProfile related functions
+    /**
+     * {@.ja ComponentProfile状態変化リスナの設定}
+     * {@.en Setting ComponentProfile listener}
+     */
+    protected void setComponentProfileListeners() {
+    }
+
+    /**
+     * {@.ja ComponentProfile状態変化リスナの解除}
+     * {@.en Unsetting ComponentProfile listener}
+     */
+    protected void unsetComponentProfileListeners() {
+    }
+
+    //============================================================
+    // Configuration related functions
+
+    /**
+     * {@.ja Configuration状態変化リスナの設定}
+     * {@.en Setting Configuration listener}
+     */
+    protected void setConfigurationListeners() {
+        m_configMsg.updateConfigParamListener = 
+          m_rtobj.addConfigurationParamListener(ConfigurationParamListenerType.ON_UPDATE_CONFIG_PARAM, m_configMsg, "updateConfigParam");
+        m_configMsg.setConfigSetListener = 
+          m_rtobj.addConfigurationSetListener(ConfigurationSetListenerType.ON_SET_CONFIG_SET, m_configMsg, "setConfigSet");
+        m_configMsg.addConfigSetListener = 
+          m_rtobj.addConfigurationSetListener(ConfigurationSetListenerType.ON_ADD_CONFIG_SET, m_configMsg, "addConfigSet");
+        m_configMsg.updateConfigSetListener = 
+          m_rtobj.addConfigurationSetNameListener(ConfigurationSetNameListenerType.ON_UPDATE_CONFIG_SET, m_configMsg, "updateConfigSet");
+        m_configMsg.removeConfigSetListener = 
+          m_rtobj.addConfigurationSetNameListener(ConfigurationSetNameListenerType.ON_REMOVE_CONFIG_SET, m_configMsg, "removeConfigSet");
+        m_configMsg.activateConfigSetListener = 
+          m_rtobj.addConfigurationSetNameListener(ConfigurationSetNameListenerType.ON_ACTIVATE_CONFIG_SET, m_configMsg, "activateConfigSet");
+    }
+
+    /**
+     * {@.ja Configuration状態変化リスナの解除}
+     * {@.en Unsetting Configurationlistener}
+     */
+    protected void unsetConfigurationListeners() {
+
+        if (m_configMsg.updateConfigParamListener != null) {
+            m_rtobj.
+              removeConfigurationParamListener(ConfigurationParamListenerType.ON_UPDATE_CONFIG_PARAM, m_configMsg.updateConfigParamListener);
+            m_configMsg.updateConfigParamListener = null;
+        }
+        if (m_configMsg.setConfigSetListener != null) {
+            m_rtobj.removeConfigurationSetListener(ConfigurationSetListenerType.ON_SET_CONFIG_SET, m_configMsg.setConfigSetListener);
+            m_configMsg.setConfigSetListener = null;
+        }
+        if (m_configMsg.addConfigSetListener != null) {
+            m_rtobj.removeConfigurationSetListener(ConfigurationSetListenerType.ON_ADD_CONFIG_SET, m_configMsg.addConfigSetListener);
+            m_configMsg.addConfigSetListener = null;
+        }
+        if (m_configMsg.updateConfigSetListener != null) {
+            m_rtobj.removeConfigurationSetNameListener(ConfigurationSetNameListenerType.ON_UPDATE_CONFIG_SET, m_configMsg.updateConfigSetListener);
+            m_configMsg.updateConfigSetListener = null;
+        }
+        if (m_configMsg.removeConfigSetListener != null) {
+            m_rtobj.removeConfigurationSetNameListener(ConfigurationSetNameListenerType.ON_REMOVE_CONFIG_SET, m_configMsg.removeConfigSetListener);
+            m_configMsg.removeConfigSetListener = null;
+        }
+        if (m_configMsg.activateConfigSetListener != null) {
+            m_rtobj.removeConfigurationSetNameListener(ConfigurationSetNameListenerType.ON_ACTIVATE_CONFIG_SET, m_configMsg.activateConfigSetListener);
+            m_configMsg.activateConfigSetListener = null;
+        }
+    }
+
+
+    /**
+     * {@.ja PostComponentActionListener class}
+     * {@.en PostComponentActionListener class}
+     */
+    private class CompStatMsg {
+        public CompStatMsg(ComponentObserverConsumer coc) {
+            activatedListener = null;
+            deactivatedListener = null;
+            resetListener = null;
+            abortingListener = null;
+            finalizeListener = null;
+            m_coc = coc;
+        }
+        public void onGeneric(final String msgprefix, int ec_id, ReturnCode_t ret) {
+            if (ret == ReturnCode_t.RTC_OK) {
+                String  msg =  msgprefix;
+                msg += ec_id;
+                m_coc.updateStatus(StatusKind.from_int(StatusKind._RTC_STATUS), msg);
+            }
+        }
+        public void onActivated(int ec_id, ReturnCode_t ret) {
+            onGeneric("ACTIVE:", ec_id, ret);
+        }
+        public void onDeactivated(int ec_id, ReturnCode_t ret) {
+            onGeneric("INACTIVE:", ec_id, ret);
+        }
+        public void onReset(int ec_id, ReturnCode_t ret) {
+            onGeneric("INACTIVE:", ec_id, ret);
+        }
+        public void onAborting(int ec_id, ReturnCode_t ret) {
+            onGeneric("ERROR:", ec_id, ret);
+        }
+        public void onFinalize(int ec_id, ReturnCode_t ret) {
+            onGeneric("FINALIZE:", ec_id, ret);
+        }
+
+        public PostComponentActionListener activatedListener;
+        public PostComponentActionListener deactivatedListener;
+        public PostComponentActionListener resetListener;
+        public PostComponentActionListener abortingListener;
+        public PostComponentActionListener finalizeListener;
+        private ComponentObserverConsumer m_coc;
+    };
+
+    /**
+     * {@.ja PortActionListener}
+     * {@.en PortActionListener}
+     */
+    private class PortAction {
+        public PortAction(ComponentObserverConsumer coc) {
+            portAddListener = null;
+            portRemoveListener = null;
+            portConnectListener = null;
+            portDisconnectListener = null;
+            m_coc = coc;
+        }
+        public void onGeneric(final String _msg, final String portname) {
+            String msg = _msg;
+            msg += portname;
+            m_coc.updateStatus(StatusKind.from_int(StatusKind._PORT_PROFILE), msg);
+        }
+        public void onAddPort(final RTC.PortProfile pprof) {
+            onGeneric("ADD:", pprof.name);
+        }
+        public void onRemovePort(final RTC.PortProfile pprof) {
+            onGeneric("REMOVE:", pprof.name);
+        }
+        public void onConnect(final String portname,
+                     RTC.ConnectorProfile pprof, ReturnCode_t ret) {
+            if (ret == ReturnCode_t.RTC_OK) {
+                onGeneric("CONNECT:", portname);
+            }
+        }
+        public void onDisconnect(final String portname, RTC.ConnectorProfile pprof, ReturnCode_t ret) {
+            if (ret == ReturnCode_t.RTC_OK) {
+                onGeneric("DISCONNECT:", portname);
+            }
+        }
+
+        public PortActionListener portAddListener;
+        public PortActionListener portRemoveListener;
+        public PortConnectRetListener portConnectListener;
+        public PortConnectRetListener portDisconnectListener;
+
+        private ComponentObserverConsumer m_coc;
+    };
+
+    /**
+     * {@.ja ExecutionContextActionListener}
+     * {@.en ExecutionContextActionListener}
+     */
+    private class ECAction {
+        public ECAction(ComponentObserverConsumer coc) {
+            ecAttached = null;
+            ecDetached = null;
+            ecRatechanged = null;
+            ecStartup = null;
+            ecShutdown = null;
+            m_coc = coc;
+        }
+        public void onGeneric(final String _msg, int ec_id) {
+            String msg = _msg + ec_id;
+            m_coc.updateStatus(StatusKind.from_int(StatusKind._EC_STATUS), msg);
+        }
+        public void onAttached(int ec_id) {
+            onGeneric("ATTACHED:", ec_id);
+        }
+        public void onDetached(int ec_id) {
+            onGeneric("DETACHED:", ec_id);
+        }
+        public void onRateChanged(int ec_id, ReturnCode_t ret) {
+            if (ret == ReturnCode_t.RTC_OK) {
+                onGeneric("RATE_CHANGED:", ec_id);
+            }
+        }
+        public void onStartup(int ec_id, ReturnCode_t ret) {
+            if (ret == ReturnCode_t.RTC_OK) {
+                onGeneric("STARTUP:", ec_id);
+            }
+        }
+        public void onShutdown(int ec_id, ReturnCode_t ret) {
+            if (ret == ReturnCode_t.RTC_OK) {
+                onGeneric("SHUTDOWN:", ec_id);
+            }
+        }
+        public ExecutionContextActionListener ecAttached;
+        public ExecutionContextActionListener ecDetached;
+        public PostComponentActionListener ecRatechanged;
+        public PostComponentActionListener ecStartup;
+        public PostComponentActionListener ecShutdown;
+        private ComponentObserverConsumer m_coc;
+    };
+
+    /**
+     * {@.ja ConfigActionListener}
+     * {@.en ConfigActionListener}
+     */
+    private class ConfigAction {
+        public ConfigAction(ComponentObserverConsumer coc) {
+            updateConfigParamListener = null;
+            setConfigSetListener = null;
+            addConfigSetListener = null;
+            updateConfigSetListener = null;
+            removeConfigSetListener = null;
+            activateConfigSetListener = null;
+            m_coc = coc;
+        }
+        public void updateConfigParam(final String configsetname,
+                             final  String configparamname) {
+            String msg = "UPDATE_CONFIG_PARAM: ";
+            msg += configsetname;
+            msg += ".";
+            msg += configparamname;
+            m_coc.updateStatus(StatusKind.from_int(StatusKind._CONFIGURATION), msg);
+        }
+        public void setConfigSet(final Properties config_set) {
+            String msg = "SET_CONFIG_SET: ";
+            msg += config_set.getName();
+            m_coc.updateStatus(StatusKind.from_int(StatusKind._CONFIGURATION), msg);
+        }
+        public void addConfigSet(final Properties config_set) {
+            String msg = "ADD_CONFIG_SET: ";
+            msg += config_set.getName();
+            m_coc.updateStatus(StatusKind.from_int(StatusKind._CONFIGURATION), msg);
+        }
+        public void updateConfigSet(final String config_set_name) {
+            String msg = "UPDATE_CONFIG_SET: ";
+            msg += config_set_name;
+            m_coc.updateStatus(StatusKind.from_int(StatusKind._CONFIGURATION), msg);
+        }
+        public void removeConfigSet(final String config_set_name) {
+            String msg = "REMOVE_CONFIG_SET: ";
+            msg += config_set_name;
+            m_coc.updateStatus(StatusKind.from_int(StatusKind._CONFIGURATION), msg);
+        }
+        public void activateConfigSet(final String config_set_name) {
+            String msg="ACTIVATE_CONFIG_SET: ";
+            msg += config_set_name;
+            m_coc.updateStatus(StatusKind.from_int(StatusKind._CONFIGURATION), msg);
+        }
+        // Listener object's pointer holder
+        public ConfigurationParamListener   updateConfigParamListener;
+        public ConfigurationSetListener     setConfigSetListener;
+        public ConfigurationSetListener     addConfigSetListener;
+        public ConfigurationSetNameListener updateConfigSetListener;
+        public ConfigurationSetNameListener removeConfigSetListener;
+        public ConfigurationSetNameListener activateConfigSetListener;
+
+        private ComponentObserverConsumer m_coc;
+    };
+
+
+    /**
+     * <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;
+    }
+    /**
+     * <p> ComponentObserverConsumerInit </p>
+     *
+     */
+    public static void ComponentObserverConsumerInit() {
+        final SdoServiceConsumerFactory<SdoServiceConsumerBase,String> factory 
+            = SdoServiceConsumerFactory.instance();
+        
+
+        factory.addFactory(ComponentObserverHelper.id(),
+                    new ComponentObserverConsumer(),
+                    new ComponentObserverConsumer());
+    
+    }
+
+    private RTObject_impl m_rtobj;
+    private _SDOPackage.ServiceProfile m_profile;
+    private CorbaConsumer<OpenRTM.ComponentObserver> m_observer =
+            new CorbaConsumer<OpenRTM.ComponentObserver>(OpenRTM.ComponentObserver.class);
+
+    private boolean[] m_observed = new boolean[StatusKind._STATUS_KIND_NUM];
+
+    private CompStatMsg m_compstat;
+    private PortAction m_portaction;
+    private ECAction m_ecaction;
+    private ConfigAction m_configMsg;
+
+    private TimeValue m_interval;
+    private boolean m_heartbeat;
+    private ListenerBase m_hblistenerid;
+
+    // このタイマーはいずれグローバルなタイマにおきかえる
+    private Timer m_timer;
+
+
+};
+

Modified: trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/DefaultConfiguration.java
===================================================================
--- trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/DefaultConfiguration.java	2011-08-14 01:07:56 UTC (rev 543)
+++ trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/DefaultConfiguration.java	2011-08-14 02:50:37 UTC (rev 544)
@@ -58,6 +58,8 @@
         "manager.shutdown_auto",            "YES",
         "manager.name",                     "manager",
         "manager.command",                  "rtcd",
+        "sdo.service.provider.enabled_services",  "ALL",
+        "sdo.service.consumer.enabled_services",  "ALL",
         ""
     };
 }

Modified: trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/FactoryGlobal.java
===================================================================
--- trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/FactoryGlobal.java	2011-08-14 01:07:56 UTC (rev 543)
+++ trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/FactoryGlobal.java	2011-08-14 02:50:37 UTC (rev 544)
@@ -1,5 +1,7 @@
 package jp.go.aist.rtm.RTC;
 
+import java.lang.reflect.Constructor;
+
 import java.util.Hashtable;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -99,7 +101,11 @@
         } 
         else {
             try{
-                Object obj2 = (Object)(Class.forName(clazz).newInstance());
+                Class cl  = Class.forName(clazz);
+                Constructor cunstructor = cl.getDeclaredConstructor(null);
+                cunstructor.setAccessible(true);
+                Object obj2 = (Object)cunstructor.newInstance();
+                //Object obj2 = (Object)(Class.forName(clazz).newInstance());
                 factory_table.put(clazz,obj2);
                 return obj2;
             }

Modified: trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/RTObject_impl.java
===================================================================
--- trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/RTObject_impl.java	2011-08-14 01:07:56 UTC (rev 543)
+++ trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/RTObject_impl.java	2011-08-14 02:50:37 UTC (rev 544)
@@ -140,7 +140,9 @@
         m_writeAll = false;
         m_readAllCompletion = false;
         m_writeAllCompletion = false;
-        
+        rtcout = new Logbuf("RTObject_impl");
+        m_sdoservice = new SdoServiceAdmin(this);
+
         m_objref = this._this();
         m_pSdoConfigImpl = new Configuration_impl(m_configsets,m_sdoservice);
         m_pSdoConfig = m_pSdoConfigImpl.getObjRef();
@@ -157,7 +159,6 @@
         }
 
         m_profile.properties    = new NameValue[0];
-        rtcout = new Logbuf("RTObject_impl");
          
     }
 
@@ -183,6 +184,8 @@
         m_writeAll = false;
         m_readAllCompletion = false;
         m_writeAllCompletion = false;
+        rtcout = new Logbuf("RTObject_impl");
+        m_sdoservice = new SdoServiceAdmin(this);
         
         m_objref = this._this();
         m_pSdoConfigImpl = new Configuration_impl(m_configsets,m_sdoservice);
@@ -199,7 +202,6 @@
 
         Manager manager = Manager.instance();
         m_profile.properties    = new NameValue[0];
-        rtcout = new Logbuf("RTObject_impl");
     }
 
     /**
@@ -5092,7 +5094,6 @@
 
                 }
                 catch(java.lang.Exception e){
-                    System.out.println("Exception caught."+e.toString());
                     rtcout.println(Logbuf.WARN, 
                         "Exception caught."+e.toString());
                 }

Modified: trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/SDOPackage/Configuration_impl.java
===================================================================
--- trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/SDOPackage/Configuration_impl.java	2011-08-14 01:07:56 UTC (rev 543)
+++ trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/SDOPackage/Configuration_impl.java	2011-08-14 02:50:37 UTC (rev 544)
@@ -1054,7 +1054,7 @@
      * {@.en SDO Service admin object with mutex lock}
      */
     protected SdoServiceAdmin m_sdoservice;
-    protected String m_sdoservice_mutex;
+    protected String m_sdoservice_mutex = new String();
     
     /**
      * {@.ja Organization リスト}

Modified: trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/SdoServiceAdmin.java
===================================================================
--- trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/SdoServiceAdmin.java	2011-08-14 01:07:56 UTC (rev 543)
+++ trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/SdoServiceAdmin.java	2011-08-14 02:50:37 UTC (rev 544)
@@ -88,7 +88,7 @@
      */
     public SdoServiceAdmin(RTObject_impl rtobj) {
         m_rtobj = rtobj;
-        m_allConsumerAllowed = true;
+        m_allConsumerEnabled = true;
         rtcout = new Logbuf("SdoServiceAdmin");
         rtcout.println(Logbuf.TRACE, "SdoServiceAdmin.SdoServiceAdmin(" + rtobj.getProperties().getProperty("instance_name") + ")");
 
@@ -417,7 +417,8 @@
         if (m_allConsumerEnabled) { return true; }
 
         for (Iterator ic=m_consumerTypes.iterator(); ic.hasNext();) {
-            if (ic.next().equals(sProfile.interface_type)) {
+            String str = (String)ic.next();
+            if (str.equals(sProfile.interface_type)) {
                 rtcout.println(Logbuf.DEBUG,sProfile.interface_type+" is supported SDO service.");
                 return true;
             }
@@ -464,7 +465,6 @@
 
     private List<String> m_consumerTypes = new ArrayList<String>();
     private boolean m_allConsumerEnabled;
-    private boolean m_allConsumerAllowed;
     
     /**
      * {@.ja Lock 付き SDO ServiceProfileList}

Modified: trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/SdoServiceConsumerFactory.java
===================================================================
--- trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/SdoServiceConsumerFactory.java	2011-08-14 01:07:56 UTC (rev 543)
+++ trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/SdoServiceConsumerFactory.java	2011-08-14 02:50:37 UTC (rev 544)
@@ -27,6 +27,7 @@
      *
      */
     public static SdoServiceConsumerFactory instance() {
+/*
         if (factory_global == null) {
             synchronized (factory_global_mutex) {
                 if (factory_global == null) {
@@ -40,6 +41,8 @@
         }
 
         return factory_global;
+*/
+        return (SdoServiceConsumerFactory)instance("jp.go.aist.rtm.RTC.SdoServiceConsumerFactory");
     }
     /**
      *  <p> mutex </p>

Modified: trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/SdoServiceProviderFactory.java
===================================================================
--- trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/SdoServiceProviderFactory.java	2011-08-14 01:07:56 UTC (rev 543)
+++ trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/SdoServiceProviderFactory.java	2011-08-14 02:50:37 UTC (rev 544)
@@ -41,7 +41,7 @@
         }
         return factory_global;
 */
-        return (SdoServiceProviderFactory)instance("SdoServiceProviderFactory");
+        return (SdoServiceProviderFactory)instance("jp.go.aist.rtm.RTC.SdoServiceProviderFactory");
     }
     /**
      *  <p> mutex </p>

Modified: trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/CorbaConsumer.java
===================================================================
--- trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/CorbaConsumer.java	2011-08-14 01:07:56 UTC (rev 543)
+++ trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/CorbaConsumer.java	2011-08-14 02:50:37 UTC (rev 544)
@@ -9,6 +9,12 @@
 public class CorbaConsumer<OBJECT_TYPE> extends CorbaConsumerBase {
 
     /**
+     * {@.ja コンストラクタ}
+     * {@.en Consructor}
+     */
+    public CorbaConsumer(){
+    }
+    /**
      * <p>コンストラクタです。</p>
      */
     public CorbaConsumer(Class<OBJECT_TYPE> OBJECT_TYPE_CLASS) {



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