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  <20162017  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  <20162017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: CSS Boy Write PVs to file
From: "Kasemir, Kay" <[email protected]>
To: "Konrad, Martin" <[email protected]>
Cc: "[email protected]" <[email protected]>
Date: Thu, 22 Sep 2016 11:18:42 +0000
Hi:

On Sep 21, 2016, at 6:50 PM, Konrad, Martin <[email protected]> wrote:
Hi Iain,
I wish to save some Process Variables to a CSV file, but I
cannot figure out the code to retrieve the values from the PVs into
Python.
I think the problem here is that createPV doesn't create the PV
immediately. It takes some time to happen (I guess due to inter-thread
synchronization in CS-Studio). My understanding of the documentation is
that the actual create happens at a rate of 50 Hz (queue run or
something similar in the receiving thread). This means waiting a little
should fix your problem:

pv = PVUtil.createPV(widget.getPV)
time.sleep(0.1)
value = PVUtil.getDouble(pv)

The PV needs to connect. If you get the value right away, you’ll receive a null because the PV has not connected and not received the initial value, yet.

Waiting via a delay will often be sufficient, but
a) You should not wait within the script, i.e. on the UI thread, because otherwise you’ll next ask:
    Why does all of CSS freeze while my script is sleeping?
b) Sometimes you need to wait 3 seconds instead of 0.1.
    Better would be to add a listener to the PV which gets notified as values arrive.

Overall, performing logic like data acquisition should not be handled in the user interface.
The user interface can start, stop, monitor the data accusation, but data acquisition needs to be performed by some service.
For example, check the sscan record for IOCs, http://www.aps.anl.gov/bcda/synApps/sscan/sscanRecord.html:
You tell it to take data for some time, it uses data storage clients to write that to files.

-Kay


Replies:
RE: CSS Boy Write PVs to file Mark Rivers
RE: CSS Boy Write PVs to file Iain Marcuson
References:
Re: CSS Boy Write PVs to file Konrad, Martin

Navigate by Date:
Prev: Re: module for Keithley 6485 PA-meter Christoph Schroeder
Next: RE: CSS Boy Write PVs to file Mark Rivers
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: CSS Boy Write PVs to file Konrad, Martin
Next: RE: CSS Boy Write PVs to file Mark Rivers
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 22 Sep 2016 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·