Changeset 7435
- Timestamp:
- 05/02/08 22:06:43 (5 years ago)
- Location:
- ossiedev/branches/jsnyder/ComponentProject/WaveDev/wavedev
- Files:
-
- 1 added
- 7 modified
-
ComponentClass.py (modified) (11 diffs)
-
MainFrame.py (modified) (101 diffs)
-
PropertiesDialog.py (modified) (27 diffs)
-
XML_gen/application_gen.py (modified) (22 diffs)
-
XML_gen/component_gen.py (modified) (10 diffs)
-
generate/genNode.py (modified) (28 diffs)
-
generate/templates/custom_ports/genStructure.py (modified) (35 diffs)
-
uuidgen.py (added)
Legend:
- Unmodified
- Added
- Removed
-
ossiedev/branches/jsnyder/ComponentProject/WaveDev/wavedev/ComponentClass.py
r5886 r7435 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/branches/jsnyder/ComponentProject/WaveDev/wavedev/MainFrame.py
r7156 r7435 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 … … 433 433 self.nodeBox.Bind(wx.EVT_TREE_END_LABEL_EDIT, 434 434 self.OnNodeBoxTreeEndLabelEdit, id=wxID_FRAME1NODEBOX) 435 435 436 436 self.RefreshResourceBtn = wx.Button(id=wxID_REFRESHRESOURCEBTN, label='Refresh', 437 437 name='RefreshResourceBtn', parent=self, pos=wx.Point(170, 40), … … 461 461 # Constructor for MainFrame 462 462 self._init_ctrls(parent) 463 463 464 464 #read in the configuration information 465 465 LoadConfiguration(self) 466 466 467 467 #setup the environment 468 468 self.active_comp = None 469 self.CompFrame = ComponentFrame.create(self) 469 self.CompFrame = ComponentFrame.create(self) 470 470 self.active_wave = WaveformClass.Waveform() 471 471 self.active_plat = PlatformClass.Platform() … … 476 476 self.saveProjectPath = None 477 477 self.description = None 478 478 self.wavedevPath = '.' # Should really be computed from the install path 479 479 480 ################################################################################ 480 481 ## File/Help Menu Functionality … … 503 504 finally: 504 505 dlg.Destroy() 505 506 506 507 if sflag == True: 507 508 tempLn = self.waveNameBox.GetLineText(0) … … 527 528 finally: 528 529 dlg.Destroy() 529 530 530 531 else: 531 532 if self.saveProjectPath != None: … … 535 536 if self.ProjectSave(True) == False: 536 537 return 537 538 538 539 self.active_wave = WaveformClass.Waveform() 539 self.active_plat = PlatformClass.Platform() 540 self.active_plat = PlatformClass.Platform() 540 541 self.saveProjectPath = None 541 542 self.waveNameBox.Clear() 542 543 self.displayComps() 543 544 self.displayNodes() 544 545 545 546 546 547 event.Skip() 547 548 … … 563 564 finally: 564 565 dlg.Destroy() 565 566 566 567 if sflag == True: 567 568 tempLn = self.waveNameBox.GetLineText(0) … … 587 588 finally: 588 589 dlg.Destroy() 589 590 590 591 else: 591 592 if self.saveWaveformPath != None: … … 595 596 if self.WaveformSave(True) == False: 596 597 return 597 598 598 599 self.active_wave = WaveformClass.Waveform() 599 600 self.saveWaveformPath = None 600 601 self.waveNameBox.Clear() 601 602 self.displayComps() 602 603 603 604 event.Skip() 604 605 … … 620 621 finally: 621 622 dlg.Destroy() 622 623 if sflag == True: 623 624 if sflag == True: 624 625 if self.savePlatformPath != None: 625 626 tmpstr = 'Do you want to overwrite the existing platform file?\n' … … 641 642 finally: 642 643 dlg.Destroy() 643 644 644 645 else: 645 646 if self.PlatformSave(True) == False: 646 647 return 647 648 648 649 self.active_plat = PlatformClass.Platform() 649 650 self.savePlatformPath = None 650 651 self.displayNodes() 651 652 652 653 event.Skip() 653 654 … … 659 660 if tmpdir == "~": 660 661 tmpdir = "/home" 661 662 662 663 tmpwildcard = "Project Files (*.owd)|*.owd|Waveform Designs (*.sca)|*.sca|Platform Layouts (*.plt)|*.plt" 663 664 dlg = wx.FileDialog(self, "Choose a file", tmpdir, "", tmpwildcard, wx.OPEN) … … 671 672 finally: 672 673 dlg.Destroy() 673 674 674 675 f = open(tmpPath,'r') 675 676 tmpObject = cPickle.load(f) … … 680 681 elif tmpObject[0] == 'project': 681 682 self.ProjectOpen(tmpPath,tmpObject[1],tmpObject[2]) 682 683 683 684 event.Skip() 684 685 … … 705 706 finally: 706 707 dlg.Destroy() 707 708 708 709 else: 709 710 self.ProjectSave(False) 710 711 else: 711 712 self.ProjectSave(False) 712 713 713 714 event.Skip() 714 715 … … 739 740 finally: 740 741 dlg.Destroy() 741 742 742 743 else: 743 744 self.WaveformSave(False) 744 745 else: 745 746 self.WaveformSave(False) 746 747 747 748 event.Skip() 748 749 … … 770 771 return False 771 772 self.active_wave.name = tempLn 772 773 773 774 if len(self.homeDir) > 0: 774 775 tmpdir = self.homeDir … … 777 778 if tmpdir == "~": 778 779 tmpdir = "/home" 779 780 780 781 dlg = wx.FileDialog(self, "Save As", tmpdir, tempLn + '.owd', "Project File (*.owd)|*.owd", wx.SAVE) 781 782 #dlg.SetPath(os.getcwd()) … … 789 790 finally: 790 791 dlg.Destroy() 791 792 792 793 f = open(self.saveProjectPath,'w') 793 cPickle.dump(('project',self.active_wave,self.active_plat),f) 794 794 cPickle.dump(('project',self.active_wave,self.active_plat),f) 795 795 796 return True 796 797 … … 802 803 return False 803 804 self.active_wave.name = tempLn 804 805 805 806 if len(self.homeDir) > 0: 806 807 tmpdir = self.homeDir … … 809 810 if tmpdir == "~": 810 811 tmpdir = "/home" 811 812 812 813 dlg = wx.FileDialog(self, "Save As", tmpdir, tempLn + '.sca', "*.sca", wx.SAVE) 813 814 #dlg.SetPath(os.getcwd()) … … 821 822 finally: 822 823 dlg.Destroy() 823 824 824 825 f = open(self.saveWaveformPath,'w') 825 cPickle.dump(('waveform',self.active_wave),f) 826 826 cPickle.dump(('waveform',self.active_wave),f) 827 827 828 return True 828 829 829 830 def PlatformSave(self,saveasFlag): 830 if saveasFlag == True or self.savePlatformPath == None: 831 if saveasFlag == True or self.savePlatformPath == None: 831 832 if self.active_plat.name != "": 832 833 tmpname = self.active_plat.name 833 834 else: 834 835 tmpname = 'Platform1' 835 836 836 837 if len(self.homeDir) > 0: 837 838 tmpdir = self.homeDir … … 840 841 if tmpdir == "~": 841 842 tmpdir = "/home" 842 843 843 844 dlg = wx.FileDialog(self, "Save As", tmpdir, tmpname + '.plt', "Platform File (*.plt)|*.plt", wx.SAVE) 844 845 try: … … 851 852 finally: 852 853 dlg.Destroy() 853 854 854 855 f = open(self.savePlatformPath,'w') 855 cPickle.dump(('platform',self.active_plat),f) 856 856 cPickle.dump(('platform',self.active_plat),f) 857 857 858 return True 858 859 859 860 def WaveformOpen(self,newPath,newWav): 860 861 if newPath != None: … … 871 872 finally: 872 873 dlg.Destroy() 873 874 874 875 self.saveWaveformPath = newPath 875 876 876 877 self.active_wave = newWav 877 878 878 879 # We must create new UUIDs for each instance and copy the file uuid from 879 880 # the base component to the instance … … 887 888 if c.generate == False and found == False: 888 889 errorMsg(self,"Could not find " + c.baseName + " which " + c.name + " is an instance of.") 889 890 890 891 891 892 #Because device assignments are stored as python objects in each component 892 893 #we must refresh the assignment with the available platform devices 893 894 894 895 for c in self.active_wave.components: 895 896 if c.device == None: … … 908 909 errorMsg(self,tmpstr) 909 910 c.device = None 910 911 911 912 self.waveNameBox.Clear() 912 913 self.waveNameBox.WriteText(self.active_wave.name) 913 self.displayComps() 914 914 self.displayComps() 915 915 916 if self.active_wave.ace == True: 916 917 self.menuWaveform.Check(wxID_FRAME1MENUWAVEFORMACESUPPORT,True) … … 918 919 else: 919 920 self.menuWaveform.Check(wxID_FRAME1MENUWAVEFORMACESUPPORT,False) 920 #self.ACEcheckBox.SetValue(False) 921 921 #self.ACEcheckBox.SetValue(False) 922 922 923 def PlatformOpen(self,newPath,newPlat): 923 924 if newPath != None: … … 934 935 finally: 935 936 dlg.Destroy() 936 937 937 938 self.savePlatformPath = newPath 938 939 939 940 self.active_plat = newPlat 940 941 941 942 942 943 # NOTE: The following comment does not hold true now that the nodes are installed … … 956 957 if found == False: 957 958 errorMsg(self,"Could not find " + d.baseName + " which " + d.name + " is an instance of.") 958 959 959 960 self.displayNodes() 960 961 961 962 962 963 def ProjectOpen(self,newPath,newWav,newPlat): 963 964 if self.saveProjectPath != None: … … 973 974 finally: 974 975 dlg.Destroy() 975 976 976 977 self.saveProjectPath = newPath 977 978 978 979 self.PlatformOpen(None,newPlat) 979 980 self.WaveformOpen(None,newWav) 980 981 self.displayNodes() 981 982 982 983 983 984 ################################################################# 984 985 ## Help Menu Stuff 985 986 ################################################################# 986 987 987 988 def OnMenuHelpAboutMenu(self, event): 988 989 dlg = AboutDialog.Dialog1(self) … … 992 993 dlg.Destroy() 993 994 event.Skip() 994 995 995 996 996 997 ################################################################################ 997 998 ## Waveform Layout Functionality … … 1035 1036 finally: 1036 1037 dlg.Destroy() 1037 1038 1038 1039 sn = self.compBox.GetSelection() 1039 1040 if sn == self.compBox.GetRootItem(): … … 1042 1043 # a main level component 1043 1044 self.active_comp = self.compBox.GetPyData(sn) 1044 ti = self.active_wave.components.index(self.active_comp) 1045 ti = self.active_wave.components.index(self.active_comp) 1045 1046 # If any other component is connected to this component - connection must be removed 1046 1047 for c in self.active_wave.components: … … 1048 1049 if con.remoteComp == self.active_comp: 1049 1050 ci = c.connections.index(con) 1050 del c.connections[ci] 1051 del c.connections[ci] 1051 1052 del self.active_wave.components[ti] 1052 1053 else: … … 1056 1057 ti = self.active_comp.connections.index(tc) 1057 1058 del self.active_comp.connections[ti] 1058 1059 1059 1060 self.displayComps() 1060 1061 self.displayNodes() … … 1082 1083 for x in self.compBoxPopup.GetMenuItems(): 1083 1084 if x.GetLabel() != 'Remove': 1084 x.Enable(False) 1085 1086 self.compBox.PopupMenu(self.compBoxPopup) 1085 x.Enable(False) 1086 1087 self.compBox.PopupMenu(self.compBoxPopup) 1087 1088 event.Skip() 1088 1089 1089 1090 def OnCompBoxPopupSet_acMenu(self, event): 1090 1091 for c in self.active_wave.components: 1091 c.AssemblyController = False 1092 c.AssemblyController = False 1092 1093 self.active_comp.AssemblyController = True 1093 1094 self.displayComps() … … 1097 1098 self.EditComponent() 1098 1099 event.Skip() 1099 1100 1100 1101 def OnCompBoxPopupConnectMenu(self, event): 1101 1102 self.ConnectComponent() … … 1107 1108 # what to do when the connections are supported : 1108 1109 #sn = self.nodeBox.GetSelection() 1109 #self.active_comp = self.nodeBox.GetPyData(sn) #active component is actually and active resource 1110 #self.active_comp = self.nodeBox.GetPyData(sn) #active component is actually and active resource 1110 1111 #self.ConnectComponent() 1111 1112 … … 1138 1139 self.active_comp = self.compBox.GetPyData(sn) 1139 1140 newname = event.GetLabel() 1140 1141 1141 1142 if len(newname) > 0: 1142 1143 for c in self.active_wave.components: … … 1145 1146 event.Veto() 1146 1147 return 1147 1148 1148 1149 #Component names with spaces do not work 1149 1150 if newname.find(' ') != -1: … … 1153 1154 #newname = newname.replace(' ','_') 1154 1155 #self.compBox.SetItemText(sn,newname) 1155 1156 1156 1157 self.active_comp.changeName(newname) 1157 1158 #self.active_comp.name = newname … … 1162 1163 event.Veto() 1163 1164 return 1164 event.Skip() 1165 1166 def OnCompBoxTreeBeginLabelEdit(self, event): 1165 event.Skip() 1166 1167 def OnCompBoxTreeBeginLabelEdit(self, event): 1167 1168 sn = self.compBox.GetSelection() 1168 1169 if sn == self.compBox.GetRootItem(): … … 1177 1178 event.Veto() 1178 1179 return 1179 event.Skip() 1180 event.Skip() 1180 1181 1181 1182 def OnCompBoxPopupRenameMenu(self, event): … … 1197 1198 1198 1199 event.Skip() 1199 1200 1200 1201 def OnCompBoxPopupRefreshMenu(self, event): 1201 1202 self.displayComps() 1202 event.Skip() 1203 1203 event.Skip() 1204 1204 1205 ################################################################# 1205 1206 ## Waveform Menu Stuff 1206 1207 ################################################################# 1207 1208 1208 1209 def OnMenuWaveformAddcompMenu(self, event): 1209 1210 ComponentFrame.newComponentFrame() … … 1228 1229 errorMsg(self,'Only top level components can be connected!') 1229 1230 return 1230 1231 1231 1232 self.ConnectComponent() 1232 1233 event.Skip() … … 1244 1245 errorMsg(self,'Only top level components can be edited!') 1245 1246 return 1246 1247 1247 1248 self.EditComponent() 1248 1249 event.Skip() … … 1253 1254 errorMsg(self,'Please enter a waveform name first') 1254 1255 return 1255 1256 nFlag = False 1256 1257 nFlag = False 1257 1258 for c in self.active_wave.components: 1258 1259 if c.name == tempLn: 1259 1260 nFlag = True 1260 1261 1261 1262 if nFlag == True: 1262 1263 tmpstr = "One of the waveform components has the same name as the waveform.\n" … … 1272 1273 node_names.append(n.name) 1273 1274 for d in n.Devices: 1274 device_ids.append(d.uuid) 1275 device_ids.append(d.uuid) 1275 1276 1276 1277 ##check for duplicate node names … … 1279 1280 # errorMsg(self,"Duplicate node names detected. This is not allowed.") 1280 1281 # return 1281 1282 1282 1283 #check for duplicates in the device uuids 1283 1284 tmp = list(set(device_ids)) #removes duplicates from the list 1284 1285 if len(tmp) != len(device_ids): #if there were duplicates (multiple copies of same device instances) 1285 1286 errorMsg(self,"Duplicate nodes or device instantiation UUIDs have been detected. This is not allowed.") 1286 return 1287 return 1287 1288 1288 1289 acFlag = False … … 1307 1308 dlg.Destroy() 1308 1309 #return 1309 1310 1310 1311 if len(noDevs) > 0: 1311 1312 tmpstr = 'The following components are not assigned to a device. ' … … 1314 1315 tmpstr += x + '\n' 1315 1316 errorMsg(self,tmpstr) 1316 1317 1317 1318 self.waveName = tempLn 1318 1319 self.active_wave.name = tempLn 1319 1320 1320 1321 dlg = wx.DirDialog(self,"Please select the place to generate the code",style=wx.DD_NEW_DIR_BUTTON) 1321 1322 dlg.SetPath(os.getcwd()) … … 1327 1328 finally: 1328 1329 dlg.Destroy() 1329 1330 gen = genStruct.genAll(self.path, copy.deepcopy(self.active_wave))1330 1331 gen = genStruct.genAll(self.path, self.wavedevPath, copy.deepcopy(self.active_wave)) 1331 1332 gen.genDirs() 1332 1333 # Only include the device manager files if there is just one node … … 1340 1341 if c.generate: 1341 1342 gen.genCompFiles(c) 1342 1343 xml_gen.genxml(copy.deepcopy(self.active_wave.components), self.path,self.active_wave.name)1344 xml_gen.genDAS(copy.deepcopy(self.active_wave.components), self.path,self.active_wave.name)1345 xml_gen.writeWaveSetuppy(self.path, self. active_wave.name)1346 1347 #save the .owd file 1343 1344 xml_gen.genxml(copy.deepcopy(self.active_wave.components), self.path, self.wavedevPath, self.active_wave.name) 1345 xml_gen.genDAS(copy.deepcopy(self.active_wave.components), self.path, self.wavedevPath, self.active_wave.name) 1346 xml_gen.writeWaveSetuppy(self.path, self.wavedevPath, self.active_wave.name) 1347 1348 #save the .owd file 1348 1349 f = open(self.path + "/" + self.waveName + "/" + self.waveName + ".owd",'w') 1349 cPickle.dump(('project',self.active_wave,self.active_plat),f) 1350 1350 cPickle.dump(('project',self.active_wave,self.active_plat),f) 1351 1351 1352 #generate the dcd file for each node 1352 1353 #for n in self.active_plat.nodes: … … 1357 1358 # tmpname = 'DeviceManager' + n.name 1358 1359 # folderFlag = True 1359 #xml_gen.genDeviceManager(n, self.path,self.active_wave.name,tmpname,folderFlag)1360 1360 #xml_gen.genDeviceManager(n, self.path, self.wavedevPath, self.active_wave.name, tmpname,folderFlag) 1361 1361 1362 gen.cleanUp() 1362 1363 … … 1371 1372 for x in self.active_wave.components: 1372 1373 if x.generate == True: 1373 x.ace = False 1374 1375 event.Skip() 1376 1377 1374 x.ace = False 1375 1376 event.Skip() 1377 1378 1378 1379 ################################################################################ 1379 1380 ## Resource Functionality 1380 1381 ################################################################################ 1381 1382 1382 1383 def displayResources(self): 1383 1384 self.resourceBox.DeleteAllItems() … … 1386 1387 devRoot = self.resourceBox.AppendItem(troot,'Devices',image=1) 1387 1388 nodeRoot = self.resourceBox.AppendItem(troot,'Nodes',image=1) 1388 1389 1389 1390 for c in self.Available_Components: 1390 1391 t1 = self.resourceBox.AppendItem(compRoot,c.name) 1391 1392 self.resourceBox.SetPyData(t1,c) 1392 1393 1393 1394 for c in self.Available_Devices: 1394 1395 t1 = self.resourceBox.AppendItem(devRoot,c.name) 1395 1396 self.resourceBox.SetPyData(t1,c) 1396 1397 1397 1398 for n in self.Available_Nodes: 1398 1399 t1 = self.resourceBox.AppendItem(nodeRoot,n.name) 1399 1400 self.resourceBox.SetPyData(t1,n) 1400 1401 1401 1402 1402 1403 if self.resourceBox.GetChildrenCount(troot,recursively=False) > 0: 1403 1404 cid1,cookie1 = self.resourceBox.GetFirstChild(troot) … … 1407 1408 self.resourceBox.SortChildren(cid1) 1408 1409 1409 def loadResources(self): 1410 def loadResources(self): 1410 1411 self.Available_Components = [] 1411 1412 self.Available_Devices = [] 1412 1413 self.Available_Nodes = [] 1413 1414 1414 1415 resList = [] 1415 1416 … … 1429 1430 tmpResPath = r[0] + r[1] 1430 1431 tmpComp = importResource.getResource(tmpResPath,tmpResName,self) 1431 1432 1432 1433 if tmpComp == None: 1433 1434 continue … … 1440 1441 elif tmpComp.type == 'device': 1441 1442 self.Available_Devices.append(tmpComp) 1442 1443 1443 1444 nodeList = [] 1444 1445 if os.path.isdir(self.installPath + 'nodes'): … … 1446 1447 else: 1447 1448 errorMsg(self, "No nodes could be found in: " + self.installPath) 1448 1449 1449 1450 # find the scd files for each node 1450 1451 for node_name in nodeList: … … 1467 1468 nodeName = node_name 1468 1469 nodePath = self.installPath + 'nodes/' + nodeName + '/' 1469 1470 1470 1471 tmpNode = importNode.getNode(nodePath,nodeName,self) 1471 1472 if tmpNode == None: … … 1473 1474 continue 1474 1475 self.Available_Nodes.append(tmpNode) 1475 1476 1476 1477 self.displayResources() 1477 1478 1478 def OnRefreshResourceBtnButton(self, event): 1479 def OnRefreshResourceBtnButton(self, event): 1479 1480 self.loadResources() 1480 1481 … … 1498 1499 if c.baseName == tmpBaseName: 1499 1500 tmpCount += 1 1500 1501 1501 1502 dlg = wx.TextEntryDialog(self, 'Please enter an instance name for this '\ 1502 1503 + tmpRes.name + ' component.', 'Enter Name', tmpRes.name + str(tmpCount)) … … 1509 1510 dlg.Destroy() 1510 1511 return 1511 1512 1512 1513 for c in self.active_wave.components: 1513 1514 if newname == c.name: … … 1520 1521 finally: 1521 1522 dlg.Destroy() 1522 1523 1523 1524 1524 1525 newRes = copy.deepcopy(tmpRes) 1525 newRes.name = newname 1526 newRes.baseName = tmpBaseName 1526 newRes.name = newname 1527 newRes.baseName = tmpBaseName 1527 1528 newRes.setUUID() # this gives the component instance a unique id 1528 1529 # we do not set the newRes.file_uuid because it is the same for all components of this type 1529 1530 1530 1531 self.active_wave.components.append(newRes) 1531 1532 self.displayComps() … … 1548 1549 x.Enable(True) 1549 1550 tmpRes = self.resourceBox.GetPyData(sn) 1550 if tmpRes.type == 'resource': 1551 if tmpRes.type == 'resource': 1551 1552 x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPADDDEV) 1552 x.Enable(False) 1553 x.Enable(False) 1553 1554 x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPADDNODE) 1554 x.Enable(False) 1555 1555 x.Enable(False) 1556 1556 1557 #x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPGETDESCR) 1557 1558 #x.Enable(False) 1558 1559 1559 1560 #disable Doxygen docs display if no docs directory found 1560 1561 docsPath = self.installPath + 'docs/' + tmpRes.name … … 1564 1565 elif tmpRes.type == 'node': 1565 1566 x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPADDDEV) 1566 x.Enable(False) 1567 x.Enable(False) 1567 1568 x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPADD) 1568 x.Enable(False) 1569 #x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPGETDESCR) 1570 #x.Enable(False) 1571 x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPGETDOXYGENREFMAN) 1572 x.Enable(False) 1573 else: 1574 x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPADDNODE) 1575 x.Enable(False) 1576 x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPADD) 1577 x.Enable(False) 1569 x.Enable(False) 1578 1570 #x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPGETDESCR) 1579 1571 #x.Enable(False) 1580 1572 x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPGETDOXYGENREFMAN) 1581 1573 x.Enable(False) 1574 else: 1575 x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPADDNODE) 1576 x.Enable(False) 1577 x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPADD) 1578 x.Enable(False) 1579 #x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPGETDESCR) 1580 #x.Enable(False) 1581 x = self.resourceBoxPopup.FindItemById(wxID_FRAME1RESOURCEBOXPOPUPGETDOXYGENREFMAN) 1582 x.Enable(False) 1582 1583 1583 1584 #if tmpRes != None: 1584 self.resourceBox.PopupMenu(self.resourceBoxPopup) 1585 self.resourceBox.PopupMenu(self.resourceBoxPopup) 1585 1586 event.Skip() 1586 1587 … … 1603 1604 sn = self.resourceBox.GetSelection() 1604 1605 tmpRes = self.resourceBox.GetPyData(sn) 1605 1606 1606 1607 if len(self.active_plat.nodes) == 0: 1607 1608 tmpstr = "There are no available nodes to add a device instance to.\n" … … 1609 1610 errorMsg(self,tmpstr) 1610 1611 return 1611 1612 1612 1613 tmpBaseName = tmpRes.name 1613 1614 #tmpCount = 1 … … 1616 1617 # if x.baseName == tmpBaseName: 1617 1618 # tmpCount += 1 1618 1619 1619 1620 #dlg = NodeDialog.create(self,self.active_plat.nodes,tmpBaseName + str(tmpCount)) 1620 1621 dlg = NodeDialog.create(self,self.active_plat.nodes,tmpBaseName) 1621 1622 1622 1623 try: 1623 1624 returnCode = dlg.ShowModal() … … 1629 1630 basename = newname 1630 1631 newname = newname+str(tmpCount) 1631 1632 1632 1633 while iterator < len(tmpnode.Devices): 1633 1634 for c in tmpnode.Devices: … … 1654 1655 finally: 1655 1656 dlg.Destroy() 1656 1657 1657 1658 1658 1659 newDev = copy.deepcopy(tmpRes) 1659 newDev.name = newname 1660 newDev.baseName = tmpBaseName 1661 newDev.generate = False 1660 newDev.name = newname 1661 newDev.baseName = tmpBaseName 1662 newDev.generate = False 1662 1663 newDev.node = tmpnode.name 1663 1664 newDev.setUUID() # this gives the device instance a unique id 1664 1665 # we do not set the newDev.file_uuid because it is the same for all devices of this type 1665 1666 1666 1667 tmpnode.Devices.append(newDev) 1667 1668 self.displayNodes() … … 1701 1702 errorMsg(self,'Neither index.html nor refman.pdf found in ' + docsPath + ': directory listing: ' + str(docList)) 1702 1703 else: 1703 errorMsg(self,'No directory for ' + tmpRes.name + ' could be found in: ' + self.installPath + 'docs') 1704 errorMsg(self,'No directory for ' + tmpRes.name + ' could be found in: ' + self.installPath + 'docs') 1704 1705 return 1705 1706 … … 1710 1711 self.displayNodes() 1711 1712 event.Skip() 1712 1713 1713 1714 ################################################################################ 1714 1715 ## Platform Layout Functionality … … 1718 1719 self.nodeBox.DeleteAllItems() 1719 1720 troot = self.nodeBox.AddRoot("the_root") 1720 1721 1721 1722 for n in self.active_plat.nodes: 1722 1723 t1 = self.nodeBox.AppendItem(troot,n.name) 1723 1724 self.nodeBox.SetPyData(t1,n) 1724 1725 1725 1726 for d in n.Devices: 1726 1727 t2 = self.nodeBox.AppendItem(t1,unicode(d.name)) 1727 1728 self.nodeBox.SetPyData(t2,d) 1728 1729 1729 1730 for c in self.active_wave.components: 1730 1731 if c.device == d: 1731 1732 t3 = self.nodeBox.AppendItem(t2,c.name) 1732 1733 self.nodeBox.SetPyData(t3,c) 1733 1734 1734 1735 def AddNode(self): 1735 1736 tmpCount = len(self.active_plat.nodes) + 1 1736 1737 1737 1738 dlg = wx.TextEntryDialog(self, 'Please enter a name for this node ',\ 1738 1739 'Enter Name', 'Node' + str(tmpCount)) … … 1745 1746 dlg.Destroy() 1746 1747 return 1747 1748 1748 1749 for c in self.active_plat.nodes: 1749 1750 if newname == c.name: … … 1756 1757 finally: 1757 1758 dlg.Destroy() 1758 1759 1759 1760 #tmpNode = PlatformClass.Node(newname) 1760 1761 tmpNode = ComponentClass.Node(name=newname) … … 1765 1766 errorMsg(self, 'WARNING: You will have to regenerate your waveform if you continue') 1766 1767 sn = self.nodeBox.GetSelection() 1767 1768 1768 1769 #generate the dcd file for the selected node 1769 1770 dlg = wx.DirDialog(self,"Please select the place to generate the code",style=wx.DD_NEW_DIR_BUTTON) … … 1777 1778 dlg.Destroy() 1778 1779 active_node = None 1779 1780 1780 1781 tmp_count = 0 1781 1782 duplicate_name_flag = False … … 1784 1785 dev_count = 0 1785 1786 while dev_count < len(self.active_plat.nodes[tmp_count].Devices): 1786 tmp_uuid = unicode( ComponentClass.uuidgen())1787 tmp_uuid = unicode(uuidgen.uuidgen()) 1787 1788 n.Devices[dev_count].uuid = tmp_uuid 1788 1789 self.active_plat.nodes[tmp_count].Devices[dev_count].uuid = tmp_uuid 1789 dev_count = dev_count + 1 1790 dev_count = dev_count + 1 1790 1791 active_node = n 1791 1792 break … … 1797 1798 1798 1799 1799 gen = genNode.genAll(self.path, copy.deepcopy(active_node))1800 gen = genNode.genAll(self.path, self.wavedevPath, copy.deepcopy(active_node)) 1800 1801 gen.genDirs() 1801 1802 gen.writeMakefile() 1802 1803 # TODO: use different configure.ac file for node -JDG 1803 1804 gen.genConfigureACFiles(self.installPath) 1804 xml_gen.genDeviceManager(n, self.path,n.name,"DeviceManager",False)1805 1806 1805 xml_gen.genDeviceManager(n, self.path, self.wavedevPath, n.name, "DeviceManager", False) 1806 1807 1807 1808 def RemoveNodeBoxSelection(self): 1808 1809 sn = self.nodeBox.GetSelection() 1809 1810 snParent = self.nodeBox.GetItemParent(sn) 1810 if snParent == self.nodeBox.GetRootItem(): 1811 # a platform node 1811 if snParent == self.nodeBox.GetRootItem(): 1812 # a platform node 1812 1813 tmpMsg = " Are you sure you want to remove this Node?\n\n" 1813 1814 tmpMsg += "All device instances assigned to this node will be removed,\n" … … 1816 1817 return 1817 1818 tmpNode = self.nodeBox.GetPyData(sn) 1818 for n in self.active_plat.nodes: 1819 if tmpNode == n: 1819 for n in self.active_plat.nodes: 1820 if tmpNode == n: 1820 1821 for d in n.Devices: 1821 1822 # If any other component is connected to this device - connection must be removed … … 1830 1831 dIndex = self.active_plat.nodes.index(tmpNode) 1831 1832 del self.active_plat.nodes[dIndex] 1832 1833 1833 1834 elif self.nodeBox.GetItemParent(snParent) == self.nodeBox.GetRootItem(): 1834 1835 # a device instance … … 1843 1844 if con.remoteComp == tmpDev: 1844 1845 ci = c.connections.index(con) 1845 del c.connections[ci] 1846 1847 for n in self.active_plat.nodes: 1846 del c.connections[ci] 1847 1848 for n in self.active_plat.nodes: 1848 1849 for d in n.Devices: 1849 1850 if tmpDev == d: … … 1860 1861 tmpComp = self.nodeBox.GetPyData(sn) 1861 1862 tmpComp.device = None 1862 1863 1863 1864 self.displayNodes() 1864 1865 self.displayComps() … … 1892 1893 self.nodeBoxPopup.Enable(wxID_FRAME1NODEBOXPOPUPGENERATE,False) 1893 1894 self.nodeBoxPopup.Enable(wxID_FRAME1NODEBOXPOPUPRENAME,False) 1894 1895 self.nodeBox.PopupMenu(self.nodeBoxPopup) 1895 1896 self.nodeBox.PopupMenu(self.nodeBoxPopup) 1896 1897 event.Skip() 1897 1898 … … 1903 1904 self.RemoveNodeBoxSelection() 1904 1905 event.Skip() 1905 1906 1906 1907 def OnNodeBoxPopupGenerateMenu(self, event): 1907 1908 self.GenerateNodeBoxSelection() … … 1910 1911 def OnNodeBoxPopupExpandMenu(self, event): 1911 1912 troot = self.nodeBox.GetRootItem() 1912 if self.nodeBox.ItemHasChildren(troot): 1913 if self.nodeBox.ItemHasChildren(troot): 1913 1914 cid1,cookie1 = self.nodeBox.GetFirstChild(troot) 1914 1915 self.ExpandTreeNode(self.nodeBox,cid1) … … 1917 1918 self.ExpandTreeNode(self.nodeBox,cid1) 1918 1919 cid1 = self.nodeBox.GetNextSibling(cid1) 1919 1920 event.Skip() 1921 1920 1921 event.Skip() 1922 1922 1923 def OnNodeBoxPopupRefreshMenu(self, event): 1923 1924 self.displayNodes() … … 1942 1943 event.Veto() 1943 1944 return 1944 event.Skip() 1945 event.Skip() 1945 1946 1946 1947 def OnNodeBoxTreeEndLabelEdit(self, event): … … 1960 1961 event.Veto() 1961 1962 return 1962 1963 1963 1964 #Node names with spaces do not work 1964 1965 if newname.find(' ') != -1: … … 1966 1967 event.Veto() 1967 1968 return 1968 1969 1969 1970 tempNode.name = newname 1970 1971 else: … … 1979 1980 newname = event.GetLabel() 1980 1981 if len(newname) > 0: 1981 for d in tempNode.Devices: 1982 for d in tempNode.Devices: 1982 1983 if d != tempDev and d.name == newname: 1983 1984 errorMsg(self,'Invalid name - a device instance with that name already exists') 1984 1985 event.Veto() 1985 1986 return 1986 1987 1987 1988 #Device names with spaces do not work 1988 1989 if newname.find(' ') != -1: … … 1990 1991 event.Veto() 1991 1992 return 1992 1993 1993 1994 tempDev.changeName(newname) 1994 1995 1995 1996 else: 1996 1997 # a child component (connection) 1997 1998 event.Veto() 1998 1999 return 1999 2000 event.Skip() 2000 2001 event.Skip() 2001 2002 2002 2003 ################################################################# … … 2023 2024 self.ExpandTreeNode(whichBox,cid1) 2024 2025 cid1 = self.nodeBox.GetNextSibling(cid1) 2025 2026 2026 2027 ############################################################################### 2027 2028 ## LoadConfiguration 2028 ## This function is not a part of the frame class so that other modules can 2029 ## This function is not a part of the frame class so that other modules can 2029 2030 ## call it 2030 ############################################################################### 2031 ############################################################################### 2031 2032 def LoadConfiguration(frame_obj): 2032 2033 '''Extracts information from configuration file''' … … 2040 2041 except: 2041 2042 frame_obj.version = "unknown" 2042 2043 2043 2044 # install path 2044 2045 try: … … 2080 2081 errorMsg(frame_obj,tmpstr) 2081 2082 2082 2083 2083 2084 # custom IDL path 2084 2085 use_default_customidlpath = False … … 2131 2132 tmpstr += "using CF interfaces.\n\n" 2132 2133 tmpstr += "If you have ossie installed in a location other than\n" 2133 tmpstr += "the default please specify that location in the\n" 2134 tmpstr += "the default please specify that location in the\n" 2134 2135 tmpstr += "wavedev.cfg file located in the top directory." 2135 2136 errorMsg(frame_obj,tmpstr) -
ossiedev/branches/jsnyder/ComponentProject/WaveDev/wavedev/PropertiesDialog.py
r5941 r7435 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/branches/jsnyder/ComponentProject/WaveDev/wavedev/XML_gen/application_gen.py
r7383 r7435 19 19 import sys 20 20 import commands 21 import os 21 import os 22 22 import shutil 23 23 import component_gen … … 26 26 #import xmlBeautify 27 27 import WaveDev.wavedev.ComponentClass as CC 28 29 30 # UUID Generator 31 def uuidgen(): 32 return commands.getoutput('uuidgen -t') 28 from WaveDev.wavedev.uuidgen import uuidgen 29 33 30 34 31 try: … … 45 42 commentLine = u'<!--Created with OSSIE WaveDev ' + version \ 46 43 + u'-->\n<!--Powered by Python-->\n' 47 44 48 45 49 46 xmlpath = u'/xml/' 50 47 ####################################################################### 51 48 # genxml generates xml profiles for each component and the waveform 52 ####################################################################### 53 def genxml(complist, genPath, wave Name):49 ####################################################################### 50 def genxml(complist, genPath, wavedevPath, waveName): 54 51 55 52 if genPath[len(genPath)-1] != '/': 56 53 genPath = genPath + '/' 57 54 genPath = unicode(genPath) 55 if wavedevPath[len(wavedevPath)-1] != '/': 56 wavedevPath = wavedevPath + '/' 58 57 waveformDir = unicode(genPath + waveName + '/') 59 58 60 59 61 60 appName = unicode(waveName) 62 61 #namingServicePrefix = u'ossie' 63 62 outputFilename_sad = appName + u'.sad.xml' 64 63 65 64 # Generate the individual component xml files 66 65 for n in complist: 67 66 if n.generate: 68 component_gen.gen_scd(n, genPath )69 component_gen.gen_spd(n, genPath )70 component_gen.gen_prf(n, genPath )71 67 component_gen.gen_scd(n, genPath, wavedevPath) 68 component_gen.gen_spd(n, genPath, wavedevPath) 69 component_gen.gen_prf(n, genPath, wavedevPath) 70 72 71 #---------------------------------------------------------------------------- 73 72 # SAD Parser / Generator 74 73 # 75 74 76 75 # Use the minidom module to objectify and generate the SAD file 77 76 try: #if running from wavedev 78 doc_sad = xml.dom.minidom.parse( 'XML_gen/_sad.xml.tpl')77 doc_sad = xml.dom.minidom.parse(wavedevPath + 'XML_gen/_sad.xml.tpl') 79 78 except: #if not being called from wavedev, try looking for the file 80 79 doc_sad = xml.dom.minidom.parse('/sdr/tools/WaveDev/wavedev/XML_gen/_sad.xml.tpl') … … 82 81 doc_sad.getElementsByTagName("softwareassembly")[0].setAttribute("name", u'OSSIE::' + appName ) 83 82 doc_sad.getElementsByTagName("softwareassembly")[0].setAttribute("id", u'DCE:' + unicode(uuidgen()) ) 84 83 85 84 # get root nodes for componentfiles, partitioning, assemblycontroller, and connections tags 86 85 componentfilesNode = doc_sad.getElementsByTagName("componentfiles")[0] … … 88 87 assemblycontrollerNode = doc_sad.getElementsByTagName("assemblycontroller")[0] 89 88 connectionsNode = doc_sad.getElementsByTagName("connections")[0] 90 91 baseComponentList = [] 89 90 baseComponentList = [] 92 91 for n in complist: 93 92 # Generate the componentfile entries 94 93 #tmpid = unicode(n.name) + u'_' + unicode(uuidgen()) 95 94 tmpid = unicode(n.baseName) + u'_' + unicode(n.file_uuid) 96 95 97 96 if n.baseName not in baseComponentList: 98 97 baseComponentList.append(n.baseName) … … 136 135 except: 137 136 pass 138 137 139 138 if overload_flag: 140 139 componentpropertiesNode = doc_sad.createElement("componentproperties") … … 184 183 namingserviceNode.setAttribute("name", NSname) 185 184 findcomponentNode.appendChild(namingserviceNode) 186 185 187 186 #TODO: append child nodes to componentplacement 188 187 componentinstantiationNode.appendChild(usagenameNode) … … 244 243 c1name = "DomainName1/USRP1" 245 244 namingserviceUsesNode.setAttribute("name", c1name) 246 245 247 246 # Append child nodes 248 247 usesidentifierNode.appendChild(usesidentifierTextNode) … … 250 249 usesportNode.appendChild(usesidentifierNode) 251 250 usesportNode.appendChild(findbyUsesNode) 252 251 253 252 if devFlag != True: 254 253 providesportNode = doc_sad.createElement("providesport") … … 258 257 namingserviceProvidesNode = doc_sad.createElement("namingservice") 259 258 namingserviceProvidesNode.setAttribute("name", c2name) 260 259 261 260 # Make connections 262 261 providesidentifierNode.appendChild(providesidentifierTextNode) … … 285 284 assemblycontroller_id = u'DCE:' + unicode(n.uuid) 286 285 assemblycontrollerNode.getElementsByTagName("componentinstantiationref")[0].setAttribute("refid", assemblycontroller_id) 287 286 288 287 # Define <!DOCTYPE> here (overriding template if necessary) 289 288 doc_sad.doctype.name = u'softwareassembly' … … 301 300 ################################################################################ 302 301 # Generate the Device Assignment Sequence 303 def genDAS(complist, path, wave Name):302 def genDAS(complist, path, wavedevPath, waveName): 304 303 if path[len(path)-1] != '/': 305 304 path = path + '/' … … 312 311 try: 313 312 # try to find the DAS template using a relative path (being called by OWD) 314 doc_das = xml.dom.minidom.parse( 'XML_gen/_DAS.xml.tpl')315 except: 316 # try to find the DAS template using an absolute path 317 # (being called by other application) 313 doc_das = xml.dom.minidom.parse(wavedevPath + 'XML_gen/_DAS.xml.tpl') 314 except: 315 # try to find the DAS template using an absolute path 316 # (being called by other application) 318 317 # if DAS file is still not found, should throw an IO Error 319 318 doc_das = xml.dom.minidom.parse('/sdr/tools/WaveDev/wavedev/XML_gen/_DAS.xml.tpl') … … 330 329 continue 331 330 tmpDev = u'DCE:' + unicode(n.device.uuid) 332 331 333 332 deviceassignmenttypeNode = doc_das.createElement("deviceassignmenttype") 334 333 componentidNode = doc_das.createElement("componentid") … … 354 353 ################################################################################ 355 354 # Generate the DeviceManager XML files 356 def genDeviceManager(node, path,wavName,dmName,folder=False):355 def genDeviceManager(node, path, wavedevPath, wavName, dmName, folder = False): 357 356 if path[len(path)-1] != '/': 358 357 path = path + '/' 359 358 path += wavName + '/' 360 359 361 360 waveformDir = path 362 361 if folder == True: 363 if os.path.exists(path + node.name) == False: 362 if os.path.exists(path + node.name) == False: 364 363 os.mkdir(path + node.name) 365 364 path += node.name + '/' 366 365 367 366 #Generate the DCD file for the Device Manager 368 genDCD(node.Devices, path,node.name,dmName,folder,node.generate,node.id)369 367 genDCD(node.Devices, path, wavedevPath, node.name, dmName, folder, node.generate, node.id) 368 370 369 outputFilename_spd = dmName + '.spd.xml' 371 370 outputFilename_scd = dmName + '.scd.xml' 372 371 outputFilename_prf = dmName + '.prf.xml' 373 372 374 373 #Copy and modify the spd file 375 doc_spd = xml.dom.minidom.parse( 'XML_gen/DevMan/_spd.xml.tpl')374 doc_spd = xml.dom.minidom.parse(wavedevPath + 'XML_gen/DevMan/_spd.xml.tpl') 376 375 doc_spd.getElementsByTagName("softpkg")[0].setAttribute("name", dmName) 377 376 localfileNode = doc_spd.getElementsByTagName("descriptor")[0].getElementsByTagName("localfile")[0] 378 377 localfileNode.setAttribute("name", unicode(dmName) + u'.scd.xml') 379 378 380 379 # Define <!DOCTYPE> here (overriding template if necessary) 381 380 doc_spd.doctype.name = u'softpkg' … … 388 387 # Copy the scd and prf files to directory - these aren't changed yet 389 388 print "Performing a copy to: " + path + outputFilename_scd 390 shutil.copyfile( 'XML_gen/DevMan/_scd.xml.tpl', path + outputFilename_scd)391 shutil.copyfile( 'XML_gen/DevMan/_prf.xml.tpl', path + outputFilename_prf)392 393 389 shutil.copyfile(wavedevPath + 'XML_gen/DevMan/_scd.xml.tpl', path + outputFilename_scd) 390 shutil.copyfile(wavedevPath + 'XML_gen/DevMan/_prf.xml.tpl', path + outputFilename_prf) 391 392 394 393 395 394 ################################################################################ 396 # Generate the DeviceManager DCD.xml file 397 def genDCD(devlist, path,nodeName,dmName='DeviceManager',folder=False,generate=True,devconf=""):398 395 # Generate the DeviceManager DCD.xml file 396 def genDCD(devlist, path, wavedevPath, nodeName, dmName = 'DeviceManager', folder = False, generate = True, devconf = ""): 397 399 398 outputFilename_dcd = dmName + '.dcd.xml' 400 401 doc_dcd = xml.dom.minidom.parse( 'XML_gen/_dcd.xml.tpl')399 400 doc_dcd = xml.dom.minidom.parse(wavedevPath + 'XML_gen/_dcd.xml.tpl') 402 401 403 402 deviceconfigurationNode = doc_dcd.getElementsByTagName("deviceconfiguration")[0] … … 412 411 devicemanagersoftpkgNode = deviceconfigurationNode.getElementsByTagName("devicemanagersoftpkg")[0] 413 412 devicemanagersoftpkgNode.getElementsByTagName("localfile")[0].setAttribute("name", unicode(dmName) + u'.spd.xml') 414 413 415 414 baseDeviceList = [] 416 415 componentfilesNode = deviceconfigurationNode.getElementsByTagName("componentfiles")[0] … … 425 424 componentfileNode.setAttribute("type", "SPD") 426 425 componentfileNode.setAttribute("id", tmpid) 427 426 428 427 localcomponentfileNode = doc_dcd.createElement("localfile") 429 428 localcomponentfileNode.setAttribute("name", unicode(xmlpath + n.baseName + '/' + n.baseName + '.spd.xml') ) … … 431 430 componentfileNode.appendChild(localcomponentfileNode) 432 431 componentfilesNode.appendChild(componentfileNode) 433 432 434 433 # Generate the partitioning entries 435 434 componentplacementNode = doc_dcd.createElement("componentplacement") … … 457 456 458 457 459 def writeWaveSetuppy(wavePath, waveName):458 def writeWaveSetuppy(wavePath, wavedevPath, waveName): 460 459 ''' 461 ############################################################################## 460 ############################################################################## 462 461 ## writeWaveSetuppy - generates the setup.py file for a waveform 463 462 ############################################################################## … … 468 467 469 468 #copy over the readme file 470 shutil.copy( 'XML_gen/README', wavePath)471 469 shutil.copy(wavedevPath + 'XML_gen/README', wavePath) 470 472 471 output = open(wavePath + '/setup.py','w') 473 472 ts = "\ … … 488 487 "',data_files=[(install_location+'/waveforms/" + waveName + "',['" + \ 489 488 waveName + ".sad.xml', '" + waveName + "_DAS.xml'])])" 490 output.writelines(ts) 489 output.writelines(ts) 491 490 492 491 output.close() #done creating the file -
ossiedev/branches/jsnyder/ComponentProject/WaveDev/wavedev/XML_gen/component_gen.py
r7383 r7435 24 24 import xml.dom.minidom 25 25 from xml.dom.minidom import Node 26 from WaveDev.wavedev.uuidgen import uuidgen 26 27 27 28 #import xmlBeautify 28 29 29 # 30 # UUID Generator 31 # 32 def uuidgen(): 33 return commands.getoutput('uuidgen -t') 34 35 36 try: 30 31 try: 37 32 doc_cfg = xml.dom.minidom.parse('../wavedev.cfg') 38 33 except: #if not being called from wavedev, try looking for wavedev … … 45 40 #version = version.strip('\n') 46 41 commentLine = u'<!--Created with OSSIE WaveDev ' + version \ 47 + u'-->\n<!--Powered by Python-->\n' 42 + u'-->\n<!--Powered by Python-->\n' 48 43 49 44 xmlpath = u'xml/' 50 45 binpath = u'bin/' 51 46 52 def gen_scd(comp, waveformDir ):47 def gen_scd(comp, waveformDir, wavdevPath): 53 48 # Generate the componentfile entries 54 doc_scd = xml.dom.minidom.parse( 'XML_gen/_scd.xml.tpl')55 49 doc_scd = xml.dom.minidom.parse(wavedevPath + 'XML_gen/_scd.xml.tpl') 50 56 51 int_types = {} 57 52 58 53 portsNode = doc_scd.getElementsByTagName("ports")[0] 59 54 60 55 # add provides ports to .scd.xml file 61 56 for p in comp.ports: … … 74 69 # append new provides port to <ports> 75 70 portsNode.appendChild(providesPortNode) 76 71 77 72 if p.interface.name not in int_types: 78 73 int_types[p.interface.name] = copy.deepcopy(p.interface) 79 74 80 75 del providesPortNode, portTypeNode 81 76 82 77 # add uses ports to .scd.xml file 83 78 for p in comp.ports: … … 93 88 portTypeNode.setAttribute("type", unicode(p.portType)) 94 89 usesPortNode.appendChild(portTypeNode) 95 90 96 91 # append new uses port to <ports> 97 92 portsNode.appendChild(usesPortNode) 98 93 99 94 if p.interface.name not in int_types: 100 95 int_types[p.interface.name] = copy.deepcopy(p.interface) 101 96 102 97 del usesPortNode, portTypeNode 103 98 104 99 # Add interfaces 105 100 interfacesRootNode = doc_scd.getElementsByTagName("softwarecomponent")[0].getElementsByTagName("interfaces")[0] … … 119 114 #doc_scd.doctype.name = u'softwarecomponent' 120 115 #doc_scd.doctype.systemId = u'../dtd/softwarecomponent.dtd' 121 116 122 117 outfile = open(compDir + outputFileName_scd, 'w') 123 118 doc_scd.writexml( outfile, encoding='UTF-8' ) 124 119 outfile.close() 125 126 def gen_spd(comp, waveformDir ):127 componentName = unicode(comp.name) 120 121 def gen_spd(comp, waveformDir, wavedevPath): 122 componentName = unicode(comp.name) 128 123 componentDescr = unicode(comp.description) 129 130 doc_spd = xml.dom.minidom.parse( 'XML_gen/_spd.xml.tpl')131 124 125 doc_spd = xml.dom.minidom.parse(wavedevPath + 'XML_gen/_spd.xml.tpl') 126 132 127 #doc_spd.softpkg.name = u'ossie' + componentName + u'Resource' 133 128 softpkgNode = doc_spd.getElementsByTagName("softpkg")[0] 134 129 softpkgNode.setAttribute("name",componentName) 135 130 softpkgNode.setAttribute("id", u'DCE:' + unicode(uuidgen()) ) 136 131 137 132 # set the general resource description 138 133 # note: this is NOT the description of the implementation … … 146 141 propertyfilePathNode = softpkgNode.getElementsByTagName("propertyfile")[0].getElementsByTagName("localfile")[0] 147 142 propertyfilePathNode.setAttribute("name", xmlpath + componentName + '/' + componentName + u'.prf.xml') 148 143 149 144 # set the descriptor file path 150 145 descriptorPathNode = softpkgNode.getElementsByTagName("descriptor")[0].getElementsByTagName("localfile")[0] 151 146 descriptorPathNode.setAttribute("name", xmlpath + componentName + '/' + componentName + u'.scd.xml') 152 147 153 148 # set the implementation id 154 149 implementationNode = softpkgNode.getElementsByTagName("implementation")[0] … … 156 151 implementationNode.getElementsByTagName("code")[0].getElementsByTagName("localfile")[0].setAttribute( \ 157 152 "name", binpath + componentName) 158 153 159 154 # Now do final processing and write to file 160 155 compDir = waveformDir + comp.name + '/' 161 156 outputFileName_spd = comp.name + '.spd.xml' 162 157 #outputFileName_spd = comp.name + 'Resource' + '.spd.xml' 163 158 164 159 # Define <!DOCTYPE> here (overriding template if necessary) 165 160 #doc_spd.doctype.name = u'softpkg' 166 161 #doc_spd.doctype.systemId = u'../dtd/softpkg.dtd' 167 162 168 163 outfile = open(compDir + outputFileName_spd, 'w') 169 164 doc_spd.writexml( outfile, encoding='UTF-8' ) 170 165 outfile.close() 171 172 def gen_prf(comp, waveformDir ):173 componentName = unicode(comp.name) 174 doc_prf = xml.dom.minidom.parse( 'XML_gen/_prf.xml.tpl')175 166 167 def gen_prf(comp, waveformDir, wavedevPath): 168 componentName = unicode(comp.name) 169 doc_prf = xml.dom.minidom.parse(wavedevPath + 'XML_gen/_prf.xml.tpl') 170 176 171 propertiesNode = doc_prf.getElementsByTagName("properties")[0] 177 172 … … 210 205 descriptionNode.appendChild(descriptionText) 211 206 e.appendChild(descriptionNode) 212 207 213 208 # Add the property kind 214 209 kindNode = doc_prf.createElement("kind") … … 217 212 218 213 propertiesNode.appendChild(e) 219 214 220 215 # Create a simplesequence of string type that lists each Provides port in the component 221 216 # Used for connecting to components from outside the framework (ex. control gui) … … 256 251 257 252 propertiesNode.appendChild(e) 258 253 259 254 # Now do final processing and write to file 260 255 compDir = waveformDir + comp.name + '/' 261 256 outputFileName_prf = comp.name + '.prf.xml' 262 257 #outputFileName_prf = comp.name + 'Resource' + '.prf.xml' 263 258 264 259 # Define <!DOCTYPE> here (overriding template if necessary) 265 260 #doc_prf.doctype.name = u'properties' 266 261 #doc_prf.doctype.systemId = u'../dtd/properties.dtd' 267 262 268 263 outfile = open(compDir + outputFileName_prf, 'w') 269 264 doc_prf.writexml( outfile, encoding='UTF-8' ) -
ossiedev/branches/jsnyder/ComponentProject/WaveDev/wavedev/generate/genNode.py
r5915 r7435 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/branches/jsnyder/ComponentProject/WaveDev/wavedev/generate/templates/custom_ports/genStructure.py
r5933 r7435 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 wavedevPath[len(wavedevPath)-1] != '/': 36 wavedevPath = wavedevPath + '/' 37 self.wavedevPath = wavedevPath 35 38 self.active_wave = active_wave 36 39 … … 43 46 errorMsg(self,"Waveform already exists - exiting") 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 #ts = 'int ' + c.u_cname + '::svc(void)\n{\n'; output.write(ts) … … 1028 1032 else: 1029 1033 ts = " "*4 + 'return 0;\n' + '}\n'; output.write(ts) 1030 1034 1031 1035 def writeTimingMessageDef(self, output,c,type): 1032 1036 if type == 'port': … … 1050 1054 1051 1055 def writeOperation(self,output,i,prefix='',cppFlag=False,in_name='',using_ace=False,comp='',port=''): 1052 """ Writes the declaration or definition of an operation (pushPacket) to 1056 """ Writes the declaration or definition of an operation (pushPacket) to 1053 1057 the port_impl.h and port_impl.cpp files respectively """ 1054 1058 ocount = 0 1055 1059 for o in i.operations: 1056 1060 1057 1061 1058 1062 ocount += 1 … … 1067 1071 ts = prefix + " "*4 + o.returnType + ' ' + o.name + '(' 1068 1072 tscxx = prefix + " "*4 + o.cxxReturnType + ' ' + o.name + '(' 1069 1073 1070 1074 first = True 1071 1075 for p in o.params: … … 1073 1077 _USE_CONST_ = 'const ' 1074 1078 _USE__OUT_ = '' 1075 if p.direction == 'out': 1079 if p.direction == 'out': 1076 1080 if len(p.dataType) > 8 and p.dataType[-8:] != 'Sequence': 1077 1081 _USE_CONST_ = '' … … 1104 1108 # output.write(ts) 1105 1109 output.write(tscxx) 1106 1110 1107 1111 if cppFlag: 1108 1112 #ts = "{\n" + " "*4 + "unsigned int len = " + "hello" + ".length();\n"; output.write(ts) … … 1189 1193 else: 1190 1194 ts = "{\n\n}\n"; output.write(ts) 1191 1195 1192 1196 def writeFriendDecl(self,output,c): 1193 1197 friendList = [] … … 1199 1203 if p.p_cname not in friendList: 1200 1204 friendList.append(p.p_cname) 1201 1205 1202 1206 for x in friendList: 1203 1207 ts = " "*4 + "friend class " + x + ";\n" 1204 output.write(ts) 1205 1208 output.write(ts) 1209 1206 1210 1207 1211 def addGPL(self,outFile,name): 1208 inFile = open( 'generate/gpl_preamble','r')1212 inFile = open(self.wavedevPath + 'generate/gpl_preamble','r') 1209 1213 for line in inFile.readlines(): 1210 1214 l_out = line.replace("__COMP_NAME__",name) 1211 1215 outFile.write(l_out) 1212 1216 1213 1217 inFile.close() 1214 1215 1218 1219 1216 1220 def cleanUp(self): 1217 1221 # Move the AssemblyController to the waveform Dir … … 1220 1224 os.system('mv ' + self.path + c.name + ' ' + self.path + self.active_wave.name) 1221 1225 1222 1226