2015-10-20 18:11:50 +08:00
|
|
|
import logging
|
|
|
|
|
2015-07-18 22:25:08 +08:00
|
|
|
from artiq import *
|
|
|
|
|
|
|
|
|
2015-08-25 00:07:37 +08:00
|
|
|
class SubComponent1(HasEnvironment):
|
|
|
|
def build(self):
|
2015-10-06 00:30:41 +08:00
|
|
|
self.setattr_argument("sc1_scan", Scannable(default=NoScan(3250),
|
2015-10-18 00:52:16 +08:00
|
|
|
scale=1e3, unit="kHz"),
|
2015-10-04 00:18:21 +08:00
|
|
|
"Flux capacitor")
|
|
|
|
self.setattr_argument("sc1_enum", EnumerationValue(["1", "2", "3"]),
|
|
|
|
"Flux capacitor")
|
2015-08-25 00:07:37 +08:00
|
|
|
|
|
|
|
def do(self):
|
|
|
|
print("SC1:")
|
|
|
|
for i in self.sc1_scan:
|
|
|
|
print(i)
|
|
|
|
print(self.sc1_enum)
|
|
|
|
|
|
|
|
|
|
|
|
class SubComponent2(HasEnvironment):
|
|
|
|
def build(self):
|
2015-10-04 00:18:21 +08:00
|
|
|
self.setattr_argument("sc2_boolean", BooleanValue(False),
|
|
|
|
"Transporter")
|
|
|
|
self.setattr_argument("sc2_scan", Scannable(default=NoScan(325)),
|
|
|
|
"Transporter")
|
|
|
|
self.setattr_argument("sc2_enum", EnumerationValue(["3", "4", "5"]),
|
|
|
|
"Transporter")
|
2015-08-25 00:07:37 +08:00
|
|
|
|
|
|
|
def do(self):
|
|
|
|
print("SC2:")
|
|
|
|
print(self.sc2_boolean)
|
|
|
|
for i in self.sc2_scan:
|
|
|
|
print(i)
|
|
|
|
print(self.sc2_enum)
|
|
|
|
|
|
|
|
|
2015-10-20 18:11:50 +08:00
|
|
|
class ArgumentsDemo(EnvExperiment):
|
2015-07-18 22:25:08 +08:00
|
|
|
def build(self):
|
2015-10-04 00:18:21 +08:00
|
|
|
self.setattr_argument("free_value", FreeValue(None))
|
2015-10-06 00:30:41 +08:00
|
|
|
self.setattr_argument("number", NumberValue(42e-6,
|
2015-10-18 00:52:16 +08:00
|
|
|
unit="us", scale=1e-6,
|
2015-10-04 00:18:21 +08:00
|
|
|
ndecimals=4))
|
|
|
|
self.setattr_argument("string", StringValue("Hello World"))
|
|
|
|
self.setattr_argument("scan", Scannable(global_max=400,
|
|
|
|
default=NoScan(325),
|
|
|
|
ndecimals=6))
|
|
|
|
self.setattr_argument("boolean", BooleanValue(True), "Group")
|
|
|
|
self.setattr_argument("enum", EnumerationValue(
|
2015-08-25 00:07:37 +08:00
|
|
|
["foo", "bar", "quux"], "foo"), "Group")
|
|
|
|
|
|
|
|
self.sc1 = SubComponent1(parent=self)
|
|
|
|
self.sc2 = SubComponent2(parent=self)
|
2015-07-18 22:25:08 +08:00
|
|
|
|
|
|
|
def run(self):
|
2015-10-20 18:11:50 +08:00
|
|
|
logging.error("logging test: error")
|
|
|
|
logging.warning("logging test: warning")
|
2015-11-24 23:04:01 +08:00
|
|
|
logging.warning("logging test:" + " this is a very long message."*15)
|
2015-10-20 18:11:50 +08:00
|
|
|
logging.info("logging test: info")
|
|
|
|
logging.debug("logging test: debug")
|
2015-10-14 16:31:07 +08:00
|
|
|
|
2015-07-18 22:25:08 +08:00
|
|
|
print(self.free_value)
|
|
|
|
print(self.boolean)
|
|
|
|
print(self.enum)
|
|
|
|
print(self.number)
|
|
|
|
print(self.string)
|
2015-07-21 23:23:32 +08:00
|
|
|
for i in self.scan:
|
|
|
|
print(i)
|
2015-08-25 00:07:37 +08:00
|
|
|
self.sc1.do()
|
|
|
|
self.sc2.do()
|