298 self.ParentWindow.Table.SetValue(row, col, values[0]) |
298 self.ParentWindow.Table.SetValue(row, col, values[0]) |
299 self.ParentWindow.Table.ResetView(self.ParentWindow.VariablesGrid) |
299 self.ParentWindow.Table.ResetView(self.ParentWindow.VariablesGrid) |
300 self.ParentWindow.SaveValues() |
300 self.ParentWindow.SaveValues() |
301 elif (element_type not in ["config", "resource", "function"] and values[1] == "Global" and |
301 elif (element_type not in ["config", "resource", "function"] and values[1] == "Global" and |
302 self.ParentWindow.Filter in ["All", "Interface", "External"] or |
302 self.ParentWindow.Filter in ["All", "Interface", "External"] or |
303 element_type in ["config", "resource", "program"] and values[1] == "location"): |
303 element_type != "function" and values[1] == "location"): |
304 if values[1] == "location": |
304 if values[1] == "location": |
305 var_name = values[3] |
305 var_name = values[3] |
306 else: |
306 else: |
307 var_name = values[0] |
307 var_name = values[0] |
308 tagname = self.ParentWindow.GetTagName() |
308 tagname = self.ParentWindow.GetTagName() |
309 if var_name.upper() in [name.upper() for name in self.ParentWindow.Controler.GetProjectPouNames(self.ParentWindow.Debug)]: |
309 if var_name.upper() in [name.upper() |
|
310 for name in self.ParentWindow.Controler.\ |
|
311 GetProjectPouNames(self.ParentWindow.Debug)]: |
310 message = _("\"%s\" pou already exists!")%var_name |
312 message = _("\"%s\" pou already exists!")%var_name |
311 elif not var_name.upper() in [name.upper() for name in self.ParentWindow.Controler.GetEditedElementVariables(tagname, self.ParentWindow.Debug)]: |
313 elif not var_name.upper() in [name.upper() |
|
314 for name in self.ParentWindow.Controler.\ |
|
315 GetEditedElementVariables(tagname, self.ParentWindow.Debug)]: |
312 var_infos = self.ParentWindow.DefaultValue.copy() |
316 var_infos = self.ParentWindow.DefaultValue.copy() |
313 var_infos["Name"] = var_name |
317 var_infos["Name"] = var_name |
314 var_infos["Type"] = values[2] |
318 var_infos["Type"] = values[2] |
315 if values[1] == "location": |
319 if values[1] == "location": |
316 if element_type == "program": |
320 location = values[0] |
317 var_infos["Class"] = "Local" |
321 if not location.startswith("%"): |
|
322 dialog = wx.SingleChoiceDialog(self.ParentWindow.ParentWindow.ParentWindow, |
|
323 _("Select a variable class:"), _("Variable class"), |
|
324 ["Input", "Output", "Memory"], |
|
325 wx.DEFAULT_DIALOG_STYLE|wx.OK|wx.CANCEL) |
|
326 if dialog.ShowModal() == wx.ID_OK: |
|
327 selected = dialog.GetSelection() |
|
328 else: |
|
329 selected = None |
|
330 dialog.Destroy() |
|
331 if selected is None: |
|
332 return |
|
333 if selected == 0: |
|
334 location = "%I" + location |
|
335 elif selected == 1: |
|
336 location = "%Q" + location |
|
337 else: |
|
338 location = "%M" + location |
|
339 if element_type == "functionBlock": |
|
340 configs = self.ParentWindow.Controler.GetProjectConfigNames( |
|
341 self.ParentWindow.Debug) |
|
342 if len(configs) == 0: |
|
343 return |
|
344 if not var_name.upper() in [name.upper() |
|
345 for name in self.ParentWindow.Controler.\ |
|
346 GetConfigurationVariableNames(configs[0])]: |
|
347 self.ParentWindow.Controler.AddConfigurationGlobalVar( |
|
348 configs[0], values[2], var_name, location, "") |
|
349 var_infos["Class"] = "External" |
318 else: |
350 else: |
319 var_infos["Class"] = "Global" |
351 if element_type == "program": |
320 var_infos["Location"] = values[0] |
352 var_infos["Class"] = "Local" |
|
353 else: |
|
354 var_infos["Class"] = "Global" |
|
355 var_infos["Location"] = location |
321 else: |
356 else: |
322 var_infos["Class"] = "External" |
357 var_infos["Class"] = "External" |
323 var_infos["Number"] = len(self.ParentWindow.Values) |
358 var_infos["Number"] = len(self.ParentWindow.Values) |
324 self.ParentWindow.Values.append(var_infos) |
359 self.ParentWindow.Values.append(var_infos) |
325 self.ParentWindow.SaveValues() |
360 self.ParentWindow.SaveValues() |