Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, expected_size_or_value):
_BufferMatcher.__init__(self, visatype.ViInt32, expected_size_or_value)
index. Use get_channel_name in a For Loop to get a complete list
of valid channel names for the switch module. Use the Channel Count
attribute to determine the number of channels.
Args:
index (int): A 1-based index into the channel table. Default value: 1 Maximum value:
Value of Channel Count attribute.
'''
vi_ctype = visatype.ViSession(self._vi) # case S110
index_ctype = visatype.ViInt32(index) # case S150
buffer_size_ctype = visatype.ViInt32() # case S170
channel_name_buffer_ctype = None # case C050
error_code = self._library.niSwitch_GetChannelName(vi_ctype, index_ctype, buffer_size_ctype, channel_name_buffer_ctype)
errors.handle_error(self, error_code, ignore_warnings=True, is_error_handling=False)
buffer_size_ctype = visatype.ViInt32(error_code) # case S180
channel_name_buffer_ctype = (visatype.ViChar * buffer_size_ctype.value)() # case C060
error_code = self._library.niSwitch_GetChannelName(vi_ctype, index_ctype, buffer_size_ctype, channel_name_buffer_ctype)
errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False)
return channel_name_buffer_ctype.value.decode(self._encoding)
current execution thread. If the InstrumentHandle parameter is an
invalid session, the function does nothing and returns an error.
Normally, the error information describes the first error that occurred
since the user last called _get_error or ClearError.
Note:
One or more of the referenced functions are not in the Python API for this driver.
Returns:
code (int): Returns the error code for the session or execution thread. If you pass
0 for the Buffer Size, you can pass VI_NULL for this parameter.
'''
vi_ctype = visatype.ViSession(self._vi) # case S110
code_ctype = visatype.ViStatus() # case S200
buffer_size_ctype = visatype.ViInt32() # case S170
description_ctype = None # case C050
error_code = self._library.niSwitch_GetError(vi_ctype, None if code_ctype is None else (ctypes.pointer(code_ctype)), buffer_size_ctype, description_ctype)
errors.handle_error(self, error_code, ignore_warnings=True, is_error_handling=True)
buffer_size_ctype = visatype.ViInt32(error_code) # case S180
description_ctype = (visatype.ViChar * buffer_size_ctype.value)() # case C060
error_code = self._library.niSwitch_GetError(vi_ctype, None if code_ctype is None else (ctypes.pointer(code_ctype)), buffer_size_ctype, description_ctype)
errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=True)
return int(code_ctype.value), description_ctype.value.decode(self._encoding)
names: ch0, com0, ab0, r1, c2, cjtemp Default value: ""
channel2 (str): Input one of the channel names of the desired path. Pass the other
channel name as the channel 1 parameter. Refer to Devices Overview for
valid channel names for the switch module. Examples of valid channel
names: ch0, com0, ab0, r1, c2, cjtemp Default value: ""
'''
vi_ctype = visatype.ViSession(self._vi) # case S110
channel1_ctype = ctypes.create_string_buffer(channel1.encode(self._encoding)) # case C020
channel2_ctype = ctypes.create_string_buffer(channel2.encode(self._encoding)) # case C020
buffer_size_ctype = visatype.ViInt32() # case S170
path_ctype = None # case C050
error_code = self._library.niSwitch_GetPath(vi_ctype, channel1_ctype, channel2_ctype, buffer_size_ctype, path_ctype)
errors.handle_error(self, error_code, ignore_warnings=True, is_error_handling=False)
buffer_size_ctype = visatype.ViInt32(error_code) # case S180
path_ctype = (visatype.ViChar * buffer_size_ctype.value)() # case C060
error_code = self._library.niSwitch_GetPath(vi_ctype, channel1_ctype, channel2_ctype, buffer_size_ctype, path_ctype)
errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False)
return path_ctype.value.decode(self._encoding)
Note:
One or more of the referenced functions are not in the Python API for this driver.
Returns:
code (int): Returns the error code for the session or execution thread. If you pass
0 for the Buffer Size, you can pass VI_NULL for this parameter.
'''
vi_ctype = visatype.ViSession(self._vi) # case S110
code_ctype = visatype.ViStatus() # case S200
buffer_size_ctype = visatype.ViInt32() # case S170
description_ctype = None # case C050
error_code = self._library.niSwitch_GetError(vi_ctype, None if code_ctype is None else (ctypes.pointer(code_ctype)), buffer_size_ctype, description_ctype)
errors.handle_error(self, error_code, ignore_warnings=True, is_error_handling=True)
buffer_size_ctype = visatype.ViInt32(error_code) # case S180
description_ctype = (visatype.ViChar * buffer_size_ctype.value)() # case C060
error_code = self._library.niSwitch_GetError(vi_ctype, None if code_ctype is None else (ctypes.pointer(code_ctype)), buffer_size_ctype, description_ctype)
errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=True)
return int(code_ctype.value), description_ctype.value.decode(self._encoding)
accurate count. Refer to the Relay Count topic in the NI Switches Help
to determine if the switch module supports relay counting.
Args:
relay_name (str): Name of the relay. Default value: None Examples of valid relay names:
ch0, ab0, 1wire, hlselect Refer to Devices Overview for a list of valid
relay names for the switch module.
Returns:
relay_count (int): The number of relay cycles.
'''
vi_ctype = visatype.ViSession(self._vi) # case S110
relay_name_ctype = ctypes.create_string_buffer(relay_name.encode(self._encoding)) # case C020
relay_count_ctype = visatype.ViInt32() # case S200
error_code = self._library.niSwitch_GetRelayCount(vi_ctype, relay_name_ctype, None if relay_count_ctype is None else (ctypes.pointer(relay_count_ctype)))
errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False)
return int(relay_count_ctype.value)
def get_relay_name(self, index):
'''get_relay_name
Returns the relay name string that is in the relay list at the specified
index. Use get_relay_name in a For Loop to get a complete list
of valid relay names for the switch module. Use the Number of Relays
attribute to determine the number of relays.
Args:
index (int): A 1-based index into the channel table. Default value: 1 Maximum value:
Value of Channel Count attribute.
'''
vi_ctype = visatype.ViSession(self._vi) # case S110
index_ctype = visatype.ViInt32(index) # case S150
relay_name_buffer_size_ctype = visatype.ViInt32() # case S170
relay_name_buffer_ctype = None # case C050
error_code = self._library.niSwitch_GetRelayName(vi_ctype, index_ctype, relay_name_buffer_size_ctype, relay_name_buffer_ctype)
errors.handle_error(self, error_code, ignore_warnings=True, is_error_handling=False)
relay_name_buffer_size_ctype = visatype.ViInt32(error_code) # case S180
relay_name_buffer_ctype = (visatype.ViChar * relay_name_buffer_size_ctype.value)() # case C060
error_code = self._library.niSwitch_GetRelayName(vi_ctype, index_ctype, relay_name_buffer_size_ctype, relay_name_buffer_ctype)
errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False)
return relay_name_buffer_ctype.value.decode(self._encoding)
scan_delay (float): The minimum length of time you want the switch device to wait after it
creates a path until it asserts a trigger on the scan advanced output
line. The driver uses this value to set the Scan Delay attribute. The
scan delay is in addition to the settling time.The driver uses this
value to set the scan_delay attribute. Express this
value in seconds. Default value: 0.0 s
'''
if type(trigger_input) is not enums.TriggerInput:
raise TypeError('Parameter mode must be of type ' + str(enums.TriggerInput))
if type(scan_advanced_output) is not enums.ScanAdvancedOutput:
raise TypeError('Parameter mode must be of type ' + str(enums.ScanAdvancedOutput))
vi_ctype = visatype.ViSession(self._vi) # case S110
scan_delay_ctype = visatype.ViReal64(scan_delay) # case S150
trigger_input_ctype = visatype.ViInt32(trigger_input.value) # case S130
scan_advanced_output_ctype = visatype.ViInt32(scan_advanced_output.value) # case S130
error_code = self._library.niSwitch_ConfigureScanTrigger(vi_ctype, scan_delay_ctype, trigger_input_ctype, scan_advanced_output_ctype)
errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False)
return
TriggerInput.TTL2 TriggerInput.TTL3 TriggerInput.TTL4
TriggerInput.TTL5 TriggerInput.TTL6 TriggerInput.TTL7
Note:
One or more of the referenced values are not in the Python API for this driver. Enums that only define values, or represent True/False, have been removed.
invert (bool): If VI_TRUE, inverts the input trigger signal from falling to rising or
vice versa. Default value: VI_FALSE
'''
if type(trigger_input_connector) is not enums.TriggerInput:
raise TypeError('Parameter mode must be of type ' + str(enums.TriggerInput))
if type(trigger_input_bus_line) is not enums.TriggerInput:
raise TypeError('Parameter mode must be of type ' + str(enums.TriggerInput))
vi_ctype = visatype.ViSession(self._vi) # case S110
trigger_input_connector_ctype = visatype.ViInt32(trigger_input_connector.value) # case S130
trigger_input_bus_line_ctype = visatype.ViInt32(trigger_input_bus_line.value) # case S130
invert_ctype = visatype.ViBoolean(invert) # case S150
error_code = self._library.niSwitch_RouteTriggerInput(vi_ctype, trigger_input_connector_ctype, trigger_input_bus_line_ctype, invert_ctype)
errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False)
return