[openrtm-commit:02747] r1008 - in trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC: src/jp/go/aist/rtm/RTC/util tests/src/jp/go/aist/rtm/RTC/util
openrtm @ openrtm.org
openrtm @ openrtm.org
2017年 8月 16日 (水) 17:27:56 JST
Author: t-katami
Date: 2017-08-16 17:27:56 +0900 (Wed, 16 Aug 2017)
New Revision: 1008
Removed:
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/util/RTShellUtil.java
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/util/RTShellUtilTest.java
Log:
[compat,bugfix,->RELENG_1_2] Deleted redundant files.
Deleted: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/util/RTShellUtil.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/util/RTShellUtil.java 2017-08-16 07:59:15 UTC (rev 1007)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/util/RTShellUtil.java 2017-08-16 08:27:56 UTC (rev 1008)
@@ -1,1587 +0,0 @@
-package jp.go.aist.rtm.RTC.util;
-
-import java.util.Vector;
-
-import RTC.RTObject;
-
-import RTC.ComponentProfile;
-import RTC.ComponentProfileHolder;
-import RTC.ComponentProfileListHolder;
-import RTC.ConnectorProfile;
-import RTC.ConnectorProfileHolder;
-import RTC.ConnectorProfileListHolder;
-import RTC.ExecutionContext;
-import RTC.ExecutionContextProfile;
-import RTC.ExecutionContextService;
-import RTC.ExecutionContextServiceHelper;
-import RTC.LifeCycleState;
-import RTC.PortProfile;
-import RTC.PortService;
-import RTC.PortServiceListHolder;
-import RTC.ReturnCode_t;
-
-import _SDOPackage.Configuration;
-import _SDOPackage.ConfigurationSet;
-import _SDOPackage.NameValue;
-import _SDOPackage.NVListHolder;
-
-import jp.go.aist.rtm.RTC.RTObject_impl;
-import jp.go.aist.rtm.RTC.port.PortBase;
-
-/**
- * {@.ja コンポーネントの各種操作ユーティリティクラス。}
- * {@.en }
- * <p>
- * {@.ja Rtshellライクにコンポーネントの各種操作を
- * 簡単に行うことができる関数セット}
- * {@.en }
- *
- */
-public class RTShellUtil {
- /**
- *
- * {@.ja コンポーネントのプロパティ取得}
- * {@.en Get RTC's profile}
- * <p>
- * {@.ja 当該コンポーネントのプロファイル情報を返す。}
- * {@.en This operation returns the ComponentProfile of the RTC.}
- *
- * @param rtc
- * {@.ja RTコンポーネント}
- * {@.ja RTComponent}
- *
- * @return
- * {@.ja コンポーネントのプロパティ}
- * {@.en ComponentProfile}
- *
- * coil::Properties get_component_profile(const RTC::RTObject_ptr rtc)
- */
- public static Properties get_component_profile(final RTObject rtc){
- if(rtc == null){
- return null;
- }
- ComponentProfile cprofs = rtc.get_component_profile();
- NVListHolder nvholder =
- new NVListHolder(cprofs.properties);
-
- Properties prop = new Properties();
- NVUtil.copyToProperties(prop, nvholder);
-
- return prop;
-
- }
-
- /**
- * {@.ja コンポーネントの生存を確認}
- * {@.en Check if the component is alive}
- *
- * @param rtc
- * {@.ja RTコンポーネント}
- * {@.en RTComponent}
- *
- * @return
- * {@.ja true:生存している, false:生存していない}
- * {@.en true: alive, false:non not alive}
- *
- */
- public static boolean is_existing(RTObject rtc) {
- try{
- if (rtc._non_existent()) {
- return false;
- }
- return true;
- }
- catch (Exception ex) {
- return false;
- }
- }
- /**
- *
- * {@.ja RTCがデフォルトの実行コンテキストでalive状態かを判定する}
- * {@.en Confirms the existence of EC of RTC.}
- *
- * @param rtc
- * {@.ja RTコンポーネント}
- * {@.ja RTComponent}
- *
- * @return
- * {@.ja true:alive状態}
- * {@.en Result of Alive state confirmation}
- *
- */
- public static boolean is_alive_in_default_ec(RTObject rtc){
- if(rtc==null) {
- return false;
- }
- ExecutionContext ec = get_actual_ec(rtc);
- if(ec==null){
- return false;
- }
- try {
- return rtc.is_alive(ec);
- }
- catch (Exception ex) {
- return false;
- }
- }
- /**
- * {@.ja RTコンポーネントに関連付けした実行コンテキストから指定したIDの実行コンテキストを取得}
- * {@.en Get ExecutionContext.}
- *
- * {@.en Obtain a reference to the execution context represented
- * by the given handle and RTC.}
- * @param rtc
- * {@.ja 対象のRTコンポーネント}
- * {@.en Target RT-Component's instances}
- *
- * @param ec_id
- * {@.ja 実行コンテキストのID}
- * {@.en ExecutionContext handle}
- *
- * @return
- * {@.ja 実行コンテキスト}
- * {@.en ExecutionContext}
- *
- * RTC::ExecutionContext_var get_actual_ec(const RTC::RTObject_ptr rtc,RTC::UniqueId ec_id = 0)
- */
- public static ExecutionContext get_actual_ec(RTObject rtc, int ec_id) {
- if( ec_id < 0){
- return null;
- }
- if(rtc == null) {
- return null;
- }
- if( ec_id < RTObject_impl.ECOTHER_OFFSET){
- ExecutionContext[] eclist = rtc.get_owned_contexts();
- if( ec_id >= eclist.length){
- return null;
- }
- if(eclist[ec_id] == null){
- return null;
- }
- return eclist[ec_id];
- }
- else {
- int pec_id = ec_id - RTObject_impl.ECOTHER_OFFSET;
- ExecutionContext[] eclist = rtc.get_participating_contexts();
- if(pec_id >= eclist.length){
- return null;
- }
- if(eclist[pec_id]==null){
- return null;
- }
- return eclist[pec_id];
- }
- }
-
- /**
- * {@.ja RTコンポーネントに関連付けした実行コンテキストから指定したIDの実行コンテキストを取得}
- * {@.en Get ExecutionContext.}
- *
- * {@.en Obtain a reference to the execution context represented
- * by the given handle and RTC.}
- * @param rtc
- * {@.ja 対象のRTコンポーネント}
- * {@.en Target RT-Component's instances}
- *
- * @return
- * {@.ja 実行コンテキスト}
- * {@.en ExecutionContext}
- *
- */
- public static ExecutionContext get_actual_ec(RTObject rtc) {
- return get_actual_ec(rtc,0);
- }
- /**
- *
- * {@.ja 対象のRTコンポーネントから指定した実行コンテキストのIDを取得する}
- *
- *
- * @param rtc
- * {@.ja 対象のRTコンポーネント}
- * {@.en Target RT-Component's instances}
- *
- * @param ec
- * {@.ja 実行コンテキスト}
- * {@.en ExecutionContext}
- *
- * @return
- * {@.ja 実行コンテキストのID
- * 指定した実行コンテキストがRTコンポーネントに
- * 関連付けられていなかった場合は-1を返す}
- * {@.en ID of ExecutionContext}
- *
- */
- public static int get_ec_id(RTObject rtc, ExecutionContext ec){
-
- if(rtc == null){
- return -1;
- }
- ExecutionContext[] eclist = rtc.get_owned_contexts();
-
- for(int ic=0;ic<eclist.length;++ic){
- if(eclist[ic] != null){
- if(eclist[ic]._is_equivalent(ec)){
- return ic;
- }
- }
- }
- ExecutionContext[] eclist_pec = rtc.get_participating_contexts();
- for(int ic=0;ic<eclist_pec.length;++ic){
- if(eclist_pec[ic] != null){
- if(eclist_pec[ic]._is_equivalent(ec)){
- return ic+RTObject_impl.ECOTHER_OFFSET;
- }
- }
- }
- return -1;
- }
- /**
- *
- * {@.ja RTCを指定した実行コンテキストでアクティベーションする}
- * {@.en Activates RTC via Specified ExecutionContext.}
- *
- * @param rtc
- * {@.ja 対象のRTコンポーネント}
- * {@.en Target RT-Component's instances}
- *
- * @param ec_id
- * {@.ja 実行コンテキストのID}
- * {@.en ExecutionContext handle}
- *
- * @return
- * {@.ja RTC、ECのオブジェクトリファレンスがnilの場合はBAD_PARAMETERを返す
- * nilではない場合はactivate_component関数の戻り値を返す。RTC_OKの場合はアクティベーションが成功}
- }
- * {@.en Return code}
- * RTC::ReturnCode_t activate(RTC::RTObject_ptr rtc, RTC::UniqueId ec_id = 0)
- */
- public static ReturnCode_t activate(RTObject rtc, int ec_id){
- if(rtc==null){
- return ReturnCode_t.BAD_PARAMETER;
- }
- ExecutionContext ec = get_actual_ec(rtc, ec_id);
- if(ec==null){
- return ReturnCode_t.BAD_PARAMETER;
- }
- return ec.activate_component(rtc);
-
- }
- /**
- *
- * {@.ja RTCをアクティベーションする}
- * {@.en Activates RTC}
- *
- * @param rtc
- * {@.ja 対象のRTコンポーネント}
- * {@.en Target RT-Component's instances}
- *
- * @return
- * {@.ja RTC、ECのオブジェクトリファレンスがnilの場合はBAD_PARAMETERを返す
- * nilではない場合はactivate_component関数の戻り値を返す。RTC_OKの場合はアクティベーションが成功}
- * {@.en Return code}
- }
- * RTC::ReturnCode_t activate(RTC::RTObject_ptr rtc, RTC::UniqueId ec_id = 0)
- */
- public static ReturnCode_t activate(RTObject rtc){
- return activate(rtc,0);
- }
- /**
- *
- * {@.ja RTCを指定した実行コンテキストで非アクティベーションする}
- * {@.en Deactivates RTC via Specified ExecutionContext.}
- *
- * @param rtc
- * {@.ja 対象のRTコンポーネント}
- * {@.en Target RT-Component's instances}
- *
- * @param ec_id
- * {@.ja 実行コンテキストのID}
- * {@.en ExecutionContext handle}
- *
- * @return
- * {@.ja RTC、ECのオブジェクトリファレンスがnilの場合はBAD_PARAMETERを返す
- * nilではない場合はdeactivate_component関数の戻り値を返す。RTC_OKの場合は非アクティベーションが成功}
- * RTC::ReturnCode_t deactivate(RTC::RTObject_ptr rtc, RTC::UniqueId ec_id = 0)
- * {@.en Return code}
- */
- public static ReturnCode_t deactivate(RTObject rtc, int ec_id){
-
- if(rtc==null){
- return ReturnCode_t.BAD_PARAMETER;
- }
- ExecutionContext ec = get_actual_ec(rtc, ec_id);
- if(ec==null){
- return ReturnCode_t.BAD_PARAMETER;
- }
- return ec.deactivate_component(rtc);
- }
- /**
- *
- * {@.ja RTCを非アクティベーションする}
- * {@.en Deactivates RTC.}
- *
- * @param rtc
- * {@.ja 対象のRTコンポーネント}
- * {@.en Target RT-Component's instances}
- *
- * @return
- * {@.ja RTC、ECのオブジェクトリファレンスがnilの場合はBAD_PARAMETERを返す
- * nilではない場合はdeactivate_component関数の戻り値を返す。RTC_OKの場合は非アクティベーションが成功}
- * RTC::ReturnCode_t deactivate(RTC::RTObject_ptr rtc, RTC::UniqueId ec_id = 0)
- * {@.en Return code}
- */
- public static ReturnCode_t deactivate(RTObject rtc){
- return deactivate( rtc, 0);
- }
- /**
- *
- * {@.ja RTCを指定した実行コンテキストでリセットする}
- * {@.en Resets RTC via Specified RTC.}
- *
- * @param rtc
- * {@.ja 対象のRTコンポーネント}
- * {@.en Target RT-Component's instances}
- *
- * @param ec_id
- * {@.ja 実行コンテキストのID}
- * {@.en ExecutionContext handle}
- *
- * @return
- * {@.ja RTC、ECのオブジェクトリファレンスがnilの場合はBAD_PARAMETERを返す
- * nilではない場合はdeactivate_component関数の戻り値を返す。RTC_OKの場合はリセットが成功}
- * {@.en Return code}
- *
- * RTC::ReturnCode_t reset(RTC::RTObject_ptr rtc, RTC::UniqueId ec_id = 0)
- */
- public static ReturnCode_t reset(RTObject rtc, int ec_id){
- if(rtc==null){
- return ReturnCode_t.BAD_PARAMETER;
- }
- ExecutionContext ec = get_actual_ec(rtc, ec_id);
- if(ec==null){
- return ReturnCode_t.BAD_PARAMETER;
- }
- return ec.reset_component(rtc);
- }
- /**
- *
- * {@.ja RTCをリセットする}
- * {@.en Resets RTC}
- *
- * @param rtc
- * {@.ja 対象のRTコンポーネント}
- * {@.en Target RT-Component's instances}
- *
- * @return
- * {@.ja RTC、ECのオブジェクトリファレンスがnilの場合はBAD_PARAMETERを返す
- * nilではない場合はdeactivate_component関数の戻り値を返す。RTC_OKの場合はリセットが成功}
- * {@.en Return code}
- *
- */
- public static ReturnCode_t reset(RTObject rtc){
- return reset(rtc,0);
- }
- /**
- *
- * {@.ja 対象のRTコンポーネントの指定した実行コンテキストでの状態を取得}
- * {@.en Get RTC's status}
- *
- * @param rtc
- * {@.ja 対象のRTコンポーネント}
- * {@.en Target RT-Component's instances}
- *
- * @param ec_id
- * {@.ja 実行コンテキストのID}
- * {@.en ExecutionContext handle}
- *
- * @return
- * {@.ja RTCの状態}
- * {@.en RTC's status}
- *
- *
- */
- public static LifeCycleState get_state(RTObject rtc, int ec_id){
- if(rtc==null){
- return LifeCycleState.ERROR_STATE;
- }
- ExecutionContext ec = get_actual_ec(rtc, ec_id);
- if(ec==null){
- return LifeCycleState.ERROR_STATE;
- }
- return ec.get_component_state(rtc);
- }
- /**
- *
- * {@.ja 対象のRTコンポーネントの状態を取得}
- * {@.en Get RTC's status}
- *
- * @param rtc
- * {@.ja 対象のRTコンポーネント}
- * {@.en Target RT-Component's instances}
- *
- * @return
- * {@.ja RTCの状態}
- * {@.en RTC's status}
- *
- *
- */
- public static LifeCycleState get_state(RTObject rtc){
- return get_state(rtc, 0);
- }
- /**
- *
- * {@.ja 対象のRTコンポーネントの指定した実行コンテキストでINACTIVE状態かどうか判定}
- * {@.en Confirm to INACTIVE}
- *
- *
- * @param rtc
- * {@.ja 対象のRTコンポーネント}
- * {@.en Target RT-Component's instances}
- *
- * @param ec_id
- * {@.ja 実行コンテキストのID}
- * {@.en ExecutionContext handle}
- *
- * @return
- * {@.ja INACTIVE状態の時はtrue、それ以外はfalse
- * rtc、ecがnilの場合もfalseを返す}
- * {@.en Result of state confirmation
- * (INACTIVE state:true, other state:false)}
- *
- */
- public static boolean is_in_inactive(RTObject rtc, int ec_id){
- if( get_state(rtc, ec_id) == LifeCycleState.INACTIVE_STATE){
- return true;
- }
- return false;
- }
- /**
- *
- * {@.ja 対象のRTコンポーネントの指定した実行コンテキストでINACTIVE状態かどうか判定}
- * {@.en Confirm to INACTIVE}
- *
- *
- * @param rtc
- * {@.ja 対象のRTコンポーネント}
- * {@.en Target RT-Component's instances}
- *
- *
- * @return
- * {@.ja INACTIVE状態の時はtrue、それ以外はfalse
- * rtc、ecがnilの場合もfalseを返す}
- * {@.en Result of state confirmation
- * (INACTIVE state:true, other state:false)}
- *
- */
- public static boolean is_in_inactive(RTObject rtc){
- return is_in_inactive(rtc, 0);
- }
- /**
- *
- * {@.ja 対象のRTコンポーネントの指定した実行コンテキストでACTIVE状態かどうか判定}
- * {@.en Confirm to ACTIVE}
- *
- * @param rtc
- * {@.ja 対象のRTコンポーネント}
- * {@.en Target RT-Component's instances}
- *
- * @param ec_id
- * {@.ja 実行コンテキストのID}
- * {@.en ExecutionContext handle}
- *
- * @return
- * {@.ja ACTIVE状態の時はtrue、それ以外はfalse
- * rtc、ecがnilの場合もfalseを返す}
- * {@.en Result of state confirmation
- * (ACTIVE state:true, other state:false)}
- *
- */
- public static boolean is_in_active(RTObject rtc, int ec_id){
- if(get_state(rtc, ec_id) == LifeCycleState.ACTIVE_STATE){
- return true;
- }
- return false;
- }
- /**
- *
- * {@.ja 対象のRTコンポーネントがACTIVE状態かどうか判定}
- * {@.en Confirm to ACTIVE}
- *
- * @param rtc
- * {@.ja 対象のRTコンポーネント}
- * {@.en Target RT-Component's instances}
- *
- * @return
- * {@.ja ACTIVE状態の時はtrue、それ以外はfalse
- * rtc、ecがnilの場合もfalseを返す}
- * {@.en Result of state confirmation
- * (ACTIVE state:true, other state:false)}
- *
- */
- public static boolean is_in_active(RTObject rtc){
- return is_in_active(rtc, 0);
- }
- /**
- *
- * {@.ja 対象のRTコンポーネントの指定した実行コンテキストでERROR状態かどうか判定}
- * {@.en Confirm to ERROR}
- *
- * @param rtc
- * {@.ja 対象のRTコンポーネント}
- * {@.en Target RT-Component's instances}
- *
- * @param ec_id
- * {@.ja 実行コンテキストのID}
- * {@.en ExecutionContext handle}
- *
- * @return
- * {@.ja ERROR状態の時はtrue、それ以外はfalse
- * rtc、ecがnilの場合もfalseを返す}
- * {@.en Result of state confirmation
- * (ERROR state:true, other state:false)}
- *
- */
- public static boolean is_in_error(RTObject rtc, int ec_id){
- if(get_state(rtc, ec_id) == LifeCycleState.ERROR_STATE){
- return true;
- }
- return false;
- }
- /**
- *
- * {@.ja 対象のRTコンポーネントがERROR状態かどうか判定}
- * {@.en Confirm to ERROR}
- *
- * @param rtc
- * {@.ja 対象のRTコンポーネント}
- * {@.en Target RT-Component's instances}
- *
- *
- * @return
- * {@.ja ERROR状態の時はtrue、それ以外はfalse
- * rtc、ecがnilの場合もfalseを返す}
- * {@.en Result of state confirmation
- * (ERROR state:true, other state:false)}
- *
- */
- public static boolean is_in_error(RTObject rtc){
- return is_in_error(rtc,0);
- }
- /**
- *
- * {@.ja RTCのデフォルトの実行コンテキストの実行周期を取得する}
- * {@.en Get execution rate(Hz) of ExecutionContext}
- *
- * @param rtc
- * {@.ja 対象のRTコンポーネント}
- * {@.en Target RT-Component's instances}
- *
- * @return
- * {@.ja 実行周期}
- * {@.en Execution cycle(Unit:Hz)}
- */
- public static double get_default_rate(RTObject rtc){
- if(rtc==null)
- {
- return 0.0;
- }
- ExecutionContext ec = get_actual_ec(rtc);
- return ec.get_rate();
- }
- /**
- *
- * {@.ja RTCのデフォルトの実行コンテキストの実行周期を設定する}
- * {@.en Set execution rate(Hz) of ExecutionContext}
- *
- *
- * @param rtc
- * {@.ja 対象のRTコンポーネント}
- * {@.en Target RT-Component's instances}
- *
- *
- * @param rate
- * {@.ja 実行周期}
- * {@.en Execution cycle(Unit:Hz)}
- *
- * @return
- * {@.ja set_rate関数の戻り値を返す。 RTC_OKで設定が成功}
- * {@.en Return code}
- *
- */
- public static ReturnCode_t set_default_rate(RTObject rtc, double rate){
- if(rtc==null)
- {
- return ReturnCode_t.BAD_PARAMETER;
- }
- ExecutionContext ec = get_actual_ec(rtc);
- return ec.set_rate(rate);
-
- }
- /**
- *
- * {@.ja RTCの指定IDの実行コンテキストの周期を取得}
- * {@.en Get execution rate(Hz) of specified ExecutionContext}
- *
- * @param rtc
- * {@.ja 対象のRTコンポーネント}
- * {@.en Target RT-Component's instances}
- *
- * @param ec_id
- * {@.ja 指定の実行コンテキストのID}
- * {@.en ExecutionContext handle}
- *
- * @return
- * {@.ja 実行周期}
- * {@.en Execution cycle(Unit:Hz)}
- *
- */
- public static double get_current_rate(RTObject rtc, int ec_id){
- if(rtc == null)
- {
- return -1.0;
- }
- ExecutionContext ec = get_actual_ec(rtc, ec_id);
- if(ec == null)
- {
- return -1.0;
- }
- return ec.get_rate();
- }
- /**
- *
- * {@.ja RTCの指定IDの実行コンテキストの周期を設定}
- * {@.en Set execution rate(Hz) of specified ExecutionContext}
- *
- * @param rtc
- * {@.ja 対象のRTコンポーネント}
- * {@.en Target RT-Component's instances}
- *
- * @param ec_id
- * {@.ja 指定の実行コンテキストのID}
- * {@.en ExecutionContext handle}
- *
- * @return
- * {@.ja set_rate関数の戻り値を返す。RTC_OKで設定が成功}
- * {@.en Return code}
- *
- */
- public static ReturnCode_t set_current_rate(RTObject rtc,
- int ec_id, double rate){
- if(rtc == null)
- {
- return ReturnCode_t.BAD_PARAMETER;
- }
- ExecutionContext ec = get_actual_ec(rtc, ec_id);
- if(ec == null)
- {
- return ReturnCode_t.BAD_PARAMETER;
- }
- return ec.set_rate(rate);
- }
- /**
- *
- * {@.ja 対象のRTCのデフォルトの実行コンテキストに指定のRTCを関連付ける}
- * {@.en Add an RT-component to The target RT-Component of ExecutionContext}
- *
- *
- * @param localcomp
- * {@.ja 対象のRTコンポーネント}
- * {@.en Target RT-Component's instances}
- *
- * @param othercomp
- * {@.ja 実行コンテキストに関連付けるRTコンポーネント}
- * {@.en The target RT-Component for add}
- *
- * @return
- * {@.ja ecの取得に失敗した場合はRTC_ERRORを返す
- * そうでない場合はaddComponent関数の戻り値を返す。RTC_OKで接続成功。}
- * {@.en The return code of ReturnCode_t type}
- *
- */
- public static ReturnCode_t add_rtc_to_default_ec(RTObject localcomp,
- RTObject othercomp){
- if(othercomp == null)
- {
- return ReturnCode_t.RTC_ERROR;
- }
- ExecutionContext ec = get_actual_ec(localcomp);
- if(ec==null){
- return ReturnCode_t.RTC_ERROR;
- }
- return ec.add_component(othercomp);
- }
- /**
- *
- * {@.ja 対象のRTCのデフォルトの実行コンテキストの指定のRTCへの関連付けを
- * 解除する}
- * {@.en Remove the RT-Component from participant list of ExecutionContext}
- *
- *
- * @param localcomp
- * {@.ja 対象のRTコンポーネント}
- * {@.en Target RT-Component's instances}
- *
- * @param othercomp
- * {@.ja 実行コンテキストとの関連付けを解除するRTコンポーネント}
- * {@.en The target RT-Component for delete}
- *
- * @return
- * {@.ja ecの取得に失敗した場合はRTC_ERRORを返す
- * そうでない場合はremoveComponent関数の戻り値を返す。RTC_OKで接続成功。}
- * {@.en The return code of ReturnCode_t type}
- *
- */
- public static ReturnCode_t remove_rtc_to_default_ec(RTObject localcomp,
- RTObject othercomp){
- if(othercomp == null)
- {
- return ReturnCode_t.RTC_ERROR;
- }
- ExecutionContext ec = get_actual_ec(localcomp);
- if(ec==null){
- return ReturnCode_t.RTC_ERROR;
- }
- return ec.remove_component(othercomp);
- }
- /**
- *
- * {@.ja RTCのデフォルトの実行コンテキストに参加しているRTCのリストを
- * 取得する}
- * {@.en Getting participant RTC list}
- * <p>
- * {@.ja 実行コンテキストがnilの場合は空のリストを返す}
- *
- *
- * @param rtc
- * {@.ja RTコンポーネント}
- * {@.en Target RT-Component's instances}
- *
- * @return
- * {@.ja RTCのリスト}
- * {@.en Participants RTC list}
- */
- public static RTObject[] get_participants_rtc(RTObject rtc){
- ExecutionContext ec = get_actual_ec(rtc);
- if(ec==null){
- return null;
- }
- ExecutionContextService ecs;
- ecs = ExecutionContextServiceHelper.narrow(ec);
- if(ecs==null){
- return null;
- }
- ExecutionContextProfile prifile = ecs.get_profile();
- return prifile.participants;
- }
- /**
- *
- * {@.ja 指定したRTCの保持するポートの名前を取得}
- * {@.en Gets the port name a specified RTC maintains.}
- *
- * @param rtc
- * {@.ja 対象のRTコンポーネント}
- * {@.en Target RT-Component's instances}
- *
- * @return
- * {@.ja ポート名のリスト}
- * {@.en List of port names}
- *
- */
- public static Vector<String> get_port_names(RTObject rtc){
- if(rtc==null){
- return null;
- }
- Vector<String> names = new Vector<String>();
- PortServiceListHolder ports = new PortServiceListHolder();
- ports.value = rtc.get_ports();
- for (int ic=0; ic < ports.value.length; ++ic) {
- PortProfile pp = ports.value[ic].get_port_profile();
- String str = pp.name;
- names.add(str);
- }
- return names;
- }
- /**
- *
- * {@.ja 指定したRTCの保持するインポートの名前を取得}
- * {@.en Gets the inport name a specified RTC maintains.}
- *
- * @param rtc
- * {@.ja 対象のRTコンポーネント}
- * {@.en Target RT-Component's instances}
- *
- * @return
- * {@.ja ポート名のリスト}
- * {@.en List of port names}
- *
- *
- */
- public static Vector<String> get_inport_names(RTObject rtc) {
- if(rtc==null){
- return null;
- }
-
- Vector<String> names = new Vector<String>();
- PortServiceListHolder ports = new PortServiceListHolder();
- ports.value = rtc.get_ports();
- for (int ic=0; ic < ports.value.length; ++ic) {
- PortProfile pp = ports.value[ic].get_port_profile();
- NVListHolder nvholder =
- new NVListHolder(pp.properties);
- Properties prop = new Properties();
- NVUtil.copyToProperties(prop, nvholder);
- String str = prop.getProperty("port.port_type");
- if(str.equals("DataInPort")){
- names.add(pp.name);
- }
- }
- return names;
- }
- /**
- *
- * {@.ja 指定したRTCの保持するアウトポートの名前を取得}
- * {@.en Gets the outport name a specified RTC maintains.}
- *
- * @param rtc
- * {@.ja 対象のRTコンポーネント}
- * {@.en Target RT-Component's instances}
- *
- * @return
- * {@.ja ポート名のリスト}
- * {@.en List of port names}
- *
- */
- public static Vector<String> get_outport_names(RTObject rtc){
- if(rtc==null){
- return null;
- }
- Vector<String> names = new Vector<String>();
- PortServiceListHolder ports = new PortServiceListHolder();
-
- ports.value = rtc.get_ports();
- for (int ic=0; ic < ports.value.length; ++ic) {
- PortProfile pp = ports.value[ic].get_port_profile();
- NVListHolder nvholder =
- new NVListHolder(pp.properties);
- Properties prop = new Properties();
- NVUtil.copyToProperties(prop, nvholder);
- String str = prop.getProperty("port.port_type");
- if(str.equals("DataOutPort")){
- names.add(pp.name);
- }
- }
- return names;
- }
-
-
- /**
- * {@.ja 指定したRTCの保持するサービスポートの名前を取得}
- * {@.en Gets names of service port a specified RTC maintains.}
- *
- * @param rtc
- * {@.ja 対象のRTコンポーネント}
- * {@.en Target RT-Component's instances}
- *
- * @return
- * {@.ja ポート名のリスト}
- * {@.en List of port names}
- */
- public static Vector<String> get_svcport_names(RTObject rtc){
- if(rtc==null){
- return null;
- }
-
- Vector<String> names = new Vector<String>();
-
- PortServiceListHolder ports = new PortServiceListHolder();
- ports.value = rtc.get_ports();
- for (int ic=0; ic < ports.value.length; ++ic) {
- PortProfile pp = ports.value[ic].get_port_profile();
- NVListHolder nvholder =
- new NVListHolder(pp.properties);
- Properties prop = new Properties();
- NVUtil.copyToProperties(prop, nvholder);
- String str = prop.getProperty("port.port_type");
- if(str.equals("CorbaPort")){
- names.add(pp.name);
- }
- }
- return names;
- }
-
- /**
- *
- * {@.ja 対象のRTCから指定した名前のポートを取得}
- * {@.en Get a port of the specified name from ports Component maintains.}
- *
- * @param rtc
- * {@.ja RTコンポーネント}
- * {@.en Target RT-Component's instances}
- *
- * @param name
- * {@.ja ポート名}
- * {@.en the name of port}
- *
- * @return
- * {@.ja ポート}
- * {@.en PortService}
- *
- * RTC::PortService_var get_port_by_name(const RTC::RTObject_ptr rtc, std::string name)
- */
- public static PortService get_port_by_name(RTObject rtc, String name){
- if(rtc==null){
- return null;
- }
- PortServiceListHolder ports = new PortServiceListHolder();
- ports.value = rtc.get_ports();
- for (int ic=0; ic < ports.value.length; ++ic) {
- PortProfile pp = ports.value[ic].get_port_profile();
- if(pp.name.equals(name)){
- return ports.value[ic];
- }
- }
- return null;
- }
- /**
- *
- * {@.ja 指定したポートの保持しているコネクタの名前のリストを取得}
- * {@.en Gets a list of the ports name specified port maintains.}
- *
- * @param port
- * {@.ja 対象のポート}
- * {@.en Target Port}
- *
- * @return
- * {@.ja コネクタ名のリスト}
- * {@.en List of port names}
- *
- *
- */
- public static Vector<String> get_connector_names(PortBase port){
- if(port==null){
- return null;
- }
- Vector<String> names = new Vector<String>();
- ConnectorProfileListHolder conprof =
- new ConnectorProfileListHolder();
- conprof.value = port.get_connector_profiles();
- for(int ic=0;ic<conprof.value.length;++ic){
- names.add(conprof.value[ic].name);
- }
- return names;
- }
-
- /**
- *
- * {@.ja 指定したポートの保持しているコネクタのIDのリストを取得}
- * {@.en Gets a list of the connectorIDs specified port maintains.}
- *
- *
- * @param port 対象のポート
- * {@.ja 対象のポート}
- * {@.en Target Port}
- *
- * @return
- * {@.ja コネクタのIDのリスト}
- * {@.en List of connectorIDs}
- *
- *
- */
- public static Vector<String> get_connector_ids(PortBase port){
- if(port == null){
- return null;
- }
- Vector<String> ids = new Vector<String>();
- ConnectorProfileListHolder conprof =
- new ConnectorProfileListHolder();
- conprof.value = port.get_connector_profiles();
- for(int ic=0;ic<conprof.value.length;++ic){
- ids.add(conprof.value[ic].connector_id);
- }
- return ids;
- }
- /**
- *
- * {@.ja 指定したポートを接続するためのコネクタプロファイルを取得}
- * {@.en Gets ConnectorProfile for connect specified ports}
- *
- *
- * @param name
- * {@.ja コネクタ名}
- * {@.en connector name}
- *
- * @param prop_arg
- * {@.ja 設定}
- * {@.en connection properties}
- *
- * @param port0
- * {@.ja 対象のポート1}
- * {@.en Target Port}
- *
- * @param port1
- * {@.ja 対象のポート2}
- * {@.en Target Port}
- *
- * @return
- * {@.ja コネクタプロファイル}
- * {@.en ConnectorProfile}
- *
- *
- * RTC::ConnectorProfile_var create_connector(const std::string name,const coil::Properties prop_arg,const RTC::PortService_ptr port0,const RTC::PortService_ptr port1)
- */
- public static ConnectorProfile create_connector(String name,
- Properties prop_arg, PortService port0, PortService port1){
- Properties prop = new Properties(prop_arg);
- String connector_id = new String();
- PortService[] ports = new PortService[2];
- ports[0] = port0;
- ports[1] = port1;
- NameValue[] properties = new NameValue[0];
- ConnectorProfile conn_prof = new ConnectorProfile(
- name,
- connector_id,
- ports,
- properties
- );
-
- if(prop.getProperty("dataport.dataflow_type").isEmpty()){
- prop.setProperty("dataport.dataflow_type","push");
- }
-
-
- if(prop.getProperty("dataport.interface_type").isEmpty()){
- prop.setProperty("dataport.interface_type","corba_cdr");
- }
-
- NVListHolder nvlist = new NVListHolder();
- NVUtil.copyFromProperties(nvlist, prop);
- conn_prof.properties = nvlist.value;
-
- return conn_prof;
-
- }
-
- /**
- *
- * {@.ja 指定したポート同士が接続されているかを判定}S
- * {@.en Cconfirms the connection in specified ports.}
- *
- *
- * @param localport
- * {@.ja 対象のポート1}
- * {@.en Target Port}
- *
- * @param otherport
- * {@.ja 対象のポート2}
- * {@.en Target Port}
- *
- * @return
- * {@.ja true: 接続済み、false: 未接続}
- * {p.en already connected:true}
- *
- */
- public static boolean already_connected(PortService localport,
- PortService otherport){
- ConnectorProfileListHolder conprof =
- new ConnectorProfileListHolder();
- conprof.value = localport.get_connector_profiles();
- for(int ic=0;ic<conprof.value.length;++ic){
- ConnectorProfile cprof = conprof.value[ic];
- for(int icc=0;icc<cprof.ports.length;++icc){
- if(cprof.ports[icc]._is_equivalent(otherport)){
- return true;
- }
- }
- }
- return false;
- }
- /**
- *
- *
- * {@.ja 指定したポートを接続する}
- * {@.en Connects specified ports.}
- *
- *
- * @param name
- * {@.ja コネクタ名}
- * {@.en connector name}
- *
- * @param prop
- * {@.ja 設定}
- * {@.en connection properties}
- *
- * @param port0
- * {@.ja 対象のポート1}
- * {@.en Target Port}
- *
- * @param port1
- * {@.ja 対象のポート2}
- * {@.en Target Port}
- *
- * @return
- * {@.ja RTC、ECのオブジェクトリファレンスがnilの場合はBAD_PARAMETERを
- * 返す
- * nilではない場合はport0.connect関数の戻り値を返す。
- * RTC_OKの場合は接続が成功}
- * {@.en Return code}
- *
- * RTC::ReturnCode_t connect(const std::string name,const coil::Properties prop,const RTC::PortService_ptr port0,const RTC::PortService_ptr port1)
- */
- public static ReturnCode_t connect(String name, Properties prop,
- PortService port0, PortService port1){
- if(port0 == null){
- return ReturnCode_t.BAD_PARAMETER;
- }
- if(port1 == null){
- return ReturnCode_t.BAD_PARAMETER;
- }
- if(port0._is_equivalent(port1)){
- return ReturnCode_t.BAD_PARAMETER;
- }
- if(prop == null){
- prop = new Properties();
- }
- ConnectorProfileHolder profileholder = new ConnectorProfileHolder();
- profileholder.value = create_connector(name, prop, port0, port1);
- return port0.connect(profileholder);
-
- }
- /**
- *
- * {@.ja 指定したポートと指定したリスト内のポート全てと接続する}
- * {@.en Connects all specified ports.}
- *
- * @param name コネクタ名
- * {@.ja コネクタ名}
- * {@.en connector name}
- *
- * @param prop
- * {@.ja 設定}
- * {@.en connection properties}
- *
- * @param port
- * {@.ja 対象のポート}
- * {@.en Target Port}
- *
- * @param target_ports
- * {@.ja 対象のポートのリスト}
- * {@.en List of connected ports}
- *
- * @return
- * {@.ja 全ての接続が成功した場合はRTC_OKを返す。
- * connect関数がRTC_OK以外を返した場合はRTC_ERRORを返す。}
- * {@.en Return code}
- *
- *
- * RTC::ReturnCode_t connect_multi(const std::string name,const coil::Properties prop,const RTC::PortService_ptr port,RTC::PortServiceList_var& target_ports)
- */
- public static ReturnCode_t connect_multi(String name, Properties prop,
- PortService port, PortServiceListHolder target_ports){
- ReturnCode_t ret = ReturnCode_t.RTC_OK;
-
- if(port == null){
- return ReturnCode_t.BAD_PARAMETER;
- }
- if(target_ports == null){
- return ReturnCode_t.BAD_PARAMETER;
- }
- if(target_ports.value == null){
- return ReturnCode_t.BAD_PARAMETER;
- }
- for (int ic=0; ic < target_ports.value.length; ++ic) {
- if(target_ports.value[ic]._is_equivalent(port)){
- continue;
- }
- if(already_connected(port, target_ports.value[ic])){
- continue;
- }
- ConnectorProfileHolder profileholder = new ConnectorProfileHolder();
- profileholder.value
- = create_connector(name, prop, port, target_ports.value[ic]);
- if(port.connect(profileholder) != ReturnCode_t.RTC_OK){
- ret = ReturnCode_t.RTC_ERROR;
- }
- }
- return ret;
- }
- /**
- *
- * {@.ja 対象のRTCの指定した名前のポートを接続する}
- * {@.en Connects the ports specified by the name.}
- *
- * @param name
- * {@.ja コネクタ名}
- * {@.en connector name}
- *
- * @param prop
- * {@.ja 設定}
- * {@.en connection properties}
- *
- * @param rtc0
- * {@.ja 対象のRTCコンポーネント1}
- * {@.en Target RT-Component's instances}
- *
- * @param portName0
- * {@.ja 対象のポート名1}
- * {@.en Target Port name}
- *
- * @param rtc1
- * {@.ja 対象のRTCコンポーネント2}
- * {@.en Target RT-Component's instances}
- *
- * @param portName1
- * {@.ja 対象のポート名2}
- * {@.en Target Port name}
- *
- * @return
- * {@.ja RTC、ポートがnilの場合はBAD_PARAMETERを返す。
- * nilではない場合はport0.connect関数の戻り値を返す。
- * RTC_OKの場合は接続が成功}
- * {@.en Return code}
- *
- *
- * RTC::ReturnCode_t connect_by_name(std::string name, coil::Properties prop,RTC::RTObject_ptr rtc0,const std::string portName0,RTC::RTObject_ptr rtc1,const std::string portName1)
- */
- public static ReturnCode_t connect_by_name( String name, Properties prop,
- RTObject rtc0, String portName0, RTObject rtc1, String portName1){
- if(rtc0 == null){
- return ReturnCode_t.BAD_PARAMETER;
- }
- if(rtc1 == null){
- return ReturnCode_t.BAD_PARAMETER;
- }
- PortService port0 = get_port_by_name(rtc0, portName0);
- if(port0 == null){
- return ReturnCode_t.BAD_PARAMETER;
- }
-
- PortService port1 = get_port_by_name(rtc1, portName1);
- if(port1==null){
- return ReturnCode_t.BAD_PARAMETER;
- }
-
- return connect(name, prop, port0, port1);
-
- }
- /**
- *
- * {@.ja 指定のコネクタを切断する}
- * {@.en Disconnects specified connections.}
- *
- *
- * @param connector_prof
- * {@.ja コネクタプロファイル}
- * {@.en Conenctor Profile}
- *
- * @return
- * {@.ja コネクタプロファイルで保持しているポートの
- * オブジェクトリファレンスがnilの場合はBAD_PARAMETERを返す
- * nilではない場合はports[0].disconnect関数の戻り値を返す。
- * RTC_OKの場合は切断が成功}
- * {@.en Return code}
- *
- *
- */
- public static ReturnCode_t disconnect(ConnectorProfile connector_prof){
- if(connector_prof == null){
- return ReturnCode_t.BAD_PARAMETER;
- }
- PortServiceListHolder ports = new PortServiceListHolder();
- ports.value = connector_prof.ports;
- return disconnect_by_connector_id(ports.value[0],
- connector_prof.connector_id);
- }
-
- /**
- *
- * {@.ja 対象のポートで指定した名前のコネクタを切断}
- * {@.en Disconnects the connectionis specified by name.}
- *
- * @param port
- * {@.ja 対象のポート}
- * {@.en Target Port}
- *
- * @param name
- * {@.ja コネクタ名}
- * {@.en Connector name}
- *
- * @return
- * {@.ja portがnilの場合はBAD_PARAMETERを返す
- * nilではない場合はdisconnect関数の戻り値を返す。RTC_OKの場合は切断が成功}
- * {@.en Return code}
- *
- *
- */
- public static ReturnCode_t disconnect_by_connector_name(PortService port,
- String name){
- if(port == null){
- return ReturnCode_t.BAD_PARAMETER;
- }
- ConnectorProfileListHolder conprof =
- new ConnectorProfileListHolder();
- conprof.value = port.get_connector_profiles();
- for(int ic=0;ic<conprof.value.length;++ic){
- if(conprof.value[ic].name.equals(name)){
- return disconnect(conprof.value[ic]);
- }
- }
- return ReturnCode_t.BAD_PARAMETER;
-
- }
-
- /**
- *
- * {@.ja 対象のポートで指定したIDのコネクタを切断}
- * {@.en Disconnects the connectionis specified by id.}
- *
- *
- * @param port
- * {@.ja 対象のポート}
- * {@.en Target Port}
- *
- * @param id
- * {@.ja コネクタID}
- * {@.en connector id}
- *
- * @return
- * {@.ja portがnilの場合はBAD_PARAMETERを返す
- * nilではない場合はdisconnect関数の戻り値を返す。RTC_OKの場合は切断が成功}
- * {@.en Return code}
- *
- *
- */
- public static ReturnCode_t disconnect_by_connector_id(PortService port,
- String id){
- if(port == null){
- return ReturnCode_t.BAD_PARAMETER;
- }
- return port.disconnect(id);
-
- }
- /**
- *
- * {@.ja 対象ポートと接続しているポートで指定したポート名と一致した場合に
- * 切断}
- * {@.en Disconnects a connection in specified by port.}
- *
- * @param localport
- * {@.ja 対象のポート}
- * {@.en Target Port}
- *
- * @param othername
- * {@.ja 接続しているポート名}
- * {@.en port name}
- *
- * @return
- * {@.ja ポートがnilの場合、localportの名前とothernameが一致する場合、
- * 接続しているポートの名前でothernameと一致するものがない場合に
- * BAD_PARAMETERを返す
- * 上記の条件に当てはまらない場合はdisconnect関数の戻り値を返す。
- * RTC_OKの場合は切断が成功}
- * {@.en Return code}
- *
- *
- */
- public static ReturnCode_t disconnect_by_port_name(PortService localport,
- String othername){
- if(localport == null){
- return ReturnCode_t.BAD_PARAMETER;
- }
- PortProfile prof = localport.get_port_profile();
- if( prof.name.equals(othername)){
- return ReturnCode_t.BAD_PARAMETER;
- }
-
- ConnectorProfileListHolder conprof =
- new ConnectorProfileListHolder();
- conprof.value = localport.get_connector_profiles();
-
- for(int ic=0;ic<conprof.value.length;++ic){
- ConnectorProfile cprof = conprof.value[ic];
- for(int icc=0;icc<cprof.ports.length;++icc){
- if(cprof.ports[icc] != null){
- PortProfile pp = cprof.ports[icc].get_port_profile();
- if(pp.name.equals(othername)){
- return disconnect(cprof);
- }
-
- }
- }
- }
-
- return ReturnCode_t.BAD_PARAMETER;
- }
- /**
- *
- * {@.ja 指定したRTコンポーネントのコンフィギュレーション取得}
- * {@.en Get Configuration object}
- *
- * @param rtc
- * {@.ja 対象のRTコンポーネント}
- * {@.en Target RTComponent}
- *
- * @return
- * {@.ja rtcがnilの場合はNoneを返す。
- * nilではない場合はコンフィギュレーションを返す。}
- * {@.en The Configuration interface of an SDO.}
- *
- */
- public static Configuration get_configuration(RTObject rtc){
- if(rtc==null){
- return null;
- }
- try {
- return rtc.get_configuration();
- }
- catch (Exception ex) {
- return null;
- }
- }
- /**
- *
- * {@.ja 指定したコンフィギュレーションセット名、パラメータ名の
- * コンフィギュレーションパラメータを取得}
- * {@.en Get Configuration object}
- * <p>
- * {@.ja コンポーネントのプロパティ取得}
- *
- * @param rtc
- * {@.ja コンフィギュレーション}
- * {@.en Configuration}
- *
- * @param confset_name
- * {@.ja コンフィギュレーションセット名}
- * {@.en ConfigurationSet name}
- *
- * @param value_name
- * {@.ja パラメータ名}
- * {@.en Paramter name}
- *
- * @return パラメータ
- * {@.ja パラメータ}
- * {@.en Property value}
- *
- */
- public static String get_parameter_by_key(RTObject rtc,
- String confset_name, String value_name){
- try {
- Configuration conf = rtc.get_configuration();
- ConfigurationSet confset = conf.get_configuration_set(confset_name);
- NVListHolder confData = new NVListHolder();
- confData.value = confset.configuration_data;
- Properties prop = new Properties();
- NVUtil.copyToProperties(prop, confData);
- return prop.getProperty(value_name);
- }
- catch (Exception ex) {
- return "";
- }
-
- }
-
- /**
- *
- * {@.ja 対象のRTCのアクティブなコンフィギュレーションセット名を取得する}
- * {@.en Get Configuration object}
- *
- * @param rtc
- * {@.ja RTコンポーネント}
- * {@.en RTComponent}
- *
- * @return
- * {@.ja コンフィギュレーションセット名
- * コンフィギュレーションの取得に失敗した場合は空の文字列を返す}
- * {@.en configuration name}
- *
- *
- *
- */
- public static String get_current_configuration_name(RTObject rtc){
- try {
- Configuration conf = rtc.get_configuration();
- ConfigurationSet confset = conf.get_active_configuration_set();
- return confset.id;
- }
- catch (Exception ex) {
- return "";
- }
- }
- /**
- *
- * {@.ja アクティブなコンフィギュレーションセットを取得}
- * {@.en Get Configuration object}
- *
- * @param rtc
- * {@.ja 対象のRTコンポーネント}
- * {@.en Target RTComponent}
- *
- * @return
- * {@.ja アクティブなコンフィギュレーションセット}
- * {@.en ConfigurationSet}
- *
- *
- *
- */
- public static Properties get_active_configuration(RTObject rtc){
- try {
- Configuration conf = rtc.get_configuration();
-
- ConfigurationSet confset = conf.get_active_configuration_set();
- NVListHolder confData = new NVListHolder();
- confData.value = confset.configuration_data;
- Properties prop = new Properties();
- NVUtil.copyToProperties(prop, confData);
- return prop;
- }
- catch (Exception ex) {
- return null;
- }
-
- }
- /**
- *
- * {@.ja コンフィギュレーションパラメータを設定}
- * {@.en Set Configuration }
- *
- * @param confset_name
- * {@.ja コンフィギュレーションセット名}
- * {@.en ConfigurationSet name}
- *
- * @param value_name
- * {@.ja パラメータ名}
- * {@.en trametername}
- *
- * @param value パラメータ
- * {@.ja パラメータ}
- * {@.en Paramter}
- *
- * @return
- * {@.ja true:設定に成功、false:設定に失敗}
- * {@.en true: succeeded, false: failed}
- *
- *
- */
- public static boolean set_configuration(RTObject rtc, String confset_name,
- String value_name, String value){
- try {
- Configuration conf = rtc.get_configuration();
-
- ConfigurationSet confset = conf.get_configuration_set(confset_name);
- NVListHolder confData = new NVListHolder();
- confData.value = confset.configuration_data;
- Properties prop = new Properties();
- NVUtil.copyToProperties(prop, confData);
- prop.setProperty(value_name,value);
- NVUtil.copyFromProperties(confData,prop);
- confset.configuration_data = confData.value;
- conf.set_configuration_set_values(confset);
-
- conf.activate_configuration_set(confset_name);
- return true;
- }
- catch (Exception ex) {
- return false;
- }
- }
-}
Deleted: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/util/RTShellUtilTest.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/util/RTShellUtilTest.java 2017-08-16 07:59:15 UTC (rev 1007)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/util/RTShellUtilTest.java 2017-08-16 08:27:56 UTC (rev 1008)
@@ -1,1038 +0,0 @@
-package jp.go.aist.rtm.RTC.util;
-
-import junit.framework.TestCase;
-
-import java.util.Vector;
-import java.util.logging.ConsoleHandler;
-import java.util.logging.FileHandler;
-
-
-import java.lang.Thread;
-
-
-import RTMExamples.SimpleIO.ConsoleIn;
-import RTMExamples.SimpleIO.ConsoleOut;
-import RTMExamples.SimpleService.MyServiceConsumer;
-import RTMExamples.ConfigSample.ConfigSample;
-
-import jp.go.aist.rtm.RTC.Manager;
-import jp.go.aist.rtm.RTC.ModuleInitProc;
-import jp.go.aist.rtm.RTC.RTObject_impl;
-import jp.go.aist.rtm.RTC.CorbaNaming;
-import jp.go.aist.rtm.RTC.RTObject_impl;
-import jp.go.aist.rtm.RTC.executionContext.ExecutionContextWorker;
-import jp.go.aist.rtm.RTC.port.CorbaConsumer;
-import jp.go.aist.rtm.RTC.util.CORBA_SeqUtil;
-import jp.go.aist.rtm.RTC.util.NVUtil;
-import jp.go.aist.rtm.RTC.util.ORBUtil;
-import jp.go.aist.rtm.RTC.util.StringUtil;
-import jp.go.aist.rtm.RTC.util.Properties;
-import jp.go.aist.rtm.RTC.util.RTShellUtil;
-
-import org.omg.CORBA.ORB;
-import org.omg.CosNaming.NamingContextPackage.CannotProceed;
-import org.omg.CosNaming.NamingContextPackage.InvalidName;
-import org.omg.CosNaming.NamingContextPackage.NotFound;
-
-import RTC.ConnectorProfile;
-import RTC.ConnectorProfileHolder;
-import RTC.ExecutionContext;
-import RTC.ExecutionContextListHolder;
-import RTC.ExecutionContextService;
-import RTC.ExecutionContextServiceHelper;
-import RTC.ExecutionContextProfile;
-import RTC.LifeCycleState;
-import RTC.PortService;
-import RTC.PortServiceListHolder;
-import RTC.RTObject;
-import RTC.RTObjectHolder;
-import RTC.RTObjectHelper;
-import RTC.ReturnCode_t;
-import OpenRTM.DataFlowComponent;
-import _SDOPackage.NVListHolder;
-import _SDOPackage.NameValue;
-
-public class RTShellUtilTest extends TestCase {
- private Manager m_manager;
- private ORB m_orb;
- private CorbaConsumer<DataFlowComponent> m_conout =
- new CorbaConsumer<DataFlowComponent>(DataFlowComponent.class);
- private CorbaConsumer<DataFlowComponent> m_conin =
- new CorbaConsumer<DataFlowComponent>(DataFlowComponent.class);
- private CorbaConsumer<DataFlowComponent> m_conin2 =
- new CorbaConsumer<DataFlowComponent>(DataFlowComponent.class);
- private CorbaConsumer<DataFlowComponent> m_sercon =
- new CorbaConsumer<DataFlowComponent>(DataFlowComponent.class);
- private CorbaConsumer<DataFlowComponent> m_config =
- new CorbaConsumer<DataFlowComponent>(DataFlowComponent.class);
-
- private RTObjectHolder m_conoutRef
- = new RTObjectHolder();
- private RTObjectHolder m_coninRef
- = new RTObjectHolder();
- private RTObjectHolder m_coninRef2
- = new RTObjectHolder();
- private RTObjectHolder m_serconRef
- = new RTObjectHolder();
- private RTObjectHolder m_configRef
- = new RTObjectHolder();
-
- //private RTObject m_conoutRef;
- private ExecutionContextListHolder m_eclisto
- = new ExecutionContextListHolder();
- private ExecutionContextListHolder m_eclisti
- = new ExecutionContextListHolder();
- private ExecutionContextListHolder m_eclistseq
- = new ExecutionContextListHolder();
-
- private RTObject_impl m_out_impl;
- private RTObject_impl m_in_impl;
- private RTObject_impl m_out_seq_impl;
- private RTObject_impl m_config_impl;
-
- public RTShellUtilTest(String name){
- super(name);
-
- m_eclisto = new ExecutionContextListHolder();
- m_eclisti = new ExecutionContextListHolder();
- m_eclistseq = new ExecutionContextListHolder();
-
- m_conoutRef = new RTObjectHolder();
- m_coninRef = new RTObjectHolder();
- m_coninRef2 = new RTObjectHolder();
- m_serconRef = new RTObjectHolder();
- m_configRef = new RTObjectHolder();
-
- String[] args = new String[0];
- //Manager manager = Manager.init(null);
- m_manager = Manager.init(null);
- //
- //
- //
- m_manager.activateManager();
- //
- //
- //
- Properties prop_out = new Properties(ConsoleOut.component_conf);
- m_manager.registerFactory(prop_out,
- new ConsoleOut(), new ConsoleOut());
- //RTObject_impl out_impl = m_manager.createComponent("ConsoleOut");
- m_out_impl = m_manager.createComponent("ConsoleOut");
- if(m_out_impl==null)
- {
- System.out.println("ConsoleOut is null.");
- }
- //
- Properties prop_in = new Properties(ConsoleIn.component_conf);
- m_manager.registerFactory(prop_in, new ConsoleIn(), new ConsoleIn());
- //RTObject_impl in_impl = m_manager.createComponent("ConsoleIn");
- m_in_impl = m_manager.createComponent("ConsoleIn");
- if(m_in_impl==null)
- {
- System.out.println("ConsoleIn is null.");
- }
- //
- Properties prop_out_seq
- = new Properties(MyServiceConsumer.component_conf);
- m_manager.registerFactory(prop_out_seq,
- new MyServiceConsumer(), new MyServiceConsumer());
- //RTObject_impl out_seq_impl
- m_out_seq_impl
- = m_manager.createComponent("MyServiceConsumer");
- if(m_out_seq_impl==null)
- {
- System.out.println("MyServiceConsumer is null.");
- }
- //
- Properties prop_config
- = new Properties(ConfigSample.component_conf);
- m_manager.registerFactory(prop_config,
- new ConfigSample(), new ConfigSample());
- //RTObject_impl
- m_config_impl
- = m_manager.createComponent("ConfigSample");
- if(m_config_impl==null)
- {
- System.out.println("ConfigSample is null.");
- }
- //
- //
- //
- m_manager.runManager(true);
- //
- //
- //
- //ExecutionContextListHolder eclisto = new ExecutionContextListHolder();
- m_eclisto.value = new ExecutionContext[0];
- m_eclisto.value = m_out_impl.get_owned_contexts();
- //System.out.println( "m_eclisto.value.length : "
- // + m_eclisto.value.length);
- //
- //ExecutionContextListHolder eclisti = new ExecutionContextListHolder();
- m_eclisti.value = new ExecutionContext[0];
- m_eclisti.value = m_in_impl.get_owned_contexts();
- //System.out.println( "m_eclisti.value.length : "+ m_eclisti.value.length);
- //
- //ExecutionContextListHolder eclistseq = new ExecutionContextListHolder();
- m_eclistseq.value = new ExecutionContext[0];
- m_eclistseq.value = m_out_seq_impl.get_owned_contexts();
- //System.out.println( "m_eclistseq.value.length : "+ m_eclistseq.value.length);
- //
- // bind
- //
- //System.out.println( "bind0 : "+ m_eclisto.value[0]);
- //System.out.println( "bind1 : "+ m_eclisti.value[0]);
- m_out_impl.bindContext(m_eclisti.value[0]);
- m_eclisto.value = m_out_impl.get_owned_contexts();
- //System.out.println( "m_eclisto.value.length : "
- // + m_eclisto.value.length);
-
- //System.out.println( "bind2 : "+ m_eclisto.value[0]);
- //System.out.println( "bind3 : "+ m_eclisto.value[1]);
- //
- //
- //
- //ORB orb = ORBUtil.getOrb();
- m_orb = ORBUtil.getOrb();
- CorbaNaming naming = null;
- try {
- naming = new CorbaNaming(m_orb, "localhost:2809");
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- //CorbaConsumer<DataFlowComponent> conout =
- // new CorbaConsumer<DataFlowComponent>(DataFlowComponent.class);
- // find ConsoleOut0 component
- try {
- m_conout.setObject(naming.resolve(".host_cxt/ConsoleOut0.rtc"));
- } catch (NotFound e) {
- e.printStackTrace();
- } catch (CannotProceed e) {
- e.printStackTrace();
- } catch (InvalidName e) {
- e.printStackTrace();
- }
-
- //
- ExecutionContextListHolder eclist = new ExecutionContextListHolder();
- eclist.value = new ExecutionContext[0];
- m_conoutRef.value = m_conout._ptr();
- eclist.value = m_conoutRef.value.get_owned_contexts();
- //System.out.println( "eclist.value.length : "+ eclist.value.length);
-
-
- try {
- m_conin.setObject(naming.resolve(".host_cxt/ConsoleIn0.rtc"));
- } catch (NotFound e) {
- e.printStackTrace();
- } catch (CannotProceed e) {
- e.printStackTrace();
- } catch (InvalidName e) {
- e.printStackTrace();
- }
- //
- //
- m_coninRef.value = m_conin._ptr();
- try {
- m_conin2.setObject(naming.resolve(".host_cxt/ConsoleIn1.rtc"));
- } catch (NotFound e) {
- e.printStackTrace();
- } catch (CannotProceed e) {
- e.printStackTrace();
- } catch (InvalidName e) {
- e.printStackTrace();
- }
- //
- //
- m_coninRef2.value = m_conin2._ptr();
-
-
- try {
- m_sercon.setObject(naming.resolve(".host_cxt/MyServiceConsumer0.rtc"));
- } catch (NotFound e) {
- e.printStackTrace();
- } catch (CannotProceed e) {
- e.printStackTrace();
- } catch (InvalidName e) {
- e.printStackTrace();
- }
-
- //
- m_serconRef.value = m_sercon._ptr();
- //
- //
- try {
- m_config.setObject(naming.resolve(".host_cxt/ConfigSample0.rtc"));
- } catch (NotFound e) {
- e.printStackTrace();
- } catch (CannotProceed e) {
- e.printStackTrace();
- } catch (InvalidName e) {
- e.printStackTrace();
- }
-
- //
- m_configRef.value = m_config._ptr();
- }
-
-
- protected void setUp() throws Exception {
- super.setUp();
- try{
- Thread.sleep(500);
- }
- catch(InterruptedException e){
- }
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
-/*
- for(int ic=0;ic<m_eclisto.value.length;++ic){
- m_eclisto.value[ic].stop();
- }
- for(int ic=0;ic<m_eclisti.value.length;++ic){
- m_eclisti.value[ic].stop();
- }
- for(int ic=0;ic<m_eclistseq.value.length;++ic){
- m_eclistseq.value[ic].stop();
- }
-*/
-/*
- if(m_manager!=null){
- m_manager.shutdown();
- m_manager = null;
- }
-*/
- Thread.sleep(300);
- }
-
- /**
- *
- *
- */
- public void test_get_actual_ec() {
- System.out.println( "test_get_actual_ec()" );
- ExecutionContext[] list = m_conoutRef.value.get_owned_contexts();
- ExecutionContext ec = RTShellUtil.get_actual_ec(m_conoutRef.value,0);
- {
- //System.out.println( "m_conoutRef.value.get_owned_contexts()[0]: "
- // +list[0]);
- }
- //System.out.println( "ec : " +ec);
- //System.out.println( "m_eclisto.value[0] : " +m_eclisto.value[0]);
- //assertTrue("test:id is 0",ec._is_equivalent(m_eclisto.value[0]));
- assertTrue("test:id is 0",ec._is_equivalent(list[0]));
-
- ec = RTShellUtil.get_actual_ec(m_conoutRef.value,1);
- //assertTrue("test:id is 1",ec._is_equivalent(m_eclisto.value[1]));
- assertTrue("test:id is 1",ec._is_equivalent(list[1]));
-
- ec = RTShellUtil.get_actual_ec(m_conoutRef.value,2);
- assertTrue("test:id is out of range",ec == null);
-
- ec = RTShellUtil.get_actual_ec(null,0);
- assertTrue("test:rtc is null",ec == null);
- }
- /**
- *
- *
- */
- public void test_get_ec_id(){
- System.out.println( "test_get_ec_id()" );
- ExecutionContext[] list = m_conoutRef.value.get_owned_contexts();
-/*
- System.out.println( "115 : " +list.length);
- System.out.println( "116 : " +m_eclisto.value.length);
- System.out.println( "117-0 : " +list[0]);
- System.out.println( "117-1 : " +list[1]);
- System.out.println( "118-0 : " +m_eclisto.value[0]);
- System.out.println( "118-1 : " +m_eclisto.value[1]);
- if(list[0]._is_equivalent(list[0])){
- System.out.println( "119 : " );
- }
- if(list[0]._is_equivalent(m_eclisto.value[0])){
- System.out.println( "120 : " );
- }
- if(list[0] == m_eclisto.value[0]){
- System.out.println( "130 : " );
- }
- if(list[1]._is_equivalent(m_eclisto.value[0])){
- System.out.println( "121 : " );
- }
- if(list[0]._is_equivalent(m_eclisto.value[1])){
- System.out.println( "122 : " );
- }
- if(list[1]._is_equivalent(m_eclisto.value[1])){
- System.out.println( "123 : " );
- }
- System.out.println( "140 : " );
-*/
- //int id = RTShellUtil.get_ec_id(m_conoutRef.value, m_eclisto.value[0]);
- int id = RTShellUtil.get_ec_id(m_conoutRef.value, list[0]);
- //System.out.println( "id : " + id );
- assertTrue("test:id is 0.",id == 0);
-
- //id = RTShellUtil.get_ec_id(m_conoutRef.value, m_eclisto.value[1]);
- id = RTShellUtil.get_ec_id(m_conoutRef.value, list[1]);
- //System.out.println( "id : " + id );
- assertTrue("test:id is 1",id == 1);
-
- id = RTShellUtil.get_ec_id(m_conoutRef.value, null);
- //System.out.println( "id : " + id );
- assertTrue("test:list is null",id == -1);
-
- //id = RTShellUtil.get_ec_id(null, m_eclisto.value[1]);
- id = RTShellUtil.get_ec_id(null, list[0]);
- //System.out.println( "id : " + id );
- assertTrue("test:rtc is null",id == -1);
-
- id = RTShellUtil.get_ec_id(m_conoutRef.value, m_eclistseq.value[0]);
- //System.out.println( "id : " + id );
- assertTrue("test:not foud",id == -1);
- }
- /**
- *
- *
- */
- public void test_activate_deactivate(){
- System.out.println( "test_activate_deactivate()" );
- ReturnCode_t ret = RTShellUtil.activate(null, 0);
- assertTrue(ret == ReturnCode_t.BAD_PARAMETER);
-
- ret = RTShellUtil.activate(m_conoutRef.value, 3);
- assertTrue(ret == ReturnCode_t.BAD_PARAMETER);
-
- ret = RTShellUtil.deactivate(null, 0);
- assertTrue(ret == ReturnCode_t.BAD_PARAMETER);
-
- ret = RTShellUtil.deactivate(m_conoutRef.value, 3);
- assertTrue(ret == ReturnCode_t.BAD_PARAMETER);
-
- try{
- Thread.sleep(500);
- }
- catch(InterruptedException e){
- }
-
- ret = RTShellUtil.activate(m_conoutRef.value, 0);
- assertTrue(ret == ReturnCode_t.RTC_OK);
-
- try{
- Thread.sleep(500);
- }
- catch(InterruptedException e){
- }
-
- ret = RTShellUtil.deactivate(m_conoutRef.value, 0);
- assertTrue(ret == ReturnCode_t.RTC_OK);
-/*
- ret = RTShellUtil.activate(m_conoutRef.value, 1);
- assertTrue(ret == ReturnCode_t.RTC_OK);
-
- ret = RTShellUtil.deactivate(m_conoutRef.value, 1);
- assertTrue(ret == ReturnCode_t.RTC_OK);
-*/
- }
- /**
- *
- * get_state
- *
- */
- public static String getStateString(LifeCycleState state) {
- final String st[] = {
- "CREATED_STATE",
- "INACTIVE_STATE",
- "ACTIVE_STATE",
- "ERROR_STATE"
- };
- return st[state.value()];
- }
- public void test_get_state(){
- LifeCycleState ret = RTShellUtil.get_state(m_conoutRef.value, 0);
- String str_ret = getStateString(ret);
- System.out.println(str_ret);
- assertTrue("test:inactive_state",str_ret.equals("INACTIVE_STATE"));
- //
- RTShellUtil.activate(m_conoutRef.value, 0);
- try{
- Thread.sleep(500);
- }
- catch(InterruptedException e){
- }
- ret = RTShellUtil.get_state(m_conoutRef.value, 0);
- str_ret = getStateString(ret);
- System.out.println(str_ret);
- assertTrue("test:active_state",str_ret.equals("ACTIVE_STATE"));
- //
- RTShellUtil.deactivate(m_conoutRef.value, 0);
- try{
- Thread.sleep(500);
- }
- catch(InterruptedException e){
- }
- ret = RTShellUtil.get_state(m_conoutRef.value, 0);
- str_ret = getStateString(ret);
- System.out.println(str_ret);
- assertTrue("test:inactive_state",str_ret.equals("INACTIVE_STATE"));
- //
- ret = RTShellUtil.get_state(null, 0);
- str_ret = getStateString(ret);
- System.out.println(str_ret);
- assertTrue("test:error_state",str_ret.equals("ERROR_STATE"));
- //
- ret = RTShellUtil.get_state(m_conoutRef.value, 3);
- str_ret = getStateString(ret);
- System.out.println(str_ret);
- assertTrue("test:error_state",str_ret.equals("ERROR_STATE"));
- }
- /**
- *
- * is_in_active
- *
- */
- public void test_is_in_active(){
- boolean ret;
- ret = RTShellUtil.is_in_active(m_conoutRef.value, 0);
- assertTrue("test:is",!ret);
- //
- RTShellUtil.activate(m_conoutRef.value, 0);
- try{
- Thread.sleep(500);
- }
- catch(InterruptedException e){
- }
- ret = RTShellUtil.is_in_active(m_conoutRef.value, 0);
- assertTrue("test:is",ret);
- //
- RTShellUtil.deactivate(m_conoutRef.value, 0);
- try{
- Thread.sleep(500);
- }
- catch(InterruptedException e){
- }
- ret = RTShellUtil.is_in_active(m_conoutRef.value, 0);
- assertTrue("test:is",!ret);
- //
- ret = RTShellUtil.is_in_active(null, 0);
- assertTrue("test:is",!ret);
- ret = RTShellUtil.is_in_active(m_conoutRef.value, 3);
- assertTrue("test:is",!ret);
- }
-
- /**
- *
- * get_default_rate/set_default_rate
- *
- */
- public void test_get_default_rate_set_default_rate(){
-
- double ret = RTShellUtil.get_default_rate(m_conoutRef.value);
- assertTrue("test:get_default_rate 1000.0 get value="+ret,ret == 1000.0);
- RTShellUtil.set_default_rate(m_conoutRef.value, 500.0);
- ret = RTShellUtil.get_default_rate(m_conoutRef.value);
- assertTrue("test:get_default_rate 500.0",ret == 500.0);
- //
- //
- //
- ret = RTShellUtil.get_default_rate(null);
- ReturnCode_t code = RTShellUtil.set_default_rate(null, 500.0);
- assertTrue("test:set_default_rate",code == ReturnCode_t.BAD_PARAMETER);
- //
- }
- /**
- *
- * get_current_rate/set_current_rate
- *
- */
- public void test_get_current_rate_set_current_rate(){
- RTShellUtil.set_default_rate(m_conoutRef.value, 1000.0);
- double ret = RTShellUtil.get_current_rate(m_conoutRef.value,0);
- assertTrue("test:get_rate 1000.0 get value="+ret,ret == 1000.0);
- ret = RTShellUtil.get_current_rate(m_conoutRef.value,1);
- assertTrue("test:get_rate 1000.0",ret == 1000.0);
- //
- RTShellUtil.set_current_rate(m_conoutRef.value,0,500.0);
- ret = RTShellUtil.get_current_rate(m_conoutRef.value,0);
- assertTrue("test:get_rate 500.0",ret == 500.0);
- RTShellUtil.set_current_rate(m_conoutRef.value,1,500.0);
- ret = RTShellUtil.get_current_rate(m_conoutRef.value,1);
- assertTrue("test:get_rate 500.0",ret == 500.0);
- //
- //
- //
- ret = RTShellUtil.get_current_rate(null,0);
- assertTrue("test:",ret == -1.0);
- ret = RTShellUtil.get_current_rate(null,1);
- assertTrue("test:",ret == -1.0);
- ReturnCode_t code;
- code = RTShellUtil.set_current_rate(null, 0, 500.0);
- assertTrue("test:set_rate",code == ReturnCode_t.BAD_PARAMETER);
- code = RTShellUtil.set_current_rate(null, 1, 500.0);
- assertTrue("test:set_rate",code == ReturnCode_t.BAD_PARAMETER);
- //
- ret = RTShellUtil.get_current_rate(m_conoutRef.value,2);
- code = RTShellUtil.set_current_rate(m_conoutRef.value, 2, 500.0);
- assertTrue("test:set_rate",code == ReturnCode_t.BAD_PARAMETER);
-
- RTShellUtil.set_current_rate(m_conoutRef.value,0,1000.0);
- RTShellUtil.set_current_rate(m_conoutRef.value,1,1000.0);
- }
- /**
- *
- * add_rtc_to_default_ec
- * remove_rtc_to_default_ec
- * get_participants_rtc
- *
- */
- public void test_rtc_to_default_ec(){
- ReturnCode_t code;
- code = RTShellUtil.add_rtc_to_default_ec(m_conoutRef.value,
- m_serconRef.value);
- assertTrue("test:add_rtc",code == ReturnCode_t.RTC_OK);
-
- RTObject[] objs;
- objs = RTShellUtil.get_participants_rtc(m_conoutRef.value);
- //System.out.println( "length : "+ objs.length);
- assertTrue("test:get_rtc",objs.length == 1);
-
- code = RTShellUtil.remove_rtc_to_default_ec(m_conoutRef.value,
- m_serconRef.value);
- assertTrue("test:remove_rtc : "+code.value() ,code == ReturnCode_t.RTC_OK);
-
- objs = RTShellUtil.get_participants_rtc(m_conoutRef.value);
- //System.out.println( "length : "+ objs.length);
- assertTrue("test:get_rtc",objs.length == 0);
-
- //
- //
- //
- code = RTShellUtil.add_rtc_to_default_ec(null, m_serconRef.value);
- assertTrue("test:add_rtc",code == ReturnCode_t.RTC_ERROR);
- code = RTShellUtil.add_rtc_to_default_ec(m_conoutRef.value, null);
- assertTrue("test:add_rtc",code == ReturnCode_t.RTC_ERROR);
- code = RTShellUtil.add_rtc_to_default_ec(null, null);
- assertTrue("test:add_rtc",code == ReturnCode_t.RTC_ERROR);
- //
- code = RTShellUtil.remove_rtc_to_default_ec(null, m_serconRef.value);
- assertTrue("test:remove_rtc",code == ReturnCode_t.RTC_ERROR);
- code = RTShellUtil.remove_rtc_to_default_ec(m_conoutRef.value,null);
- assertTrue("test:remove_rtc",code == ReturnCode_t.RTC_ERROR);
- code = RTShellUtil.remove_rtc_to_default_ec(null,null);
- assertTrue("test:remove_rtc",code == ReturnCode_t.RTC_ERROR);
- objs = RTShellUtil.get_participants_rtc(null);
- assertTrue("test:",objs == null);
-
- }
- /**
- *
- * get_port_names
- * get_inport_names
- * get_outport_names
- * get_svcport_names
- *
- */
- public void test_get_port_names(){
- Vector<String> names;
- //
- //
- //
- names = RTShellUtil.get_port_names(m_conoutRef.value);
- System.out.println( "names : "+ names.toString());
- assertTrue("test:",names.size() == 1);
-
- names = RTShellUtil.get_port_names(m_coninRef.value);
- System.out.println( "names : "+ names.toString());
- assertTrue("test:",names.size() == 1);
-
- names = RTShellUtil.get_port_names(m_serconRef.value);
- System.out.println( "names : "+ names.toString());
- assertTrue("test:",names.size() == 1);
-
- //
- //
- //
- names = RTShellUtil.get_inport_names(m_conoutRef.value);
- System.out.println( "names : "+ names.toString());
- assertTrue("test:",names.size() == 1);
-
- names = RTShellUtil.get_inport_names(m_coninRef.value);
- System.out.println( "names : "+ names.toString());
- assertTrue("test:",names.size() == 0);
-
- names = RTShellUtil.get_inport_names(m_serconRef.value);
- System.out.println( "names : "+ names.toString());
- assertTrue("test:",names.size() == 0);
-
- //
- //
- //
- names = RTShellUtil.get_outport_names(m_conoutRef.value);
- System.out.println( "names : "+ names.toString());
- assertTrue("test:",names.size() == 0);
-
- names = RTShellUtil.get_outport_names(m_coninRef.value);
- System.out.println( "names : "+ names.toString());
- assertTrue("test:",names.size() == 1);
-
- names = RTShellUtil.get_outport_names(m_serconRef.value);
- System.out.println( "names : "+ names.toString());
- assertTrue("test:",names.size() == 0);
-
- //
- //
- //
- names = RTShellUtil.get_svcport_names(m_conoutRef.value);
- System.out.println( "names : "+ names.toString());
- assertTrue("test:",names.size() == 0);
-
- names = RTShellUtil.get_svcport_names(m_coninRef.value);
- System.out.println( "names : "+ names.toString());
- assertTrue("test:",names.size() == 0);
-
- names = RTShellUtil.get_svcport_names(m_serconRef.value);
- System.out.println( "names : "+ names.toString());
- assertTrue("test:",names.size() == 1);
-
-
- names = RTShellUtil.get_port_names(null);
- assertTrue("test:",names == null);
- names = RTShellUtil.get_inport_names(null);
- assertTrue("test:",names == null);
- names = RTShellUtil.get_outport_names(null);
- assertTrue("test:",names == null);
- names = RTShellUtil.get_svcport_names(null);
- assertTrue("test:",names == null);
- }
- /**
- *
- * get_port_by_name
- *
- */
- public void test_get_port_by_name(){
- PortService ps;
- ps = RTShellUtil.get_port_by_name(m_conoutRef.value,
- "ConsoleOut0.in");
- System.out.println( "name : "+ ps.get_port_profile().name);
- assertTrue("test:",ps.get_port_profile().name.equals("ConsoleOut0.in"));
-
- ps = RTShellUtil.get_port_by_name(null,
- "ConsoleOut0.in");
- assertTrue("test:",ps == null);
-
- ps = RTShellUtil.get_port_by_name(m_conoutRef.value, "");
- assertTrue("test:",ps == null);
- }
- /**
- *
- * connect
- *
- */
- public void test_connect(){
-
- PortService port1 = RTShellUtil.get_port_by_name(m_conoutRef.value,
- "ConsoleOut0.in");
- PortService port2 = RTShellUtil.get_port_by_name(m_coninRef.value,
- "ConsoleIn0.out");
- Properties prop = new Properties();
- String[] conprop = {
- "dataport.interface_type","corba_cdr",
- "dataport.dataflow_type", "push",
- ""
- };
-
- prop.setDefaults(conprop);
- ReturnCode_t code;
- code = RTShellUtil.connect("kamo0",prop,port1,port2);
- assertTrue("test:connect",code == ReturnCode_t.RTC_OK);
-/*
- try{
- Thread.sleep(10000);
- }
- catch(InterruptedException e){
- }
-*/
- //
- //
- //
- code = RTShellUtil.connect("",prop,port1,port2);
- assertTrue("test:disconnect",code == ReturnCode_t.RTC_OK);
- code = RTShellUtil.connect("kamo1",null,port1,port2);
- assertTrue("test:disconnect",code == ReturnCode_t.RTC_OK);
- code = RTShellUtil.connect("kamo2",prop,null,port2);
- assertTrue("test:",code == ReturnCode_t.BAD_PARAMETER);
- code = RTShellUtil.connect("kamo3",prop,port1,null);
- assertTrue("test:",code == ReturnCode_t.BAD_PARAMETER);
-
- code = RTShellUtil.disconnect_by_connector_name(port1, "kamo0");
- assertTrue("test:disconnect",code == ReturnCode_t.RTC_OK);
-/*
- try{
- Thread.sleep(10000);
- }
- catch(InterruptedException e){
- }
-*/
- code = RTShellUtil.disconnect_by_connector_name(null, "kamo0");
- assertTrue("test:",code == ReturnCode_t.BAD_PARAMETER);
- code = RTShellUtil.disconnect_by_connector_name(port1, "kamo5");
- assertTrue("test:"+code.value(),code == ReturnCode_t.BAD_PARAMETER);
-
- }
- /**
- *
- * connect
- *
- */
- public void test_connect_by_name(){
-
- PortService port1 = RTShellUtil.get_port_by_name(m_conoutRef.value,
- "ConsoleOut0.in");
- PortService port2 = RTShellUtil.get_port_by_name(m_coninRef.value,
- "ConsoleIn0.out");
- Properties prop = new Properties();
- String[] conprop = {
- "dataport.interface_type","corba_cdr",
- "dataport.dataflow_type", "push",
- ""
- };
-
- prop.setDefaults(conprop);
- ReturnCode_t code;
- code = RTShellUtil.connect_by_name("kamo0",prop,
- m_conoutRef.value,"ConsoleOut0.in",
- m_coninRef.value,"ConsoleIn0.out");
- assertTrue("test:connect",code == ReturnCode_t.RTC_OK);
-/*
- try{
- Thread.sleep(10000);
- }
- catch(InterruptedException e){
- }
-*/
- //
- //
- //
- code = RTShellUtil.connect_by_name("",prop,
- m_conoutRef.value,"ConsoleOut0.in",
- m_coninRef.value,"ConsoleIn0.out");
- assertTrue("test:disconnect",code == ReturnCode_t.RTC_OK);
- code = RTShellUtil.connect_by_name("kamo1",null,
- m_conoutRef.value,"ConsoleOut0.in",
- m_coninRef.value,"ConsoleIn0.out");
- assertTrue("test:disconnect",code == ReturnCode_t.RTC_OK);
- code = RTShellUtil.connect_by_name("kamo2",prop,
- null,"ConsoleOut0.in",
- m_coninRef.value,"ConsoleIn0.out");
- assertTrue("test:",code == ReturnCode_t.BAD_PARAMETER);
- code = RTShellUtil.connect_by_name("kamo3",prop,
- m_conoutRef.value,"ConsoleOut0.in",
- m_coninRef.value,"");
- assertTrue("test:",code == ReturnCode_t.BAD_PARAMETER);
-
-
- ConnectorProfile[] cprofs = port1.get_connector_profiles();
- for(int ic=0;ic<cprofs.length;++ic){
- if(cprofs[ic].name.equals("kamo0")){
- code = RTShellUtil.disconnect(cprofs[ic]);
- break;
- }
- }
-
- assertTrue("test:disconnect "+code.value(),code == ReturnCode_t.RTC_OK);
-/*
- try{
- Thread.sleep(10000);
- }
- catch(InterruptedException e){
- }
-*/
- code = RTShellUtil.disconnect(null);
- assertTrue("test:",code == ReturnCode_t.BAD_PARAMETER);
- }
- /**
- *
- * disconnect
- *
- */
- public void test_disconnect_by_id(){
-
- PortService port1 = RTShellUtil.get_port_by_name(m_conoutRef.value,
- "ConsoleOut0.in");
- PortService port2 = RTShellUtil.get_port_by_name(m_coninRef.value,
- "ConsoleIn0.out");
- Properties prop = new Properties();
- String[] conprop = {
- "dataport.interface_type","corba_cdr",
- "dataport.dataflow_type", "push",
- ""
- };
-
- prop.setDefaults(conprop);
- ReturnCode_t code;
- code = RTShellUtil.connect("kamo0",prop,port1,port2);
- assertTrue("test:connect",code == ReturnCode_t.RTC_OK);
- //
- //
- //
- String id = new String();
- ConnectorProfile[] cprofs = port1.get_connector_profiles();
- for(int ic=0;ic<cprofs.length;++ic){
- if(cprofs[ic].name.equals("kamo0")){
- id = cprofs[ic].connector_id;
- break;
- }
- }
- code = RTShellUtil.disconnect_by_connector_id(port1,id);
- assertTrue("test:disconnect",code == ReturnCode_t.RTC_OK);
-
-
-
- code = RTShellUtil.disconnect_by_connector_id(null,id);
- assertTrue("test:",code == ReturnCode_t.BAD_PARAMETER);
- code = RTShellUtil.disconnect_by_connector_id(port1,"");
- assertTrue("test:"+code.value(),code == ReturnCode_t.BAD_PARAMETER);
-
- }
- /**
- *
- * disconnect
- *
- */
- public void test_disconnect_by_port_name(){
- PortService port1 = RTShellUtil.get_port_by_name(m_conoutRef.value,
- "ConsoleOut0.in");
- PortService port2 = RTShellUtil.get_port_by_name(m_coninRef.value,
- "ConsoleIn0.out");
- Properties prop = new Properties();
- String[] conprop = {
- "dataport.interface_type","corba_cdr",
- "dataport.dataflow_type", "push",
- ""
- };
-
- prop.setDefaults(conprop);
- ReturnCode_t code;
- code = RTShellUtil.connect("kamo0",prop,port1,port2);
- assertTrue("test:connect",code == ReturnCode_t.RTC_OK);
-
-
-
-
- code = RTShellUtil.disconnect_by_port_name(port1,"ConsoleIn0.out");
- assertTrue("test:disconnect",code == ReturnCode_t.RTC_OK);
-
- code = RTShellUtil.disconnect_by_port_name(port1,"");
- assertTrue("test:",code == ReturnCode_t.BAD_PARAMETER);
- code = RTShellUtil.disconnect_by_port_name(null,"ConsoleIn0.out");
- assertTrue("test:",code == ReturnCode_t.BAD_PARAMETER);
-
- }
- /**
- *
- * get_parameter_by_key
- * get_current_configuration_name
- * get_active_configuration
- * set_configuration
- */
- public void test_get_parameter_by_key(){
- String str;
- str = RTShellUtil.get_parameter_by_key(m_configRef.value,
- "default","double_param0");
- assertTrue("test:",str.equals("0.11"));
-
- str = RTShellUtil.get_parameter_by_key(m_configRef.value,
- "","double_param0");
- assertTrue("test:",str.equals(""));
- str = RTShellUtil.get_parameter_by_key(m_configRef.value,
- "default","");
- assertTrue("test:",str.equals(""));
-
-
-
- str = RTShellUtil.get_current_configuration_name(m_configRef.value);
- assertTrue("test:",str.equals("default"));
- str = RTShellUtil.get_current_configuration_name(null);
- assertTrue("test:",str.equals(""));
-
-
-
- Properties prop
- = RTShellUtil.get_active_configuration(m_configRef.value);
- str = prop.getProperty("double_param0");
- assertTrue("test:",str.equals("0.11"));
- prop = RTShellUtil.get_active_configuration(null);
- assertTrue("test:",prop==null);
-
- boolean bool = RTShellUtil.set_configuration(m_configRef.value,
- "default", "double_param0","305.8560");
- assertTrue("test:",bool);
- str = RTShellUtil.get_parameter_by_key(m_configRef.value,
- "default","double_param0");
- assertTrue("test:",str.equals("305.8560"));
- //
- bool = RTShellUtil.set_configuration(null,
- "default", "double_param0","305.8560");
- assertTrue("test:",!bool);
- bool = RTShellUtil.set_configuration(m_configRef.value,
- "", "double_param0","305.8560");
- assertTrue("test:",!bool);
- bool = RTShellUtil.set_configuration(m_configRef.value,
- "default", "double_param2","123.456");
- assertTrue("test:",bool);
- str = RTShellUtil.get_parameter_by_key(m_configRef.value,
- "default","double_param2");
- assertTrue("test:",str.equals("123.456"));
-
-
- }
- /**
- *
- * connect
- *
- */
- public void test_connect_multi(){
-
- PortService port1 = RTShellUtil.get_port_by_name(m_conoutRef.value,
- "ConsoleOut0.in");
- PortService port2 = RTShellUtil.get_port_by_name(m_coninRef.value,
- "ConsoleIn0.out");
- PortService port3 = RTShellUtil.get_port_by_name(m_coninRef2.value,
- "ConsoleIn1.out");
- Properties prop = new Properties();
- String[] conprop = {
- "dataport.interface_type","corba_cdr",
- "dataport.dataflow_type", "push",
- ""
- };
- PortServiceListHolder target_ports = new PortServiceListHolder();
- target_ports.value = new PortService[2];
- target_ports.value[0] = port2;
- target_ports.value[1] = port3;
- prop.setDefaults(conprop);
- ReturnCode_t code;
- code = RTShellUtil.connect_multi("kamo10", prop,
- port1, target_ports);
- assertTrue("test:",code == ReturnCode_t.RTC_OK);
-/*
- try{
- Thread.sleep(30000);
- }
- catch(InterruptedException e){
- }
-*/
- code = RTShellUtil.connect_multi("kamo11", prop,
- null, target_ports);
- assertTrue("test:",code == ReturnCode_t.BAD_PARAMETER);
- code = RTShellUtil.connect_multi("kamo11", prop,
- port1, null);
- assertTrue("test:",code == ReturnCode_t.BAD_PARAMETER);
- PortServiceListHolder error_ports = new PortServiceListHolder();
- code = RTShellUtil.connect_multi("kamo11", prop,
- port1, error_ports );
- assertTrue("test:",code == ReturnCode_t.BAD_PARAMETER);
- }
-}
-
-
More information about the openrtm-commit
mailing list