And the mbbi record used in this demo:
1 record(mbbi, "status") {
2 field("VAL", 3)
3 field("ZRST", "Level0")
4 field("ONST", "Level1")
5 field("TWST", "Level2")
6 field("THST", "Level3")
7 field("PINI", "1")
8 }
On 2/19/19 9:25 AM, Tong Zhang wrote:
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 Matt Newville 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
- Re: Issue of PV callback of PyEpics Tong Zhang via Tech-talk
- Navigate by Date:
- Prev:
Re: Issue of PV callback of PyEpics Tong Zhang via Tech-talk
- Next:
Re: Stream device - parsing array of pairs of floats Johnson, Andrew N. 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
<2019>
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
Re: Issue of PV callback of PyEpics Tong Zhang via Tech-talk
- Next:
Re: Issue of PV callback of PyEpics Matt Newville 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
<2019>
2020
2021
2022
2023
2024
|