#! /usr/env/python #-------------------------------------------------------------------------------- """ Application: Dialog_Adf for DAQ_96_Gui ADF-2 Card Level Commands 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 Misc_Constants import SlotNumMax from Xml_Utils import CreateXmlCommand from Xml_Utils import AppendCommentField from Xml_Utils import RetrieveXmlAttr from Misc_Constants import eOk, eError #-------------------------------------------------------------------------------- #-------------------------------------------------------------------------------- class Dialog_Adf : def __init__ ( self, MShell, FrameNum ) : self.MShell = MShell self.AdfFrame = FrameNum # printLine ( "Dialog", 'Frame #%d is "%s"' % ( FrameNum, MShell.frameName[FrameNum] ) ) #-------------------------------------------------------------------------------- def createInterface(self): MShell = self.MShell MShell.addFieldLabel ( nFrame = self.AdfFrame, labelName = 'Access: Card Level IO', column = 1, columnspan = 3, height = 3, width = 35, row = MShell.nextFieldRow() ) # MShell.addFieldLabel ( nFrame = self.AdfFrame, # labelName = "VI Mst/Slv", # column = 1, # row = MShell.nextFieldRow() ) # AdfCrateMasterFrame = \ # MShell.addFieldFrame ( nFrame = self.AdfFrame, # labelName = "VI Frame for Adf", # column = 2, # columnspan = 3, # row = MShell.currentFieldRow() ) self.AdfMasterNum_var = IntVar() self.AdfMasterNum_var.set(0) # MShell.addFieldRadioB ( frame = AdfCrateMasterFrame, # labelName ="M#0", # value = 0, # variable = self.AdfMasterNum_var ) # MShell.addFieldRadioB ( frame = AdfCrateMasterFrame, # labelName ="#1", # value = 1, # variable = self.AdfMasterNum_var ) self.AdfSlaveNum_var = IntVar() self.AdfSlaveNum_var.set(0) # MShell.addFieldRadioB ( frame = AdfCrateMasterFrame, # labelName ="S#0", # value = 0, # variable = self.AdfSlaveNum_var ) # MShell.addFieldRadioB ( frame = AdfCrateMasterFrame, # labelName ="#1", # value = 1, # variable = self.AdfSlaveNum_var ) # MShell.addFieldRadioB ( frame = AdfCrateMasterFrame, # labelName ="#2", # value = 2, # variable = self.AdfSlaveNum_var ) # MShell.addFieldRadioB ( frame = AdfCrateMasterFrame, # labelName ="#3", # value = 3, # variable = self.AdfSlaveNum_var ) self.AdfSlotNum_box = \ MShell.addFieldCombo ( nFrame = self.AdfFrame, labelName ="Slot Num", helpMessage ="Slot Num", statusMessage="Slot Num", initValue ="0", width = 10 ) MShell.addFieldButton ( nFrame = self.AdfFrame, labelName = 'Init Adf Card', helpMessage = 'Init ADF-2 Card', statusMessage= 'Init ADF-2 Card', column = 3, row = MShell.currentFieldRow(), command = self.Adf_InitCard ) MShell.addFieldButton ( nFrame = self.AdfFrame, labelName = 'Send Pseudo-Random', helpMessage = 'Send Pseudo-Random to TABs', statusMessage= 'Send Pseudo-Random to TABs', column = 2, row = MShell.nextFieldRow(), command = self.Adf_SendPrn ) MShell.addFieldButton ( nFrame = self.AdfFrame, labelName = 'Send BLS Data', helpMessage = 'Send BLS Data to TABs', statusMessage= 'Send BLS Data to TABs', column = 3, row = MShell.currentFieldRow(), command = self.Adf_SendBls ) self.AdfReply_box = \ MShell.addFieldEntry ( nFrame = self.AdfFrame, labelName ="Reply", helpMessage ="Reply", statusMessage="Reply", initValue ="-", bg = 'gray80', columnspan = 3, font = ('Verdana',7), width = 43 ) MShell.addFieldButton ( nFrame = self.AdfFrame, labelName = 'Init Adf Crate', helpMessage = 'Init all ADF-2 Cards in Crate', statusMessage= 'Init all ADF-2 Cards in Crate', column = 3, row = MShell.nextFieldRow(), command = self.Adf_InitCrate ) #-------------------------------------------------------------------------------- def Adf_SendPrn ( self, MasterNum = None, SlaveNum = None, SlotNum = None, Comment = None ) : MasterNum_int = updateIntVar ( self.AdfMasterNum_var, MasterNum ) SlaveNum_int = updateIntVar ( self.AdfSlaveNum_var, SlaveNum ) SlotNum_int = updateComboBox ( self.AdfSlotNum_box, SlotNum ) printLine ( "Adf_Card", "Setting up ADF-2 Card %s to send Pseudo-Random Data" \ % ( RegAddrString ( MasterNum_int, SlaveNum_int, SlotNum_int ) ) ) guiCmdName = "Adf_SendPrn" xmlCmdDoc = CreateXmlCommand ( guiCmdName, { "ADF" : { "MASTER" : str(MasterNum_int), "SLAVE" : str(SlaveNum_int), "SLOT" : str(SlotNum_int) } } ) AppendCommentField ( xmlCmdDoc, Comment ) guiCmdReply = self.MShell.sendGuiComand ( xmlCmdDoc ) Reply_Status = RetrieveXmlAttr ( CmdReply = guiCmdReply, CmdName = guiCmdName, ReplyBox = self.AdfReply_box ) if ( Reply_Status != eOk ) : printLine ( "Adf_Card", "*** Error Detected ***" ) return Reply_Status #-------------------------------------------------------------------------------- def Adf_SendBls ( self, MasterNum = None, SlaveNum = None, SlotNum = None, Comment = None ) : MasterNum_int = updateIntVar ( self.AdfMasterNum_var, MasterNum ) SlaveNum_int = updateIntVar ( self.AdfSlaveNum_var, SlaveNum ) SlotNum_int = updateComboBox ( self.AdfSlotNum_box, SlotNum ) printLine ( "Adf_Card", "Setting up ADF-2 Card %s to send BLS Data" \ % ( RegAddrString ( MasterNum_int, SlaveNum_int, SlotNum_int ) ) ) guiCmdName = "Adf_SendBls" xmlCmdDoc = CreateXmlCommand ( guiCmdName, { "ADF" : { "MASTER" : str(MasterNum_int), "SLAVE" : str(SlaveNum_int), "SLOT" : str(SlotNum_int) } } ) AppendCommentField ( xmlCmdDoc, Comment ) guiCmdReply = self.MShell.sendGuiComand ( xmlCmdDoc ) Reply_Status = RetrieveXmlAttr ( CmdReply = guiCmdReply, CmdName = guiCmdName, ReplyBox = self.AdfReply_box ) if ( Reply_Status != eOk ) : printLine ( "Adf_Card", "*** Error Detected ***" ) return Reply_Status #-------------------------------------------------------------------------------- def Adf_InitCard ( self, MasterNum = None, SlaveNum = None, SlotNum = None, Comment = None ) : MasterNum_int = updateIntVar ( self.AdfMasterNum_var, MasterNum ) SlaveNum_int = updateIntVar ( self.AdfSlaveNum_var, SlaveNum ) SlotNum_int = updateComboBox ( self.AdfSlotNum_box, SlotNum ) printLine ( "Adf_Card", "Initialize ADF-2 Card %s " % ( RegAddrString ( MasterNum_int, SlaveNum_int, SlotNum_int ) ) ) guiCmdName = "Adf_InitCard" xmlCmdDoc = CreateXmlCommand ( guiCmdName, { "ADF" : { "MASTER" : str(MasterNum_int), "SLAVE" : str(SlaveNum_int), "SLOT" : str(SlotNum_int) } } ) AppendCommentField ( xmlCmdDoc, Comment ) guiCmdReply = self.MShell.sendGuiComand ( xmlCmdDoc ) Reply_Status = RetrieveXmlAttr ( CmdReply = guiCmdReply, CmdName = guiCmdName, ReplyBox = self.AdfReply_box ) if ( Reply_Status != eOk ) : printLine ( "Adf_Card", "*** Error Detected ***" ) return Reply_Status #-------------------------------------------------------------------------------- def Adf_InitCrate ( self, MasterNum = None, SlaveNum = None, Comment = None ) : Reply_Status = eOk MasterNum_int = updateIntVar ( self.AdfMasterNum_var, MasterNum ) SlaveNum_int = updateIntVar ( self.AdfSlaveNum_var, SlaveNum ) # SlotNum will be sensed for SlotNum in range(SlotNumMax+1) : # i.e. slots 0,1,2,...21 if ( self.MShell.Dialog_Rio.Rio_ProbeSlot( MasterNum = MasterNum_int, SlaveNum = SlaveNum_int, SlotNum = SlotNum ) == "Yes" ) : Partial_Status = \ self.Adf_InitCard( MasterNum = MasterNum_int, SlaveNum = SlaveNum_int, SlotNum = SlotNum ) if ( Partial_Status != eOk ) : Reply_Status = eError return Reply_Status