Changeset 11083

Show
Ignore:
Timestamp:
03/27/12 10:15:44 (15 months ago)
Author:
Snyder.Jason
Message:

changes related to alternate component implementations

Location:
ossiedev/branches/jsnyder/trunk/tools/WaveDev/wavedev
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • ossiedev/branches/jsnyder/trunk/tools/WaveDev/wavedev/ComponentClass.py

    r8112 r11083  
    2121# Component Class 
    2222class Component: 
    23   def __init__(self, name="",AC=False,type="resource",description="",generate=True): 
    24     self.name = name        # this refers to the instance name 
    25     self.baseName = name    # this refers to the component that the instance is based on 
    26     self.connections = [] 
    27     self.ports = [] 
    28     self.mutable_params = [] 
    29     self.device = None 
    30     self.node = None 
    31     self.uuid = uuidgen.uuidgen() 
    32     self.file_uuid = uuidgen.uuidgen() 
    33     self.ace = False 
    34     self.timing = False 
    35     self.AssemblyController = AC 
    36     self.type = type 
    37     self.generate = generate 
    38     self.xmlName = name     #if imported from component library - this may change 
    39     self.properties = [] 
    40     self.description = description 
     23    def __init__(self, name="",AC=False,type="resource",description="",generate=True): 
     24        self.name = name        # this refers to the instance name 
     25        self.baseName = name    # this refers to the component that the instance is based on 
     26        self.connections = [] 
     27        self.ports = [] 
     28        self.mutable_params = [] 
     29        self.device = None 
     30        self.node = None 
     31        self.uuid = uuidgen.uuidgen() 
     32        self.file_uuid = uuidgen.uuidgen() 
     33        self.ace = False 
     34        self.timing = False 
     35        self.AssemblyController = AC 
     36        self.type = type 
     37        self.generate = generate 
     38        self.xmlName = name     #if imported from component library - this may change 
     39        self.properties = [] 
     40        self.description = description 
     41        self.implementations = [] 
    4142 
    42   def __getitem__(self,i): 
    43       return self.connections[i] 
     43    def __getitem__(self,i): 
     44        return self.connections[i] 
    4445 
    45   def setUUID(self): 
    46       self.uuid = uuidgen.uuidgen() 
     46    def setUUID(self): 
     47        self.uuid = uuidgen.uuidgen() 
    4748 
    48   def changeName(self,newname): 
    49       self.name = newname 
    50       if self.generate == True: 
    51           self.baseName = newname 
    52           self.xmlName = newname 
     49    def changeName(self,newname): 
     50        self.name = newname 
     51        if self.generate == True: 
     52            self.baseName = newname 
     53            self.xmlName = newname 
     54             
     55    def getImplementation(self, processorName): 
     56        for implementation in self.implementations: 
     57            if implementation.name == processorName: 
     58                return implementation 
     59        return None 
     60           
     61 
    5362 
    5463class Node: 
    55   def __init__(self, name="", path="", description="", generate=True): 
    56     self.name = name 
    57     self.path = path 
    58     self.Devices = [] 
    59     self.type = "node" 
    60     self.generate = generate 
    61     self.description = description 
    62     self.id = "" 
     64    def __init__(self, name="", path="", description="", generate=True): 
     65        self.name = name 
     66        self.path = path 
     67        self.Devices = [] 
     68        self.type = "node" 
     69        self.generate = generate 
     70        self.description = description 
     71        self.id = "" 
    6372 
    64   def addDevice(self, in_dev=None): 
    65     if in_dev != None: 
    66       self.Devices.append(in_comp) 
     73    def addDevice(self, in_dev=None): 
     74        if in_dev != None: 
     75            self.Devices.append(in_dev) 
    6776 
    6877 
    6978class Port: 
    70   def __init__(self, name, interface, type="Uses",portType="data"):#,dataType="ShortSequence",interface_ns="standardInterfaces"): 
    71     self.name = name 
    72     self.interface = interface 
    73     self.portType = portType    #control or data 
    74     self.type = type            #Uses or Provides 
    75     self.u_cname = "dataOut_" + interface.name + "_i" 
    76     self.p_cname = "dataIn_" + interface.name + "_i" 
    77     if type == "Uses": 
    78         self.cname = self.u_cname 
    79     if type == "Provides": 
    80         self.cname = self.p_cname 
     79    def __init__(self, name, interface, type="Uses",portType="data"):#,dataType="ShortSequence",interface_ns="standardInterfaces"): 
     80        self.name = name 
     81        self.interface = interface 
     82        self.portType = portType    #control or data 
     83        self.type = type            #Uses or Provides 
     84        self.u_cname = "dataOut_" + interface.name + "_i" 
     85        self.p_cname = "dataIn_" + interface.name + "_i" 
     86        if type == "Uses": 
     87            self.cname = self.u_cname 
     88        if type == "Provides": 
     89            self.cname = self.p_cname 
    8190 
    8291class Connection: 
     
    159168        self.kind = kind 
    160169        self.action = action 
     170         
     171class Implementation: 
     172    def __init__(self, id, description='', propertyFile='', processor=''): 
     173        self.id = id 
     174        self.description = description 
     175        self.propertyFile = propertyFile 
     176        self.processor = processor 
     177        self.properties = [] 
     178         
     179    
    161180 
    162181 
  • ossiedev/branches/jsnyder/trunk/tools/WaveDev/wavedev/importNode.py

    r10753 r11083  
    152152        newComp.xmlName =  os.path.splitext(os.path.splitext(os.path.basename(pathSCD))[0])[0] 
    153153 
    154         newNode.Devices.append(newComp) 
     154         
    155155 
    156156        # 
     
    182182        #            continue 
    183183        #        newComp.properties.append(p) 
     184        # 
     185        # Import the properties from the PRF file 
     186        # 
     187         
     188        # If there are no properties, just return the component as is 
     189        tmp = doc_spd.getElementsByTagName("propertyfile") 
     190        if len(tmp) > 0: 
     191            propertyFileNode = tmp[0] 
     192            propertyFile = '/sdr/dev' + propertyFileNode.getElementsByTagName("localfile")[0].getAttribute("name") 
     193            propertyDoc = xml.dom.minidom.parse(propertyFile) 
     194            simplePropNodes = propertyDoc.getElementsByTagName("simple") 
     195            simpleProps = getSimpleProperties(simplePropNodes, propertyFile) 
     196             
     197            for prop in simpleProps: 
     198                newComp.properties.append(prop) 
     199             
     200            simpleSequencePropNodes = propertyDoc.getElementsByTagName("simplesequence") 
     201            simpleSequenceProps = getSimpleSequenceProperties(simpleSequencePropNodes, propertyFile) 
     202             
     203            for prop in simpleSequenceProps: 
     204                newComp.properties.append(prop) 
     205        else: 
     206            propertyFile = None 
     207     
     208        
     209         
     210        newNode.Devices.append(newComp) 
    184211 
    185212    return newNode 
     
    233260    return xml 
    234261 
     262def getSimpleProperties(simplePropertyNodeList, propertyFile): 
     263    props = [] 
     264    for node in simplePropertyNodeList: 
     265        p = getSimpleProperty(node) 
     266        if p == None: 
     267            print "There was an error parsing simple properties in the PRF file " + propertyFile 
     268            continue 
     269        props.append(p) 
     270         
     271    return props 
     272 
     273def getSimpleSequenceProperties(simpleSequencePropertyNodeList, propertyFile): 
     274    props = [] 
     275    for node in simpleSequencePropertyNodeList: 
     276        p = getSimpleSequenceProperty(node, propertyFile) 
     277        if p == None: 
     278            print "There was an error parsing simple sequence properties in the PRF file " + propertyFile 
     279            continue 
     280        props.append(p) 
     281         
     282    return props 
     283 
     284def getSimpleProperty(n): 
     285    tmpName = n.getAttribute("name") 
     286    tmpID   = n.getAttribute("id") 
     287    tmpType = n.getAttribute("type") 
     288    tmpMode = n.getAttribute("mode") 
     289    tmpDes = n.getAttribute("description") 
     290 
     291    if tmpName == "" or tmpID == "" or tmpType == "" or tmpMode == "": 
     292        return None 
     293    if tmpMode not in availableModes: 
     294        return None 
     295    if tmpType not in availableTypes: 
     296        return None 
     297     
     298    newProp = CC.SimpleProperty(tmpName,tmpMode,tmpType,description=tmpDes) 
     299    
     300    # Set ID 
     301    #UUID in the sad file will need to match the UUID in the prf (tmpID is from prf) 
     302    newProp.id = tmpID 
     303 
     304    # Get/set property value 
     305    valueNodeList = n.getElementsByTagName("value") 
     306    value = valueNodeList[0].childNodes[0].data 
     307    newProp.value = newProp.defaultValue = str(value) 
     308    del valueNodeList, value 
     309     
     310    # Get/set property units 
     311    unitsNodeList = n.getElementsByTagName("units") 
     312    if len(unitsNodeList) > 0: 
     313        units = unitsNodeList[0].childNodes[0].data 
     314        newProp.units = str(s.units) 
     315    #del unitsNodeList, units 
     316     
     317    # TODO: Get/set min/max values 
     318    # TODO: Get/set enum 
     319     
     320    # Get/set kind 
     321    kindNodeList = n.getElementsByTagName("kind") 
     322    kindtype = kindNodeList[0].getAttribute("kindtype") 
     323    if kindtype == "": 
     324        return None 
     325    newProp.kind = str(kindtype) 
     326    del kindNodeList, kindtype 
     327     
     328    # Get/set action 
     329    actionNodeList = n.getElementsByTagName("action") 
     330    if len(actionNodeList) > 0: 
     331        actiontype = actionNodeList[0].getAttribute("type") 
     332        newProp.action = str(actiontype) 
     333    #del actionNodeList, actiontype 
     334         
     335    return newProp 
     336     
     337def getSimpleSequenceProperty(n, prfPath): 
     338    tmpName = n.getAttribute("name") 
     339    tmpID   = n.getAttribute("id") 
     340    tmpType = n.getAttribute("type") 
     341    tmpMode = n.getAttribute("mode") 
     342    tmpDes = n.getAttribute("description") 
     343 
     344    if tmpName == "" or tmpID == "" or tmpType == "" or tmpMode == "": 
     345        return None 
     346    if tmpMode not in availableModes: 
     347        return None 
     348    if tmpType not in availableTypes: 
     349        return None 
     350     
     351    newProp = CC.SimpleSequenceProperty(tmpName,tmpMode,tmpType,description=tmpDes) 
     352    
     353    # Set ID 
     354    #UUID in the sad file will need to match the UUID in the prf (tmpID is from prf) 
     355    newProp.id = tmpID 
     356 
     357 
     358    # Get/set property values 
     359    newProp.values = [] 
     360    newProp.defaultValues = [] 
     361    valuesNodeList = n.getElementsByTagName("values") 
     362     
     363    try: 
     364        valueNodeList = valuesNodeList[0].getElementsByTagName("value") 
     365    except: 
     366        valueNodeList = n.getElementsByTagName("value") #cbd 
     367        #print "\nERROR in " + prfPath 
     368        #print "ERROR parsing prf file.  You may be missing a values tag in a simple sequence property.\n" 
     369        #sys.exit() 
     370        print "\nWarning in " + prfPath 
     371        print "Warning parsing prf file.  You may be missing a values tag in a simple sequence property.\n" 
     372 
     373    for valueNode in valueNodeList: 
     374        tmpVal = valueNode.childNodes[0].data 
     375        newProp.values.append(str(tmpVal)) 
     376        newProp.defaultValues.append(str(tmpVal)) 
     377    del valueNodeList 
     378 
     379    # Get/set property units 
     380    unitsNodeList = n.getElementsByTagName("units") 
     381    if len(unitsNodeList) > 0: 
     382        units = unitsNodeList[0].childNodes[0].data 
     383        newProp.units = str(s.units) 
     384    #del unitsNodeList, units 
     385     
     386    # TODO: Get/set min/max values 
     387    # TODO: Get/set enum 
     388     
     389    # Get/set kind 
     390    kindNodeList = n.getElementsByTagName("kind") 
     391    kindtype = kindNodeList[0].getAttribute("kindtype") 
     392    if kindtype == "": 
     393        return None 
     394    newProp.kind = str(kindtype) 
     395    del kindNodeList, kindtype 
     396 
     397    # Get/set action 
     398    actionNodeList = n.getElementsByTagName("action") 
     399    if len(actionNodeList) > 0: 
     400        actiontype = actionNodeList[0].getAttribute("type") 
     401        newProp.action = str(actiontype) 
     402    #del actionNodeList, actiontype 
     403 
     404    return newProp 
     405 
     406 
  • ossiedev/branches/jsnyder/trunk/tools/WaveDev/wavedev/importResource.py

    r10825 r11083  
    3030 
    3131def getResource(path,Rname,parent): 
    32     scdPath = findFile(path,Rname,".scd.xml")                 
     32    scdPath = findFile(path,Rname,".scd.xml")  
    3333    if scdPath == None:          
    3434        errorMsg(parent,"No scd file found for: " + Rname) 
     
    165165    simpleSequenceProps = [] 
    166166    implementationNodes = doc_spd.getElementsByTagName("implementation") 
    167  
    168167    for node in implementationNodes: 
     168        simpleProps = [] 
     169        simpleSequenceProps = [] 
     170        propertyFile = '' 
    169171        id = node.getAttribute("id") 
    170172        tmp = node.getElementsByTagName("description") 
     
    200202         
    201203        newComp.implementations.append(newImplementation) 
    202      
     204#    print newComp.name + ' summary:' 
     205#    print 'Main properties: ' 
     206#    for prop in newComp.properties: 
     207#        print '    ' + prop.name 
     208#    print 'Implementations:' 
     209#    for imp in newComp.implementations: 
     210#        print imp.processor 
     211#        for prop in imp.properties: 
     212#            print '    ' + prop.name 
    203213    return newComp 
    204214 
     
    265275        p = getSimpleSequenceProperty(node, propertyFile) 
    266276        if p == None: 
    267             print "There was an error parsing simple sequence properties in the PRF file " + propetyFile 
     277            print "There was an error parsing simple sequence properties in the PRF file " + propertyFile 
    268278            continue 
    269279        props.append(p)