Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/artiq
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 494c670cd2fc
Choose a base ref
...
head repository: m-labs/artiq
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1b7f71bda9f2
Choose a head ref
  • 2 commits
  • 9 files changed
  • 1 contributor

Commits on Mar 21, 2015

  1. Copy the full SHA
    7e61f66 View commit details
  2. Copy the full SHA
    1b7f71b View commit details
6 changes: 2 additions & 4 deletions artiq/devices/lda/driver.py
Original file line number Diff line number Diff line change
@@ -13,8 +13,7 @@ class HidError(Exception):


class Ldasim:
"""Lab Brick Digital Attenuator simulation driver.
"""
"""Lab Brick Digital Attenuator simulation driver."""

def __init__(self):
self._attenuation = None
@@ -117,8 +116,7 @@ def __init__(self, serial=None, product="LDA-102"):
raise IOError

def close(self):
"""Close the device.
"""
"""Close the device."""
self.hidapi.hid_close(self._dev)

def get_att_step_size(self):
4 changes: 2 additions & 2 deletions artiq/devices/novatech409b/driver.py
Original file line number Diff line number Diff line change
@@ -22,8 +22,8 @@ class Novatech409B:
# maximum frequency of Novatech 409B when using PLL and external reference
max_freq_with_pll = 171.1276031

def __init__(self, serial_dev="/dev/ttyUSB0"):
if serial_dev == "sim":
def __init__(self, serial_dev):
if serial_dev is None:
self.simulation = True
else:
self.simulation = False
15 changes: 10 additions & 5 deletions artiq/devices/pdq2/mediator.py
Original file line number Diff line number Diff line change
@@ -114,15 +114,20 @@ def _invalidate(self):
class CompoundPDQ2(AutoDB):
class DBKeys:
core = Device()
ids = Argument()
pdq2_devices = Argument()
rtio_trigger = Argument()
rtio_frame = Argument()

def build(self):
self.trigger = rtio.LLRTIOOut(core=self.core, channel=self.rtio_trigger)
self.frame0 = rtio.LLRTIOOut(core=self.core, channel=self.rtio_frame[0])
self.frame1 = rtio.LLRTIOOut(core=self.core, channel=self.rtio_frame[1])
self.frame2 = rtio.LLRTIOOut(core=self.core, channel=self.rtio_frame[2])
self.pdq2s = [self.dbh.get_device(d) for d in self.pdq2_devices]
self.trigger = rtio.LLRTIOOut(
core=self.core, channel=self.rtio_trigger)
self.frame0 = rtio.LLRTIOOut(
core=self.core, channel=self.rtio_frame[0])
self.frame1 = rtio.LLRTIOOut(
core=self.core, channel=self.rtio_frame[1])
self.frame2 = rtio.LLRTIOOut(
core=self.core, channel=self.rtio_frame[2])

self.frames = []
self.current_frame = -1
13 changes: 7 additions & 6 deletions artiq/frontend/lda_controller.py
Original file line number Diff line number Diff line change
@@ -10,22 +10,23 @@
def get_argparser():
parser = argparse.ArgumentParser(
description="ARTIQ controller for the Lab Brick Digital Attenuator")
parser.add_argument("-d", "--device", default="LDA-102",
choices=["LDA-102", "LDA-602", "sim"])
parser.add_argument("-P", "--product", default="LDA-102",
choices=["LDA-102", "LDA-602"])
simple_network_args(parser, 3253)
parser.add_argument("-s", "--serial", default=None,
help="USB serial number of the device")
parser.add_argument("-d", "--device", default=None,
help="USB serial number of the device."
" Omit for simulation mode.")
verbosity_args(parser)
return parser


def main():
args = get_argparser().parse_args()
init_logger(args)
if args.device == "sim":
if args.device is None:
lda = Ldasim()
else:
lda = Lda(args.serial, args.device)
lda = Lda(args.serial, args.product)
simple_server_loop({"lda": lda},
args.bind, args.port)

9 changes: 3 additions & 6 deletions artiq/frontend/novatech409b_controller.py
Original file line number Diff line number Diff line change
@@ -20,19 +20,16 @@ def get_argparser():
" 409B 4-channel DDS box")
simple_network_args(parser, 3254)
parser.add_argument(
"-s", "--serial-dev",
default="/dev/ttyUSB0", type=str,
help="serial port: on Windows \"COMx\","
" on Linux a device path (e.g. \"/dev/ttyUSB0\")."
" Use \"sim\" for simulation mode.")
"-d", "--device", default=None,
help="serial port. Omit for simulation mode.")
verbosity_args(parser)
return parser

def main():
args = get_argparser().parse_args()
init_logger(args)

dev = Novatech409B(args.serial_dev)
dev = Novatech409B(args.device)
try:
simple_server_loop(
{"novatech409b": dev}, args.bind, args.port)
7 changes: 4 additions & 3 deletions artiq/frontend/pdq2_controller.py
Original file line number Diff line number Diff line change
@@ -11,9 +11,10 @@ def get_argparser():
parser = argparse.ArgumentParser(description="PDQ2 controller")
simple_network_args(parser, 3252)
parser.add_argument(
"-d", "--device", required=True, help="device url/path/name")
"-d", "--device", default=None,
help="serial port. Omit for simulation mode.")
parser.add_argument(
"-u", "--dump", default=None,
"--dump", default="pdq2_dump.bin",
help="file to dump pdq2 data into, for later simulation")
verbosity_args(parser)
return parser
@@ -23,7 +24,7 @@ def main():
args = get_argparser().parse_args()
init_logger(args)
port = None
if args.dump:
if args.device is None:
port = open(args.dump, "wb")
dev = Pdq2(url=args.device, dev=port)
try:
32 changes: 14 additions & 18 deletions artiq/frontend/thorlabs_tcube_controller.py
Original file line number Diff line number Diff line change
@@ -9,16 +9,15 @@

def get_argparser():
parser = argparse.ArgumentParser()
parser.add_argument("-d", "--device", required=True,
parser.add_argument("-P", "--product", required=True,
help="type of the Thorlabs T-Cube device to control",
choices=["TDC001", "TPZ001", "TDCSim", "TPZSim"])
choices=["TDC001", "TPZ001"])
parser.add_argument("--bind", default="::1",
help="hostname or IP address to bind to")
parser.add_argument("-p", "--port", default=3255, type=int,
help="TCP port to listen to")
parser.add_argument("-s", "--serial", default="/dev/ttyUSB0",
help="serial port: on Windows \"COMx\", on Linux a "
"device path (e.g. \"/dev/ttyUSB0\").")
parser.add_argument("-d", "--device", default=None,
help="serial port. Omit for simulation mode.")
verbosity_args(parser)
return parser

@@ -27,21 +26,18 @@ def main():
args = get_argparser().parse_args()
init_logger(args)

devname = args.device.lower()

if devname == "tdc001":
dev = Tdc(args.serial)
elif devname == "tpz001":
dev = Tpz(args.serial)
elif devname == "tdcsim":
dev = TdcSim()
elif devname == "tpzsim":
dev = TpzSim()
if args.device is None:
if args.product == "TDC001":
dev = TdcSim()
elif args.product == "TPZ001":
dev = TpzSim()
else:
raise ValueError("Device can be either TDC001, TPZ001, TDCSim"
" or TPZSim")
if args.product == "TDC001":
dev = Tdc(args.device)
elif args.product == "TPZ001":
dev = Tpz(args.device)

simple_server_loop({devname: dev}, args.bind, args.port)
simple_server_loop({args.product.lower(): dev}, args.bind, args.port)

if __name__ == "__main__":
main()
4 changes: 2 additions & 2 deletions doc/manual/developing_a_ndsp.rst
Original file line number Diff line number Diff line change
@@ -175,9 +175,9 @@ General guidelines
* Do not use ``__del__`` to implement the cleanup code of your driver. Instead, define a ``close`` method, and call it using a ``try...finally...`` block in the controller.
* Format your source code according to PEP8. We suggest using ``flake8`` to check for compliance.
* 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) to attach to must be passed as a command-line parameter to the controller. We suggest using ``-s`` and ``--serial`` as parameter name.
* 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 by using "sim" in place of the serial number or device name.
* We suggest that the simulation mode is entered whenever the ``-d/--device`` option is omitted.
* 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.
36 changes: 34 additions & 2 deletions examples/master/ddb.pyon
Original file line number Diff line number Diff line change
@@ -70,12 +70,44 @@
"arguments": {"reg_channel": 2, "rtio_switch": 7}
},

"qc_q1_0": {
"type": "controller",
"best_effort": false,
"host": "::1",
"port": 4000,
"target_name": "pdq2",
"command": "pdq2_controller -p {port} --bind {bind} --dump qc_q1_0.bin"
},
"qc_q1_1": {
"type": "controller",
"best_effort": false,
"host": "::1",
"port": 4001,
"target_name": "pdq2",
"command": "pdq2_controller -p {port} --bind {bind} --dump qc_q1_1.bin"
},
"qc_q1_2": {
"type": "controller",
"best_effort": false,
"host": "::1",
"port": 4002,
"target_name": "pdq2",
"command": "pdq2_controller -p {port} --bind {bind} --dump qc_q1_2.bin"
},
"qc_q1_3": {
"type": "controller",
"best_effort": false,
"host": "::1",
"port": 4003,
"target_name": "pdq2",
"command": "pdq2_controller -p {port} --bind {bind} --dump qc_q1_3.bin"
},
"electrodes": {
"type": "local",
"module": "artiq.devices.pdq2",
"class": "CompoundPDQ2",
"arguments": {
"ids": ["qc_q1_0", "qc_q1_1", "qc_q1_2", "qc_q1_3"],
"pdq2_devices": ["qc_q1_0", "qc_q1_1", "qc_q1_2", "qc_q1_3"],
"rtio_trigger": 7,
"rtio_frame": (2, 3, 4)
},
@@ -88,7 +120,7 @@
"host": "::1",
"port": 3253,
"target_name": "lda",
"command": "lda_controller -p {port} --bind {bind} -d sim"
"command": "lda_controller -p {port} --bind {bind}"
},

"pmt": "pmt0",