dynamic attributes with external devices

Reynald
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.
Yeah, I discovered this following the links to issue on this topic yesterday, thank you for this precision, it will be useful to be conscious of awaited problems with this solution.

Reynald
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.
Yes, it helps a lot. smile
I'm not sure adjusting the buffer size to big values will be possible without performance tradeoffs on libera hardware, which is why I though about a 2d device with independant buffer.
But perhaps this solution is possible, we will keep this in mind to check.
- Philippe
Hi,

to resume about dynamic attributes use, the way i understand it allows to get a set of unknown values through device properties during 'Init' command.
Following this way, I should be able, in a device server, to :

1. use a 'dynAttrList' property containing for example the list "A/B/C/attr1, A/B/C/attr2, D/E/F/attr1"

2. with this property, create 3 dynamic attributes to store last value of respectively A/B/C/attr1, A/B/C/attr2, and D/E/F/attr1
Then I would use following method to create these dynamic attributes:

void DynAttr :: add_dynamic_attributes()
{
    for (unsigned int i = 0; i <dynAttrList.size (); i = i + 1)
    {
        // convert dynAttrList [i] to local attribute named attr
        // attr[0] = A_B_C_attr1
        // attr[1] = A_B_C_attr2
        // attr[2] = D_E_F_attr1
        // …
        add_LongDynAttr_dynamic_attribute (attr[i]);
}

Is this the good way to do this?

Best wishes.
JCM
Is this the good way to do this?

Yes, you are on the right track! This will create some Tango::DevLong dynamic attributes with the names you gave (A_B_C_attr1, A_B_C_attr2, D_E_F_attr1,…) smile

Then you will have to put some smart code into DynAttr::read_LongDynAttr(Tango::Attribute &attr) method to set the attribute value for the corresponding attribute name that you can get with attr.get_name() method.
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 put my code in the DynAttr::read_LongDynAttr(Tango::Attribute &attr) method to set the attribute value but it is called only if another client accesses the attribute. The atkpanel does not display the updated value ;(
Is this normal?

Also, the DynAttr::add_dynamic_attributes() method is not executed by init_device(). The 'init' command is not enough, i have to stop my DS and restart it if changed the list of attributes ;(
Is this normal?

thank you so much

JCM
I put my code in the DynAttr::read_LongDynAttr(Tango::Attribute &attr) method to set the attribute value but it is called only if another client accesses the attribute.

The code in DynAttr::read_LongDynAttr(Tango::Attribute &attr) is called only when any client tries to read one of your created dynamic attributes. This method can be called regularly as well if your dynamic attributes are polled.

JCM
The atkpanel does not display the updated value ;(
Is this normal?

Do you mean the value of your attribute? Or do you mean the atkpanel does not display the newly created dynamic attributes.
atkpanel does not listen to interface change events, so it is not notified when new attributes are created. If you create new attributes, you need to restart atkpanel to see the current device interface with the newly created attributes.
Can you please share the code of your DynAttr::read_LongDynAttr(Tango::Attribute &attr) method so we can understand what you actually asked the device server to do?

JCM
Also, the DynAttr::add_dynamic_attributes() method is not executed by init_device(). The 'init' command is not enough, i have to stop my DS and restart it if changed the list of attributes ;(
Is this normal?

Yes, this is normal. DynAttr::add_dynamic_attributes() is invoked by DynAttrClass::device_factory() method, which is called when the device are created.

If you change the list of attributes for one device, the right approach is to do a "restart device" (available from the right-click menu on your device on jive, there is a DevRestart command on the admin device to do that too).
If you change the list of attributes for many devices from your device server, you should restart the server (there is a RestartServer command on the admin device or you can simply restart the device server from astor).

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.
JCM
I put my code in the DynAttr::read_LongDynAttr(Tango::Attribute &attr) method to set the attribute value but it is called only if another client accesses the attribute.

Reynald
The code in DynAttr::read_LongDynAttr(Tango::Attribute &attr) is called only when any client tries to read one of your created dynamic attributes. This method can be called regularly as well if your dynamic attributes are polled.

thanks, i try.


JCM
The atkpanel does not display the updated value ;(
Is this normal?

Reynald
Do you mean the value of your attribute? Or do you mean the atkpanel does not display the newly created dynamic attributes.
atkpanel does not listen to interface change events, so it is not notified when new attributes are created. If you create new attributes, you need to restart atkpanel to see the current device interface with the newly created attributes.
Can you please share the code of your DynAttr::read_LongDynAttr(Tango::Attribute &attr) method so we can understand what you actually asked the device server to do?

i mean the value of my attributes.
extract of my DynAttr::read_LongDynAttr(Tango::Attribute &attr) method smile


Tango::DevDouble *att_value = get_DoubleDynAttr_data_ptr(attr.get_name());
string &att_name = attr.get_name();
/* previously done in the method add_dynamic_attributes():
add_DoubleDynAttr_dynamic_attribute(bufferMean);
add_DoubleDynAttr_dynamic_attribute(bufferStd);
add_DoubleDynAttr_dynamic_attribute(bufferPeak);*/

for (int i=0; i<numberOfDynamicAttributes; i++)
{
if (std::strcmp(att_name.c_str(),bufMean[i])==0)
{
*att_value=theMeanValue;// theMeanValue is the value to set in dynamic attribute
attr.set_value(att_value);
break;
}
if (std::strcmp(att_name.c_str(),bufPeak[i])==0)
{
*att_value=thePeakValue;// thePeakValue is the value to set in dynamic attribute
attr.set_value(att_value);
break;
}
if (std::strcmp(att_name.c_str(),bufStd[i])==0)
{
*att_value=theSdValue;// theSdValue is the value to set in dynamic attribute
attr.set_value(att_value);
break;
}
}



JCM
Also, the DynAttr::add_dynamic_attributes() method is not executed by init_device(). The 'init' command is not enough, i have to stop my DS and restart it if changed the list of attributes ;(
Is this normal?

Reynald
Yes, this is normal. DynAttr::add_dynamic_attributes() is invoked by DynAttrClass::device_factory() method, which is called when the device are created.

If you change the list of attributes for one device, the right approach is to do a "restart device" (available from the right-click menu on your device on jive, there is a DevRestart command on the admin device to do that too).
If you change the list of attributes for many devices from your device server, you should restart the server (there is a RestartServer command on the admin device or you can simply restart the device server from astor).

Thanks



Maybe your problem comes from the fact that you have declared in POGO you would push events by code for these attributes and you actually don't push events.



So atkpanel subscribes to events for these attributes and simply waits for these events to update the displayed values.
But if the device server does not push any event, atkpanel will never receive any update.

To identify if atkpanel is actually listening to events on your attribute or doing some remote polling of the attribute, you can have a look at the ATK Diagnostic window (available from atkpanel's View menu and then "Diagnostic…" menu item).



If you see Event enabled set to true for your attributes, this means that atkpanel will not remotely poll these attributes and simply wait for events to come. This is probably what happens in your case?
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.
I precise i have not declared in POGO i you would push events by code for these attributes.
In my code i subscribe to events and a callback method is triggered when the events are received (push model).
In the ATK Diagnostic window, i see Event enabled set to true for all my attributes.


Are your attributes polled in your device server?
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.
YES
on my attributes, with jive, i set polling and absolute value on Change event.
See also the ATK diagnostic window.







 
Register or login to create to post a reply.