From 412a34dee67a572404df14742bb89bd4b12b219c Mon Sep 17 00:00:00 2001 From: Philipp Schmidt <philipp.schmidt@xfel.eu> Date: Wed, 3 Nov 2021 15:34:38 +0100 Subject: [PATCH] manager: Apply previous values after proxy creation --- src/calng/CalibrationManager.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/calng/CalibrationManager.py b/src/calng/CalibrationManager.py index 39ae1482..7fc7cd61 100644 --- a/src/calng/CalibrationManager.py +++ b/src/calng/CalibrationManager.py @@ -611,22 +611,15 @@ class CalibrationManager(DeviceClientBase, Device): if path not in managed_paths: del managed_hash[path] - # Check for current values of managed keys on DAQ devices and - # update schema correspondingly. - if self._daq_device_ids: - daq_vals = await self._get_shared_keys( - self._daq_device_ids, ManagedKeysNode.DAQ_KEYS.keys()) - - for orig_key, managed_key in ManagedKeysNode.DAQ_KEYS.items(): - managed_hash[managed_key, 'defaultValue'] = daq_vals[orig_key] - - # Check for current values of managed keys on correction - # devices and update schema correspondingly. - corr_vals = await self._get_shared_keys( + # Retrieve any previous values already on running devices in + # order to update the defaultValue attribute in the schema just + # before injection. + prev_vals = await self._get_shared_keys( self._correction_device_ids, managed_keys) - for key, value in corr_vals.items(): - managed_hash[key, 'defaultValue'] = value + if self._daq_device_ids: + prev_vals.update(await self._get_shared_keys( + self._daq_device_ids, ManagedKeysNode.DAQ_KEYS.keys())) # Retrieve the attributes on the current managed node. The # original implementation of toSchemaAndAttrs in the Node's @@ -695,6 +688,12 @@ class CalibrationManager(DeviceClientBase, Device): descr.accessMode = AccessMode.RECONFIGURABLE descr.allowedStates = [State.ACTIVE] + try: + # If there's been a previous value before + # injection, use it. + descr.defaultValue = prev_vals[full_key] + except KeyError: + pass else: self.logger.warn(f'Encountered unknown descriptor type ' f'{type(descr)}') -- GitLab