Beispiel #1
0
    def DisplayAvailableComponents(self):
        self.componentsBox.DeleteAllItems()
        self.availableComponents.clear()
        installRoot = self.componentsBox.AddRoot("install_root")
        
        #get the list of spd files under /sdr/dom/xml
        spdFiles = ALFutils.getFileList(self.fileMgr, "dom/xml", "*.spd.xml")
        for spd_file in spdFiles:   
             compname = spd_file[spd_file.rfind("/")+1:-8]
             #installPath is set to /sdr/dom by default
             compNameAndDir = spd_file[:spd_file.rfind("/")]

             if self.availableComponents.has_key(compname):
                 errorMsg(self, "Conflicting component name: " + compname)
                 continue
            
             self.availableComponents[compname] = (compname, compNameAndDir)
    
        # Populate the display at the Domain level
        for component in self.availableComponents.keys():
            t1 = self.componentsBox.AppendItem(installRoot,component)
            self.componentsBox.SetPyData(t1,self.availableComponents[component])
            self.componentsBox.SetItemBold(t1,False)

        self.componentsBox.SortChildren(installRoot)
Beispiel #2
0
    def __init__(self,parent):
        self.active_wave = None
        self.timing_display = None
        self.tools = None
        self.connect_frame = None
        self.waveform_displays = {}

        # WARNING: if alf is restarted and waveforms are left running
        # counters will overlap and cause a crash :/
        self.compform_counter = 0

        self._init_ctrls(parent)
        self.Available_Ints = ALFutils.importStandardIdl(self)
        self.rootContext = None
        self.domMgr = None
        self.fileMgr = None
        
        
        self.init_CORBA()
        
        ALFutils.LoadConfiguration(self)

        self.waveformData = {}
        self.tool_frames = []
        self.last_waveform_data_update = None
        self.dasXML_list = []
        self.availableWaveforms = {}
        self.availableComponents = {}
        self.connections = {'127.0.0.1': []}

        if self.rootContext != None and self.fileMgr != None:
            self.DisplayInstalledWaveforms()
            self.DisplayAvailableWaveforms()
            self.DisplayAvailableComponents()
def getBaseName(alfFrame, spd_path):
    # Create a binding of the SAD file
    doc_spd = ALFutils.getDOM (alfFrame.fileMgr, spd_path)
    if doc_spd is None:
        print "INvalid doc_spd - spd_path = ",spd_path 
        return None
    # TODO: validate against dtd
    try:
        softpkgNode = doc_spd.getElementsByTagName("softpkg")[0]
    except:
        errorMsg(parent, "Invalid SPD file: " + spd_path + "; no \"softpkg\" node found")
        return None
        
    return str(softpkgNode.getAttribute("name"))
Beispiel #4
0
    def BuildDevSeq(self, dasXML):
        doc_das = ALFutils.getDOM(self.fileMgr, dasXML)
        if doc_das is None:
            return None
        # create node list of "deviceassignmenttype"
        deviceassignmenttypeNodeList = doc_das.getElementsByTagName("deviceassignmenttype")

        ds = []
        for n in deviceassignmenttypeNodeList:
            componentid = n.getElementsByTagName("componentid")[0].firstChild.data
            assigndeviceid = n.getElementsByTagName("assigndeviceid")[0].firstChild.data
            ds.append(CF.DeviceAssignmentType(str(componentid),str(assigndeviceid)))

        return ds
def getWaveform(sad_path, parent, interfaces):
 
    # Create a binding of the SAD file
    #Get the dom from ALFutils. if the file is not found, the ALFutils module 
    #will take care of reporting error
    doc_sad = ALFutils.getDOM(parent.fileMgr, sad_path) 
    if doc_sad is None:
        return None

    # TODO: validate SAD file against the dtd
    # try to find "softwareassembly" node
    try:
        softwareassemblyNode = doc_sad.getElementsByTagName("softwareassembly")[0]
    except:
        errorMsg(parent, "Invalid SAD file: " + sad_path + "; no \"softwareassembly\" tag")
        return None
    
    # try to find "componentfiles" node
    try:
        componentfilesNode = softwareassemblyNode.getElementsByTagName("componentfiles")[0]
    except:
        errorMsg(parent, "Invalid SAD file: " + sad_path + "; no \"componentfiles\" tag")
        return None

    # At this point, assume SAD file validates against the DTD; no longer
    # necessary to use try/except statements
    waveform_name = softwareassemblyNode.getAttribute("name")
    new_waveform = WC.Waveform(str(waveform_name))

    # Get list of "componentfile" nodes from SAD file
    componentfileNodeList = componentfilesNode.getElementsByTagName("componentfile")
    
    # Dictionary storing mapping of componentfile ids to file names (unicode)
    compfiles = {}  
    for componentfileNode in componentfileNodeList:
        localfilename = componentfileNode.getElementsByTagName("localfile")[0].getAttribute("name")
        #localfilename resembles "/xml/TxDemo/TxDemo.spd.xml". taht itself should be enough
        #to open the file through FileManager. No need to add /sdr/dom
        tmps = localfilename
        #have to pass the parent(alf frame object) so that getBaseName can make use of fileMgr
        base_name = getBaseName(parent, tmps)
        # TODO: this next line is a dirty hack: use the python os module to strip name from path
        tmps = tmps[0:tmps.rfind('/')]  # remove actual file name (importResource format)
        componentfileid = componentfileNode.getAttribute("id")
        compfiles[componentfileid] = (tmps,base_name)

    # Create the component objects from the componentplacement section
    componentplacementNodeList = softwareassemblyNode.getElementsByTagName("componentplacement")
    for componentplacementNode in componentplacementNodeList:
        # get refid
        componentfilerefNode = componentplacementNode.getElementsByTagName("componentfileref")[0]
        refid = componentfilerefNode.getAttribute("refid")

        # get component path from compfiles dictionary
        comp_path = compfiles[refid][0]

        # get componentinstantiation id (strip off "DCE:")
        componentinstantiationNode = componentplacementNode.getElementsByTagName("componentinstantiation")[0]
        comp_id = str(componentinstantiationNode.getAttribute("id")).replace("DCE:","")

        # get component base name from compfiles dictionary
        comp_base_name = str(compfiles[refid][1])

        # get usagename
        usagenameNode = componentinstantiationNode.getElementsByTagName("usagename")[0]
        comp_name = str(usagenameNode.firstChild.data)

        new_comp = importResourceForALF.getResource(comp_path, comp_base_name, parent)
        new_comp.name = comp_name
        new_comp.uuid = comp_id
        new_comp.file_uuid = str(refid.replace(comp_base_name + '_',''))
        new_waveform.components.append(new_comp)
    
    # Assign interfaces based on import IDL - gets the operations right this way
    for comp in new_waveform.components:
        assignInterfaces(comp,interfaces)
    
    # Find and set the AssemblyController through its refid
    assemblycontrollerNode = softwareassemblyNode.getElementsByTagName("assemblycontroller")[0]
    # NOTE: first and only child is "componentinstantiationref"
    componentinstantiationrefNode = assemblycontrollerNode.getElementsByTagName("componentinstantiationref")[0]
    ac = str(componentinstantiationrefNode.getAttribute("refid"))
    ac = ac.replace("DCE:","")
    for c in new_waveform.components:
        if c.uuid == ac:
            c.AssemblyController = True


    # Create the connections
    connectinterfaceNodeList = softwareassemblyNode.getElementsByTagName("connectinterface")

    if len(connectinterfaceNodeList) != 0:
        for connectinterfaceNode in connectinterfaceNodeList:
            usesportNode = connectinterfaceNode.getElementsByTagName("usesport")[0]
            usesid = usesportNode.getElementsByTagName("usesidentifier")[0].firstChild.data
            # NOTE: first and only child of "findby" node is "namingservice"
            findbyNode = usesportNode.getElementsByTagName("findby")[0]
            nsname = findbyNode.getElementsByTagName("namingservice")[0].getAttribute("name")
            usesid = str(usesid)
            nsname = str(nsname)

            uses_comp = getCompFromNSName(nsname,new_waveform)

            # Check for providesport
            providesportNodeList = connectinterfaceNode.getElementsByTagName("providesport")
            if len(providesportNodeList) != 0:
                # "providesport" tag exists
                providesportNode = providesportNodeList[0]

                # get providesidentifier
                providesidentifierNode = providesportNode.getElementsByTagName("providesidentifier")[0]
                providesid = str(providesidentifierNode.firstChild.data)

                # get namingservice name
                # NOTE: first and only child of "findby" node is "namingservice"
                findbyNode = providesportNode.getElementsByTagName("findby")[0]
                nsname = str(findbyNode.getElementsByTagName("namingservice")[0].getAttribute("name"))
                provides_comp = getCompFromNSName(nsname,new_waveform)
            else:
                # "providesport" tag does not exist
                # Probably is a hardware port located directly on the naming service
                # Not supporting this quite yet
                continue
                # NOTE: the next line is only supported with amara
                if not hasattr(ci, 'findby'):
                    errorMsg(parent, "Invalid SAD file")
                    return None
                
                nsname = str(ci.findby.namingservice.name)


            uses_port = None
            provides_port = None

            #try statement is a temporary fix to ALF's inability to display devices
            try:
                for port in uses_comp.ports:
                    if port.name == usesid:
                        uses_port = port
                for port in provides_comp.ports:
                    if port.name == providesid:
                        provides_port = port

                # Unfortunately there is no information stored in the XML about which component
                # initiated the connection in OWD - so we'll say that uses is always the local port
                new_connection = CC.Connection(uses_port, provides_port, provides_comp)

                uses_comp.connections.append(new_connection)
            except:
                pass    #skip the device

    return new_waveform
Beispiel #6
0
    def InstallWaveform(self,name_SAD, absolute_name_SAD, 
                        name_DAS, absolute_name_DAS, start_flag = True):
        ''' Installs waveform application as an (SCA) application.  By default
            the (SCA) application will be started '''
         
        #name_SAD - contains the path of the SAD file relative the framework filesystem
        #e.g. the framework file system is mounted at /sdr/dom. then the value of name_SAD
        #would be /waveforms/ossie_demo/ossie_demo.sad.xml
           
        #doc_sad = xml.dom.minidom.parse(absolute_name_SAD)
        doc_sad = ALFutils.getDOM (self.fileMgr, name_SAD)
        if doc_sad is None:
            return
        app_name = doc_sad.getElementsByTagName("softwareassembly")[0].getAttribute("name")
        _appFacProps = []
        devMgrSeq = self.domMgr._get_deviceManagers()
        available_dev_seq = []
        for devmgr in range(len(devMgrSeq)):
            devMgr = devMgrSeq[devmgr]
            curr_devSeq = devMgr._get_registeredDevices()
            for dev in range(len(curr_devSeq)):
                curr_dev = curr_devSeq[dev]
                available_dev_seq.append(curr_dev._get_identifier())
                #print curr_dev._get_identifier()

        self.domMgr.installApplication(name_SAD)
        
        # Parse the device assignment sequence, ensure
        #Use FileManager to open files.
        
        doc_das = ALFutils.getDOM(self.fileMgr, name_DAS)
        deviceassignmenttypeNodeList = doc_das.getElementsByTagName("deviceassignmenttype")

        for deviceassignmenttypeNode in deviceassignmenttypeNodeList:
            # look for assigndeviceid nodes
            assigndeviceidNodeList = deviceassignmenttypeNode.getElementsByTagName("assigndeviceid")
            if len(assigndeviceidNodeList) == 0:
                ts = "Could not find \"assigndeviceid\" tag\nAborting install"
                errorMsg(self, ts)
                return

            # get assigndeviceid tag value (DCE:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
            assigndeviceid = assigndeviceidNodeList[0].firstChild.data

            # ensure assigndeviceid is in list of available devices
            if assigndeviceid not in available_dev_seq:
                ts = "Could not find the required device: " + str(assigndeviceid)
                ts += "\nAborting install"
                errorMsg(self, ts)
                return
                
        _devSeq = self.BuildDevSeq(name_DAS)
        _applicationFactories = self.domMgr._get_applicationFactories()

        # attempt to match up the waveform application name to 
        # a application factory of the same name
        app_factory_num = -1
        for app_num in range(len(_applicationFactories)):
            if _applicationFactories[app_num]._get_name()==app_name:
                app_factory_num = app_num
                break
    
        if app_factory_num == -1:
            print "Application factory not found"
            sys.exit(-1)

        # use the application factor I found above to create an instance
        # of an application
        try:
            app = _applicationFactories[app_factory_num].create(_applicationFactories[app_factory_num]._get_name(),_appFacProps,_devSeq)
        except:
            print "Unable to create application - make sure that all appropriate nodes are installed"
            return(None)
        
        if start_flag:
            # start the application
            app.start()
        
        naming_context_list = app._get_componentNamingContexts()
        naming_context = naming_context_list[0].elementId.split("/")
        application_name = app._get_name()
        waveform_name = naming_context[1]
        
        
#        self.refreshDisplay()
        self.DisplayInstalledWaveforms()
        if self.connect_frame:
            self.connect_frame.refreshDisplay()

        return app
Beispiel #7
0
def getResource(path, Rname, parent):
    #
    #    scdPath = findFile(path,Rname,".scd.xml")
    #    if scdPath == None:
    #        errorMsg(parent,"No scd file found for: " + Rname)
    #        return
    #
    #    spdPath = findFile(path,Rname,".spd.xml")
    #    prfPath = findFile(path,Rname,".prf.xml")

    #converting from unicode to string.
    scdPath = str(path + "/" + Rname + ".scd.xml")
    spdPath = str(path + "/" + Rname + ".spd.xml")
    prfPath = str(path + "/" + Rname + ".prf.xml")

    #return if any of these three files does not exist
    if not (parent.fileMgr.exists(scdPath) or \
        parent.fileMgr.exists(spdPath) or \
        parent.fileMgr.exists(prfPath) ):
        errorMsg(
            parent,
            "Some files (scd/spd/prf) missing for " + Rname + " in " + path)
        return

    #
    # Build the main component or device from the SCD file
    #
    #doc_scd = xml.dom.minidom.parse(scdPath)
    doc_scd = ALFutils.getDOM(parent.fileMgr, scdPath)
    try:
        componenttypeNode = doc_scd.getElementsByTagName("componenttype")
        componenttype = componenttypeNode[0].childNodes[0].data
    except:
        errorMsg(parent, "Invalid file: " + scdPath)
        return None

    #doc_spd = xml.dom.minidom.parse(spdPath)
    doc_spd = ALFutils.getDOM(parent.fileMgr, spdPath)

    # get resource description
    # note: this is not the same as the implementation description
    softpkgNode = doc_spd.getElementsByTagName("softpkg")[0]
    Rdescription = ''
    for n in softpkgNode.childNodes:
        if n.nodeName == "description":
            resDescriptionNode = doc_spd.getElementsByTagName("description")
            try:
                Rdescription = resDescriptionNode[0].firstChild.data
            except:
                pass
            break

    #Instantiate a new component of the appropriate type
    if componenttype == u'resource':
        newComp = CC.Component(name=Rname,
                               type='resource',
                               description=Rdescription)
    elif componenttype == u'executabledevice':
        newComp = CC.Component(name=Rname,
                               type='executabledevice',
                               description=Rdescription)
    elif componenttype == u'loadabledevice':
        newComp = CC.Component(name=Rname,
                               type='loadabledevice',
                               description=Rdescription)
    elif componenttype == u'device':
        newComp = CC.Component(name=Rname,
                               type='device',
                               description=Rdescription)
    else:
        errorMsg(parent, "Can't identify resource type for: " + Rname)
        return None

    # Get the Ports
    portsNodes = doc_scd.getElementsByTagName("ports")
    for node in portsNodes:
        providesPortsNodes = node.getElementsByTagName("provides")
        usesPortsNodes = node.getElementsByTagName("uses")

    # Provides ports
    for node in providesPortsNodes:
        tmpName = node.getAttribute("providesname")
        tmpInt = getInterface(node.getAttribute("repid"), tmpName)
        if tmpInt == None:
            return None
        portTypeNodeList = node.getElementsByTagName("porttype")
        tmpType = portTypeNodeList[0].getAttribute("type")
        newPort = CC.Port(tmpName, tmpInt, type='Provides', portType=tmpType)
        newComp.ports.append(newPort)

    # Uses ports
    for node in usesPortsNodes:
        tmpName = node.getAttribute("usesname")
        tmpInt = getInterface(node.getAttribute("repid"), tmpName)
        if tmpInt == None:
            return None
        portTypeNodeList = node.getElementsByTagName("porttype")
        tmpType = portTypeNodeList[0].getAttribute("type")
        newPort = CC.Port(tmpName, tmpInt, type='Uses', portType=tmpType)
        newComp.ports.append(newPort)

    # Make sure that xml and code are not generated for this resource
    newComp.generate = False

    # Store the name of the file without the suffix (.scd.xml)
    i = scdPath.rfind("/")
    if i != -1:
        newComp.xmlName = scdPath[i + 1:-8]
    else:
        newComp.xmlName = scdPath[:-8]

    #
    # Import the properties from the PRF file
    #
    # If there are no properties, just return the component as is
    if prfPath == None:
        return newComp
    #doc_prf = xml.dom.minidom.parse(prfPath)
    doc_prf = ALFutils.getDOM(parent.fileMgr, prfPath)
    try:
        propertyNodeList = doc_prf.getElementsByTagName("properties")
    except:
        errorMsg(parent, "Invalid file: " + prfPath)
        return None

    # get simple properties
    simplePropertyNodeList = doc_prf.getElementsByTagName("simple")
    for node in simplePropertyNodeList:
        p = getSimpleProperty(node)
        if p == None:
            print "There was an error parsing simple properties in the PRF file " + prfPath
            continue
        newComp.properties.append(p)

    # get simple sequence properties
    simpleSequencePropertyNodeList = doc_prf.getElementsByTagName(
        "simplesequence")
    for node in simpleSequencePropertyNodeList:
        p = getSimpleSequenceProperty(node, prfPath)
        if p == None:
            print "There was an error parsing simple sequence properties in the PRF file " + prfPath
            continue
        newComp.properties.append(p)

    return newComp
def getResource(path,Rname,parent):
#    
#    scdPath = findFile(path,Rname,".scd.xml")                
#    if scdPath == None:         
#        errorMsg(parent,"No scd file found for: " + Rname)
#        return
#    
#    spdPath = findFile(path,Rname,".spd.xml")
#    prfPath = findFile(path,Rname,".prf.xml")
    
    #converting from unicode to string.
    scdPath = str(path + "/" + Rname + ".scd.xml")
    spdPath = str(path + "/" + Rname + ".spd.xml")
    prfPath = str(path + "/" + Rname + ".prf.xml")
    
    #return if any of these three files does not exist
    if not (parent.fileMgr.exists(scdPath) or \
        parent.fileMgr.exists(spdPath) or \
        parent.fileMgr.exists(prfPath) ):
        errorMsg(parent, "Some files (scd/spd/prf) missing for " + Rname + " in " + path )
        return
    
    #
    # Build the main component or device from the SCD file    
    #
    #doc_scd = xml.dom.minidom.parse(scdPath)
    doc_scd = ALFutils.getDOM(parent.fileMgr, scdPath)
    try:
        componenttypeNode = doc_scd.getElementsByTagName("componenttype")
        componenttype = componenttypeNode[0].childNodes[0].data
    except:
        errorMsg(parent,"Invalid file: " + scdPath)
        return None
    
    #doc_spd = xml.dom.minidom.parse(spdPath)
    doc_spd = ALFutils.getDOM(parent.fileMgr, spdPath)

    # get resource description
    # note: this is not the same as the implementation description
    softpkgNode = doc_spd.getElementsByTagName("softpkg")[0]
    Rdescription = ''
    for n in softpkgNode.childNodes:
        if n.nodeName == "description":
            resDescriptionNode = doc_spd.getElementsByTagName("description")
            try:
                Rdescription = resDescriptionNode[0].firstChild.data
            except:
                pass
            break

    #Instantiate a new component of the appropriate type
    if componenttype == u'resource':
        newComp = CC.Component(name=Rname,type='resource',description=Rdescription)
    elif componenttype == u'executabledevice':
        newComp = CC.Component(name=Rname,type='executabledevice',description=Rdescription)
    elif componenttype == u'loadabledevice':
        newComp = CC.Component(name=Rname,type='loadabledevice',description=Rdescription)
    elif componenttype == u'device':
        newComp = CC.Component(name=Rname,type='device',description=Rdescription)
    else:
        errorMsg(parent,"Can't identify resource type for: " + Rname)
        return None
        
    # Get the Ports
    portsNodes = doc_scd.getElementsByTagName("ports")
    for node in portsNodes:
        providesPortsNodes = node.getElementsByTagName("provides")
        usesPortsNodes = node.getElementsByTagName("uses")

    # Provides ports
    for node in providesPortsNodes:
        tmpName = node.getAttribute("providesname")
        tmpInt = getInterface( node.getAttribute("repid"), tmpName )
        if tmpInt == None:
            return None
        portTypeNodeList = node.getElementsByTagName("porttype")
        tmpType = portTypeNodeList[0].getAttribute("type")
        newPort = CC.Port(tmpName,tmpInt,type='Provides',portType=tmpType)
        newComp.ports.append(newPort)

    # Uses ports
    for node in usesPortsNodes:
        tmpName = node.getAttribute("usesname")
        tmpInt = getInterface( node.getAttribute("repid"), tmpName )
        if tmpInt == None:
            return None
        portTypeNodeList = node.getElementsByTagName("porttype")
        tmpType = portTypeNodeList[0].getAttribute("type")
        newPort = CC.Port(tmpName,tmpInt,type='Uses',portType=tmpType)
        newComp.ports.append(newPort)

    # Make sure that xml and code are not generated for this resource
    newComp.generate = False        
    
    # Store the name of the file without the suffix (.scd.xml)
    i = scdPath.rfind("/")
    if i != -1:
        newComp.xmlName = scdPath[i+1:-8]
    else:
        newComp.xmlName = scdPath[:-8]
    
    #
    # Import the properties from the PRF file
    #
    # If there are no properties, just return the component as is
    if prfPath == None:
        return newComp
    #doc_prf = xml.dom.minidom.parse(prfPath)
    doc_prf = ALFutils.getDOM(parent.fileMgr, prfPath)
    try:
        propertyNodeList = doc_prf.getElementsByTagName("properties")
    except:
        errorMsg(parent,"Invalid file: " + prfPath)
        return None
    
    # get simple properties
    simplePropertyNodeList = doc_prf.getElementsByTagName("simple")
    for node in simplePropertyNodeList:
        p = getSimpleProperty(node)
        if p == None:
            print "There was an error parsing simple properties in the PRF file " + prfPath
            continue
        newComp.properties.append(p)

    # get simple sequence properties
    simpleSequencePropertyNodeList = doc_prf.getElementsByTagName("simplesequence")
    for node in simpleSequencePropertyNodeList:
        p = getSimpleSequenceProperty(node, prfPath)
        if p == None:
            print "There was an error parsing simple sequence properties in the PRF file " + prfPath
            continue
        newComp.properties.append(p)

    return newComp