[openrtm-commit:01867] r801 - in trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC: . port
openrtm @ openrtm.org
openrtm @ openrtm.org
2016年 3月 21日 (月) 19:44:58 JST
Author: win-ei
Date: 2016-03-21 19:44:58 +0900 (Mon, 21 Mar 2016)
New Revision: 801
Modified:
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/FactoryInit.java
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/InPortBase.java
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/InPortConnector.java
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/InPortPullConnector.java
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/InPortPushConnector.java
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/OutPort.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
Log:
Direct data put functionality between data ports has been implemented. refs #3225
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/FactoryInit.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/FactoryInit.java 2016-03-14 09:43:15 UTC (rev 800)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/FactoryInit.java 2016-03-21 10:44:58 UTC (rev 801)
@@ -11,6 +11,8 @@
import jp.go.aist.rtm.RTC.port.OutPortCorbaCdrConsumer;
import jp.go.aist.rtm.RTC.port.InPortDirectProvider;
import jp.go.aist.rtm.RTC.port.InPortDirectConsumer;
+import jp.go.aist.rtm.RTC.port.OutPortDirectProvider;
+import jp.go.aist.rtm.RTC.port.OutPortDirectConsumer;
import jp.go.aist.rtm.RTC.port.InPortSHMProvider;
import jp.go.aist.rtm.RTC.port.InPortSHMConsumer;
import jp.go.aist.rtm.RTC.port.OutPortSHMProvider;
@@ -49,8 +51,11 @@
InPortCorbaCdrConsumer.InPortCorbaCdrConsumerInit();
OutPortCorbaCdrConsumer.OutPortCorbaCdrConsumerInit();
OutPortCorbaCdrProvider.OutPortCorbaCdrProviderInit();
+
InPortDirectProvider.InPortDirectProviderInit();
InPortDirectConsumer.InPortDirectConsumerInit();
+ OutPortDirectProvider.OutPortDirectProviderInit();
+ OutPortDirectConsumer.OutPortDirectConsumerInit();
InPortSHMProvider.InPortSHMProviderInit();
InPortSHMConsumer.InPortSHMConsumerInit();
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-03-14 09:43:15 UTC (rev 800)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/InPort.java 2016-03-21 10:44:58 UTC (rev 801)
@@ -516,6 +516,14 @@
"isEmpty() = false, data exists in the buffer");
return false;
}
+ /**
+ * {@.ja データ書き込み}
+ * {@.en Write data}
+ * @param value
+ * {@.ja 書き込み対象データ}
+ * {@.en The target data for writing}
+ *
+ */
public void write(final DataRef<DataType> data)
{
rtcout.println(Logbuf.TRACE, "write()");
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/InPortBase.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/InPortBase.java 2016-03-14 09:43:15 UTC (rev 800)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/InPortBase.java 2016-03-21 10:44:58 UTC (rev 801)
@@ -6,6 +6,7 @@
import java.util.Vector;
import jp.go.aist.rtm.Constants;
+import jp.go.aist.rtm.RTC.Manager;
import jp.go.aist.rtm.RTC.BufferFactory;
import jp.go.aist.rtm.RTC.InPortProviderFactory;
import jp.go.aist.rtm.RTC.OutPortConsumerFactory;
@@ -17,8 +18,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;
@@ -1387,7 +1391,7 @@
"old compiler? new returned 0;");
return null;
}
- rtcout.println(Logbuf.TRACE, "InPortPushConnector create");
+ rtcout.println(Logbuf.TRACE, "InPortPushConnector created");
m_connectors.add(connector);
rtcout.println(Logbuf.PARANOID,
@@ -1440,7 +1444,23 @@
"old compiler? new returned 0;");
return null;
}
- rtcout.println(Logbuf.TRACE, "InPortPullConnector create");
+ rtcout.println(Logbuf.TRACE, "InPortPullConnector created");
+
+ String type = prop.getProperty("interface_type").trim();
+ rtcout.println(Logbuf.PARANOID, "interface_type= " + type);
+ // "interface_type" == "direct"
+ if (type.equals("direct")) {
+ OutPortBase outport = getLocalOutPort(profile);
+ if (outport == null) {
+ rtcout.println(Logbuf.DEBUG,
+ "interface_type is direct, " +
+ "but a peer InPort servant could not be obtained.");
+ //delete connector;
+ return null;
+ }
+ connector.setOutPort(outport);
+ }
+ // end of direct interface_type
m_connectors.add(connector);
rtcout.println(Logbuf.PARANOID,
@@ -1456,6 +1476,44 @@
}
/**
+ * {@.ja ローカルのピアOutPortを取得}
+ * {@.en Getting local peer OutPort if available}
+ */
+ protected OutPortBase
+ getLocalOutPort(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);
+ OutPortBase outport = (OutPortBase)(poa.reference_to_servant(obj));
+ rtcout.println(Logbuf.DEBUG,
+ "OutPortBase servant pointer is obtained.");
+ return outport;
+ }
+ catch (Exception e) {
+ rtcout.println(Logbuf.TRACE, "126: "+e);
+ rtcout.println(Logbuf.DEBUG,
+ "Peer port might be a remote port.");
+ }
+ }
+ return null;
+ }
+ /**
* {@.ja リスナホルダを取得する}
* {@.en Getting listeners holder}
*
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/InPortConnector.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/InPortConnector.java 2016-03-14 09:43:15 UTC (rev 800)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/InPortConnector.java 2016-03-21 10:44:58 UTC (rev 801)
@@ -36,6 +36,7 @@
m_isLittleEndian = true;
m_orb = ORBUtil.getOrb();
m_listeners = listeners;
+ m_directOutPort = null;
}
@@ -165,7 +166,30 @@
*
*/
public abstract ReturnCode read(DataRef<InputStream> data);
+ /**
+ * {@.ja OutPortのオブジェクトを設定する。}
+ * {@.en Sets the object of OutPort}
+ * <p>
+ * {@.ja ダイレクトポートのためにOutPortrBaseのオブジェクトを設定する。}
+ * {@.en Set an object of OutPortBase for a direct port.}
+ * @param directOutPort
+ * {@.ja OutPortBase オブジェクト}
+ * {@.en OutPortBase object}
+ *
+ */
+ public boolean setOutPort(OutPortBase directOutPort){
+ rtcout.println(Logbuf.TRACE, "setOutPort()");
+ if (directOutPort == null) {
+ rtcout.println(Logbuf.TRACE, "OutPortBase is null.");
+ return false;
+ }
+ m_directOutPort = directOutPort;
+ m_outPortListeners = m_directOutPort.getListeners();
+
+ return true;
+ }
+
protected Logbuf rtcout;
protected ConnectorInfo m_profile;
protected BufferBase<OutputStream> m_buffer;
@@ -176,6 +200,16 @@
* {@.en A reference to a ConnectorListener}
*/
ConnectorListeners m_listeners;
+ /**
+ * {@.ja 同一プロセス上のピアOutPortのポインタ}
+ * {@.en OutProt pointer to the peer in the same process}
+ */
+ protected OutPortBase m_directOutPort;
+ /**
+ * {@.ja OutPort 側の ConnectorListenrs への参照}
+ * {@.en A pointer to a OutPort's ConnectorListener}
+ */
+ protected ConnectorListeners m_outPortListeners = new ConnectorListeners();
}
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/InPortPullConnector.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/InPortPullConnector.java 2016-03-14 09:43:15 UTC (rev 800)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/InPortPullConnector.java 2016-03-21 10:44:58 UTC (rev 801)
@@ -147,6 +147,15 @@
*/
public ReturnCode read(DataRef<InputStream> data){
rtcout.println(Logbuf.TRACE, "InPortPullConnector.read()");
+ if (m_directOutPort != null) {
+ OutPort outport = (OutPort)m_directOutPort;
+ //DataRef<DataType> dataref
+ // = new DataRef<DataType>(data);
+ outport.read(data);
+ // ON_RECEIVED(In,Out) callback
+ return ReturnCode.PORT_OK;
+
+ }
if (m_consumer == null) {
return ReturnCode.PORT_ERROR;
}
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/InPortPushConnector.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/InPortPushConnector.java 2016-03-14 09:43:15 UTC (rev 800)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/InPortPushConnector.java 2016-03-21 10:44:58 UTC (rev 801)
@@ -119,6 +119,15 @@
*/
public ReturnCode read(DataRef<InputStream> data) {
rtcout.println(Logbuf.TRACE, "read()");
+ if (m_directOutPort != null) {
+ OutPort outport = (OutPort)m_directOutPort;
+ //DataRef<DataType> dataref
+ // = new DataRef<DataType>(data);
+ outport.read(data);
+ // ON_RECEIVED(In,Out) callback
+ return ReturnCode.PORT_OK;
+
+ }
/*
* buffer returns
* BUFFER_OK
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/OutPort.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/OutPort.java 2016-03-14 09:43:15 UTC (rev 800)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/OutPort.java 2016-03-21 10:44:58 UTC (rev 801)
@@ -313,6 +313,19 @@
rtcout.println(Logbuf.TRACE, "OnWrite called");
}
+ // 1) direct connection
+ synchronized (m_directNewDataMutex){
+ rtcout.println(Logbuf.DEBUG, "Direct data transfer");
+ if (m_OnWriteConvert != null) {
+ m_value.v = m_OnReadConvert.run(m_value.v);
+ rtcout.println(Logbuf.DEBUG,
+ "OnReadConvert for direct data called");
+ m_OnWriteConvert.run(value);
+ m_value.v = value;
+ return true;
+ }
+ }
+ // 2) network connection
boolean result = true;
Vector<String> disconnect_ids = new Vector<String>();
synchronized (m_connectorsMutex){
@@ -679,7 +692,19 @@
return false;
}
+ /**
+ * {@.ja 値を読み出す}
+ * {@.en Readout the value}
+ * <p>
+ */
+ public void read(DataRef<DataType> data) {
+ rtcout.println(Logbuf.TRACE, "read()");
+ synchronized (m_value){
+ data.v = m_value.v;
+ }
+ }
+
private BufferBase<DataType> m_buffer;
private DataRef<DataType> m_value;
private long m_timeoutTick;
@@ -701,4 +726,7 @@
private Streamable m_streamable = null;
private Field m_field = null;
private Vector<ReturnCode> m_status = new Vector<ReturnCode>();
+
+ 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-03-14 09:43:15 UTC (rev 800)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/OutPortBase.java 2016-03-21 10:44:58 UTC (rev 801)
@@ -1645,6 +1645,22 @@
return null;
}
/**
+ * {@.ja リスナホルダを取得する}
+ * {@.en Getting listeners holder}
+ *
+ * <p>
+ * {@.ja OutPortBaseが保持するリスナホルダを返す。}
+ * {@.en This operation returns listeners holder.}
+ *
+ * @return
+ * {@.ja ConnectorListeners}
+ * {@.en ConnectorListeners}
+ *
+ */
+ public ConnectorListeners getListeners(){
+ return m_listeners;
+ }
+ /**
* {@.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-03-14 09:43:15 UTC (rev 800)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/OutPortConnector.java 2016-03-21 10:44:58 UTC (rev 801)
@@ -132,6 +132,17 @@
public abstract <DataType> ReturnCode write(final DataType data);
+ /**
+ * {@.ja InPortのオブジェクトを設定する。}
+ * {@.en Sets the object of InPort}
+ * <p>
+ * {@.ja ダイレクトポートのためにInPortrBaseのオブジェクトを設定する。}
+ * {@.en Set an object of InPortBase for a direct port.}
+ * @param directInPort
+ * {@.ja InPortBase オブジェクト}
+ * {@.en InPortBase object}
+ *
+ */
public boolean setInPort(InPortBase directInPort){
rtcout.println(Logbuf.TRACE, "setInPort()");
if (directInPort == null) {
More information about the openrtm-commit
mailing list