--- a/controls/VariablePanel.py Mon May 13 23:07:24 2013 +0200
+++ b/controls/VariablePanel.py Mon May 13 23:08:47 2013 +0200
@@ -167,11 +167,8 @@
elif col != 0 and self.GetValueByName(row, "Edit"):
grid.SetReadOnly(row, col, False)
- if self.Parent.PouIsUsed and var_class in ["Input", "Output", "InOut"]:
- grid.SetReadOnly(row, col, True)
- editor = wx.grid.GridCellTextEditor()
- renderer = wx.grid.GridCellStringRenderer()
+ editor = wx.grid.GridCellTextEditor() + renderer = wx.grid.GridCellStringRenderer() elif colname == "Initial Value":
if var_class not in ["External", "InOut"]:
if self.Parent.Controler.IsEnumeratedType(var_type):
@@ -189,13 +186,11 @@
grid.SetReadOnly(row, col, True)
- if len(self.Parent.ClassList) == 1 or self.Parent.PouIsUsed and var_class in ["Input", "Output", "InOut"]:
+ if len(self.Parent.ClassList) == 1: grid.SetReadOnly(row, col, True)
editor = wx.grid.GridCellChoiceEditor()
- if self.Parent.PouIsUsed:
- excluded.extend(["Input","Output","InOut"])
if self.Parent.IsFunctionBlockType(var_type):
excluded.extend(["Local","Temp"])
editor.SetParameters(",".join([_(choice) for choice in self.Parent.ClassList if choice not in excluded]))
@@ -490,50 +485,46 @@
self.VariablesGrid.SetEditable(not self.Debug)
def _AddVariable(new_row):
- if not self.PouIsUsed or self.Filter not in ["Interface", "Input", "Output", "InOut"]:
- row_content = self.Values[new_row - 1].copy()
- result = VARIABLE_NAME_SUFFIX_MODEL.search(row_content["Name"])
- name = row_content["Name"][:result.start(1)]
- suffix = result.group(1)
- start_idx = int(suffix)
+ row_content = self.Values[new_row - 1].copy() + result = VARIABLE_NAME_SUFFIX_MODEL.search(row_content["Name"]) + name = row_content["Name"][:result.start(1)] + suffix = result.group(1) + start_idx = int(suffix) - name = row_content["Name"]
- row_content["Name"] = self.Controler.GenerateNewName(
- self.TagName, None, name + "%d", start_idx)
+ name = row_content["Name"] + row_content["Name"] = self.Controler.GenerateNewName( + self.TagName, None, name + "%d", start_idx) + row_content = self.DefaultValue.copy() + if self.Filter in self.DefaultTypes: + row_content["Class"] = self.DefaultTypes[self.Filter] - row_content = self.DefaultValue.copy()
- if self.Filter in self.DefaultTypes:
- row_content["Class"] = self.DefaultTypes[self.Filter]
- row_content["Class"] = self.Filter
- if self.Filter == "All" and len(self.Values) > 0:
- self.Values.insert(new_row, row_content)
- self.Values.append(row_content)
- new_row = self.Table.GetNumberRows()
- return self.VariablesGrid.GetGridCursorRow()
+ row_content["Class"] = self.Filter + if self.Filter == "All" and len(self.Values) > 0: + self.Values.insert(new_row, row_content) + self.Values.append(row_content) + new_row = self.Table.GetNumberRows() setattr(self.VariablesGrid, "_AddRow", _AddVariable)
def _DeleteVariable(row):
- if (self.Table.GetValueByName(row, "Edit") and
- (not self.PouIsUsed or self.Table.GetValueByName(row, "Class") not in ["Input", "Output", "InOut"])):
+ if self.Table.GetValueByName(row, "Edit"): self.Values.remove(self.Table.GetRow(row))
setattr(self.VariablesGrid, "_DeleteRow", _DeleteVariable)
def _MoveVariable(row, move):
- if (self.Filter == "All" and
- (not self.PouIsUsed or self.Table.GetValueByName(row, "Class") not in ["Input", "Output", "InOut"])):
+ if self.Filter == "All": new_row = max(0, min(row + move, len(self.Values) - 1))
self.Values.insert(new_row, self.Values.pop(row))
@@ -552,12 +543,10 @@
row = self.VariablesGrid.GetGridCursorRow()
row_edit = self.Table.GetValueByName(row, "Edit")
- row_class = self.Table.GetValueByName(row, "Class")
- self.AddButton.Enable(not self.Debug and (not self.PouIsUsed or self.Filter not in ["Interface", "Input", "Output", "InOut"]))
- self.DeleteButton.Enable(not self.Debug and (table_length > 0 and row_edit and row_class not in ["Input", "Output", "InOut"]))
- self.UpButton.Enable(not self.Debug and (table_length > 0 and row > 0 and self.Filter == "All" and row_class not in ["Input", "Output", "InOut"]))
- self.DownButton.Enable(not self.Debug and (table_length > 0 and row < table_length - 1 and self.Filter == "All" and row_class not in ["Input", "Output", "InOut"]))
+ self.AddButton.Enable(not self.Debug) + self.DeleteButton.Enable(not self.Debug and (table_length > 0 and row_edit)) + self.UpButton.Enable(not self.Debug and (table_length > 0 and row > 0 and self.Filter == "All")) + self.DownButton.Enable(not self.Debug and (table_length > 0 and row < table_length - 1 and self.Filter == "All")) setattr(self.VariablesGrid, "RefreshButtons", _RefreshButtons)
self.VariablesGrid.SetRowLabelSize(0)
@@ -592,10 +581,8 @@
words = self.TagName.split("::")
if self.ElementType == "config":
self.Values = self.Controler.GetConfigurationGlobalVars(words[1], self.Debug)
elif self.ElementType == "resource":
self.Values = self.Controler.GetConfigurationResourceGlobalVars(words[1], words[2], self.Debug)
if self.ElementType == "function":
@@ -604,7 +591,6 @@
self.ReturnType.Append(data_type)
returnType = self.Controler.GetEditedElementInterfaceReturnType(self.TagName)
description = self.Controler.GetPouDescription(words[1])
- self.PouIsUsed = self.Controler.PouIsUsed(words[1])
self.Values = self.Controler.GetEditedElementInterfaceVars(self.TagName, self.Debug)
if returnType is not None: