forked from M-Labs/artiq
lda: minor fixes and refactoring
This commit is contained in:
parent
744e7841c6
commit
57e25c7af1
@ -1,21 +1,15 @@
|
||||
#!/usr/bin/env python3
|
||||
from artiq.management.pc_rpc import Client
|
||||
import argparse
|
||||
|
||||
from artiq.management.pc_rpc import Client
|
||||
|
||||
def get(remote):
|
||||
return remote.get_attenuation()
|
||||
|
||||
|
||||
def set(remote, attenuation):
|
||||
remote.set_attenuation(attenuation)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-s', '--server', default="::1",
|
||||
help="The IP address or hostname of the controller")
|
||||
parser.add_argument('-p', '--port', default=7777, type=int,
|
||||
parser.add_argument('-p', '--port', default=8890, type=int,
|
||||
help="The TCP port the controller listens to")
|
||||
parser.add_argument('-a', '--attenuation', type=float,
|
||||
help="The attenuation value you want to set")
|
||||
@ -25,9 +19,8 @@ if __name__ == "__main__":
|
||||
|
||||
try:
|
||||
if args.attenuation is None:
|
||||
print("Current attenuation: {}".format(get(remote)))
|
||||
print("Current attenuation: {}".format(remote.get_attenuation()))
|
||||
else:
|
||||
set(remote, args.attenuation)
|
||||
except Exception as e:
|
||||
print("exception: {}".format(e))
|
||||
remote.set_attenuation(args.attenuation)
|
||||
finally:
|
||||
remote.close_rpc()
|
@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
import os
|
||||
import logging
|
||||
import atexit
|
||||
@ -6,6 +7,9 @@ import ctypes
|
||||
import ctypes.util
|
||||
import struct
|
||||
|
||||
from artiq.management.pc_rpc import simple_server_loop
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if "." not in os.environ["PATH"].split(";"):
|
||||
@ -141,12 +145,18 @@ class Lda:
|
||||
print("[LDA-sim] setting attenuation to {}".format(attenuation))
|
||||
self._attenuation = attenuation
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
logger.info(list(Lda.enumerate("LDA-102")))
|
||||
l = Lda()
|
||||
logger.info(l.get_attenuation())
|
||||
l.set_attenuation(50)
|
||||
logger.info(l.get_attenuation())
|
||||
l.set_attenuation(60)
|
||||
logger.info(l.get_attenuation())
|
||||
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()
|
||||
|
||||
simple_server_loop(Lda(args.serial, args.device), "lda",
|
||||
args.bind, args.port)
|
@ -1,19 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
from artiq.management.pc_rpc import simple_server_loop
|
||||
from lda import Lda
|
||||
import argparse
|
||||
|
||||
if __name__ == "__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=7777, 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()
|
||||
|
||||
simple_server_loop(Lda(args.serial, args.device), "lda",
|
||||
args.bind, args.port)
|
Loading…
Reference in New Issue
Block a user