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 gLAT 00011 ## 00012 ## \brief GLAST LAT record definitions. 00013 ## 00014 ## \b Contents: 00015 ## 00016 ## GLAST LAT functional block hierarchy representation in Python. See the following documents for more info: 00017 ## <p><a href="http://www-glast.slac.stanford.edu/IntegrationTest/ONLINE/docs/TEM.pdf">The Tower Electronics Module (TEM) - Programming ICD specification (LAT-TD-00605-D1)</a> 00018 ## <p><a href="http://www-glast.slac.stanford.edu/IntegrationTest/ONLINE/docs/AEM.pdf">ACD Electronics Module (AEM) - Programming ICD specification (LAT-TD-00639-D1)</a> 00019 ## <p><a href="http://www-glast.slac.stanford.edu/IntegrationTest/ONLINE/docs/EBM.pdf">The Event Builder Module - Programming ICD specification (LAT-TD-01546)</a> 00020 ## <p><a href="http://www-glast.slac.stanford.edu/IntegrationTest/ONLINE/docs/GEM.pdf">The GLT Electronics Module - Programming ICD specification (LAT-TD-01545)</a> 00021 ## <p><a href="http://www-glast.slac.stanford.edu/IntegrationTest/ONLINE/docs/CRU.pdf">The Command/Response Unit - Programming ICD specification (LAT-TD-01547)</a> 00022 ## <p><a href="http://www-glast.slac.stanford.edu/IntegrationTest/ONLINE/docs/PDU.pdf">The Power Distribution Unit - Programming ICD specification (LAT-TD-01543)</a> 00023 ## 00024 ## \b Overview: 00025 ## 00026 ## This module provides classes that are used as the building blocks for the 00027 ## LAT hierarchy. All classes inherit from Gnode class and add their own member 00028 ## methods and functions where necessary. Here is a list of classes defined: 00029 ## 00030 ## - GLAT: Root node for the hierarchy 00031 ## - GPDU: Power Distribution Unit 00032 ## - GPDUC: PDU Controller 00033 ## - GPEQ: PDU Environmental Monitors 00034 ## - GTWR: Tower 00035 ## - GTEM: Tower Electronics Module 00036 ## - GCCC: Calorimeter Cable Controller 00037 ## - GCRC: Calorimeter Readout Controller 00038 ## - GCFE: Calorimeter Front-end Controller 00039 ## - GTCC: Tracker Cable Controller 00040 ## - GTRC: Tracker Readout Controller 00041 ## - GTFE: Tracker Front-end Controller 00042 ## - GTIC: Trigger Interface Controller 00043 ## - GAEM: ACD Common Controller 00044 ## - GAEQ: ACD Environmental Monitors 00045 ## - GARC: ACD Readout Controller 00046 ## - GAFE: ACD Front-End Controller 00047 ## - GGLT: Global Trigger 00048 ## - GEBM: Event Builder Module 00049 ## - GEBMC: Event Builder Module Controller 00050 ## - GEBMST: Event Builder Module Statistics 00051 ## - GGEM: GLT Electronics Module 00052 ## - GGEMC: GLT Electronics Module Controller 00053 ## - GGEMMG: GLT Electronics Module TAM generator 00054 ## - GGEMST: GLT Electronics Module Statistics 00055 ## - GGEMSC: GLT Electronics Module Scheduler 00056 ## - GGEMVG: GLT Electronics Module ROI generator 00057 ## - GGEMIE: GLT Electronics Module Input enables 00058 ## - GGEMW: GLT Electronics Module Window 00059 ## - GCRU: Command Response Unit 00060 00061 __facility__ = "Online" 00062 __abstract__ = "GLAST LAT functional block hierarchy" 00063 __author__ = "Selim Tuvi <stuvi@slac.stanford.edu> SLAC - GLAST LAT I&T/Online" 00064 __date__ = ("$Date: 2006/07/17 18:29:10 $").split(' ')[1] 00065 __version__ = "$Revision: 2.19 $" 00066 __release__ = "$Name: R04-12-00 $" 00067 __credits__ = "SLAC" 00068 00069 import LATTE.copyright_SLAC 00070 import gSchemaConfig 00071 import gDb 00072 import gAttr 00073 00074 from gLCB import GLCB 00075 from gCRU import GCRU 00076 from gEBM import GEBM 00077 from gGEM import GGEM 00078 from gAEM import GAEM 00079 from gPDU import GPDU 00080 from gTEM import GTEM 00081 from gSIU import GSIU 00082 from gEPU import GEPU 00083 00084 00085 # GLAT class 00086 class GLAT(gDb.Gdb): 00087 """\brief GLAST LAT node Record 00088 00089 The GLAT node provides access to parity registers and 00090 event statistics registers. 00091 00092 Valid Registers: 00093 - \c parity_latp_cell_header 00094 - \c parity_latp_cell_body 00095 - \c parity_tem_cmd_str 00096 - \c parity_tem_access_desc 00097 - \c parity_tem_cmd_payload 00098 - \c stats_failed_events 00099 - \c stats_failed_event_sends 00100 - \c stats_valid_events 00101 - \c stats_discarded_event_sends 00102 - \c stats_length_mismatch_count 00103 - \c stats_events_not_sent 00104 00105 \deprecated 00106 - \c \b parity_latp_cell_header Use 'LCB.parity_latp_cell_header' instead 00107 - \c \b parity_latp_cell_body Use 'LCB.parity_latp_cell_body' instead 00108 - \c \b stats_failed_events Use 'OCS.stats_failed_events' instead 00109 - \c \b stats_failed_event_sends Use 'OCS.stats_failed_event_sends' instead 00110 - \c \b stats_valid_events Use 'OCS.stats_valid_events' instead 00111 - \c \b stats_discarded_event_sends Use 'OCS.stats_discarded_event_sends' instead 00112 - \c \b stats_length_mismatch_count Use 'OCS.stats_length_mismatch_count' instead 00113 - \c \b stats_events_not_sent Use 'OCS.stats_events_not_sent' instead 00114 00115 Event statistics: 00116 00117 The following statistics registers are initialized 00118 at the start of each RunControl run: 00119 00120 - \c stats_failed_events -- Counts events where 00121 the eventHandler receives a bad status for the event. 00122 00123 - \c stats_failed_event_sends -- Counts events where 00124 the socket send failed with an error other than 00125 EWOULDBLOCK. 00126 00127 - \c stats_valid_events -- Counts when a valid event 00128 has been successfully sent to the client. 00129 00130 - \c stats_discarded_event_sends -- Counts cases when an 00131 event send failed due to the fact that the send 00132 returned an EWOULDBLOCK error. 00133 00134 - \c stats_length_mismatch_count -- Counts cases when 00135 the length argument passed to the event handler did 00136 not match the length provided in the event header. 00137 00138 - \c stats_events_not_sent -- Counts when the event 00139 mode is set to DONOT_SEND_EVENTS where the incoming 00140 events will not be forwarded to the client over the 00141 socket. 00142 00143 """ 00144 __attrs = [ 00145 # Registers 00146 gAttr.GattrRegDepr('parity_latp_cell_header', 0, 4), # Deprecated: use gLCB 00147 gAttr.GattrRegDepr('parity_latp_cell_body', 1, 4), # Deprecated: use gLCB 00148 gAttr.GattrReg( 'parity_tem_cmd_str', 2, 4), 00149 gAttr.GattrReg( 'parity_tem_access_desc', 3, 4), 00150 gAttr.GattrReg( 'parity_tem_cmd_payload', 4, 4), 00151 gAttr.GattrRegDepr('stats_failed_events', 8, 4), # Deprecated: use gOCS 00152 gAttr.GattrRegDepr('stats_failed_event_sends', 9, 4), # Deprecated: use gOCS 00153 gAttr.GattrRegDepr('stats_valid_events', 10, 4), # Deprecated: use gOCS 00154 gAttr.GattrRegDepr('stats_discarded_event_sends', 11, 4), # Deprecated: use gOCS 00155 gAttr.GattrRegDepr('stats_length_mismatch_count', 12, 4), # Deprecated: use gOCS 00156 gAttr.GattrRegDepr('stats_events_not_sent', 13, 4) # Deprecated: use gOCS 00157 ] 00158 00159 def __init__(self, client): 00160 """\brief Initialize valid registers as Gattrs. 00161 00162 Assign default values to members 00163 """ 00164 self.LCB = GLCB(client) 00165 self.CRU = None 00166 self.AEM = None 00167 self.GEM = None 00168 self.EBM = None 00169 self.PDU = gDb.Children(self, GPDU) 00170 self.TEM = gDb.Children(self, GTEM) 00171 self.SIU = gDb.Children(self, GSIU) 00172 self.EPU = gDb.Children(self, GEPU) 00173 self.__schemaComments = [] 00174 self.__schemaName = '' 00175 self.__configComments = [] 00176 self.__configName = '' 00177 self.__configVersion = '' 00178 self.__includeFiles = [] 00179 self.__declarations = None 00180 self.__configurations = {} 00181 self.__deadChannels = None 00182 self.__noisyChannels = None 00183 self.__opaque = {} 00184 self.__serialnos = {} 00185 self.__xbrdExists = False 00186 self.__excludes = {} 00187 gDb.Gdb.__init__(self, client, None, 0, self.__attrs) 00188 00189 def read(self, reg): 00190 return self.cmdrsp('ggLATread', reg, '!I') 00191 00192 def load(self, reg, value): 00193 return self.cmdrsp('ggLATload', reg, value) 00194 00195 def readSchema(self, name): 00196 self.CRU = None 00197 self.AEM = None 00198 self.GEM = None 00199 self.EBM = None 00200 self.PDU = gDb.Children(self, GPDU) 00201 self.TEM = gDb.Children(self, GTEM) 00202 self.SIU = gDb.Children(self, GSIU) 00203 self.EPU = gDb.Children(self, GEPU) 00204 return gSchemaConfig.readSchema(self, name) 00205 00206 def writeSchema(self, fileName): 00207 gSchemaConfig.writeSchema(self, file(fileName, "w+"), snapshotMode=0) 00208 00209 def writeConfig(self, fileName, seq=None): 00210 gSchemaConfig.writeConfig(self, file(fileName, "w+"), seq) 00211 00212 def takeSnapshot(self, stream, fileName, 00213 captureGTIC, captureGAEQ, 00214 trigger, configName, configVersion): 00215 return gSchemaConfig.takeSnapshot(self, stream, fileName, 00216 captureGTIC, captureGAEQ, 00217 trigger, configName, configVersion) 00218 00219 def readConfig(self, cfgFileName): 00220 return gSchemaConfig.readConfig(self, cfgFileName) 00221 00222 def applyConfig(self, seq=None, gxbrd=None): 00223 gSchemaConfig.applyConfig(self, seq, gxbrd) 00224 00225 def getSysReg(self, node, regName): 00226 """\brief Returns the system register value applied. 00227 00228 The value of the register applied in the configuration and specified by 00229 \a node and \a regName is returned. 00230 00231 \return Register value or None 00232 """ 00233 return gSchemaConfig.getSysReg(self.__declarations, node, regName) 00234 00235 def downTEM(self, childId): 00236 """\brief Navigate to the GTEM indicated by \a childId 00237 00238 \param childId The id of the child TEM 00239 \return a GTEM object instance 00240 """ 00241 return self.TEM.down(childId) 00242 00243 def allTEM(self): 00244 """\brief Navigate to the GTEM broadcast node. 00245 00246 \return the GTEM broadcast node instance 00247 """ 00248 return self.TEM.all() 00249 00250 def downPDU(self, childId): 00251 """\brief Navigate to the GPDU indicated by \a childId 00252 00253 \param childId The id of the child PDU 00254 \return a GPDU object instance 00255 """ 00256 return self.PDU.down(childId) 00257 00258 def downAEM(self): 00259 """\brief Navigate to the GAEM 00260 00261 \return the GAEM object instance 00262 """ 00263 return self.AEM 00264 00265 def downGEM(self): 00266 """\brief Navigate to the GGEM 00267 00268 \return the GGEM object instance 00269 """ 00270 return self.GEM 00271 00272 def downEBM(self): 00273 """\brief Navigate to the GEBM 00274 00275 \return the GEBM object instance 00276 """ 00277 return self.EBM 00278 00279 def downLCB(self): 00280 """\brief Navigate to the GLCB 00281 00282 \return the GLCB object instance 00283 """ 00284 return self.LCB 00285 00286 def downCRU(self): 00287 """\brief Navigate to the GCRU 00288 00289 \return the GCRU object instance 00290 """ 00291 return self.CRU 00292 00293 def TEMcnt(self): 00294 """\brief Return the TEM count 00295 00296 \return Current TEM count 00297 """ 00298 return len(self.TEM) 00299 00300 def existsTEM(self, temId): 00301 """\brief Check if the GTEM instance with the id \a temId exists 00302 in the schema. 00303 00304 \param temId TEM id 00305 \return 1 if it exists, 0 if it doesn't. 00306 """ 00307 return self.TEM.exists(temId) 00308 00309 def existsPDU(self, pduId): 00310 """\brief Check if the GPDU instance with the id \a pduId exists 00311 in the schema. 00312 00313 \param pduId PDU id 00314 \return 1 if it exists, 0 if it doesn't. 00315 """ 00316 return self.PDU.exists(pduId) 00317 00318 def existsAEM(self): 00319 """\brief Check if the GAEM instance exists in the schema. 00320 00321 \return 1 if it exists, 0 if it doesn't. 00322 """ 00323 return self.AEM != None 00324 00325 def existsGEM(self): 00326 """\brief Check if the GGEM instance exists in the schema. 00327 00328 \return 1 if it exists, 0 if it doesn't. 00329 """ 00330 return self.GEM != None 00331 00332 def existsEBM(self): 00333 """\brief Check if the GEBM instance exists in the schema. 00334 00335 \return 1 if it exists, 0 if it doesn't. 00336 """ 00337 return self.EBM != None 00338 00339 def existsCRU(self): 00340 """\brief Check if the GCRU instance exists in the schema. 00341 00342 \return 1 if it exists, 0 if it doesn't. 00343 """ 00344 return self.CRU != None 00345 00346 def existsLCB(self): 00347 """\brief Check if the GLCB instance exists in the schema. 00348 00349 \return 1 if it exists, 0 if it doesn't. 00350 """ 00351 return self.LCB != None 00352 00353 def getConfigurations(self): 00354 """\brief Get list of configurations. 00355 00356 Return a list of configuration tuples where 00357 each tuple contains the configDOM, configName and configRelease. 00358 00359 \return Configuration tuple list. 00360 """ 00361 return self.__configurations 00362 00363 def getDeclarations(self): 00364 """\brief Get list of declarations. 00365 00366 Return a list of declarations 00367 00368 \return Declarations. 00369 """ 00370 return self.__declarations 00371 00372 def getRules(self): 00373 """\brief Retrieves the rule dictionary as defined by the 00374 current schema/configuration. 00375 00376 \return Dictionary containing Grule objects (or its descendants). 00377 """ 00378 return self.__declarations['rules'] 00379 00380 def getAllOpaque(self): 00381 """\brief Return all opaque data. 00382 00383 \return All opaque data regardless of the node they are 00384 associated with. 00385 """ 00386 return self.__opaque 00387 00388 def getAllSerialNos(self): 00389 """\brief Return all opaque data. 00390 00391 \return All serial number data regardless of the node 00392 they are associated with. 00393 """ 00394 return self.__serialnos 00395 00396 def getAllExcludeFlags(self): 00397 """\brief Return all exclude data. 00398 00399 \return All exclude data regardless of the node 00400 they are associated with. 00401 """ 00402 return self.__excludes 00403 00404 ##private: 00405 00406 def __removeTEM(self, temId): 00407 self.TEM.remove(temId) 00408 00409 def __addTEM(self, temId): 00410 return self.TEM.add(temId) 00411 00412 def __removeSIU(self, temId): 00413 self.SIU.remove(temId) 00414 00415 def __addSIU(self, temId): 00416 return self.SIU.add(temId) 00417 00418 def __removeEPU(self, temId): 00419 self.EPU.remove(temId) 00420 00421 def __addEPU(self, temId): 00422 return self.EPU.add(temId) 00423 00424 def __removePDU(self, pduId): 00425 self.PDU.remove(pduId) 00426 00427 def __addPDU(self, pduId): 00428 return self.PDU.add(pduId) 00429 00430 def __removeAEM(self): 00431 self.AEM = None 00432 00433 def __addAEM(self): 00434 self.AEM = GAEM(self.client(), self) 00435 return self.AEM 00436 00437 def __removeEBM(self): 00438 self.EBM = None 00439 00440 def __addEBM(self): 00441 self.EBM = GEBM(self.client(), self) 00442 return self.EBM 00443 00444 def __removeGEM(self): 00445 self.GEM = None 00446 00447 def __addGEM(self): 00448 self.GEM = GGEM(self.client(), self) 00449 return self.GEM 00450 00451 def __removeCRU(self): 00452 self.CRU = None 00453 00454 def __addCRU(self): 00455 self.CRU = GCRU(self.client(), self) 00456 return self.CRU 00457 00458 def xbrdExists(self): 00459 """\brief Check if a GXBRD node was encountered during readSchema. 00460 00461 \return Boolean indicating whether a GXBRD node was encountered or not 00462 """ 00463 return self.__xbrdExists