forked from M-Labs/artiq
1
0
Fork 0

examples/tdr: cleanup

This commit is contained in:
Robert Jördens 2015-07-28 23:30:26 -06:00
parent 278570faf6
commit ebbbdcf194
1 changed files with 4 additions and 8 deletions

View File

@ -49,27 +49,23 @@ class TDR(EnvExperiment):
print("rising: {:5g} ns, falling {:5g} ns".format( print("rising: {:5g} ns, falling {:5g} ns".format(
t_rise/1e-9, t_fall/1e-9)) t_rise/1e-9, t_fall/1e-9))
def rep(self, t):
self.t = t
@kernel @kernel
def many(self, n, p): def many(self, n, p):
t = [0 for i in range(2)] t = [0 for i in range(2)]
self.core.break_realtime() self.core.break_realtime()
for i in range(n): for i in range(n):
self.one(t, p) self.one(t, p)
self.rep(t) self.t = t
@kernel @kernel
def one(self, t, p): def one(self, t, p):
t0 = now_mu()
with parallel: with parallel:
self.pmt0.gate_both_mu(2*p) self.pmt0.gate_both_mu(2*p)
with sequential: self.ttl2.pulse_mu(p)
t0 = now_mu()
self.ttl2.pulse_mu(p)
for i in range(len(t)): for i in range(len(t)):
ti = self.pmt0.timestamp_mu() ti = self.pmt0.timestamp_mu()
if ti <= 0: if ti <= 0:
raise PulseNotReceivedError raise PulseNotReceivedError
t[i] += ti - t0 t[i] += ti - t0
self.pmt0.count() self.pmt0.count() # flush