#! /usr/env/python #-------------------------------------------------------------------------------- """ Application: Dialog_Mio 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_Mio : def __init__ ( self, MShell, FrameNum ) : self.MShell = MShell self.MioFrame = FrameNum # printLine ( "Dialog", 'Frame #%d is "%s"' % ( FrameNum, MShell.frameName[FrameNum] ) ) #-------------------------------------------------------------------------------- def createInterface(self): MShell = self.MShell MShell.addFieldLabel ( nFrame = self.MioFrame, labelName = 'Access: Multiple Register Read', column = 1, columnspan = 4, height = 1, width = 35, row = MShell.nextFieldRow() ) # MShell.addFieldLabel ( nFrame = self.MioFrame, # labelName = "VI Mst/Slv", # column = 1, # row = MShell.nextFieldRow() ) # MioCrateMasterFrame = \ # MShell.addFieldFrame ( nFrame = self.MioFrame, # labelName = "VI Frame for Mio", # column = 2, # columnspan = 3, # row = MShell.currentFieldRow() ) self.MioMasterNum_var = IntVar() self.MioMasterNum_var.set(0) # MShell.addFieldRadioB ( frame = MioCrateMasterFrame, # labelName ="M#0", # value = 0, # variable = self.MioMasterNum_var ) # MShell.addFieldRadioB ( frame = MioCrateMasterFrame, # labelName ="#1", # value = 1, # variable = self.MioMasterNum_var ) self.MioSlaveNum_var = IntVar() self.MioSlaveNum_var.set(0) # MShell.addFieldRadioB ( frame = MioCrateMasterFrame, # labelName ="S#0", # value = 0, # variable = self.MioSlaveNum_var ) # MShell.addFieldRadioB ( frame = MioCrateMasterFrame, # labelName ="#1", # value = 1, # variable = self.MioSlaveNum_var ) # MShell.addFieldRadioB ( frame = MioCrateMasterFrame, # labelName ="#2", # value = 2, # variable = self.MioSlaveNum_var ) # MShell.addFieldRadioB ( frame = MioCrateMasterFrame, # labelName ="#3", # value = 3, # variable = self.MioSlaveNum_var ) self.MioSlotNum_box = \ MShell.addFieldCombo ( nFrame = self.MioFrame, labelName ="Slot Num", helpMessage ="Slot Num", statusMessage="Slot Num", initValue ="0", width = 10 ) MShell.addFieldLabel ( nFrame = self.MioFrame, labelName = "Chip Num", column = 1, row = MShell.nextFieldRow() ) MioChipNumFrame = \ MShell.addFieldFrame ( nFrame = self.MioFrame, labelName = "Chip Num Mio", column = 2, columnspan = 3, row = MShell.currentFieldRow() ) self.MioChipNum_var = IntVar() self.MioChipNum_var.set(0) MShell.addFieldRadioB ( frame = MioChipNumFrame, labelName ="Fpga#0", value = 0, variable = self.MioChipNum_var ) MShell.addFieldRadioB ( frame = MioChipNumFrame, labelName ="Fpga#1", value = 1, variable = self.MioChipNum_var ) self.MioRegAddr_box = \ MShell.addFieldCombo ( nFrame = self.MioFrame, labelName ="Reg Addr", helpMessage ="Register Addr", statusMessage="Register Addr", initValue ="16", width = 10 ) self.MioCondMask_box = \ MShell.addFieldCombo ( nFrame = self.MioFrame, labelName ="Cond Mask", helpMessage ="Condition Requirement Data Mask", statusMessage="Condition Requirement Data Mask", initValue ="0xff00", width = 10 ) self.MioCondValue_box = \ MShell.addFieldCombo ( nFrame = self.MioFrame, labelName ="Cond Value", helpMessage ="Condition Requirement Data Value", statusMessage="Condition Requirement Data Value", initValue ="0x0700", column = 3, row = MShell.currentFieldRow(), width = 10 ) self.MioSamples_box = \ MShell.addFieldCombo ( nFrame = self.MioFrame, labelName ="Samples", helpMessage ="Requested Number of Samples", statusMessage="Requested Number of Samples", initValue ="1", column = 1, row = MShell.nextFieldRow(), width = 10 ) self.MioMaxWaitSec_box = \ MShell.addFieldCombo ( nFrame = self.MioFrame, labelName ="Max Sec", helpMessage ="Maximum Wait time", statusMessage="Maximum Wait time", initValue ="1", column = 3, row = MShell.currentFieldRow(), width = 10 ) MShell.addFieldButton ( nFrame = self.MioFrame, labelName = "Multi Read", helpMessage = "Multiple Register Read", statusMessage= "Multiple Register Read", column = 4, row = MShell.nextFieldRow(), command = self.Mio_MultiRead ) self.MioDumpToFile_var = IntVar() self.MioDumpToFile_var.set(0) MShell.addFieldCheckB ( nFrame = self.MioFrame, labelName = 'Write Dump File', helpMessage = 'Write to Dump File', statusMessage= 'Write to Dump File', column = 2, row = MShell.currentFieldRow(), columnspan = 3, variable = self.MioDumpToFile_var ) self.MioDataIn_box = \ MShell.addFieldEntry ( nFrame = self.MioFrame, labelName ="1st Match", helpMessage ="First Data Match Found", statusMessage="First Data Match Found", column = 1, row = MShell.nextFieldRow(), initValue ="-", bg = 'gray80', width = 10 ) self.MioReply_box = \ MShell.addFieldEntry ( nFrame = self.MioFrame, labelName ="Reply", helpMessage ="Reply", statusMessage="Reply", initValue ="-", bg = 'gray80', columnspan = 3, font = ('Verdana',7), width = 43 ) #-------------------------------------------------------------------------------- def Mio_MultiRead ( self, MasterNum = None, SlaveNum = None, SlotNum = None, ChipNum = None, RegAddr = None, Samples = None, MaxWaitSec = None, CondMask = None, CondValue = None, DumpToFile = None, Comment = None ) : MasterNum_int = updateIntVar ( self.MioMasterNum_var, MasterNum ) SlaveNum_int = updateIntVar ( self.MioSlaveNum_var, SlaveNum ) SlotNum_int = updateComboBox ( self.MioSlotNum_box, SlotNum ) ChipNum_int = updateIntVar ( self.MioChipNum_var, ChipNum ) RegAddr_int = updateComboBox ( self.MioRegAddr_box, RegAddr ) Samples_int = updateComboBox ( self.MioSamples_box, Samples ) CondMask_int = updateComboBox ( self.MioCondMask_box, CondMask ) CondValue_int = updateComboBox ( self.MioCondValue_box, CondValue ) MaxWaitSec_int = updateComboBox ( self.MioMaxWaitSec_box, MaxWaitSec ) DumpToFile_int = updateIntVar ( self.MioDumpToFile_var, DumpToFile ) printLine ( "Mio_Multi", "Read %d Values %s" \ % ( Samples_int, RegAddrString ( MasterNum_int, SlaveNum_int, SlotNum_int, ChipNum_int, RegAddr_int ) ) ) printLine ( "Mio_Multi", "With Condition Data Mask %#06x Value %#06x" \ % ( CondMask_int, CondValue_int ) ) guiCmdName = "Mio_MultiRead" 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) }, "TRIGGER" : { "MASK" : str(CondMask_int), "VALUE" : str(CondValue_int), "MAX_TRY" : str(MaxWaitSec_int), "DUMPTOFILE": str(DumpToFile_int) } } ) AppendCommentField ( xmlCmdDoc, Comment ) guiCmdReply = self.MShell.sendGuiComand ( xmlCmdDoc ) DataIn_str, \ Reply_Status = RetrieveXmlAttr ( CmdReply = guiCmdReply, CmdName = guiCmdName, EltAttrList = [ [ "DATA", "IN", self.MioDataIn_box ] ], ReplyBox = self.MioReply_box ) try : DataIn_int = eval ( DataIn_str ) except : DataIn_int = 0 if ( Reply_Status == eOk ) : printLine ( "Mio_Multi", "Read %#06x = %5d %s" % ( DataIn_int, DataIn_int, RegAddrString ( MasterNum_int, SlaveNum_int, SlotNum_int, ChipNum_int, RegAddr_int ) ) ) else : printLine ( "Mio_Multi", "*** Error Detected ***" ) return DataIn_int, Reply_Status #--------------------------------------------------------------------------------