예제 #1
0
    def setEnabled(self, setState):
        if self.state == deviceHandler.STATES.constant != setState:
            if 'setExposing' in self.callbacks:
                self.callbacks['setExposing'](self.name, False)

        if setState == deviceHandler.STATES.constant:
            if self.state == setState:
                # Turn off the light
                self.callbacks['setEnabled'](self.name, False)
                # Update setState since used to set self.state later
                setState = deviceHandler.STATES.disabled
                events.publish(events.LIGHT_SOURCE_ENABLE, self, False)
            else:
                # Turn on the light continuously.
                self.callbacks['setEnabled'](self.name, True)
                if 'setExposing' in self.callbacks:
                    self.callbacks['setExposing'](self.name, True)
                # We indicate that the light source is disabled to prevent
                # it being switched off by an exposure, but this event is
                # used to update controls, so we need to chain it with a
                # manual update.
                events.oneShotSubscribe(
                    events.LIGHT_SOURCE_ENABLE,
                    lambda *args: self.notifyListeners(self, setState))
                events.publish(events.LIGHT_SOURCE_ENABLE, self, False)
        elif setState == deviceHandler.STATES.enabled:
            self.callbacks['setEnabled'](self.name, True)
            events.publish(events.LIGHT_SOURCE_ENABLE, self, True)
        else:
            self.callbacks['setEnabled'](self.name, False)
            events.publish(events.LIGHT_SOURCE_ENABLE, self, False)
        self.state = setState
예제 #2
0
    def __init__(self,
                 name: str,
                 groupName: str,
                 settings: typing.Sequence[DrawerSettings],
                 settingIndex: int,
                 callbacks={}) -> None:
        super().__init__(name, groupName, False, callbacks, depot.DRAWER)
        self.settings = settings
        self.settingIndex = settingIndex

        # Last thing to do is update UI to show default selections.
        initial_settings = self.settings[self.settingIndex]
        events.oneShotSubscribe('cockpit initialization complete',
                                lambda: self.changeDrawer(initial_settings))