Skip to content

Commit f158a15

Browse files
author
Dilmi Wickramanayake
committed
updated run button and panel methods
1 parent 2d31d50 commit f158a15

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

examples/nidaqmx/nidaqmx_analog_input_filtering/nidaqmx_analog_input_filtering.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import nipanel
2121

2222
panel_script_path = Path(__file__).with_name("nidaqmx_analog_input_filtering_panel.py")
23-
panel = nipanel.create_panel(panel_script_path)
23+
panel = nipanel.create_streamlit_panel(panel_script_path)
2424
panel.set_value("is_running", False)
2525

2626
system = nidaqmx.system.System.local()
@@ -42,12 +42,9 @@
4242
print(f"Waiting for the 'Run' button to be pressed...")
4343
print(f"(Press Ctrl + C to quit)")
4444
while True:
45+
panel.set_value("run_button", False)
4546
while not panel.get_value("run_button", False):
46-
panel.set_value("is_running", False)
4747
time.sleep(0.1)
48-
panel.set_value("is_running", True)
49-
panel.set_value("stop_button", False)
50-
5148
# How to use nidaqmx: https://nidaqmx-python.readthedocs.io/en/stable/
5249
with nidaqmx.Task() as task:
5350

@@ -132,6 +129,9 @@
132129

133130
try:
134131
task.start()
132+
panel.set_value("is_running", True)
133+
134+
panel.set_value("stop_button", False)
135135
while not panel.get_value("stop_button", False):
136136
data = task.read(
137137
number_of_samples_per_channel=100 # pyright: ignore[reportArgumentType]
@@ -142,7 +142,6 @@
142142
finally:
143143
task.stop()
144144
panel.set_value("is_running", False)
145-
panel.set_value("run_button", False)
146145

147146

148147
except KeyboardInterrupt:

examples/nidaqmx/nidaqmx_analog_input_filtering/nidaqmx_analog_input_filtering_panel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
st.set_page_config(page_title="Analog Input Filtering", page_icon="📈", layout="wide")
2121
st.title("Analog Input - Filtering")
22-
panel = nipanel.get_panel_accessor()
22+
panel = nipanel.get_streamlit_panel_accessor()
2323

2424
left_col, right_col = st.columns(2)
2525

0 commit comments

Comments
 (0)