[openrtm-commit:03160] r1107 - trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC
openrtm @ openrtm.org
openrtm @ openrtm.org
2018年 2月 7日 (水) 14:50:14 JST
Author: t-katami
Date: 2018-02-07 14:50:14 +0900 (Wed, 07 Feb 2018)
New Revision: 1107
Modified:
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/Manager.java
Log:
[compat,->RELENG_1_2] Changed the format of manager.components.preconnect. refs #4445
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 2018-01-29 08:20:32 UTC (rev 1106)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/Manager.java 2018-02-07 05:50:14 UTC (rev 1107)
@@ -13,6 +13,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.Vector;
import java.util.logging.FileHandler;
@@ -1007,8 +1008,7 @@
* {@.ja このメソッドは"manager.components.preactivation"に設定される
* コンポーネントを活性化する。
* 例:
- * manager.components.preconnect: RTC0.port0^RTC0.port1(interface_type=corba_cdr&dataflow_type=pull&~),~}
- * {@.en This method activates components set to
+ * manager.components.preconnect: RTC0.port0?port=RTC0.port1&interface_type=corba_cdr&dataflow_type=pull&~,~
* "manager.components.preconnect".}
*
*/
@@ -1026,29 +1026,48 @@
+Arrays.toString(connectors));
}
for (int ic=0; ic < connectors.length; ++ic) {
- // ConsoleIn.out^Console.in(dataflow_type=push&....)
- String[] conn_prop = connectors[ic].split("\\(");
+ // ConsoleIn.out?Console.in&dataflow_type=push&....
+ String[] conn_prop = connectors[ic].split("\\?");
if ( conn_prop == null || conn_prop.length == 0 ) {
}
- if ( conn_prop.length == 2 ) {
- conn_prop[1] = conn_prop[1].replace(")","");
+ //String[] params = connectors[ic].split("&");
+ ArrayList<String> params
+ = new ArrayList(Arrays.asList(conn_prop[1].split("&")));
+ HashMap<String,String> config = new HashMap<>();
+ ArrayList<String> ports = new ArrayList<String>();
+ for(String param :params){
+ String[] elem = param.split("=");
+ if(elem.length != 2){
+ continue;
+ }
+ elem[0] = elem[0].trim();
+ elem[1] = elem[1].trim();
+ String exp = "port\\d*";
+ if(elem[0].matches(exp)){
+ ports.add(elem[1]);
+ continue;
+ }
+ config.put(elem[0],elem[1]);
}
- String[] comp_ports = conn_prop[0].split("\\^"); //"^" is expressing a connection between ports.
- if(comp_ports.length != 2) {
+
+ if(ports.size() == 0) {
rtcout.println(Logbuf.ERROR,
"Invalid format for pre-connection.");
rtcout.println(Logbuf.ERROR,
- "Format must be Comp0.port0:Comp1.port1");
+ "Format must be RTC0.port0?port=RTC0.port1");
continue;
}
- String comp0_name = comp_ports[0].split("\\.")[0];
- String port0_name = comp_ports[0];
+
+ String comp0_name = conn_prop[0].split("\\.")[0];
+ //String port0_name
+ // = conn_prop[0].substring(conn_prop[0].lastIndexOf(".") + 1);
+ String port0_name = conn_prop[0];
+
RTC.RTObject comp0_ref;
if(comp0_name.indexOf("://") == -1){
RTObject_impl comp0 = getComponent(comp0_name);
if (comp0 == null) {
- rtcout.println(Logbuf.ERROR,
- comp0_name + " not found.");
+ rtcout.println(Logbuf.ERROR, comp0_name + " not found.");
continue;
}
comp0_ref = comp0.getObjRef();
@@ -1060,7 +1079,7 @@
continue;
}
comp0_ref = rtcs[0];
- String[] array = comp_ports[0].split("/");
+ String[] array = conn_prop[0].split("/");
port0_name = array[array.length-1];
}
@@ -1071,61 +1090,73 @@
continue;
}
+ //Makes ConnectorProfile
+ NVListHolder nvholder = new NVListHolder();
+ if( nvholder.value==null ) {
+ nvholder.value = new NameValue[0];
+ }
+ if(config.get("dataflow_type")==null){
+ config.put("dataflow_type","push");
+ }
+ if(config.get("interface_type")==null){
+ config.put("interface_type","corba_cdr");
+ }
+ config.forEach((k, v) -> {
+ rtcout.println(Logbuf.TRACE, "options: " + k +","+ v);
+ CORBA_SeqUtil.push_back(nvholder,
+ NVUtil.newNVString("dataport." + k,v));
+ });
+ Properties prop = new Properties();
+ NVUtil.copyToProperties(prop, nvholder);
- String comp1_name = comp_ports[1].split("\\.")[0];
- String port1_name = comp_ports[1];
- RTC.RTObject comp1_ref;
- if(comp1_name.indexOf("://") == -1){
- RTObject_impl comp1 = getComponent(comp1_name);
- if (comp1 == null) {
- rtcout.println(Logbuf.ERROR,
- comp1_name + " not found.");
- continue;
+ //Connects ports
+ for(String port : ports){
+ //String port_name = port.substring(port.lastIndexOf(".")+1);
+ String port_name = port;
+ String comp_name = port.split("\\.")[0];
+
+ RTC.RTObject comp_ref;
+ if(comp_name.indexOf("://") == -1){
+ RTObject_impl comp = getComponent(comp_name);
+ if (comp == null) {
+ rtcout.println(Logbuf.ERROR,
+ comp_name + " not found.");
+ continue;
+ }
+ comp_ref = comp.getObjRef();
}
- comp1_ref = comp1.getObjRef();
- }
- else{
- RTC.RTObject[] rtcs = m_namingManager.string_to_component(comp1_name);
- if(rtcs == null || rtcs.length == 0) {
- rtcout.println(Logbuf.ERROR, comp1_name + " not found.");
- continue;
+ else{
+ RTC.RTObject[] rtcs
+ = m_namingManager.string_to_component(comp_name);
+ if(rtcs == null || rtcs.length == 0) {
+ rtcout.println(Logbuf.ERROR, comp_name + " not found.");
+ continue;
+ }
+ comp_ref = rtcs[0];
+ String[] array = port.split("/");
+ port_name = array[array.length-1];
}
- comp1_ref = rtcs[0];
- String[] array = comp_ports[1].split("/");
- port1_name = array[array.length-1];
- }
- PortService port1_var = CORBA_RTCUtil.get_port_by_name(comp1_ref, port1_name);
- if(port1_var == null){
- rtcout.println(Logbuf.ERROR, "port " + port1_name + " not found.");
- continue;
- }
+ PortService port_var
+ = CORBA_RTCUtil.get_port_by_name(comp_ref, port_name);
+ if(port_var == null){
+ rtcout.println(Logbuf.ERROR,
+ "port " + port_name + " not found.");
+ continue;
+ }
- NVListHolder nvholder = new NVListHolder();
- if( nvholder.value==null ) {
- nvholder.value = new NameValue[0];
- }
- String[] opt_props = conn_prop[1].split("\\&");
- for (int o=0; o < opt_props.length; ++o) {
- String[] temp = opt_props[o].split("=");
- //prop["dataport." + temp[0]] = temp[1];
- if(temp.length == 2){
- rtcout.println(Logbuf.TRACE, "options: " + Arrays.toString(temp));
- CORBA_SeqUtil.push_back(nvholder,
- NVUtil.newNVString("dataport." + temp[0],temp[1]));
+ //ReturnCode_t ret = CORBA_RTCUtil.connect(
+ // connectors[ic],prop,port0_var, port_var);
+ ReturnCode_t ret = CORBA_RTCUtil.connect(
+ conn_prop[0]+"?"+port_name,prop,port0_var, port_var);
+ if(ret != ReturnCode_t.RTC_OK){
+ rtcout.println(Logbuf.ERROR,
+ "Connection error in topic connection.");
}
+ NVUtil.dump(nvholder);
}
- Properties prop = new Properties();
- NVUtil.copyToProperties(prop, nvholder);
- ReturnCode_t ret = CORBA_RTCUtil.connect(
- connectors[ic],prop,port0_var, port1_var);
- if(ret != ReturnCode_t.RTC_OK){
- rtcout.println(Logbuf.ERROR,
- "Connection error in topic connection.");
- }
- NVUtil.dump(nvholder);
}
}
More information about the openrtm-commit
mailing list