def run(self): while display.isActive(): scan_id = long(display.getVar("LatestPointScanID")) if scan_id > 0: scanInfo = client.getScanInfo(scan_id) statusLabel.setPropertyValue("text", scanInfo.getState().toString()) if scanInfo.getState().isActive(): scanNameLabel.setPropertyValue("text", scanInfo.getName()) commandLabel.setPropertyValue("text", scanInfo.getCurrentCommand()) progressBar.setPropertyValue( "pv_value", scanInfo.getPercentage() / 100.0) # Mark scanned points as green for i in range(table.getRowCount()): xpos = float(table.getCellText(i, 1)) ypos = float(table.getCellText(i, 2)) if ( xpos == PVUtil.getDouble(pvs[1]) and ypos == PVUtil.getDouble(pvs[2]) and scanInfo.getPercentage() >= i * 100.0 / table.getRowCount() ): #To make sure the matched position is set from this scan Display.getDefault().asyncExec( SetRowColor(i, ColorFontUtil.GREEN)) elif scanInfo.getState().isDone(): display.setVar("LatestPointScanID", -1) else: scanNameLabel.setPropertyValue("text", "None") commandLabel.setPropertyValue("text", "") progressBar.setPropertyValue("pv_value", 0) Thread.sleep(1000)
def run(self): while display.isActive(): scanInfos = client.server.getScanInfos() findActive = False markedDone = False for scanInfo in scanInfos: if scanInfo.getId() == long( display.getVar("LatestPointScanID")): statusLabel.setPropertyValue( "text", scanInfo.getState().toString()) if scanInfo.getState().isDone(): #mark table to dark gray if it is done. if scanInfo.getId() == long( display.getVar( "LatestPointScanID")) and not markedDone: for i in range(table.getRowCount()): Display.getDefault().asyncExec( SetRowColor(i, ColorFontUtil.DARK_GRAY)) markedDone = True continue if scanInfo.getState().isActive(): scanNameLabel.setPropertyValue("text", scanInfo.getName()) commandLabel.setPropertyValue("text", scanInfo.getCurrentCommand()) progressBar.setPropertyValue( "pv_value", scanInfo.getPercentage() / 100.0) #Mark scanned points as green if scanInfo.getId() == long( display.getVar("LatestPointScanID")): markedDone = False for i in range(table.getRowCount()): xpos = float(table.getCellText(i, 1)) ypos = float(table.getCellText(i, 2)) if ( xpos == PVUtil.getDouble(pvs[1]) and ypos == PVUtil.getDouble(pvs[2]) and scanInfo.getPercentage() >= i * 100.0 / table.getRowCount() ): #To make sure the matched position is set from this scan Display.getDefault().asyncExec( SetRowColor(i, ColorFontUtil.GREEN)) findActive = True if not findActive: scanNameLabel.setPropertyValue("text", "None") commandLabel.setPropertyValue("text", "") progressBar.setPropertyValue("pv_value", 0) Thread.sleep(200)
def update_channels(this_display, this_pvs): """ Updates the channels available on the summary maintenance page Args: this_display: The display that has called this script. Used to control modification of global CSS variables this_pvs: PVs passed to the script by CSS. Used to control modification of global CSS variables Returns: None """ # Loop through the channels, and if selected add them to the list actioned = PVUtil.getDouble(this_pvs[0]) == 1 if actioned: # Generate the list of included channel names channel_names = list() for crate, slot, channel in get_available_channels(this_pvs[1:1 + get_max_crates(this_display)], this_display): channel_name = get_channel_pv_name(crate, slot, channel) if this_display.getWidget(channel_name).getChild('Include').getValue() == 1: channel_names.append(channel_name) # Create a PV value based on the channel names new_pv_value = " ".join(channel_names) this_display.getWidget('update').getPV().setValue(new_pv_value)
def run(self): simuData = array.array('d', range(65536)) value = PVUtil.getDouble(pvs[0]) dataSrc = PVUtil.getString(pvs[1]) if dataSrc == "Linear Sine Wave": for i in range(256): for j in range(256): simuData[i * 256 + j] = math.sin(j * 6 * math.pi / 256 + i * 6 * math.pi / 256 + value) else: for i in range(256): for j in range(256): x = j - 128 y = i - 128 p = math.sqrt(x * x + y * y) simuData[i * 256 + j] = math.sin(p * 2 * math.pi / 256 + value) class UITask(Runnable): def run(self): widget.setValue(simuData) UIBundlingThread.getInstance().addRunnable(currentDisplay, UITask())
def check_interlock(): interlock_optical = PVUtil.getDouble(interlock_optical_pv) interlock_experimental = PVUtil.getDouble(interlock_experimental_pv) if (interlock_optical != interlock_experimental): status_pv.setValue("Necessitamos de feixe nas estacoes experimentais") #ConsoleUtil.writeInfo ("Necessitamos de feixe nas estacoes experimentais") raise ValueError("Necessitamos de feixe nas estacoes experimentais") elif (interlock_optical == 0): status_pv.setValue("Necessitamos de feixe nas estacoes experimentais") #ConsoleUtil.writeInfo ("Necessitamos de feixe nas estacoes experimentais") raise ValueError("Necessitamos de feixe nas estacoes experimentais") else: status_pv.setValue( "Feixe nas estacoes experimentais - Experimento liberado") ConsoleUtil.writeInfo( "Feixe nas estacoes experimentais - Experimento liberado")
def getWidgetPVDouble(display, widget): """Fetch value of a widget's PV @param display BOY Display @param widget Widget name @return Value of that PV as double """ pv = display.getWidget(widget).getPV() return PVUtil.getDouble(pv)
def getWidgetPVDouble(display, widget): """Fetch value of a widget's PV @param display BOY Display @param widget Widget name @return Value of that PV as double """ pv = display.getWidget(widget).getPV() return PVUtil.getDouble(pv);
def check_mono_enconder(): encoder_mono = PVUtil.getDouble(enconder_mono_pv) position_monotheta = PVUtil.getDouble(position_monotheta_pv) diff = abs(encoder_mono - position_monotheta) if (diff > 0.1): status_pv.setValue( "Leitura incorreta do encoder. Faca o procedimento para a busca da posicao de referencia" ) #ConsoleUtil.writeInfo ("Leitura incorreta do encoder. Faca o procedimento para a busca da posicao de referencia") raise ValueError( "Leitura incorreta do encoder. Faca o procedimento para a busca da posicao de referencia" ) else: status_pv.setValue("Leitura correta do encoder - Experimento liberado") ConsoleUtil.writeInfo( "Leitura correta do encoder - Experimento liberado")
def run(self): element = PVUtil.getString(pvs[1]) edge = PVUtil.getString(pvs[2]) vacuum_press = PVUtil.getString(pvs[3]) default_press = PVUtil.getString(pvs[4]) wait_purge = PVUtil.getString(pvs[5]) wait_vacuum = PVUtil.getString(pvs[6]) argon_order = int(PVUtil.getDouble(pvs[7])) helium_order = int(PVUtil.getDouble(pvs[8])) nitrogen_order = int(PVUtil.getDouble(pvs[9])) ConsoleUtil.writeInfo("Element: " + str(element)) ConsoleUtil.writeInfo("Edge: " + str(edge)) ConsoleUtil.writeInfo("Vacuum_press: " + str(vacuum_press)) ConsoleUtil.writeInfo("Default_press: " + str(default_press)) ConsoleUtil.writeInfo("Wait_purge: " + str(wait_purge)) ConsoleUtil.writeInfo("Wait_vacuum: " + str(wait_vacuum)) ConsoleUtil.writeInfo("Argon_order: " + str(argon_order)) ConsoleUtil.writeInfo("Helium_order: " + str(helium_order)) ConsoleUtil.writeInfo("Nitrogen_order: " + str(nitrogen_order)) command = [ 'gass', str(element), str(edge), "--pressureVacuum=" + str(vacuum_press), "--pressureWork=" + str(default_press), "--extraTimeManifold=" + str(wait_purge), "--extraTimeManifoldVacuum=" + str(wait_vacuum), "--argonOrder=" + str(argon_order), "--heliumOrder=" + str(helium_order), "--nitrogenOrder=" + str(nitrogen_order) ] #command = ['python3.4', '/usr/local/bin/gass', '-h'] #command = ['gass', '-h'] #command = "gass %s %s" % (str(element), str(edge)) ConsoleUtil.writeInfo("command: " + str(command)) #pvs[0].setValue(0) subprocess.call(command)
def mono_position_height(): initial_energy = PVUtil.getDouble(initial_energy_pv) final_energy = PVUtil.getDouble(final_energy_pv) actual_height = PVUtil.getDouble(actual_height_pv) velo_height = PVUtil.getDouble(velo_height_pv) #calculations offset = 18.0 #offset_DCM h = 6.62606896E-34 ev = 1.602176565E-19 c = 299792458 d = 3.13542 hcort_c = h / ev * c / 1E-10 initial_theta = math.asin(1.2398E4 / (2 * initial_energy * math.pi)) final_theta = math.asin(1.2398E4 / (2 * final_energy * math.pi)) initial_height = offset * math.sin(initial_theta) / math.sin( 2 * initial_theta) final_height = offset * math.sin(final_theta) / math.sin(2 * final_theta) height = (initial_height + final_height) / 2 theta_calc = math.acos(offset / (2 * height)) energy = hcort_c / (2 * d * math.sin(theta_calc)) # moving motors to calculated positions # energy_theta #ConsoleUtil.writeInfo ("Movendo os motores para as posicoes calculadas..."); #ConsoleUtil.writeInfo ("E = "); #ConsoleUtil.writeInfo (str(energy)); move_motor(energy_pv, energy) #height second crystal height_before = height + 0.1 move_motor(actual_height_pv, height_before, height_motor_dmov_pv, True) #ConsoleUtil.writeInfo ("height_before = "); #ConsoleUtil.writeInfo (str(height_before)); move_motor(actual_height_pv, height, height_motor_dmov_pv, True)
def get_pvs(self): self.north = PVUtil.getDouble(pvs[0]) self.south = PVUtil.getDouble(pvs[1]) self.east = PVUtil.getDouble(pvs[2]) self.west = PVUtil.getDouble(pvs[3]) self.max_y = PVUtil.getDouble(pvs[4]) self.max_x = PVUtil.getDouble(pvs[5])
def copy_pvs(this_display, this_pvs): """ Copies PVs Args: this_display: The display that has called this script. Used to control modification of global CSS variables this_pvs: PVs passed to the script by CSS. Used to control modification of global CSS variables List of PVs, first one is the trigger, then in pairs which copy to their partner. E.g: ["trigger", "PVA-source", "PVA-target", "PVB-source", "PVB-target", "PVC-source", "PVC-target", ] Returns: None """ # Make sure this has been triggered, then reset the trigger actioned = PVUtil.getDouble(this_pvs[0]) == 1 this_pvs[0].setValue(0) if actioned: these_pvs = iter(this_pvs) # Skip the trigger PV these_pvs.next() # Iterate through PVs, copying every other PV to the next one for value in these_pvs: these_pvs.next().setValue(PVUtil.getDouble(value))
def run(self): while display.isActive(): scan_id = long(display.getVar("LatestPointScanID")) if scan_id > 0: scanInfo = client.getScanInfo(scan_id) statusLabel.setPropertyValue("text", scanInfo.getState().toString()) if scanInfo.getState().isActive(): scanNameLabel.setPropertyValue("text", scanInfo.getName()) commandLabel.setPropertyValue("text", scanInfo.getCurrentCommand()) progressBar.setPropertyValue("pv_value", scanInfo.getPercentage()/100.0) # Mark scanned points as green for i in range(table.getRowCount()): xpos=float(table.getCellText(i, 1)) ypos=float(table.getCellText(i, 2)) if (xpos == PVUtil.getDouble(pvs[1]) and ypos==PVUtil.getDouble(pvs[2]) and scanInfo.getPercentage() >= i*100.0/table.getRowCount()): #To make sure the matched position is set from this scan Display.getDefault().asyncExec(SetRowColor(i, ColorFontUtil.GREEN)) elif scanInfo.getState().isDone(): display.setVar("LatestPointScanID", -1) else: scanNameLabel.setPropertyValue("text", "None") commandLabel.setPropertyValue("text", "") progressBar.setPropertyValue("pv_value", 0) Thread.sleep(1000)
def run(self): while display.isActive(): scanInfos = client.server.getScanInfos() findActive = False markedDone = False for scanInfo in scanInfos: if scanInfo.getId() == long(display.getVar("LatestPointScanID")): statusLabel.setPropertyValue("text", scanInfo.getState().toString()) if scanInfo.getState().isDone(): #mark table to dark gray if it is done. if scanInfo.getId() == long(display.getVar("LatestPointScanID")) and not markedDone : for i in range(table.getRowCount()): Display.getDefault().asyncExec(SetRowColor(i, ColorFontUtil.DARK_GRAY)) markedDone=True continue if scanInfo.getState().isActive(): scanNameLabel.setPropertyValue("text", scanInfo.getName()) commandLabel.setPropertyValue("text", scanInfo.getCurrentCommand()) progressBar.setPropertyValue("pv_value", scanInfo.getPercentage()/100.0) #Mark scanned points as green if scanInfo.getId() == long(display.getVar("LatestPointScanID")): markedDone=False for i in range(table.getRowCount()): xpos=float(table.getCellText(i, 1)) ypos=float(table.getCellText(i, 2)) if (xpos == PVUtil.getDouble(pvs[1]) and ypos==PVUtil.getDouble(pvs[2]) and scanInfo.getPercentage() >= i*100.0/table.getRowCount()): #To make sure the matched position is set from this scan Display.getDefault().asyncExec(SetRowColor(i, ColorFontUtil.GREEN)) findActive=True if not findActive: scanNameLabel.setPropertyValue("text", "None") commandLabel.setPropertyValue("text", "") progressBar.setPropertyValue("pv_value", 0) Thread.sleep(200)
def run(self): #this method must be called in UI thread leftAnnotation.setValues(PVUtil.getDouble(leftPV), leftAnnotation.getYValue()) rightAnnotation.setValues(PVUtil.getDouble(rightPV), rightAnnotation.getYValue())
from org.csstudio.opibuilder.scriptUtil import PVUtil op1=PVUtil.getDouble(pvs[0]) op2=PVUtil.getDouble(pvs[1]) operator = PVUtil.getString(pvs[2]) resultPV=pvs[3] if operator=="+": resultPV.setValue(op1 + op2) elif operator=="-": resultPV.setValue(op1 - op2) elif operator=="*": resultPV.setValue(op1 * op2) elif operator=="/": resultPV.setValue(op1 / op2)
# Used by plot in EdgeScan.opi to update local waveform PVs # that are used to display edge markers # # pvs[0]: Location of edge # pvs[1]: Height of edge # pvs[2]: Width of edge # pvs[3]: 'x' waveform for edge marker # pvs[4]: 'y' waveform for edge markers # pvs[5]: 'x' waveform for left edge marker # pvs[6]: 'x' waveform for right edge marker from org.csstudio.opibuilder.scriptUtil import PVUtil from org.eclipse.jface.dialogs import MessageDialog from jarray import array x = PVUtil.getDouble(pvs[0]) h = PVUtil.getDouble(pvs[1]) # Show half of full-widths-half-height on each side of center hw = PVUtil.getDouble(pvs[2]) / 2 # MessageDialog.openWarning(None, "Debug", "Set %s = %s" % (pvs[2].getName(), str(x)) ) pvs[3].setValue(array([x, x], 'd')) pvs[4].setValue(array([0, h], 'd')) pvs[5].setValue(array([x - hw, x - hw], 'd')) pvs[6].setValue(array([x + hw, x + hw], 'd'))
from org.csstudio.opibuilder.scriptUtil import PVUtil value = PVUtil.getDouble(pvs[0]) width = 5*value; oldY=widget.getPropertyValue("y") oldHeight = widget.getPropertyValue("height"); #module in the same directory is visible to this script import WidgetUtil WidgetUtil.setMyBounds(widget, value*40, 500 - width/2, width, width)
#1 local XMIN #2$(P)_XMAX #3local XMAX #4 $(P)_NBINSX #5 local_NBINSX #6 $(P)_DATA.NELM #7 $(P)_XTITLE #8 local_XTITLE #9 $(P)_YTITLE #10 local_YTITLE #11 local TRACETYPE init = widget.getPropertyValue("border_width") #misuse this as an init flag if init == 0: #if not already initialised xmin = PVUtil.getDouble(pvArray[0]) #get all the PVs lxmin = PVUtil.getDouble(pvArray[1]) xmax = PVUtil.getDouble(pvArray[2]) lxmax = PVUtil.getDouble(pvArray[3]) nbinsx = PVUtil.getLong(pvArray[4]) lnbinsx = PVUtil.getLong(pvArray[5]) nelm = PVUtil.getLong(pvArray[6]) xt = PVUtil.getStringArray(pvArray[7]) lxt = PVUtil.getString(pvArray[8]) yt = PVUtil.getStringArray(pvArray[9]) lyt = PVUtil.getString(pvArray[10]) trace = PVUtil.getLong(pvArray[11]) xt = list(map(int, xt)) #convert the waveforms into strings - ugly! xtstr = "".join([chr(c) for c in xt]) yt = list(map(int, yt))
# Used by plot in EdgeScan.opi to update local waveform PVs # that are used to display edge markers # # pvs[0]: Location of edge # pvs[1]: Height of edge # pvs[2]: Width of edge # pvs[3]: 'x' waveform for edge marker # pvs[4]: 'y' waveform for edge markers # pvs[5]: 'x' waveform for left edge marker # pvs[6]: 'x' waveform for right edge marker from org.csstudio.opibuilder.scriptUtil import PVUtil from org.eclipse.jface.dialogs import MessageDialog from jarray import array x = PVUtil.getDouble(pvs[0]) h = PVUtil.getDouble(pvs[1]) # Show half of full-widths-half-height on each side of center hw = PVUtil.getDouble(pvs[2]) / 2 # MessageDialog.openWarning(None, "Debug", "Set %s = %s" % (pvs[2].getName(), str(x)) ) pvs[3].setValue(array([ x, x ], 'd')) pvs[4].setValue(array([ 0, h ], 'd')) pvs[5].setValue(array([ x-hw, x-hw ], 'd')) pvs[6].setValue(array([ x+hw, x+hw ], 'd'))
# move it to the other side of the screen childw = child.getPropertyValue("width") childx = child.getPropertyValue("x") child.setPropertyValue("x", displayw - childx - childw) if child.getPropertyValue("widget_type") == "Action Button": flipIcon(child, "image", ".") elif child.getPropertyValue( "widget_type") == "Multistate Symbol Monitor": child.setPropertyValue( "flip_horizontal", not child.getPropertyValue("flip_horizontal")) # First pv tells us if we should flip try: should_flip = PVUtil.getDouble(pvs[0]) except: should_flip = 0 pvs[0].setValue(0) # Cache the initial points of the array if widget.getVar("orig_points") is None: widget.setVar("orig_points", widget.getPropertyValue("points")) # If we don't have flipped points then generate these if widget.getVar("flipped_points") is None: widget.setVar("flipped_points", flipPoints(widget.getVar("orig_points"))) # If we should flip if should_flip != bool(display.getVar("flipped")): flipDisplay(display)
from org.csstudio.opibuilder.scriptUtil import PVUtil from org.csstudio.opibuilder.scriptUtil import WidgetUtil from org.csstudio.opibuilder.scriptUtil import DataUtil from org.csstudio.opibuilder.scriptUtil import ConsoleUtil pv_rbv_name = widget.getPropertyValue("pv_name") + "_RBV" pv_rbv = PVUtil.createPV(pv_rbv_name, widget) while (True): if (pv_rbv.isConnected()): pv_rbv_val = PVUtil.getDouble(pv_rbv) pv_setter = widget.getPV() pv_setter.setValue(pv_rbv_val) break
from org.csstudio.opibuilder.scriptUtil import PVUtil #from org.csstudio.opibuilder.scriptUtil import executeSystemCommand import org.csstudio.opibuilder.scriptUtil.ConsoleUtil as ConsoleUtil import math # Checar se executeSystemCommand funciona e a funcao de wait/sleep #PVs #pv0: Ei #pv1: Ef #pv2: E_medial #pv3: height_medial initial_energy = PVUtil.getDouble(pvs[0]) final_energy = PVUtil.getDouble(pvs[1]) #calcs offset = 18.0 #offset_DCM h = 6.62606896E-34 ev = 1.602176565E-19 c = 299792458 d = 3.13542 hcort_c = h / ev * c / 1E-10 initial_theta = math.asin(1.2398E4 / (2 * initial_energy * math.pi)) final_theta = math.asin(1.2398E4 / (2 * final_energy * math.pi)) initial_height = offset * math.sin(initial_theta) / math.sin(2 * initial_theta) final_height = offset * math.sin(final_theta) / math.sin(2 * final_theta)
from org.csstudio.opibuilder.scriptUtil import PVUtil import org.csstudio.opibuilder.scriptUtil.ConsoleUtil as ConsoleUtil encoder_mono = PVUtil.getDouble(pvs[0]); position_monotheta = PVUtil.getDouble(pvs[1]); encoder_warning = PVUtil.getDouble(pvs[2]); diff = abs(encoder_mono - position_monotheta); ConsoleUtil.writeInfo (str(diff)) if(diff > 0.1): # pvs[2].setValue("Leitura incorreta do encoder. Faca o procedimento para a busca da posicao de referencia."); pvs[2].setValue("Incorrect feedback with the encoder. Do the reference search procedure."); # ConsoleUtil.writeInfo ("Leitura incorreta do encoder. Faca o procedimento para a busca da posicao de referencia") ConsoleUtil.writeInfo ("Incorrect feedback with the encoder. Do the reference search procedure.") else: # pvs[2].setValue("Leitura correta do encoder - Experimento liberado"); pvs[2].setValue("Correct feedback with the encoder. Experiment released!"); # ConsoleUtil.writeInfo ("Leitura correta do encoder - Experimento liberado") ConsoleUtil.writeInfo ("Correct feedback with the encoder. Experiment released!")
def move_motor(motor_pv, position, motor_dmov_pv=None, wait=False): motor_pv.setValue(position) if (wait == True): while (PVUtil.getDouble(motor_dmov_pv) == 0): pass
from org.csstudio.opibuilder.scriptUtil import PVUtil import org.csstudio.opibuilder.scriptUtil.ConsoleUtil as ConsoleUtil energy = PVUtil.getDouble(pvs[0]) energy_target = PVUtil.getDouble(pvs[1]) ConsoleUtil.writeInfo(str(energy)) ConsoleUtil.writeInfo(str(energy_target)) if (energy == energy_target): pvs[2].setValue("OK") ConsoleUtil.writeInfo("Atingida a energia alvo. Por favor, continue.") else: pvs[2].setValue("Pressione Go") ConsoleUtil.writeInfo("Energia alvo não atingida. Por favor, aguarde.")
#!/usr/bin/env python from org.csstudio.opibuilder.scriptUtil import PVUtil from org.csstudio.opibuilder.scriptUtil import ConsoleUtil import os #looks at host name to see if it development PC import socket devList = ['dsg-c-linux1.jlab.org'] dev = socket.gethostname() in devList #screen = 'HMS-Hodo-1-X-list.opi' screen = str(PVUtil.getString(pvs[0])) if PVUtil.getDouble(pvs[1]) == 1: #path = '/home/tlemon/CSS-Workspaces/dev/CSS/' path = os.getcwd() if path[-1] != '/': path += '/' inFile = path+screen+'-list.opi' with open(inFile,'r') as f: data = f.readlines() pwPVs = [] count = 0 for line in data: line = line.strip() if '<pv_name>' in line and '</pv_name>' in line: pv = line.split('<pv_name>')[1].split('</pv_name>')[0] if 'Pw' in pv:
from org.csstudio.opibuilder.scriptUtil import PVUtil, ScriptUtil, DataUtil from org.eclipse.ui import PlatformUI ## Get PV error_type = PVUtil.getDouble(pvArray[0]) ## Get Widgets error_window = display.getWidget("Window") error = error_window.getWidget("Error Type") error_cause_1 = error_window.getWidget("Error Cause 1") error_cause_2 = error_window.getWidget("Error Cause 2") ## Set Error Text if error_type == 1: error.setPropertyValue("text", "Matrix measurent request could not be processed.") error_cause_1.setPropertyValue("text", "Automatic correction is running.") elif error_type == 2: error.setPropertyValue("text", "Number of samples could not be set.") error_cause_1.setPropertyValue("text", "Value out of range. Maximun value is 100.") elif error_type == 3: error.setPropertyValue("text", "Orbit average could not be calculated.") error_cause_1.setPropertyValue("text", "Orbit was not correctly read.") elif error_type == 4: error.setPropertyValue("text", "Matrix could not be set.") error_cause_1.setPropertyValue("text", "Automatic correction is running.") error_cause_2.setPropertyValue("text", "Variables are being update.") elif error_type == 5: error.setPropertyValue("text", "Reference orbit could not be set.") error_cause_1.setPropertyValue("text", "Automatic correction is running.") error_cause_2.setPropertyValue("text", "Variables are being update.") elif error_type == 6:
GREEN = ColorFontUtil.getColorFromRGB(0, 180, 0) RED = ColorFontUtil.RED #Name of the flag to show if dialog has been popped up. flagName = "popped" labelName = "myLabel" if widget.getExternalObject(flagName) == None: widget.setExternalObject(flagName, 0) #Example to write text to BOY Console ConsoleUtil.writeInfo("Welcome to Best OPI, Yet (BOY)!") b = widget.getExternalObject(flagName) if PVUtil.getDouble(pvs[0]) > PVUtil.getDouble(pvs[1]): s = "Temperature is too high!" WidgetUtil.setText(display, labelName, s) WidgetUtil.setForeColor(display, labelName, RED) #If dialog has not been popped up, pop up the dialog if b == 0: #set popped flag to true widget.setExternalObject(flagName, 1) MessageDialog.openWarning(None, "Warning", "The temperature you set is too high!") else: s = "Temperature is normal" WidgetUtil.setText(display, "myLabel", s) WidgetUtil.setForeColor(display, labelName, GREEN) #reset popped flag to false if b != 0:
# loc://$(DID)SaveXY pv_savey = pvs[5] # 6 - Image height # $(P)image1:ArraySize1_RBV pv_height = pvs[6] # 7 - Destination for center X # $(WARP)CenterX pv_cx = pvs[7] # 8 - Destination for center Y # $(WARP)CenterY pv_cy = pvs[8] # 9 - Destination for Length # $(WARP)LPX_CSET pv_len = pvs[9] isdown = PVUtil.getDouble(pv_sel) if isdown > 0.5: next_mode = 0 # widget coordinates to image coordinates X, Y = PVUtil.getDouble(pv_px), PVUtil.getDouble(pv_py) H = PVUtil.getDouble(pv_height) X -= 4 # empirically necessary to align w/ cursor ... Y = H - Y mode = PVUtil.getDouble(pv_mode) if mode == 1: # select and store center # don't use 'long' with setValue as jython maps this to BigInteger, which pvManager doesn't understand
ConsoleUtil.writeInfo(str(l)) # returns distance between two points. Used in PV check. def distance(pvcoor, labelcoor): x1, y1 = pvcoor x2, y2 = labelcoor d = math.sqrt((x2 - x1)**2 + (y2 - y1)**2) return (d) # read in file to create test screens for fin = str(PVUtil.getString(pvs[1]))[1:] # read in go button to initiate screen creation go = PVUtil.getDouble(pvs[0]) == 1 # flag used to include PV in rules list if macros are used macroFlag = False check = PVUtil.getDouble(pvs[3]) == 1 if go and fin != '': fin = str(FileUtil.workspacePathToSysPath(fin)) # performs PV check if selected if check: # read in and parse OPI file for relevant info tree = ET.parse(fin) root = tree.getroot() relevant = [
from org.csstudio.opibuilder.scriptUtil import PVUtil import org.csstudio.opibuilder.scriptUtil.ConsoleUtil as ConsoleUtil interlock_optical = PVUtil.getDouble(pvs[0]); interlock_experimental = PVUtil.getDouble(pvs[1]); interlock_warning = PVUtil.getDouble(pvs[2]); if(interlock_optical != interlock_experimental): pvs[2].setValue("We need beam at experimental stations!"); ConsoleUtil.writeInfo ("We need beam at experimental stations!") elif (interlock_optical == 0): pvs[2].setValue("We need beam at experimental stations!"); ConsoleUtil.writeInfo ("We need beam at experimental stations!") else: pvs[2].setValue("Beam at experimental stations! - Experiment released!"); ConsoleUtil.writeInfo ("Beam at experimental stations! - Experiment released!")
from org.csstudio.opibuilder.scriptUtil import PVUtil from java.lang import System from org.eclipse.jface.dialogs import MessageDialog ok = PVUtil.getDouble(pvs[0]) if ok == 1: userName = System.getProperty("UserName") password = System.getProperty("Password") if userName == "admin" and password == "123456": widget.setPropertyValue("visible", True) else: MessageDialog.openError(None, "Error", "The user name or password is wrong!") pvs[0].setValue(0)
from org.csstudio.opibuilder.scriptUtil import PVUtil, ScriptUtil, DataUtil from org.eclipse.ui import PlatformUI ## Set OPI File opi_file = "error/error_window.opi" ## Open OPI if PVUtil.getDouble(pvArray[0]) != 0: ScriptUtil.openOPI(widget, opi_file, 2, None)
def main(): # Ampl if PVUtil.getLong(pvs[0]) == 1: graph = "TopGraph" # CAV Ampl offset1 = PVUtil.getDouble(pvs[7]) one = PVUtil.getDouble(pvs[1]) # FWD Ampl offset2 = PVUtil.getDouble(pvs[8]) two = PVUtil.getDouble(pvs[2]) # REV Ampl offset3 = PVUtil.getDouble(pvs[9]) three = PVUtil.getDouble(pvs[3]) # Phase if PVUtil.getLong(pvs[0]) == 2: graph = "BottomGraph" # CAV Phase offset and magnitude offset1 = PVUtil.getDouble(pvs[10]) one = PVUtil.getDouble(pvs[4]) # FWD Phase offset and magnitude offset2 = PVUtil.getDouble(pvs[11]) two = PVUtil.getDouble(pvs[5]) # REV Phase offset and magnitude offset3 = PVUtil.getDouble(pvs[12]) three = PVUtil.getDouble(pvs[6]) # Execute the commands only if the button has been pressed if PVUtil.getLong(pvs[0]) != 0: # Get the graph widget and turn off autoscale display.getWidget(graph).setPropertyValue("axis_1_auto_scale", "0") display.getWidget(graph).setPropertyValue("axis_2_auto_scale", "0") display.getWidget(graph).setPropertyValue("axis_3_auto_scale", "0") # Set the max and min values of the y-axis display.getWidget(graph).setPropertyValue("axis_1_maximum", one + offset1) display.getWidget(graph).setPropertyValue("axis_1_minimum", one - offset1) display.getWidget(graph).setPropertyValue("axis_2_maximum", two + offset2) display.getWidget(graph).setPropertyValue("axis_2_minimum", two - offset2) display.getWidget(graph).setPropertyValue("axis_3_maximum", three + offset3) display.getWidget(graph).setPropertyValue("axis_3_minimum", three - offset3) # Reset the rescale action indicator to 0 pvs[0].setValue(0)
from org.csstudio.opibuilder.scriptUtil import PVUtil from org.csstudio.opibuilder.scriptUtil import ColorFontUtil pvname = widget.getPropertyValue("pv_name") if pvname != "": widget.setPropertyValue("off_color", ColorFontUtil.GREEN) pv = widget.getPV() variance = PVUtil.getDouble(pv) if variance < 2 and variance > -2: widget.setPropertyValue("on_color", ColorFontUtil.GREEN) elif variance >= 2 and variance < 5: widget.setPropertyValue("on_color", ColorFontUtil.YELLOW) elif variance <= -2 and variance > -5: widget.setPropertyValue("on_color", ColorFontUtil.YELLOW) elif variance >= 5 and variance < 10: widget.setPropertyValue("on_color", ColorFontUtil.ORANGE) elif variance <= -5 and variance > -10:
from org.csstudio.opibuilder.scriptUtil import PVUtil,WidgetUtil,ConsoleUtil ch = int(PVUtil.getDouble(pvArray[0])) desc = widget.getPropertyValue("tooltip") #ConsoleUtil.writeInfo(desc) currhv = -1 if len(desc) > 2: ConsoleUtil.writeInfo(desc) currhv = int(desc[desc.find("HVChan")+7:]) ConsoleUtil.writeInfo("Currhv = " + str(currhv) ) if currhv < 0: hv="1" else: hv = PVUtil.getString(pvArray[1]) if (int(hv) != currhv): widget.removeAllChildren() #clean the area first linkingContainer = WidgetUtil.createWidgetModel("org.csstudio.opibuilder.widgets.linkingContainer") linkingContainer.setPropertyValue("opi_file", "chan8.opi") linkingContainer.addMacro("ID", str(ch).zfill(3)) #linkingContainer.addMacro("ID", ch) linkingContainer.addMacro("HV", str(hv.zfill(2))) linkingContainer.setPropertyValue("resize_behaviour", 1) linkingContainer.setPropertyValue("border_style", 0) widget.addChild(linkingContainer) widget.setPropertyValue("tooltip","ChanHV " + hv)
((lam * N * 1000.0)**2) / rprime_vls - c0) / (lam * 10000.0) E = lam1 / lam print "Energy : %f" % E print "b2Shadow : %f" % b2 return (E, b2) ############################################################################### # # This section interfaces with the CSS scripting from org.csstudio.opibuilder.scriptUtil import PVUtil, ConsoleUtil, FileUtil # read in the N Eref m and CFF values from PVs # calculate and set the pv representing b2Shadow this_Cff = PVUtil.getDouble(pvs[0]) this_Eref = PVUtil.getDouble(pvs[1]) this_N = PVUtil.getDouble(pvs[2]) this_m = PVUtil.getLong(pvs[3]) calc_ok = 1 b2s = 0 try: b2s = calc_b2Shadow(this_N, this_Eref, this_Cff, this_m) except Exception, e: print "error calculating b2Shadow :", e.message calc_ok = 0 pvs[4].setValue(b2s) pvs[5].setValue(calc_ok)
from org.csstudio.opibuilder.scriptUtil import PVUtil #Medium energy energy_medium = PVUtil.getDouble(pvs[0]); energyRBV = PVUtil.getDouble(pvs[1]); mov = PVUtil.getDouble(pvs[3]); diff = abs(energy_medium - energyRBV) if (diff < 0.5 & mov == 0) : pvs[2].setValue(1); else: pvs[2].setValue(0);
from org.csstudio.opibuilder.scriptUtil import PVUtil, ConsoleUtil pv = widget.getPV() current_value = int(PVUtil.getDouble(pv)) if current_value == 0: pv.setValue(1) else: pv.setValue(0)
from org.csstudio.opibuilder.scriptUtil import PVUtil from java.lang import System from org.eclipse.jface.dialogs import MessageDialog ok = PVUtil.getDouble(pvs[0]) if ok ==1: userName = System.getProperty("UserName") password = System.getProperty("Password") if userName=="admin" and password == "123456": widget.setPropertyValue("visible", True) else: MessageDialog.openError(None, "Error", "The user name or password is wrong!") pvs[0].setValue(0)
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")
from org.csstudio.opibuilder.scriptUtil import PVUtil #Height before height = PVUtil.getDouble(pvs[0]) heightRBV = PVUtil.getDouble(pvs[1]) diff = abs(heightRBV - height) if (diff < 0.05): pvs[2].setValue(1) else: pvs[2].setValue(0)
from org.csstudio.opibuilder.scriptUtil import ConsoleUtil from org.csstudio.opibuilder.scriptUtil import PVUtil from org.csstudio.opibuilder.scriptUtil import ColorFontUtil import WidgetUtil value = PVUtil.getDouble(pvs[0]) name = pvs[1].getName() if value == 0: PVUtil.writePV(name, "Model") elif value == 1: PVUtil.writePV(name, "CONST") elif value == 2: PVUtil.writePV(name, "AWG") elif value == 3: PVUtil.writePV(name, "0")
from org.csstudio.opibuilder.scriptUtil import PVUtil, WidgetUtil, ConsoleUtil ch = int(PVUtil.getDouble(pvArray[0])) desc = widget.getPropertyValue("tooltip") #ConsoleUtil.writeInfo(desc) currhv = -1 if len(desc) > 2: ConsoleUtil.writeInfo(desc) currhv = int(desc[desc.find("HVChan") + 7:]) ConsoleUtil.writeInfo("Currhv = " + str(currhv)) if currhv < 0: hv = "1" else: hv = PVUtil.getString(pvArray[1]) if (int(hv) != currhv): widget.removeAllChildren() #clean the area first linkingContainer = WidgetUtil.createWidgetModel( "org.csstudio.opibuilder.widgets.linkingContainer") linkingContainer.setPropertyValue("opi_file", "chan8.opi") linkingContainer.addMacro("ID", str(ch).zfill(3)) #linkingContainer.addMacro("ID", ch) linkingContainer.addMacro("HV", str(hv.zfill(2))) linkingContainer.setPropertyValue("resize_behaviour", 1) linkingContainer.setPropertyValue("border_style", 0) widget.addChild(linkingContainer) widget.setPropertyValue("tooltip", "ChanHV " + hv)
from org.csstudio.opibuilder.scriptUtil import PVUtil op1 = PVUtil.getDouble(pvs[0]) op2 = PVUtil.getDouble(pvs[1]) operator = PVUtil.getString(pvs[2]) resultPV = pvs[3] if operator == "+": resultPV.setValue(op1 + op2) elif operator == "-": resultPV.setValue(op1 - op2) elif operator == "*": resultPV.setValue(op1 * op2) elif operator == "/": resultPV.setValue(op1 / op2)
from org.csstudio.opibuilder.scriptUtil import PVUtil from org.eclipse.ui import PlatformUI if PVUtil.getDouble(pvs[0]): selection_type = PVUtil.getString(pvs[1]) #if selection_type in ['ch', 'cv', 'fch', 'fcv', 'qs']: selection_type = "Corrector" title = selection_type.upper() + ' Selection' window = PlatformUI.getWorkbench().getActiveWorkbenchWindow() window.getShell().setText(title) pvs[0].setValue(0)
GREEN = ColorFontUtil.getColorFromRGB(0, 180, 0) RED = ColorFontUtil.RED #Name of the flag to show if dialog has been popped up. flagName = "popped" labelName = "myLabel" if widget.getExternalObject(flagName) == None: widget.setExternalObject(flagName, 0) #Example to write text to BOY Console ConsoleUtil.writeInfo("Welcome to Best OPI, Yet (BOY)!") b = widget.getExternalObject(flagName); if PVUtil.getDouble(pvs[0]) > PVUtil.getDouble(pvs[1]): s = "Temperature is too high!" WidgetUtil.setText(display, labelName, s) WidgetUtil.setForeColor(display, labelName, RED) #If dialog has not been popped up, pop up the dialog if b == 0: #set popped flag to true widget.setExternalObject(flagName, 1) MessageDialog.openWarning( None, "Warning", "The temperature you set is too high!") else: s = "Temperature is normal" WidgetUtil.setText(display, "myLabel", s) WidgetUtil.setForeColor(display, labelName, GREEN) #reset popped flag to false if b != 0: