Adding support for updating located variables when changing plugin IEC_Channel
authorlaurent
Tue, 01 Dec 2009 10:59:17 +0100
changeset 443 34c9788bd933
parent 442 f971de6d274f
child 444 8eb1186fc9cf
Adding support for updating located variables when changing plugin IEC_Channel
plugger.py
--- a/plugger.py	Mon Nov 30 10:13:36 2009 +0100
+++ b/plugger.py	Tue Dec 01 10:59:17 2009 +0100
@@ -174,7 +174,11 @@
         self.ChangesToSave = True
         # Filter IEC_Channel and Name, that have specific behavior
         if path == "BaseParams.IEC_Channel":
-            return self.FindNewIEC_Channel(value), True
+            old_leading = ".".join(map(str, self.GetCurrentLocation()))
+            new_value = self.FindNewIEC_Channel(value)
+            new_leading = ".".join(map(str, self.PlugParent.GetCurrentLocation() + (new_value,)))
+            self.GetPlugRoot().UpdateProjectVariableLocation(old_leading, new_leading)
+            return new_value, True
         elif path == "BaseParams.Name":
             res = self.FindNewName(value)
             self.PlugRequestSave()
@@ -988,6 +992,14 @@
             self.AppFrame.RefreshLibraryTree()
             self.AppFrame.RefreshEditor()
     
+    # Update a PLCOpenEditor Pou variable location
+    def UpdateProjectVariableLocation(self, old_leading, new_leading):
+        self.Project.updateElementAddress(old_leading, new_leading)
+        self.BufferProject()
+        if self.AppFrame is not None:
+            self.AppFrame._Refresh(TITLE, INSTANCESTREE, FILEMENU, EDITMENU)
+            self.AppFrame.RefreshEditor()
+    
     def GetVariableLocationTree(self):
         '''
         This function is meant to be overridden by plugins.