예제 #1
0
 def OnConnectBtnButton(self, event):
     srcOK = self.checkSrcBox()
     dstOK = self.checkDstBox()
     
     if not srcOK or not dstOK:
         return        
     else:
         srcSel = self.srcBox.GetSelection()
         dstSel = self.dstBox.GetSelection()        
         # both the source and destination boxes have ports selected
         srcP = self.srcBox.GetPyData(srcSel)
         dstP = self.dstBox.GetPyData(dstSel)
         dstC = self.dstBox.GetPyData(self.dstBox.GetItemParent(dstSel))
         
         if (srcP.type == 'Uses' and dstP.type == 'Uses') or \
             (srcP.type == 'Provides' and dstP.type == 'Provides'):
             errorMsg(self,"Ports cannot be of same type")
             return
         newCon = ComponentClass.Connection(srcP,dstP,dstC)
         tmpflag,tmpcomp = self.checkConnection(newCon)
         if tmpflag == True:
             self.active_comp.connections.append(newCon)
             self.displayConnections()
         else:
             errorMsg(self,"A duplicate connection exists on <"+tmpcomp+">.")
         
     event.Skip()
예제 #2
0
    def ComponentSave(self,saveasFlag):
        if saveasFlag == True or self.saveComponentPath == None:
            tempLn = self.compNameBox.GetLineText(0)
            if tempLn == '':
                errorMsg(self,'Please enter a component name first')
                return
            self.active_comp.name = tempLn

            tempDescr = self.compDescrBox.GetLineText(0)
            if tempDescr == '':
                errorMsg(self,'Please enter a component description first')
                return
            self.active_comp.description = tempDescr

            if len(self.homeDir) > 0:
                tmpdir = self.homeDir
            else:
                tmpdir = os.path.expanduser("~")
                if tmpdir == "~":
                    tmpdir = "/home"

            dlg = wx.FileDialog(self, "Choose a file", tmpdir, tempLn + '.cmp', "Component File (*.cmp)|*.cmp", wx.SAVE)
            try:
                returnCode = dlg.ShowModal()
                if returnCode == wx.ID_OK:
                    self.saveComponentPath = dlg.GetPath()
                elif returnCode == wx.ID_CANCEL:
                    dlg.Destroy()
                    return
            finally:
                dlg.Destroy()

        f = open(self.saveComponentPath,'w')
        cPickle.dump(('component',self.active_comp),f)
예제 #3
0
    def displayPlatformInfo(self):
        if self.parent == None:
            return

        self.deviceChoice.Clear()
        self.nodeChoice.Clear()

        for x in self.parent.active_plat.nodes:
            self.nodeChoice.Append(x.name,x)

        tmpNode = None
        if self.active_comp.device != None:
            for x in self.parent.active_plat.nodes:
                for d in x.Devices:
                    if d == self.active_comp.device:
                        tmpNode = x
            if tmpNode != None:
                pos = self.nodeChoice.FindString(tmpNode.name)
                self.nodeChoice.SetSelection(pos)
                for d in tmpNode.Devices:
                    self.deviceChoice.Append(d.name,d)
                pos = self.deviceChoice.FindString(self.active_comp.device.name)
                self.deviceChoice.SetSelection(pos)

            else:
                tmpstr = 'ERROR! Cannot find the ' + self.active_comp.device.name
                tmpstr += ' device in current Platform configuration.'
                tmpstr += '\nSetting device assignment to None.'
                errorMsg(self,tmpstr)
                self.active_comp.device = None
예제 #4
0
    def ComponentSave(self, saveasFlag):
        if saveasFlag == True or self.saveComponentPath == None:
            tempLn = self.compNameBox.GetLineText(0)
            if tempLn == '':
                errorMsg(self, 'Please enter a component name first')
                return
            self.active_comp.name = tempLn

            tempDescr = self.compDescrBox.GetLineText(0)
            if tempDescr == '':
                errorMsg(self, 'Please enter a component description first')
                return
            self.active_comp.description = tempDescr

            if len(self.homeDir) > 0:
                tmpdir = self.homeDir
            else:
                tmpdir = os.path.expanduser("~")
                if tmpdir == "~":
                    tmpdir = "/home"

            dlg = wx.FileDialog(self, "Choose a file", tmpdir, tempLn + '.cmp',
                                "Component File (*.cmp)|*.cmp", wx.SAVE)
            try:
                returnCode = dlg.ShowModal()
                if returnCode == wx.ID_OK:
                    self.saveComponentPath = dlg.GetPath()
                elif returnCode == wx.ID_CANCEL:
                    dlg.Destroy()
                    return
            finally:
                dlg.Destroy()

        f = open(self.saveComponentPath, 'w')
        cPickle.dump(('component', self.active_comp), f)
예제 #5
0
    def displayPlatformInfo(self):
        if self.parent == None:
            return

        self.deviceChoice.Clear()
        self.nodeChoice.Clear()

        for x in self.parent.active_plat.nodes:
            self.nodeChoice.Append(x.name, x)

        tmpNode = None
        if self.active_comp.device != None:
            for x in self.parent.active_plat.nodes:
                for d in x.Devices:
                    if d == self.active_comp.device:
                        tmpNode = x
            if tmpNode != None:
                pos = self.nodeChoice.FindString(tmpNode.name)
                self.nodeChoice.SetSelection(pos)
                for d in tmpNode.Devices:
                    self.deviceChoice.Append(d.name, d)
                pos = self.deviceChoice.FindString(
                    self.active_comp.device.name)
                self.deviceChoice.SetSelection(pos)

            else:
                tmpstr = 'ERROR! Cannot find the ' + self.active_comp.device.name
                tmpstr += ' device in current Platform configuration.'
                tmpstr += '\nSetting device assignment to None.'
                errorMsg(self, tmpstr)
                self.active_comp.device = None
예제 #6
0
 def checkSrcBox(self):
     srcSel = self.srcBox.GetSelection()
     
     if srcSel == self.srcBox.GetRootItem():
         # nothing is selected in the source box
         errorMsg(self,"Please select a source Port")
         return False
     else:
         return True
예제 #7
0
 def OnValueListPopupRemoveMenu(self, event):
     if self.editable == False:
         errorMsg(self,"This property is not removable!")
         return
     sel = self.valueList.GetFirstSelected()
     if sel >= 0:
         if self.elementType == "Simple":
             self.addValue.Enable(True)
         self.valueList.DeleteItem(sel)
     event.Skip()
예제 #8
0
def getInterface(repid,name):
    try:
        repid = repid.strip('IDL:')
        repid = repid[:repid.rfind(':')]
        tmpNS = repid[:repid.find('/')]
        tmpName = repid[repid.find('/')+1:]
        newInt = CC.Interface(tmpName,nameSpace=tmpNS)
        return newInt
        
    except:
        errorMsg(parent,"Can't read the Interface information for port: " + name)
        return None
예제 #9
0
    def OnElementChoiceChoice(self, event):
        pos = self.elementChoice.GetSelection()
        if pos == wx.NOT_FOUND:
            return
        self.elementType = self.elementChoice.GetString(pos)
        if self.elementType != "Simple" and self.elementType != "SimpleSequence":
            errorMsg(self,'This element type is not supported yet!')
            self.elementType = "Simple"
            self.elementChoice.SetSelection(0)

        self.refreshDisplay()
        event.Skip()
예제 #10
0
def getInterface(repid, name):
    try:
        repid = repid.strip('IDL:')
        repid = repid[:repid.rfind(':')]
        tmpNS = repid[:repid.find('/')]
        tmpName = repid[repid.find('/') + 1:]
        newInt = CC.Interface(tmpName, nameSpace=tmpNS)
        return newInt

    except:
        errorMsg(parent,
                 "Can't read the Interface information for port: " + name)
        return None
예제 #11
0
 def OnOkBtnButton(self, event):
     tempLn = self.portNameBox.GetLineText(0)
                         
     if tempLn == '':
         errorMsg(self,'Please enter a port name!')
         return
         
     sn = self.intBox.GetSelection()
     if sn == self.intBox.GetRootItem() or self.intBox.GetItemParent(sn) == self.intBox.GetRootItem():
         errorMsg(self,'Please select an Interface!')
         return   
         
     tempType = self.typeChoice.GetSelection()
     if tempType == wx.NOT_FOUND:
         errorMsg(self,'Please select a Type!')
         return 
     if tempType == 0:
         typeS = "Uses"
     else:
         typeS = "Provides"
         
     for p in self.active_comp.ports:
         if tempLn == p.name and typeS == p.type:
             errorMsg(self,"Port name <" + tempLn + "> already in use as a '"+typeS+"' port.")
             return
     
     selectedInt = self.intBox.GetPyData(sn)
     
     tempP = ComponentClass.Port(tempLn,copy.deepcopy(selectedInt),typeS)
     self.active_comp.ports.append(tempP)
     self.Close()
     event.Skip()
예제 #12
0
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"))
예제 #13
0
    def OnOkBtnButton(self, event):
        tempLn = self.portNameBox.GetLineText(0)

        if tempLn == '':
            errorMsg(self, 'Please enter a port name!')
            return

        sn = self.intBox.GetSelection()
        if sn == self.intBox.GetRootItem() or self.intBox.GetItemParent(
                sn) == self.intBox.GetRootItem():
            errorMsg(self, 'Please select an Interface!')
            return

        tempType = self.typeChoice.GetSelection()
        if tempType == wx.NOT_FOUND:
            errorMsg(self, 'Please select a Type!')
            return
        if tempType == 0:
            typeS = "Uses"
        else:
            typeS = "Provides"

        for p in self.active_comp.ports:
            if tempLn == p.name and typeS == p.type:
                errorMsg(
                    self, "Port name <" + tempLn + "> already in use as a '" +
                    typeS + "' port.")
                return

        selectedInt = self.intBox.GetPyData(sn)

        tempP = ComponentClass.Port(tempLn, copy.deepcopy(selectedInt), typeS)
        self.active_comp.ports.append(tempP)
        self.Close()
        event.Skip()
예제 #14
0
 def OnOkButton(self, event):
     pos = self.nodeChoice.GetSelection()
     if pos == wx.NOT_FOUND:
         errorMsg(self,"You must select a deployment node.")
         return 
     tempLn = self.nameBox.GetLineText(0)
     if tempLn == '':
         errorMsg(self,'Invalid instance name.')
         return
     
     self.DeploymentNode = self.nodeChoice.GetClientData(pos)
     self.InstanceName = tempLn
     
     event.Skip()
예제 #15
0
    def OnOkButton(self, event):
        pos = self.nodeChoice.GetSelection()
        if pos == wx.NOT_FOUND:
            errorMsg(self, "You must select a deployment node.")
            return
        tempLn = self.nameBox.GetLineText(0)
        if tempLn == '':
            errorMsg(self, 'Invalid instance name.')
            return

        self.DeploymentNode = self.nodeChoice.GetClientData(pos)
        self.InstanceName = tempLn

        event.Skip()
예제 #16
0
    def OnCloseBtnButton(self, event):
        if self.parent == None:
            self.Show(False)
            self.Close()
            return
        tempLn = self.compNameBox.GetLineText(0)
        if tempLn == '':
            errorMsg(self,'Please enter a component name first')
            return

        for c in self.parent.active_wave.components:
            if c != self.active_comp and c.name == tempLn:
                errorMsg(self,'Invalid name - a component by that name already exists')
                return

        #Component names with spaces do not work
        if tempLn.find(' ') != -1:
            errorMsg(self,'Resource names can not have spaces in them.\nReplacing spaces with "_".')
            tempLn = tempLn.replace(' ','_')


        self.active_comp.changeName(tempLn)

        self.MakeModal(False)
        self.parent.displayComps()
        self.parent.displayNodes()
        self.Show(False)
        event.Skip()
예제 #17
0
    def OnCloseBtnButton(self, event):
        if self.parent == None:
            self.Show(False)
            self.Close()
            return
        tempLn = self.compNameBox.GetLineText(0)
        if tempLn == '':
            errorMsg(self, 'Please enter a component name first')
            return

        for c in self.parent.active_wave.components:
            if c != self.active_comp and c.name == tempLn:
                errorMsg(
                    self,
                    'Invalid name - a component by that name already exists')
                return

        #Component names with spaces do not work
        if tempLn.find(' ') != -1:
            errorMsg(
                self,
                'Resource names can not have spaces in them.\nReplacing spaces with "_".'
            )
            tempLn = tempLn.replace(' ', '_')

        self.active_comp.changeName(tempLn)

        self.MakeModal(False)
        self.parent.displayComps()
        self.parent.displayNodes()
        self.Show(False)
        event.Skip()
예제 #18
0
 def checkDstBox(self):
     dstSel = self.dstBox.GetSelection()
     
     if dstSel == self.dstBox.GetRootItem():
         # nothing is selected in the source box
         errorMsg(self,"Please select a destination Port")
         return False
     elif self.dstBox.GetItemParent(dstSel) == self.dstBox.GetRootItem():
         # a main level component was selected for the destination
         errorMsg(self,"Invalid destination selection.")
         return False
     else:
         tmpP = self.dstBox.GetPyData(dstSel)
         if isinstance(tmpP,ComponentClass.Port):
             return True
         else:
             errorMsg(self,"Invalid destination selection.")
             return False
예제 #19
0
    def OnMenuComponentGenerateMenu(self, event):

        #select which template to use
        if self.template == "basic_ports":
            import WaveDev.wavedev.generate.templates.basic_ports.genStructure as genStruct
        elif self.template == "custom_ports":
            import WaveDev.wavedev.generate.templates.custom_ports.genStructure as genStruct
        elif self.template == "py_comp":
            import WaveDev.wavedev.generate.templates.py_comp.genStructure as genStruct
        else:
            errorMsg(
                self.parent, self.template +
                " is not supported in OnMenuComponentGenerateMenu within the componentFrame"
            )
            return

        tempLn = self.compNameBox.GetLineText(0)
        if tempLn == '':
            errorMsg(self, 'Please enter a component name first')
            return

        self.active_comp.name = tempLn

        tempDescr = self.compDescrBox.GetLineText(0)
        if tempDescr == '':
            errorMsg(self, 'Please enter a component description first')
            return

        self.active_comp.description = tempDescr

        dlg = wx.DirDialog(self)
        dlg.SetMessage("Please select the place to generate the code")
        dlg.SetPath(os.path.expanduser('~'))
        try:
            if dlg.ShowModal() == wx.ID_OK:
                savepath = dlg.GetPath()
            else:
                return
        finally:
            dlg.Destroy()

        if savepath[len(savepath) - 1] != '/':
            savepath = savepath + '/'

        self.path = savepath
        self.path = self.path + self.active_comp.name

        if os.path.exists(self.path) == False:
            os.mkdir(self.path)

        #if os.path.exists(self.path + '/aclocal.d') == False:
        #    os.mkdir(self.path + '/aclocal.d')
        #for f in os.listdir('generate/aclocal.d/'):
        #    if not os.path.isdir(f):
        #        shutil.copy('generate/aclocal.d/' + f,self.path + '/aclocal.d')
        shutil.copy(self.wavedevPath + '/generate/reconf', self.path)
        chmod(self.path + '/reconf', 0755)

        if self.licensefile != "":
            shutil.copy(self.licensefile, self.path + '/LICENSE')

        if self.active_comp.timing:
            found_timing = False
            for p in self.active_comp.ports:
                if p.interface.name == 'timingStatus':
                    found_timing = True
            if not found_timing:
                self.active_comp.ports.append(self.timing_port)

        gen = genStruct.genAll(savepath, self.wavedevPath, None)
        gen.writeCompMakefile(self.active_comp, self.path)
        gen.writeConfAC(self.path, self.active_comp.name, self.active_comp.ace,
                        False, self.installPath)
        gen.genCompFiles(self.active_comp)

        component_gen.gen_scd(self.active_comp, savepath, self.wavedevPath)
        component_gen.gen_spd(self.active_comp, savepath, self.wavedevPath)
        component_gen.gen_prf(self.active_comp, savepath, self.wavedevPath)
예제 #20
0
    def importStandardIdl(self):
        '''Imports IDL from cf, standardinterfaces, and custominterfaces'''
        #temporarily change self.parent to self so this works
        #normally this function looks at the MainFrame - but not in standalone
        changedParent = False
        if self.parent == None:
            self.parent = self
            changedParent = True

        if os.path.isfile(self.parent.ossieIncludePath + "cf.idl"):
            cfIdl_file = self.parent.ossieIncludePath + "cf.idl"
        else:
            tmpstr = "Cannot find cf.idl in the OSSIE installation location:\n"
            tmpstr += self.parent.ossieIncludePath
            errorMsg(self.parent,tmpstr)

        # for each file in the standardinterfaces directory, import all available
        # interfaces (skip standardIdl files)

        standard_idl_list = os.listdir(self.parent.stdIdlPath)

        try:
            custom_idl_list = os.listdir(self.parent.customIdlPath)
        except OSError: # this will occur if customIdlPath was never set
                        # as a result of customInterfaces not being found
            custom_idl_list = []

        if len(standard_idl_list) <= 0:
            tmpstr = "Can't find any files in: " + self.parent.stdIdlPath
            errorMsg(self.parent,tmpstr)
            return

        # Add the CF interfaces first - in case another file includes them, we
        # don't want them asscociated with anything other than cf.idl
        self.Available_Ints.extend(importIDL.getInterfaces(cfIdl_file))

        # import standard interfaces
        for standard_idl_file in standard_idl_list:
            # standardIdl files are not included because they are aggregates of the other interfaces
            if 'standardIdl' in standard_idl_file:
                continue

            if string.lower(os.path.splitext(standard_idl_file)[1]) != ".idl":
                # ignore non idl files
                continue

            tempInts = importIDL.getInterfaces(self.parent.stdIdlPath+standard_idl_file)
            for t in tempInts:
                if t not in self.Available_Ints:
                    self.Available_Ints.append(t)

        # import custom interfaces
        for custom_idl_file in custom_idl_list:
            # ignore aggregate 'customInterfaces.idl' file
            if 'customInterfaces' in custom_idl_file:
                continue

            if string.lower(os.path.splitext(custom_idl_file)[1]) != ".idl":
                # ignore non idl files
                continue

            tempInts = importIDL.getInterfaces(self.parent.customIdlPath+custom_idl_file)
            for t in tempInts:
                if t not in self.Available_Ints:
                   # print "Testing: " + t.name + " " + idl_file + " " + str(len(self.Available_Ints))
                    self.Available_Ints.append(t)
                    if t.name == 'timingStatus':
                        self.timing_interface = CC.Interface(t.name, t.nameSpace, t.operations, t.filename, t.fullpath)
                        self.timing_port = CC.Port('send_timing_report', self.timing_interface, "Uses", "data")
#                    print "CF.py: " + t.name + "  " + str(len(t.operations))

        if changedParent == True:
            self.parent = None
예제 #21
0
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
예제 #22
0
    def importStandardIdl(self):
        '''Imports IDL from cf, standardinterfaces, and custominterfaces'''
        #temporarily change self.parent to self so this works
        #normally this function looks at the MainFrame - but not in standalone
        changedParent = False
        if self.parent == None:
            self.parent = self
            changedParent = True

        if os.path.isfile(self.parent.ossieIncludePath + "cf.idl"):
            cfIdl_file = self.parent.ossieIncludePath + "cf.idl"
        else:
            tmpstr = "Cannot find cf.idl in the OSSIE installation location:\n"
            tmpstr += self.parent.ossieIncludePath
            errorMsg(self.parent, tmpstr)

        # for each file in the standardinterfaces directory, import all available
        # interfaces (skip standardIdl files)

        standard_idl_list = os.listdir(self.parent.stdIdlPath)

        try:
            custom_idl_list = os.listdir(self.parent.customIdlPath)
        except OSError:  # this will occur if customIdlPath was never set
            # as a result of customInterfaces not being found
            custom_idl_list = []

        if len(standard_idl_list) <= 0:
            tmpstr = "Can't find any files in: " + self.parent.stdIdlPath
            errorMsg(self.parent, tmpstr)
            return

        # Add the CF interfaces first - in case another file includes them, we
        # don't want them asscociated with anything other than cf.idl
        self.Available_Ints.extend(importIDL.getInterfaces(cfIdl_file))

        # import standard interfaces
        for standard_idl_file in standard_idl_list:
            # standardIdl files are not included because they are aggregates of the other interfaces
            if 'standardIdl' in standard_idl_file:
                continue

            if string.lower(os.path.splitext(standard_idl_file)[1]) != ".idl":
                # ignore non idl files
                continue

            tempInts = importIDL.getInterfaces(self.parent.stdIdlPath +
                                               standard_idl_file)
            for t in tempInts:
                if t not in self.Available_Ints:
                    self.Available_Ints.append(t)

        # import custom interfaces
        for custom_idl_file in custom_idl_list:
            # ignore aggregate 'customInterfaces.idl' file
            if 'customInterfaces' in custom_idl_file:
                continue

            if string.lower(os.path.splitext(custom_idl_file)[1]) != ".idl":
                # ignore non idl files
                continue

            tempInts = importIDL.getInterfaces(self.parent.customIdlPath +
                                               custom_idl_file)
            for t in tempInts:
                if t not in self.Available_Ints:
                    # print "Testing: " + t.name + " " + idl_file + " " + str(len(self.Available_Ints))
                    self.Available_Ints.append(t)
                    if t.name == 'timingStatus':
                        self.timing_interface = CC.Interface(
                            t.name, t.nameSpace, t.operations, t.filename,
                            t.fullpath)
                        self.timing_port = CC.Port('send_timing_report',
                                                   self.timing_interface,
                                                   "Uses", "data")
#                    print "CF.py: " + t.name + "  " + str(len(t.operations))

        if changedParent == True:
            self.parent = None
예제 #23
0
    def OnAddPropButton(self, event):
        # Check for the name
        tmpName = self.nameBox.GetLineText(0)
        if tmpName == '':
            errorMsg(self,"Please enter a property name first!")
            return

        # Check for the id
        tmpid = self.idBox.GetLineText(0)
        if tmpid == '':
            errorMsg(self,"Please enter a property id first!")
            return

        # Check for the mode
        pos = self.modeChoice.GetSelection()
        if pos == wx.NOT_FOUND:
            errorMsg(self,"Please select a property mode first!")
            return
        tmpMode = self.modeChoice.GetString(pos)

        # Get the description
        tmpDes = self.description.GetValue()

        # Check for the type ex: bool, char, short, etc.
        pos = self.typeChoice.GetSelection()
        if pos == wx.NOT_FOUND:
            errorMsg(self,"Please select a type first!")
            return
        tmpType = self.typeChoice.GetString(pos)

        if self.elementType == "Simple":
            # instantiate the property object
            newProp = CC.SimpleProperty(tmpName,tmpMode,tmpType,tmpDes)

            # store the default value and the value
            if self.valueList.GetItemCount() == 0:
                errorMsg(self,"Please enter a value first!")
                return

            v = self.valueList.GetItem(0,0)
            dv = self.valueList.GetItem(0,1)
            newProp.value = v.GetText()
            newProp.defaultValue = dv.GetText()

        if self.elementType == "SimpleSequence":
            # store the default value and the value
            if self.valueList.GetItemCount() == 0:
                    errorMsg(self,"Please enter a value first!")
                    return

            newProp = CC.SimpleSequenceProperty(tmpName,tmpMode,tmpType,tmpDes)


            newProp.values = []
            newProp.defaultValues = []

            for x in range(self.valueList.GetItemCount()):
                v = self.valueList.GetItem(x,0)
                dv = self.valueList.GetItem(x,1)

                newProp.values.append(v.GetText())
                newProp.defaultValues.append(dv.GetText())

        # store the enum if any
        newProp.enum = self.enumBox.GetLineText(0)

        # Check for the kind ex: allocation, configure, test, etc.
        pos = self.kindChoice.GetSelection()
        if pos == wx.NOT_FOUND:
            errorMsg(self,"Please select a kind first!")
            return
        newProp.kind = self.kindChoice.GetString(pos)

        # Check and store the range
        tmpMin = self.minBox.GetLineText(0)
        tmpMax = self.maxBox.GetLineText(0)

        if tmpMin == 'min' or tmpMin == '':
            tmpMin = -1

        if tmpMax == 'max' or tmpMax == '':
            tmpMax = -1

        newProp.range = (tmpMin,tmpMax)

        # Check and store the action
        pos = self.actionChoice.GetSelection()
        if pos == wx.NOT_FOUND:
            if newProp.kind == "allocation":
                errorMsg(self,"Please select an action first!")
                return
        else:
            newProp.action = self.actionChoice.GetString(pos)

        self.parent.active_comp.properties.append(newProp)
        self.Close()

        event.Skip()
예제 #24
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")

    #
    # Build the main component or device from the SCD file
    #
    doc_scd = xml.dom.minidom.parse(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)

    # 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)
    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
예제 #25
0
    def OnOkButton(self, event):
        if self.editable:
            # Check for the name
            tmpName = self.nameBox.GetLineText(0)
            if tmpName == '':
                errorMsg(self,"Please enter a property name first!")
                return
            self.active_prop.name = tmpName

            # Check for the id
            tmpid = self.idBox.GetLineText(0)
            if tmpid == '':
                errorMsg(self,"Please enter a property id first!")
                return
            self.active_prop.id = tmpid

            # Check for the mode
            pos = self.modeChoice.GetSelection()
            if pos == wx.NOT_FOUND:
                errorMsg(self,"Please select a property mode first!")
                return
            tmpMode = self.modeChoice.GetString(pos)
            self.active_prop.mode = tmpMode

            # Get the description
            tmpDes = self.description.GetValue()
            self.active_prop.description = tmpDes

            # Check for the type ex: bool, char, short, etc.
            pos = self.typeChoice.GetSelection()
            if pos == wx.NOT_FOUND:
                errorMsg(self,"Please select a type first!")
                return
            tmpType = self.typeChoice.GetString(pos)
            self.active_prop.type = tmpType

            if self.elementType == "Simple":
                # store the default value and the value
                if self.valueList.GetItemCount() == 0:
                    errorMsg(self,"Please enter a value first!")
                    return

                v = self.valueList.GetItem(0,0)
                dv = self.valueList.GetItem(0,1)
                self.active_prop.value = v.GetText()
                self.active_prop.defaultValue = dv.GetText()

            if self.elementType == "SimpleSequence":
                # store the default value and the value
                if self.valueList.GetItemCount() == 0:
                    errorMsg(self,"Please enter a value first!")
                    return

                self.active_prop.values = []
                self.active_prop.defaultValues = []

                for x in range(self.valueList.GetItemCount()):
                    v = self.valueList.GetItem(x,0)
                    dv = self.valueList.GetItem(x,1)

                    self.active_prop.values.append(v.GetText())
                    self.active_prop.defaultValues.append(dv.GetText())

            # store the enum if any
            self.active_prop.enum = self.enumBox.GetLineText(0)

            # Check for the kind ex: allocation, configure, test, etc.
            pos = self.kindChoice.GetSelection()
            if pos == wx.NOT_FOUND:
                errorMsg(self,"Please select a kind first!")
                return
            self.active_prop.kind = self.kindChoice.GetString(pos)

            # Check and store the range
            tmpMin = self.minBox.GetLineText(0)
            tmpMax = self.maxBox.GetLineText(0)

            if tmpMin == 'min' or tmpMin == '':
                tmpMin = -1

            if tmpMax == 'max' or tmpMax == '':
                tmpMax = -1

            self.active_prop.range = (tmpMin,tmpMax)

            # Check and store the action
            pos = self.actionChoice.GetSelection()
            if pos == wx.NOT_FOUND:
                if self.active_prop.kind == "allocation":
                    errorMsg(self,"Please select an action first!")
                    return
            else:
                self.active_prop.action = self.actionChoice.GetString(pos)

        else:
            if self.elementType == "Simple":
                # store the default value and the value
                if self.valueList.GetItemCount() == 0:
                    errorMsg(self,"Please enter a value first!")
                    return

                v = self.valueList.GetItem(0,0)
                dv = self.valueList.GetItem(0,1)
                self.active_prop.value = v.GetText()
                self.active_prop.defaultValue = dv.GetText()

            if self.elementType == "SimpleSequence":
                # store the default value and the value
                if self.valueList.GetItemCount() == 0:
                    errorMsg(self,"Please enter a value first!")
                    return

                self.active_prop.values = []
                self.active_prop.defaultValues = []

                for x in range(self.valueList.GetItemCount()):
                    v = self.valueList.GetItem(x,0)
                    dv = self.valueList.GetItem(x,1)
                    self.active_prop.values.append(v.GetText())
                    self.active_prop.defaultValues.append(dv.GetText())

        self.Close()
예제 #26
0
def getNode(inpath, Nname, parent):

    scdPath = inpath + "DeviceManager" + ".scd.xml"
    spdPath = inpath + "DeviceManager" + ".spd.xml"
    prfPath = inpath + "DeviceManager" + ".prf.xml"
    dcdPath = inpath + "DeviceManager" + ".dcd.xml"

    # import the node description from the node's .spd.xml file
    doc_node_spd = xml.dom.minidom.parse(spdPath)
    softpkgNode = doc_node_spd.getElementsByTagName("softpkg")[0]
    Ndescription = ''
    for n in softpkgNode.childNodes:
        if n.nodeName == "description":
            nDescriptionNode = doc_node_spd.getElementsByTagName("description")
            try:
                Ndescription = nDescriptionNode[0].firstChild.data
            except:
                pass
            break

    newNode = CC.Node(name=Nname,
                      path=inpath,
                      description=Ndescription,
                      generate=False)

    #
    # Build the node from the DCD
    #
    doc_dcd = xml.dom.minidom.parse(dcdPath)
    partitioningNodeList = doc_dcd.getElementsByTagName('partitioning')
    if len(partitioningNodeList) != 1:
        errorMsg(parent, "Invalid file: " + dcdPath + " (partitioning)")
        return None

    try:
        deviceconfigurationNode = doc_dcd.getElementsByTagName(
            'deviceconfiguration')[0]
    except:
        errorMsg(parent, "Invalid file: " + dcdPath + " (deviceconfiguration)")
        return None
    newNode.id = deviceconfigurationNode.getAttribute("id")

    #
    componentplacementNodeList = doc_dcd.getElementsByTagName(
        "componentplacement")
    for componentplacementNode in componentplacementNodeList:
        newComp = CC.Component(type='executabledevice')
        newComp.name = componentplacementNode.getElementsByTagName(
            "usagename")[0].firstChild.data

        # componentinstantiation
        # strip off the DCE: part of the id becuase it will get added back in later
        tmpUUID = componentplacementNode.getElementsByTagName(
            "componentinstantiation")[0].getAttribute("id")
        newComp.uuid = str(tmpUUID).strip("DCE:")

        # componentfileref
        tmpNode = componentplacementNode.getElementsByTagName(
            "componentfileref")
        newComp.file_uuid = str(tmpNode[0].getAttribute("refid")).strip(
            "DCE:")  # is this strip necessary?  -JDG

        local_SPD = ""
        componentfileNodeList = doc_dcd.getElementsByTagName("componentfile")
        for componentfileNode in componentfileNodeList:
            if componentfileNode.getAttribute("id") == newComp.file_uuid:
                localfileNodeList = componentfileNode.getElementsByTagName(
                    "localfile")
                local_SPD = localfileNodeList[0].getAttribute("name")
                del localfileNodeList
                break
        pathSPD = parent.installPath + "dev/" + local_SPD

        if not os.path.exists(pathSPD):
            errorMsg(
                parent, "Warning! Could not find " + pathSPD +
                ".\nCannot import node " + Nname)
            return None

        doc_spd = xml.dom.minidom.parse(pathSPD)
        softpkgNode = doc_spd.getElementsByTagName("softpkg")[0]
        newComp.baseName = softpkgNode.getAttribute("name")
        #pathSCD = "/sdr/sca/xml/"+newComp.baseName+"/"+doc_spd.softpkg.descriptor.localfile.name
        localfileNode = softpkgNode.getElementsByTagName("localfile")[0]
        pathSCD = parent.installPath + "dev" + localfileNode.getAttribute(
            "name")

        doc_scd = xml.dom.minidom.parse(pathSCD)

        # 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:
                errorMsg(parent, "No repid found in ProvidesPort")
                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:
                errorMsg(parent, "No repid fond in UsesPort")
                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)
        newComp.xmlName = os.path.splitext(
            os.path.splitext(os.path.basename(pathSCD))[0])[0]

        newNode.Devices.append(newComp)

        #
        # Import the properties from the PRF file
        #
        # If there are no properties, just return the component as is
        #if pathPRF == None:
        #    return newComp
        #
        #doc_prf = amara.parse(stripDoctype(prfPath))
        ##doc_prf = binderytools.bind_file(prfPath)
        #if not hasattr(doc_prf,'properties'):
        #    errorMsg(parent,"Invalid file: " + prfPath)
        #    return None
        #
        #if hasattr(doc_prf.properties,"simple"):
        #    for s in doc_prf.properties.simple:
        #        p = getSimpleProperty(s)
        #        if p == None:
        #            #errorMsg(parent,"Invalid file: " + prfPath)
        #            continue
        #        newComp.properties.append(p)
        #
        #if hasattr(doc_prf.properties,"simplesequence"):
        #    for s in doc_prf.properties.simplesequence:
        #        p = getSimpleSequenceProperty(s)
        #        if p == None:
        #            #errorMsg(parent,"Invalid file: " + prfPath)
        #            continue
        #        newComp.properties.append(p)

    return newNode
예제 #27
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")
    
    #
    # Build the main component or device from the SCD file    
    #
    doc_scd = xml.dom.minidom.parse(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)

    # 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)
    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
예제 #28
0
    def OnMenuComponentGenerateMenu(self, event):

        #select which template to use
        if self.template == "basic_ports":
            import WaveDev.wavedev.generate.templates.basic_ports.genStructure as genStruct
        elif self.template == "custom_ports":
            import WaveDev.wavedev.generate.templates.custom_ports.genStructure as genStruct
        elif self.template == "py_comp":
            import WaveDev.wavedev.generate.templates.py_comp.genStructure as genStruct
        else:
            errorMsg(self.parent, self.template + " is not supported in OnMenuComponentGenerateMenu within the componentFrame")
            return

        tempLn = self.compNameBox.GetLineText(0)
        if tempLn == '':
            errorMsg(self,'Please enter a component name first')
            return

        self.active_comp.name = tempLn

        tempDescr = self.compDescrBox.GetLineText(0)
        if tempDescr == '':
            errorMsg(self,'Please enter a component description first')
            return

        self.active_comp.description = tempDescr

        dlg = wx.DirDialog(self)
        dlg.SetMessage("Please select the place to generate the code")
        dlg.SetPath(os.path.expanduser('~'))
        try:
            if dlg.ShowModal() == wx.ID_OK:
                savepath = dlg.GetPath()
            else:
                return
        finally:
            dlg.Destroy()

        if savepath[len(savepath)-1] != '/':
            savepath = savepath + '/'

        self.path = savepath
        self.path = self.path + self.active_comp.name

        if os.path.exists(self.path) == False:
                os.mkdir(self.path)

        #if os.path.exists(self.path + '/aclocal.d') == False:
        #    os.mkdir(self.path + '/aclocal.d')
        #for f in os.listdir('generate/aclocal.d/'):
        #    if not os.path.isdir(f):
        #        shutil.copy('generate/aclocal.d/' + f,self.path + '/aclocal.d')
        shutil.copy(self.wavedevPath + '/generate/reconf',self.path)
        chmod(self.path + '/reconf', 0755)

        if self.licensefile != "":
                    shutil.copy(self.licensefile,self.path + '/LICENSE')

        if self.active_comp.timing:
                found_timing = False
                for p in self.active_comp.ports:
                        if p.interface.name == 'timingStatus':
                                found_timing = True
                if not found_timing:
                        self.active_comp.ports.append(self.timing_port)

        gen = genStruct.genAll(savepath, self.wavedevPath, None)
        gen.writeCompMakefile(self.active_comp,self.path)
        gen.writeConfAC(self.path, self.active_comp.name, self.active_comp.ace, False, self.installPath)
        gen.genCompFiles(self.active_comp)

        component_gen.gen_scd(self.active_comp, savepath, self.wavedevPath)
        component_gen.gen_spd(self.active_comp, savepath, self.wavedevPath)
        component_gen.gen_prf(self.active_comp, savepath, self.wavedevPath)
예제 #29
0
def getNode(inpath,Nname,parent):

    scdPath = inpath + "DeviceManager" + ".scd.xml"
    spdPath = inpath + "DeviceManager" + ".spd.xml"
    prfPath = inpath + "DeviceManager" + ".prf.xml"
    dcdPath = inpath + "DeviceManager" + ".dcd.xml"

    # import the node description from the node's .spd.xml file
    doc_node_spd = xml.dom.minidom.parse(spdPath)
    softpkgNode = doc_node_spd.getElementsByTagName("softpkg")[0]
    Ndescription = ''
    for n in softpkgNode.childNodes:
        if n.nodeName == "description":
            nDescriptionNode = doc_node_spd.getElementsByTagName("description")
            try:
                Ndescription = nDescriptionNode[0].firstChild.data
            except:
                pass
            break

    newNode = CC.Node(name=Nname, path=inpath, description=Ndescription, generate=False)

    #
    # Build the node from the DCD
    #
    doc_dcd = xml.dom.minidom.parse(dcdPath)
    partitioningNodeList = doc_dcd.getElementsByTagName('partitioning')
    if len(partitioningNodeList) != 1:
        errorMsg(parent,"Invalid file: " + dcdPath + " (partitioning)")
        return None

    try:
        deviceconfigurationNode = doc_dcd.getElementsByTagName('deviceconfiguration')[0]
    except:
        errorMsg(parent,"Invalid file: " + dcdPath + " (deviceconfiguration)")
        return None
    newNode.id = deviceconfigurationNode.getAttribute("id")

    #
    componentplacementNodeList = doc_dcd.getElementsByTagName("componentplacement")
    for componentplacementNode in componentplacementNodeList:
        newComp = CC.Component(type='executabledevice')
        newComp.name = componentplacementNode.getElementsByTagName("usagename")[0].firstChild.data

        # componentinstantiation
        # strip off the DCE: part of the id becuase it will get added back in later
        tmpUUID = componentplacementNode.getElementsByTagName("componentinstantiation")[0].getAttribute("id")
        newComp.uuid = str( tmpUUID ).strip("DCE:")

        # componentfileref
        tmpNode = componentplacementNode.getElementsByTagName("componentfileref")
        newComp.file_uuid = str( tmpNode[0].getAttribute("refid") ).strip("DCE:") # is this strip necessary?  -JDG

        local_SPD = ""
        componentfileNodeList = doc_dcd.getElementsByTagName("componentfile")
        for componentfileNode in componentfileNodeList:
            if componentfileNode.getAttribute("id") == newComp.file_uuid:
                localfileNodeList = componentfileNode.getElementsByTagName("localfile")
                local_SPD = localfileNodeList[0].getAttribute("name")
                del localfileNodeList
                break
        pathSPD = parent.installPath + "dev/" + local_SPD

        if not os.path.exists(pathSPD):
            errorMsg(parent, "Warning! Could not find " + pathSPD + ".\nCannot import node " + Nname)
            return None

        doc_spd = xml.dom.minidom.parse(pathSPD)
        softpkgNode = doc_spd.getElementsByTagName("softpkg")[0]
        newComp.baseName = softpkgNode.getAttribute("name")
        #pathSCD = "/sdr/sca/xml/"+newComp.baseName+"/"+doc_spd.softpkg.descriptor.localfile.name
        localfileNode = softpkgNode.getElementsByTagName("localfile")[0]
        pathSCD = parent.installPath + "dev"  + localfileNode.getAttribute("name")

        doc_scd = xml.dom.minidom.parse(pathSCD)

        # 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:
                errorMsg(parent, "No repid found in ProvidesPort")
                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:
                errorMsg(parent, "No repid fond in UsesPort")
                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)
        newComp.xmlName =  os.path.splitext(os.path.splitext(os.path.basename(pathSCD))[0])[0]

        newNode.Devices.append(newComp)

        #
        # Import the properties from the PRF file
        #
        # If there are no properties, just return the component as is
        #if pathPRF == None:
        #    return newComp
        #
        #doc_prf = amara.parse(stripDoctype(prfPath))
        ##doc_prf = binderytools.bind_file(prfPath)
        #if not hasattr(doc_prf,'properties'):
        #    errorMsg(parent,"Invalid file: " + prfPath)
        #    return None
        #
        #if hasattr(doc_prf.properties,"simple"):
        #    for s in doc_prf.properties.simple:
        #        p = getSimpleProperty(s)
        #        if p == None:
        #            #errorMsg(parent,"Invalid file: " + prfPath)
        #            continue
        #        newComp.properties.append(p)
        #
        #if hasattr(doc_prf.properties,"simplesequence"):
        #    for s in doc_prf.properties.simplesequence:
        #        p = getSimpleSequenceProperty(s)
        #        if p == None:
        #            #errorMsg(parent,"Invalid file: " + prfPath)
        #            continue
        #        newComp.properties.append(p)

    return newNode