def _add_line(table, line_opi, device): linkingContainer = WidgetUtil.createWidgetModel("org.csstudio.opibuilder.widgets.linkingContainer") linkingContainer.setPropertyValue("opi_file", line_opi) linkingContainer.setPropertyValue("resize_behaviour", 1) linkingContainer.setPropertyValue("border_style", 0) table.addChildToBottom(linkingContainer) children = linkingContainer.getChildren() for w in children: if w.getPropertyValue("widget_type") == "Grouping Container": container = w button = container.getChildren()[0] led = container.getChildren()[1] setpoint = prefix + device.upper() + sufix readback = prefix + device.upper() + '-RB' button.setPropertyValue("pv_name", setpoint) led.setPropertyValue("pv_name", readback) macro_inputs = DataUtil.createMacrosInput(True) macro_inputs.put("device", device) macro_inputs.put("power_supply_sp", setpoint) macro_inputs.put("power_supply_rb", readback) linkingContainer.setPropertyValue("macros", macro_inputs)
def add_line(table, line_opi, power_supply): linkingContainer = WidgetUtil.createWidgetModel("org.csstudio.opibuilder.widgets.linkingContainer") linkingContainer.setPropertyValue("opi_file", line_opi) linkingContainer.setPropertyValue("resize_behaviour", 1) linkingContainer.setPropertyValue("border_style", 0) table.addChildToBottom(linkingContainer) children = linkingContainer.getChildren() for w in children: if w.getPropertyValue("widget_type") == "Action Button": button = w elif w.getPropertyValue("widget_type") == "Spinner": spinner = w elif w.getPropertyValue("widget_type") == "Text Update": text_update = w elif w.getPropertyValue("widget_type") == "Grouping Container": container = w led = container.getChildren()[0] setpoint = subsystem + power_supply.upper() + '-SP' readback = subsystem + power_supply.upper() + '-RB' button.setPropertyValue("text", power_supply.replace("-FAM", "")) spinner.setPropertyValue("pv_name", setpoint) text_update.setPropertyValue("pv_name", readback) led.setPropertyValue("pv_name", '$(power_supply_status)') macro_inputs = DataUtil.createMacrosInput(True) macro_inputs.put("power_supply", power_supply) macro_inputs.put("power_supply_sp", setpoint) macro_inputs.put("power_supply_rb", readback) macro_inputs.put("power_supply_start", 'sim://const("sextupole")') linkingContainer.setPropertyValue("macros", macro_inputs)
def selectionChanged(self, selection): cuIndex="" phyName="" for row in selection: cuIndex=row[0]; phyName=row[1] # change $(CU_INDEX) substitution macroInput = DataUtil.createMacrosInput(True) macroInput.put("CUB", cuIndex) macroInput.put("PHY_NAME", phyName) macroInput.put("FCT_NAME", fct_name) # open OPI # see https://svnpub.iter.org/codac/iter/codac/dev/units/m-css-boy/trunk/org.csstudio.opibuilder/src/org/csstudio/opibuilder/scriptUtil/ScriptUtil.java ScriptUtil.openOPI(display.getWidget("Table"), fct_name+"-CubicleDetails.opi", 1, macroInput)
def selectionChanged(self, selection): cuIndex = "" phyName = "" for row in selection: cuIndex = row[0] phyName = row[1] # change $(CU_INDEX) substitution macroInput = DataUtil.createMacrosInput(True) macroInput.put("CUB", cuIndex) macroInput.put("PHY_NAME", phyName) macroInput.put("FCT_NAME", fct_name) # open OPI # see https://svnpub.iter.org/codac/iter/codac/dev/units/m-css-boy/trunk/org.csstudio.opibuilder/src/org/csstudio/opibuilder/scriptUtil/ScriptUtil.java ScriptUtil.openOPI(display.getWidget("Table"), fct_name + "-CubicleDetails.opi", 1, macroInput)
def selectionChanged(self, selection): cuName = "" phyName = "" for row in selection: phyName = row[1] cuName = row[0] # change $(CU) substitution macroInput = DataUtil.createMacrosInput(True) macroInput.put("CU", cuName) macroInput.put("PHY_NAME", phyName) macroInput.put("FCT_NAME", fct_name) # open OPI # see https://svnpub.iter.org/codac/iter/codac/dev/units/m-css-boy/trunk/org.csstudio.opibuilder/src/org/csstudio/opibuilder/scriptUtil/ScriptUtil.java if cuName.startswith("P"): ScriptUtil.openOPI(display.getWidget("Table"), fct_name + "-PLCDetails.opi", 1, macroInput) else: ScriptUtil.openOPI(display.getWidget("Table"), fct_name + "-CubiclePLCDetails.opi", 0, macroInput)
def selectionChanged(self, selection): cuName="" phyName="" plcIocHlts ="" for row in selection: phyName=row[1] cuName=row[0] plcIocHlts=row[6]; # change $(CU) substitution macroInput = DataUtil.createMacrosInput(True) macroInput.put("CU", cuName) macroInput.put("PHY_NAME", phyName) macroInput.put("FCT_NAME", fct_name) if plcIocHlts == "": macroInput.put("SHOW_PLC_IOC", "false") else: macroInput.put("SHOW_PLC_IOC", "true") # open OPI # see https://svnpub.iter.org/codac/iter/codac/dev/units/m-css-boy/trunk/org.csstudio.opibuilder/src/org/csstudio/opibuilder/scriptUtil/ScriptUtil.java ScriptUtil.openOPI(display.getWidget("Table"), fct_name+"-CtrlUnitDetails.opi", 1, macroInput)
def selectionChanged(self, selection): cuName = "" phyName = "" for row in selection: phyName = row[1] cuName = row[0] # change $(CU) substitution macroInput = DataUtil.createMacrosInput(True) macroInput.put("CU", cuName) macroInput.put("PHY_NAME", phyName) macroInput.put("FCT_NAME", fct_name) # open OPI # see https://svnpub.iter.org/codac/iter/codac/dev/units/m-css-boy/trunk/org.csstudio.opibuilder/src/org/csstudio/opibuilder/scriptUtil/ScriptUtil.java if cuName.startswith('P'): ScriptUtil.openOPI(display.getWidget("Table"), fct_name + "-PLCDetails.opi", 1, macroInput) else: ScriptUtil.openOPI(display.getWidget("Table"), fct_name + "-CubiclePLCDetails.opi", 0, macroInput)
def selectionChanged(self, selection): cuName = "" phyName = "" plcIocHlts = "" for row in selection: phyName = row[1] cuName = row[0] plcIocHlts = row[6] # change $(CU) substitution macroInput = DataUtil.createMacrosInput(True) macroInput.put("CU", cuName) macroInput.put("PHY_NAME", phyName) macroInput.put("FCT_NAME", fct_name) if plcIocHlts == "": macroInput.put("SHOW_PLC_IOC", "false") else: macroInput.put("SHOW_PLC_IOC", "true") # open OPI # see https://svnpub.iter.org/codac/iter/codac/dev/units/m-css-boy/trunk/org.csstudio.opibuilder/src/org/csstudio/opibuilder/scriptUtil/ScriptUtil.java ScriptUtil.openOPI(display.getWidget("Table"), fct_name + "-CtrlUnitDetails.opi", 1, macroInput)
from org.csstudio.opibuilder.scriptUtil import PVUtil from org.csstudio.opibuilder.scriptUtil import DataUtil macroInput = DataUtil.createMacrosInput(True) pvvalue = display.getWidget("eemem_read_value_combo").getValue() macroInput.put("EEMEM_VALUE", "%s" % pvvalue) widgetController.setPropertyValue("macros", macroInput) widgetController.setPropertyValue( "opi_file", widgetController.getPropertyValue("opi_file"), True)
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
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)
from org.csstudio.opibuilder.scriptUtil import PVUtil from org.csstudio.opibuilder.scriptUtil import DataUtil macroInput = DataUtil.createMacrosInput(True) boxpv = widget.getPVByName("loc://monitor_box") boxnumber = PVUtil.getLong(boxpv) macroInput.put("BOXNO", "%s" % boxnumber) macroInput.put("BOX", "BOX:%s" % boxnumber) macroInput.put("P", "CB:CB:HV") widgetController.setPropertyValue("macros", macroInput) widgetController.setPropertyValue("opi_file", widgetController.getPropertyValue("opi_file"), True)
# FOFB fofb_corr_h_locpv = "loc://fofb_corr_h(0)" fofb_corr_v_locpv = "loc://fofb_corr_v(0)" fofb_corr_coupling_locpv = "loc://fofb_coupling(0)" # Features feature_type_locpv = "loc://feature_type(0)" ## Control Panel # Get Widgets control_panel = display.getWidget("Control Panel") # Set Macros control_panel_macros = DataUtil.createMacrosInput(True) control_panel_macros.put("ref_orbit_x_ioc", ref_orbit_x_pv) control_panel_macros.put("orbit_x_ioc", orbit_x_pv) control_panel_macros.put("ref_orbit_x_ioc_sel", ref_orbit_x_sel_pv) control_panel_macros.put("ref_orbit_y_ioc", ref_orbit_y_pv) control_panel_macros.put("orbit_y_ioc", orbit_y_pv) control_panel_macros.put("ref_orbit_y_ioc_sel", ref_orbit_y_sel_pv) control_panel_macros.put("ref_orbit_x_graph", ref_orbit_x_locpv) control_panel_macros.put("orbit_x_graph", orbit_x_locpv) control_panel_macros.put("delta_orbit_x", delta_orbit_x_locpv) control_panel_macros.put("ref_orbit_y_graph", ref_orbit_y_locpv) control_panel_macros.put("orbit_y_graph", orbit_y_locpv) control_panel_macros.put("delta_orbit_y", delta_orbit_y_locpv) control_panel_macros.put("bpm_pos", bpm_pos_pv) control_panel_macros.put("register", register_locpv) control_panel_macros.put("display_mode", display_mode_locpv)
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