forked from M-Labs/artiq
1
0
Fork 0
artiq/frontend/artiq_gui.py

70 lines
2.1 KiB
Python
Raw Normal View History

2014-12-29 12:48:14 +08:00
#!/usr/bin/env python3
import argparse
import asyncio
2015-01-02 14:47:09 +08:00
import atexit
2014-12-29 12:48:14 +08:00
import gbulb
from gi.repository import Gtk
2015-01-05 19:52:58 +08:00
from artiq.management.pc_rpc import AsyncioClient
2014-12-30 18:18:23 +08:00
from artiq.gui.scheduler import SchedulerWindow
2014-12-31 11:11:38 +08:00
from artiq.gui.parameters import ParametersWindow
2015-01-14 22:22:33 +08:00
from artiq.gui.rt_results import RTResults
2014-12-29 12:48:14 +08:00
def _get_args():
parser = argparse.ArgumentParser(description="ARTIQ GUI client")
parser.add_argument(
"-s", "--server", default="::1",
help="hostname or IP of the master to connect to")
parser.add_argument(
"--port-notify", default=3250, type=int,
2014-12-31 20:13:10 +08:00
help="TCP port to connect to for notifications")
2014-12-29 12:48:14 +08:00
parser.add_argument(
"--port-control", default=3251, type=int,
2014-12-31 20:13:10 +08:00
help="TCP port to connect to for control")
2014-12-29 12:48:14 +08:00
return parser.parse_args()
def main():
args = _get_args()
asyncio.set_event_loop_policy(gbulb.GtkEventLoopPolicy())
loop = asyncio.get_event_loop()
2015-01-02 14:47:09 +08:00
atexit.register(lambda: loop.close())
2015-01-05 19:52:58 +08:00
# share the schedule control connection
schedule_ctl = AsyncioClient()
loop.run_until_complete(schedule_ctl.connect_rpc(
args.server, args.port_control, "master_schedule"))
2015-01-06 17:50:15 +08:00
atexit.register(lambda: schedule_ctl.close_rpc())
2015-01-05 19:52:58 +08:00
scheduler_win = SchedulerWindow(schedule_ctl)
2015-01-02 14:47:09 +08:00
scheduler_win.connect("delete-event", Gtk.main_quit)
scheduler_win.show_all()
loop.run_until_complete(scheduler_win.sub_connect(
args.server, args.port_notify))
atexit.register(
lambda: loop.run_until_complete(scheduler_win.sub_close()))
2015-01-05 19:52:58 +08:00
parameters_win = ParametersWindow()
parameters_win.connect("delete-event", Gtk.main_quit)
parameters_win.show_all()
2015-01-02 14:47:09 +08:00
loop.run_until_complete(parameters_win.sub_connect(
args.server, args.port_notify))
atexit.register(
lambda: loop.run_until_complete(parameters_win.sub_close()))
2015-01-14 22:22:33 +08:00
rtr = RTResults()
loop.run_until_complete(rtr.sub_connect(
args.server, args.port_notify))
atexit.register(
lambda: loop.run_until_complete(rtr.sub_close()))
2015-01-02 14:47:09 +08:00
loop.run_forever()
2014-12-29 12:48:14 +08:00
if __name__ == "__main__":
main()