forked from M-Labs/artiq
dds: use context manager for batches
This commit is contained in:
parent
fdc406f062
commit
1ceb06fb16
|
@ -10,6 +10,19 @@ PHASE_MODE_ABSOLUTE = 1
|
||||||
PHASE_MODE_TRACKING = 2
|
PHASE_MODE_TRACKING = 2
|
||||||
|
|
||||||
|
|
||||||
|
class _BatchContextManager:
|
||||||
|
def __init__(self, dds_bus):
|
||||||
|
self.dds_bus = dds_bus
|
||||||
|
|
||||||
|
@kernel
|
||||||
|
def __enter__(self):
|
||||||
|
self.dds_bus.batch_enter()
|
||||||
|
|
||||||
|
@kernel
|
||||||
|
def __exit__(self, type, value, traceback):
|
||||||
|
self.dds_bus.batch_exit()
|
||||||
|
|
||||||
|
|
||||||
class DDSBus(AutoDB):
|
class DDSBus(AutoDB):
|
||||||
"""Core device Direct Digital Synthesis (DDS) bus batching driver.
|
"""Core device Direct Digital Synthesis (DDS) bus batching driver.
|
||||||
|
|
||||||
|
@ -17,6 +30,9 @@ class DDSBus(AutoDB):
|
||||||
class DBKeys:
|
class DBKeys:
|
||||||
core = Device()
|
core = Device()
|
||||||
|
|
||||||
|
def build(self):
|
||||||
|
self.batch = _BatchContextManager(self)
|
||||||
|
|
||||||
@kernel
|
@kernel
|
||||||
def batch_enter(self):
|
def batch_enter(self):
|
||||||
"""Starts a DDS command batch. All DDS commands are buffered
|
"""Starts a DDS command batch. All DDS commands are buffered
|
||||||
|
|
|
@ -17,10 +17,10 @@ class DDSTest(Experiment, AutoDB):
|
||||||
|
|
||||||
@kernel
|
@kernel
|
||||||
def run(self):
|
def run(self):
|
||||||
self.dds_bus.batch_enter()
|
with self.dds_bus.batch:
|
||||||
self.dds1.set(120*MHz)
|
self.dds1.set(120*MHz)
|
||||||
self.dds2.set(200*MHz)
|
self.dds2.set(200*MHz)
|
||||||
self.dds_bus.batch_exit()
|
delay(1*us)
|
||||||
|
|
||||||
for i in range(10000):
|
for i in range(10000):
|
||||||
if i & 0x200:
|
if i & 0x200:
|
||||||
|
|
|
@ -27,10 +27,9 @@ class PhotonHistogram(Experiment, AutoDB):
|
||||||
|
|
||||||
@kernel
|
@kernel
|
||||||
def program_cooling(self):
|
def program_cooling(self):
|
||||||
self.dds_bus.batch_enter()
|
with self.dds_bus.batch:
|
||||||
self.bd_dds.set(200*MHz)
|
self.bd_dds.set(200*MHz)
|
||||||
self.bdd_dds.set(300*MHz)
|
self.bdd_dds.set(300*MHz)
|
||||||
self.dds_bus.batch_exit()
|
|
||||||
|
|
||||||
@kernel
|
@kernel
|
||||||
def cool_detect(self):
|
def cool_detect(self):
|
||||||
|
|
Loading…
Reference in New Issue