00001 #!/usr/local/bin/python 00002 # 00003 # Copyright 2004 00004 # by 00005 # The Board of Trustees of the 00006 # Leland Stanford Junior University. 00007 # All rights reserved. 00008 # 00009 00010 __facility__ = "Online" 00011 __abstract__ = "GLAST LAT Coincidence based Trigger System Interface classes" 00012 __author__ = "Jim Panetta <panetta@slac.stanford.edu> SLAC - GLAST I&T" 00013 __date__ = "2/14/04" 00014 __version__ = "$Revision: 2.4 $" 00015 __release__ = "$Name: R04-12-00 $" 00016 __credits__ = "SLAC" 00017 00018 import LATTE.copyright_SLAC 00019 00020 from TrgMiniGLTRegisters import TrgMiniGLTRegisters 00021 from TrgConditionsValue import TrgConditionsValue 00022 from TrgObject import TrgObject 00023 00024 """TrgMiniGLT: This file implements the hardware register access to the MiniGLT""" 00025 00026 class TrgMiniGLT(TrgMiniGLTRegisters): 00027 """\brief Mini GLT Hardware abstraction implementation 00028 """ 00029 00030 __SWEEP_MARKER = 5 00031 __SOLICIT_MASK = ~0x01 00032 00033 def __init__(self): 00034 """\brief TrgMiniGLT constructor 00035 """ 00036 TrgMiniGLTRegisters.__init__(self) 00037 self.__glt = None 00038 00039 def __commit(self): 00040 """\brief commit function 00041 This function commits the configuration defined by this 00042 TrgMiniGLT object to the hardware. It does *all* the registers. 00043 """ 00044 glt = self.GLT() 00045 00046 # set all engine destination addresses. 00047 # Because engines can't have a real HW dependence, this is done by cheating: 00048 # replace each instance of the TrgEngineRequest.destination function 00049 # with a local private function. 00050 for engineNo in range(TrgObject.ENGINE_NUMBER_MAX + 1): 00051 self.engines().engine(engineNo).request().destination = self.__getDestinationFromEPU 00052 00053 glt.PARITY = self.parity() 00054 glt.TAG = self.tag() 00055 glt.EVENT_NUMBER = self.eventNumber() 00056 glt.DESTINATION = self.destination() 00057 glt.MARKER = self.marker() 00058 glt.TACK = self.tack() 00059 glt.ZERO_SUPPRESS = self.zeroSuppress() 00060 glt.FOUR_RANGE_READOUT = self.fourRangeReadout() 00061 glt.CAL_STROBE = self.calStrobe() 00062 00063 glt.MASK = ~0 # everything disabled by default 00064 00065 def GLT(self, glt = None): 00066 """\brief GLT function 00067 \params glt: a GGLT object 00068 This function sets the GLT hardware implementation used by 00069 TrgGem. 00070 """ 00071 if glt is not None: 00072 self.__glt = glt 00073 self.__epuaddr = glt.getEPUaddr() 00074 return self.__glt 00075 00076 def __getDestinationFromEPU(self): 00077 return self.__epuaddr 00078 00079 ############### Pure virtual function implementation 00080 def solicit(self): 00081 # transmit the GEM's TRIGGER dataless command 00082 self.GLT().CMD_SELF_TRIGGER = 1 00083 00084 def enable(self, mask=None): 00085 if mask is not None: 00086 outMask = mask 00087 elif self.__condValue is not None: 00088 outMask = ~self.conditions().value() # remember the MiniGLT has ~logic 00089 else: 00090 raise AssertionError, "Attempting to enable a TrgConditionsValue of None" 00091 00092 self.GLT().MASK = outMask 00093 self.GLT().enableMask() 00094 00095 def disable(self): 00096 self.GLT().disableMask() 00097 00098 def shut(self, marker): 00099 """Implementation of the shut function. 00100 """ 00101 00102 #0) disable triggers 00103 self.disable() 00104 00105 #1) Set up marker logic 00106 glt = self.GLT() 00107 00108 mask = glt.MASK # Cache Mask, CalStrobe and Tack 00109 calStrobe = glt.CAL_STROBE 00110 tack = glt.TACK 00111 00112 glt.MASK = TrgMiniGLT.__SOLICIT_MASK # Enable internal trigger only 00113 glt.MARKER = marker # Signal that we're sweeping 00114 glt.CAL_STROBE = 0 # Don't inject charge 00115 glt.TACK = 0 # Don't force a readout 00116 glt.enableMask() 00117 self.solicit() # Solicit a trigger 00118 glt.disableMask() 00119 00120 #4) Put the original contents of scheduler 0x40 back, and put the TAM back 00121 glt.CAL_STROBE = calStrobe 00122 glt.TACK = tack 00123 glt.MARKER = 0 00124 glt.MASK = mask 00125 00126 #5) Put the trigger conditions back 00127 glt.enableMask() 00128 00129 00130 class MiniGLTTrgConditionsValue(TrgConditionsValue): 00131 """This class overrides the value() method of TrgConditionsValue 00132 as the MiniGLT has a different bitmap for the MASK register. 00133 It also provides the external() function. 00134 00135 Use this class instead of TrgConditionsValue for MiniGLT operations. 00136 """ 00137 def __init__(self): 00138 TrgConditionsValue.__init__(self) 00139 00140 def value(self): 00141 val = 0 00142 val |= ( self.solicited() & 0x1 ) << 0 00143 val |= ( self.external() & 0x1 ) << 1 00144 val |= ( self.calLow() & 0x1 ) << 2 00145 val |= ( self.calHigh() & 0x1 ) << 3 00146 val |= ( self.tkr() & 0x1 ) << 4 00147 return val 00148 00149 def external(self): 00150 return False 00151