1
0
mirror of https://github.com/bec-project/bec_widgets.git synced 2025-12-31 03:01:18 +01:00

feat: error messages if name or entry is wrong

This commit is contained in:
wyzula-jan
2023-09-01 01:15:19 +02:00
parent 96a88d2315
commit 415c4ee3f2
2 changed files with 24 additions and 6 deletions

View File

@@ -1,7 +1,9 @@
plot_settings:
background_color: "black"
num_columns: 3
colormap: "plasma" #TODO has to be hooked up to the plot
colormap: "plasma"
#TODO add more settings
# - plot size
plot_data:
- plot_name: "BPM plot"
@@ -43,4 +45,4 @@ plot_data:
- name: "gauss_bpm"
entry: "gauss_bpm"
- name: "samx"
entry: ["samx","setpoint"] #multiple entries for one device
# entry: ["samx","incorect"] #multiple entries for one device

View File

@@ -291,10 +291,13 @@ class PlotApp(QWidget):
for plot_config in self.plot_data:
x_config = plot_config["x"]
x_signal_config = x_config["signals"][0]
x_name = x_signal_config.get("name", "")
x_entry_list = x_signal_config.get("entry", [])
x_signal_config = x_config["signals"][0] # Assuming there's at least one signal for x
x_name = x_signal_config.get("name", "")
if not x_name:
raise ValueError("Name for x signal must be specified.")
x_entry_list = x_signal_config.get("entry", [])
if not x_entry_list:
x_entry_list = dev[x_name]._hints if hasattr(dev[x_name], "_hints") else [x_name]
@@ -306,8 +309,10 @@ class PlotApp(QWidget):
for x_entry in x_entry_list:
for y_config in y_configs:
y_name = y_config.get("name", "")
y_entry_list = y_config.get("entry", [])
if not y_name:
raise ValueError("Name for y signal must be specified.")
y_entry_list = y_config.get("entry", [])
if not y_entry_list:
y_entry_list = (
dev[y_name]._hints if hasattr(dev[y_name], "_hints") else [y_name]
@@ -322,6 +327,17 @@ class PlotApp(QWidget):
data_x = msg["data"].get(x_name, {}).get(x_entry, {}).get("value", None)
data_y = msg["data"].get(y_name, {}).get(y_entry, {}).get("value", None)
if data_x is None:
raise ValueError(f"Incorrect entry specified for x: {x_entry}")
if data_y is None:
if hasattr(dev[y_name], "_hints"):
raise ValueError(f"Incorrect entry specified for y: {y_entry}")
else:
raise ValueError(
f"No hints available for y, and name did not work as entry: {y_name}"
)
if data_x is not None:
self.data.setdefault(key, {}).setdefault("x", []).append(data_x)