mirror of https://github.com/m-labs/artiq.git
controllers: print+exit instead of raising exception for argparse error, better doc for --simulation
As long as you use --simulation, the driver will be in simulation mode. Even if you specify a --device or --channels. That can allow you to just switch to simulation mode by adding --simulation in the device database without having to remove the serial number or device path/name.
This commit is contained in:
parent
652f3359a2
commit
d7ef885d9e
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import logging
|
import logging
|
||||||
|
import sys
|
||||||
|
|
||||||
from artiq.devices.novatech409b.driver import Novatech409B
|
from artiq.devices.novatech409b.driver import Novatech409B
|
||||||
from artiq.protocols.pc_rpc import simple_server_loop
|
from artiq.protocols.pc_rpc import simple_server_loop
|
||||||
|
@ -22,7 +23,7 @@ def get_argparser():
|
||||||
help="serial port.")
|
help="serial port.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--simulation", action="store_true",
|
"--simulation", action="store_true",
|
||||||
help="Put the driver in simulation mode.")
|
help="Put the driver in simulation mode, even if --device is used.")
|
||||||
verbosity_args(parser)
|
verbosity_args(parser)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
@ -32,9 +33,9 @@ def main():
|
||||||
init_logger(args)
|
init_logger(args)
|
||||||
|
|
||||||
if not args.simulation and args.device is None:
|
if not args.simulation and args.device is None:
|
||||||
raise ValueError("You need to specify either --simulation or "
|
print("You need to specify either --simulation or -d/--device "
|
||||||
"-d/--device argument. Use --help for more "
|
"argument. Use --help for more information.")
|
||||||
"information.")
|
sys.exit(1)
|
||||||
|
|
||||||
dev = Novatech409B(args.device if not args.simulation else None)
|
dev = Novatech409B(args.device if not args.simulation else None)
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
import sys
|
||||||
|
|
||||||
from artiq.devices.pdq2.driver import Pdq2
|
from artiq.devices.pdq2.driver import Pdq2
|
||||||
from artiq.protocols.pc_rpc import simple_server_loop
|
from artiq.protocols.pc_rpc import simple_server_loop
|
||||||
|
@ -15,7 +16,7 @@ def get_argparser():
|
||||||
help="serial port.")
|
help="serial port.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--simulation", action="store_true",
|
"--simulation", action="store_true",
|
||||||
help="Put the driver in simulation mode.")
|
help="Put the driver in simulation mode, even if --device is used.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--dump", default="pdq2_dump.bin",
|
"--dump", default="pdq2_dump.bin",
|
||||||
help="file to dump pdq2 data into, for later simulation")
|
help="file to dump pdq2 data into, for later simulation")
|
||||||
|
@ -29,9 +30,9 @@ def main():
|
||||||
port = None
|
port = None
|
||||||
|
|
||||||
if not args.simulation and args.device is None:
|
if not args.simulation and args.device is None:
|
||||||
raise ValueError("You need to specify either --simulation or "
|
print("You need to specify either --simulation or -d/--device "
|
||||||
"-d/--device argument. Use --help for more "
|
"argument. Use --help for more information.")
|
||||||
"information.")
|
sys.exit(1)
|
||||||
|
|
||||||
if args.simulation:
|
if args.simulation:
|
||||||
port = open(args.dump, "wb")
|
port = open(args.dump, "wb")
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
# Yann Sionneau <ys@m-labs.hk>, 2015
|
# Yann Sionneau <ys@m-labs.hk>, 2015
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
import sys
|
||||||
|
|
||||||
from artiq.protocols.pc_rpc import simple_server_loop
|
from artiq.protocols.pc_rpc import simple_server_loop
|
||||||
from artiq.devices.pxi6733.driver import DAQmx, DAQmxSim
|
from artiq.devices.pxi6733.driver import DAQmx, DAQmxSim
|
||||||
|
@ -16,7 +17,8 @@ def get_argparser():
|
||||||
parser.add_argument("-c", "--clock", default="PFI5",
|
parser.add_argument("-c", "--clock", default="PFI5",
|
||||||
help="Input clock pin name (default: PFI5)")
|
help="Input clock pin name (default: PFI5)")
|
||||||
parser.add_argument("--simulation", action='store_true',
|
parser.add_argument("--simulation", action='store_true',
|
||||||
help="Put the driver in simulation mode.")
|
help="Put the driver in simulation mode, even if "
|
||||||
|
"--channels is used.")
|
||||||
verbosity_args(parser)
|
verbosity_args(parser)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
@ -26,9 +28,9 @@ def main():
|
||||||
init_logger(args)
|
init_logger(args)
|
||||||
|
|
||||||
if not args.simulation and args.channels is None:
|
if not args.simulation and args.channels is None:
|
||||||
raise ValueError("You need to specify either --simulation or "
|
print("You need to specify either --simulation or -C/--channels "
|
||||||
"-C/--channels argument. Use --help for more "
|
"argument. Use --help for more information.")
|
||||||
"information.")
|
sys.exit(1)
|
||||||
|
|
||||||
if args.simulation:
|
if args.simulation:
|
||||||
daq = DAQmxSim()
|
daq = DAQmxSim()
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
import sys
|
||||||
|
|
||||||
from artiq.devices.thorlabs_tcube.driver import Tdc, Tpz, TdcSim, TpzSim
|
from artiq.devices.thorlabs_tcube.driver import Tdc, Tpz, TdcSim, TpzSim
|
||||||
from artiq.protocols.pc_rpc import simple_server_loop
|
from artiq.protocols.pc_rpc import simple_server_loop
|
||||||
|
@ -16,7 +17,8 @@ def get_argparser():
|
||||||
help="serial device. See documentation for how to "
|
help="serial device. See documentation for how to "
|
||||||
"specify a USB Serial Number.")
|
"specify a USB Serial Number.")
|
||||||
parser.add_argument("--simulation", action="store_true",
|
parser.add_argument("--simulation", action="store_true",
|
||||||
help="Put the driver in simulation mode.")
|
help="Put the driver in simulation mode, even if "
|
||||||
|
"--device is used.")
|
||||||
simple_network_args(parser, 3255)
|
simple_network_args(parser, 3255)
|
||||||
verbosity_args(parser)
|
verbosity_args(parser)
|
||||||
return parser
|
return parser
|
||||||
|
@ -27,9 +29,9 @@ def main():
|
||||||
init_logger(args)
|
init_logger(args)
|
||||||
|
|
||||||
if not args.simulation and args.device is None:
|
if not args.simulation and args.device is None:
|
||||||
raise ValueError("You need to specify either --simulation or "
|
print("You need to specify either --simulation or -d/--device "
|
||||||
"-d/--device argument. Use --help for more "
|
"argument. Use --help for more information.")
|
||||||
"information.")
|
sys.exit(1)
|
||||||
|
|
||||||
if args.simulation:
|
if args.simulation:
|
||||||
if args.product == "TDC001":
|
if args.product == "TDC001":
|
||||||
|
|
Loading…
Reference in New Issue