Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | Related Pages

TrgGemCounters.py

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 Trigger Object class"
00012 __author__   = "Jim Panetta <panetta@slac.stanford.edu> SLAC - GLAST I&T"
00013 __date__     = "2/14/04"
00014 __version__  = "$Revision: 2.2 $"
00015 __release__  = "$Name: R04-12-00 $"
00016 __credits__  = "SLAC"
00017 
00018 import LATTE.copyright_SLAC
00019 
00020 from TrgObject          import TrgObject
00021 from TrgTriggerCounters import TrgTriggerCounters
00022 from TrgTriggerCounters import TrgTriggerStats
00023 
00024 from TrgTileCounters    import TrgTileCounters
00025 from TrgTileCounters    import TrgTileStats
00026 
00027 from TrgCnoCounters     import TrgCnoCounters
00028 from TrgCnoCounters     import TrgCnoStats
00029 
00030 from TrgCmdCounters     import TrgCmdCounters
00031 from TrgCmdCounters     import TrgCmdStats
00032 
00033 from TrgEventCounter    import TrgEventCounter
00034 
00035 from TrgPPSTimer        import TrgPPSTimer
00036 
00037 """TrgGemCounters: Trigger GEM counter hardware implementation class"""
00038 
00039 
00040 class TrgGemTriggerCounters(TrgTriggerCounters):
00041   """\brief TrgGemTriggerCounters class
00042   
00043   This class implements the HW abstraction corresponding to
00044   figure 66-69 of the GEM document: LAT-01545 Section 2.6.1 and 2.6.2
00045   
00046   """
00047   def __init__(self,glt):
00048     """\brief TrgGemTriggerCounters constructor
00049     """
00050     TrgTriggerCounters.__init__(self)
00051     self.__stats = TrgGemTriggerStats(glt)
00052     if glt is not None:
00053       self.__cmd = glt.downGEMST()
00054     else:
00055       self.__cmd = None
00056     
00057   def stats(self):
00058     """\brief stats() member function
00059     Returns an object that accesses the trigger statistics
00060     \return a TrgGemTriggerStats object
00061     """
00062     return self.__stats
00063   
00064   def reset(self):
00065     """\brief reset() member function
00066     Reset the statistics registers
00067     """
00068     # writing to the register resets it.
00069     self.__cmd.LIVETIME      = 0
00070     self.__cmd.PRESCALED = 0
00071     self.__cmd.DISCARDED = 0
00072     self.__cmd.SENT      = 0
00073     
00074 class TrgGemTriggerStats(TrgTriggerStats):
00075   """\brief TrgGemTriggerStats
00076   This class implements the HW abstraction corresponding to
00077   figure 66-69 of the GEM document: LAT-01545 Section 2.6.1 and 2.6.2
00078   
00079   Note:  Reading the livetime register latches all 4 registers.
00080          Rereading the livetime register unlatches the registers.
00081   """
00082   def __init__(self,glt):
00083     """\brief TrgGemTriggerStats constructor
00084     """
00085     TrgTriggerStats.__init__(self)
00086     if glt is not None:
00087       self.__cmd = glt.downGEMST()
00088     else:
00089       self.__cmd = None
00090     
00091   def livetime(self):
00092     return self.__cmd.LIVETIME & 0x0fff
00093     
00094   def prescaled(self):
00095     return self.__cmd.PRESCALED & 0x0fff
00096     
00097   def discarded(self):
00098     return self.__cmd.DISCARDED & 0x0fff
00099     
00100   def sent(self):
00101     return self.__cmd.SENT & 0x0fff
00102   
00103 # ###########
00104   
00105 class TrgGemTileCounters(TrgTileCounters):
00106   """ \brief TrgGemTileCounters
00107   
00108   This class implements the HW abstraction corresponding to
00109   the tile counter detailed in the GEM document: 
00110   LAT-01545 Section 2.6
00111   """
00112   def __init__(self,glt):
00113     """\brief TrgGemTileCounters constructor
00114     """
00115     TrgTileCounters.__init__(self)
00116     self.__stats = TrgGemTileStats(glt)
00117     if glt is not None:
00118       self.__cmd = glt.downGEMST()
00119     else:
00120       self.__cmd = None
00121 
00122   def stats(self):
00123     return self.__stats
00124 
00125   def reset(self):
00126     """\brief reset() member function
00127     
00128     Reset the tile counter register
00129     """
00130     self.__cmd.TILE_COUNTERS = 0
00131 
00132   def assignA(self,tileNumber):
00133     """\brief assignA() member function
00134     
00135     Assign the 'A' tile counter to watch a particular tile
00136     Immediately after counter assignment, both counters are reset.
00137     """
00138     if tileNumber < TrgObject.TILE_NUMBER_MIN or \
00139        tileNumber > TrgObject.TILE_NUMBER_MAX:
00140       raise IndexError, "tileNumber is out of range"
00141 
00142     self.__cmd.TILE_0 = ( tileNumber )
00143     self.reset()
00144 
00145   def assignB(self, tileNumber):
00146     """\brief assignB() member function
00147     
00148     Assign the 'B' tile counter to watch a particular tile
00149     Immediately after counter assignment, both counters are reset.
00150     """
00151     if tileNumber < TrgObject.TILE_NUMBER_MIN or \
00152        tileNumber > TrgObject.TILE_NUMBER_MAX:
00153       raise IndexError, "tileNumber is out of range"
00154 
00155     self.__cmd.TILE_1 = ( tileNumber )
00156     self.reset()
00157 
00158   def assignAB(self, a, b):
00159     """\brief assignAB() member function
00160     
00161     Assign both the 'A' and the'B' tile counters to watch two tiles
00162     Immediately after counter assignment, both counters are reset.
00163     """
00164     if a < TrgObject.TILE_NUMBER_MIN or \
00165        a > TrgObject.TILE_NUMBER_MAX:
00166       raise IndexError, "tileNumber is out of range"
00167     if b < TrgObject.TILE_NUMBER_MIN or \
00168        b > TrgObject.TILE_NUMBER_MAX:
00169       raise IndexError, "tileNumber is out of range"
00170 
00171     self.__cmd.TILE_0 = ( a & 0x7f )
00172     self.__cmd.TILE_1 = ( b & 0x7f )
00173     self.reset()
00174     
00175 class TrgGemTileStats(TrgTileStats):
00176   """\brief TrgGemTileStats
00177   
00178   This class implements the HW abstraction corresponding to
00179   figure 64 of the GEM document: LAT-01545 Section 2.5
00180   """
00181   def __init__(self,glt):
00182     """\brief TrgGemTileStats constructor
00183     """
00184     TrgTileStats.__init__(self)
00185     if glt is not None:
00186       self.__cmd = glt.downGEMST()
00187     else:
00188       self.__cmd = None
00189       
00190   def A(self):
00191     return self.__cmd.TILE_COUNTERS & 0xffff
00192     
00193   def B(self):
00194     return ( self.__cmd.TILE_COUNTERS >> 16 ) & 0xffff
00195   
00196 # ###########
00197   
00198 class TrgGemCnoCounters(TrgCnoCounters):
00199   """ \brief TrgGemCnoCounters
00200   
00201   This class implements the HW abstraction corresponding to
00202   the Cno counter detailed in the GEM document: 
00203   LAT-01545 Section 2.6
00204   """
00205   def __init__(self,glt):
00206     """\brief TrgGemCnoCounters constructor
00207     """
00208     TrgCnoCounters.__init__(self)
00209     self.__stats = TrgGemCnoStats(glt)
00210     if glt is not None:
00211       self.__cmd = glt.downGEMST()
00212     else:
00213       self.__cmd = None
00214 
00215   def stats(self):
00216     return self.__stats
00217 
00218   def reset(self):
00219     """\brief reset() member function
00220     
00221     Reset the Cno counter register
00222     """
00223     self.__cmd.CNO_COUNTERS = 0
00224 
00225   def assignA(self,CnoNumber):
00226     """\brief assignA() member function
00227     
00228     Assign the 'A' Cno counter to watch a particular Cno
00229     Immediately after counter assignment, both counters are reset.
00230     """
00231     if CnoNumber < TrgObject.CNO_NUMBER_MIN or \
00232        CnoNumber > TrgObject.CNO_NUMBER_MAX:
00233       raise IndexError, "CnoNumber is out of range"
00234 
00235     self.__cmd.CNO_0 = ( CnoNumber )
00236     self.reset()
00237 
00238   def assignB(self, CnoNumber):
00239     """\brief assignB() member function
00240     
00241     Assign the 'B' Cno counter to watch a particular Cno
00242     Immediately after counter assignment, both counters are reset.
00243     """
00244     if CnoNumber < TrgObject.CNO_NUMBER_MIN or \
00245        CnoNumber > TrgObject.CNO_NUMBER_MAX:
00246       raise IndexError, "CnoNumber is out of range"
00247 
00248     self.__cmd.CNO_1 = ( CnoNumber )
00249     self.reset()
00250 
00251   def assignAB(self, a, b):
00252     """\brief assignAB() member function
00253     
00254     Assign both the 'A' and the'B' Cno counters to watch two Cnos
00255     Immediately after counter assignment, both counters are reset.
00256     """
00257     if a < TrgObject.CNO_NUMBER_MIN or \
00258        a > TrgObject.CNO_NUMBER_MAX:
00259       raise IndexError, "CnoNumber is out of range"
00260     if b < TrgObject.CNO_NUMBER_MIN or \
00261        b > TrgObject.CNO_NUMBER_MAX:
00262       raise IndexError, "CnoNumber is out of range"
00263 
00264     self.__cmd.CNO_0 = ( a & 0xf )
00265     self.__cmd.CNO_1 = ( b & 0xf )
00266     self.reset()
00267     
00268 class TrgGemCnoStats(TrgCnoStats):
00269   """\brief TrgGemCnoStats
00270   
00271   This class implements the HW abstraction corresponding to
00272   figure 64 of the GEM document: LAT-01545 Section 2.5
00273   """
00274   def __init__(self,glt):
00275     """\brief TrgGemCnoStats constructor
00276     """
00277     TrgCnoStats.__init__(self)
00278     if glt is not None:
00279       self.__cmd = glt.downGEMST()
00280     else:
00281       self.__cmd = None
00282       
00283   def A(self):
00284     return self.__cmd.CNO_COUNTERS & 0xffff
00285     
00286   def B(self):
00287     return ( self.__cmd.CNO_COUNTERS >> 16 ) & 0xffff
00288   
00289 # ###########
00290   
00291 class TrgGemCmdCounters(TrgCmdCounters):
00292   """\brief TrgGemCmdCounters
00293   
00294   This class implements the HW abstraction corresponding to
00295   figure 62 of the GEM document: LAT-01545 Section 2.3.4
00296   """
00297   def __init__(self,glt):
00298     """\brief TrgGemCmdCounters constructor
00299     """
00300     TrgCmdCounters.__init__(self)
00301     self.__stats = TrgGemCmdStats(glt)
00302     if glt is not None:
00303       self.__cmd = glt.downGEMC()
00304     else:
00305       self.__cmd = None
00306 
00307   def stats(self):
00308     return self.__stats
00309 
00310   def reset(self):
00311     """\brief reset() member function
00312     
00313     Reset the command/response statistics register
00314     """
00315     self.__cmd.CR_STATISTICS = 0
00316     
00317 class TrgGemCmdStats(TrgCmdStats):
00318   """\brief TrgGemCmdStats
00319   
00320   This class implements the HW abstraction corresponding to
00321   figure 62 of the GEM document: LAT-01545 Section 2.3.4
00322   """
00323   def __init__(self,glt):
00324     """\brief TrgGemCmdStats constructor
00325     """
00326     TrgCmdStats.__init__(self)
00327     if glt is not None:
00328       self.__cmd = glt.downGEMC()
00329     else:
00330       self.__cmd = None
00331 
00332   def command(self):
00333     return ( self.__cmd.CR_STATISTICS >> 16 ) & 0xffff
00334     
00335   def response(self):
00336     return ( self.__cmd.CR_STATISTICS       ) & 0xffff
00337 
00338 # ###########
00339   
00340 class TrgGemEventCounter(TrgEventCounter):
00341   """\brief TrgGemEventCounter
00342   
00343   This class implements the HW abstraction corresponding to
00344   figure 63 of the GEM document: LAT-01545 Section 2.3.6
00345   """
00346   def __init__(self,glt):
00347     """\brief TrgGemEventCounter constructor
00348     """
00349     TrgEventCounter.__init__(self)
00350     if glt is not None:
00351       self.__cmd = glt.downGEMC()
00352     else:
00353       self.__cmd = None
00354     
00355   def stats(self):
00356     return ( self.__cmd.EVENT_STATISTICS ) & 0xffff
00357     
00358   def reset(self):
00359     """\brief reset() member function
00360     
00361     Reset the event statistics register
00362     """
00363     self.__cmd.EVENT_STATISTICS = 0
00364 
00365 class TrgGemPPSTimer(TrgPPSTimer):
00366   """\brief TrgGemPPSTimer class definition
00367   This class HW abstraction corresponding to
00368   figure 75 of the GEM document: LAT-01545 Section 2.6.4
00369   """
00370   def __init__(self,glt):
00371     """\brief TrgGemPPSTimer constructor
00372     """
00373     TrgPPSTimer.__init__(self)
00374     if glt is not None:
00375       self.__cmd = glt.downGEMST()
00376     else:
00377       self.__cmd = None
00378 
00379   def seconds(self):
00380     return ( self.__cmd.ONE_PPS >> 25 ) & 0x7f
00381     
00382   def timebase(self):
00383     return ( self.__cmd.ONE_PPS       ) & 0x1ffffff

Generated on Fri Jul 21 13:26:33 2006 for LATTE R04-12-00 by doxygen 1.4.3