コード例 #1
0
    def enumerate_attributes(self,
                             root='',
                             writeable=True,
                             visibility='simple'):
        # root can be AcquisitionAttributes, CameraAttributes,
        # CameraInformation and the like
        if visibility == 'simple':
            visibility = nv.IMAQdxAttributeVisibilitySimple
        elif visibility == 'intermediate':
            visibility = nv.IMAQdxAttributeVisibilityIntermediate
        elif visibility == 'advanced':
            visibility = nv.IMAQdxAttributeVisibilityAdvanced
        else:
            raise Exception("visibility can be 'simple', "
                            "'inetermediate' or 'advanced'.")

        attrs = nv.IMAQdxEnumerateAttributes2(self.imaqdx,
                                              bytes(root, encoding='utf8'),
                                              visibility)

        # returns an iterable conveniently
        if writeable:
            attrs_writeable = []
            for attr in attrs:
                if nv.IMAQdxIsAttributeWritable(self.imaqdx, attr.Name):
                    attrs_writeable.append(attr)

            return attrs_writeable  # this one return list

        return attrs  # this one return ImaqArray
コード例 #2
0
 def get_attribute_names(self, visibility_level, writeable_only=True):
     """Return a list of all attribute names of readable attributes, for the given
     visibility level. Optionally return only writeable attributes"""
     visibilities = {
         'simple': nv.IMAQdxAttributeVisibilitySimple,
         'intermediate': nv.IMAQdxAttributeVisibilityIntermediate,
         'advanced': nv.IMAQdxAttributeVisibilityAdvanced,
     }
     visibility_level = visibilities[visibility_level.lower()]
     attributes = []
     for a in nv.IMAQdxEnumerateAttributes2(self.imaqdx, b'',
                                            visibility_level):
         if writeable_only and not a.Writable:
             continue
         if not a.Readable:
             continue
         attributes.append(a.Name.decode('utf8'))
     return sorted(attributes)