The underlying epics.ca module has the code required to ask for a value and wait for a reply:
epics.ca.get(chid, ftype=None, count=None, as_string=False, as_numpy=True, wait=True, timeout=None)
(set wait==True to wait for a reply)
but (from a cursory look at the online docs) it looks like this capability is not exposed either by epics.caget() or via PV().
Tim Mooney ([email protected]) (630)252-5417
Software Services Group (www.aps.anl.gov)
Advanced Photon Source, Argonne National Lab
________________________________________
From: [email protected] [[email protected]] on behalf of Mark Rivers [[email protected]]
Sent: Thursday, August 14, 2014 9:06 PM
To: Jameson Graef Rollins; EPICS tech-talk
Subject: RE: pyepics problem with PV.put(wait=True)
Hi Jamie,
I suspect you are seeing a race condition.
The pv class by default sets the auto_monitor parameter to True. This means that a CA monitor is put on the PV and PV.get just returns the last monitored value.
When you do pv.put(i, wait=True) that waits for the record to be processed, and all other records that process as a direct result of that record processing. However, it does NOT wait for all CA monitor callbacks to complete.
You are doing pv.get immediately after the pv.put, and I suspect that the CA monitor callback has simply not had time to run. I am not that familiar with the way that multi-threading works in Python, so I am not sure if you need to do anything to allow the CA callback a chance to happen between your pv.put and pv.get.
I think you can eliminate the problem by setting auto_monitor=False when you create the pv object.
Mark
________________________________________
From: [email protected] [[email protected]] on behalf of Jameson Graef Rollins [[email protected]]
Sent: Thursday, August 14, 2014 7:18 PM
To: EPICS tech-talk
Subject: pyepics problem with PV.put(wait=True)
Hi, folks. I'm seeing what might be a bug in the behavior of PVs in the
pyepics interface, or at the very least something inconsistent with
advertised behavior.
I'm trying to use the wait=True option to PV.put() to wait for process
completion, after which I want to log the put action. Here's a basic
example:
#!/usr/bin/env python
>From epics import PV
pv = PV('T1:TEST-SYS_B')
for i in range(10):
pv.put(i, wait=True)
print pv.get()
However, what I'm consistently getting as output from the above is
something like the following:
0.0
0.0
2.0
3.0
3.0
4.0
6.0
6.0
8.0
9.0
Note that the output is not at all what is expected: on three out of ten
writes a pv.get() immediately following a pv.put(wait=True) fails to
return the newly updated value. I see the same failures if I instead
set use_complete=True and check for put_complete==True before issuing
pv.get().
If the put() has actually completed, why is the get() still seeing the
old value?
Thanks in advance for any help or suggestions.
jamie.
- References:
- pyepics problem with PV.put(wait=True) Jameson Graef Rollins
- RE: pyepics problem with PV.put(wait=True) Mark Rivers
- Navigate by Date:
- Prev:
Re: Web OPI Xinyu.Wu
- Next:
Re: pyepics problem with PV.put(wait=True) 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>
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
RE: pyepics problem with PV.put(wait=True) Mark Rivers
- Next:
Re: pyepics problem with PV.put(wait=True) Matt Newville
- 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
|