def test_pulse_time_1_samp(self, x_series_device, seed):
# Reset the pseudorandom number generator with seed.
random.seed(seed)
high_time = random.uniform(0.001, 0.01)
low_time = random.uniform(0.001, 0.01)
starting_edge = random.choice([Edge.RISING, Edge.FALLING])
# Select random counters from the device.
counters = random.sample(self._get_device_counters(x_series_device), 2)
with nidaqmx.Task() as write_task, nidaqmx.Task() as read_task:
write_task.co_channels.add_co_pulse_chan_time(
counters[0], high_time=high_time, low_time=low_time)
write_task.timing.cfg_implicit_timing(
sample_mode=AcquisitionType.CONTINUOUS)
read_task.ci_channels.add_ci_pulse_chan_time(
counters[1], min_val=0.001, max_val=0.01)
read_task.ci_channels.all.ci_pulse_time_term = (
'/{0}InternalOutput'.format(counters[0]))
read_task.ci_channels.all.ci_pulse_time_starting_edge = (
starting_edge)
read_task.start()
write_task.start()
value_read = read_task.read(timeout=2)
write_task.stop()
assert numpy.isclose(value_read.high_time, high_time, rtol=0.01)
assert numpy.isclose(value_read.low_time, low_time, rtol=0.01)
评论列表
文章目录