From 078a37bf1f01bbe297f984d1243056e9f5ddc6c3 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sun, 4 Oct 2015 18:30:29 +0800 Subject: [PATCH] examples: add basic DDS frequency setter with dynamic DDB scan --- examples/master/repository/dds_setter.py | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 examples/master/repository/dds_setter.py diff --git a/examples/master/repository/dds_setter.py b/examples/master/repository/dds_setter.py new file mode 100644 index 000000000..ebcd72bc1 --- /dev/null +++ b/examples/master/repository/dds_setter.py @@ -0,0 +1,25 @@ +from operator import itemgetter + +from artiq import * + + +class DDSSetter(EnvExperiment): + """DDS Setter""" + def build(self): + self.dds = dict() + + ddb = self.get_ddb() + for k, v in sorted(ddb.items(), key=itemgetter(0)): + if (isinstance(v, dict) + and v["type"] == "local" + and v["module"] == "artiq.coredevice.dds" + and v["class"] in {"AD9858", "AD9914"}): + self.dds[k] = { + "driver": self.get_device(k), + "frequency": self.get_argument("{}_frequency".format(k), + NumberValue()) + } + + def run(self): + for k, v in self.dds.items(): + v["driver"].set(v["frequency"])