0
0
mirror of https://github.com/bec-project/bec_widgets.git synced 2025-07-13 19:21:50 +02:00

refactor(scan_control): request_last_executed_scan_parameters logic adjusted

This commit is contained in:
2025-06-22 21:21:37 +02:00
committed by Jan Wyzula
parent 4456297beb
commit 57f75bd4d5

View File

@ -203,32 +203,37 @@ class ScanControl(BECWidget, QWidget):
""" """
Requests the last executed scan parameters from BEC and restores them to the scan control widget. Requests the last executed scan parameters from BEC and restores them to the scan control widget.
""" """
enabled = self.toggle.checked self.last_scan_found = False
if not self.toggle.checked:
return
current_scan = self.comboBox_scan_selection.currentText() current_scan = self.comboBox_scan_selection.currentText()
if enabled: history = self.client.connector.xread(
history = self.client.connector.xread(MessageEndpoints.scan_history(), from_start=True) MessageEndpoints.scan_history(), from_start=True, user_id=self.object_name
)
for scan in history: for scan in history:
scan_data = scan.get("data") scan_data = scan.get("data")
if scan_data is None: if not scan_data:
continue continue
scan_name = scan_data.scan_name
if scan_name == current_scan: if scan_data.scan_name != current_scan:
args_list = scan_data.request_inputs.get("arg_bundle", []) continue
if len(args_list) > 1 and self.arg_box is not None:
ri = getattr(scan_data, "request_inputs", {}) or {}
args_list = ri.get("arg_bundle", [])
if args_list and self.arg_box:
self.arg_box.set_parameters(args_list) self.arg_box.set_parameters(args_list)
inputs = scan_data.request_inputs.get("inputs", {})
kwargs = scan_data.request_inputs.get("kwargs", {}) inputs = ri.get("inputs", {})
kwarg_box_inputs = {**inputs, **kwargs} kwargs = ri.get("kwargs", {})
if kwarg_box_inputs and self.kwarg_boxes: merged = {**inputs, **kwargs}
if merged and self.kwarg_boxes:
for box in self.kwarg_boxes: for box in self.kwarg_boxes:
box.set_parameters(kwarg_box_inputs) box.set_parameters(merged)
self.last_scan_found = True self.last_scan_found = True
break break
else:
self.last_scan_found = False
else:
self.last_scan_found = False
@SafeProperty(str) @SafeProperty(str)
def current_scan(self): def current_scan(self):