How to memorize a READ attribute
|
|
---|---|
Hi all, as I understood it from the documentation and from experience, it is only possible to memorize READ_WRITE attributed. In my case, I need to implement a counter as an attribute, which is increased whenever the position of the according motor is changed. So writing the counter by the user is not intended. Unfortunately, the hardware does not allow for storing the value, so it must be implemented in the TangoDS. But how can I memorize the value of the counter when restarting the TangoDS? Is there any workaround? I thought of using a property instead, which is written in the delete_device() method. Best Daniel |
|
|
---|---|
Hello, In your case, you may use a property to store the data. You may push_back the data to the tango database everytime the counter is updated (this will prevent any some dataloss if the device crashes). But you can also set the attribute to READ_WRITE and not implement anything in the write_you_counter function, this way it may be easier for you to deal with it using the memorized property. Best Regards
Guillaume DI FRANCO
Thales - Software Engineer Manager |
|
|
---|---|
Hi, I would store the counter value in an attribute property of your counter attribute to achieve that. Memorized attributes are stored under attribute properties named "__value" (2 underscores). "__value" attributes properties are considered special in Tango. For performance reasons, their history is not saved in the Tango DB as for the other properties (By default, the 10 last values are saved in the history for all the other device and attribute properties. And you can see this history via jive). The idea of Guillaume to save it in a property every time the value changes is good to handle the cases when the device server crashes (but of course, this never happens ). If the counter changes at very high speed, I would discourage to save the counter value in the Tango DB because it might have an impact on your Tango Database responsiveness. Here is a code example saving a value in a __value attribute property:
And another example showing a way to retrieve the last saved value of the attribute property:
Rosenberg's Law: Software is easy to make, except when you want it to do something new.
Corollary: The only software that's worth making is software that does something new. |
|
|
---|---|
Hi guys, many thanks for the quick responses! We also had the ideas of Guillaume with the property or with a write-method which does nothing. However, using the __value attribute property is of course another nice idea. As the counter is not increasing very fast < 1Hz we could save the counter value every time we change it, but I could also live with saving it only on delete in the delete_device method - since our DSs never crash :) BTW, is there a reason why memorizing READ attributes is not implemented out of the box? Would it be worth an issue? Best Daniel |
|
|
---|---|
dschick I guess there has never been a strong demand for that but that's of course an idea for the future. We encountered this use case already where I work. Feel free to create an issue where we could discuss this possibility (and not forget about this idea). I guess this feature will not be in the top priority features to be implemented because there is a work-around with the existing features. If you're willing to create an issue, I would suggest to create this issue in the TangoTickets repository : https://gitlab.com/tango-controls/TangoTickets/-/issues/new Kind regards, Reynald
Rosenberg's Law: Software is easy to make, except when you want it to do something new.
Corollary: The only software that's worth making is software that does something new. |
|
|
---|---|
Just a small addition, recipe how to do this in pytango. Thanks to Yury Matveev.
|