27 from types import * |
27 from types import * |
28 |
28 |
29 import re |
29 import re |
30 |
30 |
31 from graphics.GraphicCommons import ERROR_HIGHLIGHT, SEARCH_RESULT_HIGHLIGHT, REFRESH_HIGHLIGHT_PERIOD |
31 from graphics.GraphicCommons import ERROR_HIGHLIGHT, SEARCH_RESULT_HIGHLIGHT, REFRESH_HIGHLIGHT_PERIOD |
32 from plcopen.structures import ST_BLOCK_START_KEYWORDS, ST_BLOCK_END_KEYWORDS, IEC_BLOCK_START_KEYWORDS, IEC_BLOCK_END_KEYWORDS |
32 from plcopen.structures import ST_BLOCK_START_KEYWORDS, ST_BLOCK_END_KEYWORDS, IEC_BLOCK_START_KEYWORDS, IEC_BLOCK_END_KEYWORDS, LOCATIONDATATYPES |
33 from controls import EditorPanel |
33 from controls import EditorPanel |
34 |
34 |
35 #------------------------------------------------------------------------------- |
35 #------------------------------------------------------------------------------- |
36 # Textual programs Viewer class |
36 # Textual programs Viewer class |
37 #------------------------------------------------------------------------------- |
37 #------------------------------------------------------------------------------- |
322 if var_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames(self.Debug)]: |
322 if var_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames(self.Debug)]: |
323 message = _("\"%s\" pou already exists!")%var_name |
323 message = _("\"%s\" pou already exists!")%var_name |
324 elif var_name.upper() in [name.upper() for name in self.Controler.GetEditedElementVariables(self.TagName, self.Debug)]: |
324 elif var_name.upper() in [name.upper() for name in self.Controler.GetEditedElementVariables(self.TagName, self.Debug)]: |
325 message = _("\"%s\" element for this pou already exists!")%var_name |
325 message = _("\"%s\" element for this pou already exists!")%var_name |
326 else: |
326 else: |
|
327 location = values[0] |
|
328 if not location.startswith("%"): |
|
329 dialog = wx.SingleChoiceDialog(self.ParentWindow, |
|
330 _("Select a variable class:"), _("Variable class"), |
|
331 ["Input", "Output", "Memory"], |
|
332 wx.DEFAULT_DIALOG_STYLE|wx.OK|wx.CANCEL) |
|
333 if dialog.ShowModal() == wx.ID_OK: |
|
334 selected = dialog.GetSelection() |
|
335 else: |
|
336 selected = None |
|
337 dialog.Destroy() |
|
338 if selected is None: |
|
339 event.SetDragText("") |
|
340 return |
|
341 if selected == 0: |
|
342 location = "%I" + location |
|
343 elif selected == 1: |
|
344 location = "%Q" + location |
|
345 else: |
|
346 location = "%M" + location |
327 if values[2] is not None: |
347 if values[2] is not None: |
328 var_type = values[2] |
348 var_type = values[2] |
329 else: |
349 else: |
330 var_type = LOCATIONDATATYPES.get(values[0][2], ["BOOL"])[0] |
350 var_type = LOCATIONDATATYPES.get(location[2], ["BOOL"])[0] |
331 self.Controler.AddEditedElementPouVar(self.TagName, var_type, var_name, values[0], values[4]) |
351 self.Controler.AddEditedElementPouVar(self.TagName, var_type, var_name, location, values[4]) |
332 self.RefreshVariablePanel() |
352 self.RefreshVariablePanel() |
333 self.RefreshVariableTree() |
353 self.RefreshVariableTree() |
334 event.SetDragText(var_name) |
354 event.SetDragText(var_name) |
335 else: |
355 else: |
336 event.SetDragText("") |
356 event.SetDragText("") |