diff options
author | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2022-01-03 23:06:52 -0500 |
---|---|---|
committer | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2022-01-03 23:06:52 -0500 |
commit | 2f9fe8e31ccd1239ed752b2a3b147a463af7f835 (patch) | |
tree | 003f13ddc62a58042267fa58aa65aee0132781af /qolab | |
parent | 7ad20884aeaf2a9b0ec5bda5e5db3fb00f9587bb (diff) | |
download | qolab-2f9fe8e31ccd1239ed752b2a3b147a463af7f835.tar.gz qolab-2f9fe8e31ccd1239ed752b2a3b147a463af7f835.zip |
added device config recovery from another config
Diffstat (limited to 'qolab')
-rw-r--r-- | qolab/hardware/basic.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/qolab/hardware/basic.py b/qolab/hardware/basic.py index 03d98c6..21e1e5d 100644 --- a/qolab/hardware/basic.py +++ b/qolab/hardware/basic.py @@ -65,6 +65,26 @@ class BasicInstrument: config['DeviceConfig'] = dconfig return config + def setConfig(self, cfg): + new_config = cfg.copy() + print('setting config') + device_config = new_config.pop('DeviceConfig') + self.config.update(new_config) + for p, v in device_config.items(): + print(f'{p=} {v=}') + setter = f'set{p}' + if hasattr(self, setter): + # we have something like setProperty + getattr(self, setter)(v) + continue + if hasattr(self, p) or hasattr(type(self), p): + # we have attribute Property + setattr(self, p, v) + continue + print(f'warning: both {setter} and attribute {p} are missing, making attribute {p}') + self.deviceProperties.add(p) + setattr(self, p, v) + def getHeader(self): header = yaml.dump(self.getConfig(), default_flow_style=False, sort_keys=False) header = header.split('\n') |