Skip to content

Commit fe0cfc3

Browse files
Mike ProsserMike Prosser
authored andcommitted
improve run/stop button behavior in nidaqmx example
1 parent d23d9c1 commit fe0cfc3

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

examples/nidaqmx/nidaqmx_continuous_analog_input.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,13 @@
2121

2222
try:
2323
print(f"Panel URL: {panel.panel_url}")
24-
print(f"Press Ctrl + C to quit")
24+
print(f"Waiting for the 'Run' button to be pressed...")
25+
print(f"(Press Ctrl + C to quit)")
2526
while True:
26-
print(f"Waiting for the 'Run' button to be pressed...")
27+
panel.set_value("run_button", False)
2728
while not panel.get_value("run_button", False):
2829
time.sleep(0.1)
2930

30-
panel.set_value("is_running", True)
31-
3231
# How to use nidaqmx: https://nidaqmx-python.readthedocs.io/en/stable/
3332
with nidaqmx.Task() as task:
3433
task.ai_channels.add_ai_voltage_chan(
@@ -64,6 +63,9 @@
6463
try:
6564
print(f"Starting data acquisition...")
6665
task.start()
66+
panel.set_value("is_running", True)
67+
68+
panel.set_value("stop_button", False)
6769
while not panel.get_value("stop_button", False):
6870
data = task.read(
6971
number_of_samples_per_channel=1000 # pyright: ignore[reportArgumentType]

0 commit comments

Comments
 (0)