From b7120aa0acc84992fde1d4dc8a2ae4db15058d8e Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Tue, 25 Aug 2015 00:07:37 +0800 Subject: [PATCH] examples/arguments_demo: demonstrate parents --- examples/master/repository/arguments_demo.py | 42 ++++++++++++++++++-- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/examples/master/repository/arguments_demo.py b/examples/master/repository/arguments_demo.py index 97393df19..d956071b3 100644 --- a/examples/master/repository/arguments_demo.py +++ b/examples/master/repository/arguments_demo.py @@ -1,15 +1,49 @@ from artiq import * +class SubComponent1(HasEnvironment): + def build(self): + self.attr_argument("sc1_scan", Scannable(default=NoScan(325)), + "Flux capacitor") + self.attr_argument("sc1_enum", EnumerationValue(["1", "2", "3"]), + "Flux capacitor") + + def do(self): + print("SC1:") + for i in self.sc1_scan: + print(i) + print(self.sc1_enum) + + +class SubComponent2(HasEnvironment): + def build(self): + self.attr_argument("sc2_boolean", BooleanValue(False), + "Transporter") + self.attr_argument("sc2_scan", Scannable(default=NoScan(325)), + "Transporter") + self.attr_argument("sc2_enum", EnumerationValue(["3", "4", "5"]), + "Transporter") + + def do(self): + print("SC2:") + print(self.sc2_boolean) + for i in self.sc2_scan: + print(i) + print(self.sc2_enum) + + class ArgumentsDemo(EnvExperiment): def build(self): self.attr_argument("free_value", FreeValue(None)) - self.attr_argument("boolean", BooleanValue(True)) - self.attr_argument("enum", EnumerationValue( - ["foo", "bar", "quux"], "foo")) self.attr_argument("number", NumberValue(42, unit="s", step=0.1)) self.attr_argument("string", StringValue("Hello World")) self.attr_argument("scan", Scannable(global_max=400, default=NoScan(325))) + self.attr_argument("boolean", BooleanValue(True), "Group") + self.attr_argument("enum", EnumerationValue( + ["foo", "bar", "quux"], "foo"), "Group") + + self.sc1 = SubComponent1(parent=self) + self.sc2 = SubComponent2(parent=self) def run(self): print(self.free_value) @@ -19,3 +53,5 @@ class ArgumentsDemo(EnvExperiment): print(self.string) for i in self.scan: print(i) + self.sc1.do() + self.sc2.do()