Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DoND reraise interupts #34

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions qcodes/utils/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ def do1d(inst_set, start, stop, num_points, delay, *inst_meas):
# try to flush VISA buffers at the beginning of a measurement
_flush_buffers(inst_set, *inst_meas)

interrupted = False
loop = qc.Loop(inst_set.sweep(start,
stop, num=num_points), delay).each(*inst_meas)
data = loop.get_data_set()
Expand All @@ -281,6 +282,7 @@ def do1d(inst_set, start, stop, num_points, delay, *inst_meas):
try:
_ = loop.with_bg_task(plot.update).run()
except KeyboardInterrupt:
interrupted = True
print("Measurement Interrupted")
plot.save()
pdfplot, num_subplots = _plot_setup(data, plottables, useQT=False)
Expand All @@ -298,6 +300,8 @@ def do1d(inst_set, start, stop, num_points, delay, *inst_meas):
with open(CURRENT_EXPERIMENT['logfile'], 'a') as fid:
print("#[QCoDeS]# Saved dataset to: {}".format(data.location),
file=fid)
if interrupted:
raise KeyboardInterrupt
return plot, data


Expand All @@ -324,6 +328,7 @@ def do1dDiagonal(inst_set, inst2_set, start, stop, num_points, delay, start2, sl
# try to flush VISA buffers at the beginning of a measurement
_flush_buffers(inst_set, inst2_set, *inst_meas)

interrupted = False
loop = qc.Loop(inst_set.sweep(start, stop, num=num_points), delay).each(
qc.Task(inst2_set, (inst_set) * slope + (slope * start - start2)), *inst_meas, inst2_set)
data = loop.get_data_set()
Expand All @@ -333,6 +338,7 @@ def do1dDiagonal(inst_set, inst2_set, start, stop, num_points, delay, start2, sl
_ = loop.with_bg_task(plot.update).run()
except KeyboardInterrupt:
print("Measurement Interrupted")
interrupted = True
plot.save()
pdfplot, num_subplots = _plot_setup(data, plottables, useQT=False)
# pad a bit more to prevent overlap between
Expand All @@ -349,7 +355,8 @@ def do1dDiagonal(inst_set, inst2_set, start, stop, num_points, delay, start2, sl
with open(CURRENT_EXPERIMENT['logfile'], 'a') as fid:
print("#[QCoDeS]# Saved dataset to: {}".format(data.location),
file=fid)

if interrupted:
raise KeyboardInterrupt
return plot, data


Expand Down Expand Up @@ -377,6 +384,7 @@ def do2d(inst_set, start, stop, num_points, delay, inst_set2, start2, stop2, num
# try to flush VISA buffers at the beginning of a measurement
_flush_buffers(inst_set, inst_set2, *inst_meas)

interrupted = False
for inst in inst_meas:
if getattr(inst, "setpoints", False):
raise ValueError("3d plotting is not supported")
Expand All @@ -389,6 +397,7 @@ def do2d(inst_set, start, stop, num_points, delay, inst_set2, start2, stop2, num
try:
_ = loop.with_bg_task(plot.update).run()
except KeyboardInterrupt:
interrupted = True
print("Measurement Interrupted")
plot.save()
pdfplot, num_subplots = _plot_setup(data, plottables, useQT=False)
Expand All @@ -406,7 +415,8 @@ def do2d(inst_set, start, stop, num_points, delay, inst_set2, start2, stop2, num
with open(CURRENT_EXPERIMENT['logfile'], 'a') as fid:
print("#[QCoDeS]# Saved dataset to: {}".format(data.location),
file=fid)

if interrupted:
raise KeyboardInterrupt
return plot, data


Expand Down