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

test_peq.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 
00011 __facility__ = "Online"
00012 __abstract__ = "PDU_adc_read"
00013 __author__   = "Patrick Young <plsyoung@SLAC.Stanford.edu> SLAC - GLAST LAT Electronics"
00014 __date__     = "16/09/2004"
00015 __version__  = "$Revision: 2.1 $"
00016 __credits__  = "SLAC"
00017 
00018 import LATTE.copyright_SLAC
00019 
00020 import LATTE.client.gOptions as gOptions
00021 import LATTE.client.gCmdCli as gCmdCli
00022 import LATTE.database.gPDU as gPDU
00023 
00024 import os
00025 from string import lstrip
00026 
00027 N_GRPS = 8 # number of (single digitize command) adc groups
00028 N_WRDS = 8 # words per adc reg
00029 N_LOOP = 4 # times one group is repetitively digitized
00030 N_ADCS = 160
00031 N_VARS = 20
00032 ADCS_BASE = 10 # constant offset from gPDU.py
00033 
00034 def is_vmon(adc):
00035   return ((adc-ADCS_BASE)%N_VARS==0)or((adc-ADCS_BASE)%N_VARS==1)\
00036   or((adc-ADCS_BASE)%N_VARS==2)
00037 
00038 def is_rtd(adc):
00039   return ((adc-ADCS_BASE)%N_VARS==9)or((adc-ADCS_BASE)%N_VARS==10)\
00040   or((adc-ADCS_BASE)%N_VARS==11)or((adc-ADCS_BASE)%N_VARS==12)
00041 
00042 if __name__ == '__main__':
00043   options = gOptions.Options(['server', 'logfile'])
00044   try:
00045     options.parse()
00046   except Exception, msg:
00047     options.usage(str(msg))
00048   else:
00049     cmdcli = gCmdCli.CmdCli()
00050     pdu = gPDU.GPDU(cmdcli, None, 0)
00051     peq = gPDU.GPEQ(cmdcli, pdu)
00052     cmdcli.connect(options.server)
00053     print "\nPDU ADC Read\n"
00054     rvrs = range(N_WRDS)
00055     rvrs.reverse()
00056     print "Write log to file %s" %options.logfile
00057     outfile = open(options.logfile, 'w')
00058 
00059     for grp in range(N_GRPS):
00060       pdu.monitor = grp
00061       reg0 = peq.adcs_00_07
00062       reg1 = peq.adcs_08_15
00063       reg2 = peq.adcs_16_19
00064       print "0x%024x 0x%024x 0x%024x" %(reg2, reg1, reg0)
00065 
00066       for i in rvrs:
00067         outstring = hex(int((reg2 >> i*12) & 0xfff))
00068         outfile.write(lstrip(outstring,'0x').zfill(3))
00069         outfile.write(' ')
00070       outfile.write('  ')
00071       for i in rvrs:
00072         outstring = hex(int((reg1 >> i*12) & 0xfff))
00073         outfile.write(lstrip(outstring,'0x').zfill(3))
00074         outfile.write(' ')
00075       outfile.write('  ')
00076       for i in rvrs:
00077         outstring = hex(int((reg0 >> i*12) & 0xfff))
00078         outfile.write(lstrip(outstring,'0x').zfill(3))
00079         outfile.write(' ')
00080       outfile.write('\n')
00081 
00082     outfile.write('\n')
00083     outfile.close()
00084 
00085     print "\nChecking ADCs one by one..."
00086     delay = 40
00087     rsp = peq.cmdrsp('setPduAdcWaitTime', delay)
00088     print 'wait was %d now %d' %(rsp.status(), delay)
00089     adcs = range(N_VARS)
00090     adcs.reverse()
00091     for grp in range(N_GRPS):
00092       msg = 'group %d:' %grp
00093       for i in adcs:
00094         adc = 10+i+N_VARS*grp
00095         val = peq.read(adc).value()
00096         msg += ' %03x' %val
00097       print msg
00098       #~ if is_vmon(adc):
00099         #~ if (val<0xa40 or val>0xa60):
00100           #~ print "Vmn[%03d] out of range. Actual: %03x"%(adc-ADCS_BASE,val)
00101       #~ elif is_rtd(adc):
00102         #~ if (val<0x298 or val>0x2b0):
00103           #~ print "RTD[%03d] out of range. Actual: %03x"%(adc-ADCS_BASE,val)
00104       #~ else:
00105         #~ if (val<0xbd0 or val>0xbe8):
00106           #~ print "Tmn[%03d] out of range. Actual: %03x"%(adc-ADCS_BASE,val)
00107     print "Done.\n"
00108     cmdcli.disconnect()

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