#!/usr/bin/env python # load TOF scalar readouts # # P. Mattione August 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, TOFSide, Index): WidgetName = "DiscWaveformContainer_" + TOFSide WaveformDisplayWidget = widget.getParent().getWidget(WidgetName) WaveformDisplayWidget.removeAllChildren() linkingContainer.append( WidgetUtil.createWidgetModel("org.csstudio.opibuilder.widgets.linkingContainer") ) linkingContainer[Index].setPropertyValue("opi_file", "TOF_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",154) linkingContainer[Index].setPropertyValue("width", 404) #add macros linkingContainer[Index].addMacro("tofReadout", ReadoutType) linkingContainer[Index].addMacro("tofType", "T") linkingContainer[Index].addMacro("tofSide", TOFSide) WaveformDisplayWidget.addChildToBottom(linkingContainer[Index]) WaveformDisplayWidget.performAutosize() def main(): Pref = widget.getParent().getMacroValue("pref") ReadoutString = PVUtil.getString(pvs[0]) SideString = PVUtil.getString(pvs[1]) if ReadoutString == "0.000": ReadoutWidget = widget.getParent().getWidget("ReadoutChoiceButtons") ReadoutWidget.setPropertyValue("pv_value", "Disc: Readout 1") if SideString == "0.000": SideWidget = widget.getParent().getWidget("SideChoiceButtons") SideWidget.setPropertyValue("pv_value", "Top") # ConsoleUtil.writeInfo("ReadoutString, TOFSide = " + ReadoutString + ", " + TOFSide) 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" TOFSide = "UP" if SideString == "Top": TOFSide = "UP" elif SideString == "Bottom": TOFSide = "DW" elif SideString == "North": TOFSide = "N" elif SideString == "South": TOFSide = "S" ################################################ Update columns ################################################ DisplayWidget=widget.getParent().getWidget("TOF_Display") DisplayWidget.removeAllChildren() linkingContainer.append( WidgetUtil.createWidgetModel("org.csstudio.opibuilder.widgets.linkingContainer") ) linkingContainer[0].setPropertyValue("opi_file", "TOF_scaler_graphic.opi") #create linking container linkingContainer[0].setPropertyValue("height",186) linkingContainer[0].setPropertyValue("width", 1208) linkingContainer[0].setPropertyValue("auto_size", False) linkingContainer[0].setPropertyValue("zoom_to_fit", False) linkingContainer[0].setPropertyValue("border_style", 0) #add macros linkingContainer[0].addMacro("tofReadout", ReadoutType) linkingContainer[0].addMacro("tofType", ModuleType) linkingContainer[0].addMacro("tofSide", TOFSide) DisplayWidget.addChildToBottom(linkingContainer[0]) DisplayWidget.performAutosize() ################################################ Update Waveforms ############################################### if ModuleType == 'T': WaveformLabelWidget=widget.getParent().getWidget("DiscWaveformLabel") WaveformLabelWidget.setPropertyValue("text", DisplayString) Update_Waveform(ReadoutType, "UP", 1) Update_Waveform(ReadoutType, "DW", 2) Update_Waveform(ReadoutType, "N", 3) Update_Waveform(ReadoutType, "S", 4) if __name__ == "__main__": main()