[openrtm-commit:02457] r951 - trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port
openrtm @ openrtm.org
openrtm @ openrtm.org
2017年 2月 17日 (金) 23:41:35 JST
Author: win-ei
Date: 2017-02-17 23:41:34 +0900 (Fri, 17 Feb 2017)
New Revision: 951
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/InPortBase.java
Log:
[FSM4RTC] for multi-buffer mode. refs #3780
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 2017-02-16 08:33:23 UTC (rev 950)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/InPort.java 2017-02-17 14:41:34 UTC (rev 951)
@@ -2,6 +2,7 @@
import java.lang.reflect.Field;
import java.lang.reflect.Method;
+import java.util.ArrayList;
import jp.go.aist.rtm.RTC.buffer.BufferBase;
import jp.go.aist.rtm.RTC.buffer.RingBuffer;
@@ -256,6 +257,40 @@
rtcout.println(Logbuf.DEBUG, "isNew() = false, no readable data");
return false;
}
+ /**
+ *
+ */
+ public boolean isNew(ArrayList<String> names) {
+
+ 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;
+ }
+ }
+ boolean ret = false;
+ synchronized (m_connectorsMutex){
+ synchronized (m_connectors){
+ if (m_connectors.size() == 0) {
+ rtcout.println(Logbuf.DEBUG, "no connectors");
+ return false;
+ }
+ for(int ic=0;ic<m_connectors.size();++ic){
+ r = m_connectors.elementAt(ic).getBuffer().readable();
+ if (r > 0) {
+ names.add(m_connectors.elementAt(ic).name());
+ ret = true;
+ }
+ }
+ }
+ }
+
+ return ret;
+ }
/**
@@ -368,7 +403,6 @@
}
//ret = m_connectors.elementAt(0).read(dataref);
- int index = 0;
for(int ic=0;ic<m_connectors.size();++ic){
ret = m_connectors.elementAt(ic).read(dataref);
if (ret.equals(ReturnCode.PORT_OK)) {
@@ -402,6 +436,77 @@
}
}
+ /**
+ *
+ */
+ public boolean read(String name) {
+ 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){
+ ReturnCode ret = ReturnCode.PORT_OK;
+ EncapsOutputStreamExt cdr = new EncapsOutputStreamExt(m_orb,
+ isLittleEndian());
+ DataRef<InputStream> dataref
+ = new DataRef<InputStream>(cdr.create_input_stream());
+ synchronized (m_connectors){
+
+ if (m_connectors.size() == 0) {
+ rtcout.println(Logbuf.DEBUG, "no connectors");
+ return false;
+ }
+
+ for(int ic=0;ic<m_connectors.size();++ic){
+ if (m_connectors.elementAt(ic).name().equals(name)) {
+ ret = m_connectors.elementAt(ic).read(dataref);
+ }
+ }
+ }
+
+ if (ret.equals(ReturnCode.PORT_OK)) {
+ rtcout.println(Logbuf.DEBUG, "data read succeeded");
+
+ m_value.v = read_stream(m_value,dataref.v);
+ if (m_OnReadConvert != null) {
+ m_value.v = m_OnReadConvert.run(m_value.v);
+ rtcout.println(Logbuf.DEBUG, "OnReadConvert called");
+ return true;
+ }
+ return true;
+ }
+ else if (ret.equals(ReturnCode.BUFFER_EMPTY)) {
+ rtcout.println(Logbuf.WARN, "buffer empty");
+ return false;
+ }
+ else if (ret.equals(ReturnCode.BUFFER_TIMEOUT)) {
+ rtcout.println(Logbuf.WARN, "buffer read timeout");
+ return false;
+ }
+ rtcout.println(Logbuf.ERROR,
+ "unknown retern value from buffer.read()");
+ return false;
+
+ }
+ }
/**
* <p>バインドされたDataType型のデータに、ポート内バッファの最新値を読み込みます。<br />
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 2017-02-16 08:33:23 UTC (rev 950)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/InPortBase.java 2017-02-17 14:41:34 UTC (rev 951)
@@ -58,7 +58,8 @@
rtcout.println(Logbuf.DEBUG, "Port name: "+name);
- m_singlebuffer = true;
+ //m_singlebuffer = true;
+ m_singlebuffer = false;
m_thebuffer = null;
m_isLittleEndian = true;
// Set PortProfile::properties
openrtm-commit メーリングリストの案内