mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-07-13 19:21:50 +02:00
fix(waveform): async data duplication if multiple signals from same device fixed
This commit is contained in:
@ -137,6 +137,7 @@ class Waveform(PlotBase):
|
|||||||
# Curve data
|
# Curve data
|
||||||
self._sync_curves = []
|
self._sync_curves = []
|
||||||
self._async_curves = []
|
self._async_curves = []
|
||||||
|
self._async_connected_devices: set[str] = set()
|
||||||
self._slice_index = None
|
self._slice_index = None
|
||||||
self._dap_curves = []
|
self._dap_curves = []
|
||||||
self._mode: Literal["none", "sync", "async", "mixed"] = "none"
|
self._mode: Literal["none", "sync", "async", "mixed"] = "none"
|
||||||
@ -544,6 +545,7 @@ class Waveform(PlotBase):
|
|||||||
continue
|
continue
|
||||||
config = CurveConfig(**cfg_dict)
|
config = CurveConfig(**cfg_dict)
|
||||||
self._add_curve(config=config)
|
self._add_curve(config=config)
|
||||||
|
self.update_with_scan_history(-1)
|
||||||
except json.JSONDecodeError as e:
|
except json.JSONDecodeError as e:
|
||||||
logger.error(f"Failed to decode JSON: {e}")
|
logger.error(f"Failed to decode JSON: {e}")
|
||||||
|
|
||||||
@ -1012,6 +1014,7 @@ class Waveform(PlotBase):
|
|||||||
return
|
return
|
||||||
|
|
||||||
if current_scan_id != self.scan_id:
|
if current_scan_id != self.scan_id:
|
||||||
|
self._async_connected_devices.clear()
|
||||||
self.reset()
|
self.reset()
|
||||||
self.new_scan.emit()
|
self.new_scan.emit()
|
||||||
self.new_scan_id.emit(current_scan_id)
|
self.new_scan_id.emit(current_scan_id)
|
||||||
@ -1178,18 +1181,22 @@ class Waveform(PlotBase):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
logger.warning(f"Curve {name} not found in plot item.")
|
logger.warning(f"Curve {name} not found in plot item.")
|
||||||
pass
|
pass
|
||||||
self.bec_dispatcher.connect_slot(
|
|
||||||
self.on_async_readback,
|
# Connect only once per device signal
|
||||||
MessageEndpoints.device_async_readback(self.scan_id, name),
|
if name not in self._async_connected_devices:
|
||||||
from_start=True,
|
self.bec_dispatcher.connect_slot(
|
||||||
cb_info={"scan_id": self.scan_id},
|
self.on_async_readback,
|
||||||
)
|
MessageEndpoints.device_async_readback(self.scan_id, name),
|
||||||
logger.info(f"Setup async curve {name}")
|
from_start=True,
|
||||||
|
cb_info={"scan_id": self.scan_id},
|
||||||
|
)
|
||||||
|
self._async_connected_devices.add(name)
|
||||||
|
logger.info(f"Async read-back connected for {name}")
|
||||||
|
|
||||||
@SafeSlot(dict, dict, verify_sender=True)
|
@SafeSlot(dict, dict, verify_sender=True)
|
||||||
def on_async_readback(self, msg, metadata):
|
def on_async_readback(self, msg, metadata):
|
||||||
"""
|
"""
|
||||||
Get async data readback. This code needs to be fast, therefor we try
|
Get async data readback. This code needs to be fast; therefore, we try
|
||||||
to reduce the number of copies in between cycles. Be careful when refactoring
|
to reduce the number of copies in between cycles. Be careful when refactoring
|
||||||
this part as it will affect the performance of the async readback.
|
this part as it will affect the performance of the async readback.
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user