nac3/nac3artiq/demo/demo.py

46 lines
835 B
Python
Raw Normal View History

2024-07-12 09:58:33 +08:00
from numpy import int64
from min_artiq import *
2024-07-12 09:58:33 +08:00
@nac3
class A:
pass
@nac3
class B(A):
pass
@nac3
class C(B):
pass
@kernel
def test():
pass
@nac3
class Demo:
2024-07-12 09:58:33 +08:00
core: Kernel[Core]
led0: Kernel[TTLOut]
optt: Kernel[float]
t_mu: Kernel[int64]
2021-09-25 14:17:11 +08:00
def __init__(self):
self.core = Core()
2021-11-05 18:07:18 +08:00
self.led0 = TTLOut(self.core, 18)
2024-07-12 09:58:33 +08:00
self.optt = 0.0
self.t_mu = int64(0)
@kernel
def set_time_kernel(self, t: float):
self.optt = t
self.t_mu = self.core.seconds_to_mu(self.optt)
2020-12-18 23:44:45 +08:00
@kernel
def run(self):
2024-07-12 09:58:33 +08:00
for t in [20.*us, 15.*us, 10.*us, 5.*us, 2.*us, 1.*us]:
self.set_time_kernel(t)
self.core.reset()
for _ in range(10000):
self.led0.pulse(self.optt)
2020-12-18 23:44:45 +08:00
if __name__ == "__main__":
2024-07-12 09:58:33 +08:00
Demo().run()