EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  <20152016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  <20152016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: pyepics not updating pv.enum_strs after connection
From: Matt Newville <[email protected]>
To: Jameson Graef Rollins <[email protected]>
Cc: EPICS tech-talk <[email protected]>
Date: Thu, 19 Mar 2015 07:13:05 -0500
Hi Jamie,


On Wed, Mar 18, 2015 at 10:09 PM, Jameson Graef Rollins <[email protected]> wrote:
On Wed, Mar 18 2015, Matt Newville <[email protected]> wrote:
> Sorry for the confusion.  The surest way to ensure you have enum strings
> and other CTRL attributes is to do
>
>    pv.get_ctrlvars()
>
> This should happens by default in many situations where you need to know
> the CTRL variables (say, putting a string for the name to enum PV, or
> getting with 'as_string=True').  Of course, a PV can't get look up its enum
> strings if it's not connected.

Hi, Matt.  Thanks so much for the response.  Unfortunately using
get_ctrlvars doesn't seem to help.  Or at least I can't figure out how
to use it properly.

I've tried setting "with_ctrlvars=True" when adding the callback (which
is supposed to be the default anyway), but enum_strs is still None in
the arguments passed to the callback.

If I explicitly retrieve the pv in the callback (via 'cb_info') and call
pv.get_ctrlvars() directly, I'm consistently returned an empty dict.
Furthermore, this call takes a very long time to return, apparently
after hitting a timeout.

Other methods on the pv retrieved from 'cb_info' are timing out as well.
It's almost as if the PV being supplied to the callback isn't actually
the same PV attached to the callback.

This is my first application that relies heavily on PV callbacks, so I
could be doing things improperly.  Everything else seems to be working
great, though.  It's just the enums that I seem to have no way of
resolving.

jamie.


I'm not certain I can tell what you did, but I'll guess that you created a PV, set a callback, and are trying to run pv.get_ctrlvars() inside the callback.  That won't work, basically because the get_ctrlvars() would have to do an Epics poll(), and inside a callback you're already "inside" an Epics poll().

But you can create a PV, get the ctrl vars, and then set a callback, or allow that the first few calls in the callback may not have the enum strings.      I typically do this as
    pv = PV(pvname)
    pv.get(as_string=True) # make sure it's connected, has a value, and has  CTRL values
    pv.add_callback(....)

Alternatively, you can create the PV with "form=ctrl", in which case you'll get all the CTRL fields.    If you're expecting that the enum strings (or limits...) aren't changing rapidly, getting the ctrl vars once early on is probably the way to go. 

--Matt Newville

Replies:
Re: pyepics not updating pv.enum_strs after connection Jameson Graef Rollins
References:
pyepics not updating pv.enum_strs after connection Jameson Graef Rollins
Re: pyepics not updating pv.enum_strs after connection Jameson Graef Rollins
Re: pyepics not updating pv.enum_strs after connection Matt Newville
Re: pyepics not updating pv.enum_strs after connection Jameson Graef Rollins

Navigate by Date:
Prev: RE: areaDetector to control Pilatus giles.knap
Next: Re: Error while staring archive engine in eclipse Kasemir, Kay
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  <20152016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: pyepics not updating pv.enum_strs after connection Jameson Graef Rollins
Next: Re: pyepics not updating pv.enum_strs after connection Jameson Graef Rollins
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  <20152016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 16 Dec 2015 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·