[openrtm-commit:01755] r656 - trunk/OpenRTM-aist-Python/OpenRTM_aist
openrtm @ openrtm.org
openrtm @ openrtm.org
2016年 2月 25日 (木) 05:49:49 JST
Author: miyamoto
Date: 2016-02-25 05:49:49 +0900 (Thu, 25 Feb 2016)
New Revision: 656
Modified:
trunk/OpenRTM-aist-Python/OpenRTM_aist/InPort.py
trunk/OpenRTM-aist-Python/OpenRTM_aist/OutPortBase.py
trunk/OpenRTM-aist-Python/OpenRTM_aist/OutPortPullConnector.py
Log:
[incompat,new_func,->RELENG_1_2] Direct data get mode has been implemented. ref #3407
Modified: trunk/OpenRTM-aist-Python/OpenRTM_aist/InPort.py
===================================================================
--- trunk/OpenRTM-aist-Python/OpenRTM_aist/InPort.py 2016-02-24 19:31:57 UTC (rev 655)
+++ trunk/OpenRTM-aist-Python/OpenRTM_aist/InPort.py 2016-02-24 20:49:49 UTC (rev 656)
@@ -308,17 +308,14 @@
if len(self._outPortConnectorList) > 0:
- data = self._outPortConnectorList[0].read()
- self._listeners.connectorData_[OpenRTM_aist.ConnectorDataListenerType.ON_BUFFER_READ].notify(self._profile, data)
- #self._outPortListeners.connectorData_[OpenRTM_aist.ConnectorDataListenerType.ON_BUFFER_READ].notify(self._profile, data)
- self._rtcout.RTC_TRACE("ON_BUFFER_READ(InPort,OutPort), ")
- self._rtcout.RTC_TRACE("callback called in direct mode.")
- self._listeners.connectorData_[OpenRTM_aist.ConnectorDataListenerType.ON_RECEIVED].notify(self._profile, data)
- #self._outPortListeners.connectorData_[OpenRTM_aist.ConnectorDataListenerType.ON_RECEIVED].notify(self._profile, data)
- self._rtcout.RTC_TRACE("ON_RECEIVED(InPort,OutPort), ")
- self._rtcout.RTC_TRACE("callback called in direct mode.")
- self._value = data
- return self._value
+ ret, data = self._outPortConnectorList[0].read()
+
+ if ret:
+ self._value = data
+ if self._OnReadConvert is not None:
+ self._value = self._OnReadConvert(self._value)
+ self._rtcout.RTC_TRACE("OnReadConvert for direct data called")
+ return self._value
if len(self._connectors) == 0:
self._rtcout.RTC_DEBUG("no connectors")
Modified: trunk/OpenRTM-aist-Python/OpenRTM_aist/OutPortBase.py
===================================================================
--- trunk/OpenRTM-aist-Python/OpenRTM_aist/OutPortBase.py 2016-02-24 19:31:57 UTC (rev 655)
+++ trunk/OpenRTM-aist-Python/OpenRTM_aist/OutPortBase.py 2016-02-24 20:49:49 UTC (rev 656)
@@ -1242,8 +1242,14 @@
self._rtcout.RTC_TRACE("but a peer InPort servant could not be obtained.")
del connector
return 0
-
- connector.setInPort(inport)
+ if consumer_ is not None:
+ connector.setInPort(inport)
+ elif provider_ is not None:
+ connector.setPorts(inport, self)
+ #if consumer_ is not None:
+ # connector.setInPort(inport)
+ #elif provider_ is not None:
+ # connector.setInPort(inport)
self._connectors.append(connector)
Modified: trunk/OpenRTM-aist-Python/OpenRTM_aist/OutPortPullConnector.py
===================================================================
--- trunk/OpenRTM-aist-Python/OpenRTM_aist/OutPortPullConnector.py 2016-02-24 19:31:57 UTC (rev 655)
+++ trunk/OpenRTM-aist-Python/OpenRTM_aist/OutPortPullConnector.py 2016-02-24 20:49:49 UTC (rev 656)
@@ -189,26 +189,13 @@
# virtual ReturnCode write(const cdrMemoryStream& data);
def write(self, data):
if self._directInPort is not None:
- if self.isNew():
- #self._listeners.connectorData_[OpenRTM_aist.ConnectorDataListenerType.ON_BUFFER_OVERWRITE].notify(self._profile, data)
- self._inPortListeners.connectorData_[OpenRTM_aist.ConnectorDataListenerType.ON_BUFFER_OVERWRITE].notify(self._profile, data)
- #self._listeners.connectorData_[OpenRTM_aist.ConnectorDataListenerType.ON_RECEIVER_FULL].notify(self._profile, data)
- self._inPortListeners.connectorData_[OpenRTM_aist.ConnectorDataListenerType.ON_RECEIVER_FULL].notify(self._profile, data)
- self._rtcout.RTC_TRACE("ONBUFFER_OVERWRITE(InPort,OutPort), ")
- self._rtcout.RTC_TRACE("ON_RECEIVER_FULL(InPort,OutPort) ")
- self._rtcout.RTC_TRACE("callback called in direct mode.")
- #self._listeners.connectorData_[OpenRTM_aist.ConnectorDataListenerType.ON_BUFFER_WRITE].notify(self._profile, data)
- self._inPortListeners.connectorData_[OpenRTM_aist.ConnectorDataListenerType.ON_BUFFER_WRITE].notify(self._profile, data)
- self._rtcout.RTC_TRACE("ON_BUFFER_WRITE(InPort,OutPort), ")
- self._rtcout.RTC_TRACE("callback called in direct mode.")
+
guard = OpenRTM_aist.ScopedLock(self._valueMutex)
self._value = data
self._directNewData = True
+
del guard
- #self._listeners.connectorData_[OpenRTM_aist.ConnectorDataListenerType.ON_RECEIVED].notify(self._profile, data)
- self._inPortListeners.connectorData_[OpenRTM_aist.ConnectorDataListenerType.ON_RECEIVED].notify(self._profile, data)
- self._rtcout.RTC_TRACE("ON_RECEIVED(InPort,OutPort), ")
- self._rtcout.RTC_TRACE("callback called in direct mode.")
+
return self.PORT_OK
# data -> (conversion) -> CDR stream
cdr_data = None
@@ -368,12 +355,13 @@
# @return
# @endif
#
- # bool setInPort(InPortBase* directInPort);
- def setInPort(self, directInPort):
+ # bool setPorts(InPortBase* directInPort, OutPortBase* outPort);
+ def setPorts(self, directInPort, outPort):
if self._directInPort is not None:
return False
self._directInPort = directInPort
self._inPortListeners = self._directInPort._listeners
+ self._outPortListeners = outPort._listeners
self._directInPort.addOutPortConnector(self)
return True
@@ -383,7 +371,7 @@
# @brief データをダイレクトに読み込む
#
# @param self
- # @return 読み込むデータ
+ # @return 判定(データが書き込まれていなければTrue)、読み込むデータ
#
# @else
# @brief
@@ -391,13 +379,37 @@
# @param self
# @param data
# @endif
- # void write(const DataType& data)
+ # DataType* read()
def read(self):
guard = OpenRTM_aist.ScopedLock(self._valueMutex)
+ if not self.isNew():
+ self._outPortListeners.connector_[OpenRTM_aist.ConnectorListenerType.ON_BUFFER_EMPTY].notify(self._profile)
+ self._inPortListeners.connector_[OpenRTM_aist.ConnectorListenerType.ON_SENDER_EMPTY].notify(self._profile)
+ self._rtcout.RTC_TRACE("ON_BUFFER_EMPTY(OutPort), ")
+ self._rtcout.RTC_TRACE("ON_SENDER_EMPTY(InPort) ")
+ self._rtcout.RTC_TRACE("callback called in direct mode.")
+ return False, ""
+
data = self._value
+ ret = self._directNewData
self._directNewData = False
del guard
- return data
+
+
+ self._outPortListeners.connectorData_[OpenRTM_aist.ConnectorDataListenerType.ON_BUFFER_READ].notify(self._profile, data)
+ self._rtcout.RTC_TRACE("ON_BUFFER_READ(OutPort), ")
+ self._rtcout.RTC_TRACE("callback called in direct mode.")
+ self._outPortListeners.connectorData_[OpenRTM_aist.ConnectorDataListenerType.ON_SEND].notify(self._profile, data)
+ self._rtcout.RTC_TRACE("ON_SEND(OutPort), ")
+ self._rtcout.RTC_TRACE("callback called in direct mode.")
+ self._inPortListeners.connectorData_[OpenRTM_aist.ConnectorDataListenerType.ON_RECEIVED].notify(self._profile, data)
+ self._rtcout.RTC_TRACE("ON_RECEIVED(InPort), ")
+ self._rtcout.RTC_TRACE("callback called in direct mode.")
+ self._inPortListeners.connectorData_[OpenRTM_aist.ConnectorDataListenerType.ON_BUFFER_WRITE].notify(self._profile, data)
+ self._rtcout.RTC_TRACE("ON_BUFFER_WRITE(InPort), ")
+ self._rtcout.RTC_TRACE("callback called in direct mode.")
+
+ return ret, data
def isNew(self):
return self._directNewData
\ No newline at end of file
More information about the openrtm-commit
mailing list