diff --git a/bec_widgets/widgets/containers/figure/plots/multi_waveform/multi_waveform.py b/bec_widgets/widgets/containers/figure/plots/multi_waveform/multi_waveform.py index a603e401..038795fd 100644 --- a/bec_widgets/widgets/containers/figure/plots/multi_waveform/multi_waveform.py +++ b/bec_widgets/widgets/containers/figure/plots/multi_waveform/multi_waveform.py @@ -338,16 +338,3 @@ class BECMultiWaveform(BECPlotBase): Export current waveform to matplotlib GUI. Available only if matplotlib is installed in the environment. """ MatplotlibExporter(self.plot_item).export() - - -if __name__ == "__main__": - import sys - - from qtpy.QtWidgets import QApplication - - from bec_widgets.widgets.containers.figure import BECFigure - - app = QApplication(sys.argv) - widget = BECFigure() - widget.show() - sys.exit(app.exec_()) diff --git a/bec_widgets/widgets/containers/figure/plots/waveform/waveform.py b/bec_widgets/widgets/containers/figure/plots/waveform/waveform.py index 2128fd6d..017fd7b8 100644 --- a/bec_widgets/widgets/containers/figure/plots/waveform/waveform.py +++ b/bec_widgets/widgets/containers/figure/plots/waveform/waveform.py @@ -1242,16 +1242,22 @@ class BECWaveform(BECPlotBase): msg(dict): Message with the async data. metadata(dict): Metadata of the message. """ - instruction = metadata.get("async_update") + y_data = None + x_data = None + instruction = metadata.get("async_update", {}).get("type") + max_shape = metadata.get("async_update", {}).get("max_shape", []) for curve in self._curves_data["async"].values(): - y_name = curve.config.signals.y.name y_entry = curve.config.signals.y.entry x_name = self._x_axis_mode["name"] for device, async_data in msg["signals"].items(): if device == y_entry: data_plot = async_data["value"] - if instruction == "extend": - x_data, y_data = curve.get_data() + if instruction == "add": + if len(max_shape) > 1: + if len(data_plot.shape) > 1: + data_plot = data_plot[-1, :] + else: + x_data, y_data = curve.get_data() if y_data is not None: new_data = np.hstack((y_data, data_plot)) else: diff --git a/tests/unit_tests/test_waveform1d.py b/tests/unit_tests/test_waveform1d.py index 57d9cb5f..e70793ff 100644 --- a/tests/unit_tests/test_waveform1d.py +++ b/tests/unit_tests/test_waveform1d.py @@ -694,7 +694,8 @@ def test_waveform_async_data_update(qtbot, mocked_client): # w1.queue.scan_storage.find_scan_by_ID.return_value = scan_item_mock msg_1 = {"signals": {"async_device": {"value": [7, 8, 9]}}} - w1.on_async_readback(msg_1, {"async_update": "extend"}) + metadata_1 = {"async_update": {"max_shape": [None], "type": "add"}} + w1.on_async_readback(msg_1, metadata_1) qtbot.wait(200) x_data, y_data = w1.curves[0].get_data() @@ -703,7 +704,7 @@ def test_waveform_async_data_update(qtbot, mocked_client): assert w1.plot_item.getAxis("bottom").labelText == custom_label + " [best_effort]" msg_2 = {"signals": {"async_device": {"value": [10, 11, 12]}}} - w1.on_async_readback(msg_2, {"async_update": "extend"}) + w1.on_async_readback(msg_2, metadata_1) qtbot.wait(200) x_data, y_data = w1.curves[0].get_data() @@ -712,7 +713,8 @@ def test_waveform_async_data_update(qtbot, mocked_client): assert w1.plot_item.getAxis("bottom").labelText == custom_label + " [best_effort]" msg_3 = {"signals": {"async_device": {"value": [20, 21, 22]}}} - w1.on_async_readback(msg_3, {"async_update": "replace"}) + metadata_3 = {"async_update": {"max_shape": [None], "type": "replace"}} + w1.on_async_readback(msg_3, metadata_3) qtbot.wait(200) x_data, y_data = w1.curves[0].get_data()