I have been trying to understand how the setpoint and readback works in TANGO compared to EPICS and I think I have finally understood it with some help from @gubaidulinvadim, looking at the code from @gupichon and the presentation by Benjamin on the community meeting. Now I'm trying to understand what we need to get the same behavior in TANGO and EPICS when using the same pyAML command.
This is how I currently understand how the TANGO bindings work. Is this correct @gupichon?
- You configure one TANGO attribute per pyAML device attribute. This attribute could be read-write or read only in your TANGO device but this you don't specify in the pyAML config. Do you need to specify it somewhere in pyAML? Maybe it's in the implementation of the device?
- For pyAML you bind
set to write_attribute_asynch in pytango which writes asynchronously.
- Then you have a function
set_and_wait bind to write_attribute which writes synchronously and the user needs to input a wait time.
- You bind
get to read_attribute.w_value which reads the last value that has been written to the attribute - so you get the existing setpoint.
- To get the readback you bind
readback to read_attribute but then do something in addition which I don't fully understand. Is it some metadata so the readback returns more than just the value?
quality = Quality[attr_value.quality.name.rsplit('_', 1)[1]] # AttrQuality.ATTR_VALID gives Quality.VALID
value = Value(attr_value.value, quality, attr_value.time.todatetime() )
This I understand how it works for magnets because then the user is mostly interested in reading the setpoint. The readback you only need for determining if the device has finished moving or not (and this maybe TANGO already does automatically?). But how does it work for a BPM? Can you still read the BPM with get or you need to do it with readback? Will a read-only device in TANGO also have the read_attribute.w_value?
Then for EPICS I think we have the following situation:
The setpoint and readback are separated into two PVs. We also need the solution to work for both channel and PV access ideally with the same behaviour for both. See Issue #21.
We could maybe do the following:
- We configure a setpoint and a readback for each pyAML device attribute. The setpoint is always read-write and the readback read-only but that we don't specify in the config but at some level of the EPICS specific implementation. This seems to me somewhat similar to the
Setpoint and Monitor fields in MML.
- We bind the setpoint to
set but I'm not sure how easy it is to make it asynchronous without using asyncio and then the behaviour would be different between TANGO and EPICS which is perhaps not so nice?
- The
set_and_wait function I don't think we want to have. We rather want the device to have a status when it is done moving and wait until then so the user never have to specify wait times anywhere.
- We bind
get to the setpoint.
- We bind
readback to the readback.
This will however give us the problem that we need to read the orbit with readback rather than get which isn't nice and the users won't like since the default command to read a device won't be the same for all devices. For EPICS it feels like maybe we need some functionality where we can have a general get function and to that function specify if we want to get the setpoint or readback? Like how it is done in MML or pytac?
What do you think?
I have been trying to understand how the setpoint and readback works in TANGO compared to EPICS and I think I have finally understood it with some help from @gubaidulinvadim, looking at the code from @gupichon and the presentation by Benjamin on the community meeting. Now I'm trying to understand what we need to get the same behavior in TANGO and EPICS when using the same pyAML command.
This is how I currently understand how the TANGO bindings work. Is this correct @gupichon?
settowrite_attribute_asynchin pytango which writes asynchronously.set_and_waitbind towrite_attributewhich writes synchronously and the user needs to input a wait time.gettoread_attribute.w_valuewhich reads the last value that has been written to the attribute - so you get the existing setpoint.readbacktoread_attributebut then do something in addition which I don't fully understand. Is it some metadata so the readback returns more than just the value?This I understand how it works for magnets because then the user is mostly interested in reading the setpoint. The readback you only need for determining if the device has finished moving or not (and this maybe TANGO already does automatically?). But how does it work for a BPM? Can you still read the BPM with
getor you need to do it withreadback? Will a read-only device in TANGO also have theread_attribute.w_value?Then for EPICS I think we have the following situation:
The setpoint and readback are separated into two PVs. We also need the solution to work for both channel and PV access ideally with the same behaviour for both. See Issue #21.
We could maybe do the following:
SetpointandMonitorfields in MML.setbut I'm not sure how easy it is to make it asynchronous without usingasyncioand then the behaviour would be different between TANGO and EPICS which is perhaps not so nice?set_and_waitfunction I don't think we want to have. We rather want the device to have a status when it is done moving and wait until then so the user never have to specify wait times anywhere.getto the setpoint.readbackto the readback.This will however give us the problem that we need to read the orbit with
readbackrather thangetwhich isn't nice and the users won't like since the default command to read a device won't be the same for all devices. For EPICS it feels like maybe we need some functionality where we can have a generalgetfunction and to that function specify if we want to get the setpoint or readback? Like how it is done in MML or pytac?What do you think?