#! /usr/env/python #-------------------------------------------------------------------------------- """ Application: Dialog_Hst for DAQ_96_Gui Histogram Analysis Dialog for the Graphical User Interface to the DAQ_96 Control Program """ #-------------------------------------------------------------------------------- #-------------------------------------------------------------------------------- import string from Tkinter import * import Pmw from MultiShell import updateComboBox from MultiShell import updateIntVar from Print_Utils import printLine from Misc_Utils import RegAddrString from Xml_Utils import CreateXmlCommand from Xml_Utils import AppendCommentField from Xml_Utils import RetrieveXmlAttr from Misc_Constants import eOk, eError from Misc_Constants import TT_EM, TT_HD, TtType_str, TtType_tot #-------------------------------------------------------------------------------- #-------------------------------------------------------------------------------- class Dialog_Hst : def __init__ ( self, MShell, FrameNum ) : self.MShell = MShell self.HstFrame = FrameNum # printLine ( "Dialog", 'Frame #%d is "%s"' % ( FrameNum, MShell.frameName[FrameNum] ) ) #-------------------------------------------------------------------------------- def createInterface(self): MShell = self.MShell MShell.addFieldLabel ( nFrame = self.HstFrame, labelName = 'Access: *10 bits* Histogram Analysis', column = 1, columnspan = 4, height = 1, width = 35, row = MShell.nextFieldRow() ) # MShell.addFieldLabel ( nFrame = self.HstFrame, # labelName = "VI Mst/Slv", # column = 1, # row = MShell.nextFieldRow() ) # HstCrateMasterFrame = \ # MShell.addFieldFrame ( nFrame = self.HstFrame, # labelName = "VI Frame for Hst", # column = 2, # columnspan = 3, # row = MShell.currentFieldRow() ) self.HstMasterNum_var = IntVar() self.HstMasterNum_var.set(0) # MShell.addFieldRadioB ( frame = HstCrateMasterFrame, # labelName ="M#0", # value = 0, # variable = self.HstMasterNum_var ) # MShell.addFieldRadioB ( frame = HstCrateMasterFrame, # labelName ="#1", # value = 1, # variable = self.HstMasterNum_var ) self.HstSlaveNum_var = IntVar() self.HstSlaveNum_var.set(0) # MShell.addFieldRadioB ( frame = HstCrateMasterFrame, # labelName ="S#0", # value = 0, # variable = self.HstSlaveNum_var ) # MShell.addFieldRadioB ( frame = HstCrateMasterFrame, # labelName ="#1", # value = 1, # variable = self.HstSlaveNum_var ) # MShell.addFieldRadioB ( frame = HstCrateMasterFrame, # labelName ="#2", # value = 2, # variable = self.HstSlaveNum_var ) # MShell.addFieldRadioB ( frame = HstCrateMasterFrame, # labelName ="#3", # value = 3, # variable = self.HstSlaveNum_var ) self.HstSlotNum_box = \ MShell.addFieldCombo ( nFrame = self.HstFrame, labelName ="Slot Num", helpMessage ="Slot Num", statusMessage="Slot Num", initValue ="0", width = 10 ) MShell.addFieldLabel ( nFrame = self.HstFrame, labelName = "Chip Num", column = 1, row = MShell.nextFieldRow() ) HstChipNumFrame = \ MShell.addFieldFrame ( nFrame = self.HstFrame, labelName = "Chip Num Hst", column = 2, columnspan = 3, row = MShell.currentFieldRow() ) self.HstChipNum_var = IntVar() self.HstChipNum_var.set(0) MShell.addFieldRadioB ( frame = HstChipNumFrame, labelName ="Fpga#0", value = 0, variable = self.HstChipNum_var ) MShell.addFieldRadioB ( frame = HstChipNumFrame, labelName ="Fpga#1", value = 1, variable = self.HstChipNum_var ) self.HstRegAddr_box = \ MShell.addFieldCombo ( nFrame = self.HstFrame, labelName ="Base Addr", helpMessage ="Starting Reg Addr", statusMessage="Starting Reg Addr", initValue ="0x4000", width = 10 ) self.HstSamples_box = \ MShell.addFieldCombo ( nFrame = self.HstFrame, labelName ="Samples", helpMessage ="Reg Addr Count", statusMessage="Reg Addr Count", initValue ="4096", column = 3, row = MShell.currentFieldRow(), width = 10 ) MShell.addFieldLabel ( nFrame = self.HstFrame, labelName = "Incr Addr", column = 1, row = MShell.nextFieldRow() ) HstAddrIncrFrame = \ MShell.addFieldFrame ( nFrame = self.HstFrame, labelName = "Incr Addr", column = 2, columnspan = 3, row = MShell.currentFieldRow() ) self.HstAddrIncr_var = IntVar() self.HstAddrIncr_var.set(0) MShell.addFieldRadioB ( frame = HstAddrIncrFrame, labelName ="Const", value = 0, variable = self.HstAddrIncr_var ) MShell.addFieldRadioB ( frame = HstAddrIncrFrame, labelName ="Increment", value = 1, variable = self.HstAddrIncr_var ) MShell.addFieldButton ( nFrame = self.HstFrame, labelName = 'Simple Histo', helpMessage = 'Simple Histogram', statusMessage= 'Simple Histogram', column = 4, row = MShell.nextFieldRow(), command = self.Hst_10BitHisto ) self.HstDumpToFile_var = IntVar() self.HstDumpToFile_var.set(0) MShell.addFieldCheckB ( nFrame = self.HstFrame, labelName = 'Write Dump File', helpMessage = 'Write to Dump File', statusMessage= 'Write to Dump File', column = 2, row = MShell.currentFieldRow(), columnspan = 3, variable = self.HstDumpToFile_var ) self.HstReply_box = \ MShell.addFieldEntry ( nFrame = self.HstFrame, labelName ="Reply", helpMessage ="Reply", statusMessage="Reply", initValue ="-", bg = 'gray80', columnspan = 3, font = ('Verdana',7), width = 43 ) #-------------------------------------------------------------------------------- def Hst_10BitHisto ( self, MasterNum = None, SlaveNum = None, SlotNum = None, ChipNum = None, RegAddr = None, Samples = None, AddrIncr = None, DumpToFile = None, Comment = None ) : MasterNum_int = updateIntVar ( self.HstMasterNum_var, MasterNum ) SlaveNum_int = updateIntVar ( self.HstSlaveNum_var, SlaveNum ) SlotNum_int = updateComboBox ( self.HstSlotNum_box, SlotNum ) ChipNum_int = updateIntVar ( self.HstChipNum_var, ChipNum ) RegAddr_int = updateComboBox ( self.HstRegAddr_box, RegAddr ) Samples_int = updateComboBox ( self.HstSamples_box, Samples ) AddrIncr_int = updateIntVar ( self.HstAddrIncr_var, AddrIncr ) DumpToFile_int = updateIntVar ( self.HstDumpToFile_var, DumpToFile ) printLine ( "Hst_Histo", "%d Entries %s with incr %+d" \ % ( Samples_int, RegAddrString ( MasterNum_int, SlaveNum_int, SlotNum_int, ChipNum_int, RegAddr_int ), AddrIncr_int ) ) guiCmdName = "Hst_10BitHisto" xmlCmdDoc = CreateXmlCommand ( guiCmdName, { "ADF" : { "MASTER" : str(MasterNum_int), "SLAVE" : str(SlaveNum_int), "SLOT" : str(SlotNum_int) }, "CHIP" : { "NUM" : str(ChipNum_int) }, "REG" : { "ADDR" : str(RegAddr_int), "SAMPLES" : str(Samples_int), "ADDR_INCR" : str(AddrIncr_int), "DUMPTOFILE": str(DumpToFile_int) } } ) AppendCommentField ( xmlCmdDoc, Comment ) guiCmdReply = self.MShell.sendGuiComand ( xmlCmdDoc ) Average_str, \ Deviation_str,\ FileName_str, \ Reply_Status = RetrieveXmlAttr ( CmdReply = guiCmdReply, CmdName = guiCmdName, EltAttrList = [ [ "DATA", "AVERAGE", None ], [ "DATA", "DEVIATION", None ], [ "FILE", "NAME", "NoFile"] ], ReplyBox = self.HstReply_box ) try : Average_float = eval ( Average_str ) except : Average_float = -1.0 try : Deviation_float = eval ( Deviation_str ) except : Deviation_float = -1.0 if ( Reply_Status == eOk ) : printLine ( "Hst_Histo", "Average = %3.2f StdDev = %2.2f " \ % ( Average_float, Deviation_float ) ) if ( DumpToFile_int != 0 ) : printLine ( "Hst_Histo","File Created <%s>" % FileName_str ) else : printLine ( "Hst_Histo", "*** Error Detected ***" ) return Average_str, Deviation_str, FileName_str, Reply_Status #--------------------------------------------------------------------------------