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: | CSS Boy Write PVs to file |
From: | Iain Marcuson <[email protected]> |
To: | "[email protected]" <[email protected]> |
Date: | Wed, 21 Sep 2016 18:56:04 +0000 |
I am running CS-Studio 4.1.1 NSLSII on Windows 7 Professional. I am writing a GUI to interface to the IOC, using Python for the occasional scripts. 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 only want to save the data when the button is clicked, so I don’t think writing an embedded script is suit, and instead execute the script as an action. The example program (I/O omitted) is: from org.csstudio.opibuilder.scriptUtil import PVUtil from java.awt import EventQueue from javax.swing import JFrame from javax.swing import JOptionPane from javax.swing import JFileChooser from jarray import zeros from java.lang import Integer #Force refresh of trim PVs #This part doesn't crash for trim_idx in range(4): PVUtil.writePV("iainmtestSetTR{}.PROC".format(trim_idx+1),1,10000)
trim_dac = zeros(640,Integer); #This part runs, and values are printed #PVUtil.createPV() requires a widget print("About to try to create process variables") pvs = [] for pv_idx in range(4): pvs.append(PVUtil.createPV("iainmtestTR{}".format(pv_idx+1), widget)) print(pvs) #Try to retrieve the values from the PVs #Program fails below for pv_idx in range(4): trim_dac = PVUtil.getLongArray(pvs[pv_idx]) curr_row = []; for chan_idx in range(640): curr_row.append(str(trim_dac[chan_idx])) print(curr_row)
The output is: About to try to create process variables [org.csstudio.simplepv.pvmanager.PVManagerPV@6343ddb4, org.csstudio.simplepv.pvmanager.PVManagerPV@35a4c0a3, org.csstudio.simplepv.pvmanager.PVManagerPV@5a7d7484,
org.csstudio.simplepv.pvmanager.PVManagerPV@2fccb8d3] 2016-09-21 14:51:16 ERROR: Error exists in script DAC Trim Save pared.py Traceback (most recent call last): File "<script>", line 29, in <module> at org.csstudio.opibuilder.scriptUtil.PVUtil.checkPVValue(PVUtil.java:96) at org.csstudio.opibuilder.scriptUtil.PVUtil.getLongArray(PVUtil.java:150) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) java.lang.RuntimeException: java.lang.RuntimeException: PV iainmtestTR1 has no value. What do I need to change to retrieve the PVs. Thank you, Iain. |