def cleanUp(self): self.trace("[TangoDevice] cleanUp") self._descr = None if not self._deviceStateObj is None: self._deviceStateObj.removeListener(self) self._deviceStateObj = None self._deviceObj = None TaurusDevice.cleanUp(self)
def addListener(self, listener): weWereListening = self.hasListeners() ret = TaurusDevice.addListener(self, listener) if not ret: return ret # We are only listening to State if someone is listening to us if weWereListening: # We were listening already, so we must fake an event to the new # subscribed listener with the current value evt_value = self.__decode(self.stateObj.read()) listeners = hasattr(listener, '__iter__') and listener or [ listener] self.fireEvent(TaurusEventType.Change, evt_value, listeners) else: # We were not listening to events, but now we have to self.stateObj.addListener(self) return ret
def addListener(self, listener): weWereListening = self.hasListeners() ret = TaurusDevice.addListener(self, listener) if not ret: return ret # We are only listening to State if someone is listening to us if weWereListening: # We were listening already, so we must fake an event to the new # subscribed listener with the current value evt_value = self.__decode(self.stateObj.read()) listeners = hasattr(listener, '__iter__') and listener or [ listener ] self.fireEvent(TaurusEventType.Change, evt_value, listeners) else: # We were not listening to events, but now we have to self.stateObj.addListener(self) return ret
def removeListener(self, listener): ret = TaurusDevice.removeListener(self, listener) if not ret or self.hasListeners(): return ret # False, None or True return self.stateObj.removeListener(self)