Пример #1
0
 def get_attribute(self, name):
     """Return current value of attribute of the given name"""
     try:
         value = nv.IMAQdxGetAttribute(self.imaqdx, name.encode('utf8'))
         if isinstance(value, nv.core.IMAQdxEnumItem):
             value = value.Name
         if isinstance(value, bytes):
             value = value.decode('utf8')
         return value
     except Exception as e:
         # Add some info to the exception:
         raise Exception(f"Failed to get attribute {name}") from e
Пример #2
0
    def get_attribute(self, attr):
        try:
            attr = nv.IMAQdxGetAttribute(self.imaqdx,
                                         bytes(attr, encoding='utf8'))
        except nv.ImaqDxError as e:
            print('ImaqDxError: ' + str(e))
            return None

        # It can either be a number or IMAQdxEnumItem. Return value or name
        try:
            return attr.Name.decode('utf8')
        except AttributeError:
            return attr