[openrtm-commit:01030] r704 - in trunk/jp.go.aist.rtm.RTC: src/jp/go/aist/rtm/RTC/port tests/src/jp/go/aist/rtm tests/src/jp/go/aist/rtm/RTC/port
openrtm @ openrtm.org
openrtm @ openrtm.org
2013年 3月 6日 (水) 02:51:10 JST
Author: ga
Date: 2013-03-06 02:51:10 +0900 (Wed, 06 Mar 2013)
New Revision: 704
Modified:
trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/InPortPullConnector.java
trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/InPortPushConnector.java
trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/OutPortPullConnector.java
trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/OutPortPushConnector.java
trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/AllTest110.java
trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/InPortPushConnectorTest.java
trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/OutPortPushConnectorTest.java
Log:
Modified buffer and connector refs.#2561
Modified: trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/InPortPullConnector.java
===================================================================
--- trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/InPortPullConnector.java 2013-03-03 02:55:53 UTC (rev 703)
+++ trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/InPortPullConnector.java 2013-03-05 17:51:10 UTC (rev 704)
@@ -103,10 +103,15 @@
m_listeners = listeners;
rtcout = new Logbuf("InPortPullConnector");
+ if (m_consumer == null) {
+ throw new Exception("bad_alloc()");
+ }
+ m_consumer.init(profile.properties);
+
if (buffer == null) {
m_buffer = createBuffer(m_profile);
}
- if (m_buffer == null || m_consumer == null) {
+ if (m_buffer == null) {
throw new Exception("bad_alloc()");
}
m_buffer.init(profile.properties.getNode("buffer"));
Modified: trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/InPortPushConnector.java
===================================================================
--- trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/InPortPushConnector.java 2013-03-03 02:55:53 UTC (rev 703)
+++ trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/InPortPushConnector.java 2013-03-05 17:51:10 UTC (rev 704)
@@ -62,23 +62,22 @@
m_deleteBuffer = false;
}
+ if (m_provider==null) {
+ rtcout.println(Logbuf.PARANOID, " m_provider is null.");
+ throw new Exception("bad_alloc()");
+ }
+ m_provider.init(profile.properties);
+
// publisher/buffer creation. This may throw std::bad_alloc;
if (m_buffer == null) {
m_buffer = createBuffer(profile);
}
- if (m_buffer == null || m_provider==null) {
- if(m_buffer == null){
- rtcout.println(Logbuf.PARANOID, " m_buffer is null.");
- }
- if(m_provider == null){
- rtcout.println(Logbuf.PARANOID, " m_provider is null.");
- }
-
+ if (m_buffer == null) {
+ rtcout.println(Logbuf.PARANOID, " m_buffer is null.");
throw new Exception("bad_alloc()");
}
m_buffer.init(profile.properties.getNode("buffer"));
- m_provider.init(profile.properties);
m_provider.setBuffer(m_buffer);
m_provider.setListener(profile, m_listeners);
Modified: trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/OutPortPullConnector.java
===================================================================
--- trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/OutPortPullConnector.java 2013-03-03 02:55:53 UTC (rev 703)
+++ trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/OutPortPullConnector.java 2013-03-05 17:51:10 UTC (rev 704)
@@ -147,19 +147,24 @@
m_buffer = buffer;
m_listeners = listeners;
m_orb = ORBUtil.getOrb();
+
+ if (m_provider == null) {
+ throw new Exception("bad_alloc()");
+ }
+ m_provider.init(profile.properties);
+
// create buffer
if (m_buffer == null) {
m_buffer = createBuffer(profile);
}
- if (m_provider == null || m_buffer == null) {
+ if (m_buffer == null) {
throw new Exception("bad_alloc()");
}
m_buffer.init(profile.properties.getNode("buffer"));
m_provider.setBuffer(m_buffer);
m_provider.setConnector(this);
- // m_provider.init(m_profile /* , m_listeners */);
m_provider.setListener(profile, m_listeners);
onConnect();
Modified: trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/OutPortPushConnector.java
===================================================================
--- trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/OutPortPushConnector.java 2013-03-03 02:55:53 UTC (rev 703)
+++ trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/OutPortPushConnector.java 2013-03-05 17:51:10 UTC (rev 704)
@@ -124,21 +124,24 @@
m_buffer = buffer;
m_listeners = listeners;
+ if (m_consumer == null) {
+ rtcout.println(Logbuf.PARANOID, "m_consumer is null");
+ throw new Exception("bad_alloc()");
+ }
+ m_consumer.init(profile.properties);
+
// publisher/buffer creation. This may throw std::bad_alloc;
m_publisher = createPublisher(profile);
if (m_buffer == null) {
m_buffer = createBuffer(profile);
}
- if (m_publisher == null || m_buffer == null || m_consumer == null) {
+ if (m_publisher == null || m_buffer == null) {
if (m_publisher == null) {
rtcout.println(Logbuf.PARANOID, "m_publisher is null");
}
if (m_buffer == null) {
rtcout.println(Logbuf.PARANOID, "m_buffer is null");
}
- if (m_consumer == null) {
- rtcout.println(Logbuf.PARANOID, "m_consumer is null");
- }
throw new Exception("bad_alloc()");
}
@@ -147,8 +150,6 @@
throw new Exception("bad_alloc()");
}
m_buffer.init(profile.properties.getNode("buffer"));
- m_consumer.init(profile.properties);
-
m_publisher.setConsumer(m_consumer);
m_publisher.setBuffer(m_buffer);
m_publisher.setListener(m_profile, m_listeners);
Modified: trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/AllTest110.java
===================================================================
--- trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/AllTest110.java 2013-03-03 02:55:53 UTC (rev 703)
+++ trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/AllTest110.java 2013-03-05 17:51:10 UTC (rev 704)
@@ -1,21 +1,26 @@
package jp.go.aist.rtm;
-import Extension.EC.logical_time.LogicalTimeTriggeredECTests;
+import jp.go.aist.rtm.RTC.buffer.RingBufferTest;
+import jp.go.aist.rtm.RTC.executionContext.ExtTrigExecutionContextTests;
+import jp.go.aist.rtm.RTC.executionContext.PeriodicExecutionContextTests;
import jp.go.aist.rtm.RTC.log.LogBufTimeTest;
import jp.go.aist.rtm.RTC.log.LogbufTest;
+import jp.go.aist.rtm.RTC.port.InPortPushConnectorTest;
+import jp.go.aist.rtm.RTC.port.OutPortPushConnectorTest;
import jp.go.aist.rtm.RTC.util.AdjustedClockTest;
import jp.go.aist.rtm.RTC.util.TimeValueTest;
-import jp.go.aist.rtm.RTC.buffer.RingBufferTest;
-import jp.go.aist.rtm.RTC.executionContext.ExtTrigExecutionContextTests;
-import jp.go.aist.rtm.RTC.executionContext.PeriodicExecutionContextTests;
import junit.framework.Test;
import junit.framework.TestSuite;
+import Extension.EC.logical_time.LogicalTimeTriggeredECTests;
public class AllTest110 {
public static Test suite() {
TestSuite suite = new TestSuite("Test for 1.1.0");
+ suite.addTestSuite(InPortPushConnectorTest.class);
+ suite.addTestSuite(OutPortPushConnectorTest.class);
+
suite.addTestSuite(LogbufTest.class);
suite.addTestSuite(LogBufTimeTest.class);
Modified: trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/InPortPushConnectorTest.java
===================================================================
--- trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/InPortPushConnectorTest.java 2013-03-03 02:55:53 UTC (rev 703)
+++ trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/InPortPushConnectorTest.java 2013-03-05 17:51:10 UTC (rev 704)
@@ -63,6 +63,7 @@
if (m_logger != null) {
m_logger.log("InPortCorbaCdrProviderMock.init");
}
+ prop.setProperty("buffer_type", "ring_buffer_mock");
}
/**
*
@@ -234,9 +235,12 @@
rtcout.println(rtcout.PARANOID, "IN test_InPortPushConnector()");
RTC.ConnectorProfile prof = new RTC.ConnectorProfile();
NVListHolder prof_holder = new NVListHolder(prof.properties);
+ // ここで"dataport.buffer_type"に"ring_buffer"を設定するが,
+ // InPortCorbaCdrProviderMock.init()にて"ring_buffer_mock"
+ // を設定しているため,"ring_buffer_mock"が使用されることを確認する.
CORBA_SeqUtil.push_back(prof_holder,
NVUtil.newNV("dataport.buffer_type",
- "ring_buffer_mock"));
+ "ring_buffer"));
prof.properties = prof_holder.value;
prof.ports = new PortService[2];
// prop: [port.outport].
Modified: trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/OutPortPushConnectorTest.java
===================================================================
--- trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/OutPortPushConnectorTest.java 2013-03-03 02:55:53 UTC (rev 703)
+++ trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/OutPortPushConnectorTest.java 2013-03-05 17:51:10 UTC (rev 704)
@@ -13,6 +13,7 @@
import _SDOPackage.NVListHolder;
import RTC.PortService;
+import RTC.ReturnCode_t;
import jp.go.aist.rtm.RTC.BufferFactory;
import jp.go.aist.rtm.RTC.PublisherBaseFactory;
@@ -21,6 +22,7 @@
import jp.go.aist.rtm.RTC.ObjectDestructor;
import jp.go.aist.rtm.RTC.PeriodicTask;
import jp.go.aist.rtm.RTC.PeriodicTaskBase;
+import jp.go.aist.rtm.RTC.util.DataRef;
import jp.go.aist.rtm.RTC.util.Properties;
import jp.go.aist.rtm.RTC.util.ORBUtil;
import jp.go.aist.rtm.RTC.util.CORBA_SeqUtil;
@@ -75,6 +77,8 @@
if (m_logger != null) {
m_logger.log("InPortCorbaCdrConsumerMock.init");
}
+ // ここで指定したバッファが使用されることを確認する
+ //prop.setProperty("buffer_type", "ring_buffer_mock2");
}
/**
*
@@ -220,6 +224,7 @@
m_logger.log("buffer OK");
}
}
+ //System.out.println("bufferName:"+buffer.toString());
m_mock_logger.log("PublisherFlushMock.setBuffer");
if(buffer == null) {
m_mock_logger.log("buffer NG");
@@ -277,7 +282,9 @@
RTC.TimedLong tl = new RTC.TimedLong();
RTC.TimedLongHolder tlh
= new RTC.TimedLongHolder(tl);
+
tlh._read(data.create_input_stream());
+
if (m_logger != null) {
m_logger.log("PublisherNewMock.write");
m_logger.log(Integer.toString(tlh.value.data));
@@ -431,6 +438,7 @@
new PeriodicTask(),
new PeriodicTask());
+ CdrRingBufferMock2.CdrRingBufferMock2Init();
}
/**
@@ -491,7 +499,7 @@
CORBA_SeqUtil.refToVstring(prof.ports),
prop);
OutPortConnector connector = null;
- ConnectorListeners listeners = null;
+ ConnectorListeners listeners = new ConnectorListeners();
int init_counter = logger.countLog("InPortCorbaCdrConsumerMock.init");
int setBuffer_counter = m_mock_logger.countLog("PublisherNewMock.setBuffer");
int buffOk_counter = m_mock_logger.countLog("buffer OK");
@@ -631,23 +639,27 @@
CORBA_SeqUtil.refToVstring(prof.ports),
prop);
OutPortConnector connector = null;
- ConnectorListeners listeners = null;
- try {
+ ConnectorListeners listeners = new ConnectorListeners();
+ //try {
//connector = new OutPortPushConnector(profile_new, consumer);
connector = new OutPortPushConnector(profile_new, listeners, consumer);
int write_counter = m_mock_logger.countLog("PublisherNewMock.write");
int num_counter = m_mock_logger.countLog("12345");
OutputStream cdr = toStream(12345,0,0);
- connector.write(12345);
-// connector.write(cdr,cdr);
+ RTC.TimedLong out_val = new RTC.TimedLong(new RTC.Time(0,0),12345);
+ DataRef<RTC.TimedLong> out = new DataRef<RTC.TimedLong>(out_val);
+ OutPort<RTC.TimedLong> outPort = new OutPort<RTC.TimedLong>("out", out);
+ connector.setOutPortBase(outPort);
+ connector.write(out.v);
+ //connector.write(cdr);
assertEquals("1:",write_counter+1,
m_mock_logger.countLog("PublisherNewMock.write"));
assertEquals("2:",num_counter+1,
m_mock_logger.countLog("12345"));
- }
- catch(Exception e) {
- fail("The exception not intended was thrown .");
- }
+ //}
+ //catch(Exception e) {
+ // fail("The exception not intended was thrown .");
+ //}
}
@@ -695,7 +707,7 @@
CORBA_SeqUtil.refToVstring(prof.ports),
prop);
OutPortConnector connector=null;
- ConnectorListeners listeners = null;
+ ConnectorListeners listeners = new ConnectorListeners();
try {
//connector = new OutPortPushConnector(profile_new, consumer);
connector = new OutPortPushConnector(profile_new, listeners, consumer);
@@ -748,7 +760,7 @@
CORBA_SeqUtil.refToVstring(prof.ports),
prop);
OutPortConnector connector = null;
- ConnectorListeners listeners = null;
+ ConnectorListeners listeners = new ConnectorListeners();
try {
//connector = new OutPortPushConnector(profile_new, consumer);
connector = new OutPortPushConnector(profile_new, listeners, consumer);
@@ -786,5 +798,221 @@
return cdr;
}
-}
+};
+
+/**
+ *
+ *
+ *
+ */
+class CdrRingBufferMock2 extends CdrRingBuffer{
+
+ /**
+ * <p> creator_ </p>
+ *
+ * @return Object Created instances
+ *
+ */
+ public BufferBase<OutputStream> creator_() {
+ return new RingBufferMock2<OutputStream>();
+ }
+ /**
+ * <p> destructor_ </p>
+ *
+ * @param obj The target instances for destruction
+ *
+ */
+ public void destructor_(Object obj) {
+ obj = null;
+ }
+
+ /**
+ * <p> CdrRingBufferInit </p>
+ *
+ */
+ public static void CdrRingBufferMock2Init() {
+ final BufferFactory<RingBufferMock2<OutputStream>,String> factory
+ = BufferFactory.instance();
+
+ factory.addFactory("ring_buffer_mock2",
+ new CdrRingBufferMock2(),
+ new CdrRingBufferMock2());
+
+ }
+ }
+
+ /**
+ *
+ *
+ *
+ */
+ class RingBufferMock2<DataType> extends RingBuffer<DataType>{
+ public RingBufferMock2() {
+ //m_logger = null;
+ //m_mock_logger.log("RingBufferMock.Constructor");
+ //m_read_return_value = jp.go.aist.rtm.RTC.buffer.ReturnCode.BUFFER_OK;
+ //m_write_return_value = jp.go.aist.rtm.RTC.buffer.ReturnCode.BUFFER_OK;
+ }
+ /**
+ *
+ *
+ */
+ public void set_read_return_value(jp.go.aist.rtm.RTC.buffer.ReturnCode value) {
+ //m_read_return_value = value;
+ }
+ /**
+ *
+ *
+ */
+ public void set_write_return_value(jp.go.aist.rtm.RTC.buffer.ReturnCode value) {
+ //m_write_return_value = value;
+ }
+ /**
+ *
+ *
+ */
+ public void init(final Properties prop) {
+ }
+ /**
+ *
+ *
+ */
+ public int length() {
+ return 0;
+ }
+ /**
+ *
+ *
+ */
+ public jp.go.aist.rtm.RTC.buffer.ReturnCode length(int n) {
+ return jp.go.aist.rtm.RTC.buffer.ReturnCode.BUFFER_OK; //BUFFER_OK;
+ }
+ /**
+ *
+ *
+ */
+ public jp.go.aist.rtm.RTC.buffer.ReturnCode reset() {
+ return jp.go.aist.rtm.RTC.buffer.ReturnCode.BUFFER_OK; //BUFFER_OK;
+ }
+ /**
+ *
+ *
+ */
+ public DataType wptr(int n) {
+ return m_data;
+ }
+ /**
+ *
+ *
+ */
+ public jp.go.aist.rtm.RTC.buffer.ReturnCode advanceWptr(int n) {
+ return jp.go.aist.rtm.RTC.buffer.ReturnCode.BUFFER_OK; //BUFFER_OK;
+ }
+ /**
+ *
+ *
+ */
+ public jp.go.aist.rtm.RTC.buffer.ReturnCode put(final DataType value) {
+ return jp.go.aist.rtm.RTC.buffer.ReturnCode.BUFFER_OK; //BUFFER_OK;
+ }
+ /**
+ *
+ *
+ */
+ public jp.go.aist.rtm.RTC.buffer.ReturnCode write(final DataType value,
+ int sec, int nsec) {
+ /*!
+ if (m_logger != null) {
+ m_logger.log("RingBufferMock.write");
+ }
+ m_mock_logger.log("RingBufferMock.write");
+ */
+ return m_write_return_value; //BUFFER_OK;
+ }
+ /**
+ *
+ *
+ */
+ public int writable() {
+ return 0;
+ }
+ /**
+ *
+ *
+ */
+ public boolean full() {
+ return true;
+ }
+ /**
+ *
+ *
+ */
+ public DataType rptr(int n ) {
+ return m_data;
+ }
+ /**
+ *
+ *
+ */
+ public jp.go.aist.rtm.RTC.buffer.ReturnCode advanceRptr(int n) {
+ return jp.go.aist.rtm.RTC.buffer.ReturnCode.BUFFER_OK; //BUFFER_OK;
+ }
+ /**
+ *
+ *
+ */
+ public jp.go.aist.rtm.RTC.buffer.ReturnCode get(DataType value) {
+ return jp.go.aist.rtm.RTC.buffer.ReturnCode.BUFFER_OK; //BUFFER_OK;
+ }
+ /**
+ *
+ *
+ */
+ public DataType get() {
+ return m_data;
+ }
+ /**
+ *
+ *
+ */
+ public jp.go.aist.rtm.RTC.buffer.ReturnCode read(DataRef<DataType> value,
+ int sec, int nsec) {
+ /*!
+ if (m_logger != null) {
+ m_logger.log("RingBufferMock.read");
+ }
+ m_mock_logger.log("RingBufferMock.read");
+ */
+ return m_read_return_value; //BUFFER_OK;
+ }
+ /**
+ *
+ *
+ */
+ public int readable() {
+ return 0;
+ }
+ /**
+ *
+ *
+ */
+ public boolean empty() {
+ return true;
+ }
+ /**
+ *
+ *
+ */
+ public void setLogger(Logger logger) {
+ //m_logger = logger;
+ }
+
+ private DataType m_data;
+ private Vector<DataType> m_buffer;
+ private Logger m_logger;
+ private jp.go.aist.rtm.RTC.buffer.ReturnCode m_read_return_value;
+ private jp.go.aist.rtm.RTC.buffer.ReturnCode m_write_return_value;
+ //public static Logger m_mock_logger = null;
+ };
+
More information about the openrtm-commit
mailing list