#!/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_Waveform(ReadoutType, BCALEnd, BCALLayer, Index): WidgetName = "DiscWaveformContainer_" + BCALEnd + BCALLayer WaveformDisplayWidget = widget.getParent().getWidget(WidgetName) WaveformDisplayWidget.removeAllChildren() linkingContainer.append( WidgetUtil.createWidgetModel("org.csstudio.opibuilder.widgets.linkingContainer") ) linkingContainer[Index].setPropertyValue("opi_file", "BCAL_scaler_wave.opi") #create linking container linkingContainer[Index].setPropertyValue("auto_size", False) linkingContainer[Index].setPropertyValue("zoom_to_fit", False) linkingContainer[Index].setPropertyValue("border_style", 0) linkingContainer[Index].setPropertyValue("height",119) linkingContainer[Index].setPropertyValue("width", 904) #add macros linkingContainer[Index].addMacro("bcalReadout", ReadoutType) linkingContainer[Index].addMacro("bcalType", "T") linkingContainer[Index].addMacro("bcalEnd", BCALEnd) linkingContainer[Index].addMacro("bcalLayer", BCALLayer) WaveformDisplayWidget.addChildToBottom(linkingContainer[Index]) WaveformDisplayWidget.performAutosize() def Update_Module(Module, ModuleType, BCALEnd, ReadoutType, Index): #Get Widget WidgetName = "BCAL_Module_" + BCALEnd DisplayWidget = widget.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" widget.setPropertyValue("pv_value", ReadoutString) if ModuleString == "": ModuleString = "1" if ModuleString == "0": ModuleString = "1" # ConsoleUtil.writeInfo("READOUT: 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 Update_Module(ModuleString, ModuleType, "U", ReadoutType, 0) Update_Module(ModuleString, ModuleType, "D", ReadoutType, 1) ################################################ Update Waveforms ############################################### if ModuleType == 'T': WaveformLabelWidget=widget.getParent().getWidget("DiscWaveformLabel") WaveformLabelWidget.setPropertyValue("text", DisplayString) Update_Waveform(ReadoutType, "U", "1", 2) Update_Waveform(ReadoutType, "U", "2", 3) Update_Waveform(ReadoutType, "U", "3", 4) Update_Waveform(ReadoutType, "D", "1", 5) Update_Waveform(ReadoutType, "D", "2", 6) Update_Waveform(ReadoutType, "D", "3", 7) if __name__ == "__main__": main()