Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_fetch_multiple(single_channel_session):
single_channel_session.source_mode = nidcpower.SourceMode.SINGLE_POINT
single_channel_session.configure_aperture_time(0, nidcpower.ApertureTimeUnits.SECONDS)
single_channel_session.voltage_level = 1
count = 10
single_channel_session.measure_when = nidcpower.MeasureWhen.AUTOMATICALLY_AFTER_SOURCE_COMPLETE
with single_channel_session.initiate():
measurements = single_channel_session.fetch_multiple(count)
assert len(measurements) == count
assert isinstance(measurements[1].voltage, float)
assert isinstance(measurements[1].current, float)
assert measurements[1].in_compliance in [True, False]
assert measurements[1].voltage == 1.0
assert measurements[1].current == 0.00001
def example(resource_name, channels, options, voltage1, voltage2, delay):
timeout = hightime.timedelta(seconds=(delay + 1.0))
with nidcpower.Session(resource_name=resource_name, channels=channels, options=options) as session:
# Configure the session.
session.source_mode = nidcpower.SourceMode.SINGLE_POINT
session.output_function = nidcpower.OutputFunction.DC_VOLTAGE
session.current_limit = .06
session.voltage_level_range = 5.0
session.current_limit_range = .06
session.source_delay = hightime.timedelta(seconds=delay)
session.measure_when = nidcpower.MeasureWhen.AUTOMATICALLY_AFTER_SOURCE_COMPLETE
session.voltage_level = voltage1
with session.initiate():
print('Voltage 1:')
print_fetched_measurements(session.fetch_multiple(count=1, timeout=timeout))
session.voltage_level = voltage2 # on-the-fly set
print('Voltage 2:')
print_fetched_measurements(session.fetch_multiple(count=1, timeout=timeout))
session.output_enabled = False
def example(resource_name, channels, options, voltage_max, current_max, points_per_output_function, delay_in_seconds):
timeout = hightime.timedelta(seconds=(delay_in_seconds + 1.0))
with nidcpower.Session(resource_name=resource_name, channels=channels, options=options) as session:
# Configure the session.
session.source_mode = nidcpower.SourceMode.SEQUENCE
session.voltage_level_autorange = True
session.current_limit_autorange = True
session.source_delay = hightime.timedelta(seconds=delay_in_seconds)
properties_used = ['output_function', 'voltage_level', 'current_level']
session.create_advanced_sequence(sequence_name='my_sequence', property_names=properties_used, set_as_active_sequence=True)
voltage_per_step = voltage_max / points_per_output_function
for i in range(points_per_output_function):
session.create_advanced_sequence_step(set_as_active_step=False)
session.output_function = nidcpower.OutputFunction.DC_VOLTAGE
session.voltage_level = voltage_per_step * i
current_per_step = current_max / points_per_output_function
for i in range(points_per_output_function):
session.create_advanced_sequence_step(set_as_active_step=False)
session.output_function = nidcpower.OutputFunction.DC_CURRENT