diff --git a/bec_widgets/examples/extreme/config.yaml b/bec_widgets/examples/extreme/config.yaml index 38c704ce..fcab38b9 100644 --- a/bec_widgets/examples/extreme/config.yaml +++ b/bec_widgets/examples/extreme/config.yaml @@ -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 \ No newline at end of file +# entry: ["samx","incorect"] #multiple entries for one device \ No newline at end of file diff --git a/bec_widgets/examples/extreme/extreme.py b/bec_widgets/examples/extreme/extreme.py index 4d5cd430..0c2bdf9c 100644 --- a/bec_widgets/examples/extreme/extreme.py +++ b/bec_widgets/examples/extreme/extreme.py @@ -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)