Changeset 8046
- Timestamp:
- 07/17/08 11:26:35 (5 years ago)
- Location:
- ossiedev/trunk/tools/WaveDev/wavedev
- Files:
-
- 12 modified
- 11 copied
-
ComponentClass.py (modified) (11 diffs)
-
ComponentFrame.py (modified) (53 diffs)
-
MainFrame.py (modified) (100 diffs)
-
PropertiesDialog.py (modified) (27 diffs)
-
XML_gen/application_gen.py (modified) (27 diffs)
-
XML_gen/component_gen.py (modified) (15 diffs)
-
cfg.py (copied) (copied from ossiedev/branches/jsnyder/ComponentProject/WaveDev/wavedev/cfg.py)
-
dtd (copied) (copied from ossiedev/branches/jsnyder/ComponentProject/WaveDev/wavedev/dtd)
-
dtd/deviceconfiguration.dtd (copied) (copied from ossiedev/branches/jsnyder/ComponentProject/WaveDev/wavedev/dtd/deviceconfiguration.dtd)
-
dtd/devicepkg.dtd (copied) (copied from ossiedev/branches/jsnyder/ComponentProject/WaveDev/wavedev/dtd/devicepkg.dtd)
-
dtd/domainmanagerconfiguration.dtd (copied) (copied from ossiedev/branches/jsnyder/ComponentProject/WaveDev/wavedev/dtd/domainmanagerconfiguration.dtd)
-
dtd/profile.dtd (copied) (copied from ossiedev/branches/jsnyder/ComponentProject/WaveDev/wavedev/dtd/profile.dtd)
-
dtd/properties.dtd (copied) (copied from ossiedev/branches/jsnyder/ComponentProject/WaveDev/wavedev/dtd/properties.dtd)
-
dtd/softpkg.dtd (copied) (copied from ossiedev/branches/jsnyder/ComponentProject/WaveDev/wavedev/dtd/softpkg.dtd)
-
dtd/softwareassembly.dtd (copied) (copied from ossiedev/branches/jsnyder/ComponentProject/WaveDev/wavedev/dtd/softwareassembly.dtd)
-
dtd/softwarecomponent.dtd (copied) (copied from ossiedev/branches/jsnyder/ComponentProject/WaveDev/wavedev/dtd/softwarecomponent.dtd)
-
generate/genNode.py (modified) (28 diffs)
-
generate/templates/basic_ports/genStructure.py (modified) (71 diffs)
-
generate/templates/custom_ports/genStructure.py (modified) (35 diffs)
-
generate/templates/py_comp/genStructure.py (modified) (28 diffs)
-
importNode.py (modified) (10 diffs)
-
importResource.py (modified) (1 diff)
-
uuidgen.py (copied) (copied from ossiedev/branches/jsnyder/ComponentProject/WaveDev/wavedev/uuidgen.py)
Legend:
- Unmodified
- Added
- Removed
-
ossiedev/trunk/tools/WaveDev/wavedev/ComponentClass.py
r5886 r8046 17 17 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 18 19 import commands 20 # UUID Generator 21 def uuidgen(): 22 return commands.getoutput('uuidgen -t') 19 from uuidgen import uuidgen 23 20 24 21 # Component Class … … 42 39 self.properties = [] 43 40 self.description = description 44 41 45 42 def __getitem__(self,i): 46 43 return self.connections[i] 47 44 48 45 def setUUID(self): 49 46 self.uuid = uuidgen() 50 47 51 48 def changeName(self,newname): 52 49 self.name = newname … … 68 65 if in_dev != None: 69 66 self.Devices.append(in_comp) 70 67 71 68 72 69 class Port: … … 86 83 def __init__(self, LP, RP, RC): 87 84 self.localPort = LP 88 self.remotePort = RP 85 self.remotePort = RP 89 86 self.remoteComp = RC 90 87 91 88 class Interface: 92 89 def __init__(self,name,nameSpace="standardInterfaces",operations=[],filename="",fullpath=""): … … 96 93 self.filename = filename #does not include the '.idl' suffix 97 94 self.fullpath = fullpath 98 95 99 96 def __eq__(self,other): 100 if isinstance(other, Interface): 97 if isinstance(other, Interface): 101 98 return (other.nameSpace == self.nameSpace ) and (other.name == self.name) 102 99 else: 103 100 return False 104 101 105 102 def __ne__(self,other): 106 103 if isinstance(other, Interface): … … 109 106 return True 110 107 111 108 112 109 class Operation: 113 110 def __init__(self,name,returnType,params=[]): … … 116 113 self.cxxReturnType = '' 117 114 self.params = [] 118 115 119 116 class Param: 120 117 def __init__(self,name,dataType='',direction=''): 121 """ 118 """ 122 119 Exampleinterface complexShort { 123 120 void pushPacket(in PortTypes::ShortSequence I, in PortTypes::ShortSequence Q); … … 129 126 self.cxxType = "" 130 127 self.direction = direction # Flow of data: 'in' 131 128 132 129 class Property: 133 130 def __init__(self,elementType,name,mode,description=''): … … 136 133 self.mode = mode 137 134 self.id = 'DCE:' + uuidgen() 138 135 139 136 class SimpleProperty(Property): 140 137 def __init__(self,name,mode,type,description='',value=None,defaultValue=None,units=None, … … 142 139 Property.__init__(self,"Simple",name,mode,description) 143 140 self.type = type 144 self.description = description 141 self.description = description 145 142 self.value = value 146 143 self.defaultValue = defaultValue … … 162 159 self.kind = kind 163 160 self.action = action 164 165 161 162 -
ossiedev/trunk/tools/WaveDev/wavedev/ComponentFrame.py
r7517 r8046 37 37 return CompFrame(parent) 38 38 39 [wxID_COMPFRAME, wxID_COMPFRAMEACECHECKBOX, wxID_COMPFRAMETIMINGCHECKBOX, wxID_COMPFRAMEADDPORTBTN, 40 wxID_COMPFRAMEADDPROP, wxID_COMPFRAMEASSEMBLYCCHECKBOX, 41 wxID_COMPFRAMECLOSEBTN, wxID_COMPFRAMECOMPNAMEBOX, wxID_COMPFRAMECOMPDESCRBOX, 42 wxID_COMPFRAMEDEVICECHOICE, wxID_COMPFRAMENODECHOICE, wxID_COMPFRAMEPORTBOX, 43 wxID_COMPFRAMEPROPLIST, wxID_COMPFRAMEREMOVEBTN, wxID_COMPFRAMEREMOVEPROP, 44 wxID_COMPFRAMESTATICTEXT1, wxID_COMPFRAMESTATICTEXT2, 45 wxID_COMPFRAMESTATICTEXT3, wxID_COMPFRAMESTATICTEXT4, 39 [wxID_COMPFRAME, wxID_COMPFRAMEACECHECKBOX, wxID_COMPFRAMETIMINGCHECKBOX, wxID_COMPFRAMEADDPORTBTN, 40 wxID_COMPFRAMEADDPROP, wxID_COMPFRAMEASSEMBLYCCHECKBOX, 41 wxID_COMPFRAMECLOSEBTN, wxID_COMPFRAMECOMPNAMEBOX, wxID_COMPFRAMECOMPDESCRBOX, 42 wxID_COMPFRAMEDEVICECHOICE, wxID_COMPFRAMENODECHOICE, wxID_COMPFRAMEPORTBOX, 43 wxID_COMPFRAMEPROPLIST, wxID_COMPFRAMEREMOVEBTN, wxID_COMPFRAMEREMOVEPROP, 44 wxID_COMPFRAMESTATICTEXT1, wxID_COMPFRAMESTATICTEXT2, 45 wxID_COMPFRAMESTATICTEXT3, wxID_COMPFRAMESTATICTEXT4, 46 46 wxID_COMPFRAMESTATICTEXT5, wxID_COMPFRAMESTATICTEXT6, 47 wxID_COMPFRAMESTATICTEXT7, wxID_COMPFRAMESTATICTEXT8, wxID_COMPFRAMESTATUSBARCOMPONENT, 47 wxID_COMPFRAMESTATICTEXT7, wxID_COMPFRAMESTATICTEXT8, wxID_COMPFRAMESTATUSBARCOMPONENT, 48 48 wxID_COMPFRAMESTATICLINE1, wxID_COMPFRAMETEMPLATECHOICE, 49 49 ] = [wx.NewId() for _init_ctrls in range(26)] 50 50 51 [wxID_COMPFRAMEMENUFILENEW, wxID_COMPFRAMEMENUFILEOPEN, 52 wxID_COMPFRAMEMENUFILESAVE, wxID_COMPFRAMEMENUFILESAVEAS, 51 [wxID_COMPFRAMEMENUFILENEW, wxID_COMPFRAMEMENUFILEOPEN, 52 wxID_COMPFRAMEMENUFILESAVE, wxID_COMPFRAMEMENUFILESAVEAS, 53 53 ] = [wx.NewId() for _init_coll_menuFile_Items in range(4)] 54 54 55 [wxID_COMPFRAMEPORTBOXPOPUPADD, wxID_COMPFRAMEPORTBOXPOPUPEXPAND, 56 wxID_COMPFRAMEPORTBOXPOPUPREMOVE, 55 [wxID_COMPFRAMEPORTBOXPOPUPADD, wxID_COMPFRAMEPORTBOXPOPUPEXPAND, 56 wxID_COMPFRAMEPORTBOXPOPUPREMOVE, 57 57 ] = [wx.NewId() for _init_coll_portBoxPopup_Items in range(3)] 58 58 59 [wxID_COMPFRAMEPROPLISTPOPUPADD, wxID_COMPFRAMEPROPLISTPOPUPEDIT, 60 wxID_COMPFRAMEPROPLISTPOPUPREMOVE, 59 [wxID_COMPFRAMEPROPLISTPOPUPADD, wxID_COMPFRAMEPROPLISTPOPUPEDIT, 60 wxID_COMPFRAMEPROPLISTPOPUPREMOVE, 61 61 ] = [wx.NewId() for _init_coll_propListPopup_Items in range(3)] 62 62 … … 155 155 156 156 self.portBoxPopup = wx.Menu(title='') 157 157 158 158 self.propListPopup = wx.Menu(title='') 159 159 … … 277 277 278 278 self.staticText3.SetFont(wx.Font(8,wx.SWISS,wx.NORMAL,wx.BOLD,True,u'Sans')) 279 279 280 280 self.nodeChoice = wx.Choice(choices=[], id=wxID_COMPFRAMENODECHOICE, 281 281 name=u'nodeChoice', parent=self, pos=wx.Point(453, 60), … … 291 291 label=u'Device', name='staticText5', parent=self, 292 292 pos=wx.Point(384, 98), size=wx.Size(51, 17), style=0) 293 293 294 294 self.staticText6 = wx.StaticText(id=wxID_COMPFRAMESTATICTEXT6, 295 295 label=u'Component Generation Options', name='staticText6', parent=self, 296 296 pos=wx.Point(634, 24), size=wx.Size(100, 35), style=wx.TE_BESTWRAP | wx.TE_MULTILINE) 297 297 self.staticText6.SetFont(wx.Font(8,wx.SWISS,wx.NORMAL,wx.BOLD,True,u'Sans')) 298 298 299 299 self.staticText7 = wx.StaticText(id=wxID_COMPFRAMESTATICTEXT7, 300 300 label=u'Template', name='staticText7', parent=self, 301 301 pos=wx.Point(634, 65), size=wx.Size(222, 17), style=0) 302 302 303 303 self.propList = wx.ListView(id=wxID_COMPFRAMEPROPLIST, name=u'propList', 304 304 parent=self, pos=wx.Point(40, 320), size=wx.Size(312, 160), … … 313 313 name='staticLine1', parent=self, pos=wx.Point(610, 17), 314 314 size=wx.Size(1, 200), style=wx.LI_VERTICAL) 315 316 self.templateChoice = wx.Choice(choices=_availableTemplates, 315 316 self.templateChoice = wx.Choice(choices=_availableTemplates, 317 317 id=wxID_COMPFRAMETEMPLATECHOICE, 318 318 name=u'templateChoice', parent=self, pos=wx.Point(703, 60), … … 321 321 self.templateChoice.Bind(wx.EVT_CHOICE, self.OnTemplateChoiceChoice, 322 322 id=wxID_COMPFRAMETEMPLATECHOICE) 323 323 324 324 def __init__(self, parent): 325 325 # Constructor for ComponentFrame 326 availableTemplates = commands.getoutput("cd generate/templates; ls -I __init__.py -I __init__.pyc")326 availableTemplates = commands.getoutput("cd " + self.wavedevPath + "generate/templates; ls -I __init__.py -I __init__.pyc") 327 327 availableTemplates = availableTemplates.split() 328 328 self._init_ctrls(parent,availableTemplates) 329 329 330 330 self.templateChoice.SetSelection(0) 331 331 self.template = self.templateChoice.GetStringSelection() 332 332 333 333 self.parent = parent 334 334 335 335 self.saveComponentPath = None 336 336 self.calledByParent = False 337 337 338 self.wavedevPath = '' # Should really be computed from the install path 339 338 340 if parent == None: #OSSIE Component Editor being run in stand-alone mode 339 341 self.menuComponent.Enable(wxID_COMPFRAMEMENUCOMPONENTGENERATE,True) … … 343 345 self.menuComponent.Enable(wxID_COMPFRAMEMENUCOMPONENTGENERATE,False) 344 346 self.compDescrBox.Enable(False) 347 self.wavedevPath = parent.wavedevPath 345 348 346 349 self.Available_Ints = [] 347 350 self.importStandardIdl() 348 349 351 352 350 353 def OnCompFrameActivate(self, event): 351 354 if self.calledByParent == True: … … 353 356 self.displayPorts() 354 357 self.displayProps() 355 358 356 359 if self.active_comp.ace == True: 357 360 self.ACEcheckBox.SetValue(True) 358 361 else: 359 362 self.ACEcheckBox.SetValue(False) 360 363 361 364 if self.active_comp.timing == True: 362 365 self.TimingcheckBox.SetValue(True) 363 366 else: 364 367 self.TimingcheckBox.SetValue(False) 365 368 366 369 if self.active_comp.AssemblyController == True: 367 370 self.AssemblyCcheckBox.SetValue(True) 368 371 else: 369 372 self.AssemblyCcheckBox.SetValue(False) 370 373 371 374 if self.active_comp.generate == False: 372 375 self.AddPortBtn.Enable(False) … … 383 386 self.ACEcheckBox.Enable(True) 384 387 self.TimingcheckBox.Enable(True) 385 388 386 389 self.compNameBox.Clear() 387 390 self.compNameBox.WriteText(self.active_comp.name) … … 389 392 self.compDescrBox.Clear() 390 393 self.compDescrBox.WriteText(self.active_comp.description) 391 394 392 395 if self.active_comp.type != 'resource': 393 396 self.deviceChoice.Clear() … … 398 401 self.nodeChoice.Enable(True) 399 402 self.displayPlatformInfo() 400 403 401 404 self.menuFile.Enable(wxID_COMPFRAMEMENUFILENEW,False) 402 405 self.menuFile.Enable(wxID_COMPFRAMEMENUFILEOPEN,False) 403 406 404 407 self.calledByParent = False 405 406 408 409 407 410 ################################################################################ 408 411 ## File Menu / Frame Functionality … … 437 440 if tmpdir == "~": 438 441 tmpdir = "/home" 439 442 440 443 tmpwildcard = "Component Files (*.cmp)|*.cmp" 441 444 dlg = wx.FileDialog(self, "Choose a file", tmpdir, "", tmpwildcard, wx.OPEN) … … 449 452 finally: 450 453 dlg.Destroy() 451 454 452 455 f = open(tmpPath,'r') 453 456 tmpObject = cPickle.load(f) … … 462 465 if tempLn == '': 463 466 errorMsg(self,'Please enter a component name first') 464 return 467 return 465 468 self.active_comp.name = tempLn 466 469 … … 470 473 return 471 474 self.active_comp.description = tempDescr 472 475 473 476 if len(self.homeDir) > 0: 474 477 tmpdir = self.homeDir … … 477 480 if tmpdir == "~": 478 481 tmpdir = "/home" 479 482 480 483 dlg = wx.FileDialog(self, "Choose a file", tmpdir, tempLn + '.cmp', "Component File (*.cmp)|*.cmp", wx.SAVE) 481 484 try: … … 488 491 finally: 489 492 dlg.Destroy() 490 493 491 494 f = open(self.saveComponentPath,'w') 492 cPickle.dump(('component',self.active_comp),f) 495 cPickle.dump(('component',self.active_comp),f) 493 496 494 497 def ComponentOpen(self,newPath,newComp): … … 506 509 finally: 507 510 dlg.Destroy() 508 511 509 512 self.saveComponentPath = newPath 510 513 511 514 self.active_comp = newComp 512 515 self.displayPorts() 513 516 self.displayProps() 514 517 515 518 if self.active_comp.ace == True: 516 519 self.ACEcheckBox.SetValue(True) … … 524 527 else: 525 528 self.TimingcheckBox.SetValue(False) 526 529 527 530 if self.active_comp.AssemblyController == True: 528 531 self.AssemblyCcheckBox.SetValue(True) 529 532 else: 530 533 self.AssemblyCcheckBox.SetValue(False) 531 534 532 535 if self.active_comp.generate == False: 533 536 self.AddPortBtn.Enable(False) … … 536 539 self.AddPortBtn.Enable(True) 537 540 self.RemoveBtn.Enable(True) 538 541 539 542 self.compNameBox.Clear() 540 543 self.compNameBox.WriteText(self.active_comp.name) 541 544 542 545 self.compDescrBox.Clear() 543 self.compDescrBox.WriteText(self.active_comp.implementation.description) 544 546 self.compDescrBox.WriteText(self.active_comp.implementation.description) 547 545 548 def OnCloseBtnButton(self, event): 546 549 if self.parent == None: … … 551 554 if tempLn == '': 552 555 errorMsg(self,'Please enter a component name first') 553 return 556 return 554 557 555 558 for c in self.parent.active_wave.components: … … 557 560 errorMsg(self,'Invalid name - a component by that name already exists') 558 561 return 559 562 560 563 #Component names with spaces do not work 561 564 if tempLn.find(' ') != -1: 562 565 errorMsg(self,'Resource names can not have spaces in them.\nReplacing spaces with "_".') 563 566 tempLn = tempLn.replace(' ','_') 564 565 567 568 566 569 self.active_comp.changeName(tempLn) 567 570 568 571 self.MakeModal(False) 569 572 self.parent.displayComps() … … 575 578 self.MakeModal(False) 576 579 if self.parent != None: 577 self.parent.displayComps() 580 self.parent.displayComps() 578 581 self.Show(False) 579 582 event.Skip() 580 581 583 584 582 585 ################################################################################ 583 586 ## Miscellaneous Functionality 584 587 ################################################################################ 585 588 586 def importStandardIdl(self): 589 def importStandardIdl(self): 587 590 '''Imports IDL from cf, standardinterfaces, and custominterfaces''' 588 591 #temporarily change self.parent to self so this works 589 592 #normally this function looks at the MainFrame - but not in standalone 590 changedParent = False 593 changedParent = False 591 594 if self.parent == None: 592 595 self.parent = self 593 changedParent = True 594 596 changedParent = True 597 595 598 if os.path.isfile(self.parent.ossieIncludePath + "cf.idl"): 596 599 cfIdl_file = self.parent.ossieIncludePath + "cf.idl" … … 605 608 standard_idl_list = os.listdir(self.parent.stdIdlPath) 606 609 607 try: 610 try: 608 611 custom_idl_list = os.listdir(self.parent.customIdlPath) 609 except OSError: # this will occur if customIdlPath was never set 612 except OSError: # this will occur if customIdlPath was never set 610 613 # as a result of customInterfaces not being found 611 614 custom_idl_list = [] … … 615 618 errorMsg(self.parent,tmpstr) 616 619 return 617 620 618 621 # Add the CF interfaces first - in case another file includes them, we 619 622 # don't want them asscociated with anything other than cf.idl 620 623 self.Available_Ints.extend(importIDL.getInterfaces(cfIdl_file)) 621 624 622 625 # import standard interfaces 623 626 for standard_idl_file in standard_idl_list: … … 629 632 # ignore non idl files 630 633 continue 631 634 632 635 tempInts = importIDL.getInterfaces(self.parent.stdIdlPath+standard_idl_file) 633 636 for t in tempInts: 634 637 if t not in self.Available_Ints: 635 638 self.Available_Ints.append(t) 636 639 637 640 # import custom interfaces 638 641 for custom_idl_file in custom_idl_list: … … 644 647 # ignore non idl files 645 648 continue 646 649 647 650 tempInts = importIDL.getInterfaces(self.parent.customIdlPath+custom_idl_file) 648 651 for t in tempInts: … … 654 657 self.timing_port = CC.Port('send_timing_report', self.timing_interface, "Uses", "data") 655 658 # print "CF.py: " + t.name + " " + str(len(t.operations)) 656 659 657 660 if changedParent == True: 658 661 self.parent = None … … 693 696 usesRoot = self.PortBox.AppendItem(troot,'Uses',image=0) 694 697 provRoot = self.PortBox.AppendItem(troot,'Provides',image=1) 695 698 696 699 for p in self.active_comp.ports: 697 700 if p.type == 'Uses': … … 699 702 t1 = self.PortBox.AppendItem(usesRoot,tnm) 700 703 self.PortBox.SetPyData(t1,p) 701 704 702 705 if p.type == 'Provides': 703 706 tnm = p.name + "::" + p.interface.name … … 715 718 finally: 716 719 dlg.Destroy() 717 720 718 721 self.displayPorts() 719 722 720 723 def RemovePort(self): 721 724 if self.active_comp.generate == False: … … 728 731 finally: 729 732 dlg.Destroy() 730 733 731 734 sn = self.PortBox.GetSelection() 732 735 if sn == self.PortBox.GetRootItem(): … … 740 743 ti = self.active_comp.ports.index(tc) 741 744 del self.active_comp.ports[ti] 742 745 743 746 self.displayPorts() 744 747 745 748 746 749 def OnAddPortBtnButton(self, event): 747 self.AddPort() 748 event.Skip() 749 750 self.AddPort() 751 event.Skip() 752 750 753 def OnRemoveBtnButton(self, event): 751 754 self.RemovePort() … … 762 765 def OnPortBoxRightUp(self, event): 763 766 sn = self.PortBox.GetSelection() 764 767 765 768 if sn == self.PortBox.GetRootItem(): 766 769 self.portBoxPopup.Enable(wxID_COMPFRAMEPORTBOXPOPUPREMOVE,False) … … 772 775 for x in self.portBoxPopup.GetMenuItems(): 773 776 x.Enable(True) 774 777 775 778 if self.active_comp.generate == False: 776 779 self.portBoxPopup.Enable(wxID_COMPFRAMEPORTBOXPOPUPADD,False) … … 778 781 else: 779 782 self.portBoxPopup.Enable(wxID_COMPFRAMEPORTBOXPOPUPADD,True) 780 781 self.PortBox.PopupMenu(self.portBoxPopup) 783 784 self.PortBox.PopupMenu(self.portBoxPopup) 782 785 event.Skip() 783 786 … … 790 793 event.Skip() 791 794 792 793 795 796 794 797 ################################################################################ 795 798 ## Deployment Functionality … … 799 802 if self.parent == None: 800 803 return 801 804 802 805 pos = self.nodeChoice.GetSelection() 803 806 if pos == wx.NOT_FOUND: 804 return 805 807 return 808 806 809 tmpNode = self.nodeChoice.GetClientData(pos) 807 808 810 811 809 812 self.deviceChoice.Clear() 810 813 for x in tmpNode.Devices: 811 814 if x.type == 'executabledevice' or x.type == 'loadabledevice': 812 815 self.deviceChoice.Append(unicode(x.name),x) 813 816 814 817 def displayPlatformInfo(self): 815 818 if self.parent == None: 816 819 return 817 820 818 821 self.deviceChoice.Clear() 819 822 self.nodeChoice.Clear() 820 823 821 824 for x in self.parent.active_plat.nodes: 822 825 self.nodeChoice.Append(x.name,x) 823 826 824 827 tmpNode = None 825 if self.active_comp.device != None: 828 if self.active_comp.device != None: 826 829 for x in self.parent.active_plat.nodes: 827 830 for d in x.Devices: … … 835 838 pos = self.deviceChoice.FindString(self.active_comp.device.name) 836 839 self.deviceChoice.SetSelection(pos) 837 840 838 841 else: 839 842 tmpstr = 'ERROR! Cannot find the ' + self.active_comp.device.name 840 tmpstr += ' device in current Platform configuration.' 843 tmpstr += ' device in current Platform configuration.' 841 844 tmpstr += '\nSetting device assignment to None.' 842 845 errorMsg(self,tmpstr) … … 846 849 pos = self.nodeChoice.GetSelection() 847 850 if pos == wx.NOT_FOUND: 848 return 851 return 849 852 self.displayDevices() 850 853 … … 852 855 pos = self.deviceChoice.GetSelection() 853 856 if pos == wx.NOT_FOUND: 854 return 855 857 return 858 856 859 tmpDev = self.deviceChoice.GetClientData(pos) 857 860 self.active_comp.device = tmpDev … … 860 863 pos = self.templateChoice.GetSelection() 861 864 if pos == wx.NOT_FOUND: 862 return 863 865 return 866 864 867 tmpTmpl = self.templateChoice.GetStringSelection() 865 868 self.template = tmpTmpl 866 867 869 870 868 871 ############################################################################ 869 872 ## Properties Functionality 870 ############################################################################ 873 ############################################################################ 871 874 def OnaddPropButton(self, event): 872 self.AddProperty() 873 event.Skip() 874 875 self.AddProperty() 876 event.Skip() 877 875 878 def OnRemovePropButton(self, event): 876 879 #sel = self.propList.GetFirstSelected() … … 893 896 self.propList.SetStringItem(pCount,1,ts) 894 897 self.propList.SetItemData(pCount,self.active_comp.properties.index(p)) 895 898 896 899 def OnPropListListItemRightClick(self, event): 897 self.propList.PopupMenu(self.propListPopup) 898 event.Skip() 899 900 self.propList.PopupMenu(self.propListPopup) 901 event.Skip() 902 900 903 def EditProperty(self): 901 904 sel = self.propList.GetFocusedItem() … … 912 915 finally: 913 916 dlg.Destroy() 914 917 915 918 self.displayProps() 916 919 917 920 def AddProperty(self): 918 921 dlg = PropertiesDialog.create(self) … … 924 927 finally: 925 928 dlg.Destroy() 926 929 927 930 self.displayProps() 928 931 929 932 def RemoveProperty(self): 930 933 sel = self.propList.GetFocusedItem() … … 943 946 self.EditProperty() 944 947 event.Skip() 945 948 946 949 def OnPropsListPopupRemoveMenu(self, event): 947 950 self.RemoveProperty() 948 951 event.Skip() 949 952 950 953 def OnPropsListPopupAddMenu(self, event): 951 954 self.AddProperty() … … 960 963 ############################################################################ 961 964 def OnMenuComponentGenerateMenu(self, event): 962 965 963 966 #select which template to use 964 967 if self.template == "basic_ports": … … 971 974 errorMsg(self.parent, self.template + " is not supported in OnMenuComponentGenerateMenu witin the componentFrame") 972 975 return 973 976 974 977 tempLn = self.compNameBox.GetLineText(0) 975 978 if tempLn == '': 976 979 errorMsg(self,'Please enter a component name first') 977 980 return 978 981 979 982 self.active_comp.name = tempLn 980 983 981 984 tempDescr = self.compDescrBox.GetLineText(0) 982 985 if tempDescr == '': … … 996 999 finally: 997 1000 dlg.Destroy() 998 1001 999 1002 if savepath[len(savepath)-1] != '/': 1000 1003 savepath = savepath + '/' 1001 1004 1002 1005 self.path = savepath 1003 1006 self.path = self.path + self.active_comp.name 1004 1007 1005 1008 if os.path.exists(self.path) == False: 1006 1009 os.mkdir(self.path) 1007 1008 #if os.path.exists(self.path + '/aclocal.d') == False: 1010 1011 #if os.path.exists(self.path + '/aclocal.d') == False: 1009 1012 # os.mkdir(self.path + '/aclocal.d') 1010 1013 #for f in os.listdir('generate/aclocal.d/'): … … 1012 1015 # shutil.copy('generate/aclocal.d/' + f,self.path + '/aclocal.d') 1013 1016 if self.template != "py_comp": 1014 shutil.copy( 'generate/reconf',self.path)1015 shutil.copy( 'generate/LICENSE',self.path)1016 1017 shutil.copy(self.wavedevPath + 'generate/reconf',self.path) 1018 shutil.copy(self.wavedevPath + 'generate/LICENSE',self.path) 1019 1017 1020 if self.active_comp.timing: 1018 1021 found_timing = False … … 1022 1025 if not found_timing: 1023 1026 self.active_comp.ports.append(self.timing_port) 1024 1025 gen = genStruct.genAll(savepath, None)1027 1028 gen = genStruct.genAll(savepath, self.wavedevPath, None) 1026 1029 gen.writeCompMakefile(self.active_comp,self.path) 1027 1030 gen.writeConfAC(self.path, self.active_comp.name, self.active_comp.ace, False, self.installPath) 1028 1031 gen.genCompFiles(self.active_comp) 1029 1032 1030 1033 component_gen.gen_scd(self.active_comp, savepath) 1031 1034 component_gen.gen_spd(self.active_comp, savepath) … … 1047 1050 wx.InitAllImageHandlers() 1048 1051 application = App() 1049 1052 1050 1053 application.main.active_comp = CC.Component("component1") 1051 1054 application.main.calledByParent = False … … 1057 1060 else: 1058 1061 application.main.ACEcheckBox.SetValue(False) 1059 1062 1060 1063 if application.main.active_comp.timing == True: 1061 1064 application.main.TimingcheckBox.SetValue(True) 1062 1065 else: 1063 1066 application.main.TimingcheckBox.SetValue(False) 1064 1067 1065 1068 application.main.deviceChoice.Enable(False) 1066 1069 application.main.nodeChoice.Enable(False) 1067 1070 application.MainLoop() 1068 1069 1070 1071 1072 1073 1071 1074 ################################################################################ 1072 1075 ## If Component Developer is run as a seperate application -
ossiedev/trunk/tools/WaveDev/wavedev/MainFrame.py
r7517 r8046 39 39 return Frame1(parent) 40 40 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, 45 45 wxID_FRAME1STATICTEXT3, wxID_FRAME1STATUSBAR1, wxID_FRAME1WAVENAMEBOX, 46 wxID_REFRESHRESOURCEBTN, wxID_FRAME1COMPDESCRBOX, wxID_FRAME1STATICTEXT4 46 wxID_REFRESHRESOURCEBTN, wxID_FRAME1COMPDESCRBOX, wxID_FRAME1STATICTEXT4 47 47 ] = [wx.NewId() for _init_ctrls in range(18)] 48 48 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, 53 53 ] = [wx.NewId() for _init_coll_menuFile_Items in range(9)] 54 54 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, 59 59 ] = [wx.NewId() for _init_coll_compBoxPopup_Items in range(7)] 60 60 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, 64 64 ] = [wx.NewId() for _init_coll_menuWaveform_Items in range(6)] 65 65 66 [wxID_FRAME1MENUHELPABOUT, wxID_FRAME1MENUHELPSAMPLEWAVEFORM, 66 [wxID_FRAME1MENUHELPABOUT, wxID_FRAME1MENUHELPSAMPLEWAVEFORM, 67 67 ] = [wx.NewId() for _init_coll_menuHelp_Items in range(2)] 68 68 … … 73 73 ] = [wx.NewId() for _init_coll_resourceBoxPopup_Items in range(5)] 74 74 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, 78 78 ] = [wx.NewId() for _init_coll_nodeBoxPopup_Items in range(8)] 79 79 80 [wxID_FRAME1NEWMENUNEWPLATFORM, wxID_FRAME1NEWMENUNEWPROJECT, 81 wxID_FRAME1NEWMENUNEWWAVEFORM, 80 [wxID_FRAME1NEWMENUNEWPLATFORM, wxID_FRAME1NEWMENUNEWPROJECT, 81 wxID_FRAME1NEWMENUNEWWAVEFORM, 82 82 ] = [wx.NewId() for _init_coll_newMenu_Items in range(3)] 83 83 … … 432 432 self.nodeBox.Bind(wx.EVT_TREE_END_LABEL_EDIT, 433 433 self.OnNodeBoxTreeEndLabelEdit, id=wxID_FRAME1NODEBOX) 434 434 435 435 self.RefreshResourceBtn = wx.Button(id=wxID_REFRESHRESOURCEBTN, label='Refresh', 436 436 name='RefreshResourceBtn', parent=self, pos=wx.Point(170, 40), … … 460 460 # Constructor for MainFrame 461 461 self._init_ctrls(parent) 462 462 463 463 #read in the configuration information 464 464 LoadConfiguration(self) 465 465 466 466 #setup the environment 467 467 self.active_comp = None 468 self.CompFrame = ComponentFrame.create(self) 468 self.CompFrame = ComponentFrame.create(self) 469 469 self.active_wave = WaveformClass.Waveform() 470 470 self.active_plat = PlatformClass.Platform() … … 475 475 self.saveProjectPath = None 476 476 self.description = None 477 477 self.wavedevPath = '' # Should really be computed from the install path 478 478 479 ################################################################################ 479 480 ## File/Help Menu Functionality … … 502 503 finally: 503 504 dlg.Destroy() 504 505 505 506 if sflag == True: 506 507 tempLn = self.waveNameBox.GetLineText(0) … … 526 527 finally: 527 528 dlg.Destroy() 528 529 529 530 else: 530 531 if self.saveProjectPath != None: … … 534 535 if self.ProjectSave(True) == False: 535 536 return 536 537 537 538 self.active_wave = WaveformClass.Waveform() 538 self.active_plat = PlatformClass.Platform() 539 self.active_plat = PlatformClass.Platform() 539 540 self.saveProjectPath = None 540 541 self.waveNameBox.Clear() 541 542 self.displayComps() 542 543 self.displayNodes() 543 544 544 545 545 546 event.Skip() 546 547 … … 562 563 finally: 563 564 dlg.Destroy() 564 565 565 566 if sflag == True: 566 567 tempLn = self.waveNameBox.GetLineText(0) … … 586 587 finally: 587 588 dlg.Destroy() 588 589 589 590 else: 590 591 if self.saveWaveformPath != None: … … 594 595 if self.WaveformSave(True) == False: 595 596 return 596 597 597 598 self.active_wave = WaveformClass.Waveform() 598 599 self.saveWaveformPath = None 599 600 self.waveNameBox.Clear() 600 601 self.displayComps() 601 602 602 603 event.Skip() 603 604 … … 619 620 finally: 620 621 dlg.Destroy() 621 622 if sflag == True: 622 623 if sflag == True: 623 624 if self.savePlatformPath != None: 624 625 tmpstr = 'Do you want to overwrite the existing platform file?\n' … … 640 641 finally: 641 642 dlg.Destroy() 642 643 643 644 else: 644 645 if self.PlatformSave(True) == False: 645 646 return 646 647 647 648 self.active_plat = PlatformClass.Platform() 648 649 self.savePlatformPath = None 649 650 self.displayNodes() 650 651 651 652 event.Skip() 652 653 … … 658 659 if tmpdir == "~": 659 660 tmpdir = "/home" 660 661 661 662 tmpwildcard = "Project Files (*.owd)|*.owd|Waveform Designs (*.sca)|*.sca|Platform Layouts (*.plt)|*.plt" 662 663 dlg = wx.FileDialog(self, "Choose a file", tmpdir, "", tmpwildcard, wx.OPEN) … … 670 671 finally: 671 672 dlg.Destroy() 672 673 673 674 f = open(tmpPath,'r') 674 675 tmpObject = cPickle.load(f) … … 679 680 elif tmpObject[0] == 'project': 680 681 self.ProjectOpen(tmpPath,tmpObject[1],tmpObject[2]) 681 682 682 683 event.Skip() 683 684 … … 704 705 finally: 705 706 dlg.Destroy() 706 707 707 708 else: 708 709 self.ProjectSave(False) 709 710 else: 710 711 self.ProjectSave(False) 711 712 712 713 event.Skip() 713 714 … … 738 739 finally: 739 740 dlg.Destroy() 740 741 741 742 else: 742 743 self.WaveformSave(False) 743 744 else: 744 745 self.WaveformSave(False) 745 746 746 747 event.Skip() 747 748 … … 769 770 return False 770 771 self.active_wave.name = tempLn 771 772 772 773 if len(self.homeDir) > 0: 773 774 tmpdir = self.homeDir 774 775 else: 775 776 tmpdir = os.path.expanduser("~") 776 777 777 778 dlg = wx.FileDialog(self, "Save As", tmpdir, tempLn + '.owd', "Project File (*.owd)|*.owd", wx.SAVE) 778 779 try: … … 785 786 finally: 786 787 dlg.Destroy() 787 788 788 789 f = open(self.saveProjectPath,'w') 789 cPickle.dump(('project',self.active_wave,self.active_plat),f) 790 790 cPickle.dump(('project',self.active_wave,self.active_plat),f) 791 791 792 return True 792 793 … … 798 799 return False 799 800 self.active_wave.name = tempLn 800 801 801 802 if len(self.homeDir) > 0: 802 803 tmpdir = self.homeDir 803 804 else: 804 805 tmpdir = os.path.expanduser("~") 805 806 806 807 dlg = wx.FileDialog(self, "Save As", tmpdir, tempLn + '.sca', "*.sca", wx.SAVE) 807 808 try: … … 814 815 finally: 815 816 dlg.Destroy() 816 817 817 818 f = open(self.saveWaveformPath,'w') 818 cPickle.dump(('waveform',self.active_wave),f) 819 819 cPickle.dump(('waveform',self.active_wave),f) 820 820 821 return True 821 822 822 823 def PlatformSave(self,saveasFlag): 823 if saveasFlag == True or self.savePlatformPath == None: 824 if saveasFlag == True or self.savePlatformPath == None: 824 825 if self.active_plat.name != "": 825 826 tmpname = self.active_plat.name 826 827 else: 827 828 tmpname = 'Platform1' 828 829 829 830 if len(self.homeDir) > 0: 830 831 tmpdir = self.homeDir 831 832 else: 832 833 tmpdir = os.path.expanduser("~") 833 834 834 835 dlg = wx.FileDialog(self, "Save As", tmpdir, tmpname + '.plt', "Platform File (*.plt)|*.plt", wx.SAVE) 835 836 try: … … 842 843 finally: 843 844 dlg.Destroy() 844 845 845 846 f = open(self.savePlatformPath,'w') 846 cPickle.dump(('platform',self.active_plat),f) 847 847 cPickle.dump(('platform',self.active_plat),f) 848 848 849 return True 849 850 850 851 def WaveformOpen(self,newPath,newWav): 851 852 if newPath != None: … … 862 863 finally: 863 864 dlg.Destroy() 864 865 865 866 self.saveWaveformPath = newPath 866 867 867 868 self.active_wave = newWav 868 869 869 870 # We must create new UUIDs for each instance and copy the file uuid from 870 871 # the base component to the instance … … 878 879 if c.generate == False and found == False: 879 880 errorMsg(self,"Could not find " + c.baseName + " which " + c.name + " is an instance of.") 880 881 881 882 882 883 #Because device assignments are stored as python objects in each component 883 884 #we must refresh the assignment with the available platform devices 884 885 885 886 for c in self.active_wave.components: 886 887 if c.device == None: … … 899 900 errorMsg(self,tmpstr) 900 901 c.device = None 901 902 902 903 self.waveNameBox.Clear() 903 904 self.waveNameBox.WriteText(self.active_wave.name) 904 self.displayComps() 905 905 self.displayComps() 906 906 907 if self.active_wave.ace == True: 907 908 self.menuWaveform.Check(wxID_FRAME1MENUWAVEFORMACESUPPORT,True) … … 909 910 else: 910 911 self.menuWaveform.Check(wxID_FRAME1MENUWAVEFORMACESUPPORT,False) 911 #self.ACEcheckBox.SetValue(False) 912 912 #self.ACEcheckBox.SetValue(False) 913 913 914 def PlatformOpen(self,newPath,newPlat): 914 915 if newPath != None: … … 925 926 finally: 926 927 dlg.Destroy() 927 928 928 929 self.savePlatformPath = newPath 929 930 930 931 self.active_plat = newPlat 931 932 932 933 933 934 # NOTE: The following comment does not hold true now that the nodes are installed … … 947 948 if found == False: 948 949 errorMsg(self,"Could not find " + d.baseName + " which " + d.name + " is an instance of.") 949 950 950 951 self.displayNodes() 951 952 952 953 953 954 def ProjectOpen(self,newPath,newWav,newPlat): 954 955 if self.saveProjectPath != None: … … 964 965 finally: 965 966 dlg.Destroy() 966 967 967 968 self.saveProjectPath = newPath 968 969 969 970 self.PlatformOpen(None,newPlat) 970 971 self.WaveformOpen(None,newWav) 971 972 self.displayNodes() 972 973 973 974 974 975 ################################################################# 975 976 ## Help Menu Stuff 976 977 ################################################################# 977 978 978 979 def OnMenuHelpAboutMenu(self, event): 979 980 dlg = AboutDialog.Dialog1(self) … … 983 984 dlg.Destroy() 984 985 event.Skip() 985 986 986 987 def OnMenuHelpSamplewaveformMenu(self, event): 987 988 self.generateTestWF() 988 989 event.Skip() 989 990 990 991 def generateTestWF(self): 991 992 self.active_wave = WaveformClass.Waveform() … … 1002 1003 t2.ports.append(p1); t2.ports.append(p2) 1003 1004 self.active_wave.components.append(t2) 1004 1005 1005 1006 t3 = ComponentClass.Component("Channel") 1006 1007 p1 = ComponentClass.Port('inPortCh1',copy.deepcopy(int1),'Provides') … … 1011 1012 p6 = ComponentClass.Port('outPortCh3',copy.deepcopy(int1),'Uses') 1012 1013 t3.ports.extend([p1,p2,p3,p4,p5,p6]) 1013 self.active_wave.components.append(t3) 1014 1014 self.active_wave.components.append(t3) 1015 1015 1016 t4 = ComponentClass.Component("Receiver") 1016 1017 p1 = ComponentClass.Port('inPortRx1',copy.deepcopy(int1),'Provides') 1017 1018 p2 = ComponentClass.Port('outPortRx1',copy.deepcopy(int1),'Uses') 1018 1019 t4.ports.append(p1); t4.ports.append(p2) 1019 self.active_wave.components.append(t4) 1020 1020 self.active_wave.components.append(t4) 1021 1021 1022 temp_dev = ComponentClass.Component("GPP") 1022 1023 self.active_wave.devices.append(temp_dev) 1023 1024 1024 1025 self.displayComps() 1025 1026 1027 1026 1028 ################################################################################ 1027 1029 ## Waveform Layout Functionality … … 1065 1067 finally: 1066 1068 dlg.Destroy() 1067 1069 1068 1070 sn = self.compBox.GetSelection() 1069 1071 if sn == self.compBox.GetRootItem(): … … 1072 1074 # a main level component 1073 1075 self.active_comp = self.compBox.GetPyData(sn) 1074 ti = self.active_wave.components.index(self.active_comp) 1076 ti = self.active_wave.components.index(self.active_comp) 1075 1077 # If any other component is connected to this component - connection must be removed 1076 1078 for c in self.active_wave.components: … … 1078 1080 if con.remoteComp == self.active_comp: 1079 1081 ci = c.connections.index(con) 1080 del c.connections[ci] 1082 del c.connections[ci] 1081 1083 del self.active_wave.components[ti] 1082 1084 else: … … 1086 1088 ti = self.active_comp.connections.index(tc) 1087 1089 del self.active_comp.connections[ti] 1088 1090 1089 1091 self.displayComps() 1090 1092 self.displayNodes() … … 1112 1114 for x in self.compBoxPopup.GetMenuItems(): 1113 1115 if x.GetLabel() != 'Remove': 1114 x.Enable(False) 1115 1116 self.compBox.PopupMenu(self.compBoxPopup) 1116 x.Enable(False) 1117 1118 self.compBox.PopupMenu(self.compBoxPopup) 1117 1119 event.Skip() 1118 1120 1119 1121 def OnCompBoxPopupSet_acMenu(self, event): 1120 1122 for c in self.active_wave.components: 1121 c.AssemblyController = False 1123 c.AssemblyController = False 1122 1124 self.active_comp.AssemblyController = True 1123 1125 self.displayComps() … … 1127 1129 self.EditComponent() 1128 1130 event.Skip() 1129 1131 1130 1132 def OnCompBoxPopupConnectMenu(self, event): 1131 1133 self.ConnectComponent() … … 1137 1139 # what to do when the connections are supported : 1138 1140 #sn = self.nodeBox.GetSelection() 1139 #self.active_comp = self.nodeBox.GetPyData(sn) #active component is actually and active resource 1141 #self.active_comp = self.nodeBox.GetPyData(sn) #active component is actually and active resource 1140 1142 #self.ConnectComponent() 1141 1143 … … 1168 1170 self.active_comp = self.compBox.GetPyData(sn) 1169 1171 newname = event.GetLabel() 1170 1172 1171 1173 if len(newname) > 0: 1172 1174 for c in self.active_wave.components: … … 1175 1177 event.Veto() 1176 1178 return 1177 1179 1178 1180 #Component names with spaces do not work 1179 1181 if newname.find(' ') != -1: … … 1183 1185 #newname = newname.replace(' ','_') 1184 1186 #self.compBox.SetItemText(sn,newname) 1185 1187 1186 1188 self.active_comp.changeName(newname) 1187 1189 #self.active_comp.name = newname … … 1192 1194 event.Veto() 1193 1195 return 1194 event.Skip() 1195 1196 def OnCompBoxTreeBeginLabelEdit(self, event): 1196 event.Skip() 1197 1198 def OnCompBoxTreeBeginLabelEdit(self, event): 1197 1199 sn = self.compBox.GetSelection() 1198 1200 if sn == self.compBox.GetRootItem(): … … 1207 1209 event.Veto() 1208 1210 return 1209 event.Skip() 1211 event.Skip() 1210 1212 1211 1213 def OnCompBoxPopupRenameMenu(self, event): … … 1227 1229 1228 1230 event.Skip() 1229 1231 1230 1232 def OnCompBoxPopupRefreshMenu(self, event): 1231 1233 self.displayComps() 1232 event.Skip() 1233 1234 event.Skip() 1235 1234 1236 ################################################################# 1235 1237 ## Waveform Menu Stuff 1236 1238 ################################################################# 1237 1239 1238 1240 def OnMenuWaveformAddcompMenu(self, event): 1239 1241 ComponentFrame.newComponentFrame() … … 1258 1260 errorMsg(self,'Only top level components can be connected!') 1259 1261 return 1260 1262 1261 1263 self.ConnectComponent() 1262 1264 event.Skip() … … 1274 1276 errorMsg(self,'Only top level components can be edited!') 1275 1277 return 1276 1278 1277 1279 self.EditComponent() 1278 1280 event.Skip() … … 1283 1285 errorMsg(self,'Please enter a waveform name first') 1284 1286 return 1285 1286 nFlag = False 1287 1288 nFlag = False 1287 1289 for c in self.active_wave.components: 1288 1290 if c.name == tempLn: 1289 1291 nFlag = True 1290 1292 1291 1293 if nFlag == True: 1292 1294 tmpstr = "One of the waveform components has the same name as the waveform.\n" … … 1302 1304 node_names.append(n.name) 1303 1305 for d in n.Devices: 1304 device_ids.append(d.uuid) 1306 device_ids.append(d.uuid) 1305 1307 1306 1308 ##check for duplicate node names … … 1309 1311 # errorMsg(self,"Duplicate node names detected. This is not allowed.") 1310 1312 # return 1311 1313 1312 1314 #check for duplicates in the device uuids 1313 1315 tmp = list(set(device_ids)) #removes duplicates from the list 1314 1316 if len(tmp) != len(device_ids): #if there were duplicates (multiple copies of same device instances) 1315 1317 errorMsg(self,"Duplicate nodes or device instantiation UUIDs have been detected. This is not allowed.") 1316 return 1318 return 1317 1319 1318 1320 acFlag = False … … 1337 1339 dlg.Destroy() 1338 1340 #return 1339 1341 1340 1342 if len(noDevs) > 0: 1341 1343 tmpstr = 'The following components are not assigned to a device. ' … … 1344 1346 tmpstr += x + '\n' 1345 1347 errorMsg(self,tmpstr) 1346 1348 1347 1349 self.waveName = tempLn 1348 1350 self.active_wave.name = tempLn 1349 1351 1350 1352 dlg = wx.DirDialog(self,"Please select the place to generate the code",style=wx.DD_NEW_DIR_BUTTON) 1351 1353 dlg.SetPath(os.path.expanduser('~')) … … 1357 1359 finally: 1358 1360 dlg.Destroy() 1359 1360 gen = genStruct.genAll(self.path, copy.deepcopy(self.active_wave))1361 1362 gen = genStruct.genAll(self.path, self.wavedevPath, copy.deepcopy(self.active_wave)) 1361 1363 gen.genDirs() 1362 1364 # Only include the device manager files if there is just one node … … 1370 1372 if c.generate: 1371 1373 gen.genCompFiles(c) 1372 1373 xml_gen.genxml(copy.deepcopy(self.active_wave.components), self.path,self.active_wave.name)1374 xml_gen.genDAS(copy.deepcopy(self.active_wave.components), self.path,self.active_wave.name)1375 xml_gen.writeWaveSetuppy(self.path, self. active_wave.name)1376 1377 #save the .owd file 1374 1375 xml_gen.genxml(copy.deepcopy(self.active_wave.components), self.path, self.wavedevPath, self.active_wave.name) 1376 xml_gen.genDAS(copy.deepcopy(self.active_wave.components), self.path, self.wavedevPath, self.active_wave.name) 1377 xml_gen.writeWaveSetuppy(self.path, self.wavedevPath, self.active_wave.name) 1378 1379 #save the .owd file 1378 1380 f = open(self.path + "/" + self.waveName + "/" + self.waveName + ".owd",'w') 1379 cPickle.dump(('project',self.active_wave,self.active_plat),f) 1380 1381 cPickle.dump(('project',self.active_wave,self.active_plat),f) 1382 1381 1383 #generate the dcd file for each node 1382 1384 #for n in self.active_plat.nodes: … … 1387 1389 # tmpname = 'DeviceManager' + n.name 1388 1390 # folderFlag = True 1389 #xml_gen.genDeviceManager(n, self.path,self.active_wave.name,tmpname,folderFlag)1390 1391 #xml_gen.genDeviceManager(n, self.path, self.wavedevPath, self.active_wave.name, tmpname,folderFlag) 1392 1391 1393 gen.cleanUp() 1392 1394 … … 1401 1403 for x in self.active_wave.components: 1402 1404 if x.generate == True: 1403 x.ace = False 1404 1405 event.Skip() 1406 1407 1405 x.ace = False 1406 1407 event.Skip() 1408 1409 1408 1410 ################################################################################ 1409 1411 ## Resource Functionality 1410 1412 ################################################################################ 1411 1413 1412 1414 def displayResources(self): 1413 1415 self.resourceBox.DeleteAllItems() … … 1416 1418 devRoot = self.resourceBox.AppendItem(troot,'Devices',image=1) 1417 1419 nodeRoot = self.resourceBox.AppendItem(troot,'Nodes',image=1) 1418 1420 1419 1421 for c in self.Available_Components: 1420 1422 t1 = self.resourceBox.AppendItem(compRoot,c.name) 1421 1423 self.resourceBox.SetPyData(t1,c) 1422 1424 1423 1425 for c in self.Available_Devices: 1424 1426 t1 = self.resourceBox.AppendItem(devRoot,c.name) 1425 1427 self.resourceBox.SetPyData(t1,c) 1426 1428 1427 1429 for n in self.Available_Nodes: 1428 1430 t1 = self.resourceBox.AppendItem(nodeRoot,n.name) 1429 1431 self.resourceBox.SetPyData(t1,n) 1430 1431 1432 1433 1432 1434 if self.resourceBox.GetChildrenCount(troot,recursively=False) > 0: 1433 1435 cid1,cookie1 = self.resourceBox.GetFirstChild(troot) … … 1437 1439 self.resourceBox.SortChildren(cid1) 1438 1440 1439 def loadResources(self): 1441 def loadResources(self): 1440 1442 self.Available_Components = [] 1441 1443 self.Available_Devices = [] 1442 1444 self.Available_Nodes = [] 1443 1445 1444 1446 resList = [] 1445 1447 … … 1459 1461 tmpResPath = r[0] + r[1] 1460 1462 tmpComp = importResource.getResource(tmpResPath,tmpResName,self) 1461 1463 1462 1464 if tmpComp == None: 1463 1465 continue … … 1470 1472 elif tmpComp.type == 'device': 1471 1473 self.Available_Devices.append(tmpComp) 1472 1474 1473 1475 nodeList = [] 1474 1476 if os.path.isdir(self.installPath + 'nodes'): … … 1476 1478 else: 1477 1479 errorMsg(self, "No nodes could be found in: " + self.installPath) 1478 1480 1479 1481 # find the scd files for each node 1480 1482 for node_name in nodeList: … … 1497 1499 nodeName = node_name 1498 1500 nodePath = self.installPath + 'nodes/' + nodeName + '/' 1499 1501 1500 1502 tmpNode = importNode.getNode(nodePath,nodeName,self) 1501 1503 if tmpNode == None: … … 1503 1505 continue 1504 1506 self.Available_Nodes.append(tmpNode) 1505 1507 1506 1508 self.displayResources() 1507 1509 1508 def OnRefreshResourceBtnButton(self, event): 1510 def OnRefreshResourceBtnButton(self, event): 1509 1511 self.loadResources() 1510 1512 … … 1528 1530 if c.baseName == tmpBaseName: 1529 1531 tmpCount += 1 1530 1532 1531 1533 dlg = wx.TextEntryDialog(self, 'Please enter an instance name for this '\ 1532 1534 + tmpRes.name + ' component.', 'Enter Name', tmpRes.name + str(tmpCount)) … … 1539 1541 dlg.Destroy() 1540 1542 return 1541 1543 1542 1544 for c in self.active_wave.components: 1543 1545 if newname == c.name: … … 1550 1552 finally: 1551 1553 dlg.Destroy() 1552 1553 1554 1555 1554 1556 newRes = copy.deepcopy(tmpRes) 1555 newRes.name = newname 1556 newRes.baseName = tmpBaseName 1557 newRes.name = newname 1558 newRes.baseName = tmpBaseName 1557 1559 newRes.setUUID() # this gives the component instance a unique id 1558 1560 # we do not set the newRes.file_uuid because it is the same for all components of this type 1559 1561 1560 1562 self.active_wave.components.append(newRes) 1561 1563 self.displayComps() … … 1578 1580 x.Enable(True) 1579 1581 tmpRes = self.resourceBox.GetPyData(sn) 1580 if tmpRes.type == 'resource': 1582 if tmpRes.type == 'resource': 1581 1583 x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPADDDEV) 1582 x.Enable(False) 1584 x.Enable(False) 1583 1585 x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPADDNODE) 1584 x.Enable(False) 1585 1586 x.Enable(False) 1587 1586 1588 #x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPGETDESCR) 1587 1589 #x.Enable(False) 1588 1590 1589 1591 #disable Doxygen docs display if no docs directory found 1590 1592 docsPath = self.installPath + 'docs/' + tmpRes.name … … 1594 1596 elif tmpRes.type == 'node': 1595 1597 x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPADDDEV) 1596 x.Enable(False) 1598 x.Enable(False) 1597 1599 x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPADD) 1598 x.Enable(False) 1599 #x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPGETDESCR) 1600 #x.Enable(False) 1601 x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPGETDOXYGENREFMAN) 1602 x.Enable(False) 1603 else: 1604 x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPADDNODE) 1605 x.Enable(False) 1606 x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPADD) 1607 x.Enable(False) 1600 x.Enable(False) 1608 1601 #x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPGETDESCR) 1609 1602 #x.Enable(False) 1610 1603 x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPGETDOXYGENREFMAN) 1611 1604 x.Enable(False) 1605 else: 1606 x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPADDNODE) 1607 x.Enable(False) 1608 x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPADD) 1609 x.Enable(False) 1610 #x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPGETDESCR) 1611 #x.Enable(False) 1612 x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPGETDOXYGENREFMAN) 1613 x.Enable(False) 1612 1614 1613 1615 #if tmpRes != None: 1614 self.resourceBox.PopupMenu(self.resourceBoxPopup) 1616 self.resourceBox.PopupMenu(self.resourceBoxPopup) 1615 1617 event.Skip() 1616 1618 … … 1633 1635 sn = self.resourceBox.GetSelection() 1634 1636 tmpRes = self.resourceBox.GetPyData(sn) 1635 1637 1636 1638 if len(self.active_plat.nodes) == 0: 1637 1639 tmpstr = "There are no available nodes to add a device instance to.\n" … … 1639 1641 errorMsg(self,tmpstr) 1640 1642 return 1641 1643 1642 1644 tmpBaseName = tmpRes.name 1643 1645 #tmpCount = 1 … … 1646 1648 # if x.baseName == tmpBaseName: 1647 1649 # tmpCount += 1 1648 1650 1649 1651 #dlg = NodeDialog.create(self,self.active_plat.nodes,tmpBaseName + str(tmpCount)) 1650 1652 dlg = NodeDialog.create(self,self.active_plat.nodes,tmpBaseName) 1651 1653 1652 1654 try: 1653 1655 returnCode = dlg.ShowModal() … … 1659 1661 basename = newname 1660 1662 newname = newname+str(tmpCount) 1661 1663 1662 1664 while iterator < len(tmpnode.Devices): 1663 1665 for c in tmpnode.Devices: … … 1684 1686 finally: 1685 1687 dlg.Destroy() 1686 1687 1688 1689 1688 1690 newDev = copy.deepcopy(tmpRes) 1689 newDev.name = newname 1690 newDev.baseName = tmpBaseName 1691 newDev.generate = False 1691 newDev.name = newname 1692 newDev.baseName = tmpBaseName 1693 newDev.generate = False 1692 1694 newDev.node = tmpnode.name 1693 1695 newDev.setUUID() # this gives the device instance a unique id 1694 1696 # we do not set the newDev.file_uuid because it is the same for all devices of this type 1695 1697 1696 1698 tmpnode.Devices.append(newDev) 1697 1699 self.displayNodes() … … 1731 1733 errorMsg(self,'Neither index.html nor refman.pdf found in ' + docsPath + ': directory listing: ' + str(docList)) 1732 1734 else: 1733 errorMsg(self,'No directory for ' + tmpRes.name + ' could be found in: ' + self.installPath + 'docs') 1735 errorMsg(self,'No directory for ' + tmpRes.name + ' could be found in: ' + self.installPath + 'docs') 1734 1736 return 1735 1737 … … 1740 1742 self.displayNodes() 1741 1743 event.Skip() 1742 1744 1743 1745 ################################################################################ 1744 1746 ## Platform Layout Functionality … … 1748 1750 self.nodeBox.DeleteAllItems() 1749 1751 troot = self.nodeBox.AddRoot("the_root") 1750 1752 1751 1753 for n in self.active_plat.nodes: 1752 1754 t1 = self.nodeBox.AppendItem(troot,n.name) 1753 1755 self.nodeBox.SetPyData(t1,n) 1754 1756 1755 1757 for d in n.Devices: 1756 1758 t2 = self.nodeBox.AppendItem(t1,unicode(d.name)) 1757 1759 self.nodeBox.SetPyData(t2,d) 1758 1760 1759 1761 for c in self.active_wave.components: 1760 1762 if c.device == d: 1761 1763 t3 = self.nodeBox.AppendItem(t2,c.name) 1762 1764 self.nodeBox.SetPyData(t3,c) 1763 1765 1764 1766 def AddNode(self): 1765 1767 tmpCount = len(self.active_plat.nodes) + 1 1766 1768 1767 1769 dlg = wx.TextEntryDialog(self, 'Please enter a name for this node ',\ 1768 1770 'Enter Name', 'Node' + str(tmpCount)) … … 1775 1777 dlg.Destroy() 1776 1778 return 1777 1779 1778 1780 for c in self.active_plat.nodes: 1779 1781 if newname == c.name: … … 1786 1788 finally: 1787 1789 dlg.Destroy() 1788 1790 1789 1791 #tmpNode = PlatformClass.Node(newname) 1790 1792 tmpNode = ComponentClass.Node(name=newname) … … 1795 1797 errorMsg(self, 'WARNING: You will have to regenerate your waveform if you continue') 1796 1798 sn = self.nodeBox.GetSelection() 1797 1799 1798 1800 #generate the dcd file for the selected node 1799 1801 dlg = wx.DirDialog(self,"Please select the place to generate the code",style=wx.DD_NEW_DIR_BUTTON) … … 1807 1809 dlg.Destroy() 1808 1810 active_node = None 1809 1811 1810 1812 tmp_count = 0 1811 1813 duplicate_name_flag = False … … 1814 1816 dev_count = 0 1815 1817 while dev_count < len(self.active_plat.nodes[tmp_count].Devices): 1816 tmp_uuid = unicode( ComponentClass.uuidgen())1818 tmp_uuid = unicode(uuidgen.uuidgen()) 1817 1819 n.Devices[dev_count].uuid = tmp_uuid 1818 1820 self.active_plat.nodes[tmp_count].Devices[dev_count].uuid = tmp_uuid 1819 dev_count = dev_count + 1 1821 dev_count = dev_count + 1 1820 1822 active_node = n 1821 1823 break … … 1827 1829 1828 1830 1829 gen = genNode.genAll(self.path, copy.deepcopy(active_node))1831 gen = genNode.genAll(self.path, self.wavedevPath, copy.deepcopy(active_node)) 1830 1832 gen.genDirs() 1831 1833 gen.writeMakefile() 1832 1834 # TODO: use different configure.ac file for node -JDG 1833 1835 gen.genConfigureACFiles(self.installPath) 1834 xml_gen.genDeviceManager(n, self.path,n.name,"DeviceManager",False)1835 1836 1836 xml_gen.genDeviceManager(n, self.path, self.wavedevPath, n.name, "DeviceManager", False) 1837 1838 1837 1839 def RemoveNodeBoxSelection(self): 1838 1840 sn = self.nodeBox.GetSelection() 1839 1841 snParent = self.nodeBox.GetItemParent(sn) 1840 if snParent == self.nodeBox.GetRootItem(): 1841 # a platform node 1842 if snParent == self.nodeBox.GetRootItem(): 1843 # a platform node 1842 1844 tmpMsg = " Are you sure you want to remove this Node?\n\n" 1843 1845 tmpMsg += "All device instances assigned to this node will be removed,\n" … … 1846 1848 return 1847 1849 tmpNode = self.nodeBox.GetPyData(sn) 1848 for n in self.active_plat.nodes: 1849 if tmpNode == n: 1850 for n in self.active_plat.nodes: 1851 if tmpNode == n: 1850 1852 for d in n.Devices: 1851 1853 # If any other component is connected to this device - connection must be removed … … 1860 1862 dIndex = self.active_plat.nodes.index(tmpNode) 1861 1863 del self.active_plat.nodes[dIndex] 1862 1864 1863 1865 elif self.nodeBox.GetItemParent(snParent) == self.nodeBox.GetRootItem(): 1864 1866 # a device instance … … 1873 1875 if con.remoteComp == tmpDev: 1874 1876 ci = c.connections.index(con) 1875 del c.connections[ci] 1876 1877 for n in self.active_plat.nodes: 1877 del c.connections[ci] 1878 1879 for n in self.active_plat.nodes: 1878 1880 for d in n.Devices: 1879 1881 if tmpDev == d: … … 1890 1892 tmpComp = self.nodeBox.GetPyData(sn) 1891 1893 tmpComp.device = None 1892 1894 1893 1895 self.displayNodes() 1894 1896 self.displayComps() … … 1922 1924 self.nodeBoxPopup.Enable(wxID_FRAME1NODEBOXPOPUPGENERATE,False) 1923 1925 self.nodeBoxPopup.Enable(wxID_FRAME1NODEBOXPOPUPRENAME,False) 1924 1925 self.nodeBox.PopupMenu(self.nodeBoxPopup) 1926 1927 self.nodeBox.PopupMenu(self.nodeBoxPopup) 1926 1928 event.Skip() 1927 1929 … … 1933 1935 self.RemoveNodeBoxSelection() 1934 1936 event.Skip() 1935 1937 1936 1938 def OnNodeBoxPopupGenerateMenu(self, event): 1937 1939 self.GenerateNodeBoxSelection() … … 1940 1942 def OnNodeBoxPopupExpandMenu(self, event): 1941 1943 troot = self.nodeBox.GetRootItem() 1942 if self.nodeBox.ItemHasChildren(troot): 1944 if self.nodeBox.ItemHasChildren(troot): 1943 1945 cid1,cookie1 = self.nodeBox.GetFirstChild(troot) 1944 1946 self.ExpandTreeNode(self.nodeBox,cid1) … … 1947 1949 self.ExpandTreeNode(self.nodeBox,cid1) 1948 1950 cid1 = self.nodeBox.GetNextSibling(cid1) 1949 1950 event.Skip() 1951 1951 1952 event.Skip() 1953 1952 1954 def OnNodeBoxPopupRefreshMenu(self, event): 1953 1955 self.displayNodes() … … 1972 1974 event.Veto() 1973 1975 return 1974 event.Skip() 1976 event.Skip() 1975 1977 1976 1978 def OnNodeBoxTreeEndLabelEdit(self, event): … … 1990 1992 event.Veto() 1991 1993 return 1992 1994 1993 1995 #Node names with spaces do not work 1994 1996 if newname.find(' ') != -1: … … 1996 1998 event.Veto() 1997 1999 return 1998 2000 1999 2001 tempNode.name = newname 2000 2002 else: … … 2009 2011 newname = event.GetLabel() 2010 2012 if len(newname) > 0: 2011 for d in tempNode.Devices: 2013 for d in tempNode.Devices: 2012 2014 if d != tempDev and d.name == newname: 2013 2015 errorMsg(self,'Invalid name - a device instance with that name already exists') 2014 2016 event.Veto() 2015 2017 return 2016 2018 2017 2019 #Device names with spaces do not work 2018 2020 if newname.find(' ') != -1: … … 2020 2022 event.Veto() 2021 2023 return 2022 2024 2023 2025 tempDev.changeName(newname) 2024 2026 2025 2027 else: 2026 2028 # a child component (connection) 2027 2029 event.Veto() 2028 2030 return 2029 2030 event.Skip() 2031 2032 event.Skip() 2031 2033 2032 2034 ################################################################# … … 2053 2055 self.ExpandTreeNode(whichBox,cid1) 2054 2056 cid1 = self.nodeBox.GetNextSibling(cid1) 2055 2057 2056 2058 ############################################################################### 2057 2059 ## LoadConfiguration 2058 ## This function is not a part of the frame class so that other modules can 2060 ## This function is not a part of the frame class so that other modules can 2059 2061 ## call it 2060 ############################################################################### 2062 ############################################################################### 2061 2063 def LoadConfiguration(frame_obj): 2062 2064 '''Extracts information from configuration file''' … … 2070 2072 except: 2071 2073 frame_obj.version = "unknown" 2072 2074 2073 2075 # install path 2074 2076 try: … … 2110 2112 errorMsg(frame_obj,tmpstr) 2111 2113 2112 2114 2113 2115 # custom IDL path 2114 2116 use_default_customidlpath = False … … 2161 2163 tmpstr += "using CF interfaces.\n\n" 2162 2164 tmpstr += "If you have ossie installed in a location other than\n" 2163 tmpstr += "the default please specify that location in the\n" 2165 tmpstr += "the default please specify that location in the\n" 2164 2166 tmpstr += "wavedev.cfg file located in the top directory." 2165 2167 errorMsg(frame_obj,tmpstr) -
ossiedev/trunk/tools/WaveDev/wavedev/PropertiesDialog.py
r5941 r8046 6 6 from errorMsg import * 7 7 import commands 8 from uuidgen import uuidgen 8 9 9 10 def create(parent): 10 11 return PropertiesDialog(parent) 11 12 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, 29 30 ] = [wx.NewId() for _init_ctrls in range(34)] 30 31 … … 238 239 self.calledByParent = False 239 240 self.active_prop = None 240 241 241 242 def OnPropertiesDialogActivate(self, event): 242 243 if self.calledByParent == True: 243 244 244 245 self.active_comp = self.parent.active_comp 245 246 246 247 if self.active_prop == None: 247 248 self.elementType = "Simple" … … 262 263 tmp = self.modeChoice.FindString(self.active_prop.mode) 263 264 self.modeChoice.SetSelection(tmp) 264 self.elementType = self.active_prop.elementType 265 self.elementType = self.active_prop.elementType 265 266 tmp = self.elementChoice.FindString(self.elementType) 266 267 self.elementChoice.SetSelection(tmp) … … 272 273 273 274 self.refreshDisplay() 274 275 275 276 self.calledByParent = False 276 277 event.Skip() … … 284 285 pos = self.elementChoice.GetSelection() 285 286 if pos == wx.NOT_FOUND: 286 return 287 return 287 288 self.elementType = self.elementChoice.GetString(pos) 288 289 if self.elementType != "Simple" and self.elementType != "SimpleSequence": … … 290 291 self.elementType = "Simple" 291 292 self.elementChoice.SetSelection(0) 292 293 293 294 self.refreshDisplay() 294 295 event.Skip() 295 296 296 297 def refreshDisplay(self): 297 298 if self.active_prop != None: 298 299 299 300 if self.active_prop.elementType == "Simple": 300 301 pass … … 305 306 self.addValue.Enable(True) 306 307 self.enumBox.Enable(True) 307 308 308 309 pos = self.kindChoice.GetSelection() 309 310 if pos != wx.NOT_FOUND: … … 312 313 else: 313 314 self.actionChoice.Enable(False) 314 315 315 316 elif self.elementType == "SimpleSequence": 316 317 self.addValue.Enable(True) 317 318 self.enumBox.Enable(False) 318 319 319 320 def initializeDisplay(self): 320 321 if self.elementType == "Simple" or self.elementType == "SimpleSequence": … … 322 323 pos = self.typeChoice.FindString(self.active_prop.type) 323 324 self.typeChoice.SetSelection(pos) 324 325 325 326 # Load the action (ie. eq, lt, ge) 326 327 if self.active_prop.action != None: 327 328 pos = self.actionChoice.FindString(self.active_prop.action) 328 329 self.actionChoice.SetSelection(pos) 329 330 330 331 # Load the kind (ie. allocation, configure, execparam) 331 332 pos = self.kindChoice.FindString(self.active_prop.kind) … … 336 337 pass 337 338 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])) 340 341 341 342 # If this is already installed on the system - can't change anything but the value(s) … … 352 353 self.modeChoice.Enable(False) 353 354 self.description.Enable(False) 354 355 if self.elementType == "Simple": 355 356 if self.elementType == "Simple": 356 357 # Load the value for a Simple type 357 358 self.valueList.InsertStringItem(0,unicode(self.active_prop.value)) 358 359 self.valueList.SetStringItem(0,1,unicode(self.active_prop.defaultValue)) 359 360 360 361 # Load the enumeration 361 362 if self.active_prop.enum != '': 362 363 self.enumBox.SetValue(self.active_prop.enum) 363 364 if self.elementType == "SimpleSequence": 364 365 if self.elementType == "SimpleSequence": 365 366 for v in self.active_prop.values: 366 367 self.valueList.InsertStringItem(0,v) #create list (backwards at first) … … 383 384 self.valueList.SetStringItem(0,1,tmpStr) 384 385 self.valueBox.Clear() 385 386 386 387 self.refreshDisplay() 387 388 event.Skip() … … 400 401 def OnValueListRightUp(self, event): 401 402 self.valueList.PopupMenu(self.valueListPopup) 402 403 403 404 event.Skip() 404 405 … … 406 407 self.Close() 407 408 event.Skip() 408 409 409 410 def OnAddPropButton(self, event): 410 411 # Check for the name … … 413 414 errorMsg(self,"Please enter a property name first!") 414 415 return 415 416 416 417 # Check for the id 417 418 tmpid = self.idBox.GetLineText(0) … … 419 420 errorMsg(self,"Please enter a property id first!") 420 421 return 421 422 422 423 # Check for the mode 423 424 pos = self.modeChoice.GetSelection() 424 425 if pos == wx.NOT_FOUND: 425 426 errorMsg(self,"Please select a property mode first!") 426 return 427 return 427 428 tmpMode = self.modeChoice.GetString(pos) 428 429 429 430 # Get the description 430 431 tmpDes = self.description.GetValue() 431 432 432 433 # Check for the type ex: bool, char, short, etc. 433 434 pos = self.typeChoice.GetSelection() 434 435 if pos == wx.NOT_FOUND: 435 436 errorMsg(self,"Please select a type first!") 436 return 437 return 437 438 tmpType = self.typeChoice.GetString(pos) 438 439 439 440 if self.elementType == "Simple": 440 441 # instantiate the property object 441 442 newProp = CC.SimpleProperty(tmpName,tmpMode,tmpType,tmpDes) 442 443 443 444 # store the default value and the value 444 445 if self.valueList.GetItemCount() == 0: 445 446 errorMsg(self,"Please enter a value first!") 446 447 return 447 448 448 449 v = self.valueList.GetItem(0,0) 449 450 dv = self.valueList.GetItem(0,1) 450 451 newProp.value = v.GetText() 451 452 newProp.defaultValue = dv.GetText() 452 453 453 454 if self.elementType == "SimpleSequence": 454 455 # store the default value and the value … … 456 457 errorMsg(self,"Please enter a value first!") 457 458 return 458 459 459 460 newProp = CC.SimpleSequenceProperty(tmpName,tmpMode,tmpType,tmpDes) 460 461 461 462 462 463 newProp.values = [] 463 newProp.defaultValues = [] 464 464 newProp.defaultValues = [] 465 465 466 for x in range(self.valueList.GetItemCount()): 466 467 v = self.valueList.GetItem(x,0) … … 472 473 # store the enum if any 473 474 newProp.enum = self.enumBox.GetLineText(0) 474 475 475 476 # Check for the kind ex: allocation, configure, test, etc. 476 477 pos = self.kindChoice.GetSelection() 477 478 if pos == wx.NOT_FOUND: 478 479 errorMsg(self,"Please select a kind first!") 479 return 480 return 480 481 newProp.kind = self.kindChoice.GetString(pos) 481 482 482 483 # Check and store the range 483 484 tmpMin = self.minBox.GetLineText(0) 484 485 tmpMax = self.maxBox.GetLineText(0) 485 486 486 487 if tmpMin == 'min' or tmpMin == '': 487 488 tmpMin = -1 488 489 489 490 if tmpMax == 'max' or tmpMax == '': 490 491 tmpMax = -1 491 492 492 493 newProp.range = (tmpMin,tmpMax) 493 494 494 495 # Check and store the action 495 496 pos = self.actionChoice.GetSelection() … … 497 498 if newProp.kind == "allocation": 498 499 errorMsg(self,"Please select an action first!") 499 return 500 return 500 501 else: 501 502 newProp.action = self.actionChoice.GetString(pos) 502 503 503 504 self.parent.active_comp.properties.append(newProp) 504 505 self.Close() 505 506 event.Skip() 507 506 507 event.Skip() 508 508 509 def OnOkButton(self, event): 509 510 if self.editable: … … 514 515 return 515 516 self.active_prop.name = tmpName 516 517 517 518 # Check for the id 518 519 tmpid = self.idBox.GetLineText(0) … … 521 522 return 522 523 self.active_prop.id = tmpid 523 524 524 525 # Check for the mode 525 526 pos = self.modeChoice.GetSelection() 526 527 if pos == wx.NOT_FOUND: 527 528 errorMsg(self,"Please select a property mode first!") 528 return 529 return 529 530 tmpMode = self.modeChoice.GetString(pos) 530 531 self.active_prop.mode = tmpMode 531 532 532 533 # Get the description 533 534 tmpDes = self.description.GetValue() 534 535 self.active_prop.description = tmpDes 535 536 536 537 # Check for the type ex: bool, char, short, etc. 537 538 pos = self.typeChoice.GetSelection() 538 539 if pos == wx.NOT_FOUND: 539 540 errorMsg(self,"Please select a type first!") 540 return 541 return 541 542 tmpType = self.typeChoice.GetString(pos) 542 543 self.active_prop.type = tmpType 543 544 544 545 if self.elementType == "Simple": 545 546 # store the default value and the value … … 547 548 errorMsg(self,"Please enter a value first!") 548 549 return 549 550 550 551 v = self.valueList.GetItem(0,0) 551 552 dv = self.valueList.GetItem(0,1) 552 553 self.active_prop.value = v.GetText() 553 554 self.active_prop.defaultValue = dv.GetText() 554 555 555 556 if self.elementType == "SimpleSequence": 556 557 # store the default value and the value … … 558 559 errorMsg(self,"Please enter a value first!") 559 560 return 560 561 561 562 self.active_prop.values = [] 562 563 self.active_prop.defaultValues = [] 563 564 564 565 for x in range(self.valueList.GetItemCount()): 565 566 v = self.valueList.GetItem(x,0) 566 567 dv = self.valueList.GetItem(x,1) 567 568 568 569 self.active_prop.values.append(v.GetText()) 569 570 self.active_prop.defaultValues.append(dv.GetText()) 570 571 571 572 # store the enum if any 572 573 self.active_prop.enum = self.enumBox.GetLineText(0) 573 574 574 575 # Check for the kind ex: allocation, configure, test, etc. 575 576 pos = self.kindChoice.GetSelection() 576 577 if pos == wx.NOT_FOUND: 577 578 errorMsg(self,"Please select a kind first!") 578 return 579 return 579 580 self.active_prop.kind = self.kindChoice.GetString(pos) 580 581 581 582 # Check and store the range 582 583 tmpMin = self.minBox.GetLineText(0) 583 584 tmpMax = self.maxBox.GetLineText(0) 584 585 585 586 if tmpMin == 'min' or tmpMin == '': 586 587 tmpMin = -1 587 588 588 589 if tmpMax == 'max' or tmpMax == '': 589 590 tmpMax = -1 590 591 591 592 self.active_prop.range = (tmpMin,tmpMax) 592 593 593 594 # Check and store the action 594 595 pos = self.actionChoice.GetSelection() … … 596 597 if self.active_prop.kind == "allocation": 597 598 errorMsg(self,"Please select an action first!") 598 return 599 return 599 600 else: 600 601 self.active_prop.action = self.actionChoice.GetString(pos) 601 602 602 603 else: 603 604 if self.elementType == "Simple": … … 606 607 errorMsg(self,"Please enter a value first!") 607 608 return 608 609 609 610 v = self.valueList.GetItem(0,0) 610 611 dv = self.valueList.GetItem(0,1) 611 612 self.active_prop.value = v.GetText() 612 613 self.active_prop.defaultValue = dv.GetText() 613 614 614 615 if self.elementType == "SimpleSequence": 615 616 # store the default value and the value … … 617 618 errorMsg(self,"Please enter a value first!") 618 619 return 619 620 620 621 self.active_prop.values = [] 621 622 self.active_prop.defaultValues = [] 622 623 623 624 for x in range(self.valueList.GetItemCount()): 624 625 v = self.valueList.GetItem(x,0) … … 626 627 self.active_prop.values.append(v.GetText()) 627 628 self.active_prop.defaultValues.append(dv.GetText()) 628 629 629 630 self.Close() 630 631 631 632 def OnKindChoiceChoice(self, event): 632 633 self.refreshDisplay() 633 634 event.Skip() 634 635 #-------------------------------------------------------------------------------636 #637 # UUID Generator638 #639 def uuidgen():640 return commands.getoutput('uuidgen -t')641 -
ossiedev/trunk/tools/WaveDev/wavedev/XML_gen/application_gen.py
r5914 r8046 19 19 import sys 20 20 import commands 21 import os 21 import os 22 22 import shutil 23 23 import component_gen 24 from component_gen import ensureDocType 24 25 import xml.dom.minidom 25 26 from xml.dom.minidom import Node 26 27 import xmlBeautify 27 28 import WaveDev.wavedev.ComponentClass as CC 28 29 30 # UUID Generator 31 def uuidgen(): 32 return commands.getoutput('uuidgen -t') 33 34 try: 35 doc_cfg = xml.dom.minidom.parse('../wavedev.cfg') 36 except: #if not being called from wavedev, try looking for the file 37 doc_cfg = xml.dom.minidom.parse('/sdr/tools/WaveDev/wavedev.cfg') 38 39 40 version = str(doc_cfg.getElementsByTagName("version")[0].firstChild.data) 41 42 #vtext = open('../version.txt') 43 #version = unicode(vtext.readline()) 44 #version = version.strip('\n') 45 commentLine = u'<!--Created with OSSIE WaveDev ' + version \ 46 + u'-->\n<!--Powered by Python-->\n' 47 29 from WaveDev.wavedev.uuidgen import uuidgen 30 48 31 49 32 xmlpath = u'/xml/' 50 33 ####################################################################### 51 34 # genxml generates xml profiles for each component and the waveform 52 ####################################################################### 53 def genxml(complist, genPath, wave Name):35 ####################################################################### 36 def genxml(complist, genPath, wavedevPath, waveName): 54 37 55 38 if genPath[len(genPath)-1] != '/': 56 39 genPath = genPath + '/' 57 40 genPath = unicode(genPath) 41 if len(wavedevPath) > 0 and wavedevPath[len(wavedevPath)-1] != '/': 42 wavedevPath = wavedevPath + '/' 58 43 waveformDir = unicode(genPath + waveName + '/') 59 44 60 45 61 46 appName = unicode(waveName) 62 47 #namingServicePrefix = u'ossie' 63 48 outputFilename_sad = appName + u'.sad.xml' 64 49 65 50 # Generate the individual component xml files 66 51 for n in complist: 67 52 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 53 component_gen.gen_scd(n, genPath, wavedevPath) 54 component_gen.gen_spd(n, genPath, wavedevPath) 55 component_gen.gen_prf(n, genPath, wavedevPath) 56 72 57 #---------------------------------------------------------------------------- 73 58 # SAD Parser / Generator 74 59 # 75 60 76 61 # Use the minidom module to objectify and generate the SAD file 77 62 try: #if running from wavedev 78 doc_sad = xml.dom.minidom.parse( 'XML_gen/_sad.xml.tpl')63 doc_sad = xml.dom.minidom.parse(wavedevPath + 'XML_gen/_sad.xml.tpl') 79 64 except: #if not being called from wavedev, try looking for the file 80 65 doc_sad = xml.dom.minidom.parse('/sdr/tools/WaveDev/wavedev/XML_gen/_sad.xml.tpl') … … 82 67 doc_sad.getElementsByTagName("softwareassembly")[0].setAttribute("name", u'OSSIE::' + appName ) 83 68 doc_sad.getElementsByTagName("softwareassembly")[0].setAttribute("id", u'DCE:' + unicode(uuidgen()) ) 84 69 85 70 # get root nodes for componentfiles, partitioning, assemblycontroller, and connections tags 86 71 componentfilesNode = doc_sad.getElementsByTagName("componentfiles")[0] … … 88 73 assemblycontrollerNode = doc_sad.getElementsByTagName("assemblycontroller")[0] 89 74 connectionsNode = doc_sad.getElementsByTagName("connections")[0] 90 91 baseComponentList = [] 75 76 baseComponentList = [] 92 77 for n in complist: 93 78 # Generate the componentfile entries 94 79 #tmpid = unicode(n.name) + u'_' + unicode(uuidgen()) 95 80 tmpid = unicode(n.baseName) + u'_' + unicode(n.file_uuid) 96 81 97 82 if n.baseName not in baseComponentList: 98 83 baseComponentList.append(n.baseName) … … 136 121 except: 137 122 pass 138 123 139 124 if overload_flag: 140 125 componentpropertiesNode = doc_sad.createElement("componentproperties") … … 184 169 namingserviceNode.setAttribute("name", NSname) 185 170 findcomponentNode.appendChild(namingserviceNode) 186 171 187 172 #TODO: append child nodes to componentplacement 188 173 componentinstantiationNode.appendChild(usagenameNode) … … 198 183 devFlag = False 199 184 200 print "Processing connection : "201 print " component name : " + cname202 print " local comp type : " + n.type203 print " local port type : " + i.localPort.type204 print " local port name : " + unicode(i.localPort.name)205 print " remote comp type: " + i.remoteComp.type206 print " remote port type: " + i.remotePort.type207 print " remote port name: " + unicode(i.remotePort.name)185 # print "Processing connection : " 186 # print " component name : " + cname 187 # print " local comp type : " + n.type 188 # print " local port type : " + i.localPort.type 189 # print " local port name : " + unicode(i.localPort.name) 190 # print " remote comp type: " + i.remoteComp.type 191 # print " remote port type: " + i.remotePort.type 192 # print " remote port name: " + unicode(i.remotePort.name) 208 193 209 194 if i.localPort.type == 'Uses': … … 244 229 c1name = "DomainName1/USRP1" 245 230 namingserviceUsesNode.setAttribute("name", c1name) 246 231 247 232 # Append child nodes 248 233 usesidentifierNode.appendChild(usesidentifierTextNode) … … 250 235 usesportNode.appendChild(usesidentifierNode) 251 236 usesportNode.appendChild(findbyUsesNode) 252 237 253 238 if devFlag != True: 254 239 providesportNode = doc_sad.createElement("providesport") … … 258 243 namingserviceProvidesNode = doc_sad.createElement("namingservice") 259 244 namingserviceProvidesNode.setAttribute("name", c2name) 260 245 261 246 # Make connections 262 247 providesidentifierNode.appendChild(providesidentifierTextNode) … … 285 270 assemblycontroller_id = u'DCE:' + unicode(n.uuid) 286 271 assemblycontrollerNode.getElementsByTagName("componentinstantiationref")[0].setAttribute("refid", assemblycontroller_id) 287 272 273 # Define <!DOCTYPE> here (overriding template if necessary) 274 ensureDocType(doc_sad, u'softwareassembly', u'../../xml/dtd/softwareassembly.dtd') 275 288 276 # Create and beautify the SAD file as a temporary file 289 277 data = doc_sad.toxml('UTF-8') 290 278 xmlBeautify.beautify(data,waveformDir + '.' + outputFilename_sad + '.tmp') 291 292 279 293 280 # Post Processing - add some of the header lines … … 304 291 postProcessed_sad.writelines(remaining) 305 292 postProcessed_sad.close() 306 293 307 294 # Remove temporary files 308 295 os.remove(waveformDir + '.' + outputFilename_sad + '.tmp') 309 296 310 297 ####################### 311 298 #Generate the DCD file … … 315 302 ################################################################################ 316 303 # Generate the Device Assignment Sequence 317 def genDAS(complist, path, wave Name):304 def genDAS(complist, path, wavedevPath, waveName): 318 305 if path[len(path)-1] != '/': 319 306 path = path + '/' … … 322 309 try: 323 310 # try to find the DAS template using a relative path (being called by OWD) 324 das = xml.dom.minidom.parse( 'XML_gen/_DAS.xml.tpl')325 except: 326 # try to find the DAS template using an absolute path 327 # (being called by other application) 311 das = xml.dom.minidom.parse(wavedevPath + 'XML_gen/_DAS.xml.tpl') 312 except: 313 # try to find the DAS template using an absolute path 314 # (being called by other application) 328 315 # if DAS file is still not found, should throw an IO Error 329 316 das = xml.dom.minidom.parse('/sdr/tools/WaveDev/wavedev/XML_gen/_DAS.xml.tpl') … … 340 327 continue 341 328 tmpDev = u'DCE:' + unicode(n.device.uuid) 342 329 343 330 deviceassignmenttypeNode = das.createElement("deviceassignmenttype") 344 331 componentidNode = das.createElement("componentid") … … 354 341 deviceassignmentsequenceNode.appendChild(deviceassignmenttypeNode) 355 342 343 # Define <!DOCTYPE> here (overriding template if necessary) 344 # ensureDocType(das, u'deploymentenforcement', u'../../xml/dtd/deploymentenforcement.dtd') 356 345 data = das.toxml('UTF-8') 357 346 xmlBeautify.beautify(data,path+'.'+waveName+'_DAS.xml.tmp') 358 347 359 348 # Post Processing - add some of the header lines 360 349 361 350 preProcessed_das = open(path+'.'+waveName+'_DAS.xml.tmp', 'r') 362 351 postProcessed_das = open(path+waveName+'_DAS.xml', 'w') 363 352 364 353 # Specify external DTD 365 354 line0 = preProcessed_das.readline() … … 370 359 postProcessed_das.writelines(remaining) 371 360 postProcessed_das.close() 372 361 373 362 # Remove temporary files 374 363 os.remove(path+'.'+waveName+'_DAS.xml.tmp') … … 376 365 ################################################################################ 377 366 # Generate the DeviceManager XML files 378 def genDeviceManager(node, path,wavName,dmName,folder=False):367 def genDeviceManager(node, path, wavedevPath, wavName, dmName, folder = False): 379 368 if path[len(path)-1] != '/': 380 369 path = path + '/' 381 370 path += wavName + '/' 382 371 383 372 waveformDir = path 384 373 if folder == True: 385 if os.path.exists(path + node.name) == False: 374 if os.path.exists(path + node.name) == False: 386 375 os.mkdir(path + node.name) 387 376 path += node.name + '/' 388 377 389 378 #Generate the DCD file for the Device Manager 390 genDCD(node.Devices, path,node.name,dmName,folder,node.generate,node.id)391 379 genDCD(node.Devices, path, wavedevPath, node.name, dmName, folder, node.generate, node.id) 380 392 381 outputFilename_spd = dmName + '.spd.xml' 393 382 outputFilename_scd = dmName + '.scd.xml' 394 383 outputFilename_prf = dmName + '.prf.xml' 395 384 396 385 #Copy and modify the spd file 397 doc_spd = xml.dom.minidom.parse( 'XML_gen/DevMan/_spd.xml.tpl')386 doc_spd = xml.dom.minidom.parse(wavedevPath + 'XML_gen/DevMan/_spd.xml.tpl') 398 387 doc_spd.getElementsByTagName("softpkg")[0].setAttribute("name", dmName) 399 388 localfileNode = doc_spd.getElementsByTagName("descriptor")[0].getElementsByTagName("localfile")[0] 400 389 localfileNode.setAttribute("name", unicode(dmName) + u'.scd.xml') 401 390 391 # Define <!DOCTYPE> here (overriding template if necessary) 392 ensureDocType(doc_spd, u'softpkg', u'../../xml/dtd/softpkg.dtd') 402 393 data = doc_spd.toxml('UTF-8') 403 394 xmlBeautify.beautify(data,path + '.' + outputFilename_spd + '.tmp') … … 417 408 postProcessed_spd.writelines(remaining) 418 409 postProcessed_spd.close() 419 410 420 411 # Remove temporary files 421 412 os.remove(path + '.' + outputFilename_spd + '.tmp') 422 413 423 414 #tempDM = CC.Component(dmName,generate=False) 424 415 #component_gen.gen_scd(tempDM,waveformDir,node.name) 425 416 426 417 # Copy the scd and prf files to directory - these aren't changed yet 427 418 print "Performing a copy to: " + path + outputFilename_scd 428 shutil.copyfile( 'XML_gen/DevMan/_scd.xml.tpl', path + outputFilename_scd)429 shutil.copyfile( 'XML_gen/DevMan/_prf.xml.tpl', path + outputFilename_prf)430 431 419 shutil.copyfile(wavedevPath + 'XML_gen/DevMan/_scd.xml.tpl', path + outputFilename_scd) 420 shutil.copyfile(wavedevPath + 'XML_gen/DevMan/_prf.xml.tpl', path + outputFilename_prf) 421 422 432 423 433 424 ################################################################################ 434 # Generate the DeviceManager DCD.xml file 435 def genDCD(devlist, path,nodeName,dmName='DeviceManager',folder=False,generate=True,devconf=""):436 425 # Generate the DeviceManager DCD.xml file 426 def genDCD(devlist, path, wavedevPath, nodeName, dmName = 'DeviceManager', folder = False, generate = True, devconf = ""): 427 437 428 outputFilename_dcd = dmName + '.dcd.xml' 438 439 doc_dcd = xml.dom.minidom.parse( 'XML_gen/_dcd.xml.tpl')429 430 doc_dcd = xml.dom.minidom.parse(wavedevPath + 'XML_gen/_dcd.xml.tpl') 440 431 441 432 deviceconfigurationNode = doc_dcd.getElementsByTagName("deviceconfiguration")[0] … … 450 441 devicemanagersoftpkgNode = deviceconfigurationNode.getElementsByTagName("devicemanagersoftpkg")[0] 451 442 devicemanagersoftpkgNode.getElementsByTagName("localfile")[0].setAttribute("name", unicode(dmName) + u'.spd.xml') 452 443 453 444 baseDeviceList = [] 454 445 componentfilesNode = deviceconfigurationNode.getElementsByTagName("componentfiles")[0] … … 459 450 else: 460 451 tmpid = unicode(n.file_uuid) 461 452 462 453 if n.baseName not in baseDeviceList: 463 454 # Generate the componentfile entries … … 466 457 componentfileNode.setAttribute("type", "SPD") 467 458 componentfileNode.setAttribute("id", tmpid) 468 459 469 460 localcomponentfileNode = doc_dcd.createElement("localfile") 470 461 localcomponentfileNode.setAttribute("name", unicode(xmlpath + n.baseName + '/' + n.baseName + '.spd.xml') ) … … 472 463 componentfileNode.appendChild(localcomponentfileNode) 473 464 componentfilesNode.appendChild(componentfileNode) 474 465 475 466 # Generate the partitioning entries 476 467 componentplacementNode = doc_dcd.createElement("componentplacement") … … 489 480 partitioningNode.appendChild(componentplacementNode) 490 481 482 # Define <!DOCTYPE> here (overriding template if necessary) 483 ensureDocType(doc_dcd, u'deviceconfiguration', u'../../xml/dtd/deviceconfiguration.dtd') 491 484 # Create and beautify the dcd file as a temporary file 492 485 data = doc_dcd.toxml('UTF-8') 493 486 xmlBeautify.beautify(data,path + '.' + outputFilename_dcd + '.tmp') 494 495 487 496 488 # Post Processing - add some of the header lines … … 507 499 postProcessed_dcd.writelines(remaining) 508 500 postProcessed_dcd.close() 509 501 510 502 # Remove temporary files 511 503 os.remove(path + '.' + outputFilename_dcd + '.tmp') … … 513 505 514 506 515 def writeWaveSetuppy(wavePath, waveName):507 def writeWaveSetuppy(wavePath, wavedevPath, waveName): 516 508 ''' 517 ############################################################################## 509 ############################################################################## 518 510 ## writeWaveSetuppy - generates the setup.py file for a waveform 519 511 ############################################################################## … … 524 516 525 517 #copy over the readme file 526 shutil.copy( 'XML_gen/README', wavePath)527 518 shutil.copy(wavedevPath + 'XML_gen/README', wavePath) 519 528 520 output = open(wavePath + '/setup.py','w') 529 521 ts = "\ … … 544 536 "',data_files=[(install_location+'/waveforms/" + waveName + "',['" + \ 545 537 waveName + ".sad.xml', '" + waveName + "_DAS.xml'])])" 546 output.writelines(ts) 538 output.writelines(ts) 547 539 548 540 output.close() #done creating the file -
ossiedev/trunk/tools/WaveDev/wavedev/XML_gen/component_gen.py
r5887 r8046 24 24 import xml.dom.minidom 25 25 from xml.dom.minidom import Node 26 27 26 import xmlBeautify 28 29 # 30 # UUID Generator 31 # 32 def uuidgen(): 33 return commands.getoutput('uuidgen -t') 34 35 36 try: 37 doc_cfg = xml.dom.minidom.parse('../wavedev.cfg') 38 except: #if not being called from wavedev, try looking for wavedev 39 doc_cfg = xml.dom.minidom.parse('/sdr/tools/WaveDev/wavedev.cfg') 40 41 version = str(doc_cfg.getElementsByTagName("version")[0].firstChild.data) 42 43 #vtext = open('../version.txt') 44 #version = unicode(vtext.readline()) 45 #version = version.strip('\n') 46 commentLine = u'<!--Created with OSSIE WaveDev ' + version \ 47 + u'-->\n<!--Powered by Python-->\n' 27 from WaveDev.wavedev.uuidgen import uuidgen 28 48 29 49 30 xmlpath = u'xml/' 50 31 binpath = u'bin/' 51 32 52 def gen_scd(comp, waveformDir ):33 def gen_scd(comp, waveformDir, wavedevPath): 53 34 # Generate the componentfile entries 54 doc_scd = xml.dom.minidom.parse( 'XML_gen/_scd.xml.tpl')55 35 doc_scd = xml.dom.minidom.parse(wavedevPath + 'XML_gen/_scd.xml.tpl') 36 56 37 int_types = {} 57 38 58 39 portsNode = doc_scd.getElementsByTagName("ports")[0] 59 40 60 41 # add provides ports to .scd.xml file 61 42 for p in comp.ports: … … 74 55 # append new provides port to <ports> 75 56 portsNode.appendChild(providesPortNode) 76 57 77 58 if p.interface.name not in int_types: 78 59 int_types[p.interface.name] = copy.deepcopy(p.interface) 79 60 80 61 del providesPortNode, portTypeNode 81 62 82 63 # add uses ports to .scd.xml file 83 64 for p in comp.ports: … … 93 74 portTypeNode.setAttribute("type", unicode(p.portType)) 94 75 usesPortNode.appendChild(portTypeNode) 95 76 96 77 # append new uses port to <ports> 97 78 portsNode.appendChild(usesPortNode) 98 79 99 80 if p.interface.name not in int_types: 100 81 int_types[p.interface.name] = copy.deepcopy(p.interface) 101 82 102 83 del usesPortNode, portTypeNode 103 84 104 85 # Add interfaces 105 86 interfacesRootNode = doc_scd.getElementsByTagName("softwarecomponent")[0].getElementsByTagName("interfaces")[0] … … 115 96 compDir = waveformDir + comp.name + '/' 116 97 outputFileName_scd = comp.name + '.scd.xml' 117 98 99 # Define <!DOCTYPE> here (overriding template if necessary) 100 ensureDocType(doc_scd, u'softwarecomponent', u'../dtd/softwarecomponent.dtd') 118 101 data = doc_scd.toxml('UTF-8') 119 102 xmlBeautify.beautify(data,compDir + '.' + outputFileName_scd + '.tmp') … … 121 104 preProcessed_scd = open(compDir + '.' + outputFileName_scd + '.tmp', 'r') 122 105 postProcessed_scd = open(compDir + outputFileName_scd, 'w') 123 106 124 107 # Specify external DTD 125 108 line0 = preProcessed_scd.readline() … … 130 113 postProcessed_scd.writelines(remaining) 131 114 postProcessed_scd.close() 132 115 133 116 # Remove temporary files 134 117 os.remove(compDir + '.' + outputFileName_scd + '.tmp') 135 136 137 def gen_spd(comp, waveformDir ):138 componentName = unicode(comp.name) 118 119 120 def gen_spd(comp, waveformDir, wavedevPath): 121 componentName = unicode(comp.name) 139 122 componentDescr = unicode(comp.description) 140 141 doc_spd = xml.dom.minidom.parse( 'XML_gen/_spd.xml.tpl')142 123 124 doc_spd = xml.dom.minidom.parse(wavedevPath + 'XML_gen/_spd.xml.tpl') 125 143 126 #doc_spd.softpkg.name = u'ossie' + componentName + u'Resource' 144 127 softpkgNode = doc_spd.getElementsByTagName("softpkg")[0] 145 128 softpkgNode.setAttribute("name",componentName) 146 129 softpkgNode.setAttribute("id", u'DCE:' + unicode(uuidgen()) ) 147 130 148 131 # set the general resource description 149 132 # note: this is NOT the description of the implementation … … 157 140 propertyfilePathNode = softpkgNode.getElementsByTagName("propertyfile")[0].getElementsByTagName("localfile")[0] 158 141 propertyfilePathNode.setAttribute("name", xmlpath + componentName + '/' + componentName + u'.prf.xml') 159 142 160 143 # set the descriptor file path 161 144 descriptorPathNode = softpkgNode.getElementsByTagName("descriptor")[0].getElementsByTagName("localfile")[0] 162 145 descriptorPathNode.setAttribute("name", xmlpath + componentName + '/' + componentName + u'.scd.xml') 163 146 164 147 # set the implementation id 165 148 implementationNode = softpkgNode.getElementsByTagName("implementation")[0] … … 167 150 implementationNode.getElementsByTagName("code")[0].getElementsByTagName("localfile")[0].setAttribute( \ 168 151 "name", binpath + componentName) 169 152 170 153 # Now do final processing and write to file 171 154 compDir = waveformDir + comp.name + '/' 172 155 outputFileName_spd = comp.name + '.spd.xml' 173 156 #outputFileName_spd = comp.name + 'Resource' + '.spd.xml' 174 157 158 # Define <!DOCTYPE> here (overriding template if necessary) 159 ensureDocType(doc_spd, u'softpkg', u'../dtd/softpkg.dtd') 175 160 data = doc_spd.toxml('UTF-8') 176 161 xmlBeautify.beautify(data,compDir + '.' + outputFileName_spd + '.tmp') … … 178 163 preProcessed_spd = open(compDir + '.' + outputFileName_spd + '.tmp', 'r') 179 164 postProcessed_spd = open(compDir + outputFileName_spd, 'w') 180 165 181 166 # Specify external DTD 182 167 line0 = preProcessed_spd.readline() … … 187 172 postProcessed_spd.writelines(remaining) 188 173 postProcessed_spd.close() 189 174 190 175 # Remove temporary files 191 176 os.remove(compDir + '.' + outputFileName_spd + '.tmp') 192 193 def gen_prf(comp, waveformDir ):194 componentName = unicode(comp.name) 195 doc_prf = xml.dom.minidom.parse( 'XML_gen/_prf.xml.tpl')196 177 178 def gen_prf(comp, waveformDir, wavedevPath): 179 componentName = unicode(comp.name) 180 doc_prf = xml.dom.minidom.parse(wavedevPath + 'XML_gen/_prf.xml.tpl') 181 197 182 propertiesNode = doc_prf.getElementsByTagName("properties")[0] 198 183 … … 231 216 descriptionNode.appendChild(descriptionText) 232 217 e.appendChild(descriptionNode) 233 218 234 219 # Add the property kind 235 220 kindNode = doc_prf.createElement("kind") … … 238 223 239 224 propertiesNode.appendChild(e) 240 225 241 226 # Create a simplesequence of string type that lists each Provides port in the component 242 227 # Used for connecting to components from outside the framework (ex. control gui) … … 277 262 278 263 propertiesNode.appendChild(e) 279 264 280 265 # Now do final processing and write to file 281 266 compDir = waveformDir + comp.name + '/' 282 267 outputFileName_prf = comp.name + '.prf.xml' 283 268 #outputFileName_prf = comp.name + 'Resource' + '.prf.xml' 284 269 270 # Define <!DOCTYPE> here (overriding template if necessary) 271 ensureDocType(doc_prf, u'properties', u'../dtd/properties.dtd') 285 272 data = doc_prf.toxml('UTF-8') 286 273 xmlBeautify.beautify(data,compDir + '.' + outputFileName_prf + '.tmp') … … 288 275 preProcessed_prf = open(compDir + '.' + outputFileName_prf + '.tmp', 'r') 289 276 postProcessed_prf = open(compDir + outputFileName_prf, 'w') 290 277 291 278 # Specify external DTD 292 279 line0 = preProcessed_prf.readline() … … 297 284 postProcessed_prf.writelines(remaining) 298 285 postProcessed_prf.close() 299 286 300 287 # Remove temporary files 301 288 os.remove(compDir + '.' + outputFileName_prf + '.tmp') 289 290 def ensureDocType(xmldoc, name, systemId): 291 # Define <!DOCTYPE> here (overriding template if necessary) 292 if xmldoc.doctype == None: 293 xmldoc.doctype = xml.dom.minidom.DocumentType(name) 294 xmldoc.insertBefore(xmldoc.doctype, xmldoc.firstChild) 295 xmldoc.doctype.name = name 296 xmldoc.doctype.systemId = systemId -
ossiedev/trunk/tools/WaveDev/wavedev/generate/genNode.py
r5915 r8046 23 23 24 24 class genAll: 25 def __init__(self, path,node):25 def __init__(self, path, wavedevPath, node): 26 26 if path[len(path)-1] != '/': 27 27 path = path + '/' 28 self.path = path 29 if wavedevPath[len(wavedevPath)-1] != '/': 30 wavedevPath = wavedevPath + '/' 28 31 self.path = path 29 32 self.node = node … … 37 40 errorMsg(self,"Node already exists - exiting") 38 41 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: 41 44 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 45 48 ############################################################################## 46 49 ## writeMakefiles - generates the make file for the waveform and then calls … … 52 55 Flags = ["-Wall"] 53 56 self.info2str(output,"AM_CXXFLAGS = ",Flags,1) 54 57 55 58 tstr = "ossieName = " + self.node.name + '\n\n' 56 59 output.write(tstr) 57 60 58 61 tstr = "waveformdir = $(prefix)/nodes/$(ossieName)\n" 59 62 output.write(tstr) … … 81 84 if mycount%2 == 0 and wrap and mylist.index(x) != len(mylist)-1: 82 85 tstr = tstr + "\\\n" 83 86 84 87 tstr = tstr + "\n" 85 88 for x in range(extraLine): … … 93 96 def genConfigureACFiles(self,installPath="/sdr/sca"): 94 97 if installPath[-1] == '/': 95 installPath = installPath[0:-1] 96 98 installPath = installPath[0:-1] 99 97 100 tmpPath = self.path + self.node.name + '/' 98 101 self.writeConfAC(tmpPath,self.node.name,False,False,installPath) 99 102 100 103 ############################################################################## 101 104 ## writeConfAC - generates configure.ac files for autoconf … … 104 107 if genPath[len(genPath)-1] != '/': 105 108 genPath = genPath + '/' 106 109 107 110 output = open(genPath + 'configure.ac','w') 108 111 tstr = "AC_INIT(" + name + ", 0.5.0)\n\n" … … 116 119 output.write(tstr) 117 120 output.close() 118 119 ############################################################################## 121 122 ############################################################################## 120 123 ## This function generates the cpp and h files for each component: 121 124 ## component.h, component.cpp, main.cpp, port_impl.h, and port_impl.cpp 122 ############################################################################## 125 ############################################################################## 123 126 def genCompFiles(self,comp): 124 127 #for x in self.active_wave.components: 125 128 # generate the .h files for each component 126 inputH = open( 'generate/sampleComp.h','r')129 inputH = open(self.wavedevPath + 'generate/sampleComp.h','r') 127 130 outputH = open(self.path + comp.name + "/" + comp.name + ".h",'w') 128 131 self.addGPL(outputH,comp.name) … … 147 150 l_out = l_out.replace("__ACE_SVC_DECL__",'int svc(void);\n size_t queue_size;') 148 151 else: 149 continue 152 continue 150 153 if l_out.find("__FRIEND_DECL__") != -1: 151 154 l_out = l_out.replace("__FRIEND_DECL__","") 152 155 self.writeFriendDecl(outputH,comp) 153 156 continue 154 157 155 158 outputH.write(l_out) 156 159 157 160 inputH.close() 158 161 outputH.close() 159 162 160 163 # generate the .cpp files for each component 161 inputCPP = open( 'generate/sampleComp.cpp','r')164 inputCPP = open(self.wavedevPath + 'generate/sampleComp.cpp','r') 162 165 outputCPP = open(self.path + comp.name + "/" + comp.name + ".cpp",'w') 163 166 self.addGPL(outputCPP,comp.name) … … 181 184 if comp.ace == True: 182 185 self.writeACESvcDef(outputCPP,comp,'component',comp.timing, comp) 183 continue 186 continue 184 187 outputCPP.write(l_out) 185 188 186 189 inputCPP.close() 187 190 outputCPP.close() 188 191 189 192 # generate the main.cpp files for each component 190 inputMain = open( 'generate/sampleMain.cpp','r')193 inputMain = open(self.wavedevPath + 'generate/sampleMain.cpp','r') 191 194 outputMain = open(self.path + comp.name + "/main.cpp",'w') 192 195 self.addGPL(outputMain,comp.name) 193 196 194 197 for line in inputMain.readlines(): 195 198 l_out = line.replace("__IncludeFile__",comp.name) … … 200 203 l_out = l_out.replace("__CLASS_VAR_ACE__",comp.name.lower()) 201 204 else: 202 continue 205 continue 203 206 if l_out.find("__NAME_SPACE__") != -1: 204 207 ns_list = [] … … 211 214 212 215 outputMain.write(l_out) 213 216 214 217 inputMain.close() 215 218 outputMain.close() 216 219 217 220 # generate the port_impl.h file 218 inputPortImpl = open( 'generate/port_impl.h','r')221 inputPortImpl = open(self.wavedevPath + 'generate/port_impl.h','r') 219 222 outputPortImpl = open(self.path + comp.name + "/port_impl.h",'w') 220 223 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') 223 226 for line in inputPortImpl.readlines(): 224 227 l_out = line.replace("__IncludeFile__",comp.name) … … 235 238 if l_out.find("__PORT_DECL__") != -1: 236 239 self.writePortImplDecl(outputPortImpl,portSample_p,portSample_u,comp) 237 continue 240 continue 238 241 outputPortImpl.write(l_out) 239 242 240 243 inputPortImpl.close() 241 244 outputPortImpl.close() 242 245 portSample_p.close() 243 246 portSample_u.close() 244 247 245 248 # generate the port_impl.cpp file 246 inputPortImpl = open( 'generate/port_impl.cpp','r')249 inputPortImpl = open(self.wavedevPath + 'generate/port_impl.cpp','r') 247 250 outputPortImpl = open(self.path + comp.name + "/port_impl.cpp",'w') 248 251 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') 251 254 for line in inputPortImpl.readlines(): 252 255 l_out = line … … 255 258 continue 256 259 outputPortImpl.write(l_out) 257 260 258 261 inputPortImpl.close() 259 262 outputPortImpl.close() 260 263 portSample_p.close() 261 264 portSample_u.close() 262 265 263 266 # Copy some required files into the main directory 264 267 # os.system('cp generate/basic_xml/* ' + self.path) … … 275 278 output.write(ts) 276 279 ts = '\n';output.write(ts); 277 intList = [] 280 intList = [] 278 281 for x in c.ports: 279 282 if x.interface.name in intList: … … 339 342 else: 340 343 l_out = l_out.replace("__COMP_REF_DECL__","") 341 344 342 345 output.write(l_out) 343 346 344 347 def writePortImplDef(self,output,portSample_p,portSample_u,c): 345 348 """ This function writes port implementation definitions for the port_impl.cpp file""" 346 intList = [] 349 intList = [] 347 350 for x in c.ports: 348 351 if x.interface.name in intList: … … 419 422 outCount += 1 420 423 ts = " "*8 + "bool component_alive;\n\n" + " "*8 + "string naming_service_name;\n"; output.write(ts) 421 424 422 425 def writePortInst(self,output,c): 423 426 """ This function writes the port instantiations to the component cpp file""" … … 442 445 ts = "\n"; output.write(ts) 443 446 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 445 448 def writeGetPort(self,output,c): 446 449 """ This function writes the getPort functionality to the component cpp file""" … … 475 478 ts = "\n"; output.write(ts) 476 479 ts = " "*4 + 'return NULL;\n'; output.write(ts) 477 480 478 481 def writeDelPort(self,output,c): 479 482 """ This function writes the destructor functionality (for ports) to the component cpp file""" … … 492 495 outCount += 1 493 496 ts = "\n"; output.write(ts) 494 497 495 498 ## def writeACESvcPorts(self,output,c): 496 499 ## """ This function writes the svc port functionality to the component cpp file""" … … 501 504 ## output.write(ts) 502 505 ## outCount += 1 503 ## ts = "\n"; output.write(ts) 504 506 ## ts = "\n"; output.write(ts) 507 505 508 def writeACESvcDef(self, output,c,type,timing_flag, comp=''): 506 509 """ This function writes the implementation of the svn() function for a given component""" … … 693 696 ts = " "*8 + "//ACE_OS::sleep (ACE_Time_Value (1));\n"; output.write(ts) 694 697 ts = " "*4 + '}\n\n' + " "*4 + 'return 0;\n}\n'; output.write(ts) 695 698 696 699 if type == 'port': 697 700 #ts = 'int ' + c.u_cname + '::svc(void)\n{\n'; output.write(ts) … … 837 840 else: 838 841 ts = " "*4 + 'return 0;\n' + '}\n'; output.write(ts) 839 842 840 843 def writeTimingMessageDef(self, output,c,type): 841 844 if type == 'port': … … 859 862 860 863 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 862 865 the port_impl.h and port_impl.cpp files respectively """ 863 866 ocount = 0 864 867 for o in i.operations: 865 868 866 869 867 870 ocount += 1 … … 876 879 ts = prefix + " "*4 + o.returnType + ' ' + o.name + '(' 877 880 tscxx = prefix + " "*4 + o.cxxReturnType + ' ' + o.name + '(' 878 881 879 882 first = True 880 883 for p in o.params: … … 882 885 _USE_CONST_ = 'const ' 883 886 _USE__OUT_ = '' 884 if p.direction == 'out': 887 if p.direction == 'out': 885 888 if len(p.dataType) > 8 and p.dataType[-8:] != 'Sequence': 886 889 _USE_CONST_ = '' … … 913 916 # output.write(ts) 914 917 output.write(tscxx) 915 918 916 919 if cppFlag: 917 920 #ts = "{\n" + " "*4 + "unsigned int len = " + "hello" + ".length();\n"; output.write(ts) … … 998 1001 else: 999 1002 ts = "{\n\n}\n"; output.write(ts) 1000 1003 1001 1004 def writeFriendDecl(self,output,c): 1002 1005 friendList = [] … … 1008 1011 if p.p_cname not in friendList: 1009 1012 friendList.append(p.p_cname) 1010 1013 1011 1014 for x in friendList: 1012 1015 ts = " "*4 + "friend class " + x + ";\n" 1013 output.write(ts) 1014 1016 output.write(ts) 1017 1015 1018 1016 1019 def addGPL(self,outFile,name): 1017 inFile = open( 'generate/gpl_preamble','r')1020 inFile = open(self.wavedevPath + 'generate/gpl_preamble','r') 1018 1021 for line in inFile.readlines(): 1019 1022 l_out = line.replace("__COMP_NAME__",name) 1020 1023 outFile.write(l_out) 1021 1024 1022 1025 inFile.close() 1023 1024 1026 1027 1025 1028 def cleanUp(self): 1026 1029 # Move the AssemblyController to the waveform Dir -
ossiedev/trunk/tools/WaveDev/wavedev/generate/templates/basic_ports/genStructure.py
r5963 r8046 28 28 29 29 class genAll: 30 def __init__(self, path,active_wave):30 def __init__(self, path, wavedevPath, active_wave): 31 31 if path[len(path)-1] != '/': 32 32 path = path + '/' 33 33 self.path = path 34 if len(wavedevPath) > 0 and wavedevPath[len(wavedevPath)-1] != '/': 35 wavedevPath = wavedevPath + '/' 36 self.wavedevPath = wavedevPath 34 37 self.active_wave = active_wave 35 38 … … 42 45 errorMsg(self,"Waveform already exists - exiting") 43 46 exit(1) 44 45 if os.path.exists(self.path+self.active_wave.name) == False: 47 48 if os.path.exists(self.path+self.active_wave.name) == False: 46 49 os.mkdir(self.path + self.active_wave.name) 47 48 shutil.copy( 'generate/reconf',self.path + self.active_wave.name)49 for x in os.listdir( 'generate/basic_xml/'):50 51 shutil.copy(self.wavedevPath + 'generate/reconf',self.path + self.active_wave.name) 52 for x in os.listdir(self.wavedevPath + 'generate/basic_xml/'): 50 53 if not os.path.isdir(x): 51 shutil.copy( 'generate/basic_xml/' + x,self.path + self.active_wave.name)52 54 shutil.copy(self.wavedevPath + 'generate/basic_xml/' + x,self.path + self.active_wave.name) 55 53 56 for x in self.active_wave.components: 54 57 if x.generate: … … 56 59 os.mkdir(self.path+x.name) 57 60 if x.AssemblyController != True: 58 shutil.copy( 'generate/reconf',self.path + x.name)59 for f in os.listdir( 'generate/basic_xml/'):61 shutil.copy(self.wavedevPath + 'generate/reconf',self.path + x.name) 62 for f in os.listdir(self.wavedevPath + 'generate/basic_xml/'): 60 63 if not os.path.isdir(f): 61 shutil.copy( 'generate/basic_xml/' + f,self.path + x.name)62 shutil.copy( 'generate/LICENSE',self.path + x.name)63 64 shutil.copy(self.wavedevPath + 'generate/basic_xml/' + f,self.path + x.name) 65 shutil.copy(self.wavedevPath + 'generate/LICENSE',self.path + x.name) 66 64 67 ############################################################################## 65 68 ## writeMakefiles - generates the make file for the waveform and then calls … … 71 74 Flags = ["-Wall"] 72 75 self.info2str(output,"AM_CXXFLAGS = ",Flags,1) 73 76 74 77 tstr = "ossieName = " + self.active_wave.name + '\n\n' 75 78 output.write(tstr) 76 79 77 80 tstr = "SUBDIRS = " 78 81 for c in self.active_wave.components: 79 82 if c.AssemblyController == True and c.generate: 80 83 tstr += c.name + '\n\n' 81 output.write(tstr) 82 84 output.write(tstr) 85 83 86 # tstr = "waveformdir = $(prefix)/dom/waveforms/$(ossieName)\n" 84 87 tstr = "waveformdir = $(prefix)/waveforms/" + self.active_wave.name + "\n" … … 102 105 103 106 output.close() 104 107 105 108 for c in self.active_wave.components: 106 109 if c.generate: 107 110 tmpPath = self.path + c.name 108 111 self.writeCompMakefile(c,tmpPath) 109 110 ############################################################################## 112 113 ############################################################################## 111 114 ## writeCompMakefilee - generates the make file for an indivdual component 112 115 ############################################################################## … … 114 117 if compPath[len(compPath)-1] != '/': 115 118 compPath = compPath + '/' 116 119 117 120 Flags = ["-Wall"] 118 121 119 122 output = open(compPath + 'Makefile.am','w') 120 123 self.info2str(output,"AM_CXXFLAGS = ",Flags,1) 121 124 122 125 tstr = "bin_PROGRAMS = " + comp.name + "\n\n" 123 126 output.write(tstr) 124 125 tstr = comp.name + "_SOURCES = " + comp.name + ".cpp " + comp.name + ".h main.cpp\n\n" 127 128 tstr = comp.name + "_SOURCES = " + comp.name + ".cpp " + comp.name + ".h main.cpp\n\n" 126 129 output.write(tstr) 127 130 tstr = "ossieName = " + comp.name + "\n" 128 131 output.write(tstr) 129 132 130 133 tstr = "xmldir = $(prefix)/xml/$(ossieName)\n" 131 134 output.write(tstr) 132 135 133 136 tstr = "bindir = $(prefix)/bin\n" 134 137 output.write(tstr) … … 141 144 xmlData.append(tstr2 + ".spd.xml") 142 145 self.info2str(output,"dist_xml_DATA = ",xmlData,1,wrapFlag=True) 143 146 144 147 output.close() 145 148 … … 156 159 if mycount%2 == 0 and wrap and mylist.index(x) != len(mylist)-1: 157 160 tstr = tstr + "\\\n" 158 161 159 162 tstr = tstr + "\n" 160 163 for x in range(extraLine): … … 168 171 def genConfigureACFiles(self,installPath): 169 172 if installPath[-1] == '/': 170 installPath = installPath[0:-1] 171 173 installPath = installPath[0:-1] 174 172 175 tmpPath = self.path + self.active_wave.name + '/' 173 176 self.writeConfAC(tmpPath,self.active_wave.name,self.active_wave.ace,True,installPath) 174 177 175 178 for c in self.active_wave.components: 176 179 if c.AssemblyController == True or not c.generate: … … 178 181 tmpPath = self.path + c.name + '/' 179 182 self.writeConfAC(tmpPath,c.name,c.ace,False,installPath) 180 183 181 184 ############################################################################## 182 185 ## writeConfAC - generates configure.ac files for autoconf … … 185 188 if genPath[len(genPath)-1] != '/': 186 189 genPath = genPath + '/' 187 190 188 191 output = open(genPath + 'configure.ac','w') 189 192 tstr = "AC_INIT(" + name + ", 0.6.0)\nAM_INIT_AUTOMAKE\n\n" … … 199 202 #tstr = "AC_CORBA_ORB\n\n" 200 203 #output.write(tstr) 201 204 202 205 tstr = 'AC_LANG_PUSH([C++])\n\n' 203 206 output.write(tstr) … … 235 238 tstr = 'IDL_FLAGS="$OSSIE_CFLAGS"\nAC_SUBST(IDL_FLAGS)\n\n' 236 239 output.write(tstr) 237 240 238 241 if aceFlag == True: 239 242 tstr = 'PKG_CHECK_MODULES(ACE, ACE >= 5.4.7)\n' 240 243 tstr = tstr + 'AC_SUBST(ACE_CFLAGS)\nAC_SUBST(ACE_LIBS)\nLIBS="$LIBS $ACE_LIBS"\n\n' 241 244 output.write(tstr) 242 245 243 246 tstr = 'LIBS="$LIBS $OSSIE_LIBS"\n\n' 244 247 output.write(tstr) 245 248 246 249 tstr = 'AC_SUBST(SI_PATH)\n\n' 247 250 output.write(tstr) 248 249 tstr = "AC_CONFIG_FILES(Makefile" 251 252 tstr = "AC_CONFIG_FILES(Makefile" 250 253 if wavFlag == True: 251 254 for x in self.active_wave.components: … … 253 256 tstr2 = " " + x.name + "/Makefile" 254 257 tstr = tstr + tstr2 255 256 tstr = tstr + ")\n\n" 258 259 tstr = tstr + ")\n\n" 257 260 output.write(tstr) 258 261 … … 261 264 262 265 output.close() 263 264 ############################################################################## 266 267 ############################################################################## 265 268 ## This function generates the cpp and h files for each component: 266 269 ## component.h, component.cpp, main.cpp, port_impl.h, and port_impl.cpp 267 ############################################################################## 268 def genCompFiles(self,comp): 270 ############################################################################## 271 def genCompFiles(self,comp): 269 272 #for x in self.active_wave.components: 270 273 # generate the .h files for each component 271 inputH = open( 'generate/templates/basic_ports/sampleComp.h','r')274 inputH = open(self.wavedevPath + 'generate/templates/basic_ports/sampleComp.h','r') 272 275 outputH = open(self.path + comp.name + "/" + comp.name + ".h",'w') 273 276 self.addGPL(outputH,comp.name) … … 307 310 l_out = l_out.replace("__ACE_SVC_DECL__",'int svc(void);') 308 311 else: 309 continue 312 continue 310 313 if l_out.find("__FRIEND_DECL__") != -1: 311 314 l_out = l_out.replace("__FRIEND_DECL__","") 312 315 self.writeFriendDecl(outputH,comp) 313 316 continue 314 317 315 318 outputH.write(l_out) 316 319 317 320 inputH.close() 318 321 outputH.close() 319 322 320 323 # generate the .cpp files for each component 321 inputCPP = open( 'generate/templates/basic_ports/sampleComp.cpp','r')324 inputCPP = open(self.wavedevPath + 'generate/templates/basic_ports/sampleComp.cpp','r') 322 325 outputCPP = open(self.path + comp.name + "/" + comp.name + ".cpp",'w') 323 326 self.addGPL(outputCPP,comp.name) … … 357 360 if comp.ace == True: 358 361 self.writeACESvcDef(outputCPP,comp,'component') 359 continue 362 continue 360 363 outputCPP.write(l_out) 361 364 362 365 inputCPP.close() 363 366 outputCPP.close() 364 367 365 368 # generate the main.cpp files for each component 366 inputMain = open( 'generate/templates/basic_ports/sampleMain.cpp','r')369 inputMain = open(self.wavedevPath + 'generate/templates/basic_ports/sampleMain.cpp','r') 367 370 outputMain = open(self.path + comp.name + "/main.cpp",'w') 368 371 self.addGPL(outputMain,comp.name) 369 372 370 373 for line in inputMain.readlines(): 371 374 l_out = line.replace("__IncludeFile__",comp.name) … … 377 380 l_out = l_out.replace("__CLASS_VAR_ACE__",comp.name.lower()) 378 381 else: 379 continue 382 continue 380 383 outputMain.write(l_out) 381 384 382 385 inputMain.close() 383 386 outputMain.close() 384 387 385 388 # generate the Doxygen documentation.txt file 386 inputDoc = open( 'generate/templates/basic_ports/sampleDocumentation.txt','r')389 inputDoc = open(self.wavedevPath + 'generate/templates/basic_ports/sampleDocumentation.txt','r') 387 390 outputDoc = open(self.path + comp.name + '/documentation.txt','w') 388 391 self.addGPL(outputDoc, comp.name) … … 395 398 396 399 # generate the Doxygen configure file 397 inputDoxy = open( 'generate/templates/basic_ports/sampleDoxyfile','r')400 inputDoxy = open(self.wavedevPath + 'generate/templates/basic_ports/sampleDoxyfile','r') 398 401 outputDoxy = open(self.path + comp.name + '/Doxyfile','w') 399 402 … … 407 410 ############################################################################################# 408 411 409 410 ##code for generating port_impl.h and .cpp files has been temporarily 411 ##commented out. this code should be rewritten to put port_impl 412 413 ##code for generating port_impl.h and .cpp files has been temporarily 414 ##commented out. this code should be rewritten to put port_impl 412 415 ##functionality into the appropriate .cpp function 413 416 ## # generate the port_impl.h file 414 ## inputPortImpl = open( 'generate/port_impl.h','r')417 ## inputPortImpl = open(self.wavedevPath + 'generate/port_impl.h','r') 415 418 ## outputPortImpl = open(self.path + comp.name + "/port_impl.h",'w') 416 419 ## self.addGPL(outputPortImpl,comp.name) 417 ## portSample = open( 'generate/port_sample.h','r')420 ## portSample = open(self.wavedevPath + 'generate/port_sample.h','r') 418 421 ## for line in inputPortImpl.readlines(): 419 422 ## l_out = line.replace("__IncludeFile__",comp.name) … … 425 428 ## if l_out.find("__PORT_DECL__") != -1: 426 429 ## self.writePortImplDecl(outputPortImpl,portSample,comp) 427 ## continue 430 ## continue 428 431 ## outputPortImpl.write(l_out) 429 ## 432 ## 430 433 ## inputPortImpl.close() 431 434 ## outputPortImpl.close() 432 435 ## portSample.close() 433 ## 436 ## 434 437 ## # generate the port_impl.cpp file 435 ## inputPortImpl = open( 'generate/port_impl.cpp','r')438 ## inputPortImpl = open(self.wavedevPath + 'generate/port_impl.cpp','r') 436 439 ## outputPortImpl = open(self.path + comp.name + "/port_impl.cpp",'w') 437 440 ## self.addGPL(outputPortImpl,comp.name) 438 ## portSample = open( 'generate/port_sample.cpp','r')441 ## portSample = open(self.wavedevPath + 'generate/port_sample.cpp','r') 439 442 ## for line in inputPortImpl.readlines(): 440 443 ## l_out = line … … 443 446 ## continue 444 447 ## outputPortImpl.write(l_out) 445 ## 448 ## 446 449 ## inputPortImpl.close() 447 450 ## outputPortImpl.close() 448 451 ## portSample.close() 449 452 450 453 # Copy some required files into the main directory 451 # os.system('cp generate/basic_xml/* ' + self.path)452 # os.system('cp generate/wavLoader.py ' + self.path)454 # os.system('cp ' + self.wavedevPath + 'generate/basic_xml/* ' + self.path) 455 # os.system('cp ' + self.wavedevPath + 'generate/wavLoader.py ' + self.path) 453 456 #################################################################################################### 454 457 #--------------------------------------------------------------------------------------------------- 455 458 456 459 457 460 458 461 #---------------------------------------------------------------------------------- 459 462 ################################################################################### … … 629 632 output.write(ts) 630 633 compLong += 1 631 634 632 635 633 636 elif x.interface.name == "realShort" and realShort == 0: … … 665 668 ################################################################################## 666 669 667 670 668 671 # def writePortImplDecl(self, output,portSample,c): 669 672 # """ This function writes port implementation declarations for the port_impl.h file""" … … 676 679 # output.write(ts) 677 680 # ts = '\n';output.write(ts); 678 # intList = [] 681 # intList = [] 679 682 # for x in c.ports: 680 683 # if x.interface.name in intList: … … 712 715 # else: 713 716 # l_out = l_out.replace("__COMP_REF_DECL__","") 714 # 717 # 715 718 # output.write(l_out) 716 719 … … 730 733 for x in c.properties: 731 734 tmp_type = str(x.type) 732 735 733 736 if x.elementType == "Simple": 734 ts = " "*8 + "CORBA::" + tmp_type.capitalize() + " simple_" + str(simpleCount) + "_value;\n"; 737 ts = " "*8 + "CORBA::" + tmp_type.capitalize() + " simple_" + str(simpleCount) + "_value;\n"; 735 738 output.write(ts) 736 739 simpleCount += 1; … … 749 752 for x in c.properties: 750 753 tmp_type = str(x.type) 751 754 752 755 if x.elementType == "SimpleSequence": 753 ts = " "*8 + "CORBA::" + tmp_type.capitalize() + "Seq *simplesequence_" + str(simplesequenceCount) + ";\n" 756 ts = " "*8 + "CORBA::" + tmp_type.capitalize() + "Seq *simplesequence_" + str(simplesequenceCount) + ";\n" 754 757 output.write(ts) 755 758 simplesequenceCount = simplesequenceCount + 1 … … 759 762 ################################################################################ 760 763 #------------------------------------------------------------------------------- 761 762 764 765 763 766 #-------------------------------------------------------------------------------------------------------------- 764 767 ############################################################################################################### … … 766 769 # def writePortImplDef(self,output,portSample,c): 767 770 # """ This function writes port implementation definitions for the port_impl.cpp file""" 768 # intList = [] 771 # intList = [] 769 772 # for x in c.ports: 770 773 # if x.interface.name in intList: … … 799 802 ############################################################################################################### 800 803 #------------------------------------------------------------------------------------------------------------- 801 804 802 805 803 806 #-------------------------------------------------------------------------------------------------------------- … … 825 828 #-------------------------------------------------------------------------------------------------------------- 826 829 ############################################################################################################### 827 830 828 831 # def writePortInst(self,output,c): 829 832 # """ This function writes the port instantiations to the component cpp file""" … … 850 853 #--------------------------------------------------------------------------------- 851 854 ################################################################################## 852 855 853 856 def writeGetPort(self,output,c): 854 857 """ This function writes the getPort functionality to the component cpp file""" … … 865 868 continue 866 869 867 ts = "\n"; output.write(ts) 870 ts = "\n"; output.write(ts) 868 871 ts = " "*4 + "if (!CORBA::is_nil(p))\n"; output.write(ts) 869 872 ts = " "*8 + "return p._retn();\n\n"; output.write(ts) 870 873 871 874 ts = " "*4 + '/*exception*/\n'; output.write(ts) 872 875 ts = " "*4 + 'throw CF::PortSupplier::UnknownPort();\n'; output.write(ts) … … 905 908 for x in c.ports: 906 909 if x.type == "Uses": 907 ts = " "*4 + 'delete dataOut_' + str(outCount) + ';\n'; 910 ts = " "*4 + 'delete dataOut_' + str(outCount) + ';\n'; 908 911 output.write(ts) 909 912 outCount += 1; 910 913 911 914 elif x.type == "Provides": 912 ts = " "*4 + 'delete dataIn_' + str(inCount) + ';\n'; 913 output.write(ts) 915 ts = " "*4 + 'delete dataIn_' + str(inCount) + ';\n'; 916 output.write(ts) 914 917 inCount += 1; 915 918 else: … … 925 928 for x in c.properties: 926 929 tmp_type = str(x.type) 927 930 928 931 if x.elementType == "SimpleSequence": 929 ts = " "*4 + "delete []simplesequence_" + str(simplesequenceCount) + ";\n" 932 ts = " "*4 + "delete []simplesequence_" + str(simplesequenceCount) + ";\n" 930 933 output.write(ts) 931 934 simplesequenceCount += 1; … … 938 941 #---------------------------------------------------------------------------------- 939 942 ################################################################################### 940 943 941 944 def writeReadProps(self,output,c): 942 945 """write the code that will read properties from the prf file""" 943 946 simpleCount = 0; 944 simplesequenceCount = 0; 947 simplesequenceCount = 0; 945 948 #make sure there are properties first 946 949 947 950 ts = " "*4 + 'std::cout << "props length : " << props.length() << std::endl;\n\n' 948 951 ts = ts + " "*4 + "for (unsigned int i = 0; i <props.length(); i++)\n" … … 950 953 ts = " "*8 + 'std::cout << "Property id : " << props[i].id << std::endl;\n\n' 951 954 output.write(ts) 952 955 953 956 for p in c.properties: 954 957 955 958 ts = " "*8 + 'if (strcmp(props[i].id, "' + p.id + '") == 0)\n' + " "*8 + "{\n";output.write(ts) 956 959 957 960 if p.elementType == "Simple": 958 961 tmp_type = "unsupported_type"; … … 971 974 ts = " "*12 + "CORBA::" + str(tmp_type) + " simple_temp;\n"; 972 975 output.write(ts) 973 ts = " "*12 + 'props[i].value >>= simple_temp;\n'; 976 ts = " "*12 + 'props[i].value >>= simple_temp;\n'; 974 977 ts = ts + " "*12 + 'simple_' + str(simpleCount) + '_value = simple_temp;\n'; 975 978 ts = ts + " "*8 + "}\n\n" … … 992 995 993 996 ts = " "*12 + "props[i].value >>= simplesequence_" + str(simplesequenceCount) + ";\n"; 994 output.write(ts) 995 996 ts = " "*8 + "}\n\n" # close the if statement 997 output.write(ts) 998 999 ts = " "*8 + "}\n\n" # close the if statement 997 1000 output.write(ts) 998 1001 999 1002 simplesequenceCount += 1; 1000 else: 1003 else: 1001 1004 print "WARNING: properties other than simple and simple sequence are not supported yet" 1002 1005 continue 1003 1006 1004 1007 ts = " "*4 + "}\n"; output.write(ts) #closes the for loop 1005 1008 1006 1009 ################################################################################# 1007 1010 #-------------------------------------------------------------------------------- 1008 1009 1010 1011 1012 1013 1011 1014 #-------------------------------------------------------------------------------- 1012 1015 ################################################################################# 1013 1016 1014 1017 1015 1018 def writeProcessDataDeclaration(self,output,c): 1016 1019 """This function sets up the majority of the process data function (in the .cpp file) based on the port type""" 1017 1020 1018 1021 outPort_present = False 1019 1022 inPort_present = False … … 1022 1025 #declare the output (uses) variables 1023 1026 for x in c.ports: #assumes that you have at least one port 1024 if x.type == "Uses": 1027 if x.type == "Uses": 1025 1028 1026 1029 if x.interface.name == "complexShort": 1027 ts = " "*4 + "PortTypes::ShortSequence I_out_" + str(outCount) + ", Q_out_" + str(outCount) + ";\n"; 1028 output.write(ts) 1030 ts = " "*4 + "PortTypes::ShortSequence I_out_" + str(outCount) + ", Q_out_" + str(outCount) + ";\n"; 1031 output.write(ts) 1029 1032 outCount += 1; 1030 1033 1031 1034 elif x.interface.name == "complexFloat": 1032 ts = " "*4 + "PortTypes::FloatSequence I_out_" + str(outCount) + ", Q_out_" + str(outCount) + ";\n"; 1035 ts = " "*4 + "PortTypes::FloatSequence I_out_" + str(outCount) + ", Q_out_" + str(outCount) + ";\n"; 1033 1036 output.write(ts) 1034 1037 outCount += 1; … … 1051 1054 1052 1055 elif x.interface.name == "realShort": 1053 ts = " "*4 + "PortTypes::ShortSequence I_out_" + str(outCount) + ";\n"; 1056 ts = " "*4 + "PortTypes::ShortSequence I_out_" + str(outCount) + ";\n"; 1054 1057 output.write(ts) 1055 1058 outCount += 1; 1056 1059 elif x.interface.name == "realFloat": 1057 ts = " "*4 + "PortTypes::FloatSequence I_out_" + str(outCount) + ";\n"; 1060 ts = " "*4 + "PortTypes::FloatSequence I_out_" + str(outCount) + ";\n"; 1058 1061 output.write(ts) 1059 1062 outCount += 1; 1060 1063 elif x.interface.name == "realDouble": 1061 ts = " "*4 + "PortTypes::DoubleSequence I_out_" + str(outCount) + ";\n"; 1064 ts = " "*4 + "PortTypes::DoubleSequence I_out_" + str(outCount) + ";\n"; 1062 1065 output.write(ts) 1063 1066 outCount += 1; 1064 1067 1065 1068 elif x.interface.name == "realChar": 1066 ts = " "*4 + "PortTypes::CharSequence I_out_" + str(outCount) + ";\n"; 1069 ts = " "*4 + "PortTypes::CharSequence I_out_" + str(outCount) + ";\n"; 1067 1070 output.write(ts) 1068 1071 outCount += 1; 1069 1072 elif x.interface.name == "realLong": 1070 ts = " "*4 + "PortTypes::LongSequence I_out_" + str(outCount) + ";\n"; 1073 ts = " "*4 + "PortTypes::LongSequence I_out_" + str(outCount) + ";\n"; 1071 1074 output.write(ts) 1072 1075 outCount += 1; … … 1084 1087 for x in c.ports: 1085 1088 if x.type == "Provides": 1086 1089 1087 1090 if x.interface.name == "complexShort": 1088 ts = "\n" + " "*4 + "PortTypes::ShortSequence *I_in_"+str(inCount)+"(NULL), *Q_in_"+str(inCount)+"(NULL);\n"; 1091 ts = "\n" + " "*4 + "PortTypes::ShortSequence *I_in_"+str(inCount)+"(NULL), *Q_in_"+str(inCount)+"(NULL);\n"; 1089 1092 output.write(ts) 1090 1093 ts = " "*4 + "CORBA::UShort I_in_" + str(inCount) + "_length, Q_in_" + str(inCount) + "_length;\n"; … … 1122 1125 1123 1126 elif x.interface.name == "realShort": 1124 ts = "\n" + " "*4 + "PortTypes::ShortSequence *I_in_"+str(inCount)+"(NULL);\n"; 1127 ts = "\n" + " "*4 + "PortTypes::ShortSequence *I_in_"+str(inCount)+"(NULL);\n"; 1125 1128 output.write(ts) 1126 1129 ts = " "*4 + "CORBA::UShort I_in_" + str(inCount) + "_length;\n"; … … 1129 1132 1130 1133 elif x.interface.name == "realFloat": 1131 ts = "\n" + " "*4 + "PortTypes::FloatSequence *I_in_"+str(inCount)+"(NULL);\n"; 1134 ts = "\n" + " "*4 + "PortTypes::FloatSequence *I_in_"+str(inCount)+"(NULL);\n"; 1132 1135 output.write(ts) 1133 1136 ts = " "*4 + "CORBA::UShort I_in_" + str(inCount) + "_length;\n"; … … 1136 1139 1137 1140 elif x.interface.name == "realDouble": 1138 ts = "\n" + " "*4 + "PortTypes::DoubleSequence *I_in_"+str(inCount)+"(NULL);\n"; 1141 ts = "\n" + " "*4 + "PortTypes::DoubleSequence *I_in_"+str(inCount)+"(NULL);\n"; 1139 1142 output.write(ts) 1140 1143 ts = " "*4 + "CORBA::UShort I_in_" + str(inCount) + "_length;\n"; … … 1143 1146 1144 1147 elif x.interface.name == "realChar": 1145 ts = "\n" + " "*4 + "PortTypes::CharSequence *I_in_"+str(inCount)+"(NULL);\n"; 1148 ts = "\n" + " "*4 + "PortTypes::CharSequence *I_in_"+str(inCount)+"(NULL);\n"; 1146 1149 output.write(ts) 1147 1150 ts = " "*4 + "CORBA::UShort I_in_" + str(inCount) + "_length;\n"; … … 1150 1153 1151 1154 elif x.interface.name == "realLong": 1152 ts = "\n" + " "*4 + "PortTypes::LongSequence *I_in_"+str(inCount)+"(NULL);\n"; 1155 ts = "\n" + " "*4 + "PortTypes::LongSequence *I_in_"+str(inCount)+"(NULL);\n"; 1153 1156 output.write(ts) 1154 1157 ts = " "*4 + "CORBA::UShort I_in_" + str(inCount) + "_length;\n"; … … 1161 1164 #only one provides port is supported at this point 1162 1165 continue 1163 1166 1164 1167 ################################################################################### 1165 1168 #---------------------------------------------------------------------------------- … … 1168 1171 ################################################################################# 1169 1172 1170 1173 1171 1174 def writeProcessDataLoop(self,output,c): 1172 1175 """This function sets up the majority of the process data function (in the .cpp file) based on the port type""" 1173 1176 inCount = 0; 1174 1177 outCount = 0; 1175 ts = " "*4 + "while(1)\n" + " "*4 + "{\n"; 1178 ts = " "*4 + "while(1)\n" + " "*4 + "{\n"; 1176 1179 output.write(ts) 1177 1180 1178 1181 #define input (provides) values input to them and get length on each loop 1179 1182 for x in c.ports: 1180 1183 if x.type == "Provides": 1181 1184 if x.interface.name == "complexShort": 1182 ts = " "*8 + "dataIn_"+str(inCount)+"->getData(I_in_"+str(inCount)+", Q_in_"+str(inCount) + ");\n\n"; 1185 ts = " "*8 + "dataIn_"+str(inCount)+"->getData(I_in_"+str(inCount)+", Q_in_"+str(inCount) + ");\n\n"; 1183 1186 output.write(ts) 1184 1187 ts = " "*8 + "I_in_" + str(inCount) + "_length = I_in_" + str(inCount) + "->length();\n"; … … 1189 1192 1190 1193 elif x.interface.name == "complexFloat": 1191 ts = " "*8 + "dataIn_"+str(inCount)+"->getData(I_in_"+str(inCount)+", Q_in_"+str(inCount) + ");\n\n"; 1194 ts = " "*8 + "dataIn_"+str(inCount)+"->getData(I_in_"+str(inCount)+", Q_in_"+str(inCount) + ");\n\n"; 1192 1195 output.write(ts) 1193 1196 ts = " "*8 + "I_in_" + str(inCount) + "_length = I_in_" + str(inCount) + "->length();\n"; … … 1198 1201 1199 1202 elif x.interface.name == "complexDouble": 1200 ts = " "*8 + "dataIn_"+str(inCount)+"->getData(I_in_"+str(inCount)+", Q_in_"+str(inCount) + ");\n\n"; 1203 ts = " "*8 + "dataIn_"+str(inCount)+"->getData(I_in_"+str(inCount)+", Q_in_"+str(inCount) + ");\n\n"; 1201 1204 output.write(ts) 1202 1205 ts = " "*8 + "I_in_" + str(inCount) + "_length = I_in_" + str(inCount) + "->length();\n"; … … 1207 1210 1208 1211 elif x.interface.name == "complexChar": 1209 ts = " "*8 + "dataIn_"+str(inCount)+"->getData(I_in_"+str(inCount)+", Q_in_"+str(inCount) + ");\n\n"; 1212 ts = " "*8 + "dataIn_"+str(inCount)+"->getData(I_in_"+str(inCount)+", Q_in_"+str(inCount) + ");\n\n"; 1210 1213 output.write(ts) 1211 1214 ts = " "*8 + "I_in_" + str(inCount) + "_length = I_in_" + str(inCount) + "->length();\n"; … … 1216 1219 1217 1220 elif x.interface.name == "complexLong": 1218 ts = " "*8 + "dataIn_"+str(inCount)+"->getData(I_in_"+str(inCount)+", Q_in_"+str(inCount) + ");\n\n"; 1221 ts = " "*8 + "dataIn_"+str(inCount)+"->getData(I_in_"+str(inCount)+", Q_in_"+str(inCount) + ");\n\n"; 1219 1222 output.write(ts) 1220 1223 ts = " "*8 + "I_in_" + str(inCount) + "_length = I_in_" + str(inCount) + "->length();\n"; … … 1225 1228 1226 1229 elif x.interface.name == "realShort": 1227 ts = " "*8 + "dataIn_"+str(inCount)+"->getData(I_in_"+str(inCount)+");\n\n"; 1230 ts = " "*8 + "dataIn_"+str(inCount)+"->getData(I_in_"+str(inCount)+");\n\n"; 1228 1231 output.write(ts) 1229 1232 ts = " "*8 + "I_in_" + str(inCount) + "_length = I_in_" + str(inCount) + "->length();\n\n"; … … 1232 1235 1233 1236 elif x.interface.name == "realFloat": 1234 ts = " "*8 + "dataIn_"+str(inCount)+"->getData(I_in_"+str(inCount)+");\n\n"; 1237 ts = " "*8 + "dataIn_"+str(inCount)+"->getData(I_in_"+str(inCount)+");\n\n"; 1235 1238 output.write(ts) 1236 1239 ts = " "*8 + "I_in_" + str(inCount) + "_length = I_in_" + str(inCount) + "->length();\n\n"; … … 1239 1242 1240 1243 elif x.interface.name == "realDouble": 1241 ts = " "*8 + "dataIn_"+str(inCount)+"->getData(I_in_"+str(inCount)+");\n\n"; 1244 ts = " "*8 + "dataIn_"+str(inCount)+"->getData(I_in_"+str(inCount)+");\n\n"; 1242 1245 output.write(ts) 1243 1246 ts = " "*8 + "I_in_" + str(inCount) + "_length = I_in_" + str(inCount) + "->length();\n\n"; … … 1246 1249 1247 1250 elif x.interface.name == "realChar": 1248 ts = " "*8 + "dataIn_"+str(inCount)+"->getData(I_in_"+str(inCount)+");\n\n"; 1251 ts = " "*8 + "dataIn_"+str(inCount)+"->getData(I_in_"+str(inCount)+");\n\n"; 1249 1252 output.write(ts) 1250 1253 ts = " "*8 + "I_in_" + str(inCount) + "_length = I_in_" + str(inCount) + "->length();\n\n"; … … 1252 1255 inCount += 1; 1253 1256 elif x.interface.name == "realLong": 1254 ts = " "*8 + "dataIn_"+str(inCount)+"->getData(I_in_"+str(inCount)+");\n\n"; 1257 ts = " "*8 + "dataIn_"+str(inCount)+"->getData(I_in_"+str(inCount)+");\n\n"; 1255 1258 output.write(ts) 1256 1259 ts = " "*8 + "I_in_" + str(inCount) + "_length = I_in_" + str(inCount) + "->length();\n\n"; … … 1263 1266 continue 1264 1267 1265 for x in c.ports: 1266 if x.type == "Uses": 1268 for x in c.ports: 1269 if x.type == "Uses": 1267 1270 if x.interface.name == "complexShort" or x.interface.name == "complexFloat" or x.interface.name == "complexDouble" or x.interface.name == "complexChar" or x.interface.name == "complexLong": 1268 ts = " "*8 + "I_out_" + str(outCount) + ".length(); //must define length of output\n"; 1269 output.write(ts) 1270 ts = " "*8 + "Q_out_" + str(outCount) + ".length(); //must define length of output\n\n"; 1271 ts = " "*8 + "I_out_" + str(outCount) + ".length(); //must define length of output\n"; 1272 output.write(ts) 1273 ts = " "*8 + "Q_out_" + str(outCount) + ".length(); //must define length of output\n\n"; 1271 1274 output.write(ts) 1272 1275 outCount += 1; … … 1275 1278 1276 1279 elif x.interface.name == "realShort" or x.interface.name == "realFloat" or x.interface.name == "realDouble" or x.interface.name == "realChar" or x.interface.name == "realLong": 1277 ts = " "*8 + "I_out_" + str(outCount) + ".length(); //must define length of output\n\n"; 1280 ts = " "*8 + "I_out_" + str(outCount) + ".length(); //must define length of output\n\n"; 1278 1281 output.write(ts) 1279 1282 outCount += 1; … … 1284 1287 continue 1285 1288 1286 ts = " "*8 + "/*insert code here to do work*/\n\n\n\n\n\n\n"; 1289 ts = " "*8 + "/*insert code here to do work*/\n\n\n\n\n\n\n"; 1287 1290 output.write(ts) 1288 1291 … … 1291 1294 if x.type == "Provides": 1292 1295 if x.interface.name == "complexShort" or x.interface.name == "complexFloat" or x.interface.name == "complexDouble" or x.interface.name == "complexChar" or x.interface.name == "complexLong": 1293 ts = " "*8 + "dataIn_" + str(inCount) + "->bufferEmptied();\n"; 1296 ts = " "*8 + "dataIn_" + str(inCount) + "->bufferEmptied();\n"; 1294 1297 output.write(ts) 1295 1298 inCount += 1; 1296 1299 1297 1300 elif x.interface.name == "realShort" or x.interface.name == "realFloat" or x.interface.name == "realDouble" or x.interface.name == "realChar" or x.interface.name == "realLong": 1298 ts = " "*8 + "dataIn_" + str(inCount) + "->bufferEmptied();\n"; 1301 ts = " "*8 + "dataIn_" + str(inCount) + "->bufferEmptied();\n"; 1299 1302 output.write(ts) 1300 1303 inCount += 1; … … 1303 1306 print "\nInterfaces other than complexand real Short, Char, long, FLoat and Double are not supported yet in the process data function generation!!\nSee writeProcessDataLoop in genStructure.\n" 1304 1307 continue 1305 1308 1306 1309 outCount = 0; 1307 1310 for x in c.ports: #assumes that you have at least one port 1308 if x.type == "Uses": 1311 if x.type == "Uses": 1309 1312 if x.interface.name == "complexShort" or x.interface.name == "complexFloat" or x.interface.name == "complexDouble" or x.interface.name == "complexChar" or x.interface.name == "complexLong": 1310 ts = " "*8 + "dataOut_" + str(outCount) + "->pushPacket(I_out_" + str(outCount) + ", Q_out_" + str(outCount) + ");\n"; 1313 ts = " "*8 + "dataOut_" + str(outCount) + "->pushPacket(I_out_" + str(outCount) + ", Q_out_" + str(outCount) + ");\n"; 1311 1314 output.write(ts) 1312 1315 outCount += 1; … … 1314 1317 elif x.interface.name == "realShort" or x.interface.name == "realFloat" or x.interface.name == "realDouble" or x.interface.name == "realChar" or x.interface.name == "realLong": 1315 1318 1316 ts = " "*8 + "dataOut_" + str(outCount) + "->pushPacket(I_out_" + str(outCount) + ");\n"; 1319 ts = " "*8 + "dataOut_" + str(outCount) + "->pushPacket(I_out_" + str(outCount) + ");\n"; 1317 1320 output.write(ts) 1318 1321 outCount += 1; … … 1323 1326 #declare input values short, shortsequence, float, floatSequence, unsupported 1324 1327 #close the infinate while loop 1325 1328 1326 1329 ts = " "*4 + "}\n"; output.write(ts) 1327 1330 … … 1331 1334 1332 1335 1333 1336 1334 1337 def writeACESvcDef(self, output,c,type): 1335 1338 """ This function writes the implementation of the svn() function for a given component""" … … 1518 1521 ts = " "*8 + "ACE_OS::sleep (ACE_Time_Value (1));\n"; output.write(ts) 1519 1522 ts = " "*4 + '}\n\n' + " "*4 + 'return 0;\n}\n'; output.write(ts) 1520 1523 1521 1524 if type == 'port': 1522 1525 #ts = 'int ' + c.u_cname + '::svc(void)\n{\n'; output.write(ts) … … 1623 1626 output.write(ts) 1624 1627 1625 1628 1626 1629 def writeFriendDecl(self,output,c): 1627 1630 friendList = [] … … 1633 1636 if p.p_cname not in friendList: 1634 1637 friendList.append(p.p_cname) 1635 1638 1636 1639 for x in friendList: 1637 1640 ts = " "*4 + "friend class " + x + ";\n" 1638 output.write(ts) 1639 1641 output.write(ts) 1642 1640 1643 1641 1644 def addGPL(self,outFile,name): 1642 inFile = open( 'generate/gpl_preamble','r')1645 inFile = open(self.wavedevPath + 'generate/gpl_preamble','r') 1643 1646 for line in inFile.readlines(): 1644 1647 l_out = line.replace("__COMP_NAME__",name) 1645 1648 outFile.write(l_out) 1646 1649 1647 1650 inFile.close() 1648 1649 1651 1652 1650 1653 def cleanUp(self): 1651 1654 # Move the AssemblyController to the waveform Dir … … 1654 1657 os.system('mv ' + self.path + c.name + ' ' + self.path + self.active_wave.name) 1655 1658 1656 1659 -
ossiedev/trunk/tools/WaveDev/wavedev/generate/templates/custom_ports/genStructure.py
r5933 r8046 29 29 30 30 class genAll: 31 def __init__(self, path,active_wave):31 def __init__(self, path, wavedevPath, active_wave): 32 32 if path[len(path)-1] != '/': 33 33 path = path + '/' 34 34 self.path = path 35 if len(wavedevPath) > 0 and wavedevPath[len(wavedevPath)-1] != '/': 36 wavedevPath = wavedevPath + '/' 37 self.wavedevPath = wavedevPath 35 38 self.active_wave = active_wave 36 39 … … 41 44 def genDirs(self): 42 45 if os.path.exists(self.path) == False: 43 errorMsg(self," Waveform already exists - exiting")46 errorMsg(self,"Output directory does not exist") 44 47 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: 47 50 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/'): 51 54 # 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 54 57 for x in self.active_wave.components: 55 58 if x.generate: … … 57 60 os.mkdir(self.path+x.name) 58 61 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/'): 61 64 # 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 65 68 ############################################################################## 66 69 ## writeMakefiles - generates the make file for the waveform and then calls … … 72 75 Flags = ["-Wall"] 73 76 self.info2str(output,"AM_CXXFLAGS = ",Flags,1) 74 77 75 78 tstr = "ossieName = " + self.active_wave.name + '\n\n' 76 79 output.write(tstr) 77 80 78 81 tstr = "SUBDIRS = " 79 82 for c in self.active_wave.components: 80 83 if c.AssemblyController == True and c.generate: 81 84 tstr += c.name + '\n\n' 82 output.write(tstr) 83 85 output.write(tstr) 86 84 87 # tstr = "waveformdir = $(prefix)/dom/waveforms/$(ossieName)\n" 85 88 tstr = "waveformdir = $(prefix)/waveforms/" + self.active_wave.name + "\n" … … 105 108 106 109 output.close() 107 110 108 111 for c in self.active_wave.components: 109 112 if c.generate: 110 113 tmpPath = self.path + c.name 111 114 self.writeCompMakefile(c,tmpPath) 112 113 ############################################################################## 115 116 ############################################################################## 114 117 ## writeCompMakefilee - generates the make file for an indivdual component 115 118 ############################################################################## … … 117 120 if compPath[len(compPath)-1] != '/': 118 121 compPath = compPath + '/' 119 122 120 123 header = "%SK.cpp %.h : %.idl\n\t@IDL@ @IDL_FLAGS@ " 121 124 header += "-bcxx -Wbh=.h -Wbs=SK.cpp -Wbkeep_inc_path $<\n\n" 122 125 header += "%.idl :\n\tcp @SI_PATH@/standardinterfaces/$@ .\n" 123 126 124 127 Flags = ["-Wall"] 125 128 126 129 output = open(compPath + 'Makefile.am','w') 127 130 output.writelines(header + "\n") 128 131 self.info2str(output,"AM_CXXFLAGS = ",Flags,1) 129 132 130 133 BuiltSources = [] 131 134 CleanFiles = [] … … 150 153 nodist.append(x.interface.filename+'SK.cpp') 151 154 tempIntList.append(x.interface.filename) 152 155 153 156 self.info2str(output,"BUILT_SOURCES = ",BuiltSources,wrapFlag=True) 154 157 self.info2str(output,"CLEANFILES = ",CleanFiles,1) 155 158 156 159 tstr = "ossieName = " + comp.name + "\n" 157 160 output.write(tstr) 158 161 tstr = "bin_PROGRAMS = " + comp.name + "\n\n" 159 162 output.write(tstr) 160 163 161 164 tstr = "xmldir = $(prefix)/xml/$(ossieName)\n" 162 165 output.write(tstr) … … 168 171 xmlData.append(tstr2 + ".spd.xml") 169 172 self.info2str(output,"dist_xml_DATA = ",xmlData,1,wrapFlag=True) 170 173 171 174 tstr = comp.name + "_SOURCES = " + comp.name+".cpp " + comp.name+".h " 172 175 tstr += "main.cpp port_impl.cpp port_impl.h\n" 173 output.write(tstr) 176 output.write(tstr) 174 177 self.info2str(output,"nodist_"+comp.name+"_SOURCES = ",nodist,1) 175 178 176 179 output.close() 177 180 … … 188 191 if mycount%2 == 0 and wrap and mylist.index(x) != len(mylist)-1: 189 192 tstr = tstr + "\\\n" 190 193 191 194 tstr = tstr + "\n" 192 195 for x in range(extraLine): … … 200 203 def genConfigureACFiles(self,installPath="/sdr/sca"): 201 204 if installPath[-1] == '/': 202 installPath = installPath[0:-1] 203 205 installPath = installPath[0:-1] 206 204 207 tmpPath = self.path + self.active_wave.name + '/' 205 208 self.writeConfAC(tmpPath,self.active_wave.name,self.active_wave.ace,True,installPath) 206 209 207 210 for c in self.active_wave.components: 208 211 if c.AssemblyController == True or not c.generate: 209 212 continue 210 213 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 213 217 ############################################################################## 214 218 ## writeConfAC - generates configure.ac files for autoconf … … 217 221 if genPath[len(genPath)-1] != '/': 218 222 genPath = genPath + '/' 219 223 220 224 output = open(genPath + 'configure.ac','w') 221 225 tstr = "AC_INIT(" + name + ", 0.5.0)\nAM_INIT_AUTOMAKE\n\n" … … 269 273 tstr = 'IDL_FLAGS="$OSSIE_CFLAGS"\nAC_SUBST(IDL_FLAGS)\n\n' 270 274 output.write(tstr) 271 275 272 276 if aceFlag == True: 273 277 tstr = 'PKG_CHECK_MODULES(ACE, ACE >= 5.4.7)\n' 274 278 tstr = tstr + 'AC_SUBST(ACE_CFLAGS)\nAC_SUBST(ACE_LIBS)\nLIBS="$LIBS $ACE_LIBS"\n\n' 275 279 output.write(tstr) 276 277 tstr = "AC_CONFIG_FILES(Makefile" 280 281 tstr = "AC_CONFIG_FILES(Makefile" 278 282 if wavFlag == True: 279 283 for x in self.active_wave.components: … … 281 285 tstr2 = " " + x.name + "/Makefile" 282 286 tstr = tstr + tstr2 283 284 tstr = tstr + ")\n\n" 287 288 tstr = tstr + ")\n\n" 285 289 output.write(tstr) 286 290 … … 289 293 290 294 output.close() 291 292 ############################################################################## 295 296 ############################################################################## 293 297 ## This function generates the cpp and h files for each component: 294 298 ## component.h, component.cpp, main.cpp, port_impl.h, and port_impl.cpp 295 ############################################################################## 299 ############################################################################## 296 300 def genCompFiles(self,comp): 297 301 #for x in self.active_wave.components: 298 302 # 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') 300 304 outputH = open(self.path + comp.name + "/" + comp.name + ".h",'w') 301 305 self.addGPL(outputH,comp.name) … … 320 324 l_out = l_out.replace("__ACE_SVC_DECL__",'int svc(void);\n size_t queue_size;') 321 325 else: 322 continue 326 continue 323 327 if l_out.find("__FRIEND_DECL__") != -1: 324 328 l_out = l_out.replace("__FRIEND_DECL__","") 325 329 self.writeFriendDecl(outputH,comp) 326 330 continue 327 331 328 332 outputH.write(l_out) 329 333 330 334 inputH.close() 331 335 outputH.close() 332 336 333 337 # 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') 335 339 outputCPP = open(self.path + comp.name + "/" + comp.name + ".cpp",'w') 336 340 self.addGPL(outputCPP,comp.name) … … 355 359 if comp.ace == True: 356 360 self.writeACESvcDef(outputCPP,comp,'component',comp.timing, comp) 357 continue 361 continue 358 362 outputCPP.write(l_out) 359 363 360 364 inputCPP.close() 361 365 outputCPP.close() 362 366 363 367 # 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') 365 369 outputMain = open(self.path + comp.name + "/main.cpp",'w') 366 370 self.addGPL(outputMain,comp.name) 367 371 368 372 for line in inputMain.readlines(): 369 373 l_out = line.replace("__IncludeFile__",comp.name) … … 375 379 l_out = l_out.replace("__CLASS_VAR_ACE__",comp.name.lower()) 376 380 else: 377 continue 381 continue 378 382 if l_out.find("__NAME_SPACE__") != -1: 379 383 ns_list = [] … … 386 390 387 391 outputMain.write(l_out) 388 392 389 393 inputMain.close() 390 394 outputMain.close() 391 395 392 396 # 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') 394 398 outputPortImpl = open(self.path + comp.name + "/port_impl.h",'w') 395 399 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') 398 402 for line in inputPortImpl.readlines(): 399 403 l_out = line.replace("__IncludeFile__",comp.name) … … 410 414 if l_out.find("__PORT_DECL__") != -1: 411 415 self.writePortImplDecl(outputPortImpl,portSample_p,portSample_u,comp) 412 continue 416 continue 413 417 outputPortImpl.write(l_out) 414 418 415 419 inputPortImpl.close() 416 420 outputPortImpl.close() 417 421 portSample_p.close() 418 422 portSample_u.close() 419 423 420 424 # 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') 422 426 outputPortImpl = open(self.path + comp.name + "/port_impl.cpp",'w') 423 427 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') 426 430 for line in inputPortImpl.readlines(): 427 431 l_out = line … … 430 434 continue 431 435 outputPortImpl.write(l_out) 432 436 433 437 inputPortImpl.close() 434 438 outputPortImpl.close() 435 439 portSample_p.close() 436 440 portSample_u.close() 437 441 438 442 # 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) 441 445 442 446 def writePortImplDecl(self, output,portSample_p,portSample_u,c): … … 522 526 else: 523 527 l_out = l_out.replace("__COMP_REF_DECL__","") 524 528 525 529 output.write(l_out) 526 530 527 531 def writePortImplDef(self,output,portSample_p,portSample_u,c): 528 532 """ This function writes port implementation definitions for the port_impl.cpp file""" 529 intList = [] 533 intList = [] 530 534 for x in c.ports: 531 535 found_match = False … … 610 614 outCount += 1 611 615 ts = " "*8 + "bool component_alive;\n\n" + " "*8 + "string naming_service_name;\n"; output.write(ts) 612 616 613 617 def writePortInst(self,output,c): 614 618 """ This function writes the port instantiations to the component cpp file""" … … 633 637 ts = "\n"; output.write(ts) 634 638 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 636 640 def writeGetPort(self,output,c): 637 641 """ This function writes the getPort functionality to the component cpp file""" … … 666 670 ts = "\n"; output.write(ts) 667 671 ts = " "*4 + 'return NULL;\n'; output.write(ts) 668 672 669 673 def writeDelPort(self,output,c): 670 674 """ This function writes the destructor functionality (for ports) to the component cpp file""" … … 683 687 outCount += 1 684 688 ts = "\n"; output.write(ts) 685 689 686 690 ## def writeACESvcPorts(self,output,c): 687 691 ## """ This function writes the svc port functionality to the component cpp file""" … … 692 696 ## output.write(ts) 693 697 ## outCount += 1 694 ## ts = "\n"; output.write(ts) 695 698 ## ts = "\n"; output.write(ts) 699 696 700 def writeACESvcDef(self, output,c,type,timing_flag, comp=''): 697 701 """ This function writes the implementation of the svn() function for a given component""" … … 884 888 ts = " "*8 + "//ACE_OS::sleep (ACE_Time_Value (1));\n"; output.write(ts) 885 889 ts = " "*4 + '}\n\n' + " "*4 + 'return 0;\n}\n'; output.write(ts) 886 890 887 891 if type == 'port': 888 892 #t