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 23:19:04 -0500
Hi Jamie,

On Thu, Mar 19, 2015 at 10:04 PM, Jameson Graef Rollins <[email protected]> wrote:
On Thu, Mar 19 2015, Matt Newville <[email protected]> wrote:
> 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(....)

The tricky bit is that for this application I do *not* want to connect
to the PV when it's being created, and I want all updates to happen from
the callbacks.  This is for a gui application that is connecting to many
PVs asynchronously.  Waiting for each individual PV to connect at
start-up would slow down the start up time considerably.  For this
application there's really no other time when the value can be retrieved
"as_string" so that enum_strs is updated without having to bring the
user into the process somehow (at least I have yet to figure out how).

I think it kind of depends what you're trying to do.  FWIW, I have lots of GUIs that display Epics variables and get control values in a "lazy manner".    Generally, one can create a PV, then ask some function to be run when the GUI is not busy where you wait-for-connection, get the control variables, and add callbacks (in the case where the widgets don't even exist when the PV is created-without-connection).   Another approach would be to use a Timer loop look for newly connected PVs (those for which pv.connected was False and is now True) and finish setting up the pvs as they connect (including getting ctrl vars).

Is there really no other option? 

There are always options!
 
I still don't understand why the
enum_strs attribute can't just be updated automatically when the
connection is first made, without having to retrieve it manually at some
point.  It would certainly make things easier from my perspective.

That would be possible.  It's not clear to me that every PV always needs CTRL variables to be fetched as part of the automatic connection process -- I might be persuaded to add this as an option,, but am not certain it's necessarily always a good idea.    It might slow down the connection (I have not profiled it carefully), but it's probably acceptable in many situations.

--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
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: pyepics not updating pv.enum_strs after connection Jameson Graef Rollins
Next: Registration Open for the Spring 2015 EPICS Collaboration Meeting Spring 2015 EPICS Collaboration Meeting
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 ·