[openrtm-commit:01795] r787 - in trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC: src/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
2016年 3月 2日 (水) 19:31:04 JST
Author: win-ei
Date: 2016-03-02 19:31:04 +0900 (Wed, 02 Mar 2016)
New Revision: 787
Modified:
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/CorbaNaming.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
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/util/CORBA_RTCUtilTest.java
Log:
Fix bugs of CORBA_RTCUtil class. refs #3385
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/CorbaNaming.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/CorbaNaming.java 2016-03-02 04:10:20 UTC (rev 786)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/CorbaNaming.java 2016-03-02 10:31:04 UTC (rev 787)
@@ -97,7 +97,9 @@
}
// m_nameServer = "corbaloc:iiop:1.2@" + m_nameServer + "/NameService";
+ //rtcout.println(Logbuf.PARANOID, "m_nameServer="+m_nameServer);
obj = m_varORB.string_to_object(m_nameServer);
+ //rtcout.println(Logbuf.PARANOID, "obj="+obj);
m_rootContext = NamingContextExtHelper.narrow(obj);
if (m_rootContext==null) {
throw new Exception("bad_alloc()");
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-02 04:10:20 UTC (rev 786)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/NamingManager.java 2016-03-02 10:31:04 UTC (rev 787)
@@ -395,10 +395,12 @@
* # RTCList string_to_component(string name);
*/
public RTObject[] string_to_component(String name){
+ rtcout.println(Logbuf.PARANOID, "name: "+name);
synchronized (m_names) {
+ rtcout.println(Logbuf.PARANOID, "m_names.size():"+m_names.size());
for(int ic=0;ic<m_names.size();++ic){
RTObject[] comps = m_names.get(ic).ns.string_to_component(name);
- if(comps == null){
+ if(comps != null){
return comps;
}
}
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-02 04:10:20 UTC (rev 786)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/NamingOnCorba.java 2016-03-02 10:31:04 UTC (rev 787)
@@ -240,17 +240,22 @@
* virtual RTCList string_to_component(string name) = 0;
*/
public RTObject[] string_to_component(String name){
+ rtcout.println(Logbuf.PARANOID, "string_to_component("+name+")");
RTCListHolder rtc_list = new RTCListHolder();
String[] tmps = name.split("//");
if(tmps.length > 1){
+ rtcout.println(Logbuf.PARANOID, "tmps[0]:"+tmps[0]);
if(tmps[0].equals("rtcname:")){
String tag = tmps[0];
String url = tmps[1];
+ rtcout.println(Logbuf.PARANOID, "tmps[1]:"+tmps[1]);
String[] elements = url.split("/");
if(elements.length > 1){
String host = elements[0];
+ rtcout.println(Logbuf.PARANOID, "host:"+host);
String rtc_name = url.substring(host.length()+1);
+ rtcout.println(Logbuf.PARANOID, "rtc_name:"+rtc_name);
try{
CorbaNaming cns;
@@ -258,7 +263,12 @@
cns = m_cosnaming;
}
else{
- ORB orb = Manager.instance().getORB();
+ Manager mgr = Manager.instance();
+ if(mgr==null){
+ }
+ ORB orb = mgr.getORB();
+ if(orb==null){
+ }
cns = new CorbaNaming(orb,host);
}
String[] names = rtc_name.split("/");
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-02 04:10:20 UTC (rev 786)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/util/CORBA_RTCUtil.java 2016-03-02 10:31:04 UTC (rev 787)
@@ -1575,14 +1575,26 @@
*
*/
public static PortService get_port_by_url(String port_name){
+ System.out.println("get_port_by_url:"+port_name);
Manager mgr = Manager.instance();
NamingManager nm = mgr.getNaming();
String[] ports = port_name.split("\\.");
+ //System.out.println("ports.length="+ports.length);
+ int index = port_name.lastIndexOf('.');
+ String comp;
+ if(index<-1){
+ comp = port_name;
+ }
+ else{
+ comp = port_name.substring(0,index);
+ }
+ //System.out.println("component:"+comp);
if(ports.length < 2){
return null;
}
- RTObject[] rtcs = nm.string_to_component(ports[0]);
- if(rtcs.length<1){
+// RTObject[] rtcs = nm.string_to_component(ports[0]);
+ RTObject[] rtcs = nm.string_to_component(comp);
+ if(rtcs == null){
return null;
}
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/util/CORBA_RTCUtilTest.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/util/CORBA_RTCUtilTest.java 2016-03-02 04:10:20 UTC (rev 786)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/util/CORBA_RTCUtilTest.java 2016-03-02 10:31:04 UTC (rev 787)
@@ -765,7 +765,8 @@
code = CORBA_RTCUtil.connect("kamo3",prop,port1,null);
assertTrue("test:",code == ReturnCode_t.BAD_PARAMETER);
- code = CORBA_RTCUtil.disconnect_by_connector_name(port1, "kamo0");
+ code = CORBA_RTCUtil.disconnect_by_portref_connector_name(
+ port1, "kamo0");
assertTrue("test:disconnect",code == ReturnCode_t.RTC_OK);
/*
try{
@@ -774,9 +775,11 @@
catch(InterruptedException e){
}
*/
- code = CORBA_RTCUtil.disconnect_by_connector_name(null, "kamo0");
+ code = CORBA_RTCUtil.disconnect_by_portref_connector_name(
+ null, "kamo0");
assertTrue("test:",code == ReturnCode_t.BAD_PARAMETER);
- code = CORBA_RTCUtil.disconnect_by_connector_name(port1, "kamo5");
+ code = CORBA_RTCUtil.disconnect_by_portref_connector_name(
+ port1, "kamo5");
assertTrue("test:"+code.value(),code == ReturnCode_t.BAD_PARAMETER);
}
@@ -884,14 +887,14 @@
break;
}
}
- code = CORBA_RTCUtil.disconnect_by_connector_id(port1,id);
+ code = CORBA_RTCUtil.disconnect_by_portref_connector_id(port1,id);
assertTrue("test:disconnect",code == ReturnCode_t.RTC_OK);
- code = CORBA_RTCUtil.disconnect_by_connector_id(null,id);
+ code = CORBA_RTCUtil.disconnect_by_portref_connector_id(null,id);
assertTrue("test:",code == ReturnCode_t.BAD_PARAMETER);
- code = CORBA_RTCUtil.disconnect_by_connector_id(port1,"");
+ code = CORBA_RTCUtil.disconnect_by_portref_connector_id(port1,"");
assertTrue("test:"+code.value(),code == ReturnCode_t.BAD_PARAMETER);
}
@@ -951,9 +954,9 @@
- str = CORBA_RTCUtil.get_current_configuration_name(m_configRef.value);
+ str = CORBA_RTCUtil.get_active_configuration_name(m_configRef.value);
assertTrue("test:",str.equals("default"));
- str = CORBA_RTCUtil.get_current_configuration_name(null);
+ str = CORBA_RTCUtil.get_active_configuration_name(null);
assertTrue("test:",str.equals(""));
@@ -1033,6 +1036,135 @@
port1, error_ports );
assertTrue("test:",code == ReturnCode_t.BAD_PARAMETER);
}
+
+ /**
+ *
+ * connect
+ *
+ */
+ public void test_disconnect_by_portname_connector_name(){
+
+ PortService port1 = CORBA_RTCUtil.get_port_by_name(m_conoutRef.value,
+ "ConsoleOut0.in");
+ PortService port2 = CORBA_RTCUtil.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 = CORBA_RTCUtil.connect("kamo0",prop,port1,port2);
+ assertTrue("test:connect",code == ReturnCode_t.RTC_OK);
+/*
+ try{
+ Thread.sleep(50000);
+ }
+ catch(InterruptedException e){
+ }
+*/
+
+ code = CORBA_RTCUtil.disconnect_by_portname_connector_name(
+ "rtcname://localhost:2809/.host_cxt/ConsoleOut0.in", "kamo0");
+ assertTrue("test:disconnect",code == ReturnCode_t.RTC_OK);
+/*
+ code = CORBA_RTCUtil.disconnect_by_portref_connector_name(
+ port1, "kamo0");
+*/
+ assertTrue("test:disconnect",code == ReturnCode_t.RTC_OK);
+/*
+ try{
+ Thread.sleep(50000);
+ }
+ catch(InterruptedException e){
+ }
+*/
+
+/*
+ code = CORBA_RTCUtil.disconnect_by_portref_connector_name(
+ null, "kamo0");
+ assertTrue("test:",code == ReturnCode_t.BAD_PARAMETER);
+ code = CORBA_RTCUtil.disconnect_by_portref_connector_name(
+ port1, "kamo5");
+ assertTrue("test:"+code.value(),code == ReturnCode_t.BAD_PARAMETER);
+*/
+
+ }
+ /**
+ *
+ * connect
+ *
+ */
+ public void test_connect_by_name2(){
+
+ PortService port1 = CORBA_RTCUtil.get_port_by_name(m_conoutRef.value,
+ "ConsoleOut0.in");
+ PortService port2 = CORBA_RTCUtil.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 = CORBA_RTCUtil.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 = CORBA_RTCUtil.connect_by_name("",prop,
+ m_conoutRef.value,"ConsoleOut0.in",
+ m_coninRef.value,"ConsoleIn0.out");
+ assertTrue("test:disconnect",code == ReturnCode_t.RTC_OK);
+ code = CORBA_RTCUtil.connect_by_name("kamo1",null,
+ m_conoutRef.value,"ConsoleOut0.in",
+ m_coninRef.value,"ConsoleIn0.out");
+ assertTrue("test:disconnect",code == ReturnCode_t.RTC_OK);
+ code = CORBA_RTCUtil.connect_by_name("kamo2",prop,
+ null,"ConsoleOut0.in",
+ m_coninRef.value,"ConsoleIn0.out");
+ assertTrue("test:",code == ReturnCode_t.BAD_PARAMETER);
+ code = CORBA_RTCUtil.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 = CORBA_RTCUtil.disconnect(cprofs[ic]);
+ break;
+ }
+ }
+
+ assertTrue("test:disconnect "+code.value(),code == ReturnCode_t.RTC_OK);
+/*
+ try{
+ Thread.sleep(10000);
+ }
+ catch(InterruptedException e){
+ }
+*/
+ code = CORBA_RTCUtil.disconnect(null);
+ assertTrue("test:",code == ReturnCode_t.BAD_PARAMETER);
+ }
+
}
More information about the openrtm-commit
mailing list