| 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) |
| 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: |
| 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 | ''' |
| 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) |
| 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) |
| 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 | |
| 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) |
| | 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 | ''' |
| 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() |