From 9b937e08f4b3203bdced7e3560da950d15b30e55 Mon Sep 17 00:00:00 2001 From: raghu Date: Wed, 7 Sep 2016 17:22:45 -0600 Subject: [PATCH] added repetitions for no scan, repetitions set to one when disable other scans selected. Closes #532 --- artiq/gui/entries.py | 16 +++++++++++++++- artiq/language/scan.py | 14 +++++++++----- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/artiq/gui/entries.py b/artiq/gui/entries.py index c05cd5947..7b09aeb0b 100644 --- a/artiq/gui/entries.py +++ b/artiq/gui/entries.py @@ -136,6 +136,18 @@ class _NoScan(LayoutWidget): state["value"] = value*scale self.value.valueChanged.connect(update) + self.repetitions = QtWidgets.QSpinBox() + self.repetitions.setMinimum(1) + self.repetitions.setMaximum((1 << 31) - 1) + disable_scroll_wheel(self.repetitions) + self.addWidget(QtWidgets.QLabel("Repetitions:"), 1, 0) + self.addWidget(self.repetitions, 1, 1) + + self.repetitions.setValue(state["repetitions"]) + + def update_repetitions(value): + state["repetitions"] = value + self.repetitions.valueChanged.connect(update_repetitions) class _RangeScan(LayoutWidget): def __init__(self, procdesc, state): @@ -272,6 +284,7 @@ class ScanEntry(LayoutWidget): def disable(self): self.radiobuttons["NoScan"].setChecked(True) + self.widgets["NoScan"].repetitions.setValue(1) @staticmethod def state_to_value(state): @@ -285,7 +298,7 @@ class ScanEntry(LayoutWidget): scale = procdesc["scale"] state = { "selected": "NoScan", - "NoScan": {"value": 0.0}, + "NoScan": {"value": 0.0, "repetitions": 1}, "LinearScan": {"start": 0.0, "stop": 100.0*scale, "npoints": 10}, "RandomScan": {"start": 0.0, "stop": 100.0*scale, "npoints": 10}, "ExplicitScan": {"sequence": []} @@ -299,6 +312,7 @@ class ScanEntry(LayoutWidget): ty = default["ty"] if ty == "NoScan": state[ty]["value"] = default["value"] + state[ty]["repetitions"] = default["repetitions"] elif ty == "LinearScan" or ty == "RandomScan": state[ty]["start"] = default["start"] state[ty]["stop"] = default["stop"] diff --git a/artiq/language/scan.py b/artiq/language/scan.py index 242e23e8c..cdab4b276 100644 --- a/artiq/language/scan.py +++ b/artiq/language/scan.py @@ -36,23 +36,27 @@ class ScanObject: class NoScan(ScanObject): - """A scan object that yields a single value.""" - def __init__(self, value): + """A scan object that yields a single value for a specified number + of repetitions.""" + def __init__(self, value, repetitions): self.value = value + self.repetitions = repetitions @portable def _gen(self): - yield self.value + for i in range(self.repetitions): + yield self.value @portable def __iter__(self): return self._gen() def __len__(self): - return 1 + return self.repetitions def describe(self): - return {"ty": "NoScan", "value": self.value} + return {"ty": "NoScan", "value": self.value, + "repetitions": self.repetitions} class LinearScan(ScanObject):