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__ = "GLAST XBR functional block" 00013 __author__ = "Selim Tuvi <stuvi@slac.stanford.edu> SLAC - GLAST LAT I&T/Online" 00014 __date__ = ("$Date: 2006/07/21 15:13:17 $").split(' ')[1] 00015 __version__ = "$Revision: 2.18 $" 00016 __release__ = "$Name: R04-12-00 $" 00017 __credits__ = "SLAC" 00018 00019 import LATTE.copyright_SLAC 00020 00021 import gSchemaConfig 00022 00023 import gDb 00024 import gAttr 00025 import gGLT 00026 import logging as log 00027 from LATTE.client import gLog 00028 from LATTE.client import gRegister 00029 00030 class GXBRD(gDb.Gdb): 00031 """\brief Tower controller node Record 00032 00033 Valid Registers: 00034 - \c dac_tem_voltage 00035 - \c dac_tkr_analog_2_5 00036 - \c dac_tkr_digital_2_5 00037 - \c dac_tkr_cal_analog 00038 - \c dac_cal_digital_3_3 00039 - \c path_cmd_resp_reset 00040 - \c path_trigger 00041 - \c path_event 00042 - \c evt_flow_ctrl 00043 00044 Dataless commands: 00045 - \c cmd_tem_hw_reset 00046 """ 00047 __regs = [ 00048 # Registers 00049 gAttr.GattrReg('dac_tem_voltage', 0, 2), 00050 gAttr.GattrReg('dac_tkr_analog_2_5', 1, 2), 00051 gAttr.GattrReg('dac_tkr_digital_2_5', 2, 2), 00052 gAttr.GattrReg('dac_tkr_cal_analog', 3, 2), 00053 gAttr.GattrReg('dac_cal_digital_3_3', 4, 2), 00054 gAttr.GattrReg('path_cmd_resp_reset', 5, 2), 00055 gAttr.GattrReg('path_trigger', 6, 2), 00056 gAttr.GattrReg('path_event', 7, 2), 00057 gAttr.GattrReg('evt_flow_ctrl', 8, 2, gAttr.REG_WRITE_ONLY), 00058 # Dataless commands 00059 gAttr.GattrDlc('cmd_tem_hw_reset', 0, 0, gAttr.REG_WRITE_ONLY) 00060 ] 00061 00062 def __init__(self, client): 00063 """\brief Initialize valid registers as Gattrs. 00064 00065 Assign default values to members 00066 """ 00067 self.GLT = None 00068 self.TWR = gDb.Children(self, GTWR) 00069 self.__schemaComments = [] 00070 self.__schemaName = '' 00071 self.__configComments = [] 00072 self.__configName = '' 00073 self.__configVersion = '' 00074 self.__includeFiles = [] 00075 self.__declarations = None 00076 self.__configurations = {} 00077 self.__opaque = {} 00078 self.__serialnos = {} 00079 self.__excludes = {} 00080 gDb.Gdb.__init__(self, client, None, 0, self.__regs) 00081 00082 def read(self, reg): 00083 if reg in (7,8): 00084 log.error("gXBRD.GXBRD:read(): Register no longer available") 00085 gLog.logStack() 00086 return gRegister.Register(0, 0, [0], 'H') 00087 else: 00088 return self.cmdrsp('ggXBRDread', reg, '!H') 00089 00090 def load(self, reg, value): 00091 if reg in (7,8): 00092 log.error("gXBRD.GXBRD:load(): Register no longer available") 00093 gLog.logStack() 00094 return gRegister.Register(0, 0, [0], 'H') 00095 else: 00096 return self.cmdrsp('ggXBRDload', reg, value) 00097 00098 def send(self, cmd): 00099 return self.cmdrsp('ggXBRDcmd', cmd) 00100 00101 def readSchema(self, name): 00102 self.GLT = None 00103 self.TWR = gDb.Children(self, GTWR) 00104 return gSchemaConfig.readSchema(self, name) 00105 00106 def readConfig(self, cfgFileName): 00107 return gSchemaConfig.readConfig(self, cfgFileName) 00108 00109 def applyConfig(self, seq=None): 00110 gSchemaConfig.applyConfig(self, seq) 00111 00112 def getConfigurations(self): 00113 """\brief Get list of configurations. 00114 00115 Return a list of configuration tuples where 00116 each tuple contains the configDOM, configName and configRelease. 00117 00118 \return Configuration tuple list. 00119 """ 00120 return self.__configurations 00121 00122 def getDeclarations(self): 00123 """\brief Get list of declarations. 00124 00125 Return a list of declarations 00126 00127 \return Declarations. 00128 """ 00129 return self.__declarations 00130 00131 def downGLT(self): 00132 """\brief Navigate to the GGLT 00133 00134 \return The GGLT object instance 00135 """ 00136 return self.GLT 00137 00138 def existsGLT(self): 00139 """\brief Check if the GGLT instance exists in the schema. 00140 00141 \return 1 if it exists, 0 if it doesn't. 00142 """ 00143 return self.GLT != None 00144 00145 def downTWR(self, twrId): 00146 """\brief Navigate to the GTWR indicated by \a childId 00147 00148 \param childId The id of the child tower 00149 \return A GTWR object instance 00150 """ 00151 return self.TWR.down(twrId) 00152 00153 def existsTWR(self, twrId): 00154 """\brief Check if the GTWR instance with the id \a twrId 00155 exists in the schema. 00156 00157 \param twrId Tower id 00158 \return 1 if it exists, 0 if it doesn't. 00159 """ 00160 return self.TWR.exists(twrId) 00161 00162 ## private: 00163 def __removeGLT(self): 00164 self.GLT = None 00165 00166 def __addGLT(self): 00167 self.GLT = gGLT.GGLT(self.client(), self) 00168 return self.GLT 00169 00170 def __removeTWR(self, twrId): 00171 self.TWR.remove(twrId) 00172 00173 def __addTWR(self, twrId): 00174 return self.TWR.add(twrId) 00175 00176 00177 class GTWR(gDb.Gdb): 00178 """\brief Tower node Record 00179 00180 Valid Registers: 00181 - \c adc_ps_temp_0 00182 - \c adc_ps_temp_1 00183 - \c adc_tem_temp_0 00184 - \c adc_tem_temp_1 00185 - \c adc_tem_voltage_0 00186 - \c adc_tem_voltage_1 00187 """ 00188 __regs = [ 00189 # Registers 00190 gAttr.GattrReg('adc_ps_temp_0', 0, 4), 00191 gAttr.GattrReg('adc_ps_temp_1', 1, 4), 00192 gAttr.GattrReg('adc_tem_temp_0', 2, 4), 00193 gAttr.GattrReg('adc_tem_temp_1', 3, 4), 00194 gAttr.GattrReg('adc_tem_voltage_0', 4, 4), 00195 gAttr.GattrReg('adc_tem_voltage_1', 5, 4) 00196 ] 00197 00198 def __init__(self, client, parent, id): 00199 """\brief Initialize valid registers as Gattrs. 00200 00201 Assign default values to members 00202 """ 00203 gDb.Gdb.__init__(self, client, parent, id, self.__regs) 00204 00205 def read(self, reg): 00206 return self.cmdrsp('ggTWRread', self.up().addr(), reg, '!I') 00207 00208 def load(self, reg, value): 00209 return self.cmdrsp('ggTWRload', self.up().addr(), reg, value)