diff options
author | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2021-12-09 17:09:58 -0500 |
---|---|---|
committer | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2021-12-09 17:09:58 -0500 |
commit | 89889df12fc0bac71ae5d7fbead67b468aa3eb26 (patch) | |
tree | 2d24b607c180b2458f2e7c8b5b37bc9ce4d95950 /qolab/hardware/basic.py | |
parent | 6c6eab0af78496791b3dbbbb7a5d2c383f10cbbd (diff) | |
download | qolab-89889df12fc0bac71ae5d7fbead67b468aa3eb26.tar.gz qolab-89889df12fc0bac71ae5d7fbead67b468aa3eb26.zip |
added basic instrument with config
Diffstat (limited to 'qolab/hardware/basic.py')
-rw-r--r-- | qolab/hardware/basic.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/qolab/hardware/basic.py b/qolab/hardware/basic.py new file mode 100644 index 0000000..fa2ccb5 --- /dev/null +++ b/qolab/hardware/basic.py @@ -0,0 +1,33 @@ +import yaml + +class BasicInstrument: + def __init__(self): + self.config={} + self.config['Device type'] = 'Basic Instrument' + self.config['Device model'] = 'Model is unset' + self.config['FnamePrefix'] = 'basicInstrument' + self.config['SavePath'] = './data' + # deviceProperties must have 'get' and preferably 'set' methods available, + # i.e. 'SampleRate' needs getSampleRate() and love to have setSampleRate(value) + # they will be used to obtain config and set device according to it + # self.deviceProperties = ['SampleRate', 'TimePerDiv', 'TrigDelay', ]; + self.deviceProperties = []; + + def getConfig(self): + config = self.config.copy() + dconfig = {} + for p in self.deviceProperties: + getter = f'get{p}' + if not hasattr(self, getter): + print(f'warning no getter for {p}, i.e. {getter} is missing') + continue + res = getattr(self, getter)() + dconfig[p] = res + config['DeviceConfig'] = dconfig + return config + + def getHeader(self): + header = yaml.dump(self.getConfig(), default_flow_style=False, sort_keys=False) + header = header.split('\n') + return header + |