Skip to content
Snippets Groups Projects
Commit abf64b5a authored by Taya Snijder's avatar Taya Snijder
Browse files

Merge branch 'L2SS-363_01-12-2021-get_RW_values_from_hardware' into 'master'

Resolve L2SS-363 "01 12 2021 get rw values from hardware"

Closes L2SS-363

See merge request !197
parents c58ab795 3929d81c
Branches
Tags with-tango-source-images
1 merge request!197Resolve L2SS-363 "01 12 2021 get rw values from hardware"
......@@ -70,47 +70,32 @@ class attribute_wrapper(attribute):
max_dim_y = 0
if access == AttrWriteType.READ_WRITE:
""" if the attribute is of READ_WRITE type, assign the RW and write function to it"""
""" if the attribute is of READ_WRITE type, assign the write function to it"""
@only_in_states([DevState.STANDBY, DevState.ON], log=False)
@fault_on_error()
def read_RW(device):
# print("read_RW {}, {}x{}, {}, {}".format(me.name, me.dim_x, me.dim_y, me.attr_type, me.value))
def write_func_wrapper(device, value):
"""
read_RW returns the value that was last written to the attribute
"""
try:
return device.value_dict[self]
except Exception as e:
raise Exception(f"Attribute read_RW function error, attempted to read value_dict with key: `{self}`, are you sure this exists?") from e
@only_in_states([DevState.STANDBY, DevState.ON], log=False)
@fault_on_error()
def write_RW(device, value):
"""
_write_RW writes a value to this attribute
write_func_wrapper writes a value to this attribute
"""
self.write_function(value)
device.value_dict[self] = value
self.fget = read_RW
self.fset = write_RW
self.fset = write_func_wrapper
else:
""" if the attribute is of READ type, assign the read function to it"""
""" Assign the read function to the attribute"""
@only_in_states([DevState.STANDBY, DevState.ON], log=False)
@fault_on_error()
def read_R(device):
"""
_read_R reads the attribute value, stores it and returns it"
"""
device.value_dict[self] = self.read_function()
return device.value_dict[self]
@only_in_states([DevState.STANDBY, DevState.ON], log=False)
@fault_on_error()
def read_func_wrapper(device):
"""
read_func_wrapper reads the attribute value, stores it and returns it"
"""
device.value_dict[self] = self.read_function()
return device.value_dict[self]
self.fget = read_R
self.fget = read_func_wrapper
super().__init__(dtype=datatype, max_dim_y=max_dim_y, max_dim_x=max_dim_x, access=access, **kwargs)
......
......@@ -308,7 +308,7 @@ class TestAttributeTypes(base.TestCase):
if test_type == "scalar":
expected = numpy.zeros((1,), dtype=dtype)
val = proxy.scalar_RW
val = proxy.scalar_R
elif test_type == "spectrum":
expected = numpy.zeros(spectrum_dims, dtype=dtype)
val = proxy.spectrum_R
......
......@@ -73,8 +73,12 @@ class test_client(CommClient):
"""
takes all gathered data to configure and return the correct read and write functions
"""
self.value = numpy.zeros(dims, dtype)
if dtype == str and dims == (1,):
self.value = ''
elif dims == (1,):
self.value = dtype(0)
else:
self.value = numpy.zeros(dims, dtype)
def read_function():
logger.debug("from read_function, reading {} array of type {}".format(dims, dtype))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment