[openrtm-commit:03166] r1109 - branches/RELENG_1_2/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC
openrtm @ openrtm.org
openrtm @ openrtm.org
2018年 2月 8日 (木) 16:35:13 JST
Author: t-katami
Date: 2018-02-08 16:35:13 +0900 (Thu, 08 Feb 2018)
New Revision: 1109
Modified:
branches/RELENG_1_2/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/FactoryInit.java
branches/RELENG_1_2/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/Manager.java
branches/RELENG_1_2/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/ManagerConfig.java
Log:
[merge] r1105-r1108 have been merged from trunk.
Modified: branches/RELENG_1_2/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/FactoryInit.java
===================================================================
--- branches/RELENG_1_2/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/FactoryInit.java 2018-02-07 08:03:19 UTC (rev 1108)
+++ branches/RELENG_1_2/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/FactoryInit.java 2018-02-08 07:35:13 UTC (rev 1109)
@@ -18,6 +18,8 @@
import jp.go.aist.rtm.RTC.port.OutPortSHMProvider;
import jp.go.aist.rtm.RTC.port.OutPortSHMConsumer;
+import jp.go.aist.rtm.RTC.ComponentObserverConsumer;
+
/**
* {@.ja Factory初期処理用クラス}
* {@.en Class for Factory initial processing}
@@ -65,5 +67,8 @@
DefaultNumberingPolicy.DefaultNumberingPolicyInit();
NodeNumberingPolicy.NodeNumberingPolicyInit();
NamingServiceNumberingPolicy.NamingServiceNumberingPolicyInit();
+
+ ComponentObserverConsumer.ComponentObserverConsumerInit();
+ //ExtendedFsmServiceProvider.ExtendedFsmServiceProviderInit();
}
}
Modified: branches/RELENG_1_2/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/Manager.java
===================================================================
--- branches/RELENG_1_2/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/Manager.java 2018-02-07 08:03:19 UTC (rev 1108)
+++ branches/RELENG_1_2/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/Manager.java 2018-02-08 07:35:13 UTC (rev 1109)
@@ -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;
@@ -996,8 +997,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".}
*
*/
@@ -1015,29 +1015,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();
@@ -1049,7 +1068,7 @@
continue;
}
comp0_ref = rtcs[0];
- String[] array = comp_ports[0].split("/");
+ String[] array = conn_prop[0].split("/");
port0_name = array[array.length-1];
}
@@ -1060,61 +1079,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);
}
}
@@ -3861,63 +3892,6 @@
}
}
- File otherref
- = new File(m_config.getProperty("manager.refstring_path"));
- if (!otherref.exists()) {
- FileWriter reffile = null;
- try {
- reffile = new FileWriter(otherref);
- reffile.write(
- m_pORB.object_to_string(m_mgrservant.getObjRef()));
- reffile.close();
- } catch (IOException e) {
- }
- if(reffile != null){
- try {
- reffile.close();
- }
- catch (IOException e) {
- }
- }
- }
- else {
- FileReader reffile = null;
- BufferedReader br = null;
- try{
- String refstring = new String();
- reffile = new FileReader(otherref);
- br = new BufferedReader(reffile);
- String line;
- while ((line = br.readLine()) != null) {
- refstring = refstring + line;
- }
- br.close();
- reffile.close();
-
-
- //Object obj = m_pORB.string_to_object(refstring);
- //Manager mgr = ManagerHelper.narrow(obj);
- // if (mgr==null) return false;
- // mgr.set_child(m_mgrservant.getObjRef());
- // m_mgrservant.set_owner(mgr);
- } catch (IOException e) {
- }
- if(br != null){
- try{
- br.close();
- }
- catch (IOException e) {
- }
- }
- if(reffile != null){
- try{
- reffile.close();
- }
- catch (IOException e) {
- }
- }
- }
-
return true;
}
Modified: branches/RELENG_1_2/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/ManagerConfig.java
===================================================================
--- branches/RELENG_1_2/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/ManagerConfig.java 2018-02-07 08:03:19 UTC (rev 1108)
+++ branches/RELENG_1_2/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/ManagerConfig.java 2018-02-08 07:35:13 UTC (rev 1109)
@@ -6,6 +6,7 @@
import java.io.FileReader;
import java.io.IOException;
import java.net.InetAddress;
+import java.util.ArrayList;
import java.util.Random;
import jp.go.aist.rtm.Constants;
@@ -372,14 +373,31 @@
}
}
- // Search rtc configuration file from default search path
- for (int i = 0; Constants.CONFIG_FILE_PATH[i] != null; i++) {
- if (fileExist(Constants.CONFIG_FILE_PATH[i])) {
- m_configFile = Constants.CONFIG_FILE_PATH[i];
- return true;
+ String osname = System.getProperty("os.name").toLowerCase();
+ if(osname.startsWith("windows")){
+ ArrayList<String> paths = new ArrayList<String>();
+ paths.add("./rtc.conf");
+ String def_path = System.getenv("RTM_ROOT")
+ + "bin\\"
+ + System.getenv("RTM_VC_VERSION")
+ + "\\rtc.conf";
+ paths.add(def_path);
+ for(String path:paths){
+ if (fileExist(path)) {
+ this.m_configFile = path;
+ return true;
+ }
}
}
-
+ else{
+ // Search rtc configuration file from default search path
+ for (int i = 0; Constants.CONFIG_FILE_PATH[i] != null; i++) {
+ if (fileExist(Constants.CONFIG_FILE_PATH[i])) {
+ m_configFile = Constants.CONFIG_FILE_PATH[i];
+ return true;
+ }
+ }
+ }
return false;
}
More information about the openrtm-commit
mailing list