OutPort.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- coding: euc-jp -*-
3 
4 
5 
18 
19 
20 from omniORB import *
21 from omniORB import any
22 
23 import OpenRTM_aist
24 
25 
26 
48 def setTimestamp(data):
49  # set timestamp
50  tm = OpenRTM_aist.Time()
51  data.tm.sec = tm.sec
52  data.tm.nsec = tm.usec * 1000
53 
54 
55 
70  """
71  """
72 
73 
74 
75 
92  def __init__(self, name, value, buffer=None):
93  OpenRTM_aist.OutPortBase.__init__(self, name, OpenRTM_aist.toTypename(value))
94  self._value = value
95  #self._timeoutTick = 1000 # timeout tick: 1ms
96  #self._writeBlock = False
97  #self._writeTimeout = 0
98  self._OnWrite = None
99  self._OnWriteConvert = None
100  #self._OnOverflow = None
101  #self._OnUnderflow = None
102  #self._OnConnect = None
103  #self._OnDisconnect = None
104 
105 
106  def __del__(self, OutPortBase=OpenRTM_aist.OutPortBase):
107  OutPortBase.__del__(self)
108  return
109 
110 
154  def write(self, value=None):
155  if not value:
156  value=self._value
157 
158 
159  if self._OnWrite:
160  self._OnWrite(value)
161 
162  # check number of connectors
163  conn_size = len(self._connectors)
164  if not conn_size > 0:
165  return True
166 
167  # set timestamp
168  #tm = Time()
169  #value.tm.sec = tm.sec
170  #value.tm.nsec = tm.usec * 1000
171 
172  #tm_pre = Time()
173 
174  if self._OnWriteConvert:
175  value = self._OnWriteConvert(value)
176 
177  result = True
178 
180  for con in self._connectors:
181  ret = con.write(value)
182  if ret != self.PORT_OK:
183  result = False
184  if ret == self.CONNECTION_LOST:
185  self.disconnect(con.id())
186 
187  return result
188 
189 
190 
209 
210 
211 
229 
230 
231 
246  def setOnWrite(self, on_write):
247  self._OnWrite = on_write
248 
249 
250 
268  def setOnWriteConvert(self, on_wconvert):
269  self._OnWriteConvert = on_wconvert
270 
271 
272 
286  def getPortDataType(self):
287  val = any.to_any(self._value)
288  return str(val.typecode().name())
289 
290 
291 
292  class subscribe:
293  def __init__(self, prof, subs = None):
294  if subs:
295  self._prof = subs._prof
296  self._consumer = subs._consumer
297  return
298 
299  self._prof = prof
300  self._consumer = None
301 
302 
303  def __call__(self, cons):
304  if cons.subscribeInterface(self._prof.properties):
305  self._consumer = cons
def disconnect(self, connector_id)
[CORBA interface] Disconnect the Port
Definition: PortBase.py:815
def write(self, value=None)
Write data.
Definition: OutPort.py:154
def setOnWrite(self, on_write)
Set read() block mode.
Definition: OutPort.py:246
def setTimestamp(data)
Setting timestamp to data.
Definition: OutPort.py:48
name
Definition: setup.py:543
int PORT_OK
DataPortStatus return codes.
def __init__(self, name, value, buffer=None)
Constructor.
Definition: OutPort.py:92
def __init__(self, prof, subs=None)
Definition: OutPort.py:293
def __del__(self, OutPortBase=OpenRTM_aist.OutPortBase)
Definition: OutPort.py:106
def setOnWriteConvert(self, on_wconvert)
Set OnWriteConvert callback.
Definition: OutPort.py:268


openrtm_aist_python
Author(s): Shinji Kurihara
autogenerated on Mon Feb 28 2022 23:01:06