PublisherFlush.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- coding: euc-jp -*-
3 
4 
17 
18 
19 import OpenRTM_aist
20 
21 
22 
36  """
37  """
38 
39 
40 
41 
54  def __init__(self):
55  self._rtcout = OpenRTM_aist.Manager.instance().getLogbuf("PublisherFlush")
56  self._consumer = None
57  self._active = False
58  self._profile = None # ConnectorInfo
59  self._listeners = None # ConnectorListeners
60  self._retcode = self.PORT_OK
61 
62 
74  def __del__(self):
75  # "consumer" should be deleted in the Connector
76  self._rtcout.RTC_TRACE("~PublisherFlush()")
77  self._consumer = None
78  return
79 
80 
105  def init(self, prop):
106  self._rtcout.RTC_TRACE("init()")
107  return self.PORT_OK;
108 
109 
133  def setConsumer(self, consumer):
134  self._rtcout.RTC_TRACE("setConsumer()")
135  if not consumer:
136  return self.INVALID_ARGS
137 
138  self._consumer = consumer
139 
140  return self.PORT_OK
141 
142 
164  def setBuffer(self, buffer):
165  self._rtcout.RTC_TRACE("setBuffer()")
166  return self.PORT_OK
167 
168 
204  def setListener(self, info, listeners):
205  self._rtcout.RTC_TRACE("setListeners()")
206 
207  if not listeners:
208  self._rtcout.RTC_ERROR("setListeners(listeners == 0): invalid argument")
209  return self.INVALID_ARGS
210 
211  self._profile = info
212  self._listeners = listeners
213 
214  return self.PORT_OK
215 
216 
277  def write(self, data, sec, usec):
278  self._rtcout.RTC_PARANOID("write()")
279  if not self._consumer or not self._listeners:
280  return self.PRECONDITION_NOT_MET
281 
282  if self._retcode == self.CONNECTION_LOST:
283  self._rtcout.RTC_DEBUG("write(): connection lost.")
284  return self._retcode
285 
286  self.onSend(data)
287 
288  self._retcode = self._consumer.put(data)
289 
290  if self._retcode == self.PORT_OK:
291  self.onReceived(data)
292  return self._retcode
293  elif self._retcode == self.PORT_ERROR:
294  self.onReceiverError(data)
295  return self._retcode
296  elif self._retcode == self.SEND_FULL:
297  self.onReceiverFull(data)
298  return self._retcode
299  elif self._retcode == self.SEND_TIMEOUT:
300  self.onReceiverTimeout(data)
301  return self._retcode
302  elif self._retcode == self.CONNECTION_LOST:
303  self.onReceiverTimeout(data)
304  return self._retcode
305  elif self._retcode == self.UNKNOWN_ERROR:
306  self.onReceiverError(data)
307  return self._retcode
308  else:
309  self.onReceiverError(data)
310  return self._retcode
311 
312  return self._retcode
313 
314 
315 
343  def isActive(self):
344  return self._active
345 
346 
347 
373  def activate(self):
374  if self._active:
375  return self.PRECONDITION_NOT_MET
376 
377  self._active = True
378 
379  return self.PORT_OK
380 
381 
407  def deactivate(self):
408  if not self._active:
409  return self.PRECONDITION_NOT_MET
410 
411  self._active = False
412 
413  return self.PORT_OK
414 
415 
425  def onSend(self, data):
426  if self._listeners is not None and self._profile is not None:
427  self._listeners.connectorData_[OpenRTM_aist.ConnectorDataListenerType.ON_SEND].notify(self._profile, data)
428  return
429 
430 
440  def onReceived(self, data):
441  if self._listeners is not None and self._profile is not None:
442  self._listeners.connectorData_[OpenRTM_aist.ConnectorDataListenerType.ON_RECEIVED].notify(self._profile, data)
443  return
444 
445 
455  def onReceiverFull(self, data):
456  if self._listeners is not None and self._profile is not None:
457  self._listeners.connectorData_[OpenRTM_aist.ConnectorDataListenerType.ON_RECEIVER_FULL].notify(self._profile, data)
458  return
459 
460 
470  def onReceiverTimeout(self, data):
471  if self._listeners is not None and self._profile is not None:
472  self._listeners.connectorData_[OpenRTM_aist.ConnectorDataListenerType.ON_RECEIVER_TIMEOUT].notify(self._profile, data)
473  return
474 
475 
485  def onReceiverError(self, data):
486  if self._listeners is not None and self._profile is not None:
487  self._listeners.connectorData_[OpenRTM_aist.ConnectorDataListenerType.ON_RECEIVER_ERROR].notify(self._profile, data)
488  return
489 
490 
492  OpenRTM_aist.PublisherFactory.instance().addFactory("flush",
494  OpenRTM_aist.Delete)
def setConsumer(self, consumer)
Store InPort consumer.
def onReceived(self, data)
Notify an ON_RECEIVED event to listeners.
def init(self, prop)
initialization
def write(self, data, sec, usec)
Write data.
def onReceiverError(self, data)
Notify an ON_RECEIVER_ERROR event to listeners.
def onSend(self, data)
Notify an ON_SEND event to listners.
def isActive(self)
If publisher is active state.
int PORT_OK
DataPortStatus return codes.
def setListener(self, info, listeners)
Set the listener.
def setBuffer(self, buffer)
Setting buffer pointer.
def onReceiverFull(self, data)
Notify an ON_RECEIVER_FULL event to listeners.
def onReceiverTimeout(self, data)
Notify an ON_RECEIVER_TIMEOUT event to listeners.


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