mirror of
https://github.com/bec-project/bec_widgets.git
synced 2026-04-07 09:17:53 +02:00
feat: error messages if name or entry is wrong
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
plot_settings:
|
plot_settings:
|
||||||
background_color: "black"
|
background_color: "black"
|
||||||
num_columns: 3
|
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_data:
|
||||||
- plot_name: "BPM plot"
|
- plot_name: "BPM plot"
|
||||||
@@ -43,4 +45,4 @@ plot_data:
|
|||||||
- name: "gauss_bpm"
|
- name: "gauss_bpm"
|
||||||
entry: "gauss_bpm"
|
entry: "gauss_bpm"
|
||||||
- name: "samx"
|
- name: "samx"
|
||||||
entry: ["samx","setpoint"] #multiple entries for one device
|
# entry: ["samx","incorect"] #multiple entries for one device
|
||||||
@@ -291,10 +291,13 @@ class PlotApp(QWidget):
|
|||||||
|
|
||||||
for plot_config in self.plot_data:
|
for plot_config in self.plot_data:
|
||||||
x_config = plot_config["x"]
|
x_config = plot_config["x"]
|
||||||
x_signal_config = x_config["signals"][0]
|
x_signal_config = x_config["signals"][0] # Assuming there's at least one signal for x
|
||||||
x_name = x_signal_config.get("name", "")
|
|
||||||
x_entry_list = x_signal_config.get("entry", [])
|
|
||||||
|
|
||||||
|
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:
|
if not x_entry_list:
|
||||||
x_entry_list = dev[x_name]._hints if hasattr(dev[x_name], "_hints") else [x_name]
|
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 x_entry in x_entry_list:
|
||||||
for y_config in y_configs:
|
for y_config in y_configs:
|
||||||
y_name = y_config.get("name", "")
|
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:
|
if not y_entry_list:
|
||||||
y_entry_list = (
|
y_entry_list = (
|
||||||
dev[y_name]._hints if hasattr(dev[y_name], "_hints") else [y_name]
|
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_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)
|
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:
|
if data_x is not None:
|
||||||
self.data.setdefault(key, {}).setdefault("x", []).append(data_x)
|
self.data.setdefault(key, {}).setdefault("x", []).append(data_x)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user