From: Kasemir, K. <kas...@or...> - 2017-04-07 13:40:29
|
Moin Jonathan! ________________________________________ I have a bunch of PV's returning double values. I'd like to display them in a bar chart with every bar represents the current value of the PV. I figured that i can display an Array of Doubles in an xy graph widget and display the points as bars. But trying to create a local pv array with the list of PVs I want to display just does not want to work. Do I need a script to create the array and write it to the widget or is there a (possibly simple)way that I just missed. Or is there a better way to get a bar chart of the PV than what I suggested. ------------------------------------------------------------------------------ It would be best to create the array on an IOC. If the values are related, if they are meant to be elements in an array, then the IOC should provide them as such. As a fallback, you might want to try placing bar widgets 'real close' to each other, with scale turned off. Finally, you could use a script that reads the N scalars and writes their elements to one local array PV. Like this one, triggered by PVs scalar1, scalar2, .., scalarN and ending the list of PVs with loc://the_array(0, 0, 0): # Inputs: # N scalar PVs followed by one array PV # # Reads all the scalar PVs and writes their values # to the array PV from org.csstudio.opibuilder.scriptUtil import PVUtil from jarray import array N = len(pvs) data = [] for i in range(N-1): data.append(PVUtil.getDouble(pvs[i])) value = array(data, 'd') pvs[N-1].setValue(value) Using a PV name like loc://the_array(0, 0, 0) initializes the local PV as an array. The script should be self evident except for the jarray stuff: It converts the python list into a Java array that's then understood by the PV. With BOY, that script will impact the UI thread, so it's not a good idea for more then ~10 elements. You also might want to think about which PVs acutally 'trigger' the script. Certainly NOT the final loc://the_array. Maybe just the first scalar1, or just the last scalarN, but not all scalar* elements? -Kay |