forked from M-Labs/artiq
1
0
Fork 0
artiq/examples/time_test.py

50 lines
1.3 KiB
Python
Raw Normal View History

from artiq.language.units import *
from artiq.language.core import *
from artiq.devices import corecom_serial, core
2014-09-05 12:03:22 +08:00
2014-08-13 18:30:57 +08:00
class DummyPulse(AutoContext):
2014-09-05 12:03:22 +08:00
parameters = "name"
def print_on(self, t, f):
print("{} ON:{:4} @{}".format(self.name, f, t))
2014-09-05 12:03:22 +08:00
def print_off(self, t):
print("{} OFF @{}".format(self.name, t))
2014-09-05 12:03:22 +08:00
@kernel
def pulse(self, f, duration):
self.print_on(int(now()), f)
delay(duration)
self.print_off(int(now()))
2014-08-13 18:30:57 +08:00
class TimeTest(AutoContext):
2014-09-05 12:03:22 +08:00
parameters = "a b c d"
@kernel
def run(self):
i = 0
while i < 3:
with parallel:
with sequential:
self.a.pulse(100+i, 20*us)
self.b.pulse(200+i, 20*us)
with sequential:
self.c.pulse(300+i, 10*us)
self.d.pulse(400+i, 20*us)
i += 1
if __name__ == "__main__":
2014-09-05 12:03:22 +08:00
with corecom_serial.CoreCom() as com:
coredev = core.Core(com)
exp = TimeTest(
core=coredev,
a=DummyPulse(core=coredev, name="a"),
b=DummyPulse(core=coredev, name="b"),
c=DummyPulse(core=coredev, name="c"),
d=DummyPulse(core=coredev, name="d"),
)
exp.run()