Пример #1
0
 def _get_installed_device_attribute_vi_int32(self, handle, index,
                                              attribute_id):
     attribute_value_ctype = ctypes_types.ViInt32_ctype(0)
     error_code = self.library.niModInst_GetInstalledDeviceAttributeViInt32(
         handle, index, attribute_id, ctypes.pointer(attribute_value_ctype))
     errors._handle_error(self, error_code)
     return attribute_value_ctype.value
Пример #2
0
 def get_extended_error_info(self, error_info_buffer_size):
     error_info_ctype = ctypes_types.ViChar_ctype(
         0)  # TODO(marcoskirsch): allocate a buffer
     error_code = self.library.niModInst_GetExtendedErrorInfo(
         error_info_buffer_size, ctypes.pointer(error_info_ctype))
     errors._handle_error(self, error_code)
     return error_info_ctype.value.decode("ascii")
Пример #3
0
 def _open_installed_devices_session(self, driver):
     handle_ctype = ctypes_types.ViSession_ctype(0)
     item_count_ctype = ctypes_types.ViInt32_ctype(0)
     error_code = self.library.niModInst_OpenInstalledDevicesSession(
         driver.encode('ascii'), ctypes.pointer(handle_ctype),
         ctypes.pointer(item_count_ctype))
     errors._handle_error(self, error_code)
     return handle_ctype.value, item_count_ctype.value
Пример #4
0
 def _get_installed_device_attribute_vi_string(self, handle, index,
                                               attribute_id,
                                               attribute_value_buffer_size):
     attribute_value_ctype = ctypes_types.ViChar_ctype(
         0)  # TODO(marcoskirsch): allocate a buffer
     error_code = self.library.niModInst_GetInstalledDeviceAttributeViString(
         handle, index, attribute_id, attribute_value_buffer_size,
         ctypes.pointer(attribute_value_ctype))
     errors._handle_error(self, error_code)
     return attribute_value_ctype.value.decode("ascii")
Пример #5
0
 def get_extended_error_info(self):
     error_info_buffer_size = 0
     error_info_ctype = ctypes.cast(
         ctypes.create_string_buffer(error_info_buffer_size),
         ctypes_types.ViString_ctype)
     error_code = self.library.niModInst_GetExtendedErrorInfo(
         error_info_buffer_size, error_info_ctype)
     # Don't use _handle_error, because positive value in error_code means size, not warning.
     if (errors._is_error(error_code)):
         raise errors.Error(self.library, self.vi, error_code)
     error_info_buffer_size = error_code
     error_info_ctype = ctypes.cast(
         ctypes.create_string_buffer(error_info_buffer_size),
         ctypes_types.ViString_ctype)
     error_code = self.library.niModInst_GetExtendedErrorInfo(
         error_info_buffer_size, error_info_ctype)
     errors._handle_error(self, error_code)
     return error_info_ctype.value.decode("ascii")
Пример #6
0
 def _get_installed_device_attribute_vi_string(self, index,
                                               attribute_id):  # noqa: F811
     # Do the IVI dance
     # Don't use _handle_error, because positive value in error_code means size, not warning.
     buffer_size = 0
     value_ctype = ctypes.create_string_buffer(buffer_size)
     error_code = self.library.niModInst_GetInstalledDeviceAttributeViString(
         self.handle, index, attribute_id, buffer_size,
         ctypes.cast(value_ctype,
                     ctypes.POINTER(ctypes_types.ViChar_ctype)))
     if (errors._is_error(error_code)):
         raise errors.Error(self, error_code)
     buffer_size = error_code
     value_ctype = ctypes.create_string_buffer(buffer_size)
     error_code = self.library.niModInst_GetInstalledDeviceAttributeViString(
         self.handle, index, attribute_id, buffer_size,
         ctypes.cast(value_ctype,
                     ctypes.POINTER(ctypes_types.ViChar_ctype)))
     errors._handle_error(self, error_code)
     return value_ctype.value.decode("ascii")
Пример #7
0
 def _get_installed_device_attribute_vi_string(self, handle, index,
                                               attribute_id):
     attribute_value_buffer_size = 0
     attribute_value_ctype = ctypes.cast(
         ctypes.create_string_buffer(attribute_value_buffer_size),
         ctypes_types.ViString_ctype)
     error_code = self.library.niModInst_GetInstalledDeviceAttributeViString(
         self.handle, index, attribute_id, attribute_value_buffer_size,
         attribute_value_ctype)
     # Don't use _handle_error, because positive value in error_code means size, not warning.
     if (errors._is_error(error_code)):
         raise errors.Error(self.library, self.vi, error_code)
     attribute_value_buffer_size = error_code
     attribute_value_ctype = ctypes.cast(
         ctypes.create_string_buffer(attribute_value_buffer_size),
         ctypes_types.ViString_ctype)
     error_code = self.library.niModInst_GetInstalledDeviceAttributeViString(
         self.handle, index, attribute_id, attribute_value_buffer_size,
         attribute_value_ctype)
     errors._handle_error(self, error_code)
     return attribute_value_ctype.value.decode("ascii")
Пример #8
0
 def _close_installed_devices_session(self, handle):
     error_code = self.library.niModInst_CloseInstalledDevicesSession(
         handle)
     errors._handle_error(self, error_code)
     return