def __init__(self, name, parent, **kwargs):
        TaurusAttribute.__init__(self, name, parent, **kwargs)
        v = self.getNameValidator()
        urigroups = v.getUriGroups(name)
        # store the hdf5 path for future readouts
        self._attr_name = urigroups.get("attrname")
        self._last_value = None

        wantpolling = not self.isUsingEvents()
        haspolling = self.isPollingEnabled()
        if wantpolling:
            self._activatePolling()
        elif haspolling and not wantpolling:
            self.disablePolling()
    def addListener(self, listener):
        """ Add a TaurusListener object in the listeners list.
            If it is the first element and Polling is enabled starts the
            polling mechanism.
            If the listener is already registered nothing happens."""

        listeners = self._listeners
        initial_subscription_state = self.__subscription_state

        ret = TaurusAttribute.addListener(self, listener)
        if not ret:
            return ret

        assert len(listeners) >= 1

        if self.__subscription_state == SubscriptionState.Unsubscribed and len(
                listeners) == 1:
            self._subscribeEvents()

        # if initial_subscription_state == SubscriptionState.Subscribed:
        if len(listeners) > 1 and (initial_subscription_state
                                   == SubscriptionState.Subscribed
                                   or self.isPollingActive()):
            sm = self.getSerializationMode()
            if sm == TaurusSerializationMode.Concurrent:
                Manager().addJob(self.__fireRegisterEvent, None, (listener, ))
            else:
                self.__fireRegisterEvent((listener, ))
        return ret
Example #3
0
    def addListener(self, listener):
        """ Add a TaurusListener object in the listeners list.
            If it is the first listener, it triggers the subscription to
            the referenced attributes.
            If the listener is already registered nothing happens."""
        initial_subscription_state = self.__subscription_state

        ret = TaurusAttribute.addListener(self, listener)

        if not ret:
            return ret

        if self.__subscription_state == SubscriptionState.Unsubscribed:
            for refobj in self._references:
                # subscribe to the referenced attributes
                refobj.addListener(self)
            self.__subscription_state = SubscriptionState.Subscribed

        assert len(self._listeners) >= 1
        # if initial_subscription_state == SubscriptionState.Subscribed:
        if len(self._listeners) > 1 and \
           (initial_subscription_state == SubscriptionState.Subscribed or
                self.isPollingActive()):
            Manager().addJob(self.__fireRegisterEvent, None, (listener, ))
        return ret
Example #4
0
    def addListener(self, listener):
        """ Add a TaurusListener object in the listeners list.
            If it is the first element and Polling is enabled starts the
            polling mechanism.
            If the listener is already registered nothing happens."""

        listeners = self._listeners
        initial_subscription_state = self.__subscription_state

        ret = TaurusAttribute.addListener(self, listener)
        if not ret:
            return ret

        assert len(listeners) >= 1

        if self.__subscription_state == SubscriptionState.Unsubscribed and len(listeners) == 1:
            self._subscribeEvents()

        # if initial_subscription_state == SubscriptionState.Subscribed:
        if len(listeners) > 1 and (
            initial_subscription_state == SubscriptionState.Subscribed or self.isPollingActive()
        ):
            sm = self.getSerializationMode()
            if sm == TaurusSerializationMode.Concurrent:
                Manager().addJob(self.__fireRegisterEvent, None, (listener,))
            else:
                self.__fireRegisterEvent((listener,))
        return ret
Example #5
0
    def addListener(self, listener):
        """ Add a TaurusListener object in the listeners list.
            If it is the first listener, it triggers the subscription to
            the referenced attributes.
            If the listener is already registered nothing happens."""
        initial_subscription_state = self.__subscription_state

        ret = TaurusAttribute.addListener(self, listener)

        if not ret:
            return ret

        if self.__subscription_state == SubscriptionState.Unsubscribed:
            for refobj in self._references:
                # subscribe to the referenced attributes
                refobj.addListener(self)
            self.__subscription_state = SubscriptionState.Subscribed

        assert len(self._listeners) >= 1
        # if initial_subscription_state == SubscriptionState.Subscribed:
        if len(self._listeners) > 1 and \
           (initial_subscription_state == SubscriptionState.Subscribed or
                self.isPollingActive()):
            Manager().addJob(self.__fireRegisterEvent, None, (listener,))
        return ret
Example #6
0
    def addListener(self, listener):
        added = TaurusAttribute.addListener(self, listener)
        if added:
            v = self.read()
            self.fireEvent(TaurusEventType.Periodic, v, listeners=[listener])

        return added
Example #7
0
    def __init__(self, name, parent, **kwargs):
        TaurusAttribute.__init__(self, name, parent, **kwargs)

        v = self.getNameValidator()
        v.getUriGroups(name)
        groups = v.getUriGroups(name)

        self.handler = schemesMap[groups['scheme']]()
        self._attr_name = groups.get("attrname")
        self._last_value = None

        wantpolling = not self.isUsingEvents()
        haspolling = self.isPollingEnabled()
        if wantpolling:
            self._activatePolling()
        elif haspolling and not wantpolling:
            self.disablePolling()
Example #8
0
 def setAlarms(self, *limits):
     if isinstance(limits[0], list):
         limits = limits[0]
     low, high = limits
     low = Quantity(low)
     high = Quantity(high)
     TaurusAttribute.setAlarms(self, [low, high])
     infoex = self._pytango_attrinfoex
     if low.magnitude != float("-inf"):
         infoex.alarms.min_alarm = str(low.to(self._units).magnitude)
     else:
         infoex.alarms.min_alarm = "Not specified"
     if high.magnitude != float("inf"):
         infoex.alarms.max_alarm = str(high.to(self._units).magnitude)
     else:
         infoex.alarms.max_alarm = "Not specified"
     self._applyConfig()
 def setAlarms(self, *limits):
     if isinstance(limits[0], list):
         limits = limits[0]
     low, high = limits
     low = Quantity(low)
     high = Quantity(high)
     TaurusAttribute.setAlarms(self, [low, high])
     infoex = self._pytango_attrinfoex
     if low.magnitude != float('-inf'):
         infoex.alarms.min_alarm = str(low.to(self._units).magnitude)
     else:
         infoex.alarms.min_alarm = 'Not specified'
     if high.magnitude != float('inf'):
         infoex.alarms.max_alarm = str(high.to(self._units).magnitude)
     else:
         infoex.alarms.max_alarm = 'Not specified'
     self._applyConfig()
Example #10
0
    def removeListener(self, listener):
        """ Remove a TaurusListener from the listeners list. If polling enabled
            and it is the last element then stop the polling timer.
            If the listener is not registered nothing happens."""
        ret = TaurusAttribute.removeListener(self, listener)

        if ret and not self.hasListeners():
            self._deactivatePolling()
            self.__subscription_state = SubscriptionState.Unsubscribed
        return ret
Example #11
0
    def removeListener(self, listener):
        """ Remove a TaurusListener from the listeners list. If polling enabled
            and it is the last element then stop the polling timer.
            If the listener is not registered nothing happens."""
        ret = TaurusAttribute.removeListener(self, listener)

        if ret and not self.hasListeners():
            self._deactivatePolling()
            self.__subscription_state = SubscriptionState.Unsubscribed
        return ret
Example #12
0
 def setRange(self, *limits):
     if isinstance(limits[0], list):
         limits = limits[0]
     low, high = limits
     low = Quantity(low)
     if low.unitless:
         low = Quantity(low.magnitude, self._units)
     high = Quantity(high)
     if high.unitless:
         high = Quantity(high.magnitude, self._units)
     TaurusAttribute.setRange(self, [low, high])
     infoex = self._pytango_attrinfoex
     if low.magnitude != float('-inf'):
         infoex.min_value = str(low.to(self._units).magnitude)
     else:
         infoex.min_value = 'Not specified'
     if high.magnitude != float('inf'):
         infoex.max_value = str(high.to(self._units).magnitude)
     else:
         infoex.max_value = 'Not specified'
     self._applyConfig()
Example #13
0
    def removeListener(self, listener):
        """ Remove a TaurusListener from the listeners list. If polling enabled
            and it is the last element the stop the polling timer.
            If the listener is not registered nothing happens."""
        ret = TaurusAttribute.removeListener(self, listener)

        if not ret:
            return ret

        if self.hasListeners():
            return ret

        if self.__subscription_state != SubscriptionState.Unsubscribed:
            self._unsubscribeEvents()

        return ret
    def removeListener(self, listener):
        """ Remove a TaurusListener from the listeners list. If polling enabled
            and it is the last element the stop the polling timer.
            If the listener is not registered nothing happens."""
        ret = TaurusAttribute.removeListener(self, listener)

        if not ret:
            return ret

        if self.hasListeners():
            return ret

        if self.__subscription_state != SubscriptionState.Unsubscribed:
            self._unsubscribeEvents()

        return ret
Example #15
0
 def setLabel(self, lbl):
     TaurusAttribute.setLabel(self, lbl)
     infoex = self._pytango_attrinfoex
     infoex.label = lbl
     self._applyConfig()
Example #16
0
 def cleanUp(self):
     self.trace("[TangoAttribute] cleanUp")
     self._unsubscribeConfEvents()
     TaurusAttribute.cleanUp(self)
     self.__dev_hw_obj = None
     self._pytango_attrinfoex = None
 def cleanUp(self):
     self.trace("[TangoAttribute] cleanUp")
     self._unsubscribeConfEvents()
     TaurusAttribute.cleanUp(self)
     self.__dev_hw_obj = None
     self._pytango_attrinfoex = None
 def setLabel(self, lbl):
     TaurusAttribute.setLabel(self, lbl)
     infoex = self._pytango_attrinfoex
     infoex.label = lbl
     self._applyConfig()