[openrtm-commit:02049] r849 - trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port
openrtm @ openrtm.org
openrtm @ openrtm.org
2016年 10月 13日 (木) 10:18:06 JST
Author: win-ei
Date: 2016-10-13 10:18:06 +0900 (Thu, 13 Oct 2016)
New Revision: 849
Modified:
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/InPortSHMConsumer.java
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/InPortSHMProvider.java
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/OutPortSHMConsumer.java
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/OutPortSHMProvider.java
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/SharedMemory.java
Log:
Fixed bugs. refs #3395
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/InPortSHMConsumer.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/InPortSHMConsumer.java 2016-10-12 14:39:15 UTC (rev 848)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/InPortSHMConsumer.java 2016-10-13 01:18:06 UTC (rev 849)
@@ -76,6 +76,24 @@
String ds = prop.getProperty("shem_default_size");
m_memory_size = (int)m_shmem.string_to_MemorySize(ds);
}
+ /**
+ * <p>CORBAオブジェクトを設定します。</p>
+ *
+ * @param obj CORBAオブジェクト
+ * @return 設定に成功した場合はtrueを、さもなくばflaseを返します。
+ */
+ public boolean setObject(Object obj) {
+
+ if (super.setObject(obj)) {
+ Object ref = getObject();
+ if(ref!=null){
+ PortSharedMemory inportcdr = PortSharedMemoryHelper.narrow(ref);
+ m_shmem.setInterface(inportcdr);
+ return true;
+ }
+ }
+ return false; // object is null
+ }
/**
* <p> Send data to the destination port </p>
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/InPortSHMProvider.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/InPortSHMProvider.java 2016-10-12 14:39:15 UTC (rev 848)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/InPortSHMProvider.java 2016-10-13 01:18:06 UTC (rev 849)
@@ -17,6 +17,7 @@
import org.omg.CORBA.portable.OutputStream;
import OpenRTM.PortSharedMemoryPOA;
+import OpenRTM.CdrDataHolder;
import _SDOPackage.NVListHolder;
import java.io.File;
@@ -26,6 +27,7 @@
import java.nio.channels.FileChannel;
import java.nio.channels.FileChannel.MapMode;
+
/**
* {@.ja InPortSHMProvider クラス}
* {@.en InPortSHMProvider class}
@@ -37,7 +39,8 @@
*
*
*/
-public class InPortSHMProvider extends PortSharedMemoryPOA implements InPortProvider, ObjectCreator<InPortProvider>, ObjectDestructor {
+//public class InPortSHMProvider extends PortSharedMemoryPOA implements InPortProvider, ObjectCreator<InPortProvider>, ObjectDestructor {
+public class InPortSHMProvider extends SharedMemory implements InPortProvider, ObjectCreator<InPortProvider>, ObjectDestructor {
/**
* {@.ja コンストラクタ}
* {@.en Constructor}
@@ -152,26 +155,38 @@
rtcout.println(Logbuf.PARANOID, "InPortSHMProvider.put()");
+ CdrDataHolder cdr_data = new CdrDataHolder();
+ read(cdr_data);
+// for(int ic=0;ic<cdr_data.value.length;++ic){
+// data[ic] = cdr_data.value[ic];
+// }
+
if (m_buffer == null) {
EncapsOutputStreamExt cdr
= new EncapsOutputStreamExt(m_orb,m_connector.isLittleEndian());
- cdr.write_octet_array(data, 0, data.length);
+ cdr.write_octet_array(cdr_data.value, 0, data.length);
onReceiverError(cdr);
return OpenRTM.PortStatus.PORT_ERROR;
}
- rtcout.println(Logbuf.PARANOID, "received data size: "+data.length);
+ rtcout.println(Logbuf.PARANOID, "received data size: "+cdr_data.value.length);
EncapsOutputStreamExt cdr
= new EncapsOutputStreamExt(m_orb,m_connector.isLittleEndian());
- cdr.write_octet_array(data, 0, data.length);
+ cdr.write_octet_array(cdr_data.value, 0, cdr_data.value.length);
int len = cdr.getByteArray().length;
rtcout.println(Logbuf.PARANOID, "converted CDR data size: "+len);
onReceived(cdr);
+
+ if(m_connector==null){
+ return OpenRTM.PortStatus.PORT_ERROR;
+ }
+
jp.go.aist.rtm.RTC.buffer.ReturnCode ret = m_buffer.write(cdr);
+ //jp.go.aist.rtm.RTC.buffer.ReturnCode ret = m_connector.write(cdr);
return convertReturn(ret,cdr);
}
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/OutPortSHMConsumer.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/OutPortSHMConsumer.java 2016-10-12 14:39:15 UTC (rev 848)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/OutPortSHMConsumer.java 2016-10-13 01:18:06 UTC (rev 849)
@@ -72,6 +72,25 @@
public void init(Properties prop) {
rtcout.println(Logbuf.TRACE, "OutPortSHMConsumer.init()");
}
+ /**
+ * <p>CORBAオブジェクトを設定します。</p>
+ *
+ * @param obj CORBAオブジェクト
+ * @return 設定に成功した場合はtrueを、さもなくばflaseを返します。
+ */
+ public boolean setObject(Object obj) {
+
+ if (super.setObject(obj)) {
+ Object ref = getObject();
+ if(ref!=null){
+ PortSharedMemory outportcdr = PortSharedMemoryHelper.narrow(ref);
+ //outportcdr.setInterface(m_shmem);
+ m_shmem.setInterface(outportcdr);
+ return true;
+ }
+ }
+ return false; // object is null
+ }
/**
* {@.ja バッファをセットする}
@@ -172,13 +191,13 @@
OpenRTM.PortStatus ret = outportcdr.get();
if (ret == OpenRTM.PortStatus.PORT_OK) {
rtcout.println(Logbuf.DEBUG, "get() successful");
+ //CdrDataHolder cdr_data = new CdrDataHolder();
+ m_shmem.read(cdr_data);
data.write_octet_array(cdr_data.value, 0,
cdr_data.value.length);
rtcout.println(Logbuf.PARANOID,
"CDR data length: "+cdr_data.value.length);
- //CdrDataHolder cdr_data = new CdrDataHolder();
- m_shmem.read(cdr_data);
onReceived(data);
onBufferWrite(data);
if (m_buffer.full()) {
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/OutPortSHMProvider.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/OutPortSHMProvider.java 2016-10-12 14:39:15 UTC (rev 848)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/OutPortSHMProvider.java 2016-10-13 01:18:06 UTC (rev 849)
@@ -43,7 +43,8 @@
* provider}
*
*/
-public class OutPortSHMProvider extends PortSharedMemoryPOA implements OutPortProvider, ObjectCreator<OutPortProvider>, ObjectDestructor {
+//public class OutPortSHMProvider extends PortSharedMemoryPOA implements OutPortProvider, ObjectCreator<OutPortProvider>, ObjectDestructor {
+public class OutPortSHMProvider extends SharedMemory implements OutPortProvider, ObjectCreator<OutPortProvider>, ObjectDestructor {
/**
* {@.ja コンストラクタ}
* {@.en Constructor}
@@ -172,6 +173,10 @@
return OpenRTM.PortStatus.UNKNOWN_ERROR;
}
+ if (m_buffer.empty()) {
+ rtcout.println(Logbuf.PARANOID, "m_buffer is empty.");
+ return OpenRTM.PortStatus.BUFFER_EMPTY;
+ }
OutputStream cdr = null;
DataRef<OutputStream> cdr_ref = new DataRef<OutputStream>(cdr);
jp.go.aist.rtm.RTC.buffer.ReturnCode ret
@@ -182,8 +187,14 @@
EncapsOutputStreamExt outcdr;
outcdr = (EncapsOutputStreamExt)cdr_ref.v;
data.value = outcdr.getByteArray();
+ if(data.value.length==0){
+ rtcout.println(Logbuf.PARANOID, "m_buffer is empty.");
+ return OpenRTM.PortStatus.BUFFER_EMPTY;
+ }
}
+ create_memory(m_memory_size, m_shm_address);
+ write(data);
return convertReturn(ret);
}
/**
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/SharedMemory.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/SharedMemory.java 2016-10-12 14:39:15 UTC (rev 848)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/SharedMemory.java 2016-10-13 01:18:06 UTC (rev 849)
@@ -229,7 +229,7 @@
/**
*
* {@.ja データを書き込む}
- * {@.en Wwrites in data.}
+ * {@.en Writes in data.}
* <p>
* {@.ja 先頭8byteにデータサイズを書き込み、その後ろにデータを書き込む
* 設定したデータサイズが共有メモリのサイズを上回った場合、
More information about the openrtm-commit
mailing list