Skip to content

Commit d0cb228

Browse files
author
Dilmi Wickramanayake
committed
resolved comments
1 parent 098d9fb commit d0cb228

File tree

3 files changed

+38
-43
lines changed

3 files changed

+38
-43
lines changed

examples/nidaqmx/nidaqmx_analog_input_filtering/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Prerequisites
33
Requires a Physical or Simulated Device. Refer to the [Getting Started Section](https://github.com/ni/nidaqmx-python/blob/master/README.rst) to learn how to create a simulated device.
44
## Sample
55

6-
This is a nipanel example that displays an interactive Streamlit app and updates and fetches data from device.
6+
This is an nipanel example that displays an interactive Streamlit app and updates and fetches data from device.
77

88
### Feature
99

@@ -18,6 +18,6 @@ Script demonstrates analog input data getting continuously acquired, and being f
1818

1919
```pwsh
2020
poetry install --with examples
21-
poetry run python examples/all_types/all_types.py
21+
poetry run python examples/nidaqmx/nidaqmx_analog_input_filtering/nidaqmx_analog_input_filtering.py
2222
```
2323

examples/nidaqmx/nidaqmx_analog_input_filtering/nidaqmx_analog_input_filtering.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@
2525

2626
system = nidaqmx.system.System.local()
2727

28-
channel_name = []
28+
available_channel_name = []
2929
for dev in system.devices:
3030
for chan in dev.ai_physical_chans:
31-
channel_name.append(chan.name)
32-
panel.set_value("channel_name", channel_name)
31+
available_channel_name.append(chan.name)
32+
panel.set_value("available_channel_name", available_channel_name)
3333

34-
trigger_sources = []
34+
available_trigger_sources = []
3535
for dev in system.devices:
3636
if hasattr(dev, "terminals"):
3737
for term in dev.terminals:
38-
trigger_sources.append(term)
39-
panel.set_value("trigger_sources", trigger_sources)
38+
available_trigger_sources.append(term)
39+
panel.set_value("available_trigger_sources", available_trigger_sources)
4040
try:
4141
print(f"Panel URL: {panel.panel_url}")
4242
print(f"Waiting for the 'Run' button to be pressed...")
@@ -96,8 +96,7 @@
9696
sample_mode=AcquisitionType.CONTINUOUS,
9797
samps_per_chan=panel.get_value("total_samples", 100),
9898
)
99-
panel.set_value("actual_sample_rate", task.timing.samp_clk_rate)
100-
panel.set_value("sample_rate", panel.get_value("rate", 100.0))
99+
panel.set_value("sample_rate", task.timing.samp_clk_rate)
101100

102101
if panel.get_value("filter", "Filter") == "Filter":
103102
chan.ai_filter_enable = True

examples/nidaqmx/nidaqmx_analog_input_filtering/nidaqmx_analog_input_filtering_panel.py

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,12 @@
3838
width: 190px !important; /* Adjust the width as needed */
3939
}
4040
</style>
41-
""",
42-
unsafe_allow_html=True,
43-
)
44-
45-
streamlit_style = """
4641
<style>
4742
iframe[title="streamlit_echarts.st_echarts"]{ height: 400px; width:100%;}
4843
</style>
49-
"""
50-
st.markdown(streamlit_style, unsafe_allow_html=True)
44+
""",
45+
unsafe_allow_html=True,
46+
)
5147

5248

5349
with left_col:
@@ -60,7 +56,7 @@
6056

6157
st.title("Channel Settings")
6258
physical_channel = st.selectbox(
63-
options=panel.get_value("channel_name", ["Mod2/ai0"]),
59+
options=panel.get_value("available_channel_name", ["Mod2/ai0"]),
6460
index=0,
6561
label="Physical Channels",
6662
disabled=panel.get_value("is_running", False),
@@ -78,7 +74,7 @@
7874

7975
st.selectbox(
8076
"Sample Clock Source",
81-
options=panel.get_value("trigger_sources", [""]),
77+
options=panel.get_value("available_trigger_sources", [""]),
8278
index=0,
8379
disabled=panel.get_value("is_running", False),
8480
)
@@ -100,7 +96,7 @@
10096
)
10197
st.number_input(
10298
"Actual Sample Rate",
103-
value=panel.get_value("actual_sample_rate", 1000.0),
99+
value=panel.get_value("sample_rate", 1000.0),
104100
key="actual_sample_rate",
105101
step=1.0,
106102
disabled=True,
@@ -178,16 +174,16 @@
178174
value=5.0,
179175
step=0.1,
180176
disabled=panel.get_value("is_running", False),
177+
key="max_value_voltage",
181178
)
182-
panel.set_value("max_value_voltage", max_value_voltage)
183179

184180
min_value_voltage = st.number_input(
185181
"Min Value",
186182
value=-5.0,
187183
step=0.1,
188184
disabled=panel.get_value("is_running", False),
185+
key="min_value_voltage",
189186
)
190-
panel.set_value("min_value_voltage", min_value_voltage)
191187

192188
if chosen_id == "2":
193189
with st.container(border=True):
@@ -215,22 +211,19 @@
215211
step=0.001,
216212
disabled=panel.get_value("is_running", False),
217213
)
218-
panel.set_value("min_value_current", min_value_current)
219214
max_value_current = st.number_input(
220215
"Max Value",
221216
value=0.01,
222217
step=1.0,
223218
key="max_value_current",
224219
disabled=panel.get_value("is_running", False),
225220
)
226-
current = panel.set_value("max_value_current", max_value_current) # type:ignore
227221
shunt_resistor_value = st.number_input(
228222
"Shunt Resistor Value",
229223
value=249.0,
230224
step=1.0,
231225
disabled=panel.get_value("is_running", False),
232226
)
233-
panel.set_value("shunt_resistor_value", shunt_resistor_value)
234227
if chosen_id == "3":
235228
with st.container(border=True):
236229
st.title("Strain Gage Data")
@@ -240,12 +233,15 @@
240233
"Min Value",
241234
value=-0.01,
242235
step=0.01,
236+
key="min_value_strain",
243237
)
244-
panel.set_value("min_value_strain", min_value_strain)
245238
max_value_strain = st.number_input(
246-
"Max Value", value=0.01, step=0.01, max_value=2.0
239+
"Max Value",
240+
value=0.01,
241+
step=0.01,
242+
max_value=2.0,
243+
key="max_value_strain",
247244
)
248-
panel.set_value("max_value_strain", max_value_strain)
249245
enum_selectbox(
250246
panel,
251247
label="Strain Units",
@@ -260,22 +256,22 @@
260256
value=2.0,
261257
step=1.0,
262258
disabled=panel.get_value("is_running", False),
259+
key="gage_factor",
263260
)
264-
panel.set_value("gage_factor", gage_factor)
265261
nominal_gage = st.number_input(
266262
"nominal gage resistance",
267263
value=350.0,
268264
step=1.0,
269265
disabled=panel.get_value("is_running", False),
266+
key="gage_resistance",
270267
)
271-
panel.set_value("gage_resistance", nominal_gage)
272268
poisson_ratio = st.number_input(
273269
"poisson ratio",
274270
value=0.3,
275271
step=1.0,
276272
disabled=panel.get_value("is_running", False),
273+
key="poisson_ratio",
277274
)
278-
panel.set_value("poisson_ratio", poisson_ratio)
279275
with st.expander("Bridge Information", expanded=False):
280276
st.title("Bridge Information")
281277
enum_selectbox(
@@ -289,15 +285,15 @@
289285
"lead wire resistance",
290286
value=0.0,
291287
step=1.0,
288+
key="wire_resistance",
292289
)
293-
panel.set_value("wire_resistance", wire_resistance)
294290
initial_voltage = st.number_input(
295291
"initial bridge voltage",
296292
value=0.0,
297293
step=1.0,
298294
disabled=panel.get_value("is_running", False),
295+
key="initial_voltage",
299296
)
300-
panel.set_value("initial_voltage", initial_voltage)
301297

302298
st.selectbox(
303299
label="voltage excitation source",
@@ -313,7 +309,6 @@
313309
key="voltage_excitation_value",
314310
disabled=panel.get_value("is_running", False),
315311
)
316-
panel.set_value("voltage_excitation_value", voltage_excit)
317312

318313
st.title("Trigger Settings")
319314
id = stx.tab_bar(
@@ -349,8 +344,9 @@
349344
)
350345
if trigger_type == "3":
351346
with st.container(border=True):
352-
st.selectbox("Source-", options=panel.get_value("trigger_sources", [""]))
353-
st.selectbox("PauseWhen", options=["High", "Low"])
347+
st.write(
348+
"This trigger type is not supported in continuous sample timing. Refer to your device documentation for more information on which triggers are supported"
349+
)
354350
if trigger_type == "4":
355351
with st.container(border=True):
356352
st.write(
@@ -368,18 +364,18 @@
368364
key="slope",
369365
)
370366

371-
level = st.number_input("Level")
372-
panel.set_value("level", level)
367+
level = st.number_input("Level", key="level")
373368
hysteriesis = st.number_input(
374-
"Hysteriesis", disabled=panel.get_value("is_running", False)
369+
"Hysteriesis",
370+
disabled=panel.get_value("is_running", False),
371+
key="hysteriesis",
375372
)
376-
panel.set_value("hysteriesis", hysteriesis)
377373

378374
if trigger_type == "6":
379375
with st.container(border=True):
380-
st.text_input("source:", "APFI0")
381-
st.selectbox("Pause When", options=["Above Level", "Below level"])
382-
st.number_input("level", value=0.0)
376+
st.write(
377+
"This trigger type is not supported in continuous sample timing. Refer to your device documentation for more information on which triggers are supported"
378+
)
383379
if trigger_type == "7":
384380
with st.container(border=True):
385381
st.write(

0 commit comments

Comments
 (0)