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 | 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 |
<== Date ==> | <== Thread ==> |
---|
Subject: | Re: pyepics callback |
From: | Matt Newville via Tech-talk <[email protected]> |
To: | Alfio Rizzo <[email protected]> |
Cc: | "[email protected]" <[email protected]> |
Date: | Mon, 9 Sep 2019 10:50:21 -0500 |
Hi
I made a simple python script to get the updated value of my PV
with a simple callback function :
import epics
import time
def onChanges(**kw):
print ('PV Changed! ', kw["pvname"], kw["value"], kw["units"], time.ctime())
mypv = epics.PV("TCU6:RF")
mypv.add_callback(onChanges)
while True:
pass
The issue is that the unit is shown as None even if it defined in the .db
PV Changed! TCU6:RF -39.69 None Mon Sep 9 15:03:58 2019
PV Changed! TCU6:RF -39.73 None Mon Sep 9 15:03:59 2019
PV Changed! TCU6:RF -39.71 None Mon Sep 9 15:04:00 2019
PV Changed! TCU6:RF -39.7 None Mon Sep 9 15:04:01 2019
PV Changed! TCU6:RF -39.67 None Mon Sep 9 15:04:02 2019
But if I add this line on the script before to add the callback
……
mypv.units
mypv.add_callback(onChanges)
……
Then when I restart the script it shows the unit correctly
PV Changed! TCU6:RF -39.79 dBm Mon Sep 9 15:04:31 2019
PV Changed! TCU6:RF -39.71 dBm Mon Sep 9 15:04:32 2019
PV Changed! TCU6:RF -39.69 dBm Mon Sep 9 15:04:33 2019
Is this a bug/feature or I am doing something wrong ?