mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-07-13 03:01:50 +02:00
refactor(scan_control): request_last_executed_scan_parameters logic adjusted
This commit is contained in:
@ -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
|
||||||
current_scan = self.comboBox_scan_selection.currentText()
|
if not self.toggle.checked:
|
||||||
if enabled:
|
return
|
||||||
history = self.client.connector.xread(MessageEndpoints.scan_history(), from_start=True)
|
|
||||||
|
|
||||||
for scan in history:
|
current_scan = self.comboBox_scan_selection.currentText()
|
||||||
scan_data = scan.get("data")
|
history = self.client.connector.xread(
|
||||||
if scan_data is None:
|
MessageEndpoints.scan_history(), from_start=True, user_id=self.object_name
|
||||||
continue
|
)
|
||||||
scan_name = scan_data.scan_name
|
|
||||||
if scan_name == current_scan:
|
for scan in history:
|
||||||
args_list = scan_data.request_inputs.get("arg_bundle", [])
|
scan_data = scan.get("data")
|
||||||
if len(args_list) > 1 and self.arg_box is not None:
|
if not scan_data:
|
||||||
self.arg_box.set_parameters(args_list)
|
continue
|
||||||
inputs = scan_data.request_inputs.get("inputs", {})
|
|
||||||
kwargs = scan_data.request_inputs.get("kwargs", {})
|
if scan_data.scan_name != current_scan:
|
||||||
kwarg_box_inputs = {**inputs, **kwargs}
|
continue
|
||||||
if kwarg_box_inputs and self.kwarg_boxes:
|
|
||||||
for box in self.kwarg_boxes:
|
ri = getattr(scan_data, "request_inputs", {}) or {}
|
||||||
box.set_parameters(kwarg_box_inputs)
|
args_list = ri.get("arg_bundle", [])
|
||||||
self.last_scan_found = True
|
if args_list and self.arg_box:
|
||||||
break
|
self.arg_box.set_parameters(args_list)
|
||||||
else:
|
|
||||||
self.last_scan_found = False
|
inputs = ri.get("inputs", {})
|
||||||
else:
|
kwargs = ri.get("kwargs", {})
|
||||||
self.last_scan_found = False
|
merged = {**inputs, **kwargs}
|
||||||
|
if merged and self.kwarg_boxes:
|
||||||
|
for box in self.kwarg_boxes:
|
||||||
|
box.set_parameters(merged)
|
||||||
|
|
||||||
|
self.last_scan_found = True
|
||||||
|
break
|
||||||
|
|
||||||
@SafeProperty(str)
|
@SafeProperty(str)
|
||||||
def current_scan(self):
|
def current_scan(self):
|
||||||
|
Reference in New Issue
Block a user