Changeset 4270

Show
Ignore:
Timestamp:
07/10/07 10:45:39 (6 years ago)
Author:
jgaeddert
Message:

removing amara: check in early, check in often

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • WaveDev/branches/WaveDevNoAmara/wavedev/XML_gen/application_gen.py

    r4252 r4270  
    2323import component_gen 
    2424from amara import binderytools 
     25import xml.dom.minidom 
     26from xml.dom.minidom import Node 
    2527import xmlBeautify 
    2628import wavedev.ComponentClass as CC 
     
    3234 
    3335try: 
    34     doc_cfg = binderytools.bind_file('../wavedev.cfg') 
     36    doc_cfg = xml.dom.minidom.parse('../wavedev.cfg') 
    3537except:   #if  not being called from wavedev, try looking for the file 
    36     doc_cfg = binderytools.bind_file('/sdr/tools/WaveDev/wavedev.cfg') 
    37  
    38  
    39 version = str(doc_cfg.owdconfiguration.version) 
     38    doc_cfg = xml.dom.minidom.parse('/sdr/tools/WaveDev/wavedev.cfg') 
     39 
     40 
     41version = str(doc_cfg.getElementsByTagName("version")[0].firstChild.data) 
    4042 
    4143#vtext = open('../version.txt') 
     
    5254def genxml(complist, genPath, waveName): 
    5355 
    54    if genPath[len(genPath)-1] != '/': 
     56    if genPath[len(genPath)-1] != '/': 
    5557        genPath = genPath + '/' 
    56    genPath = unicode(genPath) 
    57    waveformDir = unicode(genPath + waveName + '/') 
     58    genPath = unicode(genPath) 
     59    waveformDir = unicode(genPath + waveName + '/') 
    5860 
    5961    
    60    appName = unicode(waveName) 
    61    #namingServicePrefix = u'ossie' 
    62    outputFilename_sad = appName + u'.sad.xml' 
     62    appName = unicode(waveName) 
     63    #namingServicePrefix = u'ossie' 
     64    outputFilename_sad = appName + u'.sad.xml' 
    6365    
    64    # Generate the individual component xml files 
    65    for n in complist: 
    66       if n.generate: 
    67         component_gen.gen_scd(n, genPath) 
    68         component_gen.gen_spd(n, genPath) 
    69         component_gen.gen_prf(n, genPath)       
     66    # Generate the individual component xml files 
     67    for n in complist: 
     68        if n.generate: 
     69            component_gen.gen_scd(n, genPath) 
     70            component_gen.gen_spd(n, genPath) 
     71            component_gen.gen_prf(n, genPath)       
    7072    
    71    #---------------------------------------------------------------------------- 
    72    # SAD Parser / Generator 
    73    # 
     73    #---------------------------------------------------------------------------- 
     74    # SAD Parser / Generator 
     75    # 
    7476    
    75    # Use the Amara toolkit to objectify and generate the SAD file 
    76    try:  #if running from wavedev 
    77         doc_sad = binderytools.bind_file('XML_gen/_sad.xml.tpl') 
    78    except:   #if not being called from wavedev, try looking for the file 
    79         doc_sad = binderytools.bind_file('/sdr/tools/WaveDev/wavedev/XML_gen/_sad.xml.tpl') 
    80  
    81    doc_sad.softwareassembly.name = u'OSSIE::' + appName 
    82    doc_sad.softwareassembly.id = u'DCE:' + unicode(uuidgen()) 
    83      
    84    baseComponentList = []  
    85    for n in complist: 
     77    # Use the Amara toolkit to objectify and generate the SAD file 
     78    try:  #if running from wavedev 
     79        doc_sad = xml.dom.minidom.parse('XML_gen/_sad.xml.tpl') 
     80    except:   #if not being called from wavedev, try looking for the file 
     81        doc_sad = xml.dom.minidom.parse('/sdr/tools/WaveDev/wavedev/XML_gen/_sad.xml.tpl') 
     82 
     83    doc_sad.getElementsByTagName("softwareassembly")[0].setAttribute("name", u'OSSIE::' + appName ) 
     84    doc_sad.getElementsByTagName("softwareassembly")[0].setAttribute("id", u'DCE:' + unicode(uuidgen()) ) 
     85     
     86    # get root nodes for componentfiles, partitioning, assemblycontroller, and connections tags 
     87    componentfilesNode = doc_sad.getElementsByTagName("componentfiles")[0] 
     88    partitioningNode = doc_sad.getElementsByTagName("partitioning")[0] 
     89    assemblycontrollerNode = doc_sad.getElementsByTagName("assemblycontroller")[0] 
     90    connectionsNode = doc_sad.getElementsByTagName("connections")[0] 
     91     
     92    baseComponentList = []  
     93    for n in complist: 
    8694        # Generate the componentfile entries 
    8795        #tmpid = unicode(n.name) + u'_' + unicode(uuidgen()) 
     
    9098        if n.baseName not in baseComponentList: 
    9199            baseComponentList.append(n.baseName) 
    92             e = doc_sad.xml_create_element(u'componentfile', attributes={u'type': u'SPD', u'id': tmpid}) 
    93             doc_sad.softwareassembly.componentfiles.xml_append(e) 
    94             newLen = len(list(doc_sad.softwareassembly.componentfiles.componentfile)) 
    95             #e = doc_sad.xml_create_element(u'localfile',attributes={u'name':unicode(xmlpath + n.baseName + '/' + n.baseName + 'Resource.spd.xml')}) 
    96             e = doc_sad.xml_create_element(u'localfile',attributes={u'name':unicode(xmlpath + n.baseName + '/' + n.xmlName + '.spd.xml')}) 
    97             doc_sad.softwareassembly.componentfiles.componentfile[newLen-1].xml_append(e) 
    98     
     100 
     101            # create component file tag node 
     102            componentfileNode = doc_sad.createElement("componentfile") 
     103            componentfileNode.setAttribute("type", "SPD") 
     104            componentfileNode.setAttribute("id", tmpid) 
     105 
     106            # create localfile tag node 
     107            localfileNode = doc_sad.createElement("localfile") 
     108            localfileNode.setAttribute("name", unicode(xmlpath + n.baseName + '/' + n.xmlName + '.spd.xml') ) 
     109 
     110            # append nodes to .sad.xml file 
     111            componentfileNode.appendChild(localfileNode) 
     112            componentfilesNode.appendChild(componentfileNode) 
     113 
     114        # Generate the partitioning elements 
     115        componentplacementNode = doc_sad.createElement("componentplacement") 
     116        componentfilerefNode = doc_sad.createElement("componentfileref") 
     117        componentinstantiationNode = doc_sad.createElement("componentinstantiation") 
     118        usagenameNode = doc_sad.createElement("usagename") 
     119        usagenametextNode = doc_sad.createTextNode(unicode(n.name)) 
     120        findcomponentNode = doc_sad.createElement("findcomponent") 
     121 
     122        # Set attributes appropriately 
     123        componentfilerefNode.setAttribute("refid", tmpid) 
     124        componentinstantiationNode.setAttribute("id", u'DCE:' + unicode(n.uuid) ) 
     125 
     126''' 
    99127        # Generate the partitioning entries 
    100128        e = doc_sad.xml_create_element(u'componentplacement') 
     
    110138        e = doc_sad.xml_create_element(u'findcomponent') 
    111139        doc_sad.softwareassembly.partitioning.componentplacement[newLen-1].componentinstantiation.xml_append(e) 
     140''' 
    112141 
    113142        # Check for overloaded properties 
     
    119148            if tmp_prop.elementType == "SimpleSequence": 
    120149                try: 
    121                     if tmp_prop.values != tmp_prop.defaultValues: 
    122                         overload_flag = True 
    123                 except: 
    124                     pass 
     150                    if tmp_prop.values != tmp_prop.defaultValues: 
     151                        overload_flag = True 
     152                except: 
     153                    pass 
    125154                         
    126155        if overload_flag: 
    127             e = doc_sad.xml_create_element(u'componentproperties') 
     156            componentpropertiesNode = doc_sad.createElement("componentproperties") 
     157            #e = doc_sad.xml_create_element(u'componentproperties') 
    128158            doc_sad.softwareassembly.partitioning.componentplacement[newLen-1].componentinstantiation.xml_append(e) 
    129159            for tmp_prop in n.properties: 
    130160                if tmp_prop.elementType == "Simple": 
    131161                    if tmp_prop.value != tmp_prop.defaultValue: 
    132                         e = doc_sad.xml_create_element(u'simpleref',attributes={u'refid': unicode(tmp_prop.id),u'name': unicode(tmp_prop.name),u'description': unicode(tmp_prop.description), u'value': unicode(tmp_prop.value)}) 
    133                         doc_sad.softwareassembly.partitioning.componentplacement[newLen-1].componentinstantiation.componentproperties.xml_append(e) 
     162                        simplerefNode = doc_sad.createElement("simpleref") 
     163                        simplerefNode.setAttribute("refid", unicode(tmp_prop.id)) 
     164                        simplerefNode.setAttribute("name", unicode(tmp_prop.name) ) 
     165                        simplerefNode.setAttribute("description", unicode(tmp_prop.description)) 
     166                        simplerefNode.setAttribute("value", unicode(tmp_prop.value)) 
     167                        componentpropertiesNode.appendChild(simplerefNode) 
     168                        #e = doc_sad.xml_create_element(u'simpleref',attributes={u'refid': unicode(tmp_prop.id),u'name': unicode(tmp_prop.name),u'description': unicode(tmp_prop.description), u'value': unicode(tmp_prop.value)}) 
     169                        #doc_sad.softwareassembly.partitioning.componentplacement[newLen-1].componentinstantiation.componentproperties.xml_append(e) 
    134170                if tmp_prop.elementType == "SimpleSequence": 
    135171                    ssflag = False 
    136                     try: 
    137                         if tmp_prop.values != tmp_prop.defaultValues: 
    138                             ssflag = True 
    139                     except: 
    140                         pass 
     172                    try: 
     173                        if tmp_prop.values != tmp_prop.defaultValues: 
     174                            ssflag = True 
     175                    except: 
     176                        pass 
    141177 
    142178                    if ssflag: 
    143                         e = doc_sad.xml_create_element(u'simplesequenceref',attributes={u'refid': unicode(tmp_prop.id),u'name': unicode(tmp_prop.name),u'description': unicode(tmp_prop.description)}) 
    144                         doc_sad.softwareassembly.partitioning.componentplacement[newLen-1].componentinstantiation.componentproperties.xml_append(e) 
    145                         ssLen = len(list(doc_sad.softwareassembly.partitioning.componentplacement[newLen-1].componentinstantiation.componentproperties.simplesequenceref)) 
    146  
    147                         e = doc_sad.xml_create_element(u'values') 
    148                         doc_sad.softwareassembly.partitioning.componentplacement[newLen-1].componentinstantiation.componentproperties.simplesequenceref[ssLen-1].xml_append(e) 
     179                        simplesequencerefNode = doc_sad.createElement("simplesequenceref") 
     180                        simplesequencerefNode.setAttribute("refid", unicode(tmp_prop.id) ) 
     181                        simplesequencerefNode.setAttribute("name", unicode(tmp_prop.name) ) 
     182                        simplesequencerefNode.setAttribute("description", unicode(tmp_prop.description) ) 
     183                        valuesNode = doc_sad.createElement("values") 
     184                        #e = doc_sad.xml_create_element(u'simplesequenceref',attributes={u'refid': unicode(tmp_prop.id),u'name': unicode(tmp_prop.name),u'description': unicode(tmp_prop.description)}) 
     185                        #doc_sad.softwareassembly.partitioning.componentplacement[newLen-1].componentinstantiation.componentproperties.xml_append(e) 
     186                        #ssLen = len(list(doc_sad.softwareassembly.partitioning.componentplacement[newLen-1].componentinstantiation.componentproperties.simplesequenceref)) 
     187 
     188                        #e = doc_sad.xml_create_element(u'values') 
     189                        #doc_sad.softwareassembly.partitioning.componentplacement[newLen-1].componentinstantiation.componentproperties.simplesequenceref[ssLen-1].xml_append(e) 
    149190 
    150191                        for tmp_v2 in tmp_prop.values: 
    151                             e = doc_sad.xml_create_element(u'value',content=unicode(tmp_v2)) 
    152                             doc_sad.softwareassembly.partitioning.componentplacement[newLen-1].componentinstantiation.componentproperties.simplesequenceref[ssLen-1].values.xml_append(e) 
    153  
    154          
     192                            valueNode = doc_sad.createElement("value") 
     193                            valuetextNode = doc_sad.createTextNode(tmp_v2) 
     194                            valueNode.appendChild(valuetextNode) 
     195                            valuesNode.appendChild(valueNode) 
     196                            #e = doc_sad.xml_create_element(u'value',content=unicode(tmp_v2)) 
     197                            #doc_sad.softwareassembly.partitioning.componentplacement[newLen-1].componentinstantiation.componentproperties.simplesequenceref[ssLen-1].values.xml_append(e) 
     198 
     199                        simplesequencerefNode.appendChild(valuesNode) 
     200                        componentpropertiesNode.appendChild(simplesequencerefNode) 
     201 
     202        #TODO: append child nodes to componentplacement 
     203 
    155204        #NSname = u'DomainName1/' + namingServicePrefix + unicode(n.name) + u'Resource' 
    156205#        NSname = u'DomainName1/' + unicode(n.name) 
    157206        NSname = unicode(n.name) 
    158207 
    159         e = doc_sad.xml_create_element(u'namingservice', attributes={u'name': NSname}) 
    160         doc_sad.softwareassembly.partitioning.componentplacement[newLen-1].componentinstantiation.findcomponent.xml_append(e) 
     208        namingserviceNode = doc_sad.createElement("namingservice") 
     209        namingserviceNode.setAttribute("name", NSname) 
     210        findcomponentNode.appendChild(namingserviceNode) 
     211        #e = doc_sad.xml_create_element(u'namingservice', attributes={u'name': NSname}) 
     212        #doc_sad.softwareassembly.partitioning.componentplacement[newLen-1].componentinstantiation.findcomponent.xml_append(e) 
    161213         
    162214        # Generate the connections entries 
     
    184236                    dev_pname = u'DomainName1/' + pname 
    185237                    devFlag = True 
    186                  
    187             e = doc_sad.xml_create_element(u'connectinterface', attributes={u'id': u'DCE:' + unicode(uuidgen())}) 
    188             doc_sad.softwareassembly.connections.xml_append(e) 
    189             newLen = len(list(doc_sad.softwareassembly.connections.connectinterface)) 
    190238             
     239            connectinterfaceNode = doc_sad.createElement("connectinterface") 
     240            connectinterfaceNode.setAttribute("id",u'DCE:' + unicode(uuidgen())) 
     241            #doc_sad.softwareassembly.connections.xml_append(e) 
     242            #newLen = len(list(doc_sad.softwareassembly.connections.connectinterface)) 
     243 
     244            usesportNode = doc_sad.createElement("usesport") 
     245            usesidentifierNode = doc_sad.createElement("usesidentifier") 
     246            usesidentifiertextNode = doc_sad.createTextNode(uname) 
     247            findbyNode = doc_sad.createElement("findby") 
     248            namingserviceNode2 = doc_sad.createElement("namingservice") 
     249            namingserviceNode2.setAttribute("name", c1name) 
     250             
     251            ''' 
    191252            e = doc_sad.xml_create_element(u'usesport') 
    192253            doc_sad.softwareassembly.connections.connectinterface[newLen-1].xml_append(e) 
     
    197258            e = doc_sad.xml_create_element(u'namingservice',attributes={u'name': c1name}) 
    198259            doc_sad.softwareassembly.connections.connectinterface[newLen-1].usesport.findby.xml_append(e) 
     260            ''' 
    199261         
    200262            if devFlag != True: 
     
    212274                e = doc_sad.xml_create_element(u'namingservice',attributes={u'name': dev_pname}) 
    213275                doc_sad.softwareassembly.connections.connectinterface[newLen-1].findby.xml_append(e) 
     276 
     277            # Append child nodes 
     278            usesidentifierNode.appendChild(usesidentifierTextNode) 
     279            findbyNode.appendChild(namingserviceNode2) 
    214280             
    215281        # Specify the uuid for the Assembly Controller 
    216282        if n.AssemblyController == True: 
    217            assemblycontroller_id = u'DCE:' + unicode(n.uuid) 
    218            doc_sad.softwareassembly.assemblycontroller.componentinstantiationref.refid = assemblycontroller_id     
    219          
    220    # Create and beautify the SAD file as a temporary file 
    221    data = doc_sad.xml() 
    222    xmlBeautify.beautify(data,waveformDir + '.' + outputFilename_sad + '.tmp') 
    223  
    224  
    225    # Post Processing - add some of the header lines 
    226  
    227    preProcessed_sad = open(waveformDir + '.' + outputFilename_sad + '.tmp', 'r') 
    228    postProcessed_sad = open(waveformDir + outputFilename_sad, 'w') 
    229  
    230    # Specify external DTD 
    231    line0 = preProcessed_sad.readline() 
    232    remaining = preProcessed_sad.readlines() 
    233    postProcessed_sad.writelines(line0) 
    234    postProcessed_sad.writelines(u'<!DOCTYPE softwareassembly SYSTEM \"../../xml/dtd/softwareassembly.dtd\">\n') 
    235    postProcessed_sad.writelines(commentLine) 
    236    postProcessed_sad.writelines(remaining) 
    237    postProcessed_sad.close() 
     283            assemblycontroller_id = u'DCE:' + unicode(n.uuid) 
     284            doc_sad.softwareassembly.assemblycontroller.componentinstantiationref.refid = assemblycontroller_id     
     285         
     286    # Create and beautify the SAD file as a temporary file 
     287    data = doc_sad.toxml('UTF-8') 
     288    xmlBeautify.beautify(data,waveformDir + '.' + outputFilename_sad + '.tmp') 
     289 
     290 
     291    # Post Processing - add some of the header lines 
     292 
     293    preProcessed_sad = open(waveformDir + '.' + outputFilename_sad + '.tmp', 'r') 
     294    postProcessed_sad = open(waveformDir + outputFilename_sad, 'w') 
     295 
     296    # Specify external DTD 
     297    line0 = preProcessed_sad.readline() 
     298    remaining = preProcessed_sad.readlines() 
     299    postProcessed_sad.writelines(line0) 
     300    postProcessed_sad.writelines(u'<!DOCTYPE softwareassembly SYSTEM \"../../xml/dtd/softwareassembly.dtd\">\n') 
     301    postProcessed_sad.writelines(commentLine) 
     302    postProcessed_sad.writelines(remaining) 
     303    postProcessed_sad.close() 
    238304   
    239    # Remove temporary files 
    240    os.remove(waveformDir + '.' + outputFilename_sad + '.tmp') 
     305    # Remove temporary files 
     306    os.remove(waveformDir + '.' + outputFilename_sad + '.tmp') 
    241307    
    242    ####################### 
    243    #Generate the DCD file 
    244    ####################### 
    245    #genDCD(complist,genPath,waveName,xmlpath) 
     308    ####################### 
     309    #Generate the DCD file 
     310    ####################### 
     311    #genDCD(complist,genPath,waveName,xmlpath) 
    246312 
    247313################################################################################ 
     
    385451            e = doc_dcd.xml_create_element(u'componentinstantiation',attributes={u'id': u'DCE:' + unicode(n.uuid)}) 
    386452        else: 
    387             e = doc_dcd.xml_create_element(u'componentinstantiation',attributes={u'id': u'DCE:' + unicode(n.uuid)}) 
     453            e = doc_dcd.xml_create_element(u'componentinstantiation',attributes={u'id': u'DCE:' + unicode(n.uuid)}) 
    388454 
    389455        doc_dcd.deviceconfiguration.partitioning.componentplacement[newLen-1].xml_append(e) 
     
    439505\n\ 
    440506if len(sys.argv) != 2:\n\ 
    441         sys.exit(1)\n\ 
     507        sys.exit(1)\n\ 
    442508\n\ 
    443509sys.argv.append('--install-lib='+install_location)\n\n"