fetching values of memorized attributes

Hello dear Tango Experts,

We have some issues with values of memorized attributes which are not written when an init_device() method is ran (we need to re-init devices sometimes, ie after lost communication with hardware).

As we understand, it's done after the init_device() (by… which process?) when we (re-)start a device server (ie with Astor) as it appears in a write_attribute command but it's not done when we need to send an init_device() inside another command.

We have several questions:
1. Is it possible to check the values of all memorized attributes in a device server by running a command – so automatically fetching the values from database without knowing the list of memorized attributes a priori.
We've tried to get them with get_attribute_config(attr_name) after calling a deviceProxy() but we have this value:
memorized=tango._tango.attrmemorizedtype.NOT_KNOWN
Which will be the best way to enforce the fetching of the memorized value from the database?

2. In another category, we have to re-affect a memorized value in an attribute; what is the best method to do this? We use this method currently which seems quite unfriendly:
PyTango.DeviceProxy(self.get_name()).write_attribute("Gain8",
int(self.db.get_device_attribute_property(self.get_name(), ['Gain8'])['Gain8']['__value'][0]))

Best regards,
Stephane Marchand
smaluli
Hello dear Tango Experts,

We have some issues with values of memorized attributes which are not written when an init_device() method is ran (we need to re-init devices sometimes, ie after lost communication with hardware).

As we understand, it's done after the init_device() (by… which process?) when we (re-)start a device server (ie with Astor) as it appears in a write_attribute command but it's not done when we need to send an init_device() inside another command.

Hi Stephane,

The memorized attributes are not written when you invoke the init_device() method from your device but they are written if you invoke the Init command on your device.
The 2 other cases where they are written are when you restart your device (DevRestart command on admin device) and when your restart the server with the Restart server command on the admin device (and of course when the devices are created when you start the device server).

Hoping this helps a bit.
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.
Edited 3 years ago
Hi Reynald,

Thanks, it's a good confirmation of our thoughts. We use a deviceProxy on the device itself to do get the target of the command_inout() and you use the same way to write memorized attributes also… do you know a better way to do it?

Best,
Stéphane
smaluli
Hi Reynald,

Thanks, it's a good confirmation of our thoughts. We use a deviceProxy on the device itself to do get the target of the command_inout() and you use the same way to write memorized attributes also… do you know a better way to do it?

Best,
Stéphane

Sorry Stéphane, I didn't understand your question. Could you reformulate it, please?
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 Reynald,

Sorry for the delay, I miss your answer.
Our method to get a memorized attribute value is to make a call from the database itself via the proxy:

PyTango.DeviceProxy(self.get_name()).write_attribute(attr,value))

Is there a better way to get this information?

Best,
Stéphane
smaluli
PyTango.DeviceProxy(self.get_name()).write_attribute("Gain8",
int(self.db.get_device_attribute_property(self.get_name(), ['Gain8'])['Gain8']['__value'][0]))

I guess you meant this code (because the other one was simply writing the attribute)?
This is getting the latest memorized value from the Tango DB (__value Gain8 attribute property) and writing Gain8 attribute with this value.
This is indeed a correct way to write the latest memorized value in the attribute.

Except restarting the device (or server) or executing the Init command (but this is doing more), I don't know whether there is a more convenient way to do it in pytango.
In cppTango, I can see that there is a get_mem_value() method in WAttribute class but this method is not documented in Doxygen, so this method is currently not supposed to be used by the device server programmers.
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.
Oh thanks Reynald, you made a great smaluli-correct() to answer to the real question.
Yes, it was this notation on which I had some doubts. Ok for the get_mem_value() method, I keep the above one.
Best,
Stephane
 
Register or login to create to post a reply.