/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

gen.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 """
00004 Generate AD Reflector Detector Elements.
00005 
00006 This generates the Structure XML for all AD Reflectors into the TDS at
00007 /dd/Structure/AdDetails/ and files in to DDDB/AdReflectorStructure/*.xml.
00008 
00009 This needs to match the hand-written XML in DDDB/AdDetails/geometry.xml.
00010 
00011 """
00012 
00013 Eight = True
00014 suffix = ''
00015 style = '2-2-4'
00016 
00017 class AdReflectorStructure:
00018 
00019     sites = ['db', 'la', 'far']
00020 
00021     def write(self,outdir):
00022         from XmlDetDescGen.util import XmlFile, Comment
00023         from XmlDetDescGen.catalog import Catalog
00024         from XmlDetDescGen.reference import Reference
00025         from XmlDetDescGen.util import ExternalEntity
00026 
00027         topcat = Catalog('Structure');
00028         adcat = Catalog('AdReflectorStructure');
00029         adcat.refs = []
00030         adcat.things = []
00031         topcat.refs = [ adcat ]
00032         topcat.things = []
00033 
00034         ees = []
00035         for site,adcount in zip(AdReflectorStructure.sites,AdReflectors.adcounts):
00036             cat = Catalog('%s-ad'%site);
00037             cat.refs=[]
00038             for iad in range(0,adcount):
00039                 iad += 1
00040                 eename="%s%dreflectors"%(site,iad)
00041                 ees.append((eename,"%s%d.xml"%(site,iad)))
00042                 cat.refs.append(ExternalEntity(eename))
00043                 continue
00044             adcat.refs.append(cat)
00045 
00046         file = XmlFile(dtd="../DTD/structure.dtd",
00047                        external_entities=ees)
00048         file.objects = [ adcat ]
00049         file.write(outdir+"/structure.xml")
00050 
00051 
00052 class AdReflectors:
00053 
00054     lvtopname="/dd/Geometry/AdDetails/lvTopESR"
00055     lvbotname="/dd/Geometry/AdDetails/lvBotESR"
00056     siteids = [0x01,0x02,0x04]
00057     adcounts = [ 2,    2,     4]
00058 
00059 
00060     def __init__(self,site,siteid,adcount):
00061         self.site = site
00062         self.siteid = siteid
00063         self.adcount = adcount
00064         pass
00065 
00066     def write(self,outdir):
00067 
00068         from XmlDetDescGen.util import XmlFile, Comment
00069         from XmlDetDescGen.structure import DetElem,UserParameter
00070 
00071         for adn in range(0,self.adcount):
00072             adn += 1
00073 
00074             reflectors = []
00075 
00076             data = {
00077                    'site':self.site,
00078                    'siteid':self.siteid,
00079                    'adnum':adn,
00080                    }
00081                     
00082             de = DetElem('%(site)s-ad%(adnum)d-topesr'%data,
00083                         self.lvtopname,
00084                         npath="pvTopReflector/pvTopRefGap/pvTopESR",
00085                         support="/dd/Structure/AD/%(site)s-oil%(adnum)d"%data)
00086             reflectors.append(de)
00087                     
00088             de = DetElem('%(site)s-ad%(adnum)d-botesr'%data,
00089                         self.lvbotname,
00090                         npath="pvBotReflector/pvBotRefGap/pvBotESR",
00091                         support="/dd/Structure/AD/%(site)s-oil%(adnum)d"%data)
00092             reflectors.append(de)
00093 
00094             file = XmlFile()
00095             file.objects = reflectors
00096             file.write(outdir+"/%s%d.xml"%(self.site,adn))
00097             continue
00098           
00099 def main(): 
00100 
00101     import sys,os
00102 
00103     try:
00104         xddroot = sys.argv[1]
00105     except IndexError:
00106         xddroot = os.getenv("XMLDETDESCROOT")
00107 
00108     if not xddroot:
00109         print "No XMLDETDESCROOT directory given by environment or command line"
00110         print "Using current working directory"
00111         xddroot="."
00112 
00113     outdir=xddroot + "/DDDB/AdReflectorStructure" + suffix
00114     if not os.path.exists(outdir):
00115         print "Directory does not exist, please make first"
00116         print outdir
00117         sys.exit(1)
00118 
00119     
00120     print sys.argv[0],'Configuring for',style
00121 
00122     for site,siteid,adcount in zip(AdReflectorStructure.sites,AdReflectors.siteids,AdReflectors.adcounts):
00123 
00124         aps = AdReflectors(site,siteid,adcount)
00125         aps.write(outdir)
00126 
00127     aps = AdReflectorStructure()
00128     aps.write(outdir)
00129 
00130 
00131 if __name__ == '__main__' :
00132     main()
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:56:07 for XmlDetDesc by doxygen 1.7.4