def main():
    # Figure out channel number
    channel = int(widget.getPropertyValue("name").replace("Channel ", ""))
    
    # Set up PVs
    gas_type_pv = pvs[0]
    helium_current_pv = pvs[1]
    
    # Check connection
    for _ in range(10):
        if gas_type_pv.isConnected() and helium_current_pv.isConnected():
            break
        else:
            sleep(0.1)
    else:
        ConsoleUtil.writeError("Error: Unable to connect to channel " + str(channel) + " PVs")
        return    
    
    # Hide some controls for Nitrogen channels
    is_nitrogen = gas_type_pv.getValue().getValue() == "Nitrogen"
    has_helium_current = helium_current_pv.getValue().getValue() == "On"
        
    hide_widget_names = []
    if is_nitrogen or has_helium_current:
        hide_widget_names += [
            "Scan rate " + str(channel) + " label",
            "Scan rate " + str(channel) + " RBV", 
            "Scan rate " + str(channel) + " button",
        ]
    if is_nitrogen:
       hide_widget_names += [
           "Helium current " + str(channel) + " RBV",
           "Helium current " + str(channel) + " label",
       ]
    
    for widget_name in hide_widget_names:
        display.getWidget(widget_name).setVisible(False)
Beispiel #2
0
from org.csstudio.opibuilder.scriptUtil import PVUtil, DataUtil, FileUtil, ConsoleUtil

## Get Orbit Widgets Information
graph_orbit_x = display.getWidget("Graph Orbit X")
graph_orbit_y = display.getWidget("Graph Orbit Y")

orbit_x_pv = graph_orbit_x.getPV()
orbit_y_pv = graph_orbit_y.getPV()


## Save File
try:
    try:
        orbit_x = PVUtil.getDoubleArray(orbit_x_pv)
        orbit_y = PVUtil.getDoubleArray(orbit_y_pv)
        orbit_xy = orbit_x + orbit_y
    except:
        ConsoleUtil.writeError("Graphics PV must be defined. Choose a register first.")
        raise
    file = FileUtil.saveFileDialog(False)
    widget.setPropertyValue("label", file)

    orbit_xy_data = open(file, "w")
    for data in orbit_xy:
        orbit_xy_data.write("%s\n" % data)
    orbit_xy_data.close()
except:
    pass
 def pvChanged(self):
     value = pvReader.getValue()
     if value== None or pvReader.lastException() != None:
         ConsoleUtil.writeError(pvReader.lastException().toString())
         return;
     widget.setValue(pvReader.getValue().getArray());
Beispiel #4
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
from org.csstudio.opibuilder.scriptUtil import PVUtil
from org.csstudio.opibuilder.scriptUtil import ConsoleUtil
from time import sleep

remote_pv = widget.getPV();
setpoint_pv = PVUtil.createPV(widget.getPropertyValue("pv_name")+":SP", widget)
current_value = int(PVUtil.getDouble(remote_pv))
for _ in range(10):
    if remote_pv.isConnected() and setpoint_pv.isConnected():
        setpoint_pv.setValue(1 if current_value==0 else 0)
        break
    else:
        sleep(0.1)
else:
    ConsoleUtil.writeError("Error: Unable to connect to rate PVs")