#!/usr/bin/env python # load BCAL scalar readouts # # P. Mattione October 2015 # from org.csstudio.opibuilder.scriptUtil import PVUtil from org.csstudio.opibuilder.scriptUtil import WidgetUtil from org.csstudio.opibuilder.scriptUtil import ConsoleUtil from org.csstudio.utility.pv import PVFactory from org.csstudio.opibuilder.scriptUtil import ColorFontUtil import re import os import time import sys linkingContainer = [] Arr=[] def Update_Module(Module, ModuleType, BCALEnd, ReadoutType, Index): #Get Widget WidgetName = "BCAL_Module_" + BCALEnd DisplayWidget = widget.getParent().getParent().getWidget(WidgetName) DisplayWidget.removeAllChildren() linkingContainer.append( WidgetUtil.createWidgetModel("org.csstudio.opibuilder.widgets.linkingContainer") ) # ConsoleUtil.writeInfo("NAME = " + linkingContainer[Index].getPropertyValue("name")) linkingContainer[Index].setPropertyValue("opi_file", "BCAL_module.opi") #create linking container linkingContainer[Index].setPropertyValue("height",170) linkingContainer[Index].setPropertyValue("width", 528) linkingContainer[Index].setPropertyValue("auto_size", False) linkingContainer[Index].setPropertyValue("zoom_to_fit", False) linkingContainer[Index].setPropertyValue("border_style", 0) #add macros linkingContainer[Index].addMacro("bcalModule", Module) linkingContainer[Index].addMacro("bcalEnd", BCALEnd) linkingContainer[Index].addMacro("bcalType", ModuleType) linkingContainer[Index].addMacro("bcalReadout", ReadoutType) DisplayWidget.addChildToBottom(linkingContainer[Index]) DisplayWidget.performAutosize() #Set whether Layer4 Widget is visible Layer4Widget = DisplayWidget.getWidget("Layer4") if ModuleType == "T": Layer4Widget.setPropertyValue("visible", False) else: Layer4Widget.setPropertyValue("visible", True) def main(): Pref = widget.getParent().getMacroValue("pref") ReadoutString = PVUtil.getString(pvs[0]) ModuleString = PVUtil.getString(pvs[1]) ModuleString = str(int(float(ModuleString))) if ReadoutString == "0.000": ReadoutString = "Disc: Readout 1" if ModuleString == "": ModuleString = "1" if ModuleString == "0": ModuleString = "1" # ConsoleUtil.writeInfo("MODULE: ReadoutString, ModuleString = " + ReadoutString + ", " + ModuleString) ReadoutType = "scaler_r1" ModuleType = "T" DisplayString = "Discriminator: Readout 1 Scalers" if ReadoutString == "Disc: Readout 1" : DisplayString = "Discriminator: Readout 1 Scalers" ReadoutType = "scaler_r1" elif ReadoutString == "Disc: Readout 2" : DisplayString = "Discriminator: Readout 2 Scalers" ReadoutType = "scaler_r2" elif ReadoutString == "Disc: Trigger 1" : DisplayString = "Discriminator: Trigger 1 Scalers" ReadoutType = "scaler_t1" elif ReadoutString == "Disc: Trigger 2" : DisplayString = "Discriminator: Trigger 2 Scalers" ReadoutType = "scaler_t2" elif ReadoutString == "FADC" : DisplayString = "FADC Scalers" ModuleType = "A" ################################################# Update module ################################################ #Update module labels ModuleLabelWidget = widget.getParent().getParent().getWidget("Module_Up_Label") ModuleLabel = "Module " + ModuleString + ": Upstream" ModuleLabelWidget.setPropertyValue("text", ModuleLabel) #Update module labels ModuleLabelWidget = widget.getParent().getParent().getWidget("Module_Down_Label") ModuleLabel = "Module " + ModuleString + ": Downstream" ModuleLabelWidget.setPropertyValue("text", ModuleLabel) #Update module Update_Module(ModuleString, ModuleType, "U", ReadoutType, 0) Update_Module(ModuleString, ModuleType, "D", ReadoutType, 1) if __name__ == "__main__": main()