#! /usr/env/python #-------------------------------------------------------------------------------- """ Application: Dialog_Com for DAQ_96_Gui Remote Command File Dialog for the Graphical User Interface to the DAQ_96 Control Program """ #-------------------------------------------------------------------------------- #-------------------------------------------------------------------------------- import os import sys import string import time from Tkinter import * import Pmw from MultiShell import updateComboBox from Print_Utils import printLine from showException import showException from Xml_Utils import CreateXmlCommand from Xml_Utils import AppendCommentField from Xml_Utils import RetrieveXmlAttr from Misc_Constants import eOk, eError #-------------------------------------------------------------------------------- # these are not needed in this module per se, but useful in the command files being called from Misc_Constants import eOk, eError #-------------------------------------------------------------------------------- #-------------------------------------------------------------------------------- class Dialog_Com : def __init__ ( self, MShell, FrameNum ) : self.MShell = MShell self.ComFrame = FrameNum # printLine ( "Dialog", 'Frame #%d is "%s"' % ( FrameNum, MShell.frameName[FrameNum] ) ) #-------------------------------------------------------------------------------- def createInterface(self): MShell = self.MShell MShell.addFieldLabel ( nFrame = self.ComFrame, labelName = 'TCC Command File', column = 1, columnspan = 3, height = 3, width = 35, row = MShell.nextFieldRow() ) self.ComComFile = \ MShell.addFieldCombo ( nFrame = self.ComFrame, labelName ="Com File", helpMessage ="TCC Command File", statusMessage="TCC Command File", columnspan = 3, width = 35 ) MShell.addFieldButton ( nFrame = self.ComFrame, labelName ="Locate TCC ComFile...", helpMessage ="Find TCC Command File (if on TCC)", statusMessage="Find TCC Command File (if on TCC)", column = 3, row = MShell.nextFieldRow(), command = lambda: MShell.Find_File( ComboBox=self.ComComFile) ) MShell.addFieldLabel ( nFrame = self.ComFrame, labelName = '', row = MShell.nextFieldRow() ) MShell.addFieldLabel ( nFrame = self.ComFrame, labelName = 'Execute', column = 1, row = MShell.nextFieldRow() ) MShell.addFieldButton ( nFrame = self.ComFrame, labelName = 'VME IO ComFile', helpMessage = 'Execute as VME IO Command File', statusMessage= 'Execute as VME IO Command File', width = 15, column = 2, row = MShell.currentFieldRow(), command = self.Com_Exec_VioFile ) MShell.addFieldLabel ( nFrame = self.ComFrame, labelName = 'ComFile', column = 1, row = MShell.nextFieldRow() ) MShell.addFieldButton ( nFrame = self.ComFrame, labelName = 'Reg IO ComFile', helpMessage = 'Execute as Register IO Command File (to ADF)', statusMessage= 'Execute as Register IO Command File (to ADF)', width = 15, column = 2, row = MShell.currentFieldRow(), command = self.Com_Exec_RioFile ) MShell.addFieldButton ( nFrame = self.ComFrame, labelName = 'Ser IO ComFile', helpMessage = 'Execute as Serial IO Command File (to TAB/GAB)', statusMessage= 'Execute as Serial IO Command File (to TAB/GAB)', width = 15, column = 3, row = MShell.currentFieldRow(), command = self.Com_Exec_SioFile ) MShell.addFieldLabel ( nFrame = self.ComFrame, labelName = 'On TCC', column = 1, row = MShell.nextFieldRow() ) MShell.addFieldButton ( nFrame = self.ComFrame, labelName = 'Config ComFile', helpMessage = 'Execute as FPGA Config Command File', statusMessage= 'Execute as FPGA Config Command File', width = 15, column = 2, row = MShell.currentFieldRow(), command = self.Com_Exec_CfgFile ) MShell.addFieldButton ( nFrame = self.ComFrame, labelName = 'TT Info ComFile', helpMessage = 'Execute as Trigger Tower Info Command File', statusMessage= 'Execute as Trigger Tower Info Command File', width = 15, column = 3, row = MShell.currentFieldRow(), command = self.Com_Exec_TtiFile ) MShell.addFieldLabel ( nFrame = self.ComFrame, labelName = 'as...', column = 1, row = MShell.nextFieldRow() ) MShell.addFieldButton ( nFrame = self.ComFrame, labelName = 'Self Msg ComFile', helpMessage = 'Execute as Send Self Messages Command File', statusMessage= 'Execute as Send Self Messages Command File', width = 15, column = 2, row = MShell.currentFieldRow(), command = self.Com_Exec_MsgFile ) MShell.addFieldButton ( nFrame = self.ComFrame, labelName = 'Master ComFile', helpMessage = 'Execute as Master Command File', statusMessage= 'Execute as Master Command File', width = 15, column = 3, row = MShell.currentFieldRow(), command = self.Com_Exec_McfFile ) MShell.addFieldLabel ( nFrame = self.ComFrame, labelName = '', row = MShell.nextFieldRow() ) self.ComReply_box = \ MShell.addFieldEntry ( nFrame = self.ComFrame, labelName ="Reply", helpMessage ="Reply", statusMessage="Reply", initValue ="-", bg = 'gray80', columnspan = 3, font = ('Verdana',7), width = 43 ) #-------------------------------------------------------------------------------- def Com_Exec_VioFile ( self, ComFile = None, Comment = None ) : updateComboBox ( self.ComComFile, ComFile ) ComFile_str = self.ComComFile.get() printLine ( "Com_File", "Execute TCC VME IO Command File <%s>" % ComFile_str ) guiCmdName = "Com_ParseFile" xmlCmdDoc = CreateXmlCommand ( guiCmdName, { "VIO_FILE": { "NAME" : ComFile_str } } ) AppendCommentField ( xmlCmdDoc, Comment ) guiCmdReply = self.MShell.sendGuiComand ( xmlCmdDoc ) Reply_Status = RetrieveXmlAttr ( CmdReply = guiCmdReply, CmdName = guiCmdName, ReplyBox = self.ComReply_box ) if ( Reply_Status != eOk ) : printLine ( "Com_File", "*** Error Detected ***" ) return Reply_Status #-------------------------------------------------------------------------------- def Com_Exec_RioFile ( self, ComFile = None, Comment = None ) : updateComboBox ( self.ComComFile, ComFile ) ComFile_str = self.ComComFile.get() printLine ( "Com_File", "Execute TCC Reg IO Command File <%s>" % ComFile_str ) guiCmdName = "Com_ParseFile" xmlCmdDoc = CreateXmlCommand ( guiCmdName, { "RIO_FILE": { "NAME" : ComFile_str } } ) AppendCommentField ( xmlCmdDoc, Comment ) guiCmdReply = self.MShell.sendGuiComand ( xmlCmdDoc ) Reply_Status = RetrieveXmlAttr ( CmdReply = guiCmdReply, CmdName = guiCmdName, ReplyBox = self.ComReply_box ) if ( Reply_Status != eOk ) : printLine ( "Com_File", "*** Error Detected ***" ) return Reply_Status #-------------------------------------------------------------------------------- def Com_Exec_SioFile ( self, ComFile = None, Comment = None ) : updateComboBox ( self.ComComFile, ComFile ) ComFile_str = self.ComComFile.get() printLine ( "Com_File", "Execute TCC Serial IO Command File <%s>" % ComFile_str ) guiCmdName = "Com_ParseFile" xmlCmdDoc = CreateXmlCommand ( guiCmdName, { "SIO_FILE": { "NAME" : ComFile_str } } ) AppendCommentField ( xmlCmdDoc, Comment ) guiCmdReply = self.MShell.sendGuiComand ( xmlCmdDoc ) Reply_Status = RetrieveXmlAttr ( CmdReply = guiCmdReply, CmdName = guiCmdName, ReplyBox = self.ComReply_box ) if ( Reply_Status != eOk ) : printLine ( "Com_File", "*** Error Detected ***" ) return Reply_Status #-------------------------------------------------------------------------------- def Com_Exec_CfgFile ( self, ComFile = None, Comment = None ) : updateComboBox ( self.ComComFile, ComFile ) ComFile_str = self.ComComFile.get() printLine ( "Com_File", "Execute TCC FPGA Config Command File <%s>" % ComFile_str ) guiCmdName = "Com_ParseFile" xmlCmdDoc = CreateXmlCommand ( guiCmdName, { "CFG_FILE": { "NAME" : ComFile_str } } ) AppendCommentField ( xmlCmdDoc, Comment ) guiCmdReply = self.MShell.sendGuiComand ( xmlCmdDoc ) Reply_Status = RetrieveXmlAttr ( CmdReply = guiCmdReply, CmdName = guiCmdName, ReplyBox = self.ComReply_box ) if ( Reply_Status != eOk ) : printLine ( "Com_File", "*** Error Detected ***" ) return Reply_Status #-------------------------------------------------------------------------------- def Com_Exec_TtiFile ( self, ComFile = None, Comment = None ) : updateComboBox ( self.ComComFile, ComFile ) ComFile_str = self.ComComFile.get() printLine ( "Com_File", "Execute TCC TrigTwr Info Command File <%s>" % ComFile_str ) guiCmdName = "Com_ParseFile" xmlCmdDoc = CreateXmlCommand ( guiCmdName, { "TTI_FILE": { "NAME" : ComFile_str } } ) AppendCommentField ( xmlCmdDoc, Comment ) guiCmdReply = self.MShell.sendGuiComand ( xmlCmdDoc ) Reply_Status = RetrieveXmlAttr ( CmdReply = guiCmdReply, CmdName = guiCmdName, ReplyBox = self.ComReply_box ) if ( Reply_Status != eOk ) : printLine ( "Com_File", "*** Error Detected ***" ) return Reply_Status #-------------------------------------------------------------------------------- def Com_Exec_MsgFile ( self, ComFile = None, Comment = None ) : updateComboBox ( self.ComComFile, ComFile ) ComFile_str = self.ComComFile.get() printLine ( "Com_File", "Execute TCC Send Msg to Self Command File <%s>" % ComFile_str ) guiCmdName = "Com_ParseFile" xmlCmdDoc = CreateXmlCommand ( guiCmdName, { "MSG_FILE": { "NAME" : ComFile_str } } ) AppendCommentField ( xmlCmdDoc, Comment ) guiCmdReply = self.MShell.sendGuiComand ( xmlCmdDoc ) Reply_Status = RetrieveXmlAttr ( CmdReply = guiCmdReply, CmdName = guiCmdName, ReplyBox = self.ComReply_box ) if ( Reply_Status != eOk ) : printLine ( "Com_File", "*** Error Detected ***" ) return Reply_Status #-------------------------------------------------------------------------------- def Com_Exec_McfFile ( self, ComFile = None, Comment = None ) : updateComboBox ( self.ComComFile, ComFile ) ComFile_str = self.ComComFile.get() printLine ( "Com_File", "Execute TCC Master Command File <%s>" % ComFile_str ) guiCmdName = "Com_ParseFile" xmlCmdDoc = CreateXmlCommand ( guiCmdName, { "MCF_FILE": { "NAME" : ComFile_str } } ) AppendCommentField ( xmlCmdDoc, Comment ) guiCmdReply = self.MShell.sendGuiComand ( xmlCmdDoc ) Reply_Status = RetrieveXmlAttr ( CmdReply = guiCmdReply, CmdName = guiCmdName, ReplyBox = self.ComReply_box ) if ( Reply_Status != eOk ) : printLine ( "Com_File", "*** Error Detected ***" ) return Reply_Status