#! /usr/env/python #-------------------------------------------------------------------------------- """ Application: Dialog_Rrt for DAQ_96_Gui Random Register Test Dialog for the Graphical User Interface to the DAQ_96 Control Program """ #-------------------------------------------------------------------------------- #-------------------------------------------------------------------------------- import os 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 #-------------------------------------------------------------------------------- #-------------------------------------------------------------------------------- class Dialog_Rrt : def __init__ ( self, MShell, FrameNum ) : self.MShell = MShell self.RrtFrame = FrameNum # printLine ( "Dialog", 'Frame #%d is "%s"' % ( FrameNum, MShell.frameName[FrameNum] ) ) #-------------------------------------------------------------------------------- def createInterface(self): MShell = self.MShell MShell.addFieldLabel ( nFrame = self.RrtFrame, labelName = 'Access: Random Register Test', column = 1, columnspan = 5, height = 2, width = 35, row = MShell.nextFieldRow() ) # MShell.addFieldLabel ( nFrame = self.RrtFrame, # labelName = "VI Mst/Slv", # column = 1, # row = MShell.nextFieldRow() ) # RrtCrateMasterFrame = \ # MShell.addFieldFrame ( nFrame = self.RrtFrame, # labelName = "VI Frame for Rrt", # column = 2, # columnspan = 5, # row = MShell.currentFieldRow() ) self.RrtMasterNum_var = IntVar() self.RrtMasterNum_var.set(0) # MShell.addFieldRadioB ( frame = RrtCrateMasterFrame, # labelName ="M#0", # value = 0, # variable = self.RrtMasterNum_var ) # MShell.addFieldRadioB ( frame = RrtCrateMasterFrame, # labelName ="#1", # value = 1, # variable = self.RrtMasterNum_var ) self.RrtSlaveNum_var = IntVar() self.RrtSlaveNum_var.set(0) # MShell.addFieldRadioB ( frame = RrtCrateMasterFrame, # labelName ="S#0", # value = 0, # variable = self.RrtSlaveNum_var ) # MShell.addFieldRadioB ( frame = RrtCrateMasterFrame, # labelName ="#1", # value = 1, # variable = self.RrtSlaveNum_var ) # MShell.addFieldRadioB ( frame = RrtCrateMasterFrame, # labelName ="#2", # value = 2, # variable = self.RrtSlaveNum_var ) # MShell.addFieldRadioB ( frame = RrtCrateMasterFrame, # labelName ="#3", # value = 3, # variable = self.RrtSlaveNum_var ) self.RrtSlotNum_box = \ MShell.addFieldCombo ( nFrame = self.RrtFrame, labelName ="Slot Num", helpMessage ="Slot Num", statusMessage="Slot Num", initValue ="0", width = 10 ) MShell.addFieldLabel ( nFrame = self.RrtFrame, labelName = "Chip Num", column = 1, row = MShell.nextFieldRow() ) RrtChipNumFrame = \ MShell.addFieldFrame ( nFrame = self.RrtFrame, labelName = "Chip Num Rrt", column = 2, columnspan = 5, row = MShell.currentFieldRow() ) self.RrtChipNum_var = IntVar() self.RrtChipNum_var.set(0) MShell.addFieldRadioB ( frame = RrtChipNumFrame, labelName ="Pal/Fpga#0", value = 0, variable = self.RrtChipNum_var ) MShell.addFieldRadioB ( frame = RrtChipNumFrame, labelName ="Fpga#1", value = 1, variable = self.RrtChipNum_var ) self.RrtRegAddr_box = \ MShell.addFieldCombo ( nFrame = self.RrtFrame, labelName ="Reg Addr", helpMessage ="Starting Reg Addr", statusMessage="Starting Reg Addr", initValue ="1", width = 10 ) self.RrtRegAddrCnt_box = \ MShell.addFieldCombo ( nFrame = self.RrtFrame, labelName ="Count", helpMessage ="Reg Addr Count", statusMessage="Reg Addr Count", initValue ="1", column = 3, row = MShell.currentFieldRow(), width = 10 ) MShell.addFieldButton ( nFrame = self.RrtFrame, labelName = 'Add Reg Range', helpMessage = 'Add Reg Range to Test Set', statusMessage= 'Add Reg Range to Test Set', column = 2, row = MShell.nextFieldRow(), command = self.Rrt_AddRange ) MShell.addFieldButton ( nFrame = self.RrtFrame, labelName = 'Clear All', helpMessage = 'Clear All', statusMessage= 'Clear All', column = 4, row = MShell.currentFieldRow(), command = self.Rrt_ClearAll ) self.RrtDefFile = \ MShell.addFieldCombo ( nFrame = self.RrtFrame, labelName ="Reg Def File", helpMessage ="Register Definition File", statusMessage="Register Definition File", columnspan = 5, initValue ="RegTestDef.Rrt", width = 35 ) MShell.addFieldButton ( nFrame = self.RrtFrame, labelName = 'Exec Reg Def', helpMessage = 'Execute Register Definition File', statusMessage= 'Execute Register Definition File', column = 2, row = MShell.nextFieldRow(), command = lambda: MShell.Dialog_Cmd.Cmd_Exec_ComFile( ComFile=self.RrtDefFile.get(), ArgDict={} ) ) MShell.addFieldButton ( nFrame = self.RrtFrame, labelName ="Locate...", helpMessage ="Find Reg Def File", statusMessage="Find Reg Def File", column = 4, row = MShell.currentFieldRow(), command = lambda: MShell.Find_File( ComboBox=self.RrtDefFile ) ) self.RrtTestLoop_box = \ MShell.addFieldCombo ( nFrame = self.RrtFrame, labelName = 'Test Loop', helpMessage = 'Test Loop', statusMessage= 'Test Loop', initValue ="1", width = 10 ) MShell.addFieldButton ( nFrame = self.RrtFrame, labelName = 'Start Test', helpMessage = 'Start Test', statusMessage= 'Start Test', column = 4, row = MShell.currentFieldRow(), command = self.Rrt_StartTest ) self.RrtReply_box = \ MShell.addFieldEntry ( nFrame = self.RrtFrame, labelName ="Reply", helpMessage ="Reply", statusMessage="Reply", initValue ="-", bg = 'gray80', columnspan = 5, font = ('Verdana',7), width = 43 ) #-------------------------------------------------------------------------------- def Rrt_ClearAll ( self, Comment = None ) : printLine ( "Rrt_Clear", "Clear all Registers from List" ) guiCmdName = "Rrt_ClearAll" xmlCmdDoc = CreateXmlCommand ( guiCmdName, { } ) AppendCommentField ( xmlCmdDoc, Comment ) guiCmdReply = self.MShell.sendGuiComand ( xmlCmdDoc ) Reply_Status = RetrieveXmlAttr ( CmdReply = guiCmdReply, CmdName = guiCmdName, ReplyBox = self.RrtReply_box ) if ( Reply_Status != eOk ) : printLine ( "Rrt_Clear", "*** Error Detected ***" ) return Reply_Status #-------------------------------------------------------------------------------- def Rrt_AddRange ( self, MasterNum = None, SlaveNum = None, SlotNum = None, ChipNum = None, RegAddr = None, RegAddrCnt = None, Comment = None ) : MasterNum_int = updateIntVar ( self.RrtMasterNum_var, MasterNum ) SlaveNum_int = updateIntVar ( self.RrtSlaveNum_var, SlaveNum ) SlotNum_int = updateComboBox ( self.RrtSlotNum_box, SlotNum ) ChipNum_int = updateIntVar ( self.RrtChipNum_var, ChipNum ) RegAddr_int = updateComboBox ( self.RrtRegAddr_box, RegAddr ) RegAddrCnt_int = updateComboBox ( self.RrtRegAddrCnt_box, RegAddrCnt ) printLine ( "Rrt_Range", "Add Range %s:%d" % ( RegAddrString ( MasterNum_int, SlaveNum_int, SlotNum_int, ChipNum_int, RegAddr_int ), RegAddr_int+RegAddrCnt_int-1 ) ) guiCmdName = "Rrt_AddRange" 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), "ADDR_COUNT": str(RegAddrCnt_int) } } ) AppendCommentField ( xmlCmdDoc, Comment ) guiCmdReply = self.MShell.sendGuiComand ( xmlCmdDoc ) Reply_Status = RetrieveXmlAttr ( CmdReply = guiCmdReply, CmdName = guiCmdName, ReplyBox = self.RrtReply_box ) if ( Reply_Status != eOk ) : printLine ( "Rrt_Range", "*** Error Detected ***" ) return Reply_Status #-------------------------------------------------------------------------------- def Rrt_StartTest( self, TestLoop = None, Comment = None ) : TestLoop_int = updateComboBox ( self.RrtTestLoop_box, TestLoop ) printLine ( "Rrt_Start", "Start %d Test Loops" % TestLoop_int ) guiCmdName = "Rrt_StartTest" xmlCmdDoc = CreateXmlCommand ( guiCmdName, { "TEST" : { "LOOP" : str(TestLoop_int) } } ) AppendCommentField ( xmlCmdDoc, Comment ) guiCmdReply = self.MShell.sendGuiComand ( xmlCmdDoc, TimeOut_sec = 3600 ) # this may take a while... Reply_Status = RetrieveXmlAttr ( CmdReply = guiCmdReply, CmdName = guiCmdName, ReplyBox = self.RrtReply_box ) if ( Reply_Status != eOk ) : printLine ( "Rrt_Start", "*** Error Detected ***" ) return Reply_Status #--------------------------------------------------------------------------------