[openrtm-commit:01712] r757 - in trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src: RTMExamples/SimpleIO jp/go/aist/rtm/RTC/port
openrtm @ openrtm.org
openrtm @ openrtm.org
2016年 2月 15日 (月) 10:11:49 JST
Author: win-ei
Date: 2016-02-15 10:11:49 +0900 (Mon, 15 Feb 2016)
New Revision: 757
Modified:
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/SimpleIO/ConnectorComp.java
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/SimpleIO/ConsoleOutImpl.java
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/port/InPort.java
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/OutPortBase.java
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/OutPortConnector.java
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/OutPortPullConnector.java
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/OutPortPushConnector.java
Log:
Direct data put functionality between data ports has been implemented. refs #3225
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/SimpleIO/ConnectorComp.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/SimpleIO/ConnectorComp.java 2016-02-09 13:15:52 UTC (rev 756)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/SimpleIO/ConnectorComp.java 2016-02-15 01:11:49 UTC (rev 757)
@@ -137,11 +137,16 @@
NVUtil.newNVString("dataport.interface_type","corba_cdr"));
CORBA_SeqUtil.push_back(nvholder,
NVUtil.newNVString("dataport.dataflow_type", "push"));
+// CORBA_SeqUtil.push_back(nvholder,
+// NVUtil.newNVString("dataport.dataflow_type", "pull"));
CORBA_SeqUtil.push_back(nvholder,
NVUtil.newNVString("dataport.subscription_type", subs_type));
CORBA_SeqUtil.push_back(nvholder,
NVUtil.newNVString("dataport.serializer.cdr.endian", endian));
-
+//
+ CORBA_SeqUtil.push_back(nvholder,
+ NVUtil.newNVString("dataport.outport.direct_dataput.disable", "NO"));
+
if( !period.equals("") )
CORBA_SeqUtil.push_back(nvholder,
NVUtil.newNVString("dataport.push_interval", period));
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/SimpleIO/ConsoleOutImpl.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/SimpleIO/ConsoleOutImpl.java 2016-02-09 13:15:52 UTC (rev 756)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/SimpleIO/ConsoleOutImpl.java 2016-02-15 01:11:49 UTC (rev 757)
@@ -134,6 +134,7 @@
protected ReturnCode_t onExecute(int ec_id) {
if( m_inIn.isNew() ) {
m_inIn.read();
+// if( m_inIn.read() ) {
System.out.print( "Received: " + m_in.v.data + " " );
System.out.print( "TimeStamp: " + m_in.v.tm.sec + "[s] " );
System.out.println( m_in.v.tm.nsec + "[ns]" );
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-09 13:15:52 UTC (rev 756)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples/SimpleIO/rtc.conf 2016-02-15 01:11:49 UTC (rev 757)
@@ -1,13 +1,19 @@
corba.nameservers:localhost
naming.formats: %n.rtc
-logger.enable:NO
+logger.enable:YES
+logger.log_level:PARANOID
+
#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.preactivate: 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/port/InPort.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/InPort.java 2016-02-09 13:15:52 UTC (rev 756)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/InPort.java 2016-02-15 01:11:49 UTC (rev 757)
@@ -124,6 +124,8 @@
this.m_OnOverflow = null;
this.m_OnUnderflow = null;
+ this.m_directNewData = false;
+
m_orb = ORBUtil.getOrb();
Class cl = value.v.getClass();
@@ -214,6 +216,13 @@
rtcout.println(Logbuf.TRACE, "isNew()");
int r = 0;
+ synchronized (m_directNewDataMutex){
+ if (m_directNewData == true) {
+ rtcout.println(Logbuf.DEBUG,
+ "isNew() returns true because of direct write.");
+ return true;
+ }
+ }
synchronized (m_connectorsMutex){
synchronized (m_connectors){
if (m_connectors.size() == 0) {
@@ -304,13 +313,32 @@
public boolean read() {
rtcout.println(Logbuf.TRACE, "DataType read()");
+ if (m_OnRead != null) {
+ m_OnRead.run();
+ rtcout.println(Logbuf.TRACE, "OnRead called");
+ }
+ // 1) direct connection
+ synchronized (m_directNewDataMutex){
+ if (m_directNewData == true) {
+ rtcout.println(Logbuf.DEBUG, "Direct data transfer");
+ m_directNewData = false;
+ if (m_OnReadConvert != null) {
+ m_value.v = m_OnReadConvert.run(m_value.v);
+ rtcout.println(Logbuf.DEBUG,
+ "OnReadConvert for direct data called");
+ return true;
+ }
+ return true;
+ }
+ }
+ // 2) network connection
synchronized (m_connectorsMutex){
- if (m_OnRead != null) {
- m_OnRead.run();
- rtcout.println(Logbuf.TRACE, "OnRead called");
- }
+// if (m_OnRead != null) {
+// m_OnRead.run();
+// rtcout.println(Logbuf.TRACE, "OnRead called");
+// }
ReturnCode ret;
EncapsOutputStreamExt cdr = new EncapsOutputStreamExt(m_orb,
@@ -464,6 +492,10 @@
public boolean isEmpty() {
rtcout.println(Logbuf.TRACE, "isEmpty()");
+ if (m_directNewData == true) {
+ return false;
+ }
+
int r = 0;
synchronized (m_connectorsMutex){
synchronized (m_connectors){
@@ -484,7 +516,14 @@
"isEmpty() = false, data exists in the buffer");
return false;
}
-
+ public void write(final DataRef<DataType> data)
+ {
+ rtcout.println(Logbuf.TRACE, "write()");
+ synchronized (m_directNewDataMutex){
+ m_value.v = data.v;
+ m_directNewData = true;
+ }
+ }
/**
* {@.ja CDR化で使用するStreamableを設定する}
* {@.en Sets Streamable. }
@@ -537,4 +576,8 @@
private Field m_field = null;
private ORB m_orb;
+
+ private boolean m_directNewData;
+ private static String m_directNewDataMutex = new String();
+
}
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/OutPortBase.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/OutPortBase.java 2016-02-09 13:15:52 UTC (rev 756)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/OutPortBase.java 2016-02-15 01:11:49 UTC (rev 757)
@@ -8,6 +8,7 @@
import java.util.Vector;
import jp.go.aist.rtm.Constants;
+import jp.go.aist.rtm.RTC.Manager;
import jp.go.aist.rtm.RTC.InPortConsumerFactory;
import jp.go.aist.rtm.RTC.OutPortProviderFactory;
import jp.go.aist.rtm.RTC.PublisherBaseFactory;
@@ -19,8 +20,11 @@
import jp.go.aist.rtm.RTC.util.Properties;
import jp.go.aist.rtm.RTC.util.StringUtil;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Object;
import org.omg.CORBA.TCKind;
import org.omg.CORBA.portable.OutputStream;
+import org.omg.PortableServer.POA;
import _SDOPackage.NVListHolder;
import RTC.ConnectorProfile;
@@ -1514,6 +1518,20 @@
}
rtcout.println(Logbuf.TRACE, "OutPortPushConnector create");
+ rtcout.println(Logbuf.PARANOID, "direct_dataput.disable= " +
+ prop.getProperty("direct_dataput.disable"));
+ // set direct InPort if ConnectorProfile
+ // .properties["dataport.outport.direct_dataput.disable"] != YES
+ if (!StringUtil.toBool(
+ prop.getProperty("direct_dataput.disable"),
+ "YES", "NO", true)) {
+ InPortBase inport = getLocalInPort(profile);
+ if (inport != null) {
+ connector.setInPort(inport);
+ }
+ }
+ // end of direct port
+
m_connectors.add(connector);
rtcout.println(Logbuf.PARANOID,
"connector push backed: "+m_connectors.size());
@@ -1566,6 +1584,44 @@
}
}
/**
+ * {@.ja ローカルのピアInPortを取得}
+ * {@.en Getting local peer InPort if available}
+ */
+ protected InPortBase
+ getLocalInPort(final ConnectorBase.ConnectorInfo profile)
+ {
+ rtcout.println(Logbuf.DEBUG,
+ "Trying direct port connection.");
+ ORB orb = Manager.instance().getORB();
+ rtcout.println(Logbuf.DEBUG,
+ "Current connector profile: name="
+ +profile.name + ", id=" + profile.id);
+ // finding peer port object
+ for (int ic = 0; ic < profile.ports.size() ; ++ic) {
+ Object obj;
+ obj = orb.string_to_object(profile.ports.get(ic));
+ if (getPortRef()._is_equivalent(obj)) {
+ continue;
+ }
+ rtcout.println(Logbuf.DEBUG, "Peer port found: "
+ + profile.ports.get(ic));
+ try {
+ POA poa = Manager.instance().getPOA();
+ //InPort inport = (InPort)poa.reference_to_servant(obj);
+ InPortBase inport = (InPortBase)(poa.reference_to_servant(obj));
+ rtcout.println(Logbuf.DEBUG,
+ "InPortBase servant pointer is obtained.");
+ return inport;
+ }
+ catch (Exception e) {
+ rtcout.println(Logbuf.TRACE, "126: "+e);
+ rtcout.println(Logbuf.DEBUG,
+ "Peer port is remote port.");
+ }
+ }
+ return null;
+ }
+ /**
* {@.ja endian 情報を返す}
* {@.en Returns endian information}
*
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/OutPortConnector.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/OutPortConnector.java 2016-02-09 13:15:52 UTC (rev 756)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/OutPortConnector.java 2016-02-15 01:11:49 UTC (rev 757)
@@ -28,6 +28,7 @@
rtcout = new Logbuf("OutPortConnector");
m_profile = profile;
m_isLittleEndian = true;
+ m_directInPort = null;
}
/**
@@ -128,6 +129,18 @@
*/
public abstract <DataType> ReturnCode write(final DataType data);
+
+ public boolean setInPort(InPortBase directInPort){
+ rtcout.println(Logbuf.TRACE, "setInPort()");
+ if (directInPort == null) {
+ rtcout.println(Logbuf.TRACE, "InPortBase is null.");
+ return false;
+ }
+
+ m_directInPort = directInPort;
+
+ return true;
+ }
/**
* {@.ja OutPortBaseを格納する。}
* {@.en Stores OutPortBase.}
@@ -142,5 +155,6 @@
protected Logbuf rtcout;
protected ConnectorInfo m_profile;
protected boolean m_isLittleEndian;
+ protected InPortBase m_directInPort;
}
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/OutPortPullConnector.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/OutPortPullConnector.java 2016-02-09 13:15:52 UTC (rev 756)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/OutPortPullConnector.java 2016-02-15 01:11:49 UTC (rev 757)
@@ -5,6 +5,7 @@
import jp.go.aist.rtm.RTC.buffer.BufferBase;
import jp.go.aist.rtm.RTC.log.Logbuf;
import jp.go.aist.rtm.RTC.util.ORBUtil;
+import jp.go.aist.rtm.RTC.util.DataRef;
import org.omg.CORBA.portable.OutputStream;
@@ -182,6 +183,15 @@
*/
public <DataType> ReturnCode write(final DataType data) {
rtcout.println(Logbuf.TRACE, "write()");
+
+ if (m_directInPort != null) {
+ DataRef<DataType> dataref
+ = new DataRef<DataType>(data);
+ //static_cast<InPort<DataType>*>(m_directInPort).write(data);
+ ((InPort)m_directInPort).write(dataref);
+ return ReturnCode.PORT_OK;
+ }
+
OutPort out = (OutPort)m_outport;
OutputStream cdr
= new EncapsOutputStreamExt(m_orb,m_isLittleEndian);
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/OutPortPushConnector.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/OutPortPushConnector.java 2016-02-09 13:15:52 UTC (rev 756)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/OutPortPushConnector.java 2016-02-15 01:11:49 UTC (rev 757)
@@ -10,6 +10,7 @@
import jp.go.aist.rtm.RTC.port.publisher.PublisherBase;
import jp.go.aist.rtm.RTC.util.ORBUtil;
import jp.go.aist.rtm.RTC.util.StringUtil;
+import jp.go.aist.rtm.RTC.util.DataRef;
import org.omg.CORBA.portable.OutputStream;
import org.omg.CORBA.portable.Streamable;
@@ -198,6 +199,15 @@
*/
public <DataType> ReturnCode write(final DataType data) {
rtcout.println(Logbuf.TRACE, "write()");
+
+ if (m_directInPort != null) {
+ DataRef<DataType> dataref
+ = new DataRef<DataType>(data);
+ //static_cast<InPort<DataType>*>(m_directInPort).write(data);
+ ((InPort)m_directInPort).write(dataref);
+ return ReturnCode.PORT_OK;
+ }
+
OutPort out = (OutPort)m_outport;
OutputStream cdr
= new EncapsOutputStreamExt(m_orb,m_isLittleEndian);
More information about the openrtm-commit
mailing list