forked from M-Labs/artiq
1
0
Fork 0

dds: use context manager for batches

This commit is contained in:
Sebastien Bourdeauducq 2015-05-09 14:47:40 +08:00
parent fdc406f062
commit 1ceb06fb16
3 changed files with 23 additions and 8 deletions

View File

@ -10,6 +10,19 @@ PHASE_MODE_ABSOLUTE = 1
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):
"""Core device Direct Digital Synthesis (DDS) bus batching driver.
@ -17,6 +30,9 @@ class DDSBus(AutoDB):
class DBKeys:
core = Device()
def build(self):
self.batch = _BatchContextManager(self)
@kernel
def batch_enter(self):
"""Starts a DDS command batch. All DDS commands are buffered

View File

@ -17,10 +17,10 @@ class DDSTest(Experiment, AutoDB):
@kernel
def run(self):
self.dds_bus.batch_enter()
self.dds1.set(120*MHz)
self.dds2.set(200*MHz)
self.dds_bus.batch_exit()
with self.dds_bus.batch:
self.dds1.set(120*MHz)
self.dds2.set(200*MHz)
delay(1*us)
for i in range(10000):
if i & 0x200:

View File

@ -27,10 +27,9 @@ class PhotonHistogram(Experiment, AutoDB):
@kernel
def program_cooling(self):
self.dds_bus.batch_enter()
self.bd_dds.set(200*MHz)
self.bdd_dds.set(300*MHz)
self.dds_bus.batch_exit()
with self.dds_bus.batch:
self.bd_dds.set(200*MHz)
self.bdd_dds.set(300*MHz)
@kernel
def cool_detect(self):