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  2015  2016  2017  2018  <20192020  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  2015  2016  2017  2018  <20192020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: Issue of PV callback of PyEpics
From: Tong Zhang via Tech-talk <[email protected]>
To: [email protected]
Date: Tue, 19 Feb 2019 09:25:32 -0500
mypv.get(as_string=True) returns the string value as expected. Please see the detailed constructed fully functional demo below:

Script works as expected with mbbi record:

  7 import epics
  8 import time
  9
 10
 11 pv_name = 'INVALID_PV_NAME'
 12
 13 def pv_with_callback(pv_name):
 14     pv = epics.PV(pv_name)
 15     time.sleep(2)
 16     def on_value_changed(char_value, **kws):
 17         print("Char Value: ", char_value)
 18     pv.add_callback(on_value_changed)
 19
 20
 21 pv_with_callback(pv_name)
 22
 23 time.sleep(2)
 24 pv_name = 'status'
 25
 26 pv_with_callback(pv_name)

If commented out line 15th, and run it again, the behavior is changed, only value is returned in the callback rather than expected char_value.

This typically is the case when switching from one PV from another PV, while not all of them are reachable in the controls network.

Thanks,
Tong

On 2/18/19 5:49 PM, Matthew Newville via Tech-talk wrote:


On Mon, Feb 18, 2019, 4:30 PM Zhang, Tong via Tech-talk <[email protected] <mailto:[email protected]> wrote:

    Hello,

    When I work with PyEpics.PV object, I've found sometimes the value
    of 'char_value' in the added callback just return what 'value' meant
    to be. I tried with a MBBI type record, it should be expected as a
    string in the callback, but an integer was got. Could somebody let
    me know what is the possible reason?


An mbbi record definitely should return the appropriate string in 'char_value' in a callback.  That does need to be able to lookup the CTRL values, especially including the enumeration strings.

Can you do
     mypv = epics.PV(pvname)
     print(mypv.get(as_string=True))
     print(mypv.get_info())

and see the enumeration strings?

Matt

Replies:
Re: Issue of PV callback of PyEpics Tong Zhang via Tech-talk
References:
Issue of PV callback of PyEpics Zhang, Tong via Tech-talk
Re: Issue of PV callback of PyEpics Matthew Newville via Tech-talk

Navigate by Date:
Prev: Re: Problems with StreamDevice Dirk Zimoch via Tech-talk
Next: Re: Issue of PV callback of PyEpics Tong Zhang via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  <20192020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: Issue of PV callback of PyEpics Matthew Newville via Tech-talk
Next: Re: Issue of PV callback of PyEpics Tong Zhang via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  <20192020  2021  2022  2023  2024 
ANJ, 19 Feb 2019 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·