diff options
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') |