forked from M-Labs/artiq
1
0
Fork 0

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:
Yann Sionneau 2015-07-01 11:54:15 +02:00
parent 652f3359a2
commit d7ef885d9e
4 changed files with 22 additions and 16 deletions

View File

@ -4,6 +4,7 @@
import argparse
import logging
import sys
from artiq.devices.novatech409b.driver import Novatech409B
from artiq.protocols.pc_rpc import simple_server_loop
@ -22,7 +23,7 @@ def get_argparser():
help="serial port.")
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.")
verbosity_args(parser)
return parser
@ -32,9 +33,9 @@ def main():
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.")
print("You need to specify either --simulation or -d/--device "
"argument. Use --help for more information.")
sys.exit(1)
dev = Novatech409B(args.device if not args.simulation else None)
try:

View File

@ -1,6 +1,7 @@
#!/usr/bin/env python3
import argparse
import sys
from artiq.devices.pdq2.driver import Pdq2
from artiq.protocols.pc_rpc import simple_server_loop
@ -15,7 +16,7 @@ def get_argparser():
help="serial port.")
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.")
parser.add_argument(
"--dump", default="pdq2_dump.bin",
help="file to dump pdq2 data into, for later simulation")
@ -29,9 +30,9 @@ def main():
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.")
print("You need to specify either --simulation or -d/--device "
"argument. Use --help for more information.")
sys.exit(1)
if args.simulation:
port = open(args.dump, "wb")

View File

@ -2,6 +2,7 @@
# Yann Sionneau <ys@m-labs.hk>, 2015
import argparse
import sys
from artiq.protocols.pc_rpc import simple_server_loop
from artiq.devices.pxi6733.driver import DAQmx, DAQmxSim
@ -16,7 +17,8 @@ def get_argparser():
parser.add_argument("-c", "--clock", default="PFI5",
help="Input clock pin name (default: PFI5)")
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)
return parser
@ -26,9 +28,9 @@ def main():
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.")
print("You need to specify either --simulation or -C/--channels "
"argument. Use --help for more information.")
sys.exit(1)
if args.simulation:
daq = DAQmxSim()

View File

@ -1,6 +1,7 @@
#!/usr/bin/env python3
import argparse
import sys
from artiq.devices.thorlabs_tcube.driver import Tdc, Tpz, TdcSim, TpzSim
from artiq.protocols.pc_rpc import simple_server_loop
@ -16,7 +17,8 @@ def get_argparser():
help="serial device. See documentation for how to "
"specify a USB Serial Number.")
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)
verbosity_args(parser)
return parser
@ -27,9 +29,9 @@ def main():
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.")
print("You need to specify either --simulation or -d/--device "
"argument. Use --help for more information.")
sys.exit(1)
if args.simulation:
if args.product == "TDC001":