5 |
5 |
6 from nodelist import NodeList |
6 from nodelist import NodeList |
7 from nodemanager import NodeManager |
7 from nodemanager import NodeManager |
8 import config_utils, gen_cfile |
8 import config_utils, gen_cfile |
9 from networkedit import networkedit |
9 from networkedit import networkedit |
|
10 from objdictedit import objdictedit |
10 import canfestival_config |
11 import canfestival_config |
|
12 |
|
13 from gnosis.xml.pickle import * |
|
14 from gnosis.xml.pickle.util import setParanoia |
|
15 setParanoia(0) |
11 |
16 |
12 class _NetworkEdit(networkedit): |
17 class _NetworkEdit(networkedit): |
13 " Overload some of CanFestival Network Editor methods " |
18 " Overload some of CanFestival Network Editor methods " |
14 def OnCloseFrame(self, event): |
19 def OnCloseFrame(self, event): |
15 " Do reset _NodeListPlug.View when closed" |
20 " Do reset _NodeListPlug.View when closed" |
48 self._View.SetBusId(self.GetCurrentLocation()) |
53 self._View.SetBusId(self.GetCurrentLocation()) |
49 self._View._onclose = _onclose |
54 self._View._onclose = _onclose |
50 self._View._onsave = _onsave |
55 self._View._onsave = _onsave |
51 self._View.Show() |
56 self._View.Show() |
52 |
57 |
|
58 def _ShowMasterGenerated(self, logger): |
|
59 buildpath = self._getBuildPath() |
|
60 # Eventually create build dir |
|
61 if not os.path.exists(buildpath): |
|
62 logger.write_error("Error: No PLC built\n") |
|
63 return |
|
64 |
|
65 masterpath = os.path.join(buildpath, "MasterGenerated.od") |
|
66 if not os.path.exists(masterpath): |
|
67 logger.write_error("Error: No Master generated\n") |
|
68 return |
|
69 |
|
70 new_dialog = objdictedit(None, [masterpath]) |
|
71 new_dialog.Show() |
|
72 |
53 PluginMethods = [ |
73 PluginMethods = [ |
54 {"bitmap" : os.path.join("images", "NetworkEdit.png"), |
74 {"bitmap" : os.path.join("images", "NetworkEdit.png"), |
55 "name" : "Edit network", |
75 "name" : "Edit network", |
56 "tooltip" : "Edit CanOpen Network with NetworkEdit", |
76 "tooltip" : "Edit CanOpen Network with NetworkEdit", |
57 "method" : _OpenView} |
77 "method" : _OpenView}, |
|
78 {"name" : "Show Master", |
|
79 "tooltip" : "Show Master generated by config_utils", |
|
80 "method" : _ShowMasterGenerated} |
58 ] |
81 ] |
59 |
82 |
60 def OnPlugClose(self): |
83 def OnPlugClose(self): |
61 if self._View: |
84 if self._View: |
62 self._View.Close() |
85 self._View.Close() |
89 # Create a new copy of the model with DCF loaded with PDO mappings for desired location |
112 # Create a new copy of the model with DCF loaded with PDO mappings for desired location |
90 master = config_utils.GenerateConciseDCF(locations, current_location, self, self.CanFestivalNode.getSync_TPDOs(),"OD_%s"%prefix) |
113 master = config_utils.GenerateConciseDCF(locations, current_location, self, self.CanFestivalNode.getSync_TPDOs(),"OD_%s"%prefix) |
91 res = gen_cfile.GenerateFile(Gen_OD_path, master) |
114 res = gen_cfile.GenerateFile(Gen_OD_path, master) |
92 if res : |
115 if res : |
93 raise Exception, res |
116 raise Exception, res |
|
117 |
|
118 file = open(os.path.join(buildpath, "MasterGenerated.od"), "w") |
|
119 dump(master, file) |
|
120 file.close() |
94 |
121 |
95 return [(Gen_OD_path,canfestival_config.getCFLAGS(CanFestivalPath))],"",False |
122 return [(Gen_OD_path,canfestival_config.getCFLAGS(CanFestivalPath))],"",False |
96 |
123 |
97 class RootClass: |
124 class RootClass: |
98 XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?> |
125 XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?> |