Dynamic attributes with write methods
Closed this issue · 4 comments
TNoga0 commented
Hello,
I'm wondering if there is a simple way to implement a writing method for dynamically generated attribute that takes the value as argument (or allows for user input).
So far I've been using Attr's get_write_value() method - example below:
def write_analogOutput(self, attr) -> None:
elem = attr.get_name().split("_")[1]
value = attr.get_write_value()
self.write_register(elem, self.decode_value(value, elem, `0))
...but the docs say it's deprecated, so I'm looking for another solution.
I'd be grateful for any help.
ajoubertza commented
ajoubertza commented
OK, I have found the deprecation note:
pytango/tango/device_server.py
Lines 1984 to 1986 in 70ef4df
Note that there are two versions of the function, only the first one is deprecated.
Basically it says DON'T do it this way:
def write_analogOutput(self, attr) -> None:
elem = attr.get_name().split("_")[1]
deprecated_way_to_get_values = []
attr.get_write_value(deprecated_way_to_get_values)
value = deprecated_way_to_get_values[0]
self.write_register(elem, self.decode_value(value, elem, 0))
ajoubertza commented
@TNoga0 Does this answer your question?
ajoubertza commented
No response, so closing old ticket.