From a73776bd7297cb8caf467be6ad28a3ec5c7b38f7 Mon Sep 17 00:00:00 2001 From: Yann Sionneau Date: Mon, 29 Jun 2015 19:21:32 +0200 Subject: [PATCH] controllers: enforce the usage of either --simulation or --device --- artiq/frontend/novatech409b_controller.py | 5 +++++ artiq/frontend/pdq2_controller.py | 6 ++++++ artiq/frontend/pxi6733_controller.py | 5 +++++ artiq/frontend/thorlabs_tcube_controller.py | 5 +++++ 4 files changed, 21 insertions(+) diff --git a/artiq/frontend/novatech409b_controller.py b/artiq/frontend/novatech409b_controller.py index 8eb6b280a..d3c5ddf75 100755 --- a/artiq/frontend/novatech409b_controller.py +++ b/artiq/frontend/novatech409b_controller.py @@ -31,6 +31,11 @@ def main(): args = get_argparser().parse_args() init_logger(args) + if not args.simulation and args.device is None: + raise ValueError("You need to specify either --simulation or " + "-d/--device argument. Use --help for more " + "information.") + dev = Novatech409B(args.device if not args.simulation else None) try: simple_server_loop( diff --git a/artiq/frontend/pdq2_controller.py b/artiq/frontend/pdq2_controller.py index 9a9885565..95b86caa5 100755 --- a/artiq/frontend/pdq2_controller.py +++ b/artiq/frontend/pdq2_controller.py @@ -27,6 +27,12 @@ def main(): args = get_argparser().parse_args() init_logger(args) port = None + + if not args.simulation and args.device is None: + raise ValueError("You need to specify either --simulation or " + "-d/--device argument. Use --help for more " + "information.") + if args.simulation: port = open(args.dump, "wb") dev = Pdq2(url=args.device, dev=port) diff --git a/artiq/frontend/pxi6733_controller.py b/artiq/frontend/pxi6733_controller.py index 1c4a5ce64..1307bede2 100755 --- a/artiq/frontend/pxi6733_controller.py +++ b/artiq/frontend/pxi6733_controller.py @@ -25,6 +25,11 @@ def main(): args = get_argparser().parse_args() init_logger(args) + if not args.simulation and args.channels is None: + raise ValueError("You need to specify either --simulation or " + "-C/--channels argument. Use --help for more " + "information.") + if args.simulation: daq = DAQmxSim() else: diff --git a/artiq/frontend/thorlabs_tcube_controller.py b/artiq/frontend/thorlabs_tcube_controller.py index c8766dd6c..fd879d0a5 100755 --- a/artiq/frontend/thorlabs_tcube_controller.py +++ b/artiq/frontend/thorlabs_tcube_controller.py @@ -26,6 +26,11 @@ def main(): args = get_argparser().parse_args() init_logger(args) + if not args.simulation and args.device is None: + raise ValueError("You need to specify either --simulation or " + "-d/--device argument. Use --help for more " + "information.") + if args.simulation: if args.product == "TDC001": dev = TdcSim()