diff options
author | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2024-07-22 10:27:14 -0400 |
---|---|---|
committer | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2024-07-22 10:27:14 -0400 |
commit | 765df9b3d0a0a93e7abf2fd7d213d974ab145eb9 (patch) | |
tree | 9820c631cc65a3526db1466351d19b412783bb82 /qolab/hardware/scope | |
parent | d1870400ab80a05c653e96655fd908bd1bc1c8bd (diff) | |
download | qolab-765df9b3d0a0a93e7abf2fd7d213d974ab145eb9.tar.gz qolab-765df9b3d0a0a93e7abf2fd7d213d974ab145eb9.zip |
added function which waits for scope to stop
Diffstat (limited to 'qolab/hardware/scope')
-rw-r--r-- | qolab/hardware/scope/_basic.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/qolab/hardware/scope/_basic.py b/qolab/hardware/scope/_basic.py index a5626c7..afc2913 100644 --- a/qolab/hardware/scope/_basic.py +++ b/qolab/hardware/scope/_basic.py @@ -8,6 +8,15 @@ import numpy as np from qolab.hardware.scpi import SCPIinstr from qolab.hardware.basic import BasicInstrument from qolab.data.trace import TraceSetSameX +import time +import logging + +logging.basicConfig( + format="%(asctime)s %(levelname)8s %(name)s: %(message)s", + datefmt="%m/%d/%Y %H:%M:%S", +) +logger = logging.getLogger(__name__) +logger.setLevel(logging.INFO) def calcSparsingAndNumPoints(availableNpnts=None, maxRequiredPoints=None): @@ -98,6 +107,30 @@ class Scope(BasicInstrument): """Either enable run or stop the acquisition.""" raise NotImplementedError("setRun function is not implemented") + def _waitUntillStop(self, timeout=0.1): + """Wait until scope in the stop state. + + Just because we ask for a scope to stop, does not mean + that it is stopped. It can still wait for a trigger or untill + the time span is filled. + + Parameter + --------- + timeout : float + timeout in seconds, default is 1 second + """ + starttime = time.time() + deadline = starttime + timeout + while time.time() < deadline: + if self.getRun(): + time.sleep(0.010) + else: + logger.debug(f"Scope stopped within {time.time()-starttime} seconds.") + return + logger.warning( + f"Scope did not reach STOP state within {timeout=} sec, try to increase it." + ) + def getAllTraces(self, availableNpnts=None, maxRequiredPoints=None, decimate=True): allTraces = TraceSetSameX("scope traces") allTraces.config["tags"]["DAQ"] = self.getConfig() |