diff options
-rw-r--r-- | scope.py | 33 |
1 files changed, 25 insertions, 8 deletions
@@ -17,13 +17,27 @@ class Scope(scpi.SCPIinstr): def __init__(self, resource): super().__init__(resource) + # Minimal set of methods to be implemented by a scope. + # Should work with minimal arguments list + # but might be faster if parameters provided: less IO requests + + def getTrace(self, chNum, availableNpnts=None, maxRequiredPoints=None): + warnings.warn( 'this function is not implemented' ) + class Trace: - x = None - xlabel = 'time' - xunit = 'S' - y = None - ylabel = 'Voltage' - yunit = 'V' + def __init__(self, descrStr): + self.descr = descrStr + self.x = None + self.xlabel = None + self.xunit = None + self.y = None + self.ylabel = None + self.yunit = None + + def plot(self): + import matplotlib.pyplot as plt + plt.plot(self.x, self.y, label=self.descr) + plt.legend() class SDS1104x(Scope): """ Siglent SDS1104x scope """ @@ -171,10 +185,13 @@ class SDS1104x(Scope): def getTrace(self, chNum, availableNpnts=None, maxRequiredPoints=None): wfVoltage, availableNpnts = self.getWaveform( chNum, availableNpnts=availableNpnts, maxRequiredPoints=maxRequiredPoints) t = self.getTimeTrace(availableNpnts=availableNpnts, maxRequiredPoints=maxRequiredPoints) - tr = Trace() + tr = Trace( f'Ch{chNum}' ) + tr.xlabel = 'Time' + tr.xunit = 'S' + tr.ylabel = 'Voltage' + tr.yunit = 'V' tr.x = t tr.y = wfVoltage - tr.ylabel = f'Ch{chNum} Voltage' return( tr ) |