2015-04-21 16:07:18 +08:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# Yann Sionneau <ys@m-labs.hk>, 2015
|
|
|
|
|
|
|
|
import argparse
|
2015-07-01 17:54:15 +08:00
|
|
|
import sys
|
2015-04-21 16:07:18 +08:00
|
|
|
|
|
|
|
from artiq.protocols.pc_rpc import simple_server_loop
|
|
|
|
from artiq.devices.pxi6733.driver import DAQmx, DAQmxSim
|
|
|
|
from artiq.tools import verbosity_args, init_logger, simple_network_args
|
|
|
|
|
|
|
|
|
|
|
|
def get_argparser():
|
|
|
|
parser = argparse.ArgumentParser(description="NI PXI 6733 controller")
|
|
|
|
simple_network_args(parser, 3256)
|
2015-06-06 02:12:41 +08:00
|
|
|
parser.add_argument("-C", "--channels", default=None,
|
2015-06-29 18:59:52 +08:00
|
|
|
help="List of channels (e.g. Dev1/ao0, Dev1/ao1:3).")
|
2015-04-21 16:07:18 +08:00
|
|
|
parser.add_argument("-c", "--clock", default="PFI5",
|
|
|
|
help="Input clock pin name (default: PFI5)")
|
2015-06-29 18:59:52 +08:00
|
|
|
parser.add_argument("--simulation", action='store_true',
|
2015-07-01 17:54:15 +08:00
|
|
|
help="Put the driver in simulation mode, even if "
|
|
|
|
"--channels is used.")
|
2015-04-21 16:07:18 +08:00
|
|
|
verbosity_args(parser)
|
|
|
|
return parser
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
args = get_argparser().parse_args()
|
|
|
|
init_logger(args)
|
|
|
|
|
2015-06-30 01:21:32 +08:00
|
|
|
if not args.simulation and args.channels is None:
|
2015-07-01 17:54:15 +08:00
|
|
|
print("You need to specify either --simulation or -C/--channels "
|
|
|
|
"argument. Use --help for more information.")
|
|
|
|
sys.exit(1)
|
2015-06-30 01:21:32 +08:00
|
|
|
|
2015-06-29 18:59:52 +08:00
|
|
|
if args.simulation:
|
2015-04-21 16:07:18 +08:00
|
|
|
daq = DAQmxSim()
|
|
|
|
else:
|
2015-06-06 02:12:41 +08:00
|
|
|
daq = DAQmx(args.channels,
|
|
|
|
args.clock)
|
2015-04-21 16:07:18 +08:00
|
|
|
|
|
|
|
try:
|
|
|
|
simple_server_loop({"pxi6733": daq},
|
|
|
|
args.bind, args.port)
|
|
|
|
finally:
|
|
|
|
daq.close()
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|