Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/artiq
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: deaa492566d0
Choose a base ref
...
head repository: m-labs/artiq
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1a0dc499ddc8
Choose a head ref
  • 4 commits
  • 4 files changed
  • 1 contributor

Commits on Jul 19, 2015

  1. Copy the full SHA
    937ca85 View commit details
  2. Copy the full SHA
    bb05ed2 View commit details
  3. gui: add pyqtgraph patch to prevent closing of detached nonclosable d…

    …ocks (move them to main window instead)
    sbourdeauducq committed Jul 19, 2015
    Copy the full SHA
    97ebdee View commit details
  4. Copy the full SHA
    1a0dc49 View commit details
Showing with 137 additions and 18 deletions.
  1. +13 −5 artiq/frontend/artiq_gui.py
  2. +3 −1 artiq/language/__init__.py
  3. +93 −12 artiq/language/scan.py
  4. +28 −0 misc/pyqtgraph-do-not-close-nonclosable-docks.patch
18 changes: 13 additions & 5 deletions artiq/frontend/artiq_gui.py
Original file line number Diff line number Diff line change
@@ -41,6 +41,17 @@ def get_argparser():
return parser


class _MainWindow(QtGui.QMainWindow):
def __init__(self, app):
QtGui.QMainWindow.__init__(self)
self.setWindowIcon(QtGui.QIcon(os.path.join(data_dir, "icon.png")))
self.resize(1400, 800)
self.setWindowTitle("ARTIQ")
self.exit_request = asyncio.Event()

def closeEvent(self, *args):
self.exit_request.set()

def main():
args = get_argparser().parse_args()

@@ -56,15 +67,12 @@ def main():
args.server, args.port_control, "master_schedule"))
atexit.register(lambda: schedule_ctl.close_rpc())

win = QtGui.QMainWindow()
win.setWindowIcon(QtGui.QIcon(os.path.join(data_dir, "icon.png")))
win = _MainWindow(app)
area = dockarea.DockArea()
win.setCentralWidget(area)
status_bar = QtGui.QStatusBar()
status_bar.showMessage("Connected to {}".format(args.server))
win.setStatusBar(status_bar)
win.resize(1400, 800)
win.setWindowTitle("ARTIQ")

d_explorer = ExplorerDock(win, status_bar, schedule_ctl)
loop.run_until_complete(d_explorer.sub_connect(
@@ -101,7 +109,7 @@ def main():
area.addDock(d_schedule, "above", d_log)

win.show()
loop.run_forever()
loop.run_until_complete(win.exit_request.wait())

if __name__ == "__main__":
main()
4 changes: 3 additions & 1 deletion artiq/language/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from artiq.language import core, environment, units
from artiq.language import core, environment, units, scan
from artiq.language.core import *
from artiq.language.environment import *
from artiq.language.units import *
from artiq.language.scan import *


__all__ = []
__all__.extend(core.__all__)
__all__.extend(environment.__all__)
__all__.extend(units.__all__)
__all__.extend(scan.__all__)
105 changes: 93 additions & 12 deletions artiq/language/scan.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
from random import Random
from random import Random, shuffle
import inspect

from artiq.language.core import *
from artiq.language.environment import NoDefault, DefaultMissing


__all__ = ["NoScan", "LinearScan", "RandomScan", "ExplicitScan", "Scannable"]


class NoScan:
def __init__(self, value):
self.value = value

@portable
def _gen(self):
yield self.value

@portable
def __iter__(self):
return self._gen()

def describe(self):
return {"ty": "NoScan", "value": self.value}


class LinearScan:
@@ -7,28 +30,86 @@ def __init__(self, min, max, npoints):
self.max = max
self.npoints = npoints

@portable
def _gen(self):
r = self.max - self.min
d = self.npoints - 1
for i in range(self.npoints):
yield r*i/d + self.min

@portable
def __iter__(self):
return self._gen()

def describe(self):
return {"ty": "LinearScan",
"min": self.min, "max": self.max, "npoints": self.npoints}


class RandomScan:
def __init__(self, min, max, npoints, seed=0):
self.min = min
self.max = max
self.npoints = npoints
self.seed = 0

def _gen(self):
prng = Random(self.seed)
r = self.max - self.min
for i in range(self.npoints):
yield prng.random()*r + self.min
self.sequence = list(LinearScan(min, max, npoints))
shuffle(self.sequence, Random(seed).random)

@portable
def __iter__(self):
return self._gen()
return iter(self.sequence)

def describe(self):
return {"ty": "RandomScan",
"min": self.min, "max": self.max, "npoints": self.npoints}



class ExplicitScan:
def __init__(self, sequence):
self.sequence = sequence

@portable
def __iter__(self):
return iter(self.sequence)

def describe(self):
return {"ty": "ExplicitScan", "sequence": self.sequence}


_ty_to_scan = {
"NoScan": NoScan,
"LinearScan": LinearScan,
"RandomScan": RandomScan,
"ExplicitScan": ExplicitScan
}


class Scannable:
def __init__(self, global_min=None, global_max=None, global_step=None,
unit="", default=NoDefault):
self.global_min = global_min
self.global_max = global_max
self.global_step = global_step
self.unit = unit
if default is not NoDefault:
self.default_value = default

def default(self):
if not hasattr(self, "default_value"):
raise DefaultMissing
return self.default_value

def process(self, x):
cls = _ty_to_scan[x["ty"]]
args = dict()
for arg in inspect.getargspec(cls).args[1:]:
if arg in x:
args[arg] = x[arg]
return cls(**args)

def describe(self):
d = {"ty": "Scannable"}
d["global_min"] = self.global_min
d["global_max"] = self.global_max
d["global_step"] = self.global_step
d["unit"]= self.unit
if hasattr(self, "default_value"):
d["default"] = self.default_value.describe()
return d
28 changes: 28 additions & 0 deletions misc/pyqtgraph-do-not-close-nonclosable-docks.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
diff --git a/pyqtgraph/dockarea/Dock.py b/pyqtgraph/dockarea/Dock.py
index 4493d07..a05e685 100644
--- a/pyqtgraph/dockarea/Dock.py
+++ b/pyqtgraph/dockarea/Dock.py
@@ -18,6 +18,7 @@ class Dock(QtGui.QWidget, DockDrop):
self.label = DockLabel(name, self, closable)
if closable:
self.label.sigCloseClicked.connect(self.close)
+ self.closable = closable
self.labelHidden = False
self.moveLabel = True ## If false, the dock is no longer allowed to move the label.
self.autoOrient = autoOrientation
diff --git a/pyqtgraph/dockarea/DockArea.py b/pyqtgraph/dockarea/DockArea.py
index ffe75b6..b054b24 100644
--- a/pyqtgraph/dockarea/DockArea.py
+++ b/pyqtgraph/dockarea/DockArea.py
@@ -306,7 +306,10 @@ class DockArea(Container, QtGui.QWidget, DockDrop):
def clear(self):
docks = self.findAll()[1]
for dock in docks.values():
- dock.close()
+ if dock.closable:
+ dock.close()
+ else:
+ self.home.moveDock(dock, "top", None)

## PySide bug: We need to explicitly redefine these methods
## or else drag/drop events will not be delivered.