management of scan specific controller parameters
as the discussion in #1022 (closed) became a more general we move it to this issue.
After discussion with @pguillou and previously with @matias.guijarro the proposed mechanism is:
-
on the controller level
- add a
.default_params
property- Type: dict or object that has a
.to_dict()
function (may involve cache via Settings or BeaconObject) - Role: Place to keep configurable controller parameters that should be send to the controller before each acquisition to make sure the device is in a defined state
- Type: dict or object that has a
- add a
apply_params(dict)
function- Role: is called by the Acq_Obj.prepare and takes scan specific controller parameters that are used to override those defined in
.default_params
- There should be generic implementation of this in the base class
- Role: is called by the Acq_Obj.prepare and takes scan specific controller parameters that are used to override those defined in
- add a
_apply_params_to_hardw(dict)
function- Role: push a complete set of parameters to the hardware device. Will be called at the end of
apply_params
- Role: push a complete set of parameters to the hardware device. Will be called at the end of
- add a
-
in the ChainNode (!1529 (closed))
- have
ctlr_parms
in the signature of set_parms - add a
set_crlr_parms(dict)
function
- have
-
in the Acq_Obj (!1529 (closed))
- add a
scan_specific_ctrl_parms
property (better idea for name welcome) - make sure that
controller.apply_params(self.scan_specific_ctrl_parms)
is called inself.prepare()
- add a
The resulting todos are:
-
Add necessary items the controller base class, roughly like this:
class BaseController():
...
@property
def default_params(self):
"""
this property should be used to keep device configuration (in most cases it should be cached.)
this property should either return a dict or an object that has a `to_dict()`
"""
return {}
def _apply_params_to_hardw(self,complete_controller_params):
"""
to be implemented for controllers that used controller specific configuration
"""
pass
def apply_params(self,scan_specific_controller_params):
"""
is called to set a complete set of parameters on the hardware controller.
for most cases the implementation in the base class should be sufficient
(hardware specific things should happen in _apply_params_to_hardw)
"""
if type(self.default_params) == dict:
tmp_complete_params = self.default_params.copy()
else:
tmp_complete_parmas = default_params.to_dict()
if not any([key in tmp_complete_parmas for key in scan_specific_controller_params.keys()]):
#raise or warning due to unexpected key
tmp_complete_parmas.update(scan_specific_controller_params) # drop unknown keys if not raised above
self._apply_params_to_hardw(tmp_complete_parmas)
...
-
take care of management of controller parameters in ChainNode -
take care of management of controller parameters in Acq_Obj