How to work with dev_enum attribute
Dear PyTango experts, I created a dummy DS with a enum scalar attribute using pogo + manual fixes.
When I use PyTango to read the attribute, I got an int
value instead an enumeration
. When I read the attribute using jive. It returns the Enumeration string ('B') instead of Enumeration index (1).
What I doing wrong? It is something bad defined in the DS .
import PyTango
dp = PyTango.DeviceProxy('testds/test/1')
dp.read_attribute('enum_scalar')
Out[2]: DeviceAttribute(data_format = tango._tango.AttrDataFormat.SCALAR, dim_x = 1, dim_y = 0, has_failed = False, is_empty = False, name = 'enum_scalar', nb_read = 1, nb_written = 0, quality = tango._tango.AttrQuality.ATTR_VALID, r_dimension = AttributeDimension(dim_x = 1, dim_y = 0), time = TimeVal(tv_nsec = 0, tv_sec = 1524131144, tv_usec = 387732), type = tango._tango.CmdArgType.DevEnum, value = 1, w_dim_x = 0, w_dim_y = 0, w_dimension = AttributeDimension(dim_x = 0, dim_y = 0), w_value = None)
type(dp.read_attribute('enum_scalar').value)
Out[4]: int
How should I check the valid values? Assuming consecutive values and comparing with the number of enum labels
?
dp.get_attribute_config_ex('enum_scalar')
Out[4]: [AttributeInfoEx(alarms = AttributeAlarmInfo(delta_t = 'Not specified', delta_val = 'Not specified', extensions = [], max_alarm = 'Not specified', max_warning = 'Not specified', min_alarm = 'Not specified', min_warning = 'Not specified'), data_format = tango._tango.AttrDataFormat.SCALAR, data_type = tango._tango.CmdArgType.DevEnum, description = 'No description', disp_level = tango._tango.DispLevel.OPERATOR, display_unit = 'No display unit', enum_labels = ['A', 'B', 'C'], events = AttributeEventInfo(arch_event = ArchiveEventInfo(archive_abs_change = 'Not specified', archive_period = 'Not specified', archive_rel_change = 'Not specified', extensions = []), ch_event = ChangeEventInfo(abs_change = 'Not specified', extensions = [], rel_change = 'Not specified'), per_event = PeriodicEventInfo(extensions = [], period = '1000')), extensions = [], format = '%s', label = 'enum_scalar', max_alarm = 'Not specified', max_dim_x = 1, max_dim_y = 0, max_value = 'Not specified', memorized = tango._tango.AttrMemorizedType.NONE, min_alarm = 'Not specified', min_value = 'Not specified', name = 'enum_scalar', root_attr_name = 'Not specified', standard_unit = 'No standard unit', sys_extensions = [], unit = '', writable = tango._tango.AttrWriteType.WT_UNKNOWN, writable_attr_name = 'enum_scalar')]
By the way I could not find DEV_ENUM type documentation in http://pytango.readthedocs.io/en/stable/data_types.html
Thanks in advance, Carlos