Example #1
0
roiXgraph = pvs[6]
roiYgraph = pvs[7]
roiXpv    = pvs[8]
roiYpv    = pvs[9]
rocXgraph = pvs[10]
rocYgraph = pvs[11]
rocPV     = pvs[12]

xyGraph = widget

# axes limits from PV
xyGraph.getFigure().getXYGraph().primaryXAxis.setRange(posX_LOPR.getValue().getValue(), posX_HOPR.getValue().getValue())
xyGraph.getFigure().getXYGraph().primaryYAxis.setRange(posY_LOPR.getValue().getValue(), posY_HOPR.getValue().getValue())


xArray = DataUtil.createDoubleArray(4);
yArray = DataUtil.createDoubleArray(4);

# draw roi
xArray[0] = -roiXpv.getValue().getValue()
xArray[1] =  roiXpv.getValue().getValue()
xArray[2] =  roiXpv.getValue().getValue()
xArray[3] = -roiXpv.getValue().getValue()

yArray[0] =  roiYpv.getValue().getValue()
yArray[1] =  roiYpv.getValue().getValue()
yArray[2] = -roiYpv.getValue().getValue()
yArray[3] = -roiYpv.getValue().getValue()
roiXgraph.setValue(xArray)
roiYgraph.setValue(yArray)
Example #2
0
from org.csstudio.opibuilder.scriptUtil import PVUtil, DataUtil
import math

ref_orbit_pv = pvArray[0]
bpm_pos_pv   = pvArray[1]
orbit_pv     = pvArray[2]
y_pv         = pvArray[3]

try:
    bpm_pos   = PVUtil.getDoubleArray(bpm_pos_pv)
    ref_orbit = PVUtil.getDoubleArray(ref_orbit_pv)
    orbit     = PVUtil.getDoubleArray(orbit_pv)
    
    y = DataUtil.createDoubleArray(len(orbit))
    for i in range(len(orbit)):
        y[i] = orbit[i] - ref_orbit[i]
    
    y_pv.setValue(y)
    
    # Set y axis limits
    abs_y = [math.fabs(i) for i in y]
    default = 10
    maximum = max(abs_y) if len(abs_y) > 0 else default
    if maximum <= default:
        widget.setPropertyValue("axis_1_maximum",  default)
        widget.setPropertyValue("axis_1_minimum", -default)
    else:
        widget.setPropertyValue("axis_1_maximum",  maximum)
        widget.setPropertyValue("axis_1_minimum", -maximum)
except:
    pass
Example #3
0
from org.csstudio.opibuilder.scriptUtil import PVUtil, DataUtil, FileUtil, ConsoleUtil
from time import sleep

numBPM = 160
ref_orbit_x_pv = widget.getMacroValue("ref_orbit_x_ioc")
ref_orbit_x_sel_pv = widget.getMacroValue("ref_orbit_x_ioc_sel")
ref_orbit_y_pv = widget.getMacroValue("ref_orbit_y_ioc")
ref_orbit_y_sel_pv = widget.getMacroValue("ref_orbit_y_ioc_sel")

try:
        orbit_x = DataUtil.createDoubleArray(numBPM)
        orbit_y = DataUtil.createDoubleArray(numBPM)
        orbit_file = widget.getPropertyValue("label")
        if orbit_file == "":
                ConsoleUtil.writeError("Reference orbit must be defined. Load a file first.")
                raise
        orbit_xy_data = open(orbit_file).readlines()
        orbit_x_data, orbit_y_data = orbit_xy_data[:len(orbit_xy_data)//2], orbit_xy_data[len(orbit_xy_data)//2:]
        for i in range(len(orbit_x_data)):
                orbit_x[i] = float(orbit_x_data[i])
        for i in range(len(orbit_y_data)):
                orbit_y[i] = float(orbit_y_data[i])
        PVUtil.writePV(ref_orbit_x_sel_pv, 2)
        sleep(.5)
        PVUtil.writePV(ref_orbit_y_sel_pv, 2)
        sleep(.5)
        PVUtil.writePV(ref_orbit_x_pv, orbit_x)
        sleep(.5)
        PVUtil.writePV(ref_orbit_y_pv, orbit_y)
except:
        pass