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 ## \namespace gHSK 00011 ## 00012 ## \brief GLAST LAT record definitions. 00013 ## 00014 ## \b Contents: 00015 ## 00016 ## 00017 ## \b Overview: 00018 ## 00019 ## This module provides classes that are used as the building blocks for the 00020 ## Housekeeping hierarchy. 00021 ## 00022 00023 __facility__ = "Online" 00024 __abstract__ = "GLAST LAT functional block hierarchy" 00025 __author__ = "Jim Panetta <panetta@slac.stanford.edu> SLAC - GLAST LAT I&T/Online" 00026 __date__ = ("$Date: 2005/09/07 20:10:22 $").split(' ')[1] 00027 __version__ = "$Revision: 1.14 $" 00028 __release__ = "$Name: R04-12-00 $" 00029 __credits__ = "SLAC" 00030 00031 import LATTE.copyright_SLAC 00032 00033 import os, types 00034 import gSchemaConfig 00035 from gSchemaConfig import hasAttribute, getAttribute 00036 import gDb 00037 import gHdb 00038 import logging as log 00039 from xml.dom import Node 00040 from xml.dom.ext.reader import Sax2 00041 # from gHdb import GHdb 00042 from gGroup import * 00043 00044 00045 # GHSK class 00046 class GHSK(gDb.Gdb): 00047 """\brief GLAST HSK node Record 00048 00049 """ 00050 00051 def __init__(self, client): 00052 """\brief Initialize valid attributes as Gattrs. 00053 00054 Assign default values to members 00055 """ 00056 self.HTEM = gDb.Children(self, HTEM) 00057 self.HAEM = None 00058 self.HGEM = None 00059 self.HEBM = None 00060 self.HPDU = gDb.Children(self, HPDU) 00061 self.HCOM = None 00062 self.HCPU = None 00063 self.HNUL = HNUL(self) # NULL node. Used to reference non-used bytes in hsk 00064 00065 self.__schemaComments = [] 00066 self.__schemaName = '' 00067 self.__configComments = [] 00068 self.__configName = '' 00069 self.__configVersion = '' 00070 self.__includeFiles = [] 00071 self.__declarations = None 00072 self.__configurations = {} 00073 self.__opaque = {} 00074 self.__serialnos = {} 00075 gDb.Gdb.__init__(self, client, None, None) 00076 00077 def downHTEM(self, childId): 00078 """\brief Navigate to the HTEM indicated by \a childId 00079 00080 \param childId The id of the child HTEM 00081 00082 \return A HARC object instance 00083 """ 00084 return self.HTEM.down(childId) 00085 00086 def downHAEM(self): 00087 """\brief Navigate to the HAEM node 00088 00089 \return The HAEM object instance 00090 """ 00091 return self.HAEM 00092 00093 def downHGEM(self): 00094 """\brief Navigate to the HGEM node 00095 00096 \return The HGEM object instance 00097 """ 00098 return self.HGEM 00099 00100 def downHEBM(self): 00101 """\brief Navigate to the HEBM node 00102 00103 \return The HEBM object instance 00104 """ 00105 return self.HEBM 00106 00107 def downHPDU(self, childId): 00108 """\brief Navigate to the HPDU node 00109 00110 \return The HPDU object instance 00111 """ 00112 return self.HPDU.down(childId) 00113 00114 def downHCOM(self): 00115 """\brief Navigate to the HCOM node 00116 00117 \return The HCOM object instance 00118 """ 00119 return self.HCOM 00120 00121 def downHCPU(self): 00122 """\brief Navigate to the HCPU node 00123 00124 \return The HCPU object instance 00125 """ 00126 return self.HCPU 00127 00128 def downHNUL(self): 00129 """\brief Navigate to the HNUL node 00130 00131 \return The HNUL object instance 00132 """ 00133 return self.HNUL 00134 00135 def existsHTEM(self, temID): 00136 """\brief Check if the HTEM instance with the id 00137 \a temID exists in the schema. 00138 00139 \param temID ACD readout controller id 00140 00141 \return 1 if it exists, 0 if it doesn't. 00142 """ 00143 return self.HTEM.exists(temID) 00144 00145 def existsHAEM(self): 00146 """\brief Check if the HAEM instance exists in the schema. 00147 00148 \return True if it exists, False if it doesn't. 00149 """ 00150 return self.HAEM != None 00151 00152 def existsHGEM(self): 00153 """\brief Check if the HGEM instance exists in the schema. 00154 00155 \return True if it exists, False if it doesn't. 00156 """ 00157 return self.HGEM != None 00158 00159 def existsHEBM(self): 00160 """\brief Check if the HEBM instance exists in the schema. 00161 00162 \return True if it exists, False if it doesn't. 00163 """ 00164 return self.HEBM != None 00165 00166 def existsHPDU(self, hpduID): 00167 """\brief Check if the HPDU instance exists in the schema. 00168 00169 \return True if it exists, False if it doesn't. 00170 """ 00171 return self.HPDU.exists(hpduID) 00172 00173 def existsHCOM(self): 00174 """\brief Check if the HCOM instance exists in the schema. 00175 00176 \return True if it exists, False if it doesn't. 00177 """ 00178 return self.HCOM != None 00179 00180 def existsHCPU(self): 00181 """\brief Check if the HCPU instance exists in the schema. 00182 00183 \return True if it exists, False if it doesn't. 00184 """ 00185 return self.HCPU != None 00186 00187 def readSchema(self, schema): 00188 self.HTEM = gDb.Children(self, HTEM) 00189 self.HAEM = None 00190 self.HGEM = None 00191 self.HEBM = None 00192 self.HPDU = gDb.Children(self, HPDU) 00193 self.HCOM = None 00194 self.HCPU = None 00195 from gSchemaConfig import gSCprocessRegistry 00196 gSCprocessRegistry['GHSK'] = processGHSK 00197 gSchemaConfig.readSchema(self, schema) 00198 00199 def readConfig(self, cfgFileName): 00200 return readHskConfig(self, cfgFileName) 00201 00202 def applyConfig(self, seq): 00203 applyHskConfig(self, seq) 00204 00205 def getConfigurations(self): 00206 """\brief Get list of configurations. 00207 00208 Return a list of configuration tuples where 00209 each tuple contains the configDOM, configName and configRelease. 00210 00211 \return Configuration tuple list. 00212 """ 00213 return self.__configurations 00214 00215 def getDeclarations(self): 00216 """\brief Get list of declarations. 00217 00218 Return a list of declarations 00219 00220 \return Declarations. 00221 """ 00222 return self.__declarations 00223 00224 def getRules(self): 00225 """\brief Retrieves the rule dictionary as defined by the 00226 current schema/configuration. 00227 00228 \return Dictionary containing Grule objects (or its descendants). 00229 """ 00230 return self.__declarations['rules'] 00231 00232 def getOpaque(self, name): 00233 """\brief Retrieves the named opaque data included in the schema 00234 00235 \param name Name of the opaque XML data 00236 00237 \return A list of XML DOM objects matching \a name 00238 """ 00239 if name in self.__opaque: 00240 return self.__opaque[name] 00241 00242 def __addHTEM(self, temID): 00243 return self.HTEM.add(temID) 00244 00245 def __addHAEM(self): 00246 self.HAEM = HAEM(self.client(), self) 00247 return self.HAEM 00248 00249 def __addHGEM(self): 00250 self.HGEM = HGEM(self.client(), self) 00251 return self.HGEM 00252 00253 def __addHEBM(self): 00254 self.HEBM = HEBM(self.client(), self) 00255 return self.HEBM 00256 00257 def __addHPDU(self, pduID): 00258 return self.HPDU.add(pduID) 00259 00260 def __addHCOM(self): 00261 self.HCOM = HCOM(self.client(), self) 00262 return self.HCOM 00263 00264 def __addHCPU(self): 00265 self.HCPU = HCPU(self.client(), self) 00266 return self.HCPU 00267 00268 def __removeHTEM(self, temID): 00269 self.HTEM.remove(temID) 00270 00271 def __removeHAEM(self): 00272 self.HAEM = None 00273 00274 def __removeHGEM(self): 00275 self.HGEM = None 00276 00277 def __removeHEBM(self): 00278 self.HEBM = None 00279 00280 def __removeHPDU(self, pduID): 00281 self.HPDU.remove(pduID) 00282 00283 def __removeHCOM(self): 00284 self.HCOM = None 00285 00286 def __removeHCPU(self): 00287 self.HCPU = None 00288 00289 00290 class HTEM(gDb.Gdb): 00291 """\brief GLAST TEM HSK node record 00292 00293 Valid Attributes: 00294 - \c tkr_digital_v 00295 - \c tkr_digital_i DEPRECATED, no replace 00296 - \c tkr_analoga_v 00297 - \c tkr_analoga_i DEPRECATED, no replace 00298 - \c tkr_analogb_v 00299 - \c tkr_analogb_i DEPRECATED, no replace 00300 - \c tkr_bias_v DEPRECATED, replaced by: 00301 - \c tkr_bias_v0 00302 - \c tkr_bias_i DEPRECATED, no replace 00303 - \c cal_digital_v 00304 - \c cal_digital_i DEPRECATED, replaced by: 00305 - \c tkr_bias_v1 00306 - \c cal_analog_v 00307 - \c cal_analog_i DEPRECATED, replaced by: 00308 - \c cal_bias_v1 00309 - \c cal_bias_v DEPRECATED, replaced by: 00310 - \c cal_bias_v0 00311 - \c cal_bias_i DEPRECATED, replaced by: 00312 - \c tem_28_v0 00313 - \c tem_digital_v 00314 - \c tem_digital_i DEPRECATED, replaced by: 00315 - \c tem_28_v0 00316 - \c afee_[0-3]_t[0-1] (AFEE_*_t0 DEPRECATED) 00317 - \c tkr_c[0-7]_t[0-1] 00318 - \c tkr_lrs_0_low 00319 - \c tkr_lrs_0_high 00320 - \c tkr_lrs_1_low 00321 - \c tkr_lrs_1_high 00322 - \c tkr_lrs_mask 00323 - \c cal_lrs_0 00324 - \c cal_lrs_0_mask 00325 - \c cal_lrs_1 00326 - \c cal_lrs_1_mask 00327 - \c deadtime 00328 """ 00329 # Environmental 00330 __regs = [ 00331 gHdb.GattrHsk('TKR_DIGITAL_V', 0), 00332 gHdb.GattrHsk('TKR_DIGITAL_I', 1), # DEPRECATED, no replace 00333 gHdb.GattrHsk('TKR_ANALOGA_V', 2), 00334 gHdb.GattrHsk('TKR_ANALOGA_I', 3), # DEPRECATED, no replace 00335 gHdb.GattrHsk('TKR_ANALOGB_V', 4), 00336 gHdb.GattrHsk('TKR_ANALOGB_I', 5), # DEPRECATED, no replace 00337 gHdb.GattrHsk('TKR_BIAS_V' , 6), # DEPRECATED, replaced by: 00338 gHdb.GattrHsk('TKR_BIAS_V0' , 6), 00339 gHdb.GattrHsk('TKR_BIAS_I' , 7), # DEPRECATED, no replace 00340 # mux boundary 00341 gHdb.GattrHsk('CAL_DIGITAL_V', 8), 00342 gHdb.GattrHsk('CAL_DIGITAL_I', 9), # DEPRECATED, replaced by: 00343 gHdb.GattrHsk('TKR_BIAS_V1' , 9), 00344 gHdb.GattrHsk('CAL_ANALOG_V' , 10), 00345 gHdb.GattrHsk('CAL_ANALOG_I' , 11), # DEPRECATED, replaced by: 00346 gHdb.GattrHsk('CAL_BIAS_V1', 11), 00347 gHdb.GattrHsk('CAL_BIAS_V' , 12), # DEPRECATED, replaced by: 00348 gHdb.GattrHsk('CAL_BIAS_V0' , 12), 00349 gHdb.GattrHsk('CAL_BIAS_I' , 13), # DEPRECATED, replaced by: 00350 gHdb.GattrHsk('TEM_28_V0' , 13), 00351 gHdb.GattrHsk('TEM_DIGITAL_V', 14), 00352 gHdb.GattrHsk('TEM_DIGITAL_I', 15), # DEPRECATED, replaced by: 00353 gHdb.GattrHsk('TEM_28_V1' , 15), 00354 ] 00355 offset = 16 00356 for i in range(4): 00357 __regs.append(gHdb.GattrHsk('AFEE_%d_T0'%i, offset )) # DEPRECATED 00358 __regs.append(gHdb.GattrHsk('AFEE_%d_T1'%i, offset+1 )) 00359 offset += 2 00360 for i in range(8): 00361 __regs.append(gHdb.GattrHsk('TKR_C%d_T0'%i, offset )) 00362 __regs.append(gHdb.GattrHsk('TKR_C%d_T1'%i, offset+1 )) 00363 offset += 2 00364 # LRS counters 00365 __regs.append(gHdb.GattrHsk('TKR_LRS_0_LOW', offset+0 )) 00366 __regs.append(gHdb.GattrHsk('TKR_LRS_0_HIGH', offset+1 )) 00367 __regs.append(gHdb.GattrHsk('TKR_LRS_1_LOW', offset+2 )) 00368 __regs.append(gHdb.GattrHsk('TKR_LRS_1_HIGH', offset+3 )) 00369 __regs.append(gHdb.GattrHsk('TKR_LRS_MASK', offset+4 )) 00370 __regs.append(gHdb.GattrHsk('CAL_LRS_0', offset+5 )) 00371 __regs.append(gHdb.GattrHsk('CAL_LRS_0_MASK', offset+6 )) 00372 __regs.append(gHdb.GattrHsk('CAL_LRS_1', offset+7 )) 00373 __regs.append(gHdb.GattrHsk('CAL_LRS_1_MASK', offset+8 )) 00374 __regs.append(gHdb.GattrHsk('DEADTIME', offset+9 )) 00375 00376 00377 def __init__(self, client, parent, temID): 00378 """\brief Initialize valid housekeeping quantities as Gattrs 00379 """ 00380 gDb.Gdb.__init__(self, client, parent, temID, self.__regs) 00381 00382 00383 class HAEM(gDb.Gdb): 00384 """\brief GLAST AEM HSK node Record 00385 00386 Valid Attributes: 00387 - \c FreeI 00388 - \c Temperature 00389 - \c HVI 00390 - \c DAQV 00391 - \c CommonStatus 00392 - \c CableStatus 00393 00394 """ 00395 __regs = [ 00396 # DAQ board hsk quantities 00397 gHdb.GattrHsk('FreeI' , 0), 00398 gHdb.GattrHsk('Temperature' , 1), 00399 gHdb.GattrHsk('HVI' , 2), 00400 gHdb.GattrHsk('DAQV' , 3), 00401 gHdb.GattrHsk('CommonStatus' , 4), 00402 gHdb.GattrHsk('CableStatus' , 5), 00403 ] 00404 def __init__(self, client, parent): 00405 """\brief Initialize valid housekeeping quantities as Gattrs 00406 """ 00407 self.HARC = gDb.Children(self, HARC) 00408 gDb.Gdb.__init__(self, client, parent, None, self.__regs) 00409 00410 def downHARC(self, arcID): 00411 """\brief Navigate to the HARC indicated by \a arcID 00412 00413 \param arcID The id of the child HARC 00414 00415 \return A HARC object instance 00416 """ 00417 try: 00418 return self.HARC[arcID] 00419 except KeyError: 00420 return None 00421 00422 def existsHARC(self, arcID): 00423 """\brief Check if the HARC instance with the id 00424 \a arcID exists in the schema. 00425 00426 \param arcId ACD readout controller id 00427 00428 \return 1 if it exists, 0 if it doesn't. 00429 """ 00430 if arcID in self.HARC: 00431 return 1 00432 else: 00433 return 0 00434 00435 def __addHARC(self, arcID): 00436 if arcID in self.HARC: 00437 raise KeyError('*** HARC: ARC already exists with ID: %d' % arcID) 00438 else: 00439 self.HARC[arcID] = HARC(self.client(), self, arcID) 00440 return self.HARC[arcID] 00441 00442 def __removeHARC(self, arcID): 00443 if arcID in self.HARC: 00444 self.HARC.__delitem__(arcID) 00445 00446 00447 class HARC(gDb.Gdb): 00448 """\brief GLAST ARC HSK node record 00449 00450 Valid Attributes: 00451 - \c Vdd 00452 - \c Temperature 00453 - \c HV1 00454 - \c HV2 00455 """ 00456 __regs = [ 00457 gHdb.GattrHsk('Vdd' , 0), 00458 gHdb.GattrHsk('Temperature' , 1), 00459 gHdb.GattrHsk('HV1' , 2), 00460 gHdb.GattrHsk('HV2' , 3), 00461 ] 00462 def __init__(self, client, parent, arcID): 00463 """\brief Initialize valid housekeeping quantities as Gattrs 00464 """ 00465 gDb.Gdb.__init__(self, client, parent, arcID, self.__regs) 00466 00467 class HGEM(gDb.Gdb): 00468 """\brief GLAST GEM HSK node record 00469 00470 Valid Attributes: 00471 - \c Events 00472 - \c Livetime 00473 - \c Prescaled 00474 - \c Busy 00475 - \c Sent 00476 - \c PPS 00477 - \c LastPPS 00478 - \c TriggerTime 00479 """ 00480 __regs = [ 00481 gHdb.GattrHsk('Events' , 0), 00482 gHdb.GattrHsk('Livetime' , 1), 00483 gHdb.GattrHsk('Prescaled' , 2), 00484 gHdb.GattrHsk('Busy' , 3), 00485 gHdb.GattrHsk('Sent' , 4), 00486 gHdb.GattrHsk('PPS' , 5), 00487 gHdb.GattrHsk('LastPPS' , 6), 00488 gHdb.GattrHsk('TriggerTime' , 7), 00489 ] 00490 def __init__(self, client, parent): 00491 """\brief Initialize valid housekeeping quantities as Gattrs 00492 """ 00493 gDb.Gdb.__init__(self, client, parent, None, self.__regs) 00494 00495 class HEBM(gDb.Gdb): 00496 """\brief GLAST EBM HSK node record 00497 00498 Valid Attributes: 00499 - \c Events 00500 - \c GEMreceive 00501 - \c TEM[0-15]receive 00502 - \c AEMreceive 00503 - \c SIU0receive 00504 - \c SIU1receive 00505 - \c EPU0receive 00506 - \c EPU1receive 00507 - \c EPU2receive 00508 - \c SIU0transmit 00509 - \c SIU1transmit 00510 - \c EPU0transmit 00511 - \c EPU1transmit 00512 - \c EPU2transmit 00513 - \c SSRtransmit 00514 """ 00515 __regs = [ 00516 gHdb.GattrHsk('Events' , 0), 00517 gHdb.GattrHsk('GEMreceive' , 1), 00518 gHdb.GattrHsk('TEM0receive' , 2), 00519 gHdb.GattrHsk('TEM1receive' , 3), 00520 gHdb.GattrHsk('TEM2receive' , 4), 00521 gHdb.GattrHsk('TEM3receive' , 5), 00522 gHdb.GattrHsk('TEM4receive' , 6), 00523 gHdb.GattrHsk('TEM5receive' , 7), 00524 gHdb.GattrHsk('TEM6receive' , 8), 00525 gHdb.GattrHsk('TEM7receive' , 9), 00526 gHdb.GattrHsk('TEM8receive' , 10), 00527 gHdb.GattrHsk('TEM9receive' , 11), 00528 gHdb.GattrHsk('TEM10receive' , 12), 00529 gHdb.GattrHsk('TEM11receive' , 13), 00530 gHdb.GattrHsk('TEM12receive' , 14), 00531 gHdb.GattrHsk('TEM13receive' , 15), 00532 gHdb.GattrHsk('TEM14receive' , 16), 00533 gHdb.GattrHsk('TEM15receive' , 17), 00534 gHdb.GattrHsk('AEMreceive' , 18), 00535 gHdb.GattrHsk('SIU0receive' , 19), 00536 gHdb.GattrHsk('SIU1receive' , 20), 00537 gHdb.GattrHsk('EPU0receive' , 21), 00538 gHdb.GattrHsk('EPU1receive' , 22), 00539 gHdb.GattrHsk('EPU2receive' , 23), 00540 gHdb.GattrHsk('SIU0transmit' , 24), 00541 gHdb.GattrHsk('SIU1transmit' , 25), 00542 gHdb.GattrHsk('EPU0transmit' , 26), 00543 gHdb.GattrHsk('EPU1transmit' , 27), 00544 gHdb.GattrHsk('EPU2transmit' , 28), 00545 gHdb.GattrHsk('SSRtransmit' , 29), 00546 ] 00547 def __init__(self, client, parent): 00548 """\brief Initialize valid housekeeping quantities as Gattrs 00549 """ 00550 gDb.Gdb.__init__(self, client, parent, None, self.__regs) 00551 00552 class HPDU(gDb.Gdb): 00553 """\brief GLAST PDU HSK node record 00554 00555 Valid Attributes: 00556 - \c ACDShellTemp0 00557 - \c ACDShellTemp1 00558 - \c ACDconvTemp 00559 - \c ACDpowerState 00560 - \c ACDpowerSupply 00561 - \c GridTemp[0-12] 00562 - \c RadiatorTemp[0-12] 00563 - \c RadiatorAfrzTemp0 00564 - \c RadiatorAfrzTemp1 00565 - \c CalBaseplateTemp[0-16] 00566 - \c VHCP_DSHP_M_Temp[0-6] 00567 - \c VHCP_DSHP_P_Temp[0-6] 00568 - \c VHCP_XLHP_M_Temp[0-6] 00569 - \c VHCP_XLHP_P_Temp[0-6] 00570 - \c VHCPRes_M_Temp[0-6] 00571 - \c VHCPRes_P_Temp[0-6] 00572 - \c TEM[0-16]_PCBTemp 00573 - \c TEM[0-16]_digital33V 00574 - \c TEM[0-16]_PSTemp 00575 - \c TEM[0-16]_powerState 00576 - \c ACDpmtRailTemp[0-4] 00577 - \c ACDBEAgridTemp[0-1] 00578 - \c GridRadiatorTemp[0-4] 00579 - \c EPUdigitalVoltage[0-3] 00580 - \c EPUTemp[0-3] 00581 - \c EPUCratePowerStat[0-3] 00582 - \c EPUConverterStat[0-3] 00583 """ 00584 __regs = [] 00585 __regs.append(gHdb.GattrHsk('ACDShellTemp0', 0)) 00586 __regs.append(gHdb.GattrHsk('ACDShellTemp1', 1)) 00587 __regs.append(gHdb.GattrHsk('ACDconvTemp', 2)) 00588 __regs.append(gHdb.GattrHsk('ACDpowerState', 3)) 00589 __regs.append(gHdb.GattrHsk('ACDpowerSupply', 4)) 00590 offset = 5 00591 for i in range(12): 00592 __regs.append(gHdb.GattrHsk('GridTemp%d'%i, offset )) 00593 __regs.append(gHdb.GattrHsk('RadiatorTemp%d'%i, offset+1)) 00594 offset += 2 00595 __regs.append(gHdb.GattrHsk('RadiatorAfrzTemp0', offset+0)) 00596 __regs.append(gHdb.GattrHsk('RadiatorAfrzTemp1', offset+1)) 00597 offset += 2 00598 for i in range(16): 00599 __regs.append(gHdb.GattrHsk('CalBaseplateTemp%d'%i, offset)) 00600 offset += 1 00601 00602 for i in range(6): 00603 __regs.append(gHdb.GattrHsk('VHCP_DSHP_M_Temp%d'%i, offset+0)) 00604 __regs.append(gHdb.GattrHsk('VHCP_DSHP_P_Temp%d'%i, offset+1)) 00605 __regs.append(gHdb.GattrHsk('VHCP_XLHP_M_Temp%d'%i, offset+2)) 00606 __regs.append(gHdb.GattrHsk('VHCP_XLHP_P_Temp%d'%i, offset+3)) 00607 __regs.append(gHdb.GattrHsk('VHCPRes_M_Temp%d'%i, offset+4)) 00608 __regs.append(gHdb.GattrHsk('VHCPRes_P_Temp%d'%i, offset+5)) 00609 offset += 6 00610 00611 for i in range(16): 00612 __regs.append(gHdb.GattrHsk('TEM%d_PCBTemp'%i, offset+0)) 00613 __regs.append(gHdb.GattrHsk('TEM%d_digital33V'%i, offset+1)) 00614 __regs.append(gHdb.GattrHsk('TEM%d_PSTemp'%i, offset+2)) 00615 __regs.append(gHdb.GattrHsk('TEM%d_powerState'%i, offset+3)) 00616 offset += 4 00617 for i in range(4): 00618 __regs.append(gHdb.GattrHsk('ACDpmtRailTemp%d'%i, offset)) 00619 offset += 1 00620 __regs.append(gHdb.GattrHsk('ACDBEAgridTemp0',offset+0)) 00621 __regs.append(gHdb.GattrHsk('ACDBEAgridTemp1',offset+1)) 00622 offset += 2 00623 for i in range(4): 00624 __regs.append(gHdb.GattrHsk('GridRadiatorTemp%d'%i,offset)) 00625 offset += 1 00626 for i in range(3): 00627 __regs.append(gHdb.GattrHsk('EPUdigitalVoltage%d'%i,offset+0)) 00628 __regs.append(gHdb.GattrHsk('EPUTemp%d'%i, offset+1)) 00629 __regs.append(gHdb.GattrHsk('EPUCratePowerStat%d'%i,offset+2)) 00630 __regs.append(gHdb.GattrHsk('EPUConverterStat%d'%i, offset+3)) 00631 offset += 4 00632 __regs.append(gHdb.GattrHsk('Spare0',offset )) 00633 __regs.append(gHdb.GattrHsk('Spare1',offset+1)) 00634 offset += 2 00635 00636 def __init__(self, client, parent, pduID): 00637 """\brief Initialize valid housekeeping quantities as Gattrs 00638 """ 00639 gDb.Gdb.__init__(self, client, parent, pduID, self.__regs) 00640 00641 class HCOM(gDb.Gdb): 00642 """\brief GLAST Communications statistics HSK node record 00643 00644 Valid Attributes: 00645 - \c Traffic_LCB0 00646 - \c Traffic_LCB0 00647 - \c Traffic_LCB0 00648 - \c Traffic_1553 00649 - \c Traffic_SSR 00650 """ 00651 __regs = [ 00652 gHdb.GattrHsk('Traffic_LCB0',0), 00653 gHdb.GattrHsk('Traffic_LCB0',1), 00654 gHdb.GattrHsk('Traffic_LCB0',2), 00655 gHdb.GattrHsk('Traffic_1553',3), 00656 gHdb.GattrHsk('Traffic_SSR' ,4), 00657 ] 00658 def __init__(self, client, parent): 00659 """\brief Initialize valid housekeeping quantities as Gattrs 00660 """ 00661 gDb.Gdb.__init__(self, client, parent, None, self.__regs) 00662 00663 class HCPU(gDb.Gdb): 00664 """\brief GLAST CPU metrics HSK node record 00665 00666 Valid Attributes: 00667 - \c CPU_Idle_[0-3] 00668 - \c CPU_Temp_[0-3] 00669 - \c MemUsage_[0-3] 00670 - \c CacheMisses_[0-3] 00671 - \c TaskStats_[0-3] 00672 """ 00673 __regs = [] 00674 offset = 0 00675 for i in range(3): 00676 __regs.append(gHdb.GattrHsk('CPU_Idle_%d'%i, offset+0)) 00677 __regs.append(gHdb.GattrHsk('CPU_Temp_%d'%i, offset+1)) 00678 __regs.append(gHdb.GattrHsk('MemUsage_%d'%i, offset+2)) 00679 __regs.append(gHdb.GattrHsk('CacheMisses_%d'%i, offset+3)) 00680 __regs.append(gHdb.GattrHsk('TaskStats_%d'%i, offset+4)) 00681 offset += 5 00682 def __init__(self, client, parent): 00683 """\brief Initialize valid housekeeping quantities as Gattrs 00684 """ 00685 gDb.Gdb.__init__(self, client, parent, None, self.__regs) 00686 00687 class HNUL(gDb.Gdb): 00688 """\brief GLAST HSK null record 00689 00690 Valid Attributes: 00691 - \c EMPTY 00692 """ 00693 __regs = [ 00694 gHdb.GattrHsk('EMPTY',0), 00695 ] 00696 def __init__(self, parent): 00697 """\brief Initialize valid housekeeping quantities as Gattrs 00698 """ 00699 gDb.Gdb.__init__(self, None, parent, None, self.__regs) 00700 00701 def processGHSK(isSchema, ghdb, node, declarations): 00702 fn = "processGHSK" 00703 for n in gSchemaConfig.getChildNodes(node): 00704 tagName = n.tagName.lower() 00705 if tagName == 'htem': 00706 processHTEM(isSchema, ghdb, n, declarations) 00707 elif tagName == 'haem': 00708 processHAEM(isSchema, ghdb, n, declarations) 00709 elif tagName == 'hgem': 00710 processHGEM(isSchema, ghdb, n, declarations) 00711 elif tagName == 'hebm': 00712 processHEBM(isSchema, ghdb, n, declarations) 00713 elif tagName == 'hpdu': 00714 processHPDU(isSchema, ghdb, n, declarations) 00715 elif tagName == 'hcom': 00716 processHCOM(isSchema, ghdb, n, declarations) 00717 elif tagName == 'hcpu': 00718 processHCPU(isSchema, ghdb, n, declarations) 00719 elif tagName == 'opaque': 00720 gSchemaConfig.addOpaque(ghdb, n) 00721 elif isSchema: 00722 log.error("%s: Unexpected tag: %s" % (fn, n.tagName)) 00723 elif tagName in ghdb.regs: 00724 gSchemaConfig.setRegister(ghdb.regs[tagName], n, declarations) 00725 else: 00726 log.error("%s: Configuration error processing GHSK...Invalid attribute %s" % (fn, n.tagName)) 00727 00728 return ghdb 00729 00730 00731 def processHTEM(isSchema, ghdb, node, declarations): 00732 fn = "processHTEM" 00733 if hasAttribute(node,'ID'): 00734 htemIdSeq = gSchemaConfig.uncompressSequence(getAttribute(node,'ID')) 00735 else: 00736 raise KeyError("%s: Configuration error processing HTEM ...No ID attribute for HTEM." % (fn) ) 00737 00738 for htemId in htemIdSeq: 00739 if isSchema: 00740 htem = __privateFn(ghdb, '__addHTEM')(ghdb, htemId) 00741 elif ghdb.existsHTEM(htemId): 00742 htem = ghdb.downHTEM(htemId) 00743 else: 00744 log.debug("%s: Configuration error processing HTEM ...Not populated" %(fn)) 00745 continue 00746 for n in gSchemaConfig.getChildNodes(node): 00747 tagName = n.tagName.lower() 00748 if tagName == 'opaque': 00749 gSchemaConfig.addOpaque(htem, n) 00750 elif isSchema: 00751 log.error("%s: Unexpected tag: %s" % (fn, n.tagName)) 00752 elif tagName in htem.regs: 00753 gSchemaConfig.setRegister(htem.regs[tagName], n, declarations) 00754 else: 00755 log.error("%s: Configuration error processing HTEM # %d ...Invalid attribute %s" % (fn, htemId, n.tagName)) 00756 00757 def processHAEM(isSchema, ghdb, node, declarations): 00758 fn = "processHAEM" 00759 if isSchema: 00760 haem = __privateFn(ghdb, '__addHAEM')(ghdb) 00761 elif ghdb.existsHAEM(): 00762 haem = ghdb.downHAEM() 00763 else: 00764 log.debug("%s: Configuration error processing HAEM ...Not populated" %(fn)) 00765 return 00766 for n in gSchemaConfig.getChildNodes(node): 00767 tagName = n.tagName.lower() 00768 if tagName == 'harc': 00769 processHARC(isSchema, haem, n, declarations) 00770 elif tagName == 'opaque': 00771 gSchemaConfig.addOpaque(haem, n) 00772 elif isSchema: 00773 log.error("%s: Unexpected tag: %s" % (fn, n.tagName)) 00774 elif tagName in haem.regs: 00775 gSchemaConfig.setRegister(haem.regs[tagName], n, declarations) 00776 else: 00777 log.error("%s: Configuration error processing HAEM ...Invalid attribute %s" %(fn, n.tagName)) 00778 00779 def processHARC(isSchema, ghdb, node, declarations): 00780 fn = "processHARC" 00781 if hasAttribute(node,'ID'): 00782 harcIdSeq = gSchemaConfig.uncompressSequence(getAttribute(node,'ID')) 00783 else: 00784 raise KeyError("%s: Configuration error processing HARC ...No ID attribute for HARC." % (fn) ) 00785 00786 for harcId in harcIdSeq: 00787 if isSchema: 00788 harc = __privateFn(ghdb, '__addHARC')(ghdb, harcId) 00789 elif ghdb.existsHARC(harcId): 00790 harc = ghdb.downHARC(harcId) 00791 else: 00792 log.debug("%s: Configuration error processing HARC ...Not populated" %(fn)) 00793 continue 00794 for n in gSchemaConfig.getChildNodes(node): 00795 tagName = n.tagName.lower() 00796 if tagName == 'opaque': 00797 gSchemaConfig.addOpaque(harc, n) 00798 elif isSchema: 00799 log.error("%s: Unexpected tag: %s" % (fn, n.tagName)) 00800 elif tagName in harc.regs: 00801 gSchemaConfig.setRegister(harc.regs[tagName], n, declarations) 00802 else: 00803 log.error("%s: Configuration error processing HARC # %d ...Invalid attribute %s" % (fn, harcId, n.tagName)) 00804 00805 00806 00807 00808 00809 def processHGEM(isSchema, ghdb, node, declarations): 00810 fn = "processHGEM" 00811 if isSchema: 00812 hgem = __privateFn(ghdb, '__addHGEM')(ghdb) 00813 elif ghdb.existsHGEM(): 00814 hgem = ghdb.downHGEM() 00815 else: 00816 log.debug("%s: Configuration error processing HGEM ...Not populated" %(fn)) 00817 return 00818 00819 for n in gSchemaConfig.getChildNodes(node): 00820 tagName = n.tagName.lower() 00821 if tagName == 'opaque': 00822 gSchemaConfig.addOpaque(hgem, n) 00823 elif isSchema: 00824 log.error("%s: Unexpected tag: %s" % (fn, n.tagName)) 00825 elif tagName in hgem.regs: 00826 gSchemaConfig.setRegister(hgem.regs[tagName], n, declarations) 00827 else: 00828 log.error("%s: Configuration error processing HGEM ...Invalid attribute %s" %(fn, n.tagName)) 00829 00830 00831 def processHEBM(isSchema, ghdb, node, declarations): 00832 fn = "processHEBM" 00833 if isSchema: 00834 hebm = __privateFn(ghdb, '__addHEBM')(ghdb) 00835 elif ghdb.existsHEBM(): 00836 hebm = ghdb.downHEBM() 00837 else: 00838 log.debug("%s: Configuration error processing HEBM ...Not populated" %(fn)) 00839 return 00840 00841 for n in gSchemaConfig.getChildNodes(node): 00842 tagName = n.tagName.lower() 00843 if tagName == 'opaque': 00844 gSchemaConfig.addOpaque(hebm, n) 00845 elif isSchema: 00846 log.error("%s: Unexpected tag: %s" % (fn, n.tagName)) 00847 elif tagName in hebm.regs: 00848 gSchemaConfig.setRegister(hebm.regs[tagName], n, declarations) 00849 else: 00850 log.error("%s: Configuration error processing HEBM ...Invalid attribute %s" %(fn, n.tagName)) 00851 00852 00853 def processHPDU(isSchema, ghdb, node, declarations): 00854 fn = "processHPDU" 00855 if hasAttribute(node,'ID'): 00856 hpduIdSeq = gSchemaConfig.uncompressSequence(getAttribute(node,'ID')) 00857 else: 00858 raise KeyError("%s: Configuration error processing HPDU ...No ID attribute for HPDU." % (fn) ) 00859 00860 for hpduId in hpduIdSeq: 00861 if isSchema: 00862 hpdu = __privateFn(ghdb, '__addHPDU')(ghdb,hpduId) 00863 elif ghdb.existsHPDU(hpduId): 00864 hpdu = ghdb.downHPDU(hpduId) 00865 else: 00866 log.debug("%s: Configuration error processing HPDU %d ...Not populated" %(fn, hpduId)) 00867 return 00868 00869 for n in gSchemaConfig.getChildNodes(node): 00870 tagName = n.tagName.lower() 00871 if tagName == 'opaque': 00872 gSchemaConfig.addOpaque(hpdu, n) 00873 elif isSchema: 00874 log.error("%s: Unexpected tag: %s" % (fn, n.tagName)) 00875 elif tagName in hpdu.regs: 00876 gSchemaConfig.setRegister(hpdu.regs[tagName], n, declarations) 00877 else: 00878 log.error("%s: Configuration error processing HPDU ...Invalid attribute %s" %(fn, n.tagName)) 00879 00880 00881 def processHCOM(isSchema, ghdb, node, declarations): 00882 fn = "processHCOM" 00883 if isSchema: 00884 hcom = __privateFn(ghdb, '__addHCOM')(ghdb) 00885 elif ghdb.existsHCOM(): 00886 hcom = ghdb.downHCOM() 00887 else: 00888 log.debug("%s: Configuration error processing HCOM ...Not populated" %(fn)) 00889 return 00890 00891 for n in gSchemaConfig.getChildNodes(node): 00892 tagName = n.tagName.lower() 00893 if tagName == 'opaque': 00894 gSchemaConfig.addOpaque(hcom, n) 00895 elif isSchema: 00896 log.error("%s: Unexpected tag: %s" % (fn, n.tagName)) 00897 elif tagName in hcom.regs: 00898 gSchemaConfig.setRegister(hcom.regs[tagName], n, declarations) 00899 else: 00900 log.error("%s: Configuration error processing HCOM ...Invalid attribute %s" %(fn, n.tagName)) 00901 00902 00903 def processHCPU(isSchema, ghdb, node, declarations): 00904 fn = "processHCPU" 00905 if isSchema: 00906 hcpu = __privateFn(ghdb, '__addHCPU')(ghdb) 00907 elif ghdb.existsHCPU(): 00908 hcpu = ghdb.downHCPU() 00909 else: 00910 log.debug("%s: Configuration error processing HCPU ...Not populated" %(fn)) 00911 return 00912 00913 for n in gSchemaConfig.getChildNodes(node): 00914 tagName = n.tagName.lower() 00915 if tagName == 'opaque': 00916 gSchemaConfig.addOpaque(hcpu, n) 00917 elif isSchema: 00918 log.error("%s: Unexpected tag: %s" % (fn, n.tagName)) 00919 elif tagName in hcpu.regs: 00920 gSchemaConfig.setRegister(hcpu.regs[tagName], n, declarations) 00921 else: 00922 log.error("%s: Configuration error processing HCPU ...Invalid attribute %s" %(fn, n.tagName)) 00923 00924 00925 00926 def readHskConfig(ghsk, cfgFileName): 00927 """Read a hsk configuration XML file and add its DOM 00928 to the dictionary of configurations. 00929 00930 \param ghsk Populated schema 00931 \param cfgFileName Name of the configuration file in XML format 00932 \return The numeric key value of the dictionary entry. 00933 -1 if it fails to read the configuration file. 00934 """ 00935 fn = "readHskConfig" 00936 curDir = os.getcwd() 00937 mainFilePath = os.path.dirname(cfgFileName) 00938 mainFileName = os.path.basename(cfgFileName) 00939 if mainFilePath != '': os.chdir(mainFilePath) 00940 00941 try: 00942 cfgDoc = Sax2.FromXmlFile(cfgFileName) 00943 except: 00944 log.exception("%s: Error reading configuration file" % fn) 00945 os.chdir(curDir) 00946 return -1 00947 00948 cfgNode = cfgDoc.documentElement 00949 00950 includeFiles = [] 00951 gSchemaConfig.processIncludes(cfgDoc, cfgNode, includeFiles, mainFilePath) 00952 ghsk._GHSK__includeFiles += includeFiles 00953 cfgDict = ghsk.getConfigurations() 00954 configSeq = len(cfgDict) 00955 configName = '' 00956 configVersion = '' 00957 if hasAttribute(cfgNode,'name'): 00958 configName = str(getAttribute(cfgNode,'name')) 00959 if hasAttribute(cfgNode,'version'): 00960 configVersion = str(getAttribute(cfgNode,'version')) 00961 00962 cfgDict[configSeq] = (cfgNode, configName, configVersion) 00963 os.chdir(curDir) 00964 return configSeq 00965 00966 def applyHskConfig(ghsk, seq=None): 00967 """Applies the configuration that may have existed when the schema is read. 00968 The configuration portion of the schema is stored as a DOM reference 00969 in the GHSK node. This function accesses that DOM and sets the attributes 00970 accordingly 00971 00972 Input :: 00973 00974 (1) GHSK root of the object model 00975 (2) Optional sequence number of the configuration 00976 00977 Output: None 00978 00979 Usage:: 00980 00981 applyConfig(ghsk)""" 00982 00983 fn = "applyHskConfig" 00984 configs = [] 00985 if seq is None: 00986 if len(ghsk.getConfigurations()) == 0: 00987 log.debug("%s: Nothing to do, no configuration exists" % fn) 00988 return 00989 else: 00990 configSeqList = ghsk.getConfigurations().keys() 00991 configSeqList.sort() 00992 for seq in configSeqList: 00993 configs.append(ghsk.getConfigurations()[seq][0]) 00994 elif type(seq) == types.IntType: 00995 if ghsk.getConfigurations().has_key(seq): 00996 configs.append(ghsk.getConfigurations()[seq][0]) 00997 else: 00998 log.error("%s: Configuration with sequence %d could not be found" % (fn, seq)) 00999 return 01000 01001 for config in configs: 01002 for n in gSchemaConfig.getChildNodes(config): 01003 processHskConfigProperties(ghsk, n, ghsk.getDeclarations()) 01004 if n.nodeType == Node.ELEMENT_NODE: 01005 tagname = n.tagName.lower() 01006 if tagname == 'ghsk': 01007 if hasAttribute(config,'name'): 01008 configName = getAttribute(config,'name') 01009 else: 01010 configName = '(no name)' 01011 log.debug("%s: Applying configuration: %s" % (fn, configName)) 01012 processGHSK(0, ghsk, n, ghsk.getDeclarations()) 01013 01014 def processHskConfigProperties(ghsk, node, declarations): 01015 fn = "processHskConfigProperties" 01016 if node.nodeType == Node.ELEMENT_NODE: 01017 cfgTagname = node.tagName.lower() 01018 if cfgTagname == 'declarations': 01019 gSchemaConfig.processDeclarations(0, node, declarations) 01020 elif cfgTagname == 'constraints': 01021 gSchemaConfig.processConstraints(node, declarations) 01022 elif cfgTagname == 'rules': 01023 gSchemaConfig.processRules(node, declarations) 01024 elif cfgTagname == 'egus': 01025 gSchemaConfig.processEGUs(node, declarations) 01026 elif cfgTagname in ('ghsk'): 01027 pass 01028 else: 01029 log.error("%s: Unrecognized configuration tag: %s" % (fn, cfgTagname)) 01030 01031 01032 01033 01034 def __privateFn(cls, function): 01035 # local routine to return an arbitrary class attribute. 01036 # used to return private methods of classes. 01037 gname = cls.__class__.__name__ 01038 gdict = cls.__class__.__dict__ 01039 return gdict['_' + gname + function] 01040 01041