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(session):
session.configure_measurement_digits(nidmm.Function.DC_VOLTS, 10, 5.5)
session.configure_multi_point(sample_count=10, trigger_count=1)
with session.initiate():
measurements = session.fetch_multi_point(5)
assert len(measurements) == 5
measurements = session.fetch_multi_point(5)
backlog, acquisition_state = session.read_status()
assert acquisition_state == nidmm.AcquisitionStatus.FINISHED_WITH_NO_BACKLOG
def test_configure_waveform_acquisition(session):
session.configure_waveform_acquisition(nidmm.Function.WAVEFORM_VOLTAGE, 100, 1800000, 400)
assert session.function == nidmm.Function.WAVEFORM_VOLTAGE
assert session.range == 100
assert session.waveform_rate == 1800000
assert session.waveform_points == 400
def test_enum_attribute(session):
session.function = nidmm.Function.AC_CURRENT
assert session.function == nidmm.Function.AC_CURRENT
assert type(session.function) is nidmm.Function
try:
session.function = nidmm.LCCalculationModel.SERIES
assert False
except TypeError as e:
pass
def test_enum_attribute(session):
session.function = nidmm.Function.AC_CURRENT
assert session.function == nidmm.Function.AC_CURRENT
assert type(session.function) is nidmm.Function
try:
session.function = nidmm.LCCalculationModel.SERIES
assert False
except TypeError as e:
pass
def _main(argsv):
parser = argparse.ArgumentParser(description='Performs a waveform acquisition using the NI-DMM API.', formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('-n', '--resource-name', default='PXI1Slot2', help='Resource name of a National Instruments Digital Multimeter.')
parser.add_argument('-f', '--function', default='WAVEFORM_VOLTAGE', choices=nidmm.Function.__members__.keys(), type=str.upper, help='Measurement function.')
parser.add_argument('-r', '--range', default=10, type=float, help='Measurement range.')
parser.add_argument('-p', '--points', default=10, type=int, help='Specifies the number of points to acquire before the waveform acquisition completes.')
parser.add_argument('-s', '--rate', default=1000, type=int, help='Specifies the rate of the acquisition in samples per second.')
parser.add_argument('-op', '--option-string', default='', type=str, help='Option string')
args = parser.parse_args(argsv)
example(args.resource_name, args.option_string, args.function, args.range, args.points, args.rate)
def _main(argsv):
supported_functions = list(nidmm.Function.__members__.keys())
parser = argparse.ArgumentParser(description='Performs a single measurement using the NI-DMM API.', formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('-n', '--resource-name', default='PXI1Slot2', help='Resource name of a National Instruments Digital Multimeter.')
parser.add_argument('-f', '--function', default=supported_functions[0], choices=supported_functions, type=str.upper, help='Measurement function.')
parser.add_argument('-r', '--range', default=10, type=float, help='Measurement range.')
parser.add_argument('-d', '--digits', default=6.5, type=float, help='Digits of resolution for the measurement.')
parser.add_argument('-op', '--option-string', default='', type=str, help='Option string')
args = parser.parse_args(argsv)
example(args.resource_name, args.option_string, args.function, args.range, args.digits)
def _main(argsv):
parser = argparse.ArgumentParser(description='Performs a multipoint measurement using the NI-DMM API.', formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('-n', '--resource-name', default='PXI1Slot2', help='Resource name of a National Instruments Digital Multimeter.')
parser.add_argument('-f', '--function', default='DC_VOLTS', choices=nidmm.Function.__members__.keys(), type=str.upper, help='Measurement function.')
parser.add_argument('-r', '--range', default=10, type=float, help='Measurement range.')
parser.add_argument('-d', '--digits', default=6.5, type=float, help='Digits of resolution for the measurement.')
parser.add_argument('-s', '--samples', default=10, type=int, help='The number of measurements the DMM makes.')
parser.add_argument('-t', '--triggers', default=1, type=int, help='Sets the number of triggers you want the DMM to receive before returning to the Idle state.')
parser.add_argument('-op', '--option-string', default='', type=str, help='Option string')
args = parser.parse_args(argsv)
example(args.resource_name, args.option_string, args.function, args.range, args.digits, args.samples, args.triggers)
def example(resource_name, options, function, range, digits, samples, triggers):
with nidmm.Session(resource_name=resource_name, options=options) as session:
session.configure_measurement_digits(measurement_function=nidmm.Function[function], range=range, resolution_digits=digits)
session.configure_multi_point(trigger_count=triggers, sample_count=samples)
measurements = session.read_multi_point(array_size=samples)
print('Measurements: ', measurements)
def example(resource_name, options, function, range, points, rate):
with nidmm.Session(resource_name=resource_name, options=options) as session:
session.configure_waveform_acquisition(measurement_function=nidmm.Function[function], range=range, rate=rate, waveform_points=points)
with session.initiate():
while True:
time.sleep(0.1)
backlog, acquisition_state = session.read_status()
if acquisition_state == nidmm.AcquisitionStatus.FINISHED_WITH_NO_BACKLOG:
break
measurements = session.fetch_waveform(array_size=backlog)
print(measurements)
def example(resource_name, option_string, function, range, digits):
with nidmm.Session(resource_name=resource_name, options=option_string) as session:
session.configure_measurement_digits(measurement_function=nidmm.Function[function], range=range, resolution_digits=digits)
print(session.read())