Beispiel #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()
Beispiel #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()
Beispiel #3
0
    def getOption(self, key):
        opts = self.options

        if key == 'optlist':
            return opts.keys()

        if key == 'area':
            return (opts["tl-x"], opts["tl-y"]), (opts["br-x"], opts["br-y"])

        if key not in opts:
            raise AttributeError, 'No such attribute: %s' % key

        opt = opts[key]

        if opt.type == scanext.TYPE_BUTTON:
            raise AttributeError, "Buttons don't have values: %s" % key

        if opt.type == scanext.TYPE_GROUP:
            raise AttributeError, "Groups don't have values: %s " % key

        if not scanext.isOptionActive(opt.cap):
            raise AttributeError, 'Inactive option: %s' % key

        return self.dev.getOption(opt.index)
Beispiel #4
0
    def getOption(self, key):
        opts = self.options

        if key == 'optlist':
            return opts.keys()

        if key == 'area':
            return (opts["tl-x"], opts["tl-y"]), (opts["br-x"], opts["br-y"])

        if key not in opts:
            raise AttributeError, 'No such attribute: %s' % key

        opt = opts[key]

        if opt.type == scanext.TYPE_BUTTON:
            raise AttributeError, "Buttons don't have values: %s" % key

        if opt.type == scanext.TYPE_GROUP:
            raise AttributeError, "Groups don't have values: %s " % key

        if not scanext.isOptionActive(opt.cap):
            raise AttributeError, 'Inactive option: %s' % key

        return self.dev.getOption(opt.index)
Beispiel #5
0
 def isActive(self):
     return scanext.isOptionActive(self.cap)
Beispiel #6
0
 def isActive(self):
     return scanext.isOptionActive(self.cap)