258 self.ParentWindow.RefreshScrollBars() |
258 self.ParentWindow.RefreshScrollBars() |
259 self.ParentWindow.RefreshVisibleElements() |
259 self.ParentWindow.RefreshVisibleElements() |
260 self.ParentWindow.RefreshVariablePanel() |
260 self.ParentWindow.RefreshVariablePanel() |
261 self.ParentWindow.Refresh(False) |
261 self.ParentWindow.Refresh(False) |
262 elif values[1] == "location": |
262 elif values[1] == "location": |
263 if len(values) > 2 and pou_type == "program": |
263 if pou_type == "program": |
|
264 location = values[0] |
|
265 if not location.startswith("%"): |
|
266 dialog = wx.SingleChoiceDialog(self.ParentWindow, _("Select a variable class:"), _("Variable class"), ["Input", "Output", "Memory"], wx.OK|wx.CANCEL) |
|
267 if dialog.ShowModal() == wx.ID_OK: |
|
268 selected = dialog.GetSelection() |
|
269 else: |
|
270 selected = None |
|
271 dialog.Destroy() |
|
272 if selected is None: |
|
273 return |
|
274 if selected == 0: |
|
275 location = "%I" + location |
|
276 elif selected == 1: |
|
277 location = "%Q" + location |
|
278 else: |
|
279 location = "%M" + location |
264 var_name = values[3] |
280 var_name = values[3] |
265 if var_name.upper() in [name.upper() for name in self.ParentWindow.Controler.GetProjectPouNames(self.ParentWindow.Debug)]: |
281 if var_name.upper() in [name.upper() for name in self.ParentWindow.Controler.GetProjectPouNames(self.ParentWindow.Debug)]: |
266 message = _("\"%s\" pou already exists!")%var_name |
282 message = _("\"%s\" pou already exists!")%var_name |
267 else: |
283 else: |
268 if values[0][1] == "Q": |
284 if location[1] == "Q": |
269 var_class = OUTPUT |
285 var_class = OUTPUT |
270 else: |
286 else: |
271 var_class = INPUT |
287 var_class = INPUT |
272 if values[2] is not None: |
288 if values[2] is not None: |
273 var_type = values[2] |
289 var_type = values[2] |
274 else: |
290 else: |
275 var_type = LOCATIONDATATYPES.get(values[0][2], ["BOOL"])[0] |
291 var_type = LOCATIONDATATYPES.get(location[2], ["BOOL"])[0] |
276 if not var_name.upper() in [name.upper() for name in self.ParentWindow.Controler.GetEditedElementVariables(tagname, self.ParentWindow.Debug)]: |
292 if not var_name.upper() in [name.upper() for name in self.ParentWindow.Controler.GetEditedElementVariables(tagname, self.ParentWindow.Debug)]: |
277 self.ParentWindow.Controler.AddEditedElementPouVar(tagname, var_type, var_name, values[0], values[4]) |
293 self.ParentWindow.Controler.AddEditedElementPouVar(tagname, var_type, var_name, location, values[4]) |
278 self.ParentWindow.RefreshVariablePanel() |
294 self.ParentWindow.RefreshVariablePanel() |
279 self.ParentWindow.AddVariableBlock(x, y, scaling, var_class, var_name, var_type) |
295 self.ParentWindow.AddVariableBlock(x, y, scaling, var_class, var_name, var_type) |
280 elif values[1] == "Global": |
296 elif values[1] == "Global": |
281 var_name = values[0] |
297 var_name = values[0] |
282 if var_name.upper() in [name.upper() for name in self.ParentWindow.Controler.GetProjectPouNames(self.ParentWindow.Debug)]: |
298 if var_name.upper() in [name.upper() for name in self.ParentWindow.Controler.GetProjectPouNames(self.ParentWindow.Debug)]: |