dynamic attributes with external devices

Hi,

is it possible to create and manage dynamic attributes with external devices ?

I follow "HOW TO ADD DYNAMIC ATTRIBUTES TO A DEVICE CLASS"
(https://tango-controls.readthedocs.io/en/latest/tutorials-and-howtos/how-tos/how-to-dynamic-attributes-device-class.html?highlight=dynamic%20attributes)
to learn dynamic attribute, but i do not see how to do it .

What is the difference with list where each entry as single device name (vector<string> managedDevice_List; vector<string> ignoredDevice_List) ?
And by configuring group of managed devices (Tango::Group*) or device names (Tango::DevString*) ?

Thanks,
JCM
JCM
is it possible to create and manage dynamic attributes with external devices ?

The code creating the dynamic attributes must be part of the device server exposing these dynamic attributes but the creation can be triggered by an external event (command received, attribute written, event received, device property written followed by a device restart). This code must be written by the device server programmer following the documentation you found.
In many cases, the dynamic attributes are created during the startup of the device, based on some configuration device properties.
There is a dedicated method add_dynamic_attributes() generated by POGO which can be used to add the code to create the dynamic attributes and which is called during the device startup, after the device properties have been read.
But you could also add dynamic attributes in a command execution method for instance.
POGO can also be used to create some dynamic attributes. If you declare some dynamic attributes in POGO, you can define some dynamic attribute "templates" for some attributes of a specific type and you can already initialize the properties these attributes will have in common.
POGO will then generate some methods which can be invoked to create these kinds of attributes more easily.

JCM
What is the difference with list where each entry as single device name (vector<string> managedDevice_List; vector<string> ignoredDevice_List) ?
And by configuring group of managed devices (Tango::Group*) or device names (Tango::DevString*) ?

Sorry but I have no idea of what you are talking about here. Where did you find these managedDevice_List and ignoreDevice_List?
Cheers,
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.
Thanks Reynald for your detailed answer.

It was just an idea without using dynamic attributes. What I meant was that we need to be able to access attributes from other devices (at the option of the user) by configuring one or more properties (Array of strings) corresponding to the devices.
It is then enough to build: groups of devices, lists of attributes to read … with the method read_attribute () for example.

Regards.
JCM
It was just an idea without using dynamic attributes. What I meant was that we need to be able to access attributes from other devices (at the option of the user) by configuring one or more properties (Array of strings) corresponding to the devices.
It is then enough to build: groups of devices, lists of attributes to read … with the method read_attribute () for example.

I understand. What you mentioned is indeed the classical way to deal with the use case you just described.
Dynamic attributes are another concept. Dynamic attributes are attributes which are different from the classical static attributes created by POGO.
Dynamic attributes can be created on the fly with the names and types you want (with some limitations).
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,
I wonder if there is any issue if I want to fill a dynamic attribute with external attributes values.

For example, I would like to :
- create an attribute with a (static) property maxBufferSize,
- a dynamic scalar attribute A/B/C/bufferSize less or equal to maxBufferSize
- a spectrum dynamic attribute A/B/C/buffer of size A/B/C/bufferSize.

Then, I would like to fill A/B/C/buffer with D/E/F/externalAttribute by subscribing to these attribute values.

Do you see any problem with this behaviour or should it work?
Thank you.
- Philippe
Hi Philippe,

When A/B/C/buffer dynamic attribute is created, it is important for it to have the same maximum X data size as D/E/F/externalAttribute, unless you are not interested in copying the full externalAttribute buffer.
If you create an attribute with maxDimX < maxDimX(D/E/F/externalAttribute), there is a risk that at some point D/E/F/externalAttribute will contain more values than A/B/C/buffer can handle and Tango will probably complain when you will try to set the A/B/C/buffer attribute value.

For your use case, if you intend to have A/B/C/buffer attribute having exactly the same values as D/E/F/externalAttribute, it would be more logical to use a forwarded attribute to avoid intermediate copies.
But please be aware, there are some known bugs (and probably not yet known bugs too smile ) with the forwarded attributes.
For instance:
https://github.com/tango-controls/cppTango/issues/386
https://github.com/tango-controls/JTango/issues/44
https://github.com/tango-controls/JTango/issues/37

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.
Thank you for the explanation.
I should have precised that A/B/C/buffer is a spectrum and D/E/F/externalAttribute is a scalar static attribute.

The way I see to do this is then to :
- create a dynamic attribute A/B/C/buffer at device startup according to device static property bufferSize
- fill dynamic spectrum attribute A/B/C/buffer each time a new value of scalar D/E/F/externalAttribute static attribute is available. The way I see to do this is to subscribe A/B/C/buffer to D/E/F/externalAttribute but forwarded attribute does not seem to be the way since dimension of A/B/C/buffer and D/E/F/externalAttribute differs.

Am I wrong?
Is it the good way to do this?
- Philippe
Hi Philippe,
correct me if I'm wrong, but basically you want to fill the A/B/C/buffer entries with the scalar value in D/E/F/externalAttribute any time this value changes, up to the maxBufferSize? If this is the case you can subscribe to the change event for D/E/F/externalAttribute and push it into A/B/C/buffer…
Cheers,
Lorenzo
Edited 5 years ago
lorenzo
Hi Philippe,
correct me if I'm wrong, but basically you want to fill the A/B/C/buffer entries with the scalar value in D/E/F/externalAttribute any time this value changes, up to the maxBufferSize? If this is the case you can subscribe to the change event for D/E/F/externalAttribute and push it into A/B/C/buffer…
Indeed Lorenzeo, that was the way I saw it, I wondered if there is any issue to be awaited with this behavior since we are not used to dynamic attributes.
I understand it is possible.
- Philippe
You can forget about forwarded attributes in your case. I didn't understand well you use case.

At first sight, I don't expect any issue with the behavior you described.
You just have to know how you will deal with errors.
If D/E/F is not reachable for a while, you will receive error events. You have to think about how you will deal with these errors.
It looks like what you want is getting the history of the last A/B/C/bufferSize values of D/E/F/externalAttribute.
You know you could also get that by reading D/E/F/externalAttribute history from D/E/F polling buffer history if D/E/F/externalAttribute is polled.
You can tune the poll ring depth property to configure the size of the polling buffer history.
You will get a timestamp associated with each value in the polling buffer history.

If you subscribe to change events, you will receive events only when the values will change (depending on your event settings).
You just have to configure the system for what you want to achieve.

If you keep the idea of creating A/B/C/Buffer attribute, you could initialize it by reading D/E/F/externalAttribute polling buffer history. That way, if A/B/C is restarted, it will retrieve the history and fill up the buffer immediately with the latest values. In this case, depending on how the polling buffer is filled, the polling buffer history might contain consecutive values having the same values.

Hoping this helps,
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.
 
Register or login to create to post a reply.