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: c97946a71c36
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: 8979d9d5e7c1
Choose a head ref
  • 3 commits
  • 2 files changed
  • 2 contributors

Commits on Feb 6, 2015

  1. Copy the full SHA
    f9d3bd1 View commit details
  2. Add missing dependencies and their repositories

    - By adding the dependency_links statement,
    setup.py can now automatically fetch gbulb and cairoplot3
    and install them. This makes users life easier.
    fallen authored and sbourdeauducq committed Feb 6, 2015
    Copy the full SHA
    5cec341 View commit details
  3. Copy the full SHA
    8979d9d View commit details
Showing with 66 additions and 12 deletions.
  1. +53 −7 artiq/frontend/artiq_ctlmgr.py
  2. +13 −5 setup.py
60 changes: 53 additions & 7 deletions artiq/frontend/artiq_ctlmgr.py
Original file line number Diff line number Diff line change
@@ -3,38 +3,84 @@
import asyncio
import argparse
import os
import logging

from artiq.protocols.sync_struct import Subscriber
from artiq.tools import verbosity_args, init_logger


logger = logging.getLogger(__name__)


def get_argparser():
parser = argparse.ArgumentParser(description="ARTIQ controller manager")
verbosity_args(parser)
parser.add_argument(
"-s", "--server", default="::1",
help="hostname or IP of the master to connect to")
parser.add_argument(
"--port", default=3250, type=int,
help="TCP port to use to connect to the master")
parser.add_argument(
"--retry-master", default=5.0, type=float,
help="retry timer for reconnecting to master")
return parser


class Controllers:
def __setitem__(self, k, v):
print("set {} {}".format(k, v))

def __delitem__(self, k):
print("del {}".format(k))

def delete_all(self):
print("delete all")


class ControllerDB:
def __init__(self):
self.current_controllers = Controllers()

def sync_struct_init(self, init):
if self.current_controllers is not None:
self.current_controllers.delete_all()
for k, v in init.items():
self.current_controllers[k] = v


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

controller_db = ControllerDB()

if os.name == "nt":
loop = asyncio.ProactorEventLoop()
asyncio.set_event_loop(loop)
else:
loop = asyncio.get_event_loop()
try:
subscriber = Subscriber("master_ddb", lambda x: x)
loop.run_until_complete(subscriber.connect(args.server, args.port))
try:
loop.run_forever()
finally:
loop.run_until_complete(subscriber.close())
subscriber = Subscriber("devices", controller_db.sync_struct_init)
while True:
try:
loop.run_until_complete(
subscriber.connect(args.server, args.port))
try:
loop.run_until_complete(subscriber.receive_task)
finally:
loop.run_until_complete(subscriber.close())
except (ConnectionAbortedError, ConnectionError,
ConnectionRefusedError, ConnectionResetError) as e:
logger.warning("Connection to master failed (%s: %s)",
e.__class__.__name__, str(e))
else:
logger.warning("Connection to master lost")
logger.warning("Retrying in %.1f seconds", args.retry_master)
loop.run_until_complete(asyncio.sleep(args.retry_master))
finally:
loop.close()
loop.close()
controller_db.current_controllers.delete_all()

if __name__ == "__main__":
main()
18 changes: 13 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
@@ -4,6 +4,14 @@
import os


requirements = [
"sphinx", "sphinx-argparse", "pyserial", "numpy", "scipy",
"python-dateutil", "prettytable", "h5py"
]
if os.name != 'nt':
requirements += ["pygobject", "gbulb", "cairoplot"]


setup(
name="artiq",
version="0.0+dev",
@@ -13,12 +21,12 @@
description="A control system for trapped-ion experiments",
long_description=open("README.rst").read(),
license="BSD",
install_requires=[
"sphinx", "sphinx-argparse", "pyserial", "numpy", "scipy",
"python-dateutil", "prettytable", "h5py"
],
install_requires=requirements,
extras_require={},
dependency_links=[],
dependency_links=[
"git+https://github.com/m-labs/gbulb.git#egg=gbulb",
"git+https://github.com/m-labs/cairoplot3.git#egg=cairoplot"
],
packages=find_packages(),
namespace_packages=[],
test_suite="artiq.test",