Skip to content

Commit b861029

Browse files
DilmiWickramanayakeDilmi Wickramanayake
andauthored
Adding Error Message Handling to Continuous Analog Input example (#119)
* Analog Input - Voltage and Thermocouple Single Task * add niscope Signed-off-by: Dilmi Wickramanayake <[email protected]> * Rename Signed-off-by: Dilmi Wickramanayake <[email protected]> * Analog Input Filtering * Completed Task Settings * Added README.md * fixed mypy & lint errors * fixed mypy & lint errors * Revert changes * simple graph changes * simple graph changes * Update simple_graph.py * Poetry lock * update lint errors * update lint errors * changes to poetry lock file * changes to poetry lock file * Pyright error * lint error * fixed errors * Fixed panel comments * Fixed panel comments * format number input * adding number format * lint errors fixed * fixing lint errors * changed source settings * setting source up * fixing lint error * resolved comments * deleting unecessary variables * updated run button and panel methods * setting default values * adding daq errors * README.md changes * error handling * rename daq_errors -> daq_error * rename daq_error * source now works * fix lint errors * remove comment * remove logging * disable run button * added onboard clock * renaming hide_button method * fixing mypy error * lint error * removed function and simplified code * remove analog output and markdown * renaming labels * update error message * update README.md * remove changes * removing changes * resolve changes * Dev4 -> Dev1 * readme * readme * run_button = deleted --------- Signed-off-by: Dilmi Wickramanayake <[email protected]> Co-authored-by: Dilmi Wickramanayake <[email protected]>
1 parent ce17c45 commit b861029

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

examples/nidaqmx/nidaqmx_continuous_analog_input/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ This is a nipanel example that displays an interactive Streamlit app and updates
1818

1919
```pwsh
2020
poetry install --with examples
21-
poetry run examples/nidaqmx/nidaqmx_continuous_analog_input.py
21+
poetry run examples\nidaqmx\nidaqmx_continuous_analog_input\nidaqmx_continuous_analog_input.py
2222
```

examples/nidaqmx/nidaqmx_continuous_analog_input/nidaqmx_continuous_analog_input.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,23 @@
66
import nidaqmx
77
from nidaqmx.constants import (
88
AcquisitionType,
9-
TerminalConfiguration,
109
CJCSource,
11-
TemperatureUnits,
12-
ThermocoupleType,
1310
LoggingMode,
1411
LoggingOperation,
12+
TemperatureUnits,
13+
TerminalConfiguration,
14+
ThermocoupleType,
1515
)
16+
from nidaqmx.errors import DaqError
1617

1718
import nipanel
1819

1920
panel_script_path = Path(__file__).with_name("nidaqmx_continuous_analog_input_panel.py")
2021
panel = nipanel.create_streamlit_panel(panel_script_path)
2122

2223
try:
24+
panel.set_value("daq_error", "")
25+
2326
print(f"Panel URL: {panel.panel_url}")
2427
print(f"Waiting for the 'Run' button to be pressed...")
2528
print(f"(Press Ctrl + C to quit)")
@@ -79,5 +82,9 @@
7982
task.stop()
8083
panel.set_value("is_running", False)
8184

85+
except DaqError as e:
86+
daq_error = str(e)
87+
print(daq_error)
88+
panel.set_value("daq_error", daq_error)
8289
except KeyboardInterrupt:
8390
pass

examples/nidaqmx/nidaqmx_continuous_analog_input/nidaqmx_continuous_analog_input_panel.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,12 @@
3939

4040
if is_running:
4141
st.button(r"⏹️ Stop", key="stop_button")
42-
else:
42+
elif not is_running and panel.get_value("daq_error", "") == "":
4343
st.button(r"▶️ Run", key="run_button")
44+
else:
45+
st.error(
46+
f"There was an error running the script. Fix the issue and re-run nidaqmx_continuous_analog_input.py \n\n {panel.get_value('daq_error', '')}"
47+
)
4448

4549
thermocouple_data = panel.get_value("thermocouple_data", [0.0])
4650
voltage_data = panel.get_value("voltage_data", [0.0])

0 commit comments

Comments
 (0)