Polling properties for dynamically created attributes are ignored

In a device server, I create a dynamic attribute that I would like to be polled. However, despite setting the polling period in code, the attribute is not marked as polled in Jive upon creation: I need to manually check the Polled checkbox under Polling menu, and manually specify the polling interval. With the exception of polling, the attribute is created normally, and behaves as expected.

Code:
class DynamicScalarAttribute : public Tango::Attr { … };

void Controller::add_dynamic_scalar_attribute(string attribute_name)
{
    DynamicScalarAttribute *attribute = new DynamicScalarAttribute(attribute_name);
    
    Tango::UserDefaultAttrProp properties;    
    properties.set_event_rel_change("10"); // Can be seen in Jive normally.
    attribute->set_default_properties(properties);    
    attribute->set_polling_period(2500); // Not seen in Jive: the attribute will not be marked as polled at all.
    attribute->set_disp_level(Tango::OPERATOR);    

    add_attribute(attribute);
}

void Controller::add_dynamic_attributes()
{
    /*—– PROTECTED REGION ID(PLCController::add_dynamic_attributes) ENABLED START —–*/

    add_dynamic_scalar_attribute("attribute1");

    /*—– PROTECTED REGION END —–*/ //	PLCController::add_dynamic_attributes
}

I noticed that when adding a normal (non-dynamic) polled attribute in Pogo, Tango will generate effectively the same code:
polledattribute->set_polling_period(3000);
polledattribute->set_change_event(true, false);
att_list.push_back(polledattribute);
The only difference is that add_attribute() is not called explicitly, and that set_change_event() is called, though I don't understand why as events are not being pushed manually from the code. Still, even calling set_change_event() for my dynamic attribute doesn't change the result. Of course, Tango doesn't create the attribute inside add_dynamic_attributes(), but if I try to create the dynamic attribute in e.g. init_device(), the attribute is not created at all.

Any ideas how to get this to work?
Edited 5 years ago
Hi,

This is indeed a known bug which has been fixed in tango-9-lts branch but which is not yet available in an official stable release.
Here is the reference to the Pull Request solving this issue:
https://github.com/tango-controls/cppTango/pull/427

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.
Reynald, thank you for your quick reply! It's good to see that a fix has been accepted.
For anyone interested, you can get dynamic attributes to be polled by invoking poll_attribute(atr_name, period) instead of set_polling_period(). Note, however, that there is apparently another bug related to dynamic attributes and polling that causes device restart to no longer work as described here: https://github.com/tango-controls/cppTango/issues/463. I don't know if the fix mentioned by Reynald corrects this, but so far I've not been able to find a workaround that would cause device restart to work normally.
Edited 5 years ago
 
Register or login to create to post a reply.