Skip to content

Commit 207fe57

Browse files
author
Dilmi Wickramanayake
committed
adding daq errors
1 parent be3c739 commit 207fe57

File tree

2 files changed

+26
-10
lines changed

2 files changed

+26
-10
lines changed

examples/nidaqmx/nidaqmx_analog_input_filtering/nidaqmx_analog_input_filtering.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
StrainGageBridgeType,
1717
TerminalConfiguration,
1818
)
19+
from nidaqmx.errors import DaqError
1920

2021
import nipanel
2122

@@ -25,11 +26,11 @@
2526

2627
system = nidaqmx.system.System.local()
2728

28-
available_channel_name = []
29+
available_channel_names = []
2930
for dev in system.devices:
3031
for chan in dev.ai_physical_chans:
31-
available_channel_name.append(chan.name)
32-
panel.set_value("available_channel_name", available_channel_name)
32+
available_channel_names.append(chan.name)
33+
panel.set_value("available_channel_names", available_channel_names)
3334

3435
available_trigger_sources = []
3536
for dev in system.devices:
@@ -94,22 +95,22 @@
9495
samps_per_chan=panel.get_value("total_samples", 100),
9596
)
9697
panel.set_value("sample_rate", task.timing.samp_clk_rate)
97-
98+
# Not all hardware supports all filter types.
99+
# Refer to your device documentation for more information.
98100
if panel.get_value("filter", "Filter") == "Filter":
99101
chan.ai_filter_enable = True
100102
chan.ai_filter_freq = panel.get_value("filter_freq", 0.0)
101103
chan.ai_filter_response = panel.get_value("filter_response", FilterResponse.COMB)
102104
chan.ai_filter_order = panel.get_value("filter_order", 1)
103-
# Not all hardware supports all filter types.
104-
# Refer to your device documentation for more information.
105105
panel.set_value("actual_filter_freq", chan.ai_filter_freq)
106106
panel.set_value("actual_filter_response", chan.ai_filter_response)
107107
panel.set_value("actual_filter_order", chan.ai_filter_order)
108108
else:
109109
panel.set_value("actual_filter_freq", 0.0)
110110
panel.set_value("actual_filter_response", FilterResponse.COMB)
111111
panel.set_value("actual_filter_order", 0)
112-
112+
# Not all hardware supports all filter types.
113+
# Refer to your device documentation for more information.
113114
trigger_type = panel.get_value("trigger_type")
114115
if trigger_type == "5":
115116
task.triggers.start_trigger.cfg_anlg_edge_start_trig(
@@ -128,6 +129,7 @@
128129
)
129130

130131
try:
132+
panel.set_value("daq_errors", "")
131133
task.start()
132134
panel.set_value("is_running", True)
133135

@@ -143,6 +145,9 @@
143145
task.stop()
144146
panel.set_value("is_running", False)
145147

148+
except DaqError as e:
149+
daq_errors = str(e)
150+
panel.set_value("daq_errors", daq_errors)
146151

147152
except KeyboardInterrupt:
148153
pass

examples/nidaqmx/nidaqmx_analog_input_filtering/nidaqmx_analog_input_filtering_panel.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656

5757
st.title("Channel Settings")
5858
physical_channel = st.selectbox(
59-
options=panel.get_value("available_channel_name", ["Mod2/ai0"]),
59+
options=panel.get_value("available_channel_names", ["Mod2/ai0"]),
6060
index=0,
6161
label="Physical Channels",
6262
disabled=panel.get_value("is_running", False),
@@ -118,7 +118,11 @@
118118
)
119119
st.title("Filtering Settings")
120120

121-
filter = st.selectbox("Filter", options=["No Filtering", "Filter"])
121+
filter = st.selectbox(
122+
"Filter",
123+
options=["No Filtering", "Filter"],
124+
disabled=panel.get_value("is_running", False),
125+
)
122126
panel.set_value("filter", filter)
123127
enum_selectbox(
124128
panel,
@@ -147,7 +151,9 @@
147151
disabled=True,
148152
)
149153
st.selectbox(
150-
"Actual Filter Order", options=[panel.get_value("actual_filter_order", 0)], disabled=True
154+
"Actual Filter Order",
155+
options=[panel.get_value("actual_filter_order", 0)],
156+
disabled=True,
151157
)
152158

153159
with right_col:
@@ -414,3 +420,8 @@
414420
],
415421
}
416422
st_echarts(options=acquired_data_graph, height="400px", key="graph", width="100%")
423+
with st.container(border=True):
424+
if panel.get_value("daq_errors", "") == "":
425+
st.write("No DAQ Errors Found")
426+
else:
427+
st.error(panel.get_value("daq_errors", ""))

0 commit comments

Comments
 (0)