From 3ed70afaa171125eeeab2ff2ee405fe0d09b2ac4 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Mon, 22 May 2017 00:22:10 +0800 Subject: [PATCH] Use commandline prefix for controllers This keeps them better organized and consistent with the artiq_* naming scheme. Tab completion from aqctl_ also lists all the controllers installed on a machine. --- RELEASE_NOTES.rst | 1 + artiq/examples/master/device_db.py | 10 +++---- .../{pdq2_client.py => aqcli_pdq2.py} | 0 ...p_controller.py => aqctl_korad_ka3005p.py} | 0 .../{lda_controller.py => aqctl_lda.py} | 0 ...9b_controller.py => aqctl_novatech409b.py} | 0 .../{pdq2_controller.py => aqctl_pdq2.py} | 0 ..._controller.py => aqctl_thorlabs_tcube.py} | 0 artiq/test/test_korad_ka3005p.py | 2 +- artiq/test/test_novatech409b.py | 2 +- artiq/test/test_thorlabs_tcube.py | 4 +-- doc/manual/developing_a_ndsp.rst | 14 ++++----- doc/manual/ndsp_reference.rst | 30 +++++++++---------- setup.py | 14 +++++---- 14 files changed, 40 insertions(+), 37 deletions(-) rename artiq/frontend/{pdq2_client.py => aqcli_pdq2.py} (100%) rename artiq/frontend/{korad_ka3005p_controller.py => aqctl_korad_ka3005p.py} (100%) rename artiq/frontend/{lda_controller.py => aqctl_lda.py} (100%) rename artiq/frontend/{novatech409b_controller.py => aqctl_novatech409b.py} (100%) rename artiq/frontend/{pdq2_controller.py => aqctl_pdq2.py} (100%) rename artiq/frontend/{thorlabs_tcube_controller.py => aqctl_thorlabs_tcube.py} (100%) diff --git a/RELEASE_NOTES.rst b/RELEASE_NOTES.rst index f87de2534..cc540f779 100644 --- a/RELEASE_NOTES.rst +++ b/RELEASE_NOTES.rst @@ -35,6 +35,7 @@ Release notes an existing database, add ``device_db = `` at the beginning, and replace any PYON identifiers (``true``, ``null``, ...) with their Python equivalents (``True``, ``None` ...). +* Controllers are now named ``aqctl_XXX`` instead of ``XXX_controller``. 2.3 diff --git a/artiq/examples/master/device_db.py b/artiq/examples/master/device_db.py index e111f9b82..513984d6d 100644 --- a/artiq/examples/master/device_db.py +++ b/artiq/examples/master/device_db.py @@ -170,25 +170,25 @@ device_db = { # that it always resolves to a network-visible IP address (see documentation). "host": "::1", "port": 4000, - "command": "pdq2_controller -p {port} --bind {bind} --simulation --dump qc_q1_0.bin" + "command": "aqctl_pdq2 -p {port} --bind {bind} --simulation --dump qc_q1_0.bin" }, "qc_q1_1": { "type": "controller", "host": "::1", "port": 4001, - "command": "pdq2_controller -p {port} --bind {bind} --simulation --dump qc_q1_1.bin" + "command": "aqctl_pdq2 -p {port} --bind {bind} --simulation --dump qc_q1_1.bin" }, "qc_q1_2": { "type": "controller", "host": "::1", "port": 4002, - "command": "pdq2_controller -p {port} --bind {bind} --simulation --dump qc_q1_2.bin" + "command": "aqctl_pdq2 -p {port} --bind {bind} --simulation --dump qc_q1_2.bin" }, "qc_q1_3": { "type": "controller", "host": "::1", "port": 4003, - "command": "pdq2_controller -p {port} --bind {bind} --simulation --dump qc_q1_3.bin" + "command": "aqctl_pdq2 -p {port} --bind {bind} --simulation --dump qc_q1_3.bin" }, "electrodes": { "type": "local", @@ -206,7 +206,7 @@ device_db = { "best_effort": True, "host": "::1", "port": 3253, - "command": "lda_controller -p {port} --bind {bind} --simulation" + "command": "aqctl_lda -p {port} --bind {bind} --simulation" }, "camera_sim": { diff --git a/artiq/frontend/pdq2_client.py b/artiq/frontend/aqcli_pdq2.py similarity index 100% rename from artiq/frontend/pdq2_client.py rename to artiq/frontend/aqcli_pdq2.py diff --git a/artiq/frontend/korad_ka3005p_controller.py b/artiq/frontend/aqctl_korad_ka3005p.py similarity index 100% rename from artiq/frontend/korad_ka3005p_controller.py rename to artiq/frontend/aqctl_korad_ka3005p.py diff --git a/artiq/frontend/lda_controller.py b/artiq/frontend/aqctl_lda.py similarity index 100% rename from artiq/frontend/lda_controller.py rename to artiq/frontend/aqctl_lda.py diff --git a/artiq/frontend/novatech409b_controller.py b/artiq/frontend/aqctl_novatech409b.py similarity index 100% rename from artiq/frontend/novatech409b_controller.py rename to artiq/frontend/aqctl_novatech409b.py diff --git a/artiq/frontend/pdq2_controller.py b/artiq/frontend/aqctl_pdq2.py similarity index 100% rename from artiq/frontend/pdq2_controller.py rename to artiq/frontend/aqctl_pdq2.py diff --git a/artiq/frontend/thorlabs_tcube_controller.py b/artiq/frontend/aqctl_thorlabs_tcube.py similarity index 100% rename from artiq/frontend/thorlabs_tcube_controller.py rename to artiq/frontend/aqctl_thorlabs_tcube.py diff --git a/artiq/test/test_korad_ka3005p.py b/artiq/test/test_korad_ka3005p.py index 50bfbe8f5..5469a8f46 100644 --- a/artiq/test/test_korad_ka3005p.py +++ b/artiq/test/test_korad_ka3005p.py @@ -27,7 +27,7 @@ class TestKoradKA3005P(GenericKoradKA3005PTest, GenericControllerCase): "host": "::1", "port": 3256, "command": (sys.executable.replace("\\", "\\\\") - + " -m artiq.frontend.korad_ka3005p_controller " + + " -m artiq.frontend.aqctl_korad_ka3005p " + "-p {port} --simulation") } } diff --git a/artiq/test/test_novatech409b.py b/artiq/test/test_novatech409b.py index 2a18890eb..f14b28a8e 100644 --- a/artiq/test/test_novatech409b.py +++ b/artiq/test/test_novatech409b.py @@ -35,7 +35,7 @@ class TestNovatech409BSim(GenericNovatech409BTest, GenericControllerCase): "host": "::1", "port": 3254, "command": (sys.executable.replace("\\", "\\\\") - + " -m artiq.frontend.novatech409b_controller " + + " -m artiq.frontend.aqctl_novatech409b " + "-p {port} --simulation") } } diff --git a/artiq/test/test_thorlabs_tcube.py b/artiq/test/test_thorlabs_tcube.py index f435da544..b1adf6208 100644 --- a/artiq/test/test_thorlabs_tcube.py +++ b/artiq/test/test_thorlabs_tcube.py @@ -146,7 +146,7 @@ class TestTdcSim(GenericControllerCase, GenericTdcTest): "host": "::1", "port": 3255, "command": (sys.executable.replace("\\", "\\\\") - + " -m artiq.frontend.thorlabs_tcube_controller " + + " -m artiq.frontend.aqctl_thorlabs_tcube " + "-p {port} -P tdc001 --simulation") } } @@ -172,7 +172,7 @@ class TestTpzSim(GenericControllerCase, GenericTpzTest): "host": "::1", "port": 3255, "command": (sys.executable.replace("\\", "\\\\") - + " -m artiq.frontend.thorlabs_tcube_controller " + + " -m artiq.frontend.aqctl_thorlabs_tcube " + "-p {port} -P tpz001 --simulation") } } diff --git a/doc/manual/developing_a_ndsp.rst b/doc/manual/developing_a_ndsp.rst index f8d043830..a48b7aa2b 100644 --- a/doc/manual/developing_a_ndsp.rst +++ b/doc/manual/developing_a_ndsp.rst @@ -14,8 +14,8 @@ Certain devices (such as the PDQ2) may still perform real-time operations by hav A network device support package (NDSP) is composed of several parts: 1. The `driver`, which contains the Python API functions to be called over the network, and performs the I/O to the device. The top-level module of the driver is called ``artiq.devices.XXX.driver``. -2. The `controller`, which instantiates, initializes and terminates the driver, and sets up the RPC server. The controller is a front-end command-line tool to the user and is called ``artiq.frontend.XXX_controller``. A ``setup.py`` entry must also be created to install it. -3. An optional `client`, which connects to the controller and exposes the functions of the driver as a command-line interface. Clients are front-end tools (called ``artiq.frontend.XXX_client``) that have ``setup.py`` entries. In most cases, a custom client is not needed and the generic ``artiq_rpctool`` utility can be used instead. Custom clients are only required when large amounts of data must be transferred over the network API, that would be unwieldy to pass as ``artiq_rpctool`` command-line parameters. +2. The `controller`, which instantiates, initializes and terminates the driver, and sets up the RPC server. The controller is a front-end command-line tool to the user and is called ``artiq.frontend.aqctl_XXX``. A ``setup.py`` entry must also be created to install it. +3. An optional `client`, which connects to the controller and exposes the functions of the driver as a command-line interface. Clients are front-end tools (called ``artiq.frontend.aqcli_XXX``) that have ``setup.py`` entries. In most cases, a custom client is not needed and the generic ``artiq_rpctool`` utility can be used instead. Custom clients are only required when large amounts of data must be transferred over the network API, that would be unwieldy to pass as ``artiq_rpctool`` command-line parameters. 4. An optional `mediator`, which is code executed on the client that supplements the network API. A mediator may contain kernels that control real-time signals such as TTL lines connected to the device. Simple devices use the network API directly and do not have a mediator. Mediator modules are called ``artiq.devices.XXX.mediator`` and their public classes are exported at the ``artiq.devices.XXX`` level (via ``__init__.py``) for direct import and use by the experiments. The driver and controller @@ -51,13 +51,13 @@ The parameters ``::1`` and ``3249`` are respectively the address to bind the ser #!/usr/bin/env python3 -at the beginning of the file, save it to ``hello_controller.py`` and set its execution permissions: :: +at the beginning of the file, save it to ``aqctl_hello.py`` and set its execution permissions: :: - $ chmod 755 hello_controller.py + $ chmod 755 aqctl_hello.py Run it as: :: - $ ./hello_controller.py + $ ./aqctl_hello.py and verify that you can connect to the TCP port: :: @@ -81,7 +81,7 @@ Clients are small command-line utilities that expose certain functionalities of $ artiq_rpctool ::1 3249 list-methods $ artiq_rpctool ::1 3249 call message test -In case you are developing a NDSP that is complex enough to need a custom client, we will see how to develop one. Create a ``hello_client.py`` file with the following contents: :: +In case you are developing a NDSP that is complex enough to need a custom client, we will see how to develop one. Create a ``aqcli_hello.py`` file with the following contents: :: #!/usr/bin/env python3 @@ -100,7 +100,7 @@ In case you are developing a NDSP that is complex enough to need a custom client Run it as before, while the controller is running. You should see the message appearing on the controller's terminal: :: - $ ./hello_controller.py + $ ./aqctl_hello.py message: Hello World! When using the driver in an experiment, the ``Client`` instance can be returned by the environment mechanism (via the ``get_device`` and ``attr_device`` methods of :class:`artiq.language.environment.HasEnvironment`) and used normally as a device. diff --git a/doc/manual/ndsp_reference.rst b/doc/manual/ndsp_reference.rst index 50411a7fc..671860d59 100644 --- a/doc/manual/ndsp_reference.rst +++ b/doc/manual/ndsp_reference.rst @@ -21,15 +21,15 @@ Controller ++++++++++ .. argparse:: - :ref: artiq.frontend.pdq2_controller.get_argparser - :prog: pdq2_controller + :ref: artiq.frontend.aqctl_pdq2.get_argparser + :prog: aqctl_pdq2 Client ++++++ .. argparse:: - :ref: artiq.frontend.pdq2_client.get_argparser - :prog: pdq2_client + :ref: artiq.frontend.aqcli_pdq2.get_argparser + :prog: aqcli_pdq2 Lab Brick Digital Attenuator (LDA) ---------------------------------- @@ -58,7 +58,7 @@ You must also unplug/replug your device if it was already plugged in. Then, to run the Lab Brick Digital Attenuator (LDA) controller:: - $ lda_controller -d SN:xxxxx + $ aqctl_lda -d SN:xxxxx The serial number must contain exactly 5 digits, prepend it with the necessary number of 0s. Also, the ``SN:`` prefix is mandatory. @@ -66,8 +66,8 @@ Also, the ``SN:`` prefix is mandatory. You can choose the LDA model with the ``-P`` parameter. The default is LDA-102. .. argparse:: - :ref: artiq.frontend.lda_controller.get_argparser - :prog: lda_controller + :ref: artiq.frontend.aqctl_lda.get_argparser + :prog: aqctl_lda Korad KA3005P ------------- @@ -82,8 +82,8 @@ Controller ++++++++++ .. argparse:: - :ref: artiq.frontend.korad_ka3005p_controller.get_argparser - :prog: korad_ka3005p_controller + :ref: artiq.frontend.aqctl_korad_ka3005p.get_argparser + :prog: aqctl_korad_ka3005p Novatech 409B ------------- @@ -98,8 +98,8 @@ Controller ++++++++++ .. argparse:: - :ref: artiq.frontend.novatech409b_controller.get_argparser - :prog: novatech409b_controller + :ref: artiq.frontend.aqctl_novatech409b.get_argparser + :prog: aqctl_novatech409b Thorlabs T-Cube --------------- @@ -123,8 +123,8 @@ Controller ++++++++++ .. argparse:: - :ref: artiq.frontend.thorlabs_tcube_controller.get_argparser - :prog: thorlabs_controller + :ref: artiq.frontend.aqctl_thorlabs_tcube.get_argparser + :prog: aqctl_thorlabs .. _tdc001-controller-usage-example: @@ -133,7 +133,7 @@ TDC001 controller usage example First, run the TDC001 controller:: - $ thorlabs_tcube_controller -P TDC001 -d /dev/ttyUSBx + $ aqctl_thorlabs_tcube -P TDC001 -d /dev/ttyUSBx .. note:: On Windows the serial port (the ``-d`` argument) will be of the form ``COMx``. @@ -166,7 +166,7 @@ TPZ001 controller usage example First, run the TPZ001 controller:: - $ thorlabs_tcube_controller -P TPZ001 -d /dev/ttyUSBx + $ aqctl_thorlabs_tcube -P TPZ001 -d /dev/ttyUSBx .. note:: On Windows the serial port (the ``-d`` argument) will be of the form ``COMx``. diff --git a/setup.py b/setup.py index c8001e8f5..f644b863e 100755 --- a/setup.py +++ b/setup.py @@ -35,12 +35,14 @@ console_scripts = [ "artiq_rpctool=artiq.frontend.artiq_rpctool:main", "artiq_run=artiq.frontend.artiq_run:main", "artiq_flash=artiq.frontend.artiq_flash:main", - "lda_controller=artiq.frontend.lda_controller:main", - "novatech409b_controller=artiq.frontend.novatech409b_controller:main", - "korad_ka3005p_controller=artiq.frontend.korad_ka3005p_controller:main", - "pdq2_client=artiq.frontend.pdq2_client:main", - "pdq2_controller=artiq.frontend.pdq2_controller:main", - "thorlabs_tcube_controller=artiq.frontend.thorlabs_tcube_controller:main", + + "aqctl_lda=artiq.frontend.aqctl_lda:main", + "aqctl_novatech409b=artiq.frontend.aqctl_novatech409b:main", + "aqctl_korad_ka3005p=artiq.frontend.aqctl_korad_ka3005p:main", + "aqctl_pdq2=artiq.frontend.aqctl_pdq2:main", + "aqctl_thorlabs_tcube=artiq.frontend.aqctl_thorlabs_tcube:main", + + "aqcli_pdq2=artiq.frontend.aqcli_pdq2:main", ] gui_scripts = [