InPortPullConnector.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- coding: euc-jp -*-
3 
4 
18 
19 from omniORB import *
20 from omniORB import any
21 
22 import OpenRTM_aist
23 
24 
25 
80  """
81  """
82 
83 
127  def __init__(self, info, consumer, listeners, buffer = 0):
128  OpenRTM_aist.InPortConnector.__init__(self, info, buffer)
129  self._consumer = consumer
130  self._listeners = listeners
131  if buffer == 0:
132  self._buffer = self.createBuffer(self._profile)
133 
134  if self._buffer == 0 or not self._consumer:
135  raise
136 
137  self._buffer.init(info.properties.getNode("buffer"))
138  self._consumer.setBuffer(self._buffer)
139  self._consumer.setListener(info, self._listeners)
140  self.onConnect()
141  return
142 
143 
144 
159  def __del__(self):
160  return
161 
162 
163 
195  def read(self, data):
196  self._rtcout.RTC_TRACE("InPortPullConnector.read()")
197  if not self._consumer:
198  return self.PORT_ERROR
199 
200  cdr_data = [None]
201  ret = self._consumer.get(cdr_data)
202 
203  if ret == self.PORT_OK:
204  # CDR -> (conversion) -> data
205  if self._endian is not None:
206  data[0] = cdrUnmarshal(any.to_any(data[0]).typecode(),cdr_data[0],self._endian)
207 
208  else:
209  self._rtcout.RTC_ERROR("unknown endian from connector")
210  return OpenRTM_aist.BufferStatus.PRECONDITION_NOT_MET
211 
212  return ret
213 
214 
215 
229  def disconnect(self):
230  self._rtcout.RTC_TRACE("disconnect()")
231  self.onDisconnect()
232  # delete consumer
233  if self._consumer:
234  OpenRTM_aist.OutPortConsumerFactory.instance().deleteObject(self._consumer)
235  self._consumer = 0
236 
237  return self.PORT_OK
238 
239 
254  def activate(self): # do nothing
255  pass
256 
257 
272  def deactivate(self): # do nothing
273  pass
274 
275 
295  def createBuffer(self, profile):
296  buf_type = profile.properties.getProperty("buffer_type","ring_buffer")
297  return OpenRTM_aist.CdrBufferFactory.instance().createObject(buf_type)
298 
299 
306  def onConnect(self):
307  if self._listeners and self._profile:
308  self._listeners.connector_[OpenRTM_aist.ConnectorListenerType.ON_CONNECT].notify(self._profile)
309  return
310 
311 
318  def onDisconnect(self):
319  if self._listeners and self._profile:
320  self._listeners.connector_[OpenRTM_aist.ConnectorListenerType.ON_DISCONNECT].notify(self._profile)
321  return
def __init__(self, info, consumer, listeners, buffer=0)
Constructor.
def onConnect(self)
Invoke callback when connection is established void onConnect()
int PORT_OK
DataPortStatus return codes.
def onDisconnect(self)
Invoke callback when connection is destroied void onDisconnect()


openrtm_aist_python
Author(s): Shinji Kurihara
autogenerated on Thu Jun 6 2019 19:11:34