OutPortPullConnector.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- coding: euc-jp -*-
3 
4 
5 
19 
20 from omniORB import *
21 from omniORB import any
22 
23 import OpenRTM_aist
24 
25 
26 
78  """
79  """
80 
81 
125  def __init__(self, info, provider, listeners, buffer = 0):
126  OpenRTM_aist.OutPortConnector.__init__(self, info)
127  self._provider = provider
128  self._listeners = listeners
129  self._buffer = buffer
130 
131  if not self._buffer:
132  self._buffer = self.createBuffer(info)
133 
134  if not self._provider or not self._buffer:
135  self._rtcout.RTC_ERROR("Exeption: in OutPortPullConnector.__init__().")
136  raise
137 
138  self._buffer.init(info.properties.getNode("buffer"))
139  self._provider.setBuffer(self._buffer)
140  self._provider.setConnector(self)
141  self._provider.setListener(info, self._listeners)
142  self.onConnect()
143  return
144 
145 
146 
161  def __del__(self):
162  return
163 
164 
165 
182  def write(self, data):
183  # data -> (conversion) -> CDR stream
184  cdr_data = None
185  if self._endian is not None:
186  cdr_data = cdrMarshal(any.to_any(data).typecode(), data, self._endian)
187  else:
188  self._rtcout.RTC_ERROR("write(): endian %s is not support.",self._endian)
189  return self.UNKNOWN_ERROR
190 
191  self._buffer.write(cdr_data)
192  return self.PORT_OK
193 
194 
195 
211  def disconnect(self):
212  self._rtcout.RTC_TRACE("disconnect()")
213  self.onDisconnect()
214  # delete provider
215  if self._provider:
216  OpenRTM_aist.OutPortProviderFactory.instance().deleteObject(self._provider)
217  self._provider = 0
218 
219  # delete buffer
220  if self._buffer:
221  OpenRTM_aist.CdrBufferFactory.instance().deleteObject(self._buffer)
222  self._buffer = 0
223 
224  return self.PORT_OK
225 
226 
227 
241  def getBuffer(self):
242  return self._buffer
243 
244 
245 
260  def activate(self): # do nothing
261  pass
262 
263 
264 
279  def deactivate(self): # do nothing
280  pass
281 
282 
283 
291  def createBuffer(self, info):
292  buf_type = info.properties.getProperty("buffer_type","ring_buffer")
293  return OpenRTM_aist.CdrBufferFactory.instance().createObject(buf_type)
294 
295 
296 
303  def onConnect(self):
304  if self._listeners and self._profile:
305  self._listeners.connector_[OpenRTM_aist.ConnectorListenerType.ON_CONNECT].notify(self._profile)
306  return
307 
308 
309 
316  def onDisconnect(self):
317  if self._listeners and self._profile:
318  self._listeners.connector_[OpenRTM_aist.ConnectorListenerType.ON_DISCONNECT].notify(self._profile)
319  return
def onConnect(self)
Invoke callback when connection is established void onConnect()
def onDisconnect(self)
Invoke callback when connection is destroied void onDisconnect()
int PORT_OK
DataPortStatus return codes.
def createBuffer(self, info)
create bufferCdrBufferBase* createBuffer(ConnectorInfo& info);
def __init__(self, info, provider, listeners, buffer=0)
Constructor.


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