forked from M-Labs/artiq
1
0
Fork 0

language/environment: update kernel_invariants in setattr_argument and setattr_device

This commit is contained in:
Sebastien Bourdeauducq 2016-05-03 16:27:24 +08:00
parent 9e14419abc
commit adeb88619c
3 changed files with 17 additions and 6 deletions

View File

@ -3,6 +3,13 @@
Release notes
=============
1.0rc4 (unreleased)
-------------------
* setattr_argument and setattr_device add their key to kernel_invariants.
1.0rc3
------

View File

@ -227,8 +227,12 @@ class HasEnvironment:
def setattr_argument(self, key, processor=None, group=None):
"""Sets an argument as attribute. The names of the argument and of the
attribute are the same."""
attribute are the same.
The key is added to the instance's kernel invariants."""
setattr(self, key, self.get_argument(key, processor, group))
kernel_invariants = getattr(self, "kernel_invariants", set())
self.kernel_invariants = kernel_invariants | {key}
def get_device_db(self):
"""Returns the full contents of the device database."""
@ -248,8 +252,12 @@ class HasEnvironment:
def setattr_device(self, key):
"""Sets a device driver as attribute. The names of the device driver
and of the attribute are the same."""
and of the attribute are the same.
The key is added to the instance's kernel invariants."""
setattr(self, key, self.get_device(key))
kernel_invariants = getattr(self, "kernel_invariants", set())
self.kernel_invariants = kernel_invariants | {key}
def set_dataset(self, key, value,
broadcast=False, persist=False, save=True):

View File

@ -83,8 +83,6 @@ class ClockGeneratorLoopback(EnvExperiment):
class PulseRate(EnvExperiment):
kernel_invariants = {"core", "ttl_out"}
def build(self):
self.setattr_device("core")
self.setattr_device("ttl_out")
@ -107,8 +105,6 @@ class PulseRate(EnvExperiment):
class PulseRateDDS(EnvExperiment):
kernel_invariants = {"core", "core_dds", "dds0", "dds1"}
def build(self):
self.setattr_device("core")
self.setattr_device("core_dds")