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

test_bcast.py

00001 #!/usr/local/bin/python
00002 #
00003 #                               Copyright 2002
00004 #                                     by
00005 #                        The Board of Trustees of the
00006 #                     Leland Stanford Junior University.
00007 #                            All rights reserved.
00008 #
00009 
00010 """TEM test
00011 Contents:
00012 Script for testing TEM
00013 """
00014 __facility__ = "Online"
00015 __abstract__ = "Script for testing TEM broadcast functionality"
00016 __author__   = "Selim Tuvi <stuvi@slac.stanford.edu> SLAC - GLAST I&T/Online"
00017 __date__     = ("$Date: 2005/08/31 20:02:33 $").split(' ')[1]
00018 __version__  = "$Revision: 1.1 $"
00019 __release__  = "$Name: R04-12-00 $"
00020 __credits__  = "SLAC"
00021 
00022 import LATTE.copyright_SLAC
00023 
00024 from LATTE.client.gOptions import Options
00025 from LATTE.client.gCmdCli  import CmdCli
00026 from LATTE.database.gLAT   import GLAT
00027 from LATTE.database.gGLT   import GGLT
00028 from LATTE.database.gXBR   import GXBRD
00029 from LATTE.database.gPlumber import Plumber
00030 
00031 
00032 import os
00033 import logging as log
00034 
00035 def test(c=None, disconnectOnExit=1):
00036   # This test is meant to be run in simulation mode
00037 
00038   log.getLogger("").setLevel(log.DEBUG)
00039 
00040   options = Options(['server', 'schema'],
00041                     ['fswmsglevel', 'cmddebug'],
00042                     ['initforce', 'ocsverbose', 'nocommander'])
00043   try:
00044     options.parse()
00045   except Exception, msg:
00046     options.usage(str(msg))
00047     return
00048 
00049   if options.fswmsglevel is not None:
00050     msglevel = int(options.fswmsglevel)
00051   else:
00052     msglevel = 3
00053   verbose = (options.ocsverbose != None)
00054   force = (options.initforce != None)
00055   commander = not(options.nocommander != None)
00056 
00057   if c == None:
00058     cmd = CmdCli()
00059     cmd.connect(options.server)
00060     if options.cmddebug is not None:
00061       cmd.setDebug(options.cmddebug)
00062   else:
00063     cmd = c
00064 
00065   lat = GLAT(cmd)
00066   lat.readSchema(options.schema)
00067 
00068   if lat.xbrdExists():
00069     xbrd = GXBRD(cmd)
00070     xbrd = xbrd.readSchema(options.schema)
00071   else:
00072     xbrd = None
00073 
00074   plumber = Plumber(lat, xbrd)
00075   plumber.initialize(msglevel, verbose, force, commander)
00076 
00077   lat.applyConfig()
00078 
00079   # Get a TEM instance
00080   if lat.TEMcnt() > 0:
00081     bCastTem = lat.TEM.all()
00082   else:
00083     log.fatal("No TEM(s) found in the schema")
00084     if disconnectOnExit:
00085       cmd.disconnect()
00086     return -1
00087 
00088   if not lat.existsGEM():
00089     glt = GGLT(cmd)
00090     glt.initialize()
00091     
00092     
00093   # Test TEM block
00094   print "Testing TEM block..."
00095   TEST_PATTERN = 1234
00096   bCastTem.CMD_RESET = 1
00097   bCastTem.STATUS    = TEST_PATTERN
00098   for (temId, tem) in lat.TEM.items():
00099     if tem.STATUS != TEST_PATTERN:
00100       print "Failed verification in TEM block, TEM id=%d, expected %d found %d" % (
00101              temId, TEST_PATTERN, tem.STATUS
00102             )
00103       return -1
00104   print "TEM block test successful"
00105 
00106   # Test TIC block
00107   print "Testing TIC block..."
00108   TEST_PATTERN = 1235
00109   bCastTem.TIC.CMD_NOP           = 1
00110   bCastTem.TIC.TKR_LRS_COUNTER_0 = TEST_PATTERN
00111   for (temId, tem) in lat.TEM.items():
00112     if tem.TIC.TKR_LRS_COUNTER_0 != TEST_PATTERN:
00113       print "Failed verification in TIC block, TEM id=%d, expected %d found %d" % (
00114              temId, TEST_PATTERN, tem.TIC.TKR_LRS_COUNTER_0
00115             )
00116       return -1
00117   print "TIC block test successful"
00118 
00119   # Test CCC block
00120   print "Testing CCC block..."
00121   TEST_PATTERN = 1236
00122   bCastTem.CCC[0].CMD_RESET   = 1
00123   bCastTem.CCC[0].FIFO_STATUS = TEST_PATTERN
00124   for (temId, tem) in lat.TEM.items():
00125     if tem.CCC[0].FIFO_STATUS != TEST_PATTERN:
00126       print "Failed verification in CCC block, TEM id=%d, expected %d found %d" % (
00127              temId, TEST_PATTERN, tem.CCC[0].FIFO_STATUS
00128             )
00129       return -1
00130   print "CCC block test successful"
00131       
00132   # Test CRC block
00133   print "Testing CRC block..."
00134   TEST_PATTERN = 1237
00135   bCastTem.CCC[0].CRC[0].CMD_RESET = 1
00136   bCastTem.CCC[0].CRC[0].DELAY_1   = TEST_PATTERN
00137   for (temId, tem) in lat.TEM.items():
00138     if tem.CCC[0].CRC[0].DELAY_1 != TEST_PATTERN:
00139       print "Failed verification in CRC block, TEM id=%d, expected %d found %d" % (
00140              temId, TEST_PATTERN, tem.CCC[0].CRC[0].DELAY_1
00141             )
00142       return -1
00143   print "CRC block test successful"
00144       
00145   # Test CFE block
00146   print "Testing CFE block..."
00147   TEST_PATTERN = 1238
00148   bCastTem.CCC[0].CRC[0].CFE[0].CMD_NOP  = 1
00149   bCastTem.CCC[0].CRC[0].CFE[0].CONFIG_0 = TEST_PATTERN
00150   for (temId, tem) in lat.TEM.items():
00151     if tem.CCC[0].CRC[0].CFE[0].CONFIG_0 != TEST_PATTERN:
00152       print "Failed verification in CFE block, TEM id=%d, expected %d found %d" % (
00153              temId, TEST_PATTERN, tem.CCC[0].CRC[0].CFE[0].CONFIG_0
00154             )
00155       return -1
00156   print "CFE block test successful"
00157       
00158   # Test TCC block
00159   print "Testing TCC block..."
00160   TEST_PATTERN = 1239
00161   bCastTem.TCC[0].CMD_RESET   = 1
00162   bCastTem.TCC[0].FIFO_STATUS = TEST_PATTERN
00163   for (temId, tem) in lat.TEM.items():
00164     if tem.TCC[0].FIFO_STATUS != TEST_PATTERN:
00165       print "Failed verification in TCC block, TEM id=%d, expected %d found %d" % (
00166              temId, TEST_PATTERN, tem.TCC[0].FIFO_STATUS
00167             )
00168       return -1
00169   print "TCC block test successful"
00170       
00171   # Test TRC block
00172   print "Testing TRC block..."
00173   TEST_PATTERN = 1240
00174   bCastTem.TCC[0].TRC[0].CMD_RESET = 1
00175   bCastTem.TCC[0].TRC[0].SYNC   = TEST_PATTERN
00176   for (temId, tem) in lat.TEM.items():
00177     if tem.TCC[0].TRC[0].SYNC != TEST_PATTERN:
00178       print "Failed verification in TRC block, TEM id=%d, expected %d found %d" % (
00179              temId, TEST_PATTERN, tem.TCC[0].TRC[0].SYNC
00180             )
00181       return -1
00182   print "TRC block test successful"
00183       
00184   # Test TFE block
00185   print "Testing TFE block..."
00186   TEST_PATTERN = 1241
00187   bCastTem.TCC[0].TRC[0].TFE[0].CMD_RESET  = 1
00188   bCastTem.TCC[0].TRC[0].TFE[0].TRIG_MASK = TEST_PATTERN
00189   for (temId, tem) in lat.TEM.items():
00190     if tem.TCC[0].TRC[0].TFE[0].TRIG_MASK != TEST_PATTERN:
00191       print "Failed verification in TFE block, TEM id=%d, expected %d found %d" % (
00192              temId, TEST_PATTERN, tem.TCC[0].TRC[0].TFE[0].TRIG_MASK
00193             )
00194       return -1
00195   print "TFE block test successful"
00196 
00197   if disconnectOnExit:
00198     cmd.disconnect()  
00199 
00200 if __name__ == '__main__':
00201   if test(None, 0) is not None:
00202     print "** TEM broadcast test failed **"
00203   else:
00204     print "** TEM broadcast test was successful **"

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