Skip to content

Commit

Permalink
move controllers/clients to frontend
Browse files Browse the repository at this point in the history
sbourdeauducq committed Dec 11, 2014
1 parent c3953d8 commit d315268
Showing 8 changed files with 78 additions and 75 deletions.
Empty file added artiq/devices/lda/__init__.py
Empty file.
32 changes: 2 additions & 30 deletions artiq/devices/lda/lda_controller.py → artiq/devices/lda/driver.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
#!/usr/bin/env python3

import argparse
import logging
import ctypes
import struct

from artiq.management.pc_rpc import simple_server_loop


logger = logging.getLogger(__name__)
logger = logging.getLogger("lda")


class HidError(Exception):
@@ -163,27 +158,4 @@ def set_attenuation(self, attenuation):
:type attenuation: int, float or Fraction
"""
self.set(0x8d, bytes(chr(int(round(attenuation*4))), 'ascii'))

def main():
parser = argparse.ArgumentParser()
parser.add_argument('-d', '--device', default="LDA-102",
choices=["LDA-102", "LDA-602", "sim"])
parser.add_argument('--bind', default="::1",
help="hostname or IP address to bind to")
parser.add_argument('-p', '--port', default=8890, type=int,
help="TCP port to listen to")
parser.add_argument('-s', '--serial', default=None,
help="USB serial number of the device")
args = parser.parse_args()

if args.device == "sim":
lda = Ldasim()
else:
lda = Lda(args.serial, args.device)

simple_server_loop(lda, "lda",
args.bind, args.port)

if __name__ == "__main__":
main()
self.set(0x8d, bytes(chr(int(round(attenuation*4))), "ascii"))
42 changes: 1 addition & 41 deletions artiq/devices/pdq2/pdq2_controller.py → artiq/devices/pdq2/driver.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
#!/usr/bin/env python3

# Based on code by Robert Jordens <jordens@gmail.com>, 2012

import logging
import struct
import argparse
import asyncio

from scipy import interpolate
import numpy as np

from artiq.management.pc_rpc import simple_server_loop


logger = logging.getLogger("Pdq2")
logger = logging.getLogger("pdq2")

Ftdi = None

@@ -328,37 +322,3 @@ def multi_frame(self, times_voltages, channel, map=None, **kwargs):
board, dac = divmod(channel, self.num_dacs)
data = self._add_mem_header(board, dac, data)
self._write_data(data)


def _get_args():
parser = argparse.ArgumentParser(description="PDQ2 controller")
parser.add_argument("--bind", default="::1",
help="hostname or IP address to bind to")
parser.add_argument("-p", "--port", default=8889, type=int,
help="TCP port to listen to")
parser.add_argument(
"-s", "--serial", default=None,
help="device (FT245R) serial string [first]")
parser.add_argument(
"-d", "--debug", default=False, action="store_true",
help="debug communications")
return parser.parse_args()


def main():
args = _get_args()

if args.debug:
logging.basicConfig(level=logging.DEBUG)
else:
logging.basicConfig(level=logging.WARNING)

dev = Pdq2(serial=args.serial)
try:
simple_server_loop(dev, "pdq2", args.bind, args.port,
id_parameters="serial="+str(args.serial))
finally:
dev.close()

if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion doc/manual/drivers_reference.rst
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ Each driver is run in a separate "controller" that exposes a RPC interface (base
:mod:`artiq.devices.lda` module
---------------------------------

.. automodule:: artiq.devices.lda.lda_controller
.. automodule:: artiq.devices.lda.driver
:members:


6 changes: 3 additions & 3 deletions artiq/devices/lda/lda_client.py → frontend/lda_client.py
Original file line number Diff line number Diff line change
@@ -8,11 +8,11 @@
def main():
parser = argparse.ArgumentParser()
parser.add_argument('-s', '--server', default="::1",
help="The IP address or hostname of the controller")
help="hostname or IP of the controller to connect to")
parser.add_argument('-p', '--port', default=8890, type=int,
help="The TCP port the controller listens to")
help="TCP port to use to connect to the controller")
parser.add_argument('-a', '--attenuation', type=float,
help="The attenuation value you want to set")
help="attenuation value to set")
args = parser.parse_args()

remote = Client(args.server, args.port, "lda")
30 changes: 30 additions & 0 deletions frontend/lda_controller.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env python3

import argparse

from artiq.devices.lda.driver import Lda, Ldasim
from artiq.management.pc_rpc import simple_server_loop


def main():
parser = argparse.ArgumentParser()
parser.add_argument('-d', '--device', default="LDA-102",
choices=["LDA-102", "LDA-602", "sim"])
parser.add_argument('--bind', default="::1",
help="hostname or IP address to bind to")
parser.add_argument('-p', '--port', default=8890, type=int,
help="TCP port to listen to")
parser.add_argument('-s', '--serial', default=None,
help="USB serial number of the device")
args = parser.parse_args()

if args.device == "sim":
lda = Ldasim()
else:
lda = Lda(args.serial, args.device)

simple_server_loop(lda, "lda",
args.bind, args.port)

if __name__ == "__main__":
main()
File renamed without changes.
41 changes: 41 additions & 0 deletions frontend/pdq2_controller.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env python3

import argparse
import logging

from artiq.devices.pdq2.driver import Pdq2
from artiq.management.pc_rpc import simple_server_loop


def _get_args():
parser = argparse.ArgumentParser(description="PDQ2 controller")
parser.add_argument("--bind", default="::1",
help="hostname or IP address to bind to")
parser.add_argument("-p", "--port", default=8889, type=int,
help="TCP port to listen to")
parser.add_argument(
"-s", "--serial", default=None,
help="device (FT245R) serial string [first]")
parser.add_argument(
"-d", "--debug", default=False, action="store_true",
help="debug communications")
return parser.parse_args()


def main():
args = _get_args()

if args.debug:
logging.basicConfig(level=logging.DEBUG)
else:
logging.basicConfig(level=logging.WARNING)

dev = Pdq2(serial=args.serial)
try:
simple_server_loop(dev, "pdq2", args.bind, args.port,
id_parameters="serial="+str(args.serial))
finally:
dev.close()

if __name__ == "__main__":
main()

0 comments on commit d315268

Please sign in to comment.