[openrtm-commit:01717] r758 - in trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src: RTMExamples/SimpleIO jp/go/aist/rtm/RTC
openrtm @ openrtm.org
openrtm @ openrtm.org
2016年 2月 17日 (水) 18:43:24 JST
Author: win-ei
Date: 2016-02-17 18:43:24 +0900 (Wed, 17 Feb 2016)
New Revision: 758
Modified:
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/SimpleIO/rtc.conf
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/Manager.java
Log:
New rtc.conf optinos (preconnection, preactivation) have been added. refs #3222
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/SimpleIO/rtc.conf
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/SimpleIO/rtc.conf 2016-02-15 01:11:49 UTC (rev 757)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/SimpleIO/rtc.conf 2016-02-17 09:43:24 UTC (rev 758)
@@ -7,13 +7,13 @@
#manager.modules.load_path: ./Extension/LocalService/nameservice_file/
#manager.local_service.modules: FileNameservice
-manager.modules.load_path:./RTMExamples/SimpleIO
-manager.modules.preload: ConsoleOut
-manager.components.precreate: ConsoleOut
+#manager.modules.load_path:./RTMExamples/SimpleIO
+#manager.modules.preload: ConsoleOut
+#manager.components.precreate: ConsoleOut
-#manager.components.preconnect: ConsoleIn.out:ConsoleOut.in(dataflow_type=push,interface_type=corba_cdr)
+#manager.components.preconnect: ConsoleIn0.out:ConsoleOut0.in(dataflow_type=push&interface_type=corba_cdr)
-manager.components.preactivate: ConsoleIn0, ConsoleOut0
+#manager.components.preactivation: ConsoleIn0, ConsoleOut0
example.ConsoleIn.config_file: ./RTMExamples/SimpleIO/component.conf
example.ConsoleOut.config_file: ./RTMExamples/SimpleIO/component.conf
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-02-15 01:11:49 UTC (rev 757)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/Manager.java 2016-02-17 09:43:24 UTC (rev 758)
@@ -8,6 +8,7 @@
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Vector;
import java.util.logging.FileHandler;
import java.util.logging.ConsoleHandler;
@@ -22,7 +23,9 @@
import jp.go.aist.rtm.RTC.executionContext.PeriodicExecutionContext;
import jp.go.aist.rtm.RTC.log.Logbuf;
import jp.go.aist.rtm.RTC.util.CallbackFunction;
+import jp.go.aist.rtm.RTC.util.CORBA_SeqUtil;
import jp.go.aist.rtm.RTC.util.IiopAddressComp;
+import jp.go.aist.rtm.RTC.util.NVUtil;
import jp.go.aist.rtm.RTC.util.ORBUtil;
import jp.go.aist.rtm.RTC.util.Properties;
import jp.go.aist.rtm.RTC.util.StringUtil;
@@ -36,8 +39,18 @@
import org.omg.PortableServer.POA;
import org.omg.PortableServer.POAHelper;
import org.omg.PortableServer.POAManager;
+import RTC.ExecutionContext;
+import RTC.ExecutionContextListHolder;
import RTC.ReturnCode_t;
+import RTC.ConnectorProfile;
+import RTC.ConnectorProfileHolder;
+import RTC.PortService;
+import RTC.PortServiceHolder;
+import RTC.PortServiceListHolder;
+import _SDOPackage.NVListHolder;
+import _SDOPackage.NameValue;
+
/**
* {@.ja 各コンポーネントの管理を行うクラス.}
* {@.en This is a manager class that manages various information
@@ -423,7 +436,167 @@
}
precreateComponent();
+ { // pre-connection
+ String preconnect
+ = m_config.getProperty("manager.components.preconnect");
+ rtcout.println(Logbuf.TRACE, "Connection pre-connection: "
+ + preconnect);
+ String[] connectors = new String[0];
+ if ( preconnect == null || preconnect.length() == 0 ) {
+ }
+ else {
+ connectors = preconnect.split(",");
+ rtcout.println(Logbuf.TRACE, "connectors: "
+ +Arrays.toString(connectors));
+ }
+ for (int ic=0; ic < connectors.length; ++ic) {
+ // 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[] comp_ports = conn_prop[0].split(":");
+ if(comp_ports.length != 2) {
+ rtcout.println(Logbuf.ERROR,
+ "Invalid format for pre-connection.");
+ rtcout.println(Logbuf.ERROR,
+ "Format must be Comp0.port0:Comp1.port1");
+ continue;
+ }
+ String comp0_name = comp_ports[0].split("\\.")[0];
+ String comp1_name = comp_ports[1].split("\\.")[0];
+ RTObject_impl comp0 = getComponent(comp0_name);
+ RTObject_impl comp1 = getComponent(comp1_name);
+ if (comp0 == null) {
+ rtcout.println(Logbuf.ERROR,
+ comp0_name + " not found.");
+ continue;
+ }
+ if (comp1 == null) {
+ rtcout.println(Logbuf.ERROR,
+ comp1_name + " not found.");
+ continue;
+ }
+ String port0 = comp_ports[0];
+ String port1 = comp_ports[1];
+ PortServiceListHolder ports0 = new PortServiceListHolder();
+ ports0.value = comp0.get_ports();
+
+ PortServiceListHolder ports1 = new PortServiceListHolder();
+ ports1.value = comp1.get_ports();
+
+ rtcout.println(Logbuf.DEBUG, comp0_name + " has "
+ + ports0.value.length + " ports.");
+ rtcout.println(Logbuf.DEBUG, comp1_name + " has "
+ + ports1.value.length + " ports.");
+
+ PortServiceListHolder port0_var = new PortServiceListHolder();
+ port0_var.value = new PortService[0];
+ int port0_ic = -1;
+ for (int p=0; p < ports0.value.length; ++p) {
+ RTC.PortProfile pp = ports0.value[p].get_port_profile();
+ String s = pp.name;
+ if (comp_ports[0].equals(s)) {
+ rtcout.println(Logbuf.DEBUG, "port " + comp_ports[0]
+ + " found: ");
+ port0_ic = p;
+ }
+ }
+ PortServiceListHolder port1_var = new PortServiceListHolder();
+ int port1_ic = -1;
+ for (int p=0; p < ports1.value.length; ++p) {
+ RTC.PortProfile pp = ports1.value[p].get_port_profile();
+ String s = pp.name;
+ if (comp_ports[1].equals(s)) {
+ rtcout.println(Logbuf.DEBUG, "port " + comp_ports[1]
+ + " found: ");
+ port1_ic = p;
+ }
+ }
+ if (port0_ic == -1) {
+ rtcout.println(Logbuf.ERROR,
+ "port0 " + comp_ports[0] +" is nil obj");
+ continue;
+ }
+ if (port1_ic == -1) {
+ rtcout.println(Logbuf.ERROR,
+ "port1 " + comp_ports[1] +" is nil obj");
+ continue;
+ }
+ ConnectorProfile conn_prof = new ConnectorProfile();
+ String prof_name;
+ conn_prof.name = connectors[ic];
+ conn_prof.connector_id = "";
+ conn_prof.ports = new PortService[2];
+ conn_prof.ports[0] = ports0.value[port0_ic];
+ conn_prof.ports[1] = ports1.value[port1_ic];
+
+ NVListHolder nvholder = new NVListHolder();
+ nvholder.value = conn_prof.properties;
+ if( nvholder.value==null ) {
+ nvholder.value = new NameValue[0];
+ }
+
+ CORBA_SeqUtil.push_back(nvholder,
+ NVUtil.newNVString("dataport.dataflow_type", "push"));
+ CORBA_SeqUtil.push_back(nvholder,
+ NVUtil.newNVString("dataport.interface_type","corba_cdr"));
+
+
+ if ( conn_prop.length == 2 ) {
+ 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];
+ rtcout.println(Logbuf.TRACE, "options: " + Arrays.toString(temp));
+ CORBA_SeqUtil.push_back(nvholder,
+ NVUtil.newNVString("dataport." + temp[0],temp[1]));
+ }
+ }
+ conn_prof.properties = nvholder.value;
+
+ ConnectorProfileHolder profileholder = new ConnectorProfileHolder();
+ profileholder.value = conn_prof;
+
+ if (ReturnCode_t.RTC_OK != ports0.value[port0_ic].connect(profileholder)) {
+ rtcout.println(Logbuf.ERROR,
+ "Connection error: " + connectors[ic]);
+ }
+ NVUtil.dump(nvholder);
+ }
+ } // end of pre-connection
+
+ { // pre-activation
+ String preactivation
+ = m_config.getProperty("manager.components.preactivation");
+ rtcout.println(Logbuf.TRACE,
+ "Components pre-activation: "
+ + Arrays.toString(preactivation.split(",")));
+ String[] comps = new String[0];
+ if ( preactivation == null || preactivation.length() == 0 ) {
+ }
+ else {
+ comps = preactivation.split(",");
+ }
+
+ for (int ic=0; ic < comps.length; ++ic) {
+ comps[ic] = comps[ic].trim();
+ RTObject_impl comp = getComponent(comps[ic]);
+ if (comp == null) {
+ rtcout.println(Logbuf.ERROR, comps[ic] + " not found.");
+ continue;
+ }
+ ExecutionContextListHolder eclistholder
+ = new ExecutionContextListHolder();
+ eclistholder.value = new ExecutionContext[0];
+ eclistholder.value = comp.get_owned_contexts();
+ eclistholder.value[0].activate_component(comp.getObjRef());
+ }
+ } // end of pre-activation
+
return true;
}
@@ -471,6 +644,7 @@
* "Manager.components.precreate".}
*/
private void precreateComponent() {
+ rtcout.println(Logbuf.TRACE, "Components pre-creation: " + m_config.getProperty("manager.components.precreate").split(","));
String[] comp
= m_config.getProperty("manager.components.precreate").split(",");
for (int i=0; i < comp.length; ++i) {
More information about the openrtm-commit
mailing list