mirror of
https://github.com/m-labs/artiq.git
synced 2024-12-26 11:48:27 +08:00
serve GUI and Glade file from master
This commit is contained in:
parent
8904d963d2
commit
db3114f79b
@ -43,11 +43,15 @@ def main():
|
|||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
atexit.register(lambda: loop.close())
|
atexit.register(lambda: loop.close())
|
||||||
|
|
||||||
# share the schedule control connection
|
# share the schedule control and repository connections
|
||||||
schedule_ctl = AsyncioClient()
|
schedule_ctl = AsyncioClient()
|
||||||
loop.run_until_complete(schedule_ctl.connect_rpc(
|
loop.run_until_complete(schedule_ctl.connect_rpc(
|
||||||
args.server, args.port_control, "master_schedule"))
|
args.server, args.port_control, "master_schedule"))
|
||||||
atexit.register(lambda: schedule_ctl.close_rpc())
|
atexit.register(lambda: schedule_ctl.close_rpc())
|
||||||
|
repository = AsyncioClient()
|
||||||
|
loop.run_until_complete(repository.connect_rpc(
|
||||||
|
args.server, args.port_control, "master_repository"))
|
||||||
|
atexit.register(lambda: repository.close_rpc())
|
||||||
|
|
||||||
scheduler_win = lmgr.create_window(SchedulerWindow,
|
scheduler_win = lmgr.create_window(SchedulerWindow,
|
||||||
"scheduler",
|
"scheduler",
|
||||||
@ -65,7 +69,9 @@ def main():
|
|||||||
|
|
||||||
explorer_win = lmgr.create_window(ExplorerWindow,
|
explorer_win = lmgr.create_window(ExplorerWindow,
|
||||||
"explorer",
|
"explorer",
|
||||||
schedule_ctl)
|
schedule_ctl,
|
||||||
|
repository)
|
||||||
|
loop.run_until_complete(explorer_win.load_controls())
|
||||||
scheduler_win.show_all()
|
scheduler_win.show_all()
|
||||||
parameters_win.show_all()
|
parameters_win.show_all()
|
||||||
explorer_win.show_all()
|
explorer_win.show_all()
|
||||||
|
@ -9,6 +9,7 @@ from artiq.protocols.sync_struct import Publisher
|
|||||||
from artiq.protocols.file_db import FlatFileDB, SimpleHistory
|
from artiq.protocols.file_db import FlatFileDB, SimpleHistory
|
||||||
from artiq.master.scheduler import Scheduler
|
from artiq.master.scheduler import Scheduler
|
||||||
from artiq.master.rt_results import RTResults
|
from artiq.master.rt_results import RTResults
|
||||||
|
from artiq.master.repository import Repository
|
||||||
|
|
||||||
|
|
||||||
def get_argparser():
|
def get_argparser():
|
||||||
@ -33,6 +34,7 @@ def main():
|
|||||||
simplephist = SimpleHistory(30)
|
simplephist = SimpleHistory(30)
|
||||||
pdb.hooks.append(simplephist)
|
pdb.hooks.append(simplephist)
|
||||||
rtr = RTResults()
|
rtr = RTResults()
|
||||||
|
repository = Repository()
|
||||||
|
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
atexit.register(lambda: loop.close())
|
atexit.register(lambda: loop.close())
|
||||||
@ -48,9 +50,10 @@ def main():
|
|||||||
atexit.register(lambda: loop.run_until_complete(scheduler.stop()))
|
atexit.register(lambda: loop.run_until_complete(scheduler.stop()))
|
||||||
|
|
||||||
server_control = Server({
|
server_control = Server({
|
||||||
"master_schedule": scheduler,
|
|
||||||
"master_ddb": ddb,
|
"master_ddb": ddb,
|
||||||
"master_pdb": pdb
|
"master_pdb": pdb,
|
||||||
|
"master_schedule": scheduler,
|
||||||
|
"master_repository": repository
|
||||||
})
|
})
|
||||||
loop.run_until_complete(server_control.start(
|
loop.run_until_complete(server_control.start(
|
||||||
args.bind, args.port_control))
|
args.bind, args.port_control))
|
||||||
|
@ -5,68 +5,10 @@ from gi.repository import Gtk
|
|||||||
from artiq.gui.tools import Window, getitem
|
from artiq.gui.tools import Window, getitem
|
||||||
|
|
||||||
|
|
||||||
_test_description = """
|
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!-- Generated with glade 3.18.3 -->
|
|
||||||
<interface>
|
|
||||||
<requires lib="gtk+" version="3.12"/>
|
|
||||||
<object class="GtkAdjustment" id="adjustment1">
|
|
||||||
<property name="lower">1000</property>
|
|
||||||
<property name="upper">2000</property>
|
|
||||||
<property name="value">1500</property>
|
|
||||||
<property name="step_increment">1</property>
|
|
||||||
<property name="page_increment">10</property>
|
|
||||||
</object>
|
|
||||||
<object class="GtkBox" id="top">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkLabel" id="label1">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="label" translatable="yes">Simulated flopping frequency</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">0</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkSpinButton" id="spinbutton1">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="input_purpose">number</property>
|
|
||||||
<property name="adjustment">adjustment1</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</interface>
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
class _ExperimentControls:
|
|
||||||
def __init__(self):
|
|
||||||
self.builder = Gtk.Builder()
|
|
||||||
self.builder.add_from_string(_test_description)
|
|
||||||
|
|
||||||
def get_top_widget(self):
|
|
||||||
return self.builder.get_object("top")
|
|
||||||
|
|
||||||
def get_arguments(self):
|
|
||||||
return {
|
|
||||||
"F0": self.builder.get_object("adjustment1").get_value()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class ExplorerWindow(Window):
|
class ExplorerWindow(Window):
|
||||||
def __init__(self, schedule_ctl, layout_dict=dict()):
|
def __init__(self, schedule_ctl, repository, layout_dict=dict()):
|
||||||
self.schedule_ctl = schedule_ctl
|
self.schedule_ctl = schedule_ctl
|
||||||
|
self.repository = repository
|
||||||
|
|
||||||
Window.__init__(self,
|
Window.__init__(self,
|
||||||
title="Explorer",
|
title="Explorer",
|
||||||
@ -106,14 +48,21 @@ class ExplorerWindow(Window):
|
|||||||
button.connect("clicked", self.run)
|
button.connect("clicked", self.run)
|
||||||
listvbox.pack_start(button, False, False, 0)
|
listvbox.pack_start(button, False, False, 0)
|
||||||
|
|
||||||
self.controls = _ExperimentControls()
|
|
||||||
self.pane.pack2(self.controls.get_top_widget())
|
|
||||||
|
|
||||||
def get_layout_dict(self):
|
def get_layout_dict(self):
|
||||||
r = Window.get_layout_dict(self)
|
r = Window.get_layout_dict(self)
|
||||||
r["pane_position"] = self.pane.get_position()
|
r["pane_position"] = self.pane.get_position()
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
@asyncio.coroutine
|
||||||
|
def load_controls(self):
|
||||||
|
gui_mod_data = yield from self.repository.get_data(
|
||||||
|
"flopping_f_simulation_gui.py")
|
||||||
|
gui_mod = dict()
|
||||||
|
exec(gui_mod_data, gui_mod)
|
||||||
|
self.controls = gui_mod["Controls"]()
|
||||||
|
yield from self.controls.build(self.repository.get_data)
|
||||||
|
self.pane.pack2(self.controls.get_top_widget())
|
||||||
|
|
||||||
def run(self, widget):
|
def run(self, widget):
|
||||||
run_params = {
|
run_params = {
|
||||||
"file": "flopping_f_simulation.py",
|
"file": "flopping_f_simulation.py",
|
||||||
|
4
artiq/master/repository.py
Normal file
4
artiq/master/repository.py
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
class Repository:
|
||||||
|
def get_data(self, filename):
|
||||||
|
with open(filename) as f:
|
||||||
|
return f.read()
|
41
examples/flopping_f_simulation_gui.glade
Normal file
41
examples/flopping_f_simulation_gui.glade
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- Generated with glade 3.18.3 -->
|
||||||
|
<interface>
|
||||||
|
<requires lib="gtk+" version="3.12"/>
|
||||||
|
<object class="GtkAdjustment" id="F0">
|
||||||
|
<property name="lower">1000</property>
|
||||||
|
<property name="upper">2000</property>
|
||||||
|
<property name="value">1500</property>
|
||||||
|
<property name="step_increment">1</property>
|
||||||
|
<property name="page_increment">10</property>
|
||||||
|
</object>
|
||||||
|
<object class="GtkBox" id="top">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="label1">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="label" translatable="yes">Simulated flopping frequency</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkSpinButton" id="spinbutton1">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="input_purpose">number</property>
|
||||||
|
<property name="adjustment">F0</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</interface>
|
19
examples/flopping_f_simulation_gui.py
Normal file
19
examples/flopping_f_simulation_gui.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import asyncio
|
||||||
|
|
||||||
|
from gi.repository import Gtk
|
||||||
|
|
||||||
|
|
||||||
|
class Controls:
|
||||||
|
@asyncio.coroutine
|
||||||
|
def build(self, get_data):
|
||||||
|
self.builder = Gtk.Builder()
|
||||||
|
data = yield from get_data("flopping_f_simulation_gui.glade")
|
||||||
|
self.builder.add_from_string(data)
|
||||||
|
|
||||||
|
def get_top_widget(self):
|
||||||
|
return self.builder.get_object("top")
|
||||||
|
|
||||||
|
def get_arguments(self):
|
||||||
|
return {
|
||||||
|
"F0": self.builder.get_object("F0").get_value()
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user