-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
120 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
import pytest | ||
|
||
from nidaqmx.constants import AcquisitionType, Edge, Level, LineGrouping, Polarity | ||
from nidaqmx.task import Task | ||
|
||
|
||
@pytest.fixture() | ||
def sim_6535_di_single_line_task(task, sim_6535_device) -> Task: | ||
"""Gets DI task.""" | ||
task.di_channels.add_di_chan( | ||
sim_6535_device.di_lines[0].name, line_grouping=LineGrouping.CHAN_FOR_ALL_LINES | ||
) | ||
return task | ||
|
||
|
||
def test___timing___cfg_handshaking___no_errors( | ||
sim_6535_di_single_line_task: Task, | ||
): | ||
sim_6535_di_single_line_task.timing.cfg_handshaking_timing( | ||
AcquisitionType.FINITE, samps_per_chan=2000 | ||
) | ||
|
||
|
||
def test___timing___cfg_change_detection___no_errors( | ||
sim_6535_di_single_line_task: Task, | ||
): | ||
sim_6535_di_single_line_task.timing.cfg_change_detection_timing( | ||
"port0/line0:1", "port0/line3:5", AcquisitionType.FINITE, samps_per_chan=2000 | ||
) | ||
|
||
assert ( | ||
sim_6535_di_single_line_task.timing.change_detect_di_rising_edge_physical_chans.name | ||
== "port0/line0, port0/line1" | ||
) | ||
assert ( | ||
sim_6535_di_single_line_task.timing.change_detect_di_falling_edge_physical_chans.name | ||
== "port0/line3, port0/line4, port0/line5" | ||
) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"clk_source, active_edge", | ||
[ | ||
("/Dev1/PFI0", Edge.RISING), | ||
("/Dev1/PFI1", Edge.FALLING), | ||
], | ||
) | ||
def test___timing___cfg_pipelined_samp_clk___no_errors( | ||
sim_6535_di_single_line_task: Task, | ||
clk_source: str, | ||
active_edge: int, | ||
): | ||
sim_6535_di_single_line_task.timing.cfg_pipelined_samp_clk_timing( | ||
rate=32000.0, | ||
source=clk_source, | ||
active_edge=active_edge, | ||
sample_mode=AcquisitionType.FINITE, | ||
samps_per_chan=2000, | ||
) | ||
|
||
assert sim_6535_di_single_line_task.timing.samp_clk_src == clk_source | ||
assert sim_6535_di_single_line_task.timing.samp_clk_active_edge == active_edge | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"clk_source, active_edge, pause_when, ready_event_active_level", | ||
[ | ||
("/Dev1/PFI0", Edge.RISING, Level.HIGH, Polarity.ACTIVE_HIGH), | ||
("/Dev1/PFI1", Edge.FALLING, Level.HIGH, Polarity.ACTIVE_LOW), | ||
("/Dev1/PFI1", Edge.FALLING, Level.LOW, Polarity.ACTIVE_LOW), | ||
], | ||
) | ||
def test___timing___cfg_burst_handshaking_import_clock___no_errors( | ||
sim_6535_di_single_line_task: Task, | ||
clk_source: str, | ||
active_edge: int, | ||
pause_when: int, | ||
ready_event_active_level: int, | ||
): | ||
sim_6535_di_single_line_task.timing.cfg_burst_handshaking_timing_import_clock( | ||
sample_clk_rate=32000.0, | ||
sample_clk_src=clk_source, | ||
sample_mode=AcquisitionType.FINITE, | ||
samps_per_chan=2000, | ||
sample_clk_active_edge=active_edge, | ||
pause_when=pause_when, | ||
ready_event_active_level=ready_event_active_level, | ||
) | ||
|
||
assert sim_6535_di_single_line_task.timing.samp_clk_rate == 32000 | ||
assert sim_6535_di_single_line_task.timing.samp_clk_src == clk_source | ||
assert sim_6535_di_single_line_task.timing.samp_clk_active_edge == active_edge | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"clk_outp_term, clk_pulse_polarity, pause_when, ready_event_active_level", | ||
[ | ||
("/Dev1/PFI0", Polarity.ACTIVE_HIGH, Level.HIGH, Polarity.ACTIVE_HIGH), | ||
("/Dev1/PFI1", Polarity.ACTIVE_HIGH, Level.HIGH, Polarity.ACTIVE_LOW), | ||
("/Dev1/PFI1", Polarity.ACTIVE_LOW, Level.LOW, Polarity.ACTIVE_LOW), | ||
], | ||
) | ||
def test___timing___cfg_burst_handshaking_export_clock___no_errors( | ||
sim_6535_di_single_line_task: Task, | ||
clk_outp_term: str, | ||
clk_pulse_polarity: int, | ||
pause_when: int, | ||
ready_event_active_level: int, | ||
): | ||
sim_6535_di_single_line_task.timing.cfg_burst_handshaking_timing_export_clock( | ||
sample_clk_rate=32000.0, | ||
sample_clk_outp_term=clk_outp_term, | ||
sample_mode=AcquisitionType.FINITE, | ||
samps_per_chan=2000, | ||
sample_clk_pulse_polarity=clk_pulse_polarity, | ||
pause_when=pause_when, | ||
ready_event_active_level=ready_event_active_level, | ||
) | ||
|
||
assert sim_6535_di_single_line_task.timing.samp_clk_rate == 32000 |