diff options
Diffstat (limited to 'qolab/hardware/scope/_basic.py')
-rw-r--r-- | qolab/hardware/scope/_basic.py | 51 |
1 files changed, 42 insertions, 9 deletions
diff --git a/qolab/hardware/scope/_basic.py b/qolab/hardware/scope/_basic.py index d9905ce..eaab281 100644 --- a/qolab/hardware/scope/_basic.py +++ b/qolab/hardware/scope/_basic.py @@ -7,7 +7,7 @@ Created by Eugeniy E. Mikhailov 2021/11/29 import numpy as np from qolab.hardware.scpi import SCPIinstr from qolab.hardware.basic import BasicInstrument -from qolab.data.trace import TraceSetSameX +from qolab.data.trace import TraceSetSameX, TraceXY import time import logging @@ -83,17 +83,50 @@ class Scope(BasicInstrument): "VoltageOffset", } + def getWaveform( + self, chNum, availableNpnts=None, maxRequiredPoints=None, decimate=True + ): + """ + Get scope channel waveform where X axis is index and not time. + + Waveform MUST HAVE config dictionary with + ``trRaw.config["tags"]["rawChanConfig"]`` assigned + with items helping to calculate time trace + usually ``SampleRate``, ``Npnts``, ``sparsing``. + + For decimate use see ``getRawWaveform``. + + In short decimate=True is slower but more precise. + + """ + raise NotImplementedError("getWaveform function is not implemented") + + def getTimeTrace(self, rawChanCfg): + """Constructs time trace from properties provided in ``rawChanCfg`` dictionary.""" + raise NotImplementedError("getTimeTrace function is not implemented") + def getTrace( self, chNum, availableNpnts=None, maxRequiredPoints=None, decimate=True ): - # Should work with minimal arguments list - # but might be faster if parameters provided: less IO requests - # old_trg_mode = self.getTriggerMode() - # self.setTriggerMode('STOP'); # to get synchronous channels - raise NotImplementedError("getTrace function is not implemented") - # if old_trg_mode != "STOP": - # short speed up here with this check - # self.setTriggerMode(old_trg_mode) + old_run_status = self.getRun() + if old_run_status: # avoid unnecessary status change + self.setRun(False) # stop if currently running + self._waitUntillStop() + # to get synchronous channels + wfVoltage, rawChanCfg = self.getWaveform( + chNum, + availableNpnts=availableNpnts, + maxRequiredPoints=maxRequiredPoints, + decimate=decimate, + ) + t = self.getTimeTrace(rawChanCfg) + tr = TraceXY(f"Ch{chNum}") + tr.x = t + tr.y = wfVoltage + # restore scope to the before acquisition mode + if old_run_status: # avoid unnecessary status change + self.setRun(old_run_status) # start running if it was old run state + return tr def getTriggerMode(self): # we expect NORM, AUTO, SINGLE |