--- a/LPCBeremiz.py Tue Dec 01 10:59:17 2009 +0100
+++ b/LPCBeremiz.py Tue Dec 01 11:00:02 2009 +0100
@@ -381,6 +381,19 @@
def SetProjectName(self, name):
return self.Project.setname(name)
+ # Update a PLCOpenEditor Pou variable name + def UpdateProjectVariableName(self, old_name, new_name): + self.Project.updateElementName(old_name, new_name) + def RemoveProjectVariableByAddress(self, address): + self.Project.removeVariableByAddress(address) + def RemoveProjectVariableByFilter(self, leading): + self.Project.removeVariableByFilter(leading) def LoadProject(self, ProjectPath, BuildPath=None):
@@ -737,6 +750,8 @@
+ wx.CallAfter(frame._Refresh, TITLE, INSTANCESTREE, FILEMENU, EDITMENU) + wx.CallAfter(frame.RefreshEditor) wx.CallAfter(frame.RefreshAll)
@@ -785,6 +800,7 @@
for child in self.PluginRoot.IterChilds():
if child != bus and child.BaseParams.getIEC_Channel() == new_iec_channel:
return "Error: A bus with IEC_channel %d already exists" % new_iec_channel
+ self.PluginRoot.UpdateProjectVariableLocation(str(old_iec_channel), str(new_iec_channel)) bus.BaseParams.setIEC_Channel(new_iec_channel)
@@ -792,6 +808,7 @@
bus = self.PluginRoot.GetChildByIECLocation((iec_channel,))
return "Error: No bus found"
+ self.PluginRoot.RemoveProjectVariableByFilter(str(iec_channel)) self.PluginRoot.PluggedChilds["LPCBus"].remove(bus)
@@ -836,6 +853,7 @@
for child in _GetModuleChildren(parent):
if child["IEC_Channel"] == new_iec_channel:
return "Error: A module with IEC_channel %d already exists" % new_iec_channel
+ self.PluginRoot.UpdateProjectVariableLocation(".".join(map(str, old_iec_location)), ".".join(map(str, old_iec_location[:1] + (new_iec_channel,)))) module["IEC_Channel"] = new_iec_channel
@@ -846,6 +864,7 @@
child = _GetModuleBySomething(module, "IEC_Channel", (iec_channel,))
return "Error: No module found"
+ self.PluginRoot.RemoveProjectVariableByFilter(".".join(map(str, parent + (iec_channel,)))) _RemoveModuleChild(module, child)
@@ -893,7 +912,9 @@
return "Error: A variable named %s already exists" % new_name
return "Error: No variable found"
- variable["name"] = new_name
+ if variable["name"] != new_name: + self.PluginRoot.UpdateProjectVariableName(variable["name"], new_name) + variable["name"] = new_name variable["type"] = LOCATION_TYPES[new_direction]
variable["IEC_type"] = new_type
variable["declare"] = new_dcode
@@ -910,6 +931,9 @@
child = _GetModuleVariable(module, location)
return "Error: No variable found"
+ size = LOCATION_SIZES[self.PluginRoot.GetBaseType(child["IEC_type"])] + address = "%" + LOCATION_DIRS[child["type"]] + size + ".".join(map(str, parent + location)) + self.PluginRoot.RemoveProjectVariableByAddress(address) _RemoveModuleChild(module, child)
@@ -978,8 +1002,8 @@
"ChangeModuleIECChannel": ([location, int], 0),
"RemoveModule": ([location, int], 0),
"StartGroup": ([location, str, str], 1),
- "AddVariable": ([location, location, str, str, str, str, str, str], 1),
- "ChangeVariableParams": ([location, location, str, str, str, str, str, str, str, str], 1),
+ "AddVariable": ([location, location, str, str, str, str, str, str, str], 1), + "ChangeVariableParams": ([location, location, str, str, str, str, str, str, str], 1), "RemoveVariable": ([location, location], 0)}.iteritems():
setattr(LPCBeremiz_Cmd, "do_%s" % function, GetCmdFunction(function, arg_types, opt))