forked from M-Labs/artiq
controllers: use --simulation for simulation
This commit is contained in:
parent
d39382eca0
commit
515aa96819
@ -19,8 +19,9 @@ def get_argparser():
|
||||
"The serial number is written on a sticker under "
|
||||
"the device, you should write for example "
|
||||
"-d \"SN:03461\". You must prepend enough 0 for it "
|
||||
"to be 5 digits."
|
||||
" Omit for simulation mode.")
|
||||
"to be 5 digits.")
|
||||
parser.add_argument("--simulation", action="store_true",
|
||||
help="Put the driver in simulation mode.")
|
||||
verbosity_args(parser)
|
||||
return parser
|
||||
|
||||
@ -28,7 +29,7 @@ def get_argparser():
|
||||
def main():
|
||||
args = get_argparser().parse_args()
|
||||
init_logger(args)
|
||||
if args.device is None:
|
||||
if args.simulation:
|
||||
lda = Ldasim()
|
||||
else:
|
||||
lda = Lda(args.device, args.product)
|
||||
|
@ -19,7 +19,10 @@ def get_argparser():
|
||||
simple_network_args(parser, 3254)
|
||||
parser.add_argument(
|
||||
"-d", "--device", default=None,
|
||||
help="serial port. Omit for simulation mode.")
|
||||
help="serial port.")
|
||||
parser.add_argument(
|
||||
"--simulation", action="store_true",
|
||||
help="Put the driver in simulation mode.")
|
||||
verbosity_args(parser)
|
||||
return parser
|
||||
|
||||
@ -28,7 +31,7 @@ def main():
|
||||
args = get_argparser().parse_args()
|
||||
init_logger(args)
|
||||
|
||||
dev = Novatech409B(args.device)
|
||||
dev = Novatech409B(args.device if not args.simulation else None)
|
||||
try:
|
||||
simple_server_loop(
|
||||
{"novatech409b": dev}, args.bind, args.port)
|
||||
|
@ -12,7 +12,10 @@ def get_argparser():
|
||||
simple_network_args(parser, 3252)
|
||||
parser.add_argument(
|
||||
"-d", "--device", default=None,
|
||||
help="serial port. Omit for simulation mode.")
|
||||
help="serial port.")
|
||||
parser.add_argument(
|
||||
"--simulation", action="store_true",
|
||||
help="Put the driver in simulation mode.")
|
||||
parser.add_argument(
|
||||
"--dump", default="pdq2_dump.bin",
|
||||
help="file to dump pdq2 data into, for later simulation")
|
||||
@ -24,7 +27,7 @@ def main():
|
||||
args = get_argparser().parse_args()
|
||||
init_logger(args)
|
||||
port = None
|
||||
if args.device is None:
|
||||
if args.simulation:
|
||||
port = open(args.dump, "wb")
|
||||
dev = Pdq2(url=args.device, dev=port)
|
||||
try:
|
||||
|
@ -12,10 +12,11 @@ def get_argparser():
|
||||
parser = argparse.ArgumentParser(description="NI PXI 6733 controller")
|
||||
simple_network_args(parser, 3256)
|
||||
parser.add_argument("-C", "--channels", default=None,
|
||||
help="List of channels (e.g. Dev1/ao0, Dev1/ao1:3)."
|
||||
" Omit for simulation mode.")
|
||||
help="List of channels (e.g. Dev1/ao0, Dev1/ao1:3).")
|
||||
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.")
|
||||
verbosity_args(parser)
|
||||
return parser
|
||||
|
||||
@ -24,7 +25,7 @@ def main():
|
||||
args = get_argparser().parse_args()
|
||||
init_logger(args)
|
||||
|
||||
if args.channels is None:
|
||||
if args.simulation:
|
||||
daq = DAQmxSim()
|
||||
else:
|
||||
daq = DAQmx(args.channels,
|
||||
|
@ -14,8 +14,9 @@ def get_argparser():
|
||||
choices=["TDC001", "TPZ001"])
|
||||
parser.add_argument("-d", "--device", default=None,
|
||||
help="serial device. See documentation for how to "
|
||||
"specify a USB Serial Number. Omit for simulation "
|
||||
"mode.")
|
||||
"specify a USB Serial Number.")
|
||||
parser.add_argument("--simulation", action="store_true",
|
||||
help="Put the driver in simulation mode.")
|
||||
simple_network_args(parser, 3255)
|
||||
verbosity_args(parser)
|
||||
return parser
|
||||
@ -25,7 +26,7 @@ def main():
|
||||
args = get_argparser().parse_args()
|
||||
init_logger(args)
|
||||
|
||||
if args.device is None:
|
||||
if args.simulation:
|
||||
if args.product == "TDC001":
|
||||
dev = TdcSim()
|
||||
elif args.product == "TPZ001":
|
||||
|
@ -177,7 +177,7 @@ General guidelines
|
||||
* Use new-style formatting (``str.format``) except for logging where it is not well supported, and double quotes for strings.
|
||||
* The device identification (e.g. serial number, or entry in ``/dev``) to attach to must be passed as a command-line parameter to the controller. We suggest using ``-d`` and ``--device`` as parameter name.
|
||||
* Controllers must be able to operate in "simulation" mode, where they behave properly even if the associated hardware is not connected. For example, they can print the data to the console instead of sending it to the device, or dump it into a file.
|
||||
* We suggest that the simulation mode is entered whenever the ``-d/--device`` option is omitted.
|
||||
* The simulation mode is entered whenever the ``--simulation`` option is specified.
|
||||
* Keep command line parameters consistent across clients/controllers. When adding new command line options, look for a client/controller that does a similar thing and follow its use of ``argparse``. If the original client/controller could use ``argparse`` in a better way, improve it.
|
||||
* Use docstrings for all public methods of the driver (note that those will be retrieved by ``artiq_rpctool``).
|
||||
* Choose a free default TCP port and add it to the default port list in this manual.
|
||||
|
Loading…
Reference in New Issue
Block a user