00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 from omniORB import CORBA
00020 from omniORB import any
00021 import sys
00022 import traceback
00023
00024 import RTC, RTC__POA
00025 import OpenRTM
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 class InPortCorbaConsumer(OpenRTM.InPortConsumer,OpenRTM.CorbaConsumer):
00046 """
00047 """
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 def __init__(self, buffer_, consumer=None):
00065 if consumer:
00066 OpenRTM.CorbaConsumer.__init__(self, consumer=consumer)
00067 self._buffer = consumer._buffer
00068 return
00069
00070 OpenRTM.CorbaConsumer.__init__(self)
00071 self._buffer = buffer_
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088 def equal_operator(self, consumer):
00089 if self == consumer:
00090 return self
00091
00092 self._buffer = consumer._buffer
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107 def put(self, data):
00108 tmp = any.to_any(data)
00109 obj = self._ptr()._narrow(RTC.InPortAny)
00110 obj.put(tmp)
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124 def push(self):
00125 data = [None]
00126 self._buffer.read(data)
00127 tmp = any.to_any(data[0])
00128
00129 if self._ptr() is None:
00130 return
00131
00132 obj = self._ptr()._narrow(RTC.InPortAny)
00133
00134
00135 if CORBA.is_nil(obj):
00136 return
00137 try:
00138 obj.put(tmp)
00139 except:
00140
00141 traceback.print_exception(*sys.exec_info())
00142 return
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158 def clone(self):
00159 return OpenRTM.InPortCorbaConsumer(self, consumer=self)
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176 def subscribeInterface(self, properties):
00177 if not OpenRTM.NVUtil.isStringValue(properties,
00178 "dataport.dataflow_type",
00179 "Push"):
00180 return False
00181
00182 index = OpenRTM.NVUtil.find_index(properties,
00183 "dataport.corba_any.inport_ref")
00184
00185 if index < 0:
00186 return False
00187
00188 obj = None
00189 try:
00190 obj = any.from_any(properties[index].value,keep_structs=True)
00191 except:
00192 return False
00193
00194 if not CORBA.is_nil(obj):
00195 self.setObject(obj)
00196 return True
00197
00198 return False
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214 def unsubscribeInterface(self, properties):
00215 pass