mirror of
https://github.com/m-labs/artiq.git
synced 2024-12-25 03:08:27 +08:00
move controllers/clients to frontend
This commit is contained in:
parent
c3953d85d5
commit
d315268ddb
0
artiq/devices/lda/__init__.py
Normal file
0
artiq/devices/lda/__init__.py
Normal file
32
artiq/devices/lda/lda_controller.py → artiq/devices/lda/driver.py
Executable file → Normal file
32
artiq/devices/lda/lda_controller.py → artiq/devices/lda/driver.py
Executable file → Normal file
@ -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 @@ class Lda:
|
||||
: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
artiq/devices/pdq2/pdq2_controller.py → artiq/devices/pdq2/driver.py
Executable file → Normal file
42
artiq/devices/pdq2/pdq2_controller.py → artiq/devices/pdq2/driver.py
Executable file → Normal file
@ -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 @@ class Pdq2:
|
||||
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()
|
@ -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:
|
||||
|
||||
|
||||
|
@ -8,11 +8,11 @@ from artiq.management.pc_rpc import Client
|
||||
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
frontend/lda_controller.py
Executable file
30
frontend/lda_controller.py
Executable file
@ -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()
|
41
frontend/pdq2_controller.py
Executable file
41
frontend/pdq2_controller.py
Executable file
@ -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()
|
Loading…
Reference in New Issue
Block a user