| 94 | | # Why is this done twice? Wasn't this already accomplished in importResource.py? -JDG |
| 95 | | if hasattr(doc_scd.softwarecomponent.componentfeatures,'ports'): |
| 96 | | ports = doc_scd.softwarecomponent.componentfeatures.ports |
| 97 | | if hasattr(ports,'provides'): |
| 98 | | for p in ports.provides: |
| 99 | | tmpName = p.providesname |
| 100 | | tmpInt = getInterface(p.repid,tmpName) |
| 101 | | if tmpInt == None: |
| 102 | | return None |
| 103 | | tmpType = p.porttype.type |
| 104 | | newPort = CC.Port(tmpName,tmpInt,type='Provides',portType=tmpType) |
| 105 | | newComp.ports.append(newPort) |
| 106 | | |
| 107 | | if hasattr(ports,'uses'): |
| 108 | | for p in ports.uses: |
| 109 | | tmpName = p.usesname |
| 110 | | tmpInt = getInterface(p.repid,tmpName) |
| 111 | | if tmpInt == None: |
| 112 | | return None |
| 113 | | tmpType = p.porttype.type |
| 114 | | newPort = CC.Port(tmpName,tmpInt,type='Uses',portType=tmpType) |
| 115 | | newComp.ports.append(newPort) |
| | 95 | portsNodes = doc_scd.getElementsByTagName("ports") |
| | 96 | for node in portsNodes: |
| | 97 | providesPortsNodes = node.getElementsByTagName("provides") |
| | 98 | usesPortsNodes = node.getElementsByTagName("uses") |
| | 99 | |
| | 100 | # Provides ports |
| | 101 | for node in providesPortsNodes: |
| | 102 | tmpName = node.getAttribute("providesname") |
| | 103 | tmpInt = getInterface( node.getAttribute("repid"), tmpName ) |
| | 104 | if tmpInt == None: |
| | 105 | return None |
| | 106 | portTypeNodeList = node.getElementsByTagName("porttype") |
| | 107 | tmpType = portTypeNodeList[0].getAttribute("type") |
| | 108 | newPort = CC.Port(tmpName,tmpInt,type='Provides',portType=tmpType) |
| | 109 | newComp.ports.append(newPort) |
| | 110 | |
| | 111 | # Uses ports |
| | 112 | for node in usesPortsNodes: |
| | 113 | tmpName = node.getAttribute("usesname") |
| | 114 | tmpInt = getInterface( node.getAttribute("repid"), tmpName ) |
| | 115 | if tmpInt == None: |
| | 116 | return None |
| | 117 | portTypeNodeList = node.getElementsByTagName("porttype") |
| | 118 | tmpType = portTypeNodeList[0].getAttribute("type") |
| | 119 | newPort = CC.Port(tmpName,tmpInt,type='Uses',portType=tmpType) |
| | 120 | newComp.ports.append(newPort) |
| 207 | | |
| 208 | | |
| 209 | | def getSimpleProperty(s): |
| 210 | | if not hasattr(s,"name"): |
| 211 | | return None |
| 212 | | tmpName = s.name |
| 213 | | if not hasattr(s,"id"): |
| 214 | | return None |
| 215 | | tmpId = s.id |
| 216 | | if not hasattr(s,"type"): |
| 217 | | return None |
| 218 | | tmpType = s.type |
| 219 | | if not hasattr(s,"mode"): |
| 220 | | return None |
| 221 | | tmpMode = s.mode |
| 222 | | if hasattr(s,"description"): |
| 223 | | tmpDes = str(s.description) |
| 224 | | else: |
| 225 | | tmpDes = '' |
| 226 | | |
| 227 | | if tmpMode not in availableModes: |
| 228 | | return None |
| 229 | | if tmpType not in availableTypes: |
| 230 | | return None |
| 231 | | |
| 232 | | newProp = CC.SimpleProperty(tmpName,tmpMode,tmpType,description=tmpDes) |
| 233 | | |
| 234 | | if hasattr(s,"value"): |
| 235 | | newProp.value = newProp.defaultValue = str(s.value) |
| 236 | | |
| 237 | | if hasattr(s,"units"): |
| 238 | | newProp.units = str(s.units) |
| 239 | | |
| 240 | | if hasattr(s,"range"): |
| 241 | | newProp.range = (str(s.range.min),str(s.range.max)) |
| 242 | | |
| 243 | | if hasattr(s,"enum"): |
| 244 | | newProp.enum = str(s.enum.label) |
| 245 | | |
| 246 | | if not hasattr(s, "kind"): |
| 247 | | return None |
| 248 | | newProp.kind = str(s.kind.kindtype) |
| 249 | | |
| 250 | | if hasattr(s,"action"): |
| 251 | | newProp.action = str(s.action.type) |
| 252 | | |
| 253 | | return newProp |
| 254 | | |
| 255 | | def getSimpleSequenceProperty(s): |
| 256 | | if not hasattr(s,"name"): |
| 257 | | return None |
| 258 | | tmpName = s.name |
| 259 | | if not hasattr(s,"id"): |
| 260 | | return None |
| 261 | | tmpId = s.id |
| 262 | | if not hasattr(s,"type"): |
| 263 | | return None |
| 264 | | tmpType = s.type |
| 265 | | if not hasattr(s,"mode"): |
| 266 | | return None |
| 267 | | tmpMode = s.mode |
| 268 | | if hasattr(s,"description"): |
| 269 | | tmpDes = str(s.description) |
| 270 | | else: |
| 271 | | tmpDes = '' |
| 272 | | |
| 273 | | if tmpMode not in availableModes: |
| 274 | | return None |
| 275 | | if tmpType not in availableTypes: |
| 276 | | return None |
| 277 | | |
| 278 | | newProp = CC.SimpleSequenceProperty(tmpName,tmpMode,tmpType,description=tmpDes,values=[]) |
| 279 | | |
| 280 | | if hasattr(s,"value"): |
| 281 | | for val in s.value: |
| 282 | | newProp.values.append((str(val), str(val))) |
| 283 | | |
| 284 | | if hasattr(s,"units"): |
| 285 | | newProp.units = str(s.units) |
| 286 | | |
| 287 | | if hasattr(s,"range"): |
| 288 | | newProp.range = (str(s.range.min),str(s.range.max)) |
| 289 | | |
| 290 | | if not hasattr(s, "kind"): |
| 291 | | return None |
| 292 | | newProp.kind = str(s.kind.kindtype) |
| 293 | | |
| 294 | | if hasattr(s,"action"): |
| 295 | | newProp.action = str(s.action.type) |
| 296 | | |
| 297 | | return newProp |
| | 208 | |