![]() |
![]() ![]()
Experimental Physics and
| ||||||||||||||||
|
Hi Tong, On Tue, Feb 19, 2019 at 8:28 AM Tong Zhang via Tech-talk <[email protected]> wrote: And the mbbi record used in this demo: Slight aside: the value-change callback will be called with a fixed signature with PV name as the first argument, and keyword arguments for everything else, including `char_value`. So, that should be def on_value_change(pvname, char_value='?', **kws): print("Char Value ", pvname, char_value) But I think that is not the real issue, and is not solved by adding a `time.sleep()`. I do think that the issue there -- and probably why the initial call to you callback is not seeing the char_values -- is that the PV needs to connect to the Control Values for the PV. That takes a small (but non-zero) amount of time. You should not need to wait 2 seconds, but waiting 0.01 seconds might help. So, with no wait at alil, it seems sort of normal to me that the enum strings might not be **immediately available** upon creating a PV. It should show up very soon, but that initial call of the callback might not yet have the control values like enumeration strings. There are a few things you could do. First, you could use the "control data type" as with: pv = epics.PV(pv_name, form='ctrl') pv.add_callback(on_value_change) (the default value for "form" is "time" to give the Time-Status-Severity data type) or you could force retrieving the control types: pv = epics.PV(pv_name) pv.get_ctrlvars() pv.add_callback(on_value_change) You can also wait a short amount of time -- you do not need to wait 2 seconds, but waiting 0.01 seconds might help: pv = epics.PV(pv_name) time.sleep(0.01) pv.add_callback(on_value_change) If you're connecting to many PVs, I would suggest creating many of the PVs, then adding callbacks to all the PVs That approach allows all the connections (including fetching the control values) to be completed. Hope that helps, --Matt
| ||||||||||||||||
ANJ, 19 Feb 2019 |
![]() · Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing · |