00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 from omniORB import any
00019 from omniORB import CORBA
00020
00021 import OpenRTM
00022 import RTC, RTC__POA
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 class OutPortCorbaConsumer(OpenRTM.OutPortConsumer,OpenRTM.CorbaConsumer):
00041 """
00042 """
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058 def __init__(self, buffer_):
00059 self._buffer = buffer_
00060 OpenRTM.CorbaConsumer.__init__(self)
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077 def get(self, data):
00078 try:
00079 obj = self._ptr()._narrow(RTC.OutPortAny)
00080 if CORBA.is_nil(obj):
00081 return False
00082 d = any.from_any(obj.get(), keep_structs=True)
00083 data[0] = d
00084 return True
00085 except:
00086 return False
00087
00088 return False
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103 def pull(self):
00104 data = [None]
00105 if self.get(data):
00106 self._buffer.write(data[0])
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123 def subscribeInterface(self, properties):
00124 index = OpenRTM.NVUtil.find_index(properties,
00125 "dataport.corba_any.outport_ref")
00126 if index < 0:
00127 return False
00128
00129 try:
00130 obj = any.from_any(properties[index].value, keep_structs=True)
00131 self.setObject(obj)
00132 return True
00133 except:
00134 return False
00135
00136 return False
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151 def unsubscribeInterface(self, properties):
00152 index = OpenRTM.NVUtil.find_index(properties,
00153 "dataport.corba_any.outport_ref")
00154 if index < 0:
00155 return
00156
00157 try:
00158 obj = any.from_any(properties[index].value, keep_structs=True)
00159 if self.getObject()._is_equivalent(obj):
00160 self.releaseObject()
00161 except:
00162 return