[openrtm-commit:02336] r920 - trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port
openrtm @ openrtm.org
openrtm @ openrtm.org
2017年 1月 26日 (木) 00:55:39 JST
Author: win-ei
Date: 2017-01-26 00:55:39 +0900 (Thu, 26 Jan 2017)
New Revision: 920
Added:
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/Timestamp.java
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/OutPort.java
Log:
[FSM4RTC,incomapt] Timestamp class template has been added. Timestamp listeners have been added to InPort and OutPort. refs #3886
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-01-25 15:50:57 UTC (rev 919)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/InPort.java 2017-01-25 15:55:39 UTC (rev 920)
@@ -161,6 +161,11 @@
rtcout.println(Logbuf.WARN,
"Exception caught."+e.toString());
}
+ this.addConnectorDataListener(ConnectorDataListenerType.ON_RECEIVED,
+ new Timestamp<DataType>("on_received",cl));
+ this.addConnectorDataListener(ConnectorDataListenerType.ON_BUFFER_READ,
+ new Timestamp<DataType>("on_read",cl));
+
}
/**
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 2017-01-25 15:50:57 UTC (rev 919)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/OutPort.java 2017-01-25 15:55:39 UTC (rev 920)
@@ -317,6 +317,11 @@
m_propValueIndex = NVUtil.find_index(nvholder,
"dataport.data_value");
}
+ this.addConnectorDataListener(ConnectorDataListenerType.ON_BUFFER_WRITE,
+ new Timestamp<DataType>("on_write",cl));
+ this.addConnectorDataListener(ConnectorDataListenerType.ON_SEND,
+ new Timestamp<DataType>("on_send",cl));
+
}
/**
Added: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/Timestamp.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/Timestamp.java (rev 0)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/Timestamp.java 2017-01-25 15:55:39 UTC (rev 920)
@@ -0,0 +1,42 @@
+package jp.go.aist.rtm.RTC.port;
+
+import jp.go.aist.rtm.RTC.connectorListener.ReturnCode;
+import jp.go.aist.rtm.RTC.port.ConnectorBase;
+import jp.go.aist.rtm.RTC.util.TimeValue;
+import jp.go.aist.rtm.RTC.util.clock.ClockManager;
+import jp.go.aist.rtm.RTC.util.clock.IClock;
+
+public class Timestamp<DataType> extends ConnectorDataListenerT<DataType>{
+ public Timestamp(final String name, Class cl){
+ super(cl);
+ m_tstype = name;
+ m_clock = ClockManager.getInstance().getClock("system");
+ }
+ public ReturnCode operator(ConnectorBase.ConnectorInfo info,
+ DataType data) {
+ if(!info.properties.getProperty("timestamp_policy").equals(m_tstype)){
+ return ReturnCode.NO_CHANGE;
+ }
+
+ TimeValue tv = m_clock.getTime();
+ RTC.Time tm = new RTC.Time((int)(tv.getSec()),
+ (int)(tv.getUsec()*1000));
+ Class cl = data.getClass();
+ String str = cl.getName();
+ try {
+ cl.getField("tm").set(data,tm);
+ }
+ catch(NoSuchFieldException e){
+ //getField throws
+ }
+ catch(IllegalAccessException e){
+ //set throws
+ }
+ return ReturnCode.DATA_CHANGED;
+ }
+
+ public String m_tstype;
+ private IClock m_clock;
+
+}
+
More information about the openrtm-commit
mailing list