Skip to content
Snippets Groups Projects

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

Merged Resolve L2SS-363 "01 12 2021 get rw values from hardware"
2 unresolved threads
Merged Taya Snijder requested to merge L2SS-363_01-12-2021-get_RW_values_from_hardware into master
2 unresolved threads
Files
3
@@ -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))
"""
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):
def write_func_wrapper(device, value):
"""
_write_RW writes a value to this attribute
Please register or sign in to reply
"""
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_R reads the attribute value, stores it and returns it"
Please register or sign in to reply
"""
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)
Loading