Пример #1
0
    def setOption(self, key, value):
        opts = self.options

        if key not in opts:
            opts[key] = value
            return

        opt = opts[key]

        if opt.type == scanext.TYPE_GROUP:
            log.error("Groups can't be set: %s" % key)

        if not scanext.isOptionActive(opt.cap):
            log.error("Inactive option: %s" % key)

        if not scanext.isOptionSettable(opt.cap):
            log.error("Option can't be set by software: %s" % key)

        if type(value) == int and opt.type == scanext.TYPE_FIXED:
            # avoid annoying errors of backend if int is given instead float:
            value = float(value)

        try:
            self.last_opt = self.dev.setOption(opt.index, value)
        except scanext.error:
            log.error("Unable to set option %s to value %s" % (key, value))
            return

        # do binary AND to find if we have to reload options:
        if self.last_opt & scanext.INFO_RELOAD_OPTIONS:
            self.__load_options_dict()
Пример #2
0
    def setOption(self, key, value):
        opts = self.options

        if key not in opts:
            opts[key] = value
            return

        opt = opts[key]

        if opt.type == scanext.TYPE_GROUP:
            log.error("Groups can't be set: %s" % key)

        if not scanext.isOptionActive(opt.cap):
            log.error("Inactive option: %s" % key)

        if not scanext.isOptionSettable(opt.cap):
            log.error("Option can't be set by software: %s" % key)

        if type(value) == int and opt.type == scanext.TYPE_FIXED:
            # avoid annoying errors of backend if int is given instead float:
            value = float(value)

        try:
            self.last_opt = self.dev.setOption(opt.index, value)
        except scanext.error:
            log.error("Unable to set option %s to value %s" % (key, value))

        # do binary AND to find if we have to reload options:
        if self.last_opt & scanext.INFO_RELOAD_OPTIONS:
            self.__load_options_dict()
Пример #3
0
 def isSettable(self):
     return scanext.isOptionSettable(self.cap)
Пример #4
0
 def isSettable(self):
     return scanext.isOptionSettable(self.cap)