I am trying to get the device attribute’s enum labels list. At the moment I am using the DeviceProxy object to query the device for the attribute configuration, however I wanted to know if there is a way to get them through the device object.
So far I have tried using:
self.get_device_attr()
and
self.get_attribute_config()
however none of the returned objects have the property enum_labels.
Sorry for answering in C++, but since PyTango is based on the Tango C++ library, this might still help you.
In C++, in a device server, you can get the enum labels from a MultiAttrProp object, using Attribute::get_properties(MultiAttrProp&) method.
Here is a sample code:
Tango::MultiAttrProp<Tango::DevEnum> multi_attr_prop;
get_device_attr()->get_attr_by_name("Color").get_properties(multi_attr_prop);
cout << "Labels for Color DevEnum attribute:" << endl;
for(string l:multi_attr_prop.enum_labels)
{
cout << "- " << l << endl;
}
Maybe the pyTango experts could guide you better after this hint
Hoping this helps,
Reynald
PS: Special thanks to Emmanuel Taurel for his help on this topic.