Attribute enum query in server code??
|
|
---|---|
As part of a Device Server SKA we have a Tango Attribute defined as:adminMode = attribute( and later in an inherited class in the same server we wish to check the current value of this attribute Using DeviceProxy this is easy admin_labels = list(dp.attribute_query('adminMode').enum_labels) BUT can we retrieve the ENUM directly from the Attribute itself???? It seems wrong to have to loopback to the server using DeviceProxy! Ideally it would be good to replace line the admin_labels = list(dp.attribute_query('adminMode').enum_labels)by something like admin_labels = adminMode.get_enum_labels() |
|
|
---|---|
Hi Brian I agree the loopback would be a bad approach! You cannot read from the attribute itself, since it doesn't having a backing variable implicitly. There would be `read_adminMode` method that will return the current value. In the case of the SKA LMC base classes, the variable returned is `self._admin_mode`. Unfortunately this variable isn't actually an enumerated type - that's something that still needs to be fixed in the SKA Base classes - I guess I should do it soon! For a more general example, see here: https://pytango.readthedocs.io/en/stable/data_types.html#devenum-pythonic-usage That same example shows that on the client side the DeviceProxy will actually give you an IntEnum object directly, so you don't need to bother with the labels. Regards, Anton |