yat4tango: issue when adding dynamic spectrum attributes

Dear all,

I write you about some issues regarding yat4tango library. I'm currently using it to dynamically add attributes to my device server (it is more flexible than the current suggested way to add dyn attributes in Tango and it seems possible also to add forwarded attributes).
I've found this issue when adding spectrum attributes and then setting attribute properties. The sample code is (try-catch block not shown):


//Create dyn attr manager
DynamicAttributeManager* m_dam = new yat4tango::DynamicAttributeManager(this);

//Create dyn attr info
yat4tango::DynamicAttributeInfo dai;
dai.dev = this;
dai.tai.name = attr_name;
dai.tai.writable = write_type;
dai.tai.data_format = Tango::SPECTRUM;
dai.tai.data_type= data_type;
dai.tai.max_dim_x= data_size;//this seems ineffective since yat4tango initialize spectrum attr with size LONG_MAX

//Add attribute to manager
m_dam->add_attribute(dai);

//Retrieve attribute found
long attr_index= get_device_attr()->get_attr_ind_by_name(attr_name.c_str());		
std::vector<Tango::Attribute*> attribute_list= get_device_attr()->get_attribute_list();
		
//Set my properties	
Tango::MultiAttrProp<Tango::DevFloat>* multi_attr_prop= …
attribute_list[attr_index]->set_properties(*multi_attr_prop);

The last line produces this exception:


Tango exception
Severity = ERROR 
Error reason = API_AttrNotAllowed
Desc : Attribute property max_dim_x is not changeable at run time
Origin : Attribute::check_hard_coded_properties()

This has driven me nuts the whole day (think it is a bug but better ask…). The error seems in the
get_properties(Tango::AttributeConfig_3 &conf) and get_properties(Tango::AttributeConfig_5 &conf) methods of the attrgetsetprop.cpp. When converting from AttributeConfig_3 to AttributeConfig_5 the max_dim_x property (which is initialized to LONG_MAX by yat for spectrum & image attrs) seems implicitly converted to int (e.g. conf.max_dim_x= -1). Hence, when conf.max_dim_x and max_dim_x are compared in the sanity check there is a mismatch. By the way the set_properties() method should not supposed to change the hard-coded properties, no?

Do you have suggestions or could you in case confirm if it is a bug or not?
I've temporarily fixed the issue by modifying the constructor of spectrum dyn attributes (did the same for image) from:


DynamicSpectrumAttribute (const DynamicAttributeInfo& i)
    : Tango::SpectrumAttr (i.lan.c_str(), i.tai.data_type, i.tai.writable, LONG_MAX, i.tai.disp_level),…

to:


DynamicSpectrumAttribute (const DynamicAttributeInfo& i) 
		: Tango::SpectrumAttr (i.lan.c_str(), i.tai.data_type, i.tai.writable, i.tai.max_dim_x, i.tai.disp_level),


I thank you very much for your help,

Simone
****************************************************************
Simone Riggi
INAF, Osservatorio Astrofisico di Catania
Via S. Sofia 78
95123, Catania - Italy
phone: +39 095 7332 extension 282
e-mail: simone.riggi@gmail.com,
sriggi@oact.inaf.it
skype: simone.riggi
****************************************************************
Hi Simone,

Reading your comments, the problem seems to be located in Tango (to be confirmed cause it's late:). Changing the ctors code sounds like a workaround.

However, your mods clearly make sense. I even don't remember why I used LONG_MAX instead of the max dimensions specified in the yat4tango::DynamicAttributeInfo. I will adopt your proposal asap.

Thanks for reporting.

N.
Edited 7 years ago
Done! Please check out the SVN trunk.
At the speed of light - wow !
By the way the set_properties() method should not supposed to change the hard-coded properties, no?
Only part of the attribute' properties is mutable.
Question is: which part of the properties set is mutable? This is certainly written somewhere in the Tango bible…
Andy
At the speed of light - wow !
I go to the gym. yat4Tango support is now closed till Monday smile
Many thanks for your prompt support!
****************************************************************
Simone Riggi
INAF, Osservatorio Astrofisico di Catania
Via S. Sofia 78
95123, Catania - Italy
phone: +39 095 7332 extension 282
e-mail: simone.riggi@gmail.com,
sriggi@oact.inaf.it
skype: simone.riggi
****************************************************************
 
Register or login to create to post a reply.