#! /usr/env/python #-------------------------------------------------------------------------------- """ Application: DAQ_96_Gui Graphical User Interface to the DAQ 96 Control Program """ #-------------------------------------------------------------------------------- #-------------------------------------------------------------------------------- DAQ_96_Gui_Version = '1.1.A' DAQ_96_Gui_Date = '15-Sep-2008' #-------------------------------------------------------------------------------- #-------------------------------------------------------------------------------- import os import sys from Tkinter import * import Pmw from tkMessageBox import askquestion from MultiShell import MultiShell from Dialog_Vio import Dialog_Vio from Dialog_Rio import Dialog_Rio from Dialog_Mio import Dialog_Mio from Dialog_Hst import Dialog_Hst from Dialog_Cfg import Dialog_Cfg from Dialog_Dac import Dialog_Dac from Dialog_Adf import Dialog_Adf from Dialog_Rrt import Dialog_Rrt from Dialog_Adc import Dialog_Adc from Dialog_Msg import Dialog_Msg from Dialog_Mgr import Dialog_Mgr from Dialog_Com import Dialog_Com from Dialog_Cmd import Dialog_Cmd from Dialog_Ctl import Dialog_Ctl from Dialog_Col import Dialog_Col from Dialog_Plt import Dialog_Plt from Itc_Gui_Client import Itc_Gui_Client, gui_reply_timeout_sec from Itc_Coor_Client import Itc_Coor_Client from Print_Utils import printLine from Print_Utils import startLogFile from Site_Dependent import LogGuiDir from Site_Dependent import CommandFileDir from Site_Dependent import DAQ96_Config_CmdFile from Site_Dependent import DAQ96_Init_CmdFile import py_itc #-------------------------------------------------------------------------------- #-------------------------------------------------------------------------------- # Set the dimensions of the dialog window MainWindowWidth = 450 MainWindowHeight = 550 # misc debug and development flags confirmRequired = "yes" # "yes"/"no" = require confirmation, e.g. before exiting #-------------------------------------------------------------------------------- #-------------------------------------------------------------------------------- class DAQ_96_Gui_App( MultiShell ): # derive from base class MultiShell # global object variables MultiShell.frameName = [] VioFrame = 0 ; MultiShell.frameName.append ( "VME IO" ) RioFrame = 1 ; MultiShell.frameName.append ( "Reg IO" ) MioFrame = 2 ; MultiShell.frameName.append ( "Multi RegRead" ) HstFrame = 3 ; MultiShell.frameName.append ( "Reg Histogram" ) CfgFrame = 4 ; MultiShell.frameName.append ( "Config FPGA" ) DacFrame = 5 ; MultiShell.frameName.append ( "DAC Control" ) AdfFrame = 6 ; MultiShell.frameName.append ( "Adf Card" ) RrtFrame = 7 ; MultiShell.frameName.append ( "Rand Reg Test" ) AdcFrame = 8 ; MultiShell.frameName.append ( "ADC Analysis" ) MsgFrame = 9 ; MultiShell.frameName.append ( "COOR Messages") MgrFrame =10 ; MultiShell.frameName.append ( "TrgMgr Messages" ) ComFrame =11 ; MultiShell.frameName.append ( "TCC Command File" ) CmdFrame =12 ; MultiShell.frameName.append ( "GUI Command File" ) CtlFrame =13 ; MultiShell.frameName.append ( "Control/Status" ) ColFrame =14 ; MultiShell.frameName.append ( "DAQ96/Collect" ) PltFrame =15 ; MultiShell.frameName.append ( "DAQ96/Plot" ) ManFrame =16 ; MultiShell.frameName.append ( "Main Menu" ) # Main is last as totFrame gets adjusted below MultiShell.appversion = DAQ_96_Gui_Version MultiShell.appname = " DAQ_96_Gui V%s (%s)" % ( DAQ_96_Gui_Version, DAQ_96_Gui_Date ) MultiShell.copyright = 'Michigan State University' MultiShell.contactname = 'Philippe Laurens' MultiShell.contactphone = '(517) 355-9200 x2522' MultiShell.contactemail = 'laurens@pa.msu.edu' MultiShell.usecommandarea = 1 MultiShell.balloonhelp = 0 MultiShell.totFrame = ManFrame + 1 # total number of dialog frames MultiShell.curFrame = ManFrame # dialog frame to display at startup = main MultiShell.frameWidth = MainWindowWidth MultiShell.frameHeight = MainWindowHeight #-------------------------------------------------------------------------------- def __init__ ( self, TccNode = 'localhost' ) : # create the log directory if it doesn't exist try : os.listdir ( LogGuiDir ) except : os.mkdir ( LogGuiDir ) # Start a LogFile startLogFile ( LogGuiDir + 'DAQ_96_Gui.log' ) printLine ( "DAQ_96", "Gui Application to DAQ_96_TCC <%s>" % TccNode ) printLine ( "DAQ_96", "DAQ_96_Gui V%s - %s" % ( DAQ_96_Gui_Version, DAQ_96_Gui_Date ) ) printLine ( "DAQ_96", "Using Extension %s" % py_itc.version() ) printLine ( "DAQ_96", "Using python V%s" % sys.version[:6] ) # ITC connection to DAQ96 Control Application for impersonating COOR commands self.coor_client = Itc_Coor_Client ( TccNode ) # ITC connection to DAQ96 Control Application for GUI requests self.gui_client = Itc_Gui_Client ( TccNode ) # Sub-Dialog initialization self.Dialog_Vio = Dialog_Vio( MShell = self, FrameNum = self.VioFrame ) self.Dialog_Rio = Dialog_Rio( MShell = self, FrameNum = self.RioFrame ) self.Dialog_Mio = Dialog_Mio( MShell = self, FrameNum = self.MioFrame ) self.Dialog_Hst = Dialog_Hst( MShell = self, FrameNum = self.HstFrame ) self.Dialog_Cfg = Dialog_Cfg( MShell = self, FrameNum = self.CfgFrame ) self.Dialog_Dac = Dialog_Dac( MShell = self, FrameNum = self.DacFrame ) self.Dialog_Adf = Dialog_Adf( MShell = self, FrameNum = self.AdfFrame ) self.Dialog_Rrt = Dialog_Rrt( MShell = self, FrameNum = self.RrtFrame ) self.Dialog_Adc = Dialog_Adc( MShell = self, FrameNum = self.AdcFrame ) self.Dialog_Msg = Dialog_Msg( MShell = self, FrameNum = self.MsgFrame ) self.Dialog_Mgr = Dialog_Mgr( MShell = self, FrameNum = self.MgrFrame ) self.Dialog_Com = Dialog_Com( MShell = self, FrameNum = self.ComFrame ) self.Dialog_Cmd = Dialog_Cmd( MShell = self, FrameNum = self.CmdFrame ) self.Dialog_Ctl = Dialog_Ctl( MShell = self, FrameNum = self.CtlFrame ) self.Dialog_Col = Dialog_Col( MShell = self, FrameNum = self.ColFrame ) self.Dialog_Plt = Dialog_Plt( MShell = self, FrameNum = self.PltFrame ) # initialize the main base class MultiShell.__init__ ( self ) # Set default directory to command files os.chdir ( CommandFileDir ) printLine ( ) def createInterface(self): MultiShell.createInterface(self) self.createFields_Main() self.Dialog_Vio.createInterface() self.Dialog_Rio.createInterface() self.Dialog_Mio.createInterface() self.Dialog_Hst.createInterface() self.Dialog_Cfg.createInterface() self.Dialog_Dac.createInterface() self.Dialog_Adf.createInterface() self.Dialog_Rrt.createInterface() self.Dialog_Adc.createInterface() self.Dialog_Msg.createInterface() self.Dialog_Mgr.createInterface() self.Dialog_Com.createInterface() self.Dialog_Cmd.createInterface() self.Dialog_Ctl.createInterface() self.Dialog_Col.createInterface() self.Dialog_Plt.createInterface() self.createButtons() def quit(self): if self.confirm() : printLine ( "DAQ_96", "Exiting" ) self.gui_client.quit ( ) self.coor_client.quit( ) printLine ( ) printLine ( "DAQ_96", "Bye" ) printLine ( ) self.root.destroy() # note: sys.exit( 0 ) causes an error def confirm(self, title = "Confirmation", question = "Are you sure?" ): if ( confirmRequired == "yes" ) : if ( askquestion ( title, question, default="no" ) == "no" ) : return FALSE return TRUE #-------------------------------------------------------------------------------- def createButtons(self): self.AppImg = PhotoImage ( file = "LArTPC.gif" ) self.buttonAdd ( buttonName = 'LArTPC', borderwidth = 0, image = self.AppImg ) self.buttonAdd ( buttonName = 'Main', helpMessage = 'Main Menu', statusMessage = 'Main Menu', width = 10, command = lambda: self.selectFrame(self.ManFrame) ) self.buttonAdd ( buttonName = 'Exit', helpMessage = 'Exit', statusMessage = 'Exit', width = 10, command = self.quit ) self.LogoImg = PhotoImage ( file = "MrFroggy.gif" ) self.buttonAdd ( buttonName = 'Froggy', borderwidth = 0, image = self.LogoImg ) #-------------------------------------------------------------------------------- def createFields_Main(self): self.addFieldLabel ( nFrame = self.ManFrame, labelName = 'DAQ96 User Interface', column = 1, columnspan = 2, height = 1, width = 35, row = self.nextFieldRow() ) self.addFieldLabel ( nFrame = self.ManFrame, labelName = '------------- Expert --------------', column = 1, columnspan = 2, width = 35, font = ('Verdana',7), pady = 0, gridPady = 0, gridSticky = N, row = self.nextFieldRow() ) self.addFieldButton ( nFrame = self.ManFrame, labelName = 'VME IO', helpMessage = 'VME IO', statusMessage= 'VME IO', column = 1, row = self.nextFieldRow(), width = 15, command = lambda: self.selectFrame(self.VioFrame) ) self.addFieldButton ( nFrame = self.ManFrame, labelName = 'Register IO', helpMessage = 'Register IO', statusMessage= 'Register IO', column = 2, row = self.currentFieldRow(), width = 15, command = lambda: self.selectFrame(self.RioFrame) ) self.addFieldButton ( nFrame = self.ManFrame, labelName = 'Config ADF FPGA', helpMessage = 'Configure ADF-2 FPGA', statusMessage= 'Configure ADF-2 FPGA', column = 1, row = self.nextFieldRow(), width = 15, command = lambda: self.selectFrame(self.CfgFrame) ) self.addFieldButton ( nFrame = self.ManFrame, labelName = 'Ped DAC Control', helpMessage = 'Pedestal DAC Control', statusMessage= 'Pedestal DAC Control', column = 2, row = self.currentFieldRow(), width = 15, command = lambda: self.selectFrame(self.DacFrame) ) self.addFieldButton ( nFrame = self.ManFrame, labelName = 'Rand Reg Test', helpMessage = 'Random Register Test', statusMessage= 'Random Register Test', column = 1, row = self.nextFieldRow(), width = 15, command = lambda: self.selectFrame(self.RrtFrame) ) self.addFieldButton ( nFrame = self.ManFrame, labelName = 'ADC Analysis', helpMessage = 'ADC Analysis', statusMessage= 'ADC Analysis', column = 2, row = self.currentFieldRow(), width = 15, command = lambda: self.selectFrame(self.AdcFrame) ) self.addFieldButton ( nFrame = self.ManFrame, labelName = 'TBA1', helpMessage = 'Not Allocated', statusMessage= 'Not Allocated', column = 1, row = self.nextFieldRow(), width = 15, state = DISABLED, command = lambda: self.selectFrame(self.RrtFrame) ) self.addFieldButton ( nFrame = self.ManFrame, labelName = 'Adf Card', helpMessage = 'Adf Card Control', statusMessage= 'Adf Card Control', column = 2, row = self.currentFieldRow(), width = 15, command = lambda: self.selectFrame(self.AdfFrame) ) self.addFieldButton ( nFrame = self.ManFrame, labelName = 'Simu COOR Msg', helpMessage = 'Send Simulated COOR Msg', statusMessage= 'Send Simulated COOR Msg', column = 1, row = self.nextFieldRow(), width = 15, command = lambda: self.selectFrame(self.MsgFrame) ) self.addFieldButton ( nFrame = self.ManFrame, labelName = 'Control/Status', helpMessage = 'Gui Control/Status', statusMessage= 'Gui Control/Status', column = 2, row = self.currentFieldRow(), width = 15, command = lambda: self.selectFrame(self.CtlFrame) ) self.addFieldButton ( nFrame = self.ManFrame, labelName = 'TCC Com File', helpMessage = 'Execute Remote TCC Command File', statusMessage= 'Execute Remote TCC Command File', column = 1, row = self.nextFieldRow(), width = 15, command = lambda: self.selectFrame(self.ComFrame) ) self.addFieldButton ( nFrame = self.ManFrame, labelName = 'GUI Cmd File', helpMessage = 'Execute Local GUI python Command File', statusMessage= 'Execute Local GUI python Command File', column = 2, row = self.currentFieldRow(), width = 15, command = lambda: self.selectFrame(self.CmdFrame) ) self.addFieldLabel ( nFrame = self.ManFrame, labelName = '------------ DAQ96 --------------', column = 1, columnspan = 2, width = 35, font = ('Verdana',7), pady = 0, gridPady = 0, gridSticky = N, row = self.nextFieldRow() ) self.addFieldButton ( nFrame = self.ManFrame, labelName = 'Collect Events', helpMessage = 'Collect Events Raw Data', statusMessage= 'Collect Events Raw Data', column = 1, row = self.nextFieldRow(), width = 15, command = lambda: self.selectFrame(self.ColFrame) ) self.addFieldButton ( nFrame = self.ManFrame, labelName = 'Plot Raw Data', helpMessage = 'Plot Raw Data Events', statusMessage= 'Plot Raw Data Events', column = 2, row = self.currentFieldRow(), width = 15, command = lambda: self.selectFrame(self.PltFrame) ) self.addFieldButton ( nFrame = self.ManFrame, labelName = "Configure DAQ96", helpMessage = "Configure DAQ96", statusMessage= "Configure DAQ96", width = 15, column = 1, row = self.nextFieldRow(), command = lambda: self.Dialog_Cmd.Cmd_Exec_ComFile ( ComFile = CommandFileDir \ + DAQ96_Config_CmdFile ) ) self.addFieldButton ( nFrame = self.ManFrame, labelName = "Initialize DAQ96", helpMessage = "Initialize DAQ96", statusMessage= "Initialize DAQ96", width = 15, column = 2, row = self.currentFieldRow(), command = lambda: self.Dialog_Cmd.Cmd_Exec_ComFile ( ComFile = CommandFileDir \ + DAQ96_Init_CmdFile ) ) #-------------------------------------------------------------------------------- def sendGuiComand ( self, xmlCmdDoc, TimeOut_sec = gui_reply_timeout_sec ) : return self.gui_client.sendGuiComand ( xmlCmdDoc, TimeOut_sec ) #-------------------------------------------------------------------------------- #-------------------------------------------------------------------------------- if __name__ == '__main__': DAQ_96_Gui_App ( ).run()