[openrtm-commit:01794] r786 - in trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC: . util
openrtm @ openrtm.org
openrtm @ openrtm.org
2016年 3月 2日 (水) 13:10:20 JST
Author: win-ei
Date: 2016-03-02 13:10:20 +0900 (Wed, 02 Mar 2016)
New Revision: 786
Modified:
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/Manager.java
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/NamingBase.java
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/NamingManager.java
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/NamingOnCorba.java
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/util/CORBA_RTCUtil.java
Log:
implemented methods of CORBA_RTCUtil class. refs #3385
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/Manager.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/Manager.java 2016-03-01 11:08:01 UTC (rev 785)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/Manager.java 2016-03-02 04:10:20 UTC (rev 786)
@@ -44,6 +44,7 @@
import RTC.ReturnCode_t;
import RTC.ConnectorProfile;
import RTC.ConnectorProfileHolder;
+import RTC.PortProfile;
import RTC.PortService;
import RTC.PortServiceHolder;
import RTC.PortServiceListHolder;
@@ -349,8 +350,190 @@
public Properties getConfig() {
return m_config;
}
+
+
+
+ /**
+ *
+ * {@.ja 指定したRTコンポーネントの保持するポートを
+ * NamingServiceにバインドする}
+ * {@.en Bind ports in NamingService. }
+ * <p>
+ * {@.ja ポートのpublish_topicというプロパティでトピック名を設定し、
+ * トピック名のコンテキストの下に登録}
+ *
+ * @param comp
+ * {@.ja RTコンポーネント}
+ * {@.en RT Component}
+ * void publishPorts(RTObject_impl* comp)
+ */
+ public void publishPorts(RTObject_impl comp){
+/*
+ //PortServiceListHolder ports = new PortServiceListHolder();
+ PortService[] ports = comp.get_ports();
+ for(int ic=0;ic<ports.length;++ic){
+ PortProfile prof = ports[ic].get_port_profile();
+ NVListHolder nvholder =
+ new NVListHolder(prof.properties);
+ Properties prop = new Properties();
+ NVUtil.copyToProperties(prop, nvholder);
+
+ if(
+ ( prop.hasKey("publish_topic")==null ||
+ prop.getProperty("publish_topic")!=null )
+ &&
+ ( prop.hasKey("subscribe_topic")==null ||
+ prop.getProperty("subscribe_topic")!=null )
+ &&
+ ( prop.hasKey("rendezvous_point")==null ||
+ prop.getProperty("rendezvous_point")!=null )
+ ){
+
+
+ continue;
+ }
+ String name = new String();
+ if(prop.getProperty("port.port_type").equals("DataOutPort"){
+ name = "dataports.port_cxt/"
+ name += prop.getProperty("publish_topic") + ".topic_cxt/"
+ name += prof.name
+ name += ".outport"
+ }
+ else if(prop.getProperty("port.port_type").equals("DataInPort"){
+ name = "dataports.port_cxt/"
+ name += str(prop.getProperty("publish_topic")) + ".topic_cxt/"
+ name += prof.name
+ name += ".inport"
+ }
+ else if(prop.getProperty("port.port_type").equals("CorbaPort"){
+ name = "svcports.port_cxt/"
+ name += str(prop.getProperty("publish_topic")) + ".topic_cxt/"
+ name += prof.name
+ name += ".svc"
+ }
+ else{
+
+ rtcout.println(Logbuf.WARN,
+ "Unknown port type: "+prop.getProperty("port.port_type"));
+ continue
+ }
+ POA poa = Manager.instance().getPOA();
+ PortBase port = (PortBase)(poa.reference_to_servant(ports[ic]));
+
+// m_namingManager.bindPortObject(name, comp);
+ }
+*/
+/*
+ for p in ports{
+ prof = p.get_port_profile()
+ prop = OpenRTM_aist.Properties()
+ OpenRTM_aist.NVUtil.copyToProperties(prop, prof.properties)
+
+ if (prop.hasKey("publish_topic") is None or not str(prop.getProperty("publish_topic"))) and (prop.hasKey("subscribe_topic") is None or not str(prop.getProperty("subscribe_topic"))) and (prop.hasKey("rendezvous_point") is None or not str(prop.getProperty("rendezvous_point"))){
+ continue
+ }
+
+
+ if prop.getProperty("port.port_type") == "DataOutPort"{
+ name = "dataports.port_cxt/"
+ name += str(prop.getProperty("publish_topic")) + ".topic_cxt/"
+ name += prof.name
+ name += ".outport"
+ }
+ elif prop.getProperty("port.port_type") == "DataInPort"{
+ name = "dataports.port_cxt/"
+ name += str(prop.getProperty("publish_topic")) + ".topic_cxt/"
+ name += prof.name
+ name += ".inport"
+ }
+ elif prop.getProperty("port.port_type") == "CorbaPort"{
+ name = "svcports.port_cxt/"
+ name += str(prop.getProperty("publish_topic")) + ".topic_cxt/"
+ name += prof.name
+ name += ".svc"
+ }
+ else{
+
+ self._rtcout.RTC_WARN("Unknown port type: %s" % str(prop.getProperty("port.port_type")))
+ continue
+ }
+
+ port = self._poa.reference_to_servant(p)
+
+ self._namingManager.bindPortObject(name, port)
+ }
+*/
+ }
+ /**
+ *
+ * {@.ja 指定したRTコンポーネントの保持するポートを
+ * 同じトピック名以下の接続可能なポートと接続}
+ * {@.en connects a port by a topic name.}
+ *
+ *
+ * @param comp
+ * {@.ja RTコンポーネント}
+ * {@.en RT Component}
+ *
+ * # void subscribePorts(RTObject_impl* comp)
+ */
+ public void subscribePorts(RTObject_impl comp){
+/*
+ ports = comp.get_ports();
+ foro(int ic=0; ic<ports.length; ++ic ){
+
+ prof = p.get_port_profile()
+ prop = OpenRTM_aist.Properties()
+ OpenRTM_aist.NVUtil.copyToProperties(prop, prof.properties)
+
+ if (prop.hasKey("publish_topic") is None or not str(prop.getProperty("publish_topic"))) and (prop.hasKey("subscribe_topic") is None or not str(prop.getProperty("subscribe_topic"))) and (prop.hasKey("rendezvous_point") is None or not str(prop.getProperty("rendezvous_point"))){
+ continue
+ }
+
+
+
+ if prop.getProperty("port.port_type") == "DataOutPort"{
+ name = "dataports.port_cxt/"
+ name += str(prop.getProperty("publish_topic")) + ".topic_cxt"
+
+ nsports = self.getPortsOnNameServers(name, "inport")
+
+ self.connectDataPorts(p, nsports)
+ }
+ elif prop.getProperty("port.port_type") == "DataInPort"{
+ name = "dataports.port_cxt/"
+ name += str(prop.getProperty("publish_topic")) + ".topic_cxt"
+ nsports = self.getPortsOnNameServers(name, "outport")
+ self.connectDataPorts(p, nsports)
+ }
+ elif prop.getProperty("port.port_type") == "CorbaPort"{
+ name = "svcports.port_cxt/"
+ name += str(prop.getProperty("publish_topic")) + ".topic_cxt"
+ nsports = self.getPortsOnNameServers(name, "svc")
+ self.connectServicePorts(p, nsports)
+ }
+ }
+*/
+ }
/**
+ *
+ * {@ja NamingManagerを取得する}
+ * {@.en Gets NamingManager Managfer has.}
+ *
+ *
+ * @return
+ * {@.ja NamingManager}
+ * {@.en NamingManager}
+ *
+ * # NamingManager* getNaming()
+ */
+ public NamingManager getNaming(){
+ rtcout.println(Logbuf.TRACE, "Manager.getNaming()");
+ return m_namingManager;
+
+ }
+ /**
* {@.ja 初期化プロシージャのセット。}
* {@.en Set initial procedure}
*
@@ -1547,6 +1730,9 @@
}
m_listeners.naming_.postBind(comp,names);
+ publishPorts(comp);
+ subscribePorts(comp);
+
return true;
}
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/NamingBase.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/NamingBase.java 2016-03-01 11:08:01 UTC (rev 785)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/NamingBase.java 2016-03-02 04:10:20 UTC (rev 786)
@@ -1,6 +1,9 @@
package jp.go.aist.rtm.RTC;
import jp.go.aist.rtm.RTC.port.PortBase;
+
+import RTC.RTObject;
+
/**
* {@.ja Naming Service管理用インターフェース。}
* {@.en NamingService management interface}
@@ -78,4 +81,16 @@
*
*/
public boolean isAlive();
+
+ /**
+ *
+ * {@.ja rtcloc形式でRTCのオブジェクトリファレンスを取得する}
+ * {@.en Gets RTC objects by rtcloc form.}
+ *
+ * @return
+ * {@.ja RTCのオブジェクトリファレンス}
+ * {@.en RTC objects}
+ # virtual RTCList string_to_component(string name) = 0;
+ */
+ public RTObject[] string_to_component(String name);
}
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/NamingManager.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/NamingManager.java 2016-03-01 11:08:01 UTC (rev 785)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/NamingManager.java 2016-03-02 04:10:20 UTC (rev 786)
@@ -7,6 +7,7 @@
import jp.go.aist.rtm.RTC.util.CallbackFunction;
import jp.go.aist.rtm.RTC.util.StringUtil;
+import RTC.RTObject;
/**
* {@.ja NamingServer 管理クラス。}
* {@.en NamingServer management class}
@@ -153,8 +154,42 @@
this.registerMgrName(name, mgr);
}
}
-
/**
+ *
+ * {@.ja @brief 指定したポートのNamingServiceへバインド}
+ * {@.en Bind the specified port to NamingService}
+ *
+ * @param name バインド時の名称
+ * {@.ja RTコンポーネント}
+ * {@.ja バインド時の名称}
+ *
+ * @param port バインド対象のポート
+ * {@.ja バインド対象のポート}
+ * {@.en The target port for the binding}
+ *
+ * void bindPortObject(const char* name, PortBase* port)
+ */
+/*
+ public void bindPortObject(String name,PortBaes port){
+ rtcout.println(Logbuf.TRACE,
+ "NamingManager.bindPortObject(" + name + ")");
+ synchronized (m_names) {
+ int len = m_names.size();
+ for(int intIdx=0; intIdx < len; ++intIdx ) {
+ if( m_names.elementAt(intIdx).ns != null ) {
+ try{
+ m_names.elementAt(intIdx).ns.bindPortObject(name, rtobj);
+ }
+ catch(Exception ex){
+ m_names.elementAt(intIdx).ns = null;
+ }
+ }
+ }
+ this.registerPortName(name, rtobj);
+ }
+ }
+*/
+ /**
* {@.ja NamingServer の情報の更新。}
* {@.en Update information of NamingServer}
*
@@ -343,6 +378,34 @@
return m_names;
}
/**
+ *
+ * {@.ja rtcloc形式でRTCのオブジェクトリファレンスを取得}
+ * {@.en Gets RTC objects by rtcloc form.}
+ *
+ * @param name
+ * {@.ja rtcloc形式でのRTC名
+ * rtcloc://localhost:2809/example/ConsoleIn}
+ * {@.en The RTC name expressed by rtcloc form
+ * rtcloc://localhost:2809/example/ConsoleIn}
+ *
+ * @return
+ * {@.ja RTCのオブジェクトリファレンス}
+ * {@.en List of RTC objects}
+ *
+ * # RTCList string_to_component(string name);
+ */
+ public RTObject[] string_to_component(String name){
+ synchronized (m_names) {
+ for(int ic=0;ic<m_names.size();++ic){
+ RTObject[] comps = m_names.get(ic).ns.string_to_component(name);
+ if(comps == null){
+ return comps;
+ }
+ }
+ }
+ return null;
+ }
+ /**
* {@.ja NameServer 管理用オブジェクトの生成。}
* {@.en Create objects for NameServer management}
*
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/NamingOnCorba.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/NamingOnCorba.java 2016-03-01 11:08:01 UTC (rev 785)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/NamingOnCorba.java 2016-03-02 04:10:20 UTC (rev 786)
@@ -1,9 +1,23 @@
package jp.go.aist.rtm.RTC;
import jp.go.aist.rtm.RTC.log.Logbuf;
+import jp.go.aist.rtm.RTC.port.CorbaConsumer;
import jp.go.aist.rtm.RTC.port.PortBase;
+import jp.go.aist.rtm.RTC.util.CORBA_SeqUtil;
import org.omg.CORBA.ORB;
+import org.omg.CORBA.Object;
+import org.omg.CosNaming.NamingContext;
+import org.omg.CosNaming.NamingContextExtHelper;
+import org.omg.CosNaming.BindingIteratorHolder;
+import org.omg.CosNaming.BindingHolder;
+import org.omg.CosNaming.Binding;
+import org.omg.CosNaming.BindingListHolder;
+import org.omg.CosNaming.BindingType;
+
+import RTC.RTCListHolder;
+import RTC.RTObject;
+import RTC.RTObjectHelper;
/**
* {@.ja CORBA 用 NamingServer 管理クラス。}
* {@.en NamingServer management class for CORBA}
@@ -151,9 +165,137 @@
return m_cosnaming.isAlive();
}
+ /**
+ *
+ * {@.ja RTCの検索}
+ * {@.en Finds RTCs}
+ * <p>
+ * {@.ja ネーミングサービスからRTCをインスタンス名から検索し、
+ * 一致するRTCのリストを取得する}
+ * {@.en Finds RTCis from the inside of NamingService}
+ *
+ *
+ * @param context
+ * {@.ja 現在検索中のコンテキスト}
+ * {@.en context}
+ *
+ * @param name
+ * {@.ja RTCのインスタンス名}
+ * {@.en Instance name of RTC}
+ *
+ * @param rtcs
+ * {@.ja RTCのリスト}
+ * {@.en List of RTC}
+ *
+ */
+ public void get_RTC_by_Name(NamingContext context, String name,
+ RTCListHolder rtcs){
+
+ int length = 500;
+ BindingListHolder bl = new BindingListHolder();
+ BindingIteratorHolder bi = new BindingIteratorHolder();
+
+ context.list(length,bl,bi);
+ BindingHolder bindholder = new BindingHolder();
+ while (bi.value.next_one(bindholder)) {
+ if(bindholder.value.binding_type==BindingType.ncontext){
+ try{
+ NamingContext next_context
+ = NamingContextExtHelper.narrow(
+ context.resolve(bindholder.value.binding_name));
+ get_RTC_by_Name(next_context, name, rtcs);
+ }
+ catch(Exception ex){
+ rtcout.println(Logbuf.ERROR, "catch exception");
+ rtcout.println(Logbuf.ERROR, ex.toString());
+ return;
+ }
+ }
+ else if(bindholder.value.binding_type==BindingType.nobject){
+ if(bindholder.value.binding_name[0].id.equals(name) &&
+ bindholder.value.binding_name[0].kind.equals("rtc")){
+ try{
+ CorbaConsumer cc = new CorbaConsumer();
+ cc.setObject(context.resolve(
+ bindholder.value.binding_name));
+ RTObject obj = RTObjectHelper.narrow(cc.getObject());
+ CORBA_SeqUtil.push_back(rtcs, obj);
+ }
+ catch (Exception ex) {
+ rtcout.println(Logbuf.ERROR, "catch exception");
+ rtcout.println(Logbuf.ERROR, ex.toString());
+ }
+ }
+ }
+ }
+ }
+ /**
+ *
+ * {@.ja rtcname形式でRTCのオブジェクトリファレンスを取得する}
+ * {@.en Gets RTC objects by rtcname form.}
+ *
+ * @return
+ * {@.ja RTCのオブジェクトリファレンス}
+ * {@.en List of RTObjects}
+ * virtual RTCList string_to_component(string name) = 0;
+ */
+ public RTObject[] string_to_component(String name){
+ RTCListHolder rtc_list = new RTCListHolder();
+ String[] tmps = name.split("//");
+ if(tmps.length > 1){
+ if(tmps[0].equals("rtcname:")){
+ String tag = tmps[0];
+ String url = tmps[1];
+ String[] elements = url.split("/");
+ if(elements.length > 1){
+ String host = elements[0];
+
+ String rtc_name = url.substring(host.length()+1);
+
+ try{
+ CorbaNaming cns;
+ if(host.equals("*")){
+ cns = m_cosnaming;
+ }
+ else{
+ ORB orb = Manager.instance().getORB();
+ cns = new CorbaNaming(orb,host);
+ }
+ String[] names = rtc_name.split("/");
+
+ if(names.length == 2 && names[0].equals("*")){
+ NamingContext root_cxt = cns.getRootContext();
+ get_RTC_by_Name(root_cxt, names[1], rtc_list);
+ return rtc_list.value;
+ }
+ else{
+ rtc_name += ".rtc";
+ Object obj = cns.resolveStr(rtc_name);
+ if(obj == null){
+ return null;
+ }
+ CORBA_SeqUtil.push_back(rtc_list,
+ RTObjectHelper.narrow(obj));
+ return rtc_list.value;
+ }
+ }
+ catch (Exception ex) {
+ return null;
+ }
+ }
+ }
+ }
+
+
+ return rtc_list.value;
+ }
+
public CorbaNaming getCorbaNaming() {
return m_cosnaming;
}
+
+
+
private CorbaNaming m_cosnaming;
/**
* {@.ja Logging用フォーマットオブジェクト}
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/util/CORBA_RTCUtil.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/util/CORBA_RTCUtil.java 2016-03-01 11:08:01 UTC (rev 785)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/util/CORBA_RTCUtil.java 2016-03-02 04:10:20 UTC (rev 786)
@@ -1,9 +1,10 @@
package jp.go.aist.rtm.RTC.util;
+import jp.go.aist.rtm.RTC.Manager;
+import jp.go.aist.rtm.RTC.NamingManager;
+
import java.util.Vector;
-import RTC.RTObject;
-
import RTC.ComponentProfile;
import RTC.ComponentProfileHolder;
import RTC.ComponentProfileListHolder;
@@ -15,6 +16,7 @@
import RTC.ExecutionContextService;
import RTC.ExecutionContextServiceHelper;
import RTC.LifeCycleState;
+import RTC.RTObject;
import RTC.PortProfile;
import RTC.PortService;
import RTC.PortServiceListHolder;
@@ -472,7 +474,8 @@
}
/**
*
- * {@.ja 対象のRTコンポーネントの指定した実行コンテキストでINACTIVE状態かどうか判定}
+ * {@.ja 対象のRTコンポーネントの指定した実行コンテキストで
+ * INACTIVE状態かどうか判定}
* {@.en Confirm to INACTIVE}
*
*
@@ -483,7 +486,7 @@
*
* @return
* {@.ja INACTIVE状態の時はtrue、それ以外はfalse
- * rtc、ecがnilの場合もfalseを返す}
+ * rtc、ecがnilの場合もfalseを返す}
* {@.en Result of state confirmation
* (INACTIVE state:true, other state:false)}
*
@@ -1374,7 +1377,7 @@
}
PortServiceListHolder ports = new PortServiceListHolder();
ports.value = connector_prof.ports;
- return disconnect_by_connector_id(ports.value[0],
+ return disconnect_by_portref_connector_id(ports.value[0],
connector_prof.connector_id);
}
@@ -1393,13 +1396,14 @@
*
* @return
* {@.ja portがnilの場合はBAD_PARAMETERを返す
- * nilではない場合はdisconnect関数の戻り値を返す。RTC_OKの場合は切断が成功}
+ * nilではない場合はdisconnect関数の戻り値を返す。
+ * RTC_OKの場合は切断が成功}
* {@.en Return code}
*
*
*/
- public static ReturnCode_t disconnect_by_connector_name(PortService port,
- String name){
+ public static ReturnCode_t disconnect_by_portref_connector_name(
+ PortService port, String name){
if(port == null){
return ReturnCode_t.BAD_PARAMETER;
}
@@ -1414,6 +1418,41 @@
return ReturnCode_t.BAD_PARAMETER;
}
+ /**
+ *
+ * {@.ja 対象の名前のポートで指定した名前のコネクタを切断}
+ * {@.en Disconnects the connectionis specified by name.}
+ *
+ *
+ * @param port _name
+ * {@.ja 対象のポート名}
+ * {@.en Target Port name}
+ *
+ * @param conn_name
+ * {@.ja コネクタ名}
+ * {@.en Connector name}
+ *
+ * @return
+ * {@.ja portがnilの場合はBAD_PARAMETERを返す
+ * nilではない場合はdisconnect関数の戻り値を返す。
+ * RTC_OKの場合は切断が成功}
+ * {@.en Return code}
+ *
+ */
+ public static ReturnCode_t disconnect_by_portname_connector_name(
+ String port_name, String conn_name){
+ PortService port_ref = get_port_by_url(port_name);
+ if(port_ref == null){
+ return ReturnCode_t.BAD_PARAMETER;
+ }
+ ConnectorProfile[] conprof = port_ref.get_connector_profiles();
+ for(int ic=0;ic<conprof.length;++ic){
+ if(conprof[ic].name.equals(conn_name)){
+ return disconnect(conprof[ic]);
+ }
+ }
+ return ReturnCode_t.BAD_PARAMETER;
+ }
/**
*
@@ -1431,13 +1470,14 @@
*
* @return
* {@.ja portがnilの場合はBAD_PARAMETERを返す
- * nilではない場合はdisconnect関数の戻り値を返す。RTC_OKの場合は切断が成功}
+ * nilではない場合はdisconnect関数の戻り値を返す。
+ * RTC_OKの場合は切断が成功}
* {@.en Return code}
*
*
*/
- public static ReturnCode_t disconnect_by_connector_id(PortService port,
- String id){
+ public static ReturnCode_t disconnect_by_portref_connector_id(
+ PortService port, String id){
if(port == null){
return ReturnCode_t.BAD_PARAMETER;
}
@@ -1446,6 +1486,113 @@
}
/**
*
+ * {@.ja 対象の名前のポートで指定したIDのコネクタを切断}
+ * {@.en Disconnects the connectionis specified by id.}
+ *
+ *
+ * @param port_name
+ * {@.ja 対象のポート名}
+ * {@.en Target Port Name}
+ *
+ * @param name コネクタ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_portname_connector_id(
+ String port_name, String conn_id){
+ PortService port_ref = get_port_by_url(port_name);
+ if(port_ref == null){
+ return ReturnCode_t.BAD_PARAMETER;
+ }
+
+ return port_ref.disconnect(conn_id);
+ }
+ /**
+ *
+ * {@ja 対象のポートのコネクタを全て切断}
+ * {@.en Disconnect all connectors in the target port.}
+ *
+ *
+ * @param port_ref
+ * {@.ja ポートのオブジェクトリファレンス}
+ * {@.en Object reference of port}
+ *
+ * @return
+ * {@.ja portがnilの場合はBAD_PARAMETERを返す
+ * 切断できた場合はRTC_OKを返す}
+ * {@.en Return code}
+ *
+ */
+ public static ReturnCode_t disconnect_all_by_ref(PortService port_ref){
+ if(port_ref == null) {
+ return ReturnCode_t.BAD_PARAMETER;
+ }
+ return port_ref.disconnect_all();
+ }
+ /**
+ *
+ * {@ja 指定ポート名のポートのコネクタを全て切断}
+ * {@.en Disconnect all connectors in the target port name.}
+ *
+ *
+ * @param port_name
+ * {@.ja ポート名}
+ * {@.en port name}
+ *
+ * @return
+ * {@.ja portが存在しない場合はBAD_PARAMETERを返す
+ * 切断できた場合はRTC_OKを返す}
+ * {@.en Return code}
+ *
+ */
+ public static ReturnCode_t disconnect_all_by_name(String port_name){
+ PortService port_ref = get_port_by_url(port_name);
+ if(port_ref == null){
+ return ReturnCode_t.BAD_PARAMETER;
+ }
+ return port_ref.disconnect_all();
+
+ }
+ /**
+ *
+ * {@ja 指定した名前のポートを取得}
+ * {@.en Gets a port of the designated name.}
+ *
+ * @param port_name
+ * {@.ja ポート名}
+ * {@.en a port name}
+ * @return
+ * {@.a ポートのオブジェクトリファレンス
+ * portが存在しない場合はnilを返す}
+ * {@.en Object reference of port}
+ *
+ */
+ public static PortService get_port_by_url(String port_name){
+ Manager mgr = Manager.instance();
+ NamingManager nm = mgr.getNaming();
+ String[] ports = port_name.split("\\.");
+ if(ports.length < 2){
+ return null;
+ }
+ RTObject[] rtcs = nm.string_to_component(ports[0]);
+ if(rtcs.length<1){
+ return null;
+ }
+
+ String[] pn = port_name.split("/");
+
+ return get_port_by_name(rtcs[0],pn[pn.length-1]);
+
+ }
+ /**
+ *
* {@.ja 対象ポートと接続しているポートで指定したポート名と一致した場合に
* 切断}
* {@.en Disconnects a connection in specified by port.}
@@ -1582,7 +1729,7 @@
*
*
*/
- public static String get_current_configuration_name(RTObject rtc){
+ public static String get_active_configuration_name(RTObject rtc){
try {
Configuration conf = rtc.get_configuration();
ConfigurationSet confset = conf.get_active_configuration_set();
@@ -1635,7 +1782,7 @@
*
* @param value_name
* {@.ja パラメータ名}
- * {@.en trametername}
+ * {@.en ParamterName}
*
* @param value パラメータ
* {@.ja パラメータ}
@@ -1669,4 +1816,85 @@
return false;
}
}
+ /**
+ *
+ * {@.ja アクティブなコンフィギュレーションセットのパラメータを設定}
+ * {@.en SetConfiguration object}
+ *
+ *
+ * @param rtc
+ * {@.ja 対象のRTコンポーネント}
+ * {@.en Target RTComponent}
+ *
+ * @param value_name
+ * {@.ja パラメータ名}
+ * {@.en ParamterName}
+ *
+ * @param value パラメータ
+ * {@.ja パラメータ}
+ * {@.en Paramter}
+ *
+ * @return
+ * {@.ja true:設定に成功、false:設定に失敗}
+ * {@.en true: succeeded, false: failed}
+ *
+ */
+ public static boolean set_active_configuration(
+ RTObject rtc, String value_name, String value){
+ try {
+ Configuration conf = rtc.get_configuration();
+
+ ConfigurationSet confset = conf.get_active_configuration_set();
+ set_configuration_parameter(conf, confset, value_name, value);
+
+ conf.activate_configuration_set(confset.id);
+ return true;
+ }
+ catch (Exception ex) {
+ return false;
+ }
+ }
+ /**
+ *
+ * {@.ja コンフィギュレーションパラメータの設定}
+ * {@.en Set configuration paramters.}
+ *
+ *
+ * @param conf コンフィギュレーション
+ * {@.ja コンフィギュレーション}
+ * {@.en Configurationme}
+ *
+ * @param confset
+ * {@.ja コンフィギュレーションセット}
+ * {@.en ConfigurationSete}
+ *
+ * @param value_name
+ * {@.ja パラメータ名}
+ * {@.en ParamterName}
+ *
+ * @param value
+ * @return True:設定に成功、False:設定に失敗
+ * {@.ja true:設定に成功、false:設定に失敗}
+ * {@.en true: succeeded, false: failed}
+ */
+ public static boolean set_configuration_parameter(
+ Configuration conf, ConfigurationSet confset, String value_name,
+ String value){
+ try{
+ 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);
+ return true;
+ }
+ catch (Exception ex) {
+ return false;
+ }
+
+ }
}
More information about the openrtm-commit
mailing list