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  <20112012  2013  2014  2015  2016  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  <20112012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: pyepics callback function problem
From: Matt Newville <[email protected]>
To: Janko Kolar <[email protected]>
Cc: [email protected]
Date: Thu, 6 Jan 2011 09:43:46 -0600
Hi Janko,

> I hope this is a right place to ask a question about pyepics.

I think it is.

> I wrote a simple program to monitor their value:
>
> import sys
> import time
> from epics import PV
>
> def callback_function(pvname=None, value=None, char_value=None,
> type=None,units=None, enum_strs=None, **kw):
>     print "------Printout from callback ------"
>     fmt = ' pvname \t = %s \n value \t\t = %s \n\
> char_value \t = %s \n type \t\t = %s \n\
> units \t\t = %s \n enum_strs \t = %s \n'
>     print fmt % (pvname, value, char_value, type, units, enum_strs)
>     print "----------------------------------\n"
>
> pll = PV('LUCA:ENV:ENV_SC_PLL_MONITOR')
>
> vent = PV('LUCA:ENV:ENV_FRONT_VENT_ACT_MONITOR')
>
> pll.add_callback(callback_function)
> pll.run_callbacks()
>
> vent.add_callback(callback_function)
> vent.run_callbacks()
>
> while True:
>     time.sleep(0.001)
>

Sorry for the trouble.

The issue is that not all of the "extra control fields" (including the
names of the enumeration states, units, and precision) have been
determined when you do PV.run_callbacks().  That is only the "native
form" of the PV

The easiest fix is to explicitly make the control fields be looked up,
either with PV.get_ctrlvars() or PV.get(as_string=True) which also
makes sure that the "char_value" is well formed.  That is, I think you
want

   pll.add_callback(callback_function)
   pll.get(as_string=True)
   pll.run_callbacks()

   vent.add_callback(callback_function)
   vent.get(as_string=True)
   vent.run_callbacks()

   while True:
       time.sleep(0.001)

Perhaps an option should be added to PV.add_callback() to make sure
the control fields are initialized.  Either that, or this should be
better documented.

--Matt Newville <newville at cars.uchicago.edu> 630-252-0431

Replies:
Re: pyepics callback function problem Janko Kolar
References:
pyepics callback function problem Janko Kolar

Navigate by Date:
Prev: Test, please ignore Benjamin Franksen
Next: Re: GPIB to ethernet converter Cyrus Reed
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  <20112012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: pyepics callback function problem Janko Kolar
Next: Re: pyepics callback function problem Janko Kolar
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  <20112012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 18 Nov 2013 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·