Commit dd2ddc14 authored by Linus Pithan's avatar Linus Pithan

adding update_ctrl_params to api of Scan object

parent 9c70aec2
Pipeline #21145 failed with stages
in 36 minutes and 32 seconds
......@@ -35,7 +35,12 @@ from bliss.config.settings import ParametersWardrobe
from bliss.config.settings import pipeline
from import _get_or_create_node, _create_node, is_zerod
from import get_data
from bliss.scanning.chain import AcquisitionSlave, AcquisitionMaster, StopChain
from bliss.scanning.chain import (
from bliss.scanning.writer.null import Writer as NullWriter
from bliss.scanning.scan_math import peak, cen, com
from bliss.scanning.scan_saving import ScanSaving
......@@ -847,6 +852,40 @@ class Scan:
raise RuntimeError("No axis detected in scan.")
return master_axes
def update_ctrl_params(self, ctrl, new_param_dict):
if self.state != ScanState.IDLE:
raise RuntimeError(
"Scan state is not idle. ctrl_params can only be updated before scan starts running."
ctrl_acq_dev = None
for acq_dev in self.acq_chain.nodes_list:
if ctrl is acq_dev.device:
ctrl_acq_dev = acq_dev
if ctrl_acq_dev is None:
raise RuntimeError(f"Controller {ctrl} not part of this scan!")
## for Bliss 2 we have to see how to do the part below more systematic
## and to avoid hasattr
potential_new_ctrl_params = ctrl_acq_dev.ctrl_params.copy()
if hasattr(ctrl_acq_dev, "acq_params"):
potential_new_ctrl_params = CompletedCtrlParamsDict(
ctrl_acq_dev.acq_params, ctrl_params=potential_new_ctrl_params
# at least check that no new keys are added
if set(potential_new_ctrl_params.keys()) == set(
raise RuntimeError(f"New keys can not be added to ctrl_params of {ctrl}")
def _get_x_y_data(self, counter, axis=None):
axis_name = self._get_data_axis_name(axis)
counter_name = if not isinstance(counter, str) else counter
......@@ -601,3 +601,22 @@ def test_typeguard_scanable(default_session):
check_typeguard(True, m0, diode)
check_typeguard(False, diode, diode)
check_typeguard(False, m0, m0)
def test_update_ctrl_params(default_session, beacon, lima_simulator, scan_tmpdir):
scan_saving = default_session.scan_saving
scan_saving.base_path = str(scan_tmpdir)
lima_sim = beacon.get("lima_simulator")
s = scans.loopscan(1, .1, lima_sim, run=False)
with pytest.raises(RuntimeError):
s.update_ctrl_params(lima_sim, {"unkown_key": "bla"})
s.update_ctrl_params(lima_sim, {"saving_format": "EDFGZ"})
lima_data_view = s.get_data()["lima_simulator:image"]
ref_data = lima_data_view.ref_data[0]
assert lima_data_view._get_filenames(ref_data, *range(0, 1))[0][0][-7:] == ".edf.gz"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment