1 import wx |
1 import wx |
2 import os |
2 import os |
|
3 from xml.dom import minidom |
|
4 import cPickle |
|
5 |
|
6 from xmlclass import * |
|
7 |
3 from plugger import PlugTemplate |
8 from plugger import PlugTemplate |
4 from CFileEditor import CFileEditor |
9 from CFileEditor import CFileEditor |
5 |
10 from PLCControler import PLCControler, LOCATION_PLUGIN, LOCATION_MODULE, LOCATION_GROUP, LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY |
6 from xml.dom import minidom |
|
7 from xmlclass import * |
|
8 import cPickle |
|
9 |
11 |
10 CFileClasses = GenerateClassesFromXSD(os.path.join(os.path.dirname(__file__), "cext_xsd.xsd")) |
12 CFileClasses = GenerateClassesFromXSD(os.path.join(os.path.dirname(__file__), "cext_xsd.xsd")) |
11 |
13 |
12 #------------------------------------------------------------------------------- |
14 #------------------------------------------------------------------------------- |
13 # Undo Buffer for CFile |
15 # Undo Buffer for CFile |
156 datas = [] |
158 datas = [] |
157 for var in self.CFile.variables.getvariable(): |
159 for var in self.CFile.variables.getvariable(): |
158 datas.append({"Name" : var.getname(), "Type" : var.gettype(), "Class" : var.getclass()}) |
160 datas.append({"Name" : var.getname(), "Type" : var.gettype(), "Class" : var.getclass()}) |
159 return datas |
161 return datas |
160 |
162 |
|
163 def GetVariableLocationTree(self): |
|
164 '''See PlugTemplate.GetVariableLocationTree() for a description.''' |
|
165 |
|
166 current_location = ".".join(map(str, self.GetCurrentLocation())) |
|
167 |
|
168 vars = [] |
|
169 input = output = 0 |
|
170 for var in self.CFile.variables.getvariable(): |
|
171 var_size = self.GetSizeOfType(var.gettype()) |
|
172 if var.getclass() == "input": |
|
173 var_class = LOCATION_VAR_INPUT |
|
174 var_location = "%%I%s%s.%d"%(var_size, current_location, input) |
|
175 input += 1 |
|
176 else: |
|
177 var_class = LOCATION_VAR_OUTPUT |
|
178 var_location = "%%Q%s%s.%d"%(var_size, current_location, output) |
|
179 output += 1 |
|
180 vars.append({"name": var.getname(), |
|
181 "type": var_class, |
|
182 "size": var_size, |
|
183 "IEC_type": var.gettype(), |
|
184 "location": var_location, |
|
185 "description": "", |
|
186 "children": []}) |
|
187 |
|
188 return vars |
|
189 |
161 def SetPartText(self, name, text): |
190 def SetPartText(self, name, text): |
162 if name == "Includes": |
191 if name == "Includes": |
163 self.CFile.includes.settext(text) |
192 self.CFile.includes.settext(text) |
164 elif name == "Globals": |
193 elif name == "Globals": |
165 self.CFile.globals.settext(text) |
194 self.CFile.globals.settext(text) |
235 }, ...] |
264 }, ...] |
236 @return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND |
265 @return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND |
237 """ |
266 """ |
238 current_location = self.GetCurrentLocation() |
267 current_location = self.GetCurrentLocation() |
239 # define a unique name for the generated C file |
268 # define a unique name for the generated C file |
240 location_str = "_".join(map(lambda x:str(x), current_location)) |
269 location_str = "_".join(map(str, current_location)) |
241 |
270 |
242 text = "/* Code generated by Beremiz c_ext plugin */\n\n" |
271 text = "/* Code generated by Beremiz c_ext plugin */\n\n" |
243 |
272 |
244 # Adding includes |
273 # Adding includes |
245 text += "/* User includes */\n" |
274 text += "/* User includes */\n" |