merge svghmi
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Thu, 10 Jun 2021 14:05:44 +0200
branchsvghmi
changeset 3255 07f10dc95d2f
parent 3252 352b2111ca66 (current diff)
parent 3254 b1bc6099d4e5 (diff)
child 3259 76da573569a6
merge
svghmi/ui.py
--- a/PLCControler.py	Thu Jun 10 13:47:58 2021 +0200
+++ b/PLCControler.py	Thu Jun 10 14:05:44 2021 +0200
@@ -2049,14 +2049,15 @@
                         self.GetVarTypeObject(var_type),
                         name, **args)
 
-    def AddEditedElementPouExternalVar(self, tagname, var_type, name):
+    def AddEditedElementPouExternalVar(self, tagname, var_type, name, **args):
         if self.Project is not None:
             words = tagname.split("::")
             if words[0] in ['P', 'T', 'A']:
                 pou = self.Project.getpou(words[1])
                 if pou is not None:
                     pou.addpouExternalVar(
-                        self.GetVarTypeObject(var_type), name)
+                        self.GetVarTypeObject(var_type),
+                        name, **args)
 
     def ChangeEditedElementPouVar(self, tagname, old_type, old_name, new_type, new_name):
         if self.Project is not None:
--- a/editors/CodeFileEditor.py	Thu Jun 10 13:47:58 2021 +0200
+++ b/editors/CodeFileEditor.py	Thu Jun 10 14:05:44 2021 +0200
@@ -857,8 +857,9 @@
             row = event.GetRow()
             data_type = self.Table.GetValueByName(row, "Type")
             var_name = self.Table.GetValueByName(row, "Name")
+            desc = self.Table.GetValueByName(row, "Description")
             data = wx.TextDataObject(str((var_name, "Global", data_type,
-                                          self.Controler.GetCurrentLocation())))
+                                          self.Controler.GetCurrentLocation(), desc)))
             dragSource = wx.DropSource(self.VariablesGrid)
             dragSource.SetData(data)
             dragSource.DoDragDrop()
--- a/editors/Viewer.py	Thu Jun 10 13:47:58 2021 +0200
+++ b/editors/Viewer.py	Thu Jun 10 14:05:44 2021 +0200
@@ -389,7 +389,8 @@
                 elif var_name.upper() in [name.upper() for name in self.ParentWindow.Controler.GetProjectPouNames(self.ParentWindow.Debug)]:
                     message = _("\"%s\" pou already exists!") % var_name
                 elif not var_name.upper() in [name.upper() for name in self.ParentWindow.Controler.GetEditedElementVariables(tagname, self.ParentWindow.Debug)]:
-                    self.ParentWindow.Controler.AddEditedElementPouExternalVar(tagname, values[2], var_name)
+                    print(values) 
+                    self.ParentWindow.Controler.AddEditedElementPouExternalVar(tagname, values[2], var_name, description=values[4])
                     self.ParentWindow.RefreshVariablePanel()
                     self.ParentWindow.ParentWindow.RefreshPouInstanceVariablesPanel()
                     self.ParentWindow.AddVariableBlock(x, y, scaling, INPUT, var_name, values[2])
--- a/plcopen/plcopen.py	Thu Jun 10 13:47:58 2021 +0200
+++ b/plcopen/plcopen.py	Thu Jun 10 14:05:44 2021 +0200
@@ -1393,8 +1393,8 @@
         self.interface.setcontent(vars)
     setattr(cls, "setvars", setvars)
 
-    def addpouExternalVar(self, var_type, name):
-        self.addpouVar(var_type, name, "externalVars")
+    def addpouExternalVar(self, var_type, name, **args):
+        self.addpouVar(var_type, name, "externalVars", **args)
     setattr(cls, "addpouExternalVar", addpouExternalVar)
 
     def addpouVar(self, var_type, name, var_class="localVars", location="", description="", initval=""):
--- a/svghmi/ui.py	Thu Jun 10 13:47:58 2021 +0200
+++ b/svghmi/ui.py	Thu Jun 10 14:05:44 2021 +0200
@@ -163,7 +163,7 @@
         self.root = self.AddRoot(root_display_name)
         self.SetPyData(self.root, None)
 
-        if lib_dir is not None:
+        if lib_dir is not None and os.path.exists(lib_dir):
             self._recurseTree(lib_dir, self.root, [])
             self.Expand(self.root)