aboutsummaryrefslogtreecommitdiff
path: root/qolab/hardware/scope/__init__.py
diff options
context:
space:
mode:
authorEugeniy E. Mikhailov <evgmik@gmail.com>2021-12-09 20:57:53 -0500
committerEugeniy E. Mikhailov <evgmik@gmail.com>2021-12-09 21:03:02 -0500
commit735c19aed4fc85ff6f17b413930ada1672ebb4ff (patch)
tree0266f39936fc6336493965b4514a3199522cedc0 /qolab/hardware/scope/__init__.py
parent8a5e8d993a71728100839e6c37f765d15926c75d (diff)
downloadqolab-735c19aed4fc85ff6f17b413930ada1672ebb4ff.tar.gz
qolab-735c19aed4fc85ff6f17b413930ada1672ebb4ff.zip
generalized code
Diffstat (limited to 'qolab/hardware/scope/__init__.py')
-rw-r--r--qolab/hardware/scope/__init__.py26
1 files changed, 9 insertions, 17 deletions
diff --git a/qolab/hardware/scope/__init__.py b/qolab/hardware/scope/__init__.py
index bcbc87c..b89e2b6 100644
--- a/qolab/hardware/scope/__init__.py
+++ b/qolab/hardware/scope/__init__.py
@@ -3,20 +3,21 @@ Provide basic class to operate scope
Created by Eugeniy E. Mikhailov 2021/11/29
"""
from qolab.hardware.scpi import SCPIinstr
+from qolab.hardware.basic import BasicInstrument
from qolab.data.trace import TraceSetSameX
from qolab.file_utils import get_next_data_file
import yaml
-class Scope:
+class Scope(BasicInstrument):
# Minimal set of methods to be implemented by a scope.
def __init__(self):
- self.config={}
- self.config['Device type'] = 'Scope'
+ BasicInstrument.__init__(self)
+ self.config['Device type']='Scope'
+ self.config['FnamePrefix'] = 'scope'
self.config['Device model'] = 'Generic Scope Without Hardware interface'
+ self.config['FnamePrefix'] = 'scope'
self.numberOfChannels = 0
- self.fname_prefix = 'scope'
- self.savepath = './scope'
# 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
@@ -42,17 +43,7 @@ class Scope:
allTraces.plot()
def getConfig(self):
- config = self.config.copy()
- dconfig = {}
- dconfig['id'] = self.idn
- 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
+ config = BasicInstrument.getConfig(self).copy()
chconfig = {}
for chNum in range(1, self.numberOfChannels+1):
chNconfig = {}
@@ -76,7 +67,7 @@ class Scope:
def save(self, fname=None, item_format='e', availableNpnts=None, maxRequiredPoints=None, extention='dat'):
allTraces = self.getAllTraces(availableNpnts=availableNpnts, maxRequiredPoints=maxRequiredPoints)
if fname is None:
- fname = get_next_data_file(self.fname_prefix, self.savepath, extention=extention)
+ fname = get_next_data_file(self.config['FnamePrefix'], self.config['SavePath'], extention=extention)
allTraces.save(fname, item_format=item_format)
return(fname)
@@ -91,6 +82,7 @@ class ScopeSCPI(SCPIinstr, Scope):
def __init__(self, resource):
SCPIinstr.__init__(self, resource)
Scope.__init__(self)
+ self.config['DeviceId'] = str.strip(self.idn)
from .sds1104x import SDS1104X