[openrtm-commit:02061] r852 - trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port
openrtm @ openrtm.org
openrtm @ openrtm.org
2016年 10月 16日 (日) 13:14:45 JST
Author: win-ei
Date: 2016-10-16 13:14:45 +0900 (Sun, 16 Oct 2016)
New Revision: 852
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/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-14 05:11:15 UTC (rev 851)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/InPortSHMConsumer.java 2016-10-16 04:14:45 UTC (rev 852)
@@ -305,7 +305,6 @@
return false;
}
- //if (!super.setObject(obj)) {
if (!setObject(obj)) {
rtcout.println(Logbuf.WARN, "Setting object to consumer failed.");
return false;
@@ -348,7 +347,6 @@
return false;
}
- //if (!super.setObject(obj)) {
if (!setObject(obj)) {
rtcout.println(Logbuf.ERROR, "Setting object to consumer failed.");
return false;
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-14 05:11:15 UTC (rev 851)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/OutPortSHMConsumer.java 2016-10-16 04:14:45 UTC (rev 852)
@@ -7,6 +7,7 @@
import jp.go.aist.rtm.RTC.buffer.BufferBase;
import jp.go.aist.rtm.RTC.log.Logbuf;
import jp.go.aist.rtm.RTC.util.NVUtil;
+import jp.go.aist.rtm.RTC.util.POAUtil;
import jp.go.aist.rtm.RTC.util.Properties;
import org.omg.CORBA.BAD_OPERATION;
@@ -71,6 +72,7 @@
*/
public void init(Properties prop) {
rtcout.println(Logbuf.TRACE, "OutPortSHMConsumer.init()");
+ m_properties = prop;
}
/**
* <p>CORBAオブジェクトを設定します。</p>
@@ -84,8 +86,19 @@
Object ref = getObject();
if(ref!=null){
PortSharedMemory outportcdr = PortSharedMemoryHelper.narrow(ref);
- //outportcdr.setInterface(m_shmem);
- m_shmem.setInterface(outportcdr);
+ //outportcdr.setInterface((PortSharedMemory)m_shmem);
+ //outportcdr.setInterface(m_shmem._this(Manager.instance().getORB()));
+ PortSharedMemory objref;
+ try {
+ objref = OpenRTM.PortSharedMemoryHelper.narrow(
+ POAUtil.getRef(m_shmem));
+ }
+ catch (Exception e) {
+ return false; // object is null
+ }
+ outportcdr.setInterface(objref);
+
+ //m_shmem.setInterface(outportcdr);
return true;
}
}
@@ -188,8 +201,10 @@
m_outportcdr = outportcdr;
synchronized(m_mutex) {
+ //OpenRTM.PortStatus ret = _ptr().get();
OpenRTM.PortStatus ret = outportcdr.get();
- if (ret == OpenRTM.PortStatus.PORT_OK) {
+// if (ret == OpenRTM.PortStatus.PORT_OK) {
+ if (ret.equals(OpenRTM.PortStatus.PORT_OK)) {
rtcout.println(Logbuf.DEBUG, "get() successful");
//CdrDataHolder cdr_data = new CdrDataHolder();
m_shmem.read(cdr_data);
@@ -281,7 +296,8 @@
return false;
}
- if (!super.setObject(var)) {
+ //if (!super.setObject(var)) {
+ if (!setObject(var)) {
rtcout.println(Logbuf.ERROR,
"Invalid object reference.");
return false;
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-14 05:11:15 UTC (rev 851)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/OutPortSHMProvider.java 2016-10-16 04:14:45 UTC (rev 852)
@@ -51,16 +51,20 @@
*
*/
public OutPortSHMProvider() {
+System.out.println("- 2016/10/14 0a100 - ");
m_buffer = null;
rtcout = new Logbuf("OutPortSHMProvider");
// PortProfile setting
setInterfaceType("shared_memory");
+System.out.println("- 2016/10/14 0a200 - ");
// ConnectorProfile setting
m_objref = this._this();
// set outPort's reference
ORB orb = ORBUtil.getOrb();
+System.out.println("- 2016/10/14 0a200 - "+m_objref);
+System.out.println("- 2016/10/14 0a200 - "+orb.object_to_string(m_objref));
CORBA_SeqUtil.
push_back(m_properties,
NVUtil.newNVString("dataport.corba_cdr.outport_ior",
@@ -71,6 +75,7 @@
m_objref, OpenRTM.PortSharedMemory.class ));
m_shm_address = UUID.randomUUID().toString();
+System.out.println("- 2016/10/14 0a800 - ");
}
/**
* {@.ja 当該OpenRTM.PortSharedMemoryのCORBAオブジェクト参照を取得する。}
@@ -82,20 +87,24 @@
*
*/
public OpenRTM.PortSharedMemory _this() {
+System.out.println("- 2016/10/14 0b100 - ");
if (this.m_objref == null) {
+System.out.println("- 2016/10/14 0b200 - ");
try {
this.m_objref
= OpenRTM.PortSharedMemoryHelper.narrow(POAUtil.getRef(this));
-
+
+System.out.println("- 2016/10/14 0b300 - ");
} catch (Exception e) {
+System.out.println("- 2016/10/14 0be00 - ");
throw new IllegalStateException(e);
}
}
+System.out.println("- 2016/10/14 0b800 - ");
return this.m_objref;
}
-
/**
*
* {@.ja 設定初期化}
@@ -120,7 +129,7 @@
*/
public void init(Properties prop) {
String ds = prop.getProperty("shem_default_size");
- m_memory_size = (int)m_shmem.string_to_MemorySize(ds);
+ m_memory_size = (int)string_to_MemorySize(ds);
}
/**
@@ -165,6 +174,9 @@
*
*/
public OpenRTM.PortStatus get(OpenRTM.CdrDataHolder data) {
+ return OpenRTM.PortStatus.UNKNOWN_ERROR;
+/*
+System.out.println("- 2016/10/14 04100 - ");
rtcout.println(Logbuf.PARANOID, "OutPortSHMProvider.get()");
if (m_buffer == null) {
@@ -178,10 +190,12 @@
return OpenRTM.PortStatus.BUFFER_EMPTY;
}
OutputStream cdr = null;
+System.out.println("- 2016/10/14 04200 - ");
DataRef<OutputStream> cdr_ref = new DataRef<OutputStream>(cdr);
jp.go.aist.rtm.RTC.buffer.ReturnCode ret
= m_buffer.read(cdr_ref,0,0);
+System.out.println("- 2016/10/14 04300 - ");
if (ret.equals(jp.go.aist.rtm.RTC.buffer.ReturnCode.BUFFER_OK)) {
EncapsOutputStreamExt outcdr;
@@ -193,9 +207,13 @@
}
}
+System.out.println("- 2016/10/14 04400 - ");
create_memory(m_memory_size, m_shm_address);
+System.out.println("- 2016/10/14 04500 - ");
write(data);
+System.out.println("- 2016/10/14 04600 - ");
return convertReturn(ret);
+*/
}
/**
* {@.ja ReturnCodeをPortStatusに変換する。}
@@ -577,7 +595,8 @@
* {@.en name of memory}
# void open_memory(int memory_size, string shm_address);
*/
- public void open_memory (int memory_size, String shm_address){
+// public void open_memory (int memory_size, String shm_address){
+/*
rtcout.println(Logbuf.TRACE,
"open():memory_size="
+ memory_size +",shm_address=" + shm_address);
@@ -590,6 +609,7 @@
catch(Exception ex) {
rtcout.println(Logbuf.ERROR,"Open error "+ex.toString() );
}
+*/
/*
self._rtcout.RTC_TRACE("open():memory_size="+str(memory_size)+",shm_address="+str(shm_address))
self._memory_size = memory_size
@@ -607,7 +627,7 @@
self.rt.close( self.fd )
*/
- }
+// }
/**
*
* {@.ja 共有メモリの初期化}
@@ -625,6 +645,7 @@
* {@.en name of memory}
* # void create_memory(int memory_size, string shm_address);
*/
+/*
public void create_memory (int memory_size, String shm_address){
rtcout.println(Logbuf.TRACE,
"create():memory_size="
@@ -632,6 +653,7 @@
m_memory_size = memory_size;
m_shm_address = shm_address;
}
+*/
/**
*
* {@.ja マッピングした共有メモリをアンマップする}
@@ -679,17 +701,59 @@
* {@.ja SharedMemoryのオブジェクトリファレンス}
* {@.en Object reference of shared momory}
*/
+/*
public void setInterface (OpenRTM.PortSharedMemory sm){
- //self._smInterface = sm
+ m_smInterface = sm
}
-
+*/
/**
*
* {@.ja データの送信を要求する}
* {@.en Get data.}
*/
public OpenRTM.PortStatus get(){
- return OpenRTM.PortStatus.UNKNOWN_ERROR;
+System.out.println("- 2016/10/14 04100 - ");
+ rtcout.println(Logbuf.PARANOID, "OutPortSHMProvider.get()");
+
+ if (m_buffer == null) {
+ onSenderError();
+ rtcout.println(Logbuf.PARANOID, "m_buffer is null.");
+System.out.println("- 2016/10/14 04120 - ");
+ return OpenRTM.PortStatus.UNKNOWN_ERROR;
+ }
+
+ if (m_buffer.empty()) {
+ rtcout.println(Logbuf.PARANOID, "m_buffer is empty.");
+System.out.println("- 2016/10/14 04130 - ");
+ return OpenRTM.PortStatus.BUFFER_EMPTY;
+ }
+ OutputStream cdr = null;
+ OpenRTM.CdrDataHolder data = new OpenRTM.CdrDataHolder();
+System.out.println("- 2016/10/14 04200 - ");
+ DataRef<OutputStream> cdr_ref = new DataRef<OutputStream>(cdr);
+ jp.go.aist.rtm.RTC.buffer.ReturnCode ret
+ = m_buffer.read(cdr_ref,0,0);
+
+System.out.println("- 2016/10/14 04300 - "+ret);
+ if (ret.equals(jp.go.aist.rtm.RTC.buffer.ReturnCode.BUFFER_OK)) {
+
+System.out.println("- 2016/10/14 04350 - ");
+ EncapsOutputStreamExt outcdr;
+ outcdr = (EncapsOutputStreamExt)cdr_ref.v;
+ data.value = outcdr.getByteArray();
+ if(data.value.length==0){
+System.out.println("- 2016/10/14 043e0 - "+"m_buffer is empty.");
+ rtcout.println(Logbuf.PARANOID, "m_buffer is empty.");
+ return OpenRTM.PortStatus.BUFFER_EMPTY;
+ }
+
+ }
+System.out.println("- 2016/10/14 04400 - "+m_memory_size+" "+m_shm_address);
+ create_memory(m_memory_size, m_shm_address);
+System.out.println("- 2016/10/14 04500 - ");
+ write(data);
+System.out.println("- 2016/10/14 04600 - ");
+ return convertReturn(ret);
}
/**
*
@@ -711,7 +775,7 @@
private ConnectorListeners m_listeners;
private ConnectorBase.ConnectorInfo m_profile;
- private SharedMemory m_shmem = new SharedMemory();
+ //private SharedMemory m_shmem = new SharedMemory();
private String m_shm_address = new String();
private int m_memory_size;
}
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-14 05:11:15 UTC (rev 851)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/SharedMemory.java 2016-10-16 04:14:45 UTC (rev 852)
@@ -185,6 +185,7 @@
rtcout.println(Logbuf.TRACE, "write()");
try{
RandomAccessFile file = new RandomAccessFile(m_shm_address, "rw");
+file.setLength(m_memory_size);
FileChannel channel = file.getChannel();
int length = (int)channel.size();
MappedByteBuffer buffer
@@ -193,7 +194,6 @@
LongHolder len = new LongHolder(data.value.length);
- //OutputStream cdr
EncapsOutputStreamExt cdr
= new EncapsOutputStreamExt(ORBUtil.getOrb(),true);
len._write(cdr);
@@ -265,7 +265,7 @@
* {@.en Object reference of shared momory}
# void close(int memory_size, string shm_address);
*/
- public void setInterface (OpenRTM.PortSharedMemory sm){
+ public void setInterface(OpenRTM.PortSharedMemory sm){
m_smInterface = sm;
}
More information about the openrtm-commit
mailing list