Changeset 7435

Show
Ignore:
Timestamp:
05/02/08 22:06:43 (5 years ago)
Author:
stedwar2
Message:

Fixes from Eclipse integration.

Location:
ossiedev/branches/jsnyder/ComponentProject/WaveDev/wavedev
Files:
1 added
7 modified

Legend:

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

    r5886 r7435  
    1717## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
    1818 
    19 import commands 
    20 # UUID Generator 
    21 def uuidgen(): 
    22    return commands.getoutput('uuidgen -t') 
     19from uuidgen import uuidgen 
    2320 
    2421# Component Class 
     
    4239    self.properties = [] 
    4340    self.description = description 
    44    
     41 
    4542  def __getitem__(self,i): 
    4643      return self.connections[i] 
    47    
     44 
    4845  def setUUID(self): 
    4946      self.uuid = uuidgen() 
    50        
     47 
    5148  def changeName(self,newname): 
    5249      self.name = newname 
     
    6865    if in_dev != None: 
    6966      self.Devices.append(in_comp) 
    70      
     67 
    7168 
    7269class Port: 
     
    8683    def __init__(self, LP, RP, RC): 
    8784        self.localPort = LP 
    88         self.remotePort = RP  
     85        self.remotePort = RP 
    8986        self.remoteComp = RC 
    90          
     87 
    9188class Interface: 
    9289    def __init__(self,name,nameSpace="standardInterfaces",operations=[],filename="",fullpath=""): 
     
    9693        self.filename = filename    #does not include the '.idl' suffix 
    9794        self.fullpath = fullpath 
    98          
     95 
    9996    def __eq__(self,other): 
    100         if isinstance(other, Interface):         
     97        if isinstance(other, Interface): 
    10198            return (other.nameSpace == self.nameSpace ) and (other.name == self.name) 
    10299        else: 
    103100            return False 
    104          
     101 
    105102    def __ne__(self,other): 
    106103        if isinstance(other, Interface): 
     
    109106            return True 
    110107 
    111          
     108 
    112109class Operation: 
    113110    def __init__(self,name,returnType,params=[]): 
     
    116113        self.cxxReturnType = '' 
    117114        self.params = [] 
    118          
     115 
    119116class Param: 
    120117    def __init__(self,name,dataType='',direction=''): 
    121         """  
     118        """ 
    122119        Exampleinterface complexShort { 
    123120            void pushPacket(in PortTypes::ShortSequence I, in PortTypes::ShortSequence Q); 
     
    129126        self.cxxType = "" 
    130127        self.direction = direction  # Flow of data: 'in' 
    131          
     128 
    132129class Property: 
    133130    def __init__(self,elementType,name,mode,description=''): 
     
    136133        self.mode = mode 
    137134        self.id = 'DCE:' + uuidgen() 
    138          
     135 
    139136class SimpleProperty(Property): 
    140137    def __init__(self,name,mode,type,description='',value=None,defaultValue=None,units=None, 
     
    142139        Property.__init__(self,"Simple",name,mode,description) 
    143140        self.type = type 
    144         self.description = description    
     141        self.description = description 
    145142        self.value = value 
    146143        self.defaultValue = defaultValue 
     
    162159        self.kind = kind 
    163160        self.action = action 
    164      
    165      
     161 
     162 
  • ossiedev/branches/jsnyder/ComponentProject/WaveDev/wavedev/MainFrame.py

    r7156 r7435  
    3939    return Frame1(parent) 
    4040 
    41 [wxID_FRAME1, wxID_FRAME1COMPBOX, wxID_FRAME1NODEBOX, wxID_FRAME1RESOURCEBOX,  
    42  wxID_FRAME1SASHWINDOW1, wxID_FRAME1SASHWINDOW2, wxID_FRAME1SASHWINDOW3,  
    43  wxID_FRAME1SASHWINDOW4, wxID_FRAME1SPLITTERWINDOW1,  
    44  wxID_FRAME1SPLITTERWINDOW2, wxID_FRAME1STATICTEXT1, wxID_FRAME1STATICTEXT2,  
     41[wxID_FRAME1, wxID_FRAME1COMPBOX, wxID_FRAME1NODEBOX, wxID_FRAME1RESOURCEBOX, 
     42 wxID_FRAME1SASHWINDOW1, wxID_FRAME1SASHWINDOW2, wxID_FRAME1SASHWINDOW3, 
     43 wxID_FRAME1SASHWINDOW4, wxID_FRAME1SPLITTERWINDOW1, 
     44 wxID_FRAME1SPLITTERWINDOW2, wxID_FRAME1STATICTEXT1, wxID_FRAME1STATICTEXT2, 
    4545 wxID_FRAME1STATICTEXT3, wxID_FRAME1STATUSBAR1, wxID_FRAME1WAVENAMEBOX, 
    46  wxID_REFRESHRESOURCEBTN, wxID_FRAME1COMPDESCRBOX, wxID_FRAME1STATICTEXT4  
     46 wxID_REFRESHRESOURCEBTN, wxID_FRAME1COMPDESCRBOX, wxID_FRAME1STATICTEXT4 
    4747] = [wx.NewId() for _init_ctrls in range(18)] 
    4848 
    49 [wxID_FRAME1MENUFILEEXIT, wxID_FRAME1MENUFILENEW, wxID_FRAME1MENUFILEOPEN,  
    50  wxID_FRAME1MENUFILESAVE, wxID_FRAME1MENUFILESAVEPLATFORM,  
    51  wxID_FRAME1MENUFILESAVEPLATFORMAS, wxID_FRAME1MENUFILESAVEWAVEFORM,  
    52  wxID_FRAME1MENUFILESAVEWAVEFORMAS, wxID_FRAME1MENUFILESAVE_AS,  
     49[wxID_FRAME1MENUFILEEXIT, wxID_FRAME1MENUFILENEW, wxID_FRAME1MENUFILEOPEN, 
     50 wxID_FRAME1MENUFILESAVE, wxID_FRAME1MENUFILESAVEPLATFORM, 
     51 wxID_FRAME1MENUFILESAVEPLATFORMAS, wxID_FRAME1MENUFILESAVEWAVEFORM, 
     52 wxID_FRAME1MENUFILESAVEWAVEFORMAS, wxID_FRAME1MENUFILESAVE_AS, 
    5353] = [wx.NewId() for _init_coll_menuFile_Items in range(9)] 
    5454 
    55 [wxID_FRAME1COMPBOXPOPUPCONNECT, wxID_FRAME1COMPBOXPOPUPEDIT,  
    56  wxID_FRAME1COMPBOXPOPUPEXPAND, wxID_FRAME1COMPBOXPOPUPREFRESH,  
    57  wxID_FRAME1COMPBOXPOPUPREMOVE, wxID_FRAME1COMPBOXPOPUPRENAME,  
    58  wxID_FRAME1COMPBOXPOPUPSET_AC,  
     55[wxID_FRAME1COMPBOXPOPUPCONNECT, wxID_FRAME1COMPBOXPOPUPEDIT, 
     56 wxID_FRAME1COMPBOXPOPUPEXPAND, wxID_FRAME1COMPBOXPOPUPREFRESH, 
     57 wxID_FRAME1COMPBOXPOPUPREMOVE, wxID_FRAME1COMPBOXPOPUPRENAME, 
     58 wxID_FRAME1COMPBOXPOPUPSET_AC, 
    5959] = [wx.NewId() for _init_coll_compBoxPopup_Items in range(7)] 
    6060 
    61 [wxID_FRAME1MENUWAVEFORMACESUPPORT, wxID_FRAME1MENUWAVEFORMADDCOMP,  
    62  wxID_FRAME1MENUWAVEFORMCONNECTCOMP, wxID_FRAME1MENUWAVEFORMEDITCOMP,  
    63  wxID_FRAME1MENUWAVEFORMGENWAV, wxID_FRAME1MENUWAVEFORMREMOVECOMP,  
     61[wxID_FRAME1MENUWAVEFORMACESUPPORT, wxID_FRAME1MENUWAVEFORMADDCOMP, 
     62 wxID_FRAME1MENUWAVEFORMCONNECTCOMP, wxID_FRAME1MENUWAVEFORMEDITCOMP, 
     63 wxID_FRAME1MENUWAVEFORMGENWAV, wxID_FRAME1MENUWAVEFORMREMOVECOMP, 
    6464] = [wx.NewId() for _init_coll_menuWaveform_Items in range(6)] 
    6565 
    66 [wxID_FRAME1MENUHELPABOUT, wxID_FRAME1MENUHELPSAMPLEWAVEFORM,  
     66[wxID_FRAME1MENUHELPABOUT, wxID_FRAME1MENUHELPSAMPLEWAVEFORM, 
    6767] = [wx.NewId() for _init_coll_menuHelp_Items in range(2)] 
    6868 
     
    7373] = [wx.NewId() for _init_coll_resourceBoxPopup_Items in range(5)] 
    7474 
    75 [wxID_FRAME1NODEBOXPOPUPADDNODE, wxID_FRAME1NODEBOXPOPUPLOADNODE, wxID_FRAME1NODEBOXPOPUPEXPAND,  
    76  wxID_FRAME1NODEBOXPOPUPREFRESH, wxID_FRAME1NODEBOXPOPUPREMOVE, wxID_FRAME1NODEBOXPOPUPGENERATE,  
    77  wxID_FRAME1NODEBOXPOPUPCONNECT, wxID_FRAME1NODEBOXPOPUPRENAME,  
     75[wxID_FRAME1NODEBOXPOPUPADDNODE, wxID_FRAME1NODEBOXPOPUPLOADNODE, wxID_FRAME1NODEBOXPOPUPEXPAND, 
     76 wxID_FRAME1NODEBOXPOPUPREFRESH, wxID_FRAME1NODEBOXPOPUPREMOVE, wxID_FRAME1NODEBOXPOPUPGENERATE, 
     77 wxID_FRAME1NODEBOXPOPUPCONNECT, wxID_FRAME1NODEBOXPOPUPRENAME, 
    7878] = [wx.NewId() for _init_coll_nodeBoxPopup_Items in range(8)] 
    7979 
    80 [wxID_FRAME1NEWMENUNEWPLATFORM, wxID_FRAME1NEWMENUNEWPROJECT,  
    81  wxID_FRAME1NEWMENUNEWWAVEFORM,  
     80[wxID_FRAME1NEWMENUNEWPLATFORM, wxID_FRAME1NEWMENUNEWPROJECT, 
     81 wxID_FRAME1NEWMENUNEWWAVEFORM, 
    8282] = [wx.NewId() for _init_coll_newMenu_Items in range(3)] 
    8383 
     
    433433        self.nodeBox.Bind(wx.EVT_TREE_END_LABEL_EDIT, 
    434434              self.OnNodeBoxTreeEndLabelEdit, id=wxID_FRAME1NODEBOX) 
    435          
     435 
    436436        self.RefreshResourceBtn = wx.Button(id=wxID_REFRESHRESOURCEBTN, label='Refresh', 
    437437              name='RefreshResourceBtn', parent=self, pos=wx.Point(170, 40), 
     
    461461        # Constructor for MainFrame 
    462462        self._init_ctrls(parent) 
    463          
     463 
    464464        #read in the configuration information 
    465465        LoadConfiguration(self) 
    466          
     466 
    467467        #setup the environment 
    468468        self.active_comp = None 
    469         self.CompFrame = ComponentFrame.create(self)     
     469        self.CompFrame = ComponentFrame.create(self) 
    470470        self.active_wave = WaveformClass.Waveform() 
    471471        self.active_plat = PlatformClass.Platform() 
     
    476476        self.saveProjectPath = None 
    477477        self.description = None 
    478          
     478        self.wavedevPath = '.'  # Should really be computed from the install path 
     479 
    479480################################################################################ 
    480481## File/Help Menu Functionality 
     
    503504            finally: 
    504505                dlg.Destroy() 
    505              
     506 
    506507            if sflag == True: 
    507508                tempLn = self.waveNameBox.GetLineText(0) 
     
    527528                    finally: 
    528529                        dlg.Destroy() 
    529                          
     530 
    530531                else: 
    531532                    if self.saveProjectPath != None: 
     
    535536                        if self.ProjectSave(True) == False: 
    536537                            return 
    537                      
     538 
    538539        self.active_wave = WaveformClass.Waveform() 
    539         self.active_plat = PlatformClass.Platform()       
     540        self.active_plat = PlatformClass.Platform() 
    540541        self.saveProjectPath = None 
    541542        self.waveNameBox.Clear() 
    542543        self.displayComps() 
    543544        self.displayNodes() 
    544                      
    545                  
     545 
     546 
    546547        event.Skip() 
    547548 
     
    563564            finally: 
    564565                dlg.Destroy() 
    565              
     566 
    566567            if sflag == True: 
    567568                tempLn = self.waveNameBox.GetLineText(0) 
     
    587588                    finally: 
    588589                        dlg.Destroy() 
    589                          
     590 
    590591                else: 
    591592                    if self.saveWaveformPath != None: 
     
    595596                        if self.WaveformSave(True) == False: 
    596597                            return 
    597                      
     598 
    598599        self.active_wave = WaveformClass.Waveform() 
    599600        self.saveWaveformPath = None 
    600601        self.waveNameBox.Clear() 
    601602        self.displayComps() 
    602              
     603 
    603604        event.Skip() 
    604605 
     
    620621            finally: 
    621622                dlg.Destroy() 
    622              
    623             if sflag == True:                   
     623 
     624            if sflag == True: 
    624625                if self.savePlatformPath != None: 
    625626                    tmpstr = 'Do you want to overwrite the existing platform file?\n' 
     
    641642                    finally: 
    642643                        dlg.Destroy() 
    643                  
     644 
    644645                else: 
    645646                    if self.PlatformSave(True) == False: 
    646647                        return 
    647                      
     648 
    648649        self.active_plat = PlatformClass.Platform() 
    649650        self.savePlatformPath = None 
    650651        self.displayNodes() 
    651              
     652 
    652653        event.Skip() 
    653654 
     
    659660            if tmpdir == "~": 
    660661                tmpdir = "/home" 
    661          
     662 
    662663        tmpwildcard = "Project Files (*.owd)|*.owd|Waveform Designs (*.sca)|*.sca|Platform Layouts (*.plt)|*.plt" 
    663664        dlg = wx.FileDialog(self, "Choose a file", tmpdir, "", tmpwildcard, wx.OPEN) 
     
    671672        finally: 
    672673            dlg.Destroy() 
    673              
     674 
    674675        f = open(tmpPath,'r') 
    675676        tmpObject = cPickle.load(f) 
     
    680681        elif tmpObject[0] == 'project': 
    681682            self.ProjectOpen(tmpPath,tmpObject[1],tmpObject[2]) 
    682          
     683 
    683684        event.Skip() 
    684685 
     
    705706                finally: 
    706707                    dlg.Destroy() 
    707                      
     708 
    708709            else: 
    709710                self.ProjectSave(False) 
    710711        else: 
    711712            self.ProjectSave(False) 
    712              
     713 
    713714        event.Skip() 
    714715 
     
    739740                finally: 
    740741                    dlg.Destroy() 
    741                      
     742 
    742743            else: 
    743744                self.WaveformSave(False) 
    744745        else: 
    745746            self.WaveformSave(False) 
    746      
     747 
    747748        event.Skip() 
    748749 
     
    770771                return False 
    771772            self.active_wave.name = tempLn 
    772              
     773 
    773774            if len(self.homeDir) > 0: 
    774775                tmpdir = self.homeDir 
     
    777778                if tmpdir == "~": 
    778779                    tmpdir = "/home" 
    779                  
     780 
    780781            dlg = wx.FileDialog(self, "Save As", tmpdir, tempLn + '.owd', "Project File (*.owd)|*.owd", wx.SAVE) 
    781782            #dlg.SetPath(os.getcwd()) 
     
    789790            finally: 
    790791                dlg.Destroy() 
    791              
     792 
    792793        f = open(self.saveProjectPath,'w') 
    793         cPickle.dump(('project',self.active_wave,self.active_plat),f)  
    794          
     794        cPickle.dump(('project',self.active_wave,self.active_plat),f) 
     795 
    795796        return True 
    796797 
     
    802803                return False 
    803804            self.active_wave.name = tempLn 
    804              
     805 
    805806            if len(self.homeDir) > 0: 
    806807                tmpdir = self.homeDir 
     
    809810                if tmpdir == "~": 
    810811                    tmpdir = "/home" 
    811                  
     812 
    812813            dlg = wx.FileDialog(self, "Save As", tmpdir, tempLn + '.sca', "*.sca", wx.SAVE) 
    813814            #dlg.SetPath(os.getcwd()) 
     
    821822            finally: 
    822823                dlg.Destroy() 
    823              
     824 
    824825        f = open(self.saveWaveformPath,'w') 
    825         cPickle.dump(('waveform',self.active_wave),f)      
    826          
     826        cPickle.dump(('waveform',self.active_wave),f) 
     827 
    827828        return True 
    828      
     829 
    829830    def PlatformSave(self,saveasFlag): 
    830         if saveasFlag == True or self.savePlatformPath == None:         
     831        if saveasFlag == True or self.savePlatformPath == None: 
    831832            if self.active_plat.name != "": 
    832833                tmpname = self.active_plat.name 
    833834            else: 
    834835                tmpname = 'Platform1' 
    835                  
     836 
    836837            if len(self.homeDir) > 0: 
    837838                tmpdir = self.homeDir 
     
    840841                if tmpdir == "~": 
    841842                    tmpdir = "/home" 
    842              
     843 
    843844            dlg = wx.FileDialog(self, "Save As", tmpdir, tmpname + '.plt', "Platform File (*.plt)|*.plt", wx.SAVE) 
    844845            try: 
     
    851852            finally: 
    852853                dlg.Destroy() 
    853              
     854 
    854855        f = open(self.savePlatformPath,'w') 
    855         cPickle.dump(('platform',self.active_plat),f)   
    856          
     856        cPickle.dump(('platform',self.active_plat),f) 
     857 
    857858        return True 
    858      
     859 
    859860    def WaveformOpen(self,newPath,newWav): 
    860861        if newPath != None: 
     
    871872                finally: 
    872873                    dlg.Destroy() 
    873              
     874 
    874875            self.saveWaveformPath = newPath 
    875              
     876 
    876877        self.active_wave = newWav 
    877          
     878 
    878879        # We must create new UUIDs for each instance and copy the file uuid from 
    879880        # the base component to the instance 
     
    887888            if c.generate == False and found == False: 
    888889                errorMsg(self,"Could not find " + c.baseName + " which " + c.name + " is an instance of.") 
    889                  
    890          
     890 
     891 
    891892        #Because device assignments are stored as python objects in each component 
    892893        #we must refresh the assignment with the available platform devices 
    893          
     894 
    894895        for c in self.active_wave.components: 
    895896            if c.device == None: 
     
    908909                errorMsg(self,tmpstr) 
    909910                c.device = None 
    910          
     911 
    911912        self.waveNameBox.Clear() 
    912913        self.waveNameBox.WriteText(self.active_wave.name) 
    913         self.displayComps()     
    914          
     914        self.displayComps() 
     915 
    915916        if self.active_wave.ace == True: 
    916917            self.menuWaveform.Check(wxID_FRAME1MENUWAVEFORMACESUPPORT,True) 
     
    918919        else: 
    919920            self.menuWaveform.Check(wxID_FRAME1MENUWAVEFORMACESUPPORT,False) 
    920             #self.ACEcheckBox.SetValue(False)  
    921      
     921            #self.ACEcheckBox.SetValue(False) 
     922 
    922923    def PlatformOpen(self,newPath,newPlat): 
    923924        if newPath != None: 
     
    934935                finally: 
    935936                    dlg.Destroy() 
    936              
     937 
    937938            self.savePlatformPath = newPath 
    938              
     939 
    939940        self.active_plat = newPlat 
    940          
     941 
    941942 
    942943        # NOTE: The following comment does not hold true now that the nodes are installed 
     
    956957                if found == False: 
    957958                    errorMsg(self,"Could not find " + d.baseName + " which " + d.name + " is an instance of.") 
    958          
     959 
    959960        self.displayNodes() 
    960      
    961      
     961 
     962 
    962963    def ProjectOpen(self,newPath,newWav,newPlat): 
    963964        if self.saveProjectPath != None: 
     
    973974            finally: 
    974975                dlg.Destroy() 
    975              
     976 
    976977        self.saveProjectPath = newPath 
    977                  
     978 
    978979        self.PlatformOpen(None,newPlat) 
    979980        self.WaveformOpen(None,newWav) 
    980981        self.displayNodes() 
    981          
    982          
     982 
     983 
    983984    ################################################################# 
    984985    ## Help Menu Stuff 
    985986    ################################################################# 
    986      
     987 
    987988    def OnMenuHelpAboutMenu(self, event): 
    988989        dlg = AboutDialog.Dialog1(self) 
     
    992993            dlg.Destroy() 
    993994        event.Skip() 
    994          
    995      
     995 
     996 
    996997################################################################################ 
    997998## Waveform Layout Functionality 
     
    10351036        finally: 
    10361037            dlg.Destroy() 
    1037      
     1038 
    10381039        sn = self.compBox.GetSelection() 
    10391040        if sn == self.compBox.GetRootItem(): 
     
    10421043            # a main level component 
    10431044            self.active_comp = self.compBox.GetPyData(sn) 
    1044             ti = self.active_wave.components.index(self.active_comp)  
     1045            ti = self.active_wave.components.index(self.active_comp) 
    10451046            # If any other component is connected to this component - connection must be removed 
    10461047            for c in self.active_wave.components: 
     
    10481049                    if con.remoteComp == self.active_comp: 
    10491050                        ci = c.connections.index(con) 
    1050                         del c.connections[ci]               
     1051                        del c.connections[ci] 
    10511052            del self.active_wave.components[ti] 
    10521053        else: 
     
    10561057            ti = self.active_comp.connections.index(tc) 
    10571058            del self.active_comp.connections[ti] 
    1058          
     1059 
    10591060        self.displayComps() 
    10601061        self.displayNodes() 
     
    10821083            for x in self.compBoxPopup.GetMenuItems(): 
    10831084                if x.GetLabel() != 'Remove': 
    1084                     x.Enable(False)            
    1085          
    1086         self.compBox.PopupMenu(self.compBoxPopup)             
     1085                    x.Enable(False) 
     1086 
     1087        self.compBox.PopupMenu(self.compBoxPopup) 
    10871088        event.Skip() 
    10881089 
    10891090    def OnCompBoxPopupSet_acMenu(self, event): 
    10901091        for c in self.active_wave.components: 
    1091             c.AssemblyController = False             
     1092            c.AssemblyController = False 
    10921093        self.active_comp.AssemblyController = True 
    10931094        self.displayComps() 
     
    10971098        self.EditComponent() 
    10981099        event.Skip() 
    1099          
     1100 
    11001101    def OnCompBoxPopupConnectMenu(self, event): 
    11011102        self.ConnectComponent() 
     
    11071108        # what to do when the connections are supported : 
    11081109        #sn = self.nodeBox.GetSelection() 
    1109         #self.active_comp = self.nodeBox.GetPyData(sn)  #active component is actually and active resource   
     1110        #self.active_comp = self.nodeBox.GetPyData(sn)  #active component is actually and active resource 
    11101111        #self.ConnectComponent() 
    11111112 
     
    11381139            self.active_comp = self.compBox.GetPyData(sn) 
    11391140            newname = event.GetLabel() 
    1140          
     1141 
    11411142        if len(newname) > 0: 
    11421143            for c in self.active_wave.components: 
     
    11451146                    event.Veto() 
    11461147                    return 
    1147              
     1148 
    11481149            #Component names with spaces do not work 
    11491150            if newname.find(' ') != -1: 
     
    11531154                #newname = newname.replace(' ','_') 
    11541155                #self.compBox.SetItemText(sn,newname) 
    1155                  
     1156 
    11561157            self.active_comp.changeName(newname) 
    11571158            #self.active_comp.name = newname 
     
    11621163            event.Veto() 
    11631164            return 
    1164         event.Skip()         
    1165  
    1166     def OnCompBoxTreeBeginLabelEdit(self, event):         
     1165        event.Skip() 
     1166 
     1167    def OnCompBoxTreeBeginLabelEdit(self, event): 
    11671168        sn = self.compBox.GetSelection() 
    11681169        if sn == self.compBox.GetRootItem(): 
     
    11771178            event.Veto() 
    11781179            return 
    1179         event.Skip()     
     1180        event.Skip() 
    11801181 
    11811182    def OnCompBoxPopupRenameMenu(self, event): 
     
    11971198 
    11981199        event.Skip() 
    1199          
     1200 
    12001201    def OnCompBoxPopupRefreshMenu(self, event): 
    12011202        self.displayComps() 
    1202         event.Skip()     
    1203          
     1203        event.Skip() 
     1204 
    12041205    ################################################################# 
    12051206    ## Waveform Menu Stuff 
    12061207    ################################################################# 
    1207      
     1208 
    12081209    def OnMenuWaveformAddcompMenu(self, event): 
    12091210        ComponentFrame.newComponentFrame() 
     
    12281229            errorMsg(self,'Only top level components can be connected!') 
    12291230            return 
    1230          
     1231 
    12311232        self.ConnectComponent() 
    12321233        event.Skip() 
     
    12441245            errorMsg(self,'Only top level components can be edited!') 
    12451246            return 
    1246          
     1247 
    12471248        self.EditComponent() 
    12481249        event.Skip() 
     
    12531254            errorMsg(self,'Please enter a waveform name first') 
    12541255            return 
    1255              
    1256         nFlag = False     
     1256 
     1257        nFlag = False 
    12571258        for c in self.active_wave.components: 
    12581259            if c.name == tempLn: 
    12591260                nFlag = True 
    1260          
     1261 
    12611262        if nFlag == True: 
    12621263            tmpstr = "One of the waveform components has the same name as the waveform.\n" 
     
    12721273            node_names.append(n.name) 
    12731274            for d in n.Devices: 
    1274                 device_ids.append(d.uuid)                 
     1275                device_ids.append(d.uuid) 
    12751276 
    12761277        ##check for duplicate node names 
     
    12791280        #    errorMsg(self,"Duplicate node names detected.  This is not allowed.") 
    12801281        #    return 
    1281          
     1282 
    12821283        #check for duplicates in the device uuids 
    12831284        tmp = list(set(device_ids))  #removes duplicates from the list 
    12841285        if len(tmp) != len(device_ids):  #if there were duplicates (multiple copies of same device instances) 
    12851286            errorMsg(self,"Duplicate nodes or device instantiation UUIDs have been detected.  This is not allowed.") 
    1286             return     
     1287            return 
    12871288 
    12881289        acFlag = False 
     
    13071308                dlg.Destroy() 
    13081309            #return 
    1309              
     1310 
    13101311        if len(noDevs) > 0: 
    13111312            tmpstr = 'The following components are not assigned to a device. ' 
     
    13141315                tmpstr += x + '\n' 
    13151316            errorMsg(self,tmpstr) 
    1316              
     1317 
    13171318        self.waveName = tempLn 
    13181319        self.active_wave.name = tempLn 
    1319      
     1320 
    13201321        dlg = wx.DirDialog(self,"Please select the place to generate the code",style=wx.DD_NEW_DIR_BUTTON) 
    13211322        dlg.SetPath(os.getcwd()) 
     
    13271328        finally: 
    13281329            dlg.Destroy() 
    1329          
    1330         gen = genStruct.genAll(self.path,copy.deepcopy(self.active_wave)) 
     1330 
     1331        gen = genStruct.genAll(self.path, self.wavedevPath, copy.deepcopy(self.active_wave)) 
    13311332        gen.genDirs() 
    13321333        # Only include the device manager files if there is just one node 
     
    13401341            if c.generate: 
    13411342                gen.genCompFiles(c) 
    1342          
    1343         xml_gen.genxml(copy.deepcopy(self.active_wave.components),self.path,self.active_wave.name) 
    1344         xml_gen.genDAS(copy.deepcopy(self.active_wave.components),self.path,self.active_wave.name) 
    1345         xml_gen.writeWaveSetuppy(self.path, self.active_wave.name)      
    1346    
    1347         #save the .owd file  
     1343 
     1344        xml_gen.genxml(copy.deepcopy(self.active_wave.components), self.path, self.wavedevPath, self.active_wave.name) 
     1345        xml_gen.genDAS(copy.deepcopy(self.active_wave.components), self.path, self.wavedevPath, self.active_wave.name) 
     1346        xml_gen.writeWaveSetuppy(self.path, self.wavedevPath, self.active_wave.name) 
     1347 
     1348        #save the .owd file 
    13481349        f = open(self.path + "/" + self.waveName +  "/" + self.waveName + ".owd",'w') 
    1349         cPickle.dump(('project',self.active_wave,self.active_plat),f)    
    1350                 
     1350        cPickle.dump(('project',self.active_wave,self.active_plat),f) 
     1351 
    13511352        #generate the dcd file for each node 
    13521353        #for n in self.active_plat.nodes: 
     
    13571358            #    tmpname = 'DeviceManager' + n.name 
    13581359            #    folderFlag = True 
    1359             #xml_gen.genDeviceManager(n,self.path,self.active_wave.name,tmpname,folderFlag) 
    1360          
     1360            #xml_gen.genDeviceManager(n, self.path, self.wavedevPath, self.active_wave.name, tmpname,folderFlag) 
     1361 
    13611362        gen.cleanUp() 
    13621363 
     
    13711372            for x in self.active_wave.components: 
    13721373                if x.generate == True: 
    1373                     x.ace = False  
    1374          
    1375         event.Skip() 
    1376          
    1377      
     1374                    x.ace = False 
     1375 
     1376        event.Skip() 
     1377 
     1378 
    13781379################################################################################ 
    13791380## Resource Functionality 
    13801381################################################################################ 
    1381          
     1382 
    13821383    def displayResources(self): 
    13831384        self.resourceBox.DeleteAllItems() 
     
    13861387        devRoot = self.resourceBox.AppendItem(troot,'Devices',image=1) 
    13871388        nodeRoot = self.resourceBox.AppendItem(troot,'Nodes',image=1) 
    1388          
     1389 
    13891390        for c in self.Available_Components: 
    13901391            t1 = self.resourceBox.AppendItem(compRoot,c.name) 
    13911392            self.resourceBox.SetPyData(t1,c) 
    1392          
     1393 
    13931394        for c in self.Available_Devices: 
    13941395            t1 = self.resourceBox.AppendItem(devRoot,c.name) 
    13951396            self.resourceBox.SetPyData(t1,c) 
    1396          
     1397 
    13971398        for n in self.Available_Nodes: 
    13981399            t1 = self.resourceBox.AppendItem(nodeRoot,n.name) 
    13991400            self.resourceBox.SetPyData(t1,n) 
    1400          
    1401          
     1401 
     1402 
    14021403        if self.resourceBox.GetChildrenCount(troot,recursively=False) > 0: 
    14031404            cid1,cookie1 = self.resourceBox.GetFirstChild(troot) 
     
    14071408                self.resourceBox.SortChildren(cid1) 
    14081409 
    1409     def loadResources(self):             
     1410    def loadResources(self): 
    14101411        self.Available_Components = [] 
    14111412        self.Available_Devices = [] 
    14121413        self.Available_Nodes = [] 
    1413   
     1414 
    14141415        resList = [] 
    14151416 
     
    14291430            tmpResPath = r[0] + r[1] 
    14301431            tmpComp = importResource.getResource(tmpResPath,tmpResName,self) 
    1431                  
     1432 
    14321433            if tmpComp == None: 
    14331434                continue 
     
    14401441            elif tmpComp.type == 'device': 
    14411442                self.Available_Devices.append(tmpComp) 
    1442          
     1443 
    14431444        nodeList = [] 
    14441445        if os.path.isdir(self.installPath + 'nodes'): 
     
    14461447        else: 
    14471448            errorMsg(self, "No nodes could be found in: " + self.installPath) 
    1448          
     1449 
    14491450        # find the scd files for each node 
    14501451        for node_name in nodeList: 
     
    14671468            nodeName = node_name 
    14681469            nodePath = self.installPath + 'nodes/' + nodeName + '/' 
    1469              
     1470 
    14701471            tmpNode = importNode.getNode(nodePath,nodeName,self) 
    14711472            if tmpNode == None: 
     
    14731474                continue 
    14741475            self.Available_Nodes.append(tmpNode) 
    1475            
     1476 
    14761477        self.displayResources() 
    14771478 
    1478     def OnRefreshResourceBtnButton(self, event):         
     1479    def OnRefreshResourceBtnButton(self, event): 
    14791480        self.loadResources() 
    14801481 
     
    14981499                    if c.baseName == tmpBaseName: 
    14991500                        tmpCount += 1 
    1500          
     1501 
    15011502                dlg = wx.TextEntryDialog(self, 'Please enter an instance name for this '\ 
    15021503                + tmpRes.name + ' component.', 'Enter Name', tmpRes.name + str(tmpCount)) 
     
    15091510                            dlg.Destroy() 
    15101511                            return 
    1511                  
     1512 
    15121513                        for c in self.active_wave.components: 
    15131514                            if newname == c.name: 
     
    15201521                finally: 
    15211522                    dlg.Destroy() 
    1522          
    1523          
     1523 
     1524 
    15241525                newRes = copy.deepcopy(tmpRes) 
    1525                 newRes.name = newname     
    1526                 newRes.baseName = tmpBaseName     
     1526                newRes.name = newname 
     1527                newRes.baseName = tmpBaseName 
    15271528                newRes.setUUID()    # this gives the component instance a unique id 
    15281529        # we do not set the newRes.file_uuid because it is the same for all components of this type 
    1529          
     1530 
    15301531                self.active_wave.components.append(newRes) 
    15311532                self.displayComps() 
     
    15481549                    x.Enable(True) 
    15491550            tmpRes =  self.resourceBox.GetPyData(sn) 
    1550             if tmpRes.type == 'resource':            
     1551            if tmpRes.type == 'resource': 
    15511552                x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPADDDEV) 
    1552                 x.Enable(False)            
     1553                x.Enable(False) 
    15531554                x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPADDNODE) 
    1554                 x.Enable(False)            
    1555                  
     1555                x.Enable(False) 
     1556 
    15561557                #x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPGETDESCR) 
    15571558                #x.Enable(False) 
    1558                  
     1559 
    15591560                #disable Doxygen docs display if no docs directory found 
    15601561                docsPath = self.installPath + 'docs/' + tmpRes.name 
     
    15641565            elif tmpRes.type == 'node': 
    15651566                x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPADDDEV) 
    1566                 x.Enable(False)            
     1567                x.Enable(False) 
    15671568                x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPADD) 
    1568                 x.Enable(False)           
    1569                 #x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPGETDESCR) 
    1570                 #x.Enable(False) 
    1571                 x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPGETDOXYGENREFMAN) 
    1572                 x.Enable(False)  
    1573             else:            
    1574                 x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPADDNODE) 
    1575                 x.Enable(False)            
    1576                 x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPADD) 
    1577                 x.Enable(False)            
     1569                x.Enable(False) 
    15781570                #x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPGETDESCR) 
    15791571                #x.Enable(False) 
    15801572                x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPGETDOXYGENREFMAN) 
    15811573                x.Enable(False) 
     1574            else: 
     1575                x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPADDNODE) 
     1576                x.Enable(False) 
     1577                x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPADD) 
     1578                x.Enable(False) 
     1579                #x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPGETDESCR) 
     1580                #x.Enable(False) 
     1581                x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPGETDOXYGENREFMAN) 
     1582                x.Enable(False) 
    15821583 
    15831584        #if tmpRes != None: 
    1584         self.resourceBox.PopupMenu(self.resourceBoxPopup)             
     1585        self.resourceBox.PopupMenu(self.resourceBoxPopup) 
    15851586        event.Skip() 
    15861587 
     
    16031604        sn = self.resourceBox.GetSelection() 
    16041605        tmpRes =  self.resourceBox.GetPyData(sn) 
    1605          
     1606 
    16061607        if len(self.active_plat.nodes) == 0: 
    16071608            tmpstr = "There are no available nodes to add a device instance to.\n" 
     
    16091610            errorMsg(self,tmpstr) 
    16101611            return 
    1611          
     1612 
    16121613        tmpBaseName = tmpRes.name 
    16131614        #tmpCount = 1 
     
    16161617        #        if x.baseName == tmpBaseName: 
    16171618        #            tmpCount += 1 
    1618          
     1619 
    16191620        #dlg = NodeDialog.create(self,self.active_plat.nodes,tmpBaseName + str(tmpCount)) 
    16201621        dlg = NodeDialog.create(self,self.active_plat.nodes,tmpBaseName) 
    1621          
     1622 
    16221623        try: 
    16231624            returnCode = dlg.ShowModal() 
     
    16291630                basename = newname 
    16301631                newname = newname+str(tmpCount) 
    1631                  
     1632 
    16321633                while iterator < len(tmpnode.Devices): 
    16331634                    for c in tmpnode.Devices: 
     
    16541655        finally: 
    16551656            dlg.Destroy() 
    1656          
    1657          
     1657 
     1658 
    16581659        newDev = copy.deepcopy(tmpRes) 
    1659         newDev.name = newname     
    1660         newDev.baseName = tmpBaseName    
    1661         newDev.generate = False  
     1660        newDev.name = newname 
     1661        newDev.baseName = tmpBaseName 
     1662        newDev.generate = False 
    16621663        newDev.node = tmpnode.name 
    16631664        newDev.setUUID()    # this gives the device instance a unique id 
    16641665        # we do not set the newDev.file_uuid because it is the same for all devices of this type 
    1665          
     1666 
    16661667        tmpnode.Devices.append(newDev) 
    16671668        self.displayNodes() 
     
    17011702                errorMsg(self,'Neither index.html nor refman.pdf found in ' + docsPath + ': directory listing: ' + str(docList)) 
    17021703        else: 
    1703             errorMsg(self,'No directory for ' + tmpRes.name + ' could be found in: ' + self.installPath + 'docs')             
     1704            errorMsg(self,'No directory for ' + tmpRes.name + ' could be found in: ' + self.installPath + 'docs') 
    17041705            return 
    17051706 
     
    17101711        self.displayNodes() 
    17111712        event.Skip() 
    1712              
     1713 
    17131714################################################################################ 
    17141715## Platform Layout Functionality 
     
    17181719        self.nodeBox.DeleteAllItems() 
    17191720        troot = self.nodeBox.AddRoot("the_root") 
    1720          
     1721 
    17211722        for n in self.active_plat.nodes: 
    17221723            t1 = self.nodeBox.AppendItem(troot,n.name) 
    17231724            self.nodeBox.SetPyData(t1,n) 
    1724      
     1725 
    17251726            for d in n.Devices: 
    17261727                t2 = self.nodeBox.AppendItem(t1,unicode(d.name)) 
    17271728                self.nodeBox.SetPyData(t2,d) 
    1728                  
     1729 
    17291730                for c in self.active_wave.components: 
    17301731                    if c.device == d: 
    17311732                        t3 = self.nodeBox.AppendItem(t2,c.name) 
    17321733                        self.nodeBox.SetPyData(t3,c) 
    1733                      
     1734 
    17341735    def AddNode(self): 
    17351736        tmpCount = len(self.active_plat.nodes) + 1 
    1736          
     1737 
    17371738        dlg = wx.TextEntryDialog(self, 'Please enter a name for this node ',\ 
    17381739         'Enter Name', 'Node' + str(tmpCount)) 
     
    17451746                    dlg.Destroy() 
    17461747                    return 
    1747                  
     1748 
    17481749                for c in self.active_plat.nodes: 
    17491750                    if newname == c.name: 
     
    17561757        finally: 
    17571758            dlg.Destroy() 
    1758          
     1759 
    17591760        #tmpNode = PlatformClass.Node(newname) 
    17601761        tmpNode = ComponentClass.Node(name=newname) 
     
    17651766        errorMsg(self, 'WARNING: You will have to regenerate your waveform if you continue') 
    17661767        sn = self.nodeBox.GetSelection() 
    1767          
     1768 
    17681769        #generate the dcd file for the selected node 
    17691770        dlg = wx.DirDialog(self,"Please select the place to generate the code",style=wx.DD_NEW_DIR_BUTTON) 
     
    17771778            dlg.Destroy() 
    17781779        active_node = None 
    1779         
     1780 
    17801781        tmp_count = 0 
    17811782        duplicate_name_flag = False 
     
    17841785                dev_count = 0 
    17851786                while dev_count < len(self.active_plat.nodes[tmp_count].Devices): 
    1786                     tmp_uuid = unicode(ComponentClass.uuidgen()) 
     1787                    tmp_uuid = unicode(uuidgen.uuidgen()) 
    17871788                    n.Devices[dev_count].uuid = tmp_uuid 
    17881789                    self.active_plat.nodes[tmp_count].Devices[dev_count].uuid = tmp_uuid 
    1789                     dev_count = dev_count + 1                 
     1790                    dev_count = dev_count + 1 
    17901791                active_node = n 
    17911792                break 
     
    17971798 
    17981799 
    1799         gen = genNode.genAll(self.path,copy.deepcopy(active_node)) 
     1800        gen = genNode.genAll(self.path, self.wavedevPath, copy.deepcopy(active_node)) 
    18001801        gen.genDirs() 
    18011802        gen.writeMakefile() 
    18021803        # TODO: use different configure.ac file for node -JDG 
    18031804        gen.genConfigureACFiles(self.installPath) 
    1804         xml_gen.genDeviceManager(n,self.path,n.name,"DeviceManager",False) 
    1805          
    1806                      
     1805        xml_gen.genDeviceManager(n, self.path, self.wavedevPath, n.name, "DeviceManager", False) 
     1806 
     1807 
    18071808    def RemoveNodeBoxSelection(self): 
    18081809        sn = self.nodeBox.GetSelection() 
    18091810        snParent = self.nodeBox.GetItemParent(sn) 
    1810         if snParent == self.nodeBox.GetRootItem():   
    1811             # a platform node           
     1811        if snParent == self.nodeBox.GetRootItem(): 
     1812            # a platform node 
    18121813            tmpMsg = "        Are you sure you want to remove this Node?\n\n" 
    18131814            tmpMsg += "All device instances assigned to this node will be removed,\n" 
     
    18161817                return 
    18171818            tmpNode = self.nodeBox.GetPyData(sn) 
    1818             for n in self.active_plat.nodes:     
    1819                 if tmpNode == n:   
     1819            for n in self.active_plat.nodes: 
     1820                if tmpNode == n: 
    18201821                    for d in n.Devices: 
    18211822                        # If any other component is connected to this device - connection must be removed 
     
    18301831                    dIndex = self.active_plat.nodes.index(tmpNode) 
    18311832                    del self.active_plat.nodes[dIndex] 
    1832              
     1833 
    18331834        elif self.nodeBox.GetItemParent(snParent) == self.nodeBox.GetRootItem(): 
    18341835            # a device instance 
     
    18431844                    if con.remoteComp == tmpDev: 
    18441845                        ci = c.connections.index(con) 
    1845                         del c.connections[ci]   
    1846              
    1847             for n in self.active_plat.nodes:     
     1846                        del c.connections[ci] 
     1847 
     1848            for n in self.active_plat.nodes: 
    18481849                for d in n.Devices: 
    18491850                    if tmpDev == d: 
     
    18601861            tmpComp = self.nodeBox.GetPyData(sn) 
    18611862            tmpComp.device = None 
    1862          
     1863 
    18631864        self.displayNodes() 
    18641865        self.displayComps() 
     
    18921893            self.nodeBoxPopup.Enable(wxID_FRAME1NODEBOXPOPUPGENERATE,False) 
    18931894            self.nodeBoxPopup.Enable(wxID_FRAME1NODEBOXPOPUPRENAME,False) 
    1894          
    1895         self.nodeBox.PopupMenu(self.nodeBoxPopup)             
     1895 
     1896        self.nodeBox.PopupMenu(self.nodeBoxPopup) 
    18961897        event.Skip() 
    18971898 
     
    19031904        self.RemoveNodeBoxSelection() 
    19041905        event.Skip() 
    1905          
     1906 
    19061907    def OnNodeBoxPopupGenerateMenu(self, event): 
    19071908        self.GenerateNodeBoxSelection() 
     
    19101911    def OnNodeBoxPopupExpandMenu(self, event): 
    19111912        troot = self.nodeBox.GetRootItem() 
    1912         if self.nodeBox.ItemHasChildren(troot):               
     1913        if self.nodeBox.ItemHasChildren(troot): 
    19131914            cid1,cookie1 = self.nodeBox.GetFirstChild(troot) 
    19141915            self.ExpandTreeNode(self.nodeBox,cid1) 
     
    19171918                self.ExpandTreeNode(self.nodeBox,cid1) 
    19181919                cid1 = self.nodeBox.GetNextSibling(cid1) 
    1919                  
    1920         event.Skip() 
    1921          
     1920 
     1921        event.Skip() 
     1922 
    19221923    def OnNodeBoxPopupRefreshMenu(self, event): 
    19231924        self.displayNodes() 
     
    19421943            event.Veto() 
    19431944            return 
    1944         event.Skip()     
     1945        event.Skip() 
    19451946 
    19461947    def OnNodeBoxTreeEndLabelEdit(self, event): 
     
    19601961                        event.Veto() 
    19611962                        return 
    1962                  
     1963 
    19631964                #Node names with spaces do not work 
    19641965                if newname.find(' ') != -1: 
     
    19661967                    event.Veto() 
    19671968                    return 
    1968                      
     1969 
    19691970                tempNode.name = newname 
    19701971            else: 
     
    19791980            newname = event.GetLabel() 
    19801981            if len(newname) > 0: 
    1981                 for d in tempNode.Devices:                     
     1982                for d in tempNode.Devices: 
    19821983                    if d != tempDev and d.name == newname: 
    19831984                        errorMsg(self,'Invalid name - a device instance with that name already exists') 
    19841985                        event.Veto() 
    19851986                        return 
    1986                  
     1987 
    19871988                #Device names with spaces do not work 
    19881989                if newname.find(' ') != -1: 
     
    19901991                    event.Veto() 
    19911992                    return 
    1992                      
     1993 
    19931994                tempDev.changeName(newname) 
    1994                  
     1995 
    19951996        else: 
    19961997            # a child component (connection) 
    19971998            event.Veto() 
    19981999            return 
    1999          
    2000         event.Skip()         
     2000 
     2001        event.Skip() 
    20012002 
    20022003    ################################################################# 
     
    20232024                self.ExpandTreeNode(whichBox,cid1) 
    20242025                cid1 = self.nodeBox.GetNextSibling(cid1) 
    2025                  
     2026 
    20262027############################################################################### 
    20272028## LoadConfiguration 
    2028 ## This function is not a part of the frame class so that other modules can  
     2029## This function is not a part of the frame class so that other modules can 
    20292030## call it 
    2030 ###############################################################################                 
     2031############################################################################### 
    20312032def LoadConfiguration(frame_obj): 
    20322033    '''Extracts information from configuration file''' 
     
    20402041    except: 
    20412042        frame_obj.version = "unknown" 
    2042      
     2043 
    20432044    # install path 
    20442045    try: 
     
    20802081            errorMsg(frame_obj,tmpstr) 
    20812082 
    2082     
     2083 
    20832084    # custom IDL path 
    20842085    use_default_customidlpath = False 
     
    21312132            tmpstr += "using CF interfaces.\n\n" 
    21322133            tmpstr += "If you have ossie installed in a location other than\n" 
    2133             tmpstr += "the default please specify that location in the\n"  
     2134            tmpstr += "the default please specify that location in the\n" 
    21342135            tmpstr += "wavedev.cfg file located in the top directory." 
    21352136            errorMsg(frame_obj,tmpstr) 
  • ossiedev/branches/jsnyder/ComponentProject/WaveDev/wavedev/PropertiesDialog.py

    r5941 r7435  
    66from errorMsg import * 
    77import commands 
     8from uuidgen import uuidgen 
    89 
    910def create(parent): 
    1011    return PropertiesDialog(parent) 
    1112 
    12 [wxID_PROPERTIESDIALOG, wxID_PROPERTIESDIALOGACTIONCHOICE,  
    13  wxID_PROPERTIESDIALOGADDPROP, wxID_PROPERTIESDIALOGADDVALUE,  
    14  wxID_PROPERTIESDIALOGCANCEL, wxID_PROPERTIESDIALOGDESCRIPTION,  
    15  wxID_PROPERTIESDIALOGELEMENTCHOICE, wxID_PROPERTIESDIALOGENUMBOX,  
    16  wxID_PROPERTIESDIALOGIDBOX, wxID_PROPERTIESDIALOGKINDCHOICE,  
    17  wxID_PROPERTIESDIALOGMAXBOX, wxID_PROPERTIESDIALOGMINBOX,  
    18  wxID_PROPERTIESDIALOGMODECHOICE, wxID_PROPERTIESDIALOGNAMEBOX,  
    19  wxID_PROPERTIESDIALOGOK, wxID_PROPERTIESDIALOGSASHWINDOW1,  
    20  wxID_PROPERTIESDIALOGSASHWINDOW2, wxID_PROPERTIESDIALOGSPLITTERWINDOW1,  
    21  wxID_PROPERTIESDIALOGSTATICTEXT1, wxID_PROPERTIESDIALOGSTATICTEXT10,  
    22  wxID_PROPERTIESDIALOGSTATICTEXT11, wxID_PROPERTIESDIALOGSTATICTEXT12,  
    23  wxID_PROPERTIESDIALOGSTATICTEXT2, wxID_PROPERTIESDIALOGSTATICTEXT3,  
    24  wxID_PROPERTIESDIALOGSTATICTEXT4, wxID_PROPERTIESDIALOGSTATICTEXT5,  
    25  wxID_PROPERTIESDIALOGSTATICTEXT6, wxID_PROPERTIESDIALOGSTATICTEXT7,  
    26  wxID_PROPERTIESDIALOGSTATICTEXT8, wxID_PROPERTIESDIALOGSTATICTEXT9,  
    27  wxID_PROPERTIESDIALOGTYPECHOICE, wxID_PROPERTIESDIALOGUNITSCHOICE,  
    28  wxID_PROPERTIESDIALOGVALUEBOX, wxID_PROPERTIESDIALOGVALUELIST,  
     13[wxID_PROPERTIESDIALOG, wxID_PROPERTIESDIALOGACTIONCHOICE, 
     14 wxID_PROPERTIESDIALOGADDPROP, wxID_PROPERTIESDIALOGADDVALUE, 
     15 wxID_PROPERTIESDIALOGCANCEL, wxID_PROPERTIESDIALOGDESCRIPTION, 
     16 wxID_PROPERTIESDIALOGELEMENTCHOICE, wxID_PROPERTIESDIALOGENUMBOX, 
     17 wxID_PROPERTIESDIALOGIDBOX, wxID_PROPERTIESDIALOGKINDCHOICE, 
     18 wxID_PROPERTIESDIALOGMAXBOX, wxID_PROPERTIESDIALOGMINBOX, 
     19 wxID_PROPERTIESDIALOGMODECHOICE, wxID_PROPERTIESDIALOGNAMEBOX, 
     20 wxID_PROPERTIESDIALOGOK, wxID_PROPERTIESDIALOGSASHWINDOW1, 
     21 wxID_PROPERTIESDIALOGSASHWINDOW2, wxID_PROPERTIESDIALOGSPLITTERWINDOW1, 
     22 wxID_PROPERTIESDIALOGSTATICTEXT1, wxID_PROPERTIESDIALOGSTATICTEXT10, 
     23 wxID_PROPERTIESDIALOGSTATICTEXT11, wxID_PROPERTIESDIALOGSTATICTEXT12, 
     24 wxID_PROPERTIESDIALOGSTATICTEXT2, wxID_PROPERTIESDIALOGSTATICTEXT3, 
     25 wxID_PROPERTIESDIALOGSTATICTEXT4, wxID_PROPERTIESDIALOGSTATICTEXT5, 
     26 wxID_PROPERTIESDIALOGSTATICTEXT6, wxID_PROPERTIESDIALOGSTATICTEXT7, 
     27 wxID_PROPERTIESDIALOGSTATICTEXT8, wxID_PROPERTIESDIALOGSTATICTEXT9, 
     28 wxID_PROPERTIESDIALOGTYPECHOICE, wxID_PROPERTIESDIALOGUNITSCHOICE, 
     29 wxID_PROPERTIESDIALOGVALUEBOX, wxID_PROPERTIESDIALOGVALUELIST, 
    2930] = [wx.NewId() for _init_ctrls in range(34)] 
    3031 
     
    238239        self.calledByParent = False 
    239240        self.active_prop = None 
    240          
     241 
    241242    def OnPropertiesDialogActivate(self, event): 
    242243        if self.calledByParent == True: 
    243244 
    244245            self.active_comp = self.parent.active_comp 
    245            
     246 
    246247            if self.active_prop == None: 
    247248                self.elementType = "Simple" 
     
    262263                tmp = self.modeChoice.FindString(self.active_prop.mode) 
    263264                self.modeChoice.SetSelection(tmp) 
    264                 self.elementType = self.active_prop.elementType  
     265                self.elementType = self.active_prop.elementType 
    265266                tmp = self.elementChoice.FindString(self.elementType) 
    266267                self.elementChoice.SetSelection(tmp) 
     
    272273 
    273274            self.refreshDisplay() 
    274          
     275 
    275276            self.calledByParent = False 
    276277        event.Skip() 
     
    284285        pos = self.elementChoice.GetSelection() 
    285286        if pos == wx.NOT_FOUND: 
    286             return  
     287            return 
    287288        self.elementType = self.elementChoice.GetString(pos) 
    288289        if self.elementType != "Simple" and self.elementType != "SimpleSequence": 
     
    290291            self.elementType = "Simple" 
    291292            self.elementChoice.SetSelection(0) 
    292                          
     293 
    293294        self.refreshDisplay() 
    294295        event.Skip() 
    295          
     296 
    296297    def refreshDisplay(self): 
    297298        if self.active_prop != None: 
    298              
     299 
    299300            if self.active_prop.elementType == "Simple": 
    300301                pass 
     
    305306                self.addValue.Enable(True) 
    306307            self.enumBox.Enable(True) 
    307              
     308 
    308309            pos = self.kindChoice.GetSelection() 
    309310            if pos != wx.NOT_FOUND: 
     
    312313                else: 
    313314                    self.actionChoice.Enable(False) 
    314              
     315 
    315316        elif self.elementType == "SimpleSequence": 
    316317            self.addValue.Enable(True) 
    317318            self.enumBox.Enable(False) 
    318              
     319 
    319320    def initializeDisplay(self): 
    320321        if self.elementType == "Simple" or self.elementType == "SimpleSequence": 
     
    322323            pos = self.typeChoice.FindString(self.active_prop.type) 
    323324            self.typeChoice.SetSelection(pos) 
    324              
     325 
    325326            # Load the action (ie. eq, lt, ge) 
    326327            if self.active_prop.action != None: 
    327328                pos = self.actionChoice.FindString(self.active_prop.action) 
    328329                self.actionChoice.SetSelection(pos) 
    329              
     330 
    330331            # Load the kind (ie. allocation, configure, execparam) 
    331332            pos = self.kindChoice.FindString(self.active_prop.kind) 
     
    336337                pass 
    337338            else: 
    338                 self.minBox.SetValue(str(self.active_prop.range[0]))  
    339                 self.maxBox.SetValue(str(self.active_prop.range[1]))  
     339                self.minBox.SetValue(str(self.active_prop.range[0])) 
     340                self.maxBox.SetValue(str(self.active_prop.range[1])) 
    340341 
    341342            # If this is already installed on the system - can't change anything but the value(s) 
     
    352353                self.modeChoice.Enable(False) 
    353354                self.description.Enable(False) 
    354                 
    355         if self.elementType == "Simple":     
     355 
     356        if self.elementType == "Simple": 
    356357            # Load the value for a Simple type 
    357358            self.valueList.InsertStringItem(0,unicode(self.active_prop.value)) 
    358359            self.valueList.SetStringItem(0,1,unicode(self.active_prop.defaultValue)) 
    359              
     360 
    360361            # Load the enumeration 
    361362            if self.active_prop.enum != '': 
    362363                self.enumBox.SetValue(self.active_prop.enum) 
    363          
    364         if self.elementType == "SimpleSequence":     
     364 
     365        if self.elementType == "SimpleSequence": 
    365366            for v in self.active_prop.values: 
    366367                self.valueList.InsertStringItem(0,v)  #create list (backwards at first) 
     
    383384            self.valueList.SetStringItem(0,1,tmpStr) 
    384385            self.valueBox.Clear() 
    385              
     386 
    386387        self.refreshDisplay() 
    387388        event.Skip() 
     
    400401    def OnValueListRightUp(self, event): 
    401402        self.valueList.PopupMenu(self.valueListPopup) 
    402          
     403 
    403404        event.Skip() 
    404405 
     
    406407        self.Close() 
    407408        event.Skip() 
    408              
     409 
    409410    def OnAddPropButton(self, event): 
    410411        # Check for the name 
     
    413414            errorMsg(self,"Please enter a property name first!") 
    414415            return 
    415          
     416 
    416417        # Check for the id 
    417418        tmpid = self.idBox.GetLineText(0) 
     
    419420            errorMsg(self,"Please enter a property id first!") 
    420421            return 
    421          
     422 
    422423        # Check for the mode 
    423424        pos = self.modeChoice.GetSelection() 
    424425        if pos == wx.NOT_FOUND: 
    425426            errorMsg(self,"Please select a property mode first!") 
    426             return  
     427            return 
    427428        tmpMode = self.modeChoice.GetString(pos) 
    428          
     429 
    429430        # Get the description 
    430431        tmpDes = self.description.GetValue() 
    431                  
     432 
    432433        # Check for the type ex: bool, char, short, etc. 
    433434        pos = self.typeChoice.GetSelection() 
    434435        if pos == wx.NOT_FOUND: 
    435436            errorMsg(self,"Please select a type first!") 
    436             return  
     437            return 
    437438        tmpType = self.typeChoice.GetString(pos) 
    438          
     439 
    439440        if self.elementType == "Simple": 
    440441            # instantiate the property object 
    441442            newProp = CC.SimpleProperty(tmpName,tmpMode,tmpType,tmpDes) 
    442              
     443 
    443444            # store the default value and the value 
    444445            if self.valueList.GetItemCount() == 0: 
    445446                errorMsg(self,"Please enter a value first!") 
    446447                return 
    447              
     448 
    448449            v = self.valueList.GetItem(0,0) 
    449450            dv = self.valueList.GetItem(0,1) 
    450451            newProp.value = v.GetText() 
    451452            newProp.defaultValue = dv.GetText() 
    452              
     453 
    453454        if self.elementType == "SimpleSequence": 
    454455            # store the default value and the value 
     
    456457                    errorMsg(self,"Please enter a value first!") 
    457458                    return 
    458              
     459 
    459460            newProp = CC.SimpleSequenceProperty(tmpName,tmpMode,tmpType,tmpDes) 
    460              
    461     
     461 
     462 
    462463            newProp.values = [] 
    463             newProp.defaultValues = []         
    464              
     464            newProp.defaultValues = [] 
     465 
    465466            for x in range(self.valueList.GetItemCount()): 
    466467                v = self.valueList.GetItem(x,0) 
     
    472473        # store the enum if any 
    473474        newProp.enum = self.enumBox.GetLineText(0) 
    474              
     475 
    475476        # Check for the kind ex: allocation, configure, test, etc. 
    476477        pos = self.kindChoice.GetSelection() 
    477478        if pos == wx.NOT_FOUND: 
    478479            errorMsg(self,"Please select a kind first!") 
    479             return  
     480            return 
    480481        newProp.kind = self.kindChoice.GetString(pos) 
    481               
     482 
    482483        # Check and store the range 
    483484        tmpMin = self.minBox.GetLineText(0) 
    484485        tmpMax = self.maxBox.GetLineText(0) 
    485              
     486 
    486487        if tmpMin == 'min' or tmpMin == '': 
    487488            tmpMin = -1 
    488              
     489 
    489490        if tmpMax == 'max' or tmpMax == '': 
    490491            tmpMax = -1 
    491                  
     492 
    492493        newProp.range = (tmpMin,tmpMax) 
    493              
     494 
    494495        # Check and store the action 
    495496        pos = self.actionChoice.GetSelection() 
     
    497498            if newProp.kind == "allocation": 
    498499                errorMsg(self,"Please select an action first!") 
    499                 return  
     500                return 
    500501        else: 
    501502            newProp.action = self.actionChoice.GetString(pos) 
    502                             
     503 
    503504        self.parent.active_comp.properties.append(newProp) 
    504505        self.Close() 
    505              
    506         event.Skip() 
    507          
     506 
     507        event.Skip() 
     508 
    508509    def OnOkButton(self, event): 
    509510        if self.editable: 
     
    514515                return 
    515516            self.active_prop.name = tmpName 
    516              
     517 
    517518            # Check for the id 
    518519            tmpid = self.idBox.GetLineText(0) 
     
    521522                return 
    522523            self.active_prop.id = tmpid 
    523          
     524 
    524525            # Check for the mode 
    525526            pos = self.modeChoice.GetSelection() 
    526527            if pos == wx.NOT_FOUND: 
    527528                errorMsg(self,"Please select a property mode first!") 
    528                 return  
     529                return 
    529530            tmpMode = self.modeChoice.GetString(pos) 
    530531            self.active_prop.mode = tmpMode 
    531              
     532 
    532533            # Get the description 
    533534            tmpDes = self.description.GetValue() 
    534535            self.active_prop.description = tmpDes 
    535                  
     536 
    536537            # Check for the type ex: bool, char, short, etc. 
    537538            pos = self.typeChoice.GetSelection() 
    538539            if pos == wx.NOT_FOUND: 
    539540                errorMsg(self,"Please select a type first!") 
    540                 return  
     541                return 
    541542            tmpType = self.typeChoice.GetString(pos) 
    542543            self.active_prop.type = tmpType 
    543          
     544 
    544545            if self.elementType == "Simple": 
    545546                # store the default value and the value 
     
    547548                    errorMsg(self,"Please enter a value first!") 
    548549                    return 
    549                      
     550 
    550551                v = self.valueList.GetItem(0,0) 
    551552                dv = self.valueList.GetItem(0,1) 
    552553                self.active_prop.value = v.GetText() 
    553554                self.active_prop.defaultValue = dv.GetText() 
    554                  
     555 
    555556            if self.elementType == "SimpleSequence": 
    556557                # store the default value and the value 
     
    558559                    errorMsg(self,"Please enter a value first!") 
    559560                    return 
    560                 
     561 
    561562                self.active_prop.values = [] 
    562563                self.active_prop.defaultValues = [] 
    563                     
     564 
    564565                for x in range(self.valueList.GetItemCount()): 
    565566                    v = self.valueList.GetItem(x,0) 
    566567                    dv = self.valueList.GetItem(x,1) 
    567                  
     568 
    568569                    self.active_prop.values.append(v.GetText()) 
    569570                    self.active_prop.defaultValues.append(dv.GetText()) 
    570      
     571 
    571572            # store the enum if any 
    572573            self.active_prop.enum = self.enumBox.GetLineText(0) 
    573                  
     574 
    574575            # Check for the kind ex: allocation, configure, test, etc. 
    575576            pos = self.kindChoice.GetSelection() 
    576577            if pos == wx.NOT_FOUND: 
    577578                errorMsg(self,"Please select a kind first!") 
    578                 return  
     579                return 
    579580            self.active_prop.kind = self.kindChoice.GetString(pos) 
    580                   
     581 
    581582            # Check and store the range 
    582583            tmpMin = self.minBox.GetLineText(0) 
    583584            tmpMax = self.maxBox.GetLineText(0) 
    584                  
     585 
    585586            if tmpMin == 'min' or tmpMin == '': 
    586587                tmpMin = -1 
    587                  
     588 
    588589            if tmpMax == 'max' or tmpMax == '': 
    589590                tmpMax = -1 
    590                      
     591 
    591592            self.active_prop.range = (tmpMin,tmpMax) 
    592                  
     593 
    593594            # Check and store the action 
    594595            pos = self.actionChoice.GetSelection() 
     
    596597                if self.active_prop.kind == "allocation": 
    597598                    errorMsg(self,"Please select an action first!") 
    598                     return  
     599                    return 
    599600            else: 
    600601                self.active_prop.action = self.actionChoice.GetString(pos) 
    601                  
     602 
    602603        else: 
    603604            if self.elementType == "Simple": 
     
    606607                    errorMsg(self,"Please enter a value first!") 
    607608                    return 
    608                      
     609 
    609610                v = self.valueList.GetItem(0,0) 
    610611                dv = self.valueList.GetItem(0,1) 
    611612                self.active_prop.value = v.GetText() 
    612613                self.active_prop.defaultValue = dv.GetText() 
    613                  
     614 
    614615            if self.elementType == "SimpleSequence": 
    615616                # store the default value and the value 
     
    617618                    errorMsg(self,"Please enter a value first!") 
    618619                    return 
    619                 
     620 
    620621                self.active_prop.values = [] 
    621622                self.active_prop.defaultValues = [] 
    622                     
     623 
    623624                for x in range(self.valueList.GetItemCount()): 
    624625                    v = self.valueList.GetItem(x,0) 
     
    626627                    self.active_prop.values.append(v.GetText()) 
    627628                    self.active_prop.defaultValues.append(dv.GetText()) 
    628                      
     629 
    629630        self.Close() 
    630          
     631 
    631632    def OnKindChoiceChoice(self, event): 
    632633        self.refreshDisplay() 
    633634        event.Skip() 
    634          
    635 #-------------------------------------------------------------------------------     
    636 # 
    637 # UUID Generator 
    638 # 
    639 def uuidgen(): 
    640    return commands.getoutput('uuidgen -t') 
    641          
  • ossiedev/branches/jsnyder/ComponentProject/WaveDev/wavedev/XML_gen/application_gen.py

    r7383 r7435  
    1919import sys 
    2020import commands 
    21 import os  
     21import os 
    2222import shutil 
    2323import component_gen 
     
    2626#import xmlBeautify 
    2727import WaveDev.wavedev.ComponentClass as CC 
    28  
    29  
    30 # UUID Generator 
    31 def uuidgen(): 
    32    return commands.getoutput('uuidgen -t') 
     28from WaveDev.wavedev.uuidgen import uuidgen 
     29 
    3330 
    3431try: 
     
    4542commentLine = u'<!--Created with OSSIE WaveDev ' + version \ 
    4643    + u'-->\n<!--Powered by Python-->\n' 
    47      
     44 
    4845 
    4946xmlpath = u'/xml/' 
    5047####################################################################### 
    5148# genxml generates xml profiles for each component and the waveform 
    52 #######################################################################     
    53 def genxml(complist, genPath, waveName): 
     49####################################################################### 
     50def genxml(complist, genPath, wavedevPath, waveName): 
    5451 
    5552    if genPath[len(genPath)-1] != '/': 
    5653        genPath = genPath + '/' 
    5754    genPath = unicode(genPath) 
     55    if wavedevPath[len(wavedevPath)-1] != '/': 
     56        wavedevPath = wavedevPath + '/' 
    5857    waveformDir = unicode(genPath + waveName + '/') 
    5958 
    60     
     59 
    6160    appName = unicode(waveName) 
    6261    #namingServicePrefix = u'ossie' 
    6362    outputFilename_sad = appName + u'.sad.xml' 
    64     
     63 
    6564    # Generate the individual component xml files 
    6665    for n in complist: 
    6766        if n.generate: 
    68             component_gen.gen_scd(n, genPath) 
    69             component_gen.gen_spd(n, genPath) 
    70             component_gen.gen_prf(n, genPath)       
    71     
     67            component_gen.gen_scd(n, genPath, wavedevPath) 
     68            component_gen.gen_spd(n, genPath, wavedevPath) 
     69            component_gen.gen_prf(n, genPath, wavedevPath) 
     70 
    7271    #---------------------------------------------------------------------------- 
    7372    # SAD Parser / Generator 
    7473    # 
    75     
     74 
    7675    # Use the minidom module to objectify and generate the SAD file 
    7776    try:  #if running from wavedev 
    78         doc_sad = xml.dom.minidom.parse('XML_gen/_sad.xml.tpl') 
     77        doc_sad = xml.dom.minidom.parse(wavedevPath + 'XML_gen/_sad.xml.tpl') 
    7978    except:   #if not being called from wavedev, try looking for the file 
    8079        doc_sad = xml.dom.minidom.parse('/sdr/tools/WaveDev/wavedev/XML_gen/_sad.xml.tpl') 
     
    8281    doc_sad.getElementsByTagName("softwareassembly")[0].setAttribute("name", u'OSSIE::' + appName ) 
    8382    doc_sad.getElementsByTagName("softwareassembly")[0].setAttribute("id", u'DCE:' + unicode(uuidgen()) ) 
    84      
     83 
    8584    # get root nodes for componentfiles, partitioning, assemblycontroller, and connections tags 
    8685    componentfilesNode = doc_sad.getElementsByTagName("componentfiles")[0] 
     
    8887    assemblycontrollerNode = doc_sad.getElementsByTagName("assemblycontroller")[0] 
    8988    connectionsNode = doc_sad.getElementsByTagName("connections")[0] 
    90      
    91     baseComponentList = []  
     89 
     90    baseComponentList = [] 
    9291    for n in complist: 
    9392        # Generate the componentfile entries 
    9493        #tmpid = unicode(n.name) + u'_' + unicode(uuidgen()) 
    9594        tmpid = unicode(n.baseName) + u'_' + unicode(n.file_uuid) 
    96          
     95 
    9796        if n.baseName not in baseComponentList: 
    9897            baseComponentList.append(n.baseName) 
     
    136135                except: 
    137136                    pass 
    138                          
     137 
    139138        if overload_flag: 
    140139            componentpropertiesNode = doc_sad.createElement("componentproperties") 
     
    184183        namingserviceNode.setAttribute("name", NSname) 
    185184        findcomponentNode.appendChild(namingserviceNode) 
    186          
     185 
    187186        #TODO: append child nodes to componentplacement 
    188187        componentinstantiationNode.appendChild(usagenameNode) 
     
    244243                c1name = "DomainName1/USRP1" 
    245244            namingserviceUsesNode.setAttribute("name", c1name) 
    246              
     245 
    247246            # Append child nodes 
    248247            usesidentifierNode.appendChild(usesidentifierTextNode) 
     
    250249            usesportNode.appendChild(usesidentifierNode) 
    251250            usesportNode.appendChild(findbyUsesNode) 
    252              
     251 
    253252            if devFlag != True: 
    254253                providesportNode = doc_sad.createElement("providesport") 
     
    258257                namingserviceProvidesNode = doc_sad.createElement("namingservice") 
    259258                namingserviceProvidesNode.setAttribute("name", c2name) 
    260                  
     259 
    261260                # Make connections 
    262261                providesidentifierNode.appendChild(providesidentifierTextNode) 
     
    285284            assemblycontroller_id = u'DCE:' + unicode(n.uuid) 
    286285            assemblycontrollerNode.getElementsByTagName("componentinstantiationref")[0].setAttribute("refid", assemblycontroller_id) 
    287          
     286 
    288287    # Define <!DOCTYPE> here (overriding template if necessary) 
    289288    doc_sad.doctype.name = u'softwareassembly' 
     
    301300################################################################################ 
    302301# Generate the Device Assignment Sequence 
    303 def genDAS(complist, path, waveName): 
     302def genDAS(complist, path, wavedevPath, waveName): 
    304303    if path[len(path)-1] != '/': 
    305304        path = path + '/' 
     
    312311    try: 
    313312        # try to find the DAS template using a relative path (being called by OWD) 
    314         doc_das = xml.dom.minidom.parse('XML_gen/_DAS.xml.tpl') 
    315     except:  
    316         # try to find the DAS template using an absolute path  
    317         # (being called by other application)   
     313        doc_das = xml.dom.minidom.parse(wavedevPath + 'XML_gen/_DAS.xml.tpl') 
     314    except: 
     315        # try to find the DAS template using an absolute path 
     316        # (being called by other application) 
    318317        # if DAS file is still not found, should throw an IO Error 
    319318        doc_das = xml.dom.minidom.parse('/sdr/tools/WaveDev/wavedev/XML_gen/_DAS.xml.tpl') 
     
    330329            continue 
    331330        tmpDev = u'DCE:' + unicode(n.device.uuid) 
    332          
     331 
    333332        deviceassignmenttypeNode = doc_das.createElement("deviceassignmenttype") 
    334333        componentidNode = doc_das.createElement("componentid") 
     
    354353################################################################################ 
    355354# Generate the DeviceManager XML files 
    356 def genDeviceManager(node,path,wavName,dmName,folder=False): 
     355def genDeviceManager(node, path, wavedevPath, wavName, dmName, folder = False): 
    357356    if path[len(path)-1] != '/': 
    358357        path = path + '/' 
    359358    path += wavName + '/' 
    360      
     359 
    361360    waveformDir = path 
    362361    if folder == True: 
    363         if os.path.exists(path + node.name) == False:    
     362        if os.path.exists(path + node.name) == False: 
    364363            os.mkdir(path + node.name) 
    365364        path += node.name + '/' 
    366      
     365 
    367366    #Generate the DCD file for the Device Manager 
    368     genDCD(node.Devices,path,node.name,dmName,folder,node.generate,node.id)  
    369      
     367    genDCD(node.Devices, path, wavedevPath, node.name, dmName, folder, node.generate, node.id) 
     368 
    370369    outputFilename_spd = dmName + '.spd.xml' 
    371370    outputFilename_scd = dmName + '.scd.xml' 
    372371    outputFilename_prf = dmName + '.prf.xml' 
    373      
     372 
    374373    #Copy and modify the spd file 
    375     doc_spd = xml.dom.minidom.parse('XML_gen/DevMan/_spd.xml.tpl') 
     374    doc_spd = xml.dom.minidom.parse(wavedevPath + 'XML_gen/DevMan/_spd.xml.tpl') 
    376375    doc_spd.getElementsByTagName("softpkg")[0].setAttribute("name", dmName) 
    377376    localfileNode = doc_spd.getElementsByTagName("descriptor")[0].getElementsByTagName("localfile")[0] 
    378377    localfileNode.setAttribute("name", unicode(dmName) + u'.scd.xml') 
    379      
     378 
    380379    # Define <!DOCTYPE> here (overriding template if necessary) 
    381380    doc_spd.doctype.name = u'softpkg' 
     
    388387    # Copy the scd and prf files to directory - these aren't changed yet 
    389388    print "Performing a copy to: " + path + outputFilename_scd 
    390     shutil.copyfile('XML_gen/DevMan/_scd.xml.tpl', path + outputFilename_scd) 
    391     shutil.copyfile('XML_gen/DevMan/_prf.xml.tpl', path + outputFilename_prf) 
    392      
    393      
     389    shutil.copyfile(wavedevPath + 'XML_gen/DevMan/_scd.xml.tpl', path + outputFilename_scd) 
     390    shutil.copyfile(wavedevPath + 'XML_gen/DevMan/_prf.xml.tpl', path + outputFilename_prf) 
     391 
     392 
    394393 
    395394################################################################################ 
    396 # Generate the DeviceManager DCD.xml file     
    397 def genDCD(devlist,path,nodeName,dmName='DeviceManager',folder=False,generate=True,devconf=""): 
    398              
     395# Generate the DeviceManager DCD.xml file 
     396def genDCD(devlist, path, wavedevPath, nodeName, dmName = 'DeviceManager', folder = False, generate = True, devconf = ""): 
     397 
    399398    outputFilename_dcd = dmName + '.dcd.xml' 
    400      
    401     doc_dcd = xml.dom.minidom.parse('XML_gen/_dcd.xml.tpl') 
     399 
     400    doc_dcd = xml.dom.minidom.parse(wavedevPath + 'XML_gen/_dcd.xml.tpl') 
    402401 
    403402    deviceconfigurationNode = doc_dcd.getElementsByTagName("deviceconfiguration")[0] 
     
    412411    devicemanagersoftpkgNode = deviceconfigurationNode.getElementsByTagName("devicemanagersoftpkg")[0] 
    413412    devicemanagersoftpkgNode.getElementsByTagName("localfile")[0].setAttribute("name", unicode(dmName) + u'.spd.xml') 
    414      
     413 
    415414    baseDeviceList = [] 
    416415    componentfilesNode = deviceconfigurationNode.getElementsByTagName("componentfiles")[0] 
     
    425424            componentfileNode.setAttribute("type", "SPD") 
    426425            componentfileNode.setAttribute("id", tmpid) 
    427              
     426 
    428427            localcomponentfileNode = doc_dcd.createElement("localfile") 
    429428            localcomponentfileNode.setAttribute("name", unicode(xmlpath + n.baseName + '/' + n.baseName + '.spd.xml') ) 
     
    431430            componentfileNode.appendChild(localcomponentfileNode) 
    432431            componentfilesNode.appendChild(componentfileNode) 
    433     
     432 
    434433        # Generate the partitioning entries 
    435434        componentplacementNode = doc_dcd.createElement("componentplacement") 
     
    457456 
    458457 
    459 def writeWaveSetuppy(wavePath,waveName): 
     458def writeWaveSetuppy(wavePath, wavedevPath, waveName): 
    460459    ''' 
    461     ##############################################################################  
     460    ############################################################################## 
    462461    ## writeWaveSetuppy - generates the setup.py file for a waveform 
    463462    ############################################################################## 
     
    468467 
    469468    #copy over the readme file 
    470     shutil.copy('XML_gen/README', wavePath) 
    471   
     469    shutil.copy(wavedevPath + 'XML_gen/README', wavePath) 
     470 
    472471    output = open(wavePath + '/setup.py','w') 
    473472    ts = "\ 
     
    488487         "',data_files=[(install_location+'/waveforms/" + waveName + "',['" + \ 
    489488         waveName + ".sad.xml', '" + waveName + "_DAS.xml'])])" 
    490     output.writelines(ts)    
     489    output.writelines(ts) 
    491490 
    492491    output.close()   #done creating the file 
  • ossiedev/branches/jsnyder/ComponentProject/WaveDev/wavedev/XML_gen/component_gen.py

    r7383 r7435  
    2424import xml.dom.minidom 
    2525from xml.dom.minidom import Node 
     26from WaveDev.wavedev.uuidgen import uuidgen 
    2627 
    2728#import xmlBeautify 
    2829 
    29 # 
    30 # UUID Generator 
    31 # 
    32 def uuidgen(): 
    33    return commands.getoutput('uuidgen -t') 
    34  
    35  
    36 try:  
     30 
     31try: 
    3732   doc_cfg = xml.dom.minidom.parse('../wavedev.cfg') 
    3833except:  #if not being called from wavedev, try looking for wavedev 
     
    4540#version = version.strip('\n') 
    4641commentLine = u'<!--Created with OSSIE WaveDev ' + version \ 
    47     + u'-->\n<!--Powered by Python-->\n'  
     42    + u'-->\n<!--Powered by Python-->\n' 
    4843 
    4944xmlpath = u'xml/' 
    5045binpath = u'bin/' 
    5146 
    52 def gen_scd(comp, waveformDir): 
     47def gen_scd(comp, waveformDir, wavdevPath): 
    5348    # Generate the componentfile entries 
    54     doc_scd = xml.dom.minidom.parse('XML_gen/_scd.xml.tpl') 
    55      
     49    doc_scd = xml.dom.minidom.parse(wavedevPath + 'XML_gen/_scd.xml.tpl') 
     50 
    5651    int_types = {} 
    5752 
    5853    portsNode = doc_scd.getElementsByTagName("ports")[0] 
    59      
     54 
    6055    # add provides ports to .scd.xml file 
    6156    for p in comp.ports: 
     
    7469        # append new provides port to <ports> 
    7570        portsNode.appendChild(providesPortNode) 
    76          
     71 
    7772        if p.interface.name not in int_types: 
    7873            int_types[p.interface.name] = copy.deepcopy(p.interface) 
    7974 
    8075        del providesPortNode, portTypeNode 
    81      
     76 
    8277    # add uses ports to .scd.xml file 
    8378    for p in comp.ports: 
     
    9388        portTypeNode.setAttribute("type", unicode(p.portType)) 
    9489        usesPortNode.appendChild(portTypeNode) 
    95          
     90 
    9691        # append new uses port to <ports> 
    9792        portsNode.appendChild(usesPortNode) 
    98          
     93 
    9994        if p.interface.name not in int_types: 
    10095            int_types[p.interface.name] = copy.deepcopy(p.interface) 
    10196 
    10297        del usesPortNode, portTypeNode 
    103      
     98 
    10499    # Add interfaces 
    105100    interfacesRootNode = doc_scd.getElementsByTagName("softwarecomponent")[0].getElementsByTagName("interfaces")[0] 
     
    119114    #doc_scd.doctype.name = u'softwarecomponent' 
    120115    #doc_scd.doctype.systemId = u'../dtd/softwarecomponent.dtd' 
    121      
     116 
    122117    outfile = open(compDir + outputFileName_scd, 'w') 
    123118    doc_scd.writexml( outfile, encoding='UTF-8' ) 
    124119    outfile.close() 
    125     
    126 def gen_spd(comp, waveformDir): 
    127     componentName = unicode(comp.name)     
     120 
     121def gen_spd(comp, waveformDir, wavedevPath): 
     122    componentName = unicode(comp.name) 
    128123    componentDescr = unicode(comp.description) 
    129      
    130     doc_spd = xml.dom.minidom.parse('XML_gen/_spd.xml.tpl') 
    131     
     124 
     125    doc_spd = xml.dom.minidom.parse(wavedevPath + 'XML_gen/_spd.xml.tpl') 
     126 
    132127    #doc_spd.softpkg.name = u'ossie' + componentName + u'Resource' 
    133128    softpkgNode = doc_spd.getElementsByTagName("softpkg")[0] 
    134129    softpkgNode.setAttribute("name",componentName) 
    135130    softpkgNode.setAttribute("id", u'DCE:' + unicode(uuidgen()) ) 
    136      
     131 
    137132    # set the general resource description 
    138133    # note: this is NOT the description of the implementation 
     
    146141    propertyfilePathNode = softpkgNode.getElementsByTagName("propertyfile")[0].getElementsByTagName("localfile")[0] 
    147142    propertyfilePathNode.setAttribute("name", xmlpath + componentName  + '/' + componentName + u'.prf.xml') 
    148      
     143 
    149144    # set the descriptor file path 
    150145    descriptorPathNode = softpkgNode.getElementsByTagName("descriptor")[0].getElementsByTagName("localfile")[0] 
    151146    descriptorPathNode.setAttribute("name", xmlpath + componentName + '/' + componentName + u'.scd.xml') 
    152      
     147 
    153148    # set the implementation id 
    154149    implementationNode = softpkgNode.getElementsByTagName("implementation")[0] 
     
    156151    implementationNode.getElementsByTagName("code")[0].getElementsByTagName("localfile")[0].setAttribute( \ 
    157152        "name", binpath + componentName) 
    158      
     153 
    159154    # Now do final processing and write to file 
    160155    compDir = waveformDir + comp.name + '/' 
    161156    outputFileName_spd = comp.name + '.spd.xml' 
    162157    #outputFileName_spd = comp.name + 'Resource' + '.spd.xml' 
    163      
     158 
    164159    # Define <!DOCTYPE> here (overriding template if necessary) 
    165160    #doc_spd.doctype.name = u'softpkg' 
    166161    #doc_spd.doctype.systemId = u'../dtd/softpkg.dtd' 
    167      
     162 
    168163    outfile = open(compDir + outputFileName_spd, 'w') 
    169164    doc_spd.writexml( outfile, encoding='UTF-8' ) 
    170165    outfile.close() 
    171      
    172 def gen_prf(comp, waveformDir): 
    173     componentName = unicode(comp.name)     
    174     doc_prf = xml.dom.minidom.parse('XML_gen/_prf.xml.tpl') 
    175      
     166 
     167def gen_prf(comp, waveformDir, wavedevPath): 
     168    componentName = unicode(comp.name) 
     169    doc_prf = xml.dom.minidom.parse(wavedevPath + 'XML_gen/_prf.xml.tpl') 
     170 
    176171    propertiesNode = doc_prf.getElementsByTagName("properties")[0] 
    177172 
     
    210205        descriptionNode.appendChild(descriptionText) 
    211206        e.appendChild(descriptionNode) 
    212              
     207 
    213208        # Add the property kind 
    214209        kindNode = doc_prf.createElement("kind") 
     
    217212 
    218213        propertiesNode.appendChild(e) 
    219              
     214 
    220215    # Create a simplesequence of string type that lists each Provides port in the component 
    221216    # Used for connecting to components from outside the framework (ex. control gui) 
     
    256251 
    257252        propertiesNode.appendChild(e) 
    258      
     253 
    259254    # Now do final processing and write to file 
    260255    compDir = waveformDir + comp.name + '/' 
    261256    outputFileName_prf = comp.name + '.prf.xml' 
    262257    #outputFileName_prf = comp.name + 'Resource' + '.prf.xml' 
    263      
     258 
    264259    # Define <!DOCTYPE> here (overriding template if necessary) 
    265260    #doc_prf.doctype.name = u'properties' 
    266261    #doc_prf.doctype.systemId = u'../dtd/properties.dtd' 
    267      
     262 
    268263    outfile = open(compDir + outputFileName_prf, 'w') 
    269264    doc_prf.writexml( outfile, encoding='UTF-8' ) 
  • ossiedev/branches/jsnyder/ComponentProject/WaveDev/wavedev/generate/genNode.py

    r5915 r7435  
    2323 
    2424class genAll: 
    25   def __init__(self,path,node): 
     25  def __init__(self, path, wavedevPath, node): 
    2626    if path[len(path)-1] != '/': 
    2727        path = path + '/' 
     28    self.path = path 
     29    if wavedevPath[len(wavedevPath)-1] != '/': 
     30        wavedevPath = wavedevPath + '/' 
    2831    self.path = path 
    2932    self.node = node 
     
    3740       errorMsg(self,"Node already exists - exiting") 
    3841       exit(1) 
    39         
    40     if os.path.exists(self.path+self.node.name) == False:    
     42 
     43    if os.path.exists(self.path+self.node.name) == False: 
    4144        os.mkdir(self.path + self.node.name) 
    42          
    43     shutil.copy('generate/reconf',self.path + self.node.name) 
    44                  
     45 
     46    shutil.copy(self.wavedevPath + 'generate/reconf',self.path + self.node.name) 
     47 
    4548  ############################################################################## 
    4649  ## writeMakefiles - generates the make file for the waveform and then calls 
     
    5255    Flags = ["-Wall"] 
    5356    self.info2str(output,"AM_CXXFLAGS = ",Flags,1) 
    54      
     57 
    5558    tstr = "ossieName = " + self.node.name + '\n\n' 
    5659    output.write(tstr) 
    57      
     60 
    5861    tstr = "waveformdir = $(prefix)/nodes/$(ossieName)\n" 
    5962    output.write(tstr) 
     
    8184      if mycount%2 == 0 and wrap and mylist.index(x) != len(mylist)-1: 
    8285        tstr = tstr + "\\\n" 
    83    
     86 
    8487    tstr = tstr + "\n" 
    8588    for x in range(extraLine): 
     
    9396  def genConfigureACFiles(self,installPath="/sdr/sca"): 
    9497    if installPath[-1] == '/': 
    95         installPath = installPath[0:-1]   
    96        
     98        installPath = installPath[0:-1] 
     99 
    97100    tmpPath = self.path + self.node.name + '/' 
    98101    self.writeConfAC(tmpPath,self.node.name,False,False,installPath) 
    99          
     102 
    100103  ############################################################################## 
    101104  ## writeConfAC - generates configure.ac files for autoconf 
     
    104107     if genPath[len(genPath)-1] != '/': 
    105108        genPath = genPath + '/' 
    106        
     109 
    107110     output = open(genPath + 'configure.ac','w') 
    108111     tstr = "AC_INIT(" + name + ", 0.5.0)\n\n" 
     
    116119     output.write(tstr) 
    117120     output.close() 
    118      
    119   ##############################################################################       
     121 
     122  ############################################################################## 
    120123  ## This function generates the cpp and h files for each component: 
    121124  ## component.h, component.cpp, main.cpp, port_impl.h, and port_impl.cpp 
    122   ##############################################################################       
     125  ############################################################################## 
    123126  def genCompFiles(self,comp): 
    124127      #for x in self.active_wave.components: 
    125128        # generate the .h files for each component 
    126         inputH = open('generate/sampleComp.h','r') 
     129        inputH = open(self.wavedevPath + 'generate/sampleComp.h','r') 
    127130        outputH = open(self.path + comp.name + "/" + comp.name + ".h",'w') 
    128131        self.addGPL(outputH,comp.name) 
     
    147150                  l_out = l_out.replace("__ACE_SVC_DECL__",'int svc(void);\n        size_t queue_size;') 
    148151              else: 
    149                   continue    
     152                  continue 
    150153          if l_out.find("__FRIEND_DECL__") != -1: 
    151154              l_out = l_out.replace("__FRIEND_DECL__","") 
    152155              self.writeFriendDecl(outputH,comp) 
    153156              continue 
    154                     
     157 
    155158          outputH.write(l_out) 
    156            
     159 
    157160        inputH.close() 
    158161        outputH.close() 
    159          
     162 
    160163        # generate the .cpp files for each component 
    161         inputCPP = open('generate/sampleComp.cpp','r') 
     164        inputCPP = open(self.wavedevPath + 'generate/sampleComp.cpp','r') 
    162165        outputCPP = open(self.path + comp.name + "/" + comp.name + ".cpp",'w') 
    163166        self.addGPL(outputCPP,comp.name) 
     
    181184              if comp.ace == True: 
    182185                  self.writeACESvcDef(outputCPP,comp,'component',comp.timing, comp) 
    183               continue               
     186              continue 
    184187          outputCPP.write(l_out) 
    185            
     188 
    186189        inputCPP.close() 
    187190        outputCPP.close() 
    188          
     191 
    189192        # generate the main.cpp files for each component 
    190         inputMain = open('generate/sampleMain.cpp','r') 
     193        inputMain = open(self.wavedevPath + 'generate/sampleMain.cpp','r') 
    191194        outputMain = open(self.path + comp.name + "/main.cpp",'w') 
    192195        self.addGPL(outputMain,comp.name) 
    193          
     196 
    194197        for line in inputMain.readlines(): 
    195198          l_out = line.replace("__IncludeFile__",comp.name) 
     
    200203                  l_out = l_out.replace("__CLASS_VAR_ACE__",comp.name.lower()) 
    201204              else: 
    202                   continue           
     205                  continue 
    203206          if l_out.find("__NAME_SPACE__") != -1: 
    204207              ns_list = [] 
     
    211214 
    212215          outputMain.write(l_out) 
    213            
     216 
    214217        inputMain.close() 
    215218        outputMain.close() 
    216          
     219 
    217220        # generate the port_impl.h file 
    218         inputPortImpl = open('generate/port_impl.h','r') 
     221        inputPortImpl = open(self.wavedevPath + 'generate/port_impl.h','r') 
    219222        outputPortImpl = open(self.path + comp.name + "/port_impl.h",'w') 
    220223        self.addGPL(outputPortImpl,comp.name) 
    221         portSample_p = open('generate/port_sample_p.h','r') 
    222         portSample_u = open('generate/port_sample_u.h','r') 
     224        portSample_p = open(self.wavedevPath + 'generate/port_sample_p.h','r') 
     225        portSample_u = open(self.wavedevPath + 'generate/port_sample_u.h','r') 
    223226        for line in inputPortImpl.readlines(): 
    224227            l_out = line.replace("__IncludeFile__",comp.name) 
     
    235238            if l_out.find("__PORT_DECL__") != -1: 
    236239              self.writePortImplDecl(outputPortImpl,portSample_p,portSample_u,comp) 
    237               continue           
     240              continue 
    238241            outputPortImpl.write(l_out) 
    239              
     242 
    240243        inputPortImpl.close() 
    241244        outputPortImpl.close() 
    242245        portSample_p.close() 
    243246        portSample_u.close() 
    244          
     247 
    245248        # generate the port_impl.cpp file 
    246         inputPortImpl = open('generate/port_impl.cpp','r') 
     249        inputPortImpl = open(self.wavedevPath + 'generate/port_impl.cpp','r') 
    247250        outputPortImpl = open(self.path + comp.name + "/port_impl.cpp",'w') 
    248251        self.addGPL(outputPortImpl,comp.name) 
    249         portSample_p = open('generate/port_sample_p.cpp','r') 
    250         portSample_u = open('generate/port_sample_u.cpp','r') 
     252        portSample_p = open(self.wavedevPath + 'generate/port_sample_p.cpp','r') 
     253        portSample_u = open(self.wavedevPath + 'generate/port_sample_u.cpp','r') 
    251254        for line in inputPortImpl.readlines(): 
    252255            l_out = line 
     
    255258              continue 
    256259            outputPortImpl.write(l_out) 
    257              
     260 
    258261        inputPortImpl.close() 
    259262        outputPortImpl.close() 
    260263        portSample_p.close() 
    261264        portSample_u.close() 
    262          
     265 
    263266    # Copy some required files into the main directory 
    264267    #  os.system('cp generate/basic_xml/* ' + self.path) 
     
    275278        output.write(ts) 
    276279    ts = '\n';output.write(ts); 
    277     intList = []  
     280    intList = [] 
    278281    for x in c.ports: 
    279282        if x.interface.name in intList: 
     
    339342                else: 
    340343                    l_out = l_out.replace("__COMP_REF_DECL__","") 
    341                  
     344 
    342345            output.write(l_out) 
    343346 
    344347  def writePortImplDef(self,output,portSample_p,portSample_u,c): 
    345348    """ This function writes port implementation definitions for the port_impl.cpp file""" 
    346     intList = []     
     349    intList = [] 
    347350    for x in c.ports: 
    348351        if x.interface.name in intList: 
     
    419422            outCount += 1 
    420423    ts = " "*8 + "bool component_alive;\n\n" + " "*8 + "string naming_service_name;\n"; output.write(ts) 
    421      
     424 
    422425  def writePortInst(self,output,c): 
    423426    """ This function writes the port instantiations to the component cpp file""" 
     
    442445    ts = "\n"; output.write(ts) 
    443446    ts = " "*4 + "queue_size = DEFAULT_QUEUE_BLOCK_SIZE;\n\n" + " "*4 + "component_alive = true;\n\n" + " "*4 + "naming_service_name = label;\n"; output.write(ts) 
    444      
     447 
    445448  def writeGetPort(self,output,c): 
    446449    """ This function writes the getPort functionality to the component cpp file""" 
     
    475478    ts = "\n"; output.write(ts) 
    476479    ts = " "*4 + 'return NULL;\n'; output.write(ts) 
    477      
     480 
    478481  def writeDelPort(self,output,c): 
    479482    """ This function writes the destructor functionality (for ports) to the component cpp file""" 
     
    492495            outCount += 1 
    493496    ts = "\n"; output.write(ts) 
    494      
     497 
    495498##  def writeACESvcPorts(self,output,c): 
    496499##    """ This function writes the svc port functionality to the component cpp file""" 
     
    501504##            output.write(ts) 
    502505##            outCount += 1 
    503 ##    ts = "\n"; output.write(ts)   
    504      
     506##    ts = "\n"; output.write(ts) 
     507 
    505508  def writeACESvcDef(self, output,c,type,timing_flag, comp=''): 
    506509    """ This function writes the implementation of the svn() function for a given component""" 
     
    693696        ts = " "*8 + "//ACE_OS::sleep (ACE_Time_Value (1));\n"; output.write(ts) 
    694697        ts = " "*4 + '}\n\n' + " "*4 + 'return 0;\n}\n'; output.write(ts) 
    695          
     698 
    696699    if type == 'port': 
    697700        #ts = 'int ' + c.u_cname + '::svc(void)\n{\n'; output.write(ts) 
     
    837840                else: 
    838841                        ts = " "*4 + 'return 0;\n' + '}\n'; output.write(ts) 
    839      
     842 
    840843  def writeTimingMessageDef(self, output,c,type): 
    841844    if type == 'port': 
     
    859862 
    860863  def writeOperation(self,output,i,prefix='',cppFlag=False,in_name='',using_ace=False,comp='',port=''): 
    861     """ Writes the declaration or definition of an operation (pushPacket) to  
     864    """ Writes the declaration or definition of an operation (pushPacket) to 
    862865        the port_impl.h and port_impl.cpp files respectively """ 
    863866    ocount = 0 
    864867    for o in i.operations: 
    865          
     868 
    866869 
    867870        ocount += 1 
     
    876879            ts = prefix + " "*4 + o.returnType + ' ' + o.name + '(' 
    877880            tscxx = prefix + " "*4 + o.cxxReturnType + ' ' + o.name + '(' 
    878          
     881 
    879882        first = True 
    880883        for p in o.params: 
     
    882885            _USE_CONST_ = 'const ' 
    883886            _USE__OUT_ = '' 
    884             if p.direction == 'out':  
     887            if p.direction == 'out': 
    885888                if len(p.dataType) > 8 and p.dataType[-8:] != 'Sequence': 
    886889                    _USE_CONST_ = '' 
     
    913916#        output.write(ts) 
    914917        output.write(tscxx) 
    915          
     918 
    916919        if cppFlag: 
    917920                #ts = "{\n" + " "*4 + "unsigned int len = " + "hello" + ".length();\n"; output.write(ts) 
     
    9981001                else: 
    9991002                        ts = "{\n\n}\n"; output.write(ts) 
    1000          
     1003 
    10011004  def writeFriendDecl(self,output,c): 
    10021005      friendList = [] 
     
    10081011              if p.p_cname not in friendList: 
    10091012                  friendList.append(p.p_cname) 
    1010                    
     1013 
    10111014      for x in friendList: 
    10121015          ts = " "*4 + "friend class " + x + ";\n" 
    1013           output.write(ts)  
    1014        
     1016          output.write(ts) 
     1017 
    10151018 
    10161019  def addGPL(self,outFile,name): 
    1017       inFile = open('generate/gpl_preamble','r') 
     1020      inFile = open(self.wavedevPath + 'generate/gpl_preamble','r') 
    10181021      for line in inFile.readlines(): 
    10191022          l_out = line.replace("__COMP_NAME__",name) 
    10201023          outFile.write(l_out) 
    1021          
     1024 
    10221025      inFile.close() 
    1023            
    1024          
     1026 
     1027 
    10251028  def cleanUp(self): 
    10261029      # Move the AssemblyController to the waveform Dir 
  • ossiedev/branches/jsnyder/ComponentProject/WaveDev/wavedev/generate/templates/custom_ports/genStructure.py

    r5933 r7435  
    2929 
    3030class genAll: 
    31   def __init__(self,path,active_wave): 
     31  def __init__(self, path, wavedevPath, active_wave): 
    3232    if path[len(path)-1] != '/': 
    3333        path = path + '/' 
    3434    self.path = path 
     35    if wavedevPath[len(wavedevPath)-1] != '/': 
     36        wavedevPath = wavedevPath + '/' 
     37    self.wavedevPath = wavedevPath 
    3538    self.active_wave = active_wave 
    3639 
     
    4346       errorMsg(self,"Waveform already exists - exiting") 
    4447       exit(1) 
    45         
    46     if os.path.exists(self.path+self.active_wave.name) == False:    
     48 
     49    if os.path.exists(self.path+self.active_wave.name) == False: 
    4750        os.mkdir(self.path + self.active_wave.name) 
    48       
    49     shutil.copy('generate/reconf',self.path + self.active_wave.name) 
    50     #for x in os.listdir('generate/basic_xml/'): 
     51 
     52    shutil.copy(self.wavedevPath + 'generate/reconf',self.path + self.active_wave.name) 
     53    #for x in os.listdir(self.wavedevPath + 'generate/basic_xml/'): 
    5154    #    if not os.path.isdir(x): 
    52     #        shutil.copy('generate/basic_xml/' + x,self.path + self.active_wave.name) 
    53      
     55    #        shutil.copy(self.wavedevPath + 'generate/basic_xml/' + x,self.path + self.active_wave.name) 
     56 
    5457    for x in self.active_wave.components: 
    5558        if x.generate: 
     
    5760                os.mkdir(self.path+x.name) 
    5861            if x.AssemblyController != True: 
    59                 shutil.copy('generate/reconf',self.path + x.name) 
    60                 #for f in os.listdir('generate/basic_xml/'): 
     62                shutil.copy(self.wavedevPath + 'generate/reconf',self.path + x.name) 
     63                #for f in os.listdir(self.wavedevPath + 'generate/basic_xml/'): 
    6164                #    if not os.path.isdir(f): 
    62                 #        shutil.copy('generate/basic_xml/' + f,self.path + x.name) 
    63                 shutil.copy('generate/LICENSE',self.path + x.name) 
    64                  
     65                #        shutil.copy(self.wavedevPath + 'generate/basic_xml/' + f,self.path + x.name) 
     66                shutil.copy(self.wavedevPath + 'generate/LICENSE',self.path + x.name) 
     67 
    6568  ############################################################################## 
    6669  ## writeMakefiles - generates the make file for the waveform and then calls 
     
    7275    Flags = ["-Wall"] 
    7376    self.info2str(output,"AM_CXXFLAGS = ",Flags,1) 
    74      
     77 
    7578    tstr = "ossieName = " + self.active_wave.name + '\n\n' 
    7679    output.write(tstr) 
    77      
     80 
    7881    tstr = "SUBDIRS = " 
    7982    for c in self.active_wave.components: 
    8083        if c.AssemblyController == True and c.generate: 
    8184            tstr += c.name + '\n\n' 
    82             output.write(tstr)     
    83      
     85            output.write(tstr) 
     86 
    8487#    tstr = "waveformdir = $(prefix)/dom/waveforms/$(ossieName)\n" 
    8588    tstr = "waveformdir = $(prefix)/waveforms/" + self.active_wave.name + "\n" 
     
    105108 
    106109    output.close() 
    107      
     110 
    108111    for c in self.active_wave.components: 
    109112        if c.generate: 
    110113            tmpPath = self.path + c.name 
    111114            self.writeCompMakefile(c,tmpPath) 
    112              
    113   ##############################################################################  
     115 
     116  ############################################################################## 
    114117  ## writeCompMakefilee - generates the make file for an indivdual component 
    115118  ############################################################################## 
     
    117120    if compPath[len(compPath)-1] != '/': 
    118121        compPath = compPath + '/' 
    119      
     122 
    120123    header = "%SK.cpp %.h : %.idl\n\t@IDL@ @IDL_FLAGS@ " 
    121124    header += "-bcxx -Wbh=.h -Wbs=SK.cpp -Wbkeep_inc_path $<\n\n" 
    122125    header += "%.idl :\n\tcp @SI_PATH@/standardinterfaces/$@ .\n" 
    123      
     126 
    124127    Flags = ["-Wall"] 
    125      
     128 
    126129    output = open(compPath + 'Makefile.am','w') 
    127130    output.writelines(header + "\n") 
    128131    self.info2str(output,"AM_CXXFLAGS = ",Flags,1) 
    129        
     132 
    130133    BuiltSources = [] 
    131134    CleanFiles = [] 
     
    150153        nodist.append(x.interface.filename+'SK.cpp') 
    151154        tempIntList.append(x.interface.filename) 
    152        
     155 
    153156    self.info2str(output,"BUILT_SOURCES = ",BuiltSources,wrapFlag=True) 
    154157    self.info2str(output,"CLEANFILES = ",CleanFiles,1) 
    155        
     158 
    156159    tstr = "ossieName = " + comp.name + "\n" 
    157160    output.write(tstr) 
    158161    tstr = "bin_PROGRAMS = " + comp.name + "\n\n" 
    159162    output.write(tstr) 
    160        
     163 
    161164    tstr = "xmldir = $(prefix)/xml/$(ossieName)\n" 
    162165    output.write(tstr) 
     
    168171    xmlData.append(tstr2 + ".spd.xml") 
    169172    self.info2str(output,"dist_xml_DATA = ",xmlData,1,wrapFlag=True) 
    170        
     173 
    171174    tstr = comp.name + "_SOURCES = " + comp.name+".cpp " + comp.name+".h " 
    172175    tstr += "main.cpp port_impl.cpp port_impl.h\n" 
    173     output.write(tstr)     
     176    output.write(tstr) 
    174177    self.info2str(output,"nodist_"+comp.name+"_SOURCES = ",nodist,1) 
    175      
     178 
    176179    output.close() 
    177180 
     
    188191      if mycount%2 == 0 and wrap and mylist.index(x) != len(mylist)-1: 
    189192        tstr = tstr + "\\\n" 
    190    
     193 
    191194    tstr = tstr + "\n" 
    192195    for x in range(extraLine): 
     
    200203  def genConfigureACFiles(self,installPath="/sdr/sca"): 
    201204    if installPath[-1] == '/': 
    202         installPath = installPath[0:-1]   
    203        
     205        installPath = installPath[0:-1] 
     206 
    204207    tmpPath = self.path + self.active_wave.name + '/' 
    205208    self.writeConfAC(tmpPath,self.active_wave.name,self.active_wave.ace,True,installPath) 
    206      
     209 
    207210    for c in self.active_wave.components: 
    208211        if c.AssemblyController ==  True or not c.generate: 
    209212            continue 
    210213        tmpPath = self.path + c.name + '/' 
    211         self.writeConfAC(tmpPath,c.name,c.ace,c.timing,False,installPath) 
    212          
     214        self.writeConfAC(tmpPath,c.name,c.ace, #c.timing, 
     215                         False,installPath) 
     216 
    213217  ############################################################################## 
    214218  ## writeConfAC - generates configure.ac files for autoconf 
     
    217221     if genPath[len(genPath)-1] != '/': 
    218222        genPath = genPath + '/' 
    219        
     223 
    220224     output = open(genPath + 'configure.ac','w') 
    221225     tstr = "AC_INIT(" + name + ", 0.5.0)\nAM_INIT_AUTOMAKE\n\n" 
     
    269273     tstr = 'IDL_FLAGS="$OSSIE_CFLAGS"\nAC_SUBST(IDL_FLAGS)\n\n' 
    270274     output.write(tstr) 
    271       
     275 
    272276     if aceFlag == True: 
    273277         tstr = 'PKG_CHECK_MODULES(ACE, ACE >= 5.4.7)\n' 
    274278         tstr = tstr + 'AC_SUBST(ACE_CFLAGS)\nAC_SUBST(ACE_LIBS)\nLIBS="$LIBS $ACE_LIBS"\n\n' 
    275279         output.write(tstr) 
    276       
    277      tstr = "AC_CONFIG_FILES(Makefile"      
     280 
     281     tstr = "AC_CONFIG_FILES(Makefile" 
    278282     if wavFlag == True: 
    279283        for x in self.active_wave.components: 
     
    281285                tstr2 = " " + x.name + "/Makefile" 
    282286                tstr = tstr + tstr2 
    283             
    284      tstr = tstr + ")\n\n"  
     287 
     288     tstr = tstr + ")\n\n" 
    285289     output.write(tstr) 
    286290 
     
    289293 
    290294     output.close() 
    291      
    292   ##############################################################################       
     295 
     296  ############################################################################## 
    293297  ## This function generates the cpp and h files for each component: 
    294298  ## component.h, component.cpp, main.cpp, port_impl.h, and port_impl.cpp 
    295   ##############################################################################       
     299  ############################################################################## 
    296300  def genCompFiles(self,comp): 
    297301      #for x in self.active_wave.components: 
    298302        # generate the .h files for each component 
    299         inputH = open('generate/templates/custom_ports/sampleComp.h','r') 
     303        inputH = open(self.wavedevPath + 'generate/templates/custom_ports/sampleComp.h','r') 
    300304        outputH = open(self.path + comp.name + "/" + comp.name + ".h",'w') 
    301305        self.addGPL(outputH,comp.name) 
     
    320324                  l_out = l_out.replace("__ACE_SVC_DECL__",'int svc(void);\n        size_t queue_size;') 
    321325              else: 
    322                   continue    
     326                  continue 
    323327          if l_out.find("__FRIEND_DECL__") != -1: 
    324328              l_out = l_out.replace("__FRIEND_DECL__","") 
    325329              self.writeFriendDecl(outputH,comp) 
    326330              continue 
    327                     
     331 
    328332          outputH.write(l_out) 
    329            
     333 
    330334        inputH.close() 
    331335        outputH.close() 
    332          
     336 
    333337        # generate the .cpp files for each component 
    334         inputCPP = open('generate/templates/custom_ports/sampleComp.cpp','r') 
     338        inputCPP = open(self.wavedevPath + 'generate/templates/custom_ports/sampleComp.cpp','r') 
    335339        outputCPP = open(self.path + comp.name + "/" + comp.name + ".cpp",'w') 
    336340        self.addGPL(outputCPP,comp.name) 
     
    355359              if comp.ace == True: 
    356360                  self.writeACESvcDef(outputCPP,comp,'component',comp.timing, comp) 
    357               continue               
     361              continue 
    358362          outputCPP.write(l_out) 
    359            
     363 
    360364        inputCPP.close() 
    361365        outputCPP.close() 
    362          
     366 
    363367        # generate the main.cpp files for each component 
    364         inputMain = open('generate/templates/custom_ports/sampleMain.cpp','r') 
     368        inputMain = open(self.wavedevPath + 'generate/templates/custom_ports/sampleMain.cpp','r') 
    365369        outputMain = open(self.path + comp.name + "/main.cpp",'w') 
    366370        self.addGPL(outputMain,comp.name) 
    367          
     371 
    368372        for line in inputMain.readlines(): 
    369373          l_out = line.replace("__IncludeFile__",comp.name) 
     
    375379                  l_out = l_out.replace("__CLASS_VAR_ACE__",comp.name.lower()) 
    376380              else: 
    377                   continue           
     381                  continue 
    378382          if l_out.find("__NAME_SPACE__") != -1: 
    379383              ns_list = [] 
     
    386390 
    387391          outputMain.write(l_out) 
    388            
     392 
    389393        inputMain.close() 
    390394        outputMain.close() 
    391          
     395 
    392396        # generate the port_impl.h file 
    393         inputPortImpl = open('generate/templates/custom_ports/port_impl.h','r') 
     397        inputPortImpl = open(self.wavedevPath + 'generate/templates/custom_ports/port_impl.h','r') 
    394398        outputPortImpl = open(self.path + comp.name + "/port_impl.h",'w') 
    395399        self.addGPL(outputPortImpl,comp.name) 
    396         portSample_p = open('generate/templates/custom_ports/port_sample_p.h','r') 
    397         portSample_u = open('generate/templates/custom_ports/port_sample_u.h','r') 
     400        portSample_p = open(self.wavedevPath + 'generate/templates/custom_ports/port_sample_p.h','r') 
     401        portSample_u = open(self.wavedevPath + 'generate/templates/custom_ports/port_sample_u.h','r') 
    398402        for line in inputPortImpl.readlines(): 
    399403            l_out = line.replace("__IncludeFile__",comp.name) 
     
    410414            if l_out.find("__PORT_DECL__") != -1: 
    411415              self.writePortImplDecl(outputPortImpl,portSample_p,portSample_u,comp) 
    412               continue           
     416              continue 
    413417            outputPortImpl.write(l_out) 
    414              
     418 
    415419        inputPortImpl.close() 
    416420        outputPortImpl.close() 
    417421        portSample_p.close() 
    418422        portSample_u.close() 
    419          
     423 
    420424        # generate the port_impl.cpp file 
    421         inputPortImpl = open('generate/templates/custom_ports/port_impl.cpp','r') 
     425        inputPortImpl = open(self.wavedevPath + 'generate/templates/custom_ports/port_impl.cpp','r') 
    422426        outputPortImpl = open(self.path + comp.name + "/port_impl.cpp",'w') 
    423427        self.addGPL(outputPortImpl,comp.name) 
    424         portSample_p = open('generate/templates/custom_ports/port_sample_p.cpp','r') 
    425         portSample_u = open('generate/templates/custom_ports/port_sample_u.cpp','r') 
     428        portSample_p = open(self.wavedevPath + 'generate/templates/custom_ports/port_sample_p.cpp','r') 
     429        portSample_u = open(self.wavedevPath + 'generate/templates/custom_ports/port_sample_u.cpp','r') 
    426430        for line in inputPortImpl.readlines(): 
    427431            l_out = line 
     
    430434              continue 
    431435            outputPortImpl.write(l_out) 
    432              
     436 
    433437        inputPortImpl.close() 
    434438        outputPortImpl.close() 
    435439        portSample_p.close() 
    436440        portSample_u.close() 
    437          
     441 
    438442    # Copy some required files into the main directory 
    439     #  os.system('cp generate/basic_xml/* ' + self.path) 
    440     #  os.system('cp generate/wavLoader.py ' + self.path) 
     443    #  os.system('cp ' + self.wavedevPath + 'generate/basic_xml/* ' + self.path) 
     444    #  os.system('cp ' + self.wavedevPath + 'generate/wavLoader.py ' + self.path) 
    441445 
    442446  def writePortImplDecl(self, output,portSample_p,portSample_u,c): 
     
    522526                else: 
    523527                    l_out = l_out.replace("__COMP_REF_DECL__","") 
    524                  
     528 
    525529            output.write(l_out) 
    526530 
    527531  def writePortImplDef(self,output,portSample_p,portSample_u,c): 
    528532    """ This function writes port implementation definitions for the port_impl.cpp file""" 
    529     intList = []     
     533    intList = [] 
    530534    for x in c.ports: 
    531535        found_match = False 
     
    610614            outCount += 1 
    611615    ts = " "*8 + "bool component_alive;\n\n" + " "*8 + "string naming_service_name;\n"; output.write(ts) 
    612      
     616 
    613617  def writePortInst(self,output,c): 
    614618    """ This function writes the port instantiations to the component cpp file""" 
     
    633637    ts = "\n"; output.write(ts) 
    634638    ts = " "*4 + "queue_size = DEFAULT_QUEUE_BLOCK_SIZE;\n\n" + " "*4 + "component_alive = true;\n\n" + " "*4 + "naming_service_name = label;\n"; output.write(ts) 
    635      
     639 
    636640  def writeGetPort(self,output,c): 
    637641    """ This function writes the getPort functionality to the component cpp file""" 
     
    666670    ts = "\n"; output.write(ts) 
    667671    ts = " "*4 + 'return NULL;\n'; output.write(ts) 
    668      
     672 
    669673  def writeDelPort(self,output,c): 
    670674    """ This function writes the destructor functionality (for ports) to the component cpp file""" 
     
    683687            outCount += 1 
    684688    ts = "\n"; output.write(ts) 
    685      
     689 
    686690##  def writeACESvcPorts(self,output,c): 
    687691##    """ This function writes the svc port functionality to the component cpp file""" 
     
    692696##            output.write(ts) 
    693697##            outCount += 1 
    694 ##    ts = "\n"; output.write(ts)   
    695      
     698##    ts = "\n"; output.write(ts) 
     699 
    696700  def writeACESvcDef(self, output,c,type,timing_flag, comp=''): 
    697701    """ This function writes the implementation of the svn() function for a given component""" 
     
    884888        ts = " "*8 + "//ACE_OS::sleep (ACE_Time_Value (1));\n"; output.write(ts) 
    885889        ts = " "*4 + '}\n\n' + " "*4 + 'return 0;\n}\n'; output.write(ts) 
    886          
     890 
    887891    if type == 'port': 
    888892        #ts = 'int ' + c.u_cname + '::svc(void)\n{\n'; output.write(ts) 
     
    10281032                else: 
    10291033                        ts = " "*4 + 'return 0;\n' + '}\n'; output.write(ts) 
    1030      
     1034 
    10311035  def writeTimingMessageDef(self, output,c,type): 
    10321036    if type == 'port': 
     
    10501054 
    10511055  def writeOperation(self,output,i,prefix='',cppFlag=False,in_name='',using_ace=False,comp='',port=''): 
    1052     """ Writes the declaration or definition of an operation (pushPacket) to  
     1056    """ Writes the declaration or definition of an operation (pushPacket) to 
    10531057        the port_impl.h and port_impl.cpp files respectively """ 
    10541058    ocount = 0 
    10551059    for o in i.operations: 
    1056          
     1060 
    10571061 
    10581062        ocount += 1 
     
    10671071            ts = prefix + " "*4 + o.returnType + ' ' + o.name + '(' 
    10681072            tscxx = prefix + " "*4 + o.cxxReturnType + ' ' + o.name + '(' 
    1069          
     1073 
    10701074        first = True 
    10711075        for p in o.params: 
     
    10731077            _USE_CONST_ = 'const ' 
    10741078            _USE__OUT_ = '' 
    1075             if p.direction == 'out':  
     1079            if p.direction == 'out': 
    10761080                if len(p.dataType) > 8 and p.dataType[-8:] != 'Sequence': 
    10771081                    _USE_CONST_ = '' 
     
    11041108#        output.write(ts) 
    11051109        output.write(tscxx) 
    1106          
     1110 
    11071111        if cppFlag: 
    11081112                #ts = "{\n" + " "*4 + "unsigned int len = " + "hello" + ".length();\n"; output.write(ts) 
     
    11891193                else: 
    11901194                        ts = "{\n\n}\n"; output.write(ts) 
    1191          
     1195 
    11921196  def writeFriendDecl(self,output,c): 
    11931197      friendList = [] 
     
    11991203              if p.p_cname not in friendList: 
    12001204                  friendList.append(p.p_cname) 
    1201                    
     1205 
    12021206      for x in friendList: 
    12031207          ts = " "*4 + "friend class " + x + ";\n" 
    1204           output.write(ts)  
    1205        
     1208          output.write(ts) 
     1209 
    12061210 
    12071211  def addGPL(self,outFile,name): 
    1208       inFile = open('generate/gpl_preamble','r') 
     1212      inFile = open(self.wavedevPath + 'generate/gpl_preamble','r') 
    12091213      for line in inFile.readlines(): 
    12101214          l_out = line.replace("__COMP_NAME__",name) 
    12111215          outFile.write(l_out) 
    1212          
     1216 
    12131217      inFile.close() 
    1214            
    1215          
     1218 
     1219 
    12161220  def cleanUp(self): 
    12171221      # Move the AssemblyController to the waveform Dir 
     
    12201224            os.system('mv ' + self.path + c.name + ' ' + self.path + self.active_wave.name) 
    12211225 
    1222          
     1226