Fixed bugs when editing resource variables and tasks
authorLaurent Bessard
Fri, 11 Oct 2013 12:10:40 +0200
changeset 1361 7158aa054226
parent 1360 ebfe9c22af2a
child 1362 077bcba2d485
Fixed bugs when editing resource variables and tasks
PLCControler.py
controls/VariablePanel.py
plcopen/variables_infos.xslt
plcopen/variables_infos.ysl2
--- a/PLCControler.py	Fri Oct 11 10:07:56 2013 +0200
+++ b/PLCControler.py	Fri Oct 11 12:10:40 2013 +0200
@@ -3050,11 +3050,11 @@
         varlist = []
         words = tagname.split("::")
         for var in self.GetConfigurationGlobalVars(words[1], debug):
-            if var["Type"] == "BOOL":
-                varlist.append(var["Name"])
+            if var.Type == "BOOL":
+                varlist.append(var.Name)
         for var in self.GetConfigurationResourceGlobalVars(words[1], words[2], debug):
-            if var["Type"] == "BOOL":
-                varlist.append(var["Name"])
+            if var.Type == "BOOL":
+                varlist.append(var.Name)
         return varlist
 
     def SetEditedResourceInfos(self, tagname, tasks, instances):
--- a/controls/VariablePanel.py	Fri Oct 11 10:07:56 2013 +0200
+++ b/controls/VariablePanel.py	Fri Oct 11 12:10:40 2013 +0200
@@ -573,6 +573,8 @@
             if self.Table.GetValueByName(row, "Edit"):
                 self.Values.remove(self.Table.GetRow(row))
                 self.SaveValues()
+                if self.ElementType == "resource":
+                    self.ParentWindow.RefreshView(variablepanel = False)
                 self.RefreshValues()
         setattr(self.VariablesGrid, "_DeleteRow", _DeleteVariable)
             
--- a/plcopen/variables_infos.xslt	Fri Oct 11 10:07:56 2013 +0200
+++ b/plcopen/variables_infos.xslt	Fri Oct 11 12:10:40 2013 +0200
@@ -28,10 +28,28 @@
       </xsl:when>
     </xsl:choose>
   </xsl:variable>
+  <xsl:template match="ppx:configuration">
+    <xsl:param name="_indent" select="0"/>
+    <xsl:apply-templates select="ppx:globalVars">
+      <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/>
+    </xsl:apply-templates>
+  </xsl:template>
+  <xsl:template match="ppx:resource">
+    <xsl:param name="_indent" select="0"/>
+    <xsl:apply-templates select="ppx:globalVars">
+      <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/>
+    </xsl:apply-templates>
+  </xsl:template>
+  <xsl:template match="ppx:pou">
+    <xsl:param name="_indent" select="0"/>
+    <xsl:apply-templates select="ppx:interface/*">
+      <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/>
+    </xsl:apply-templates>
+  </xsl:template>
   <xsl:template match="ppx:returnType">
     <xsl:param name="_indent" select="0"/>
     <xsl:value-of select="ns:AddTree()"/>
-    <xsl:apply-templates>
+    <xsl:apply-templates mode="var_type" select=".">
       <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/>
     </xsl:apply-templates>
   </xsl:template>
@@ -70,7 +88,7 @@
         </xsl:choose>
       </xsl:variable>
       <xsl:value-of select="ns:AddTree()"/>
-      <xsl:apply-templates select="ppx:type">
+      <xsl:apply-templates mode="var_type" select="ppx:type">
         <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/>
       </xsl:apply-templates>
       <xsl:value-of select="ns:AddVariable(@name, $var_class, $var_option, @address, $initial_value, $edit, ppx:documentation/xhtml:p/text())"/>
@@ -132,73 +150,73 @@
       </xsl:with-param>
     </xsl:call-template>
   </xsl:template>
-  <xsl:template match="ppx:pou">
-    <xsl:param name="_indent" select="0"/>
-    <xsl:apply-templates select="ppx:interface/*[self::ppx:inputVars or self::ppx:inOutVars or self::ppx:outputVars]/ppx:variable">
-      <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/>
-    </xsl:apply-templates>
-  </xsl:template>
-  <xsl:template match="ppx:variable">
+  <xsl:template mode="var_type" match="ppx:pou">
+    <xsl:param name="_indent" select="0"/>
+    <xsl:apply-templates mode="var_type" select="ppx:interface/*[self::ppx:inputVars or self::ppx:inOutVars or self::ppx:outputVars]/ppx:variable">
+      <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/>
+    </xsl:apply-templates>
+  </xsl:template>
+  <xsl:template mode="var_type" match="ppx:variable">
     <xsl:param name="_indent" select="0"/>
     <xsl:variable name="name">
       <xsl:value-of select="@name"/>
     </xsl:variable>
     <xsl:value-of select="ns:AddTree($name)"/>
-    <xsl:apply-templates select="ppx:type">
+    <xsl:apply-templates mode="var_type" select="ppx:type">
       <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/>
     </xsl:apply-templates>
     <xsl:value-of select="ns:AddVarToTree($name)"/>
   </xsl:template>
-  <xsl:template match="ppx:dataType">
-    <xsl:param name="_indent" select="0"/>
-    <xsl:apply-templates select="ppx:baseType">
-      <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/>
-    </xsl:apply-templates>
-  </xsl:template>
-  <xsl:template match="*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:struct">
-    <xsl:param name="_indent" select="0"/>
-    <xsl:apply-templates select="ppx:variable">
-      <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/>
-    </xsl:apply-templates>
-  </xsl:template>
-  <xsl:template match="*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:derived">
+  <xsl:template mode="var_type" match="ppx:dataType">
+    <xsl:param name="_indent" select="0"/>
+    <xsl:apply-templates mode="var_type" select="ppx:baseType">
+      <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/>
+    </xsl:apply-templates>
+  </xsl:template>
+  <xsl:template mode="var_type" match="*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:struct">
+    <xsl:param name="_indent" select="0"/>
+    <xsl:apply-templates mode="var_type" select="ppx:variable">
+      <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/>
+    </xsl:apply-templates>
+  </xsl:template>
+  <xsl:template mode="var_type" match="*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:derived">
     <xsl:param name="_indent" select="0"/>
     <xsl:variable name="type_name">
       <xsl:value-of select="@name"/>
     </xsl:variable>
     <xsl:choose>
       <xsl:when test="$tree='True'">
-        <xsl:apply-templates select="exsl:node-set($project)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] |&#10;                         exsl:node-set($project)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name] |&#10;                         exsl:node-set($stdlib)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] |&#10;                         exsl:node-set($stdlib)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name] |&#10;                         exsl:node-set($extensions)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] |&#10;                         exsl:node-set($extensions)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name]">
+        <xsl:apply-templates mode="var_type" select="exsl:node-set($project)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] |&#10;                         exsl:node-set($project)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name] |&#10;                         exsl:node-set($stdlib)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] |&#10;                         exsl:node-set($stdlib)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name] |&#10;                         exsl:node-set($extensions)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] |&#10;                         exsl:node-set($extensions)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name]">
           <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/>
         </xsl:apply-templates>
       </xsl:when>
     </xsl:choose>
     <xsl:value-of select="ns:SetType($type_name)"/>
   </xsl:template>
-  <xsl:template match="*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:array">
-    <xsl:param name="_indent" select="0"/>
-    <xsl:apply-templates select="ppx:baseType">
+  <xsl:template mode="var_type" match="*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:array">
+    <xsl:param name="_indent" select="0"/>
+    <xsl:apply-templates mode="var_type" select="ppx:baseType">
       <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/>
     </xsl:apply-templates>
     <xsl:for-each select="ppx:dimension">
       <xsl:value-of select="ns:AddDimension(@lower, @upper)"/>
     </xsl:for-each>
   </xsl:template>
-  <xsl:template match="*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:string">
+  <xsl:template mode="var_type" match="*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:string">
     <xsl:param name="_indent" select="0"/>
     <xsl:variable name="name">
       <xsl:text>STRING</xsl:text>
     </xsl:variable>
     <xsl:value-of select="ns:SetType($name)"/>
   </xsl:template>
-  <xsl:template match="*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:wstring">
+  <xsl:template mode="var_type" match="*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:wstring">
     <xsl:param name="_indent" select="0"/>
     <xsl:variable name="name">
       <xsl:text>WSTRING</xsl:text>
     </xsl:variable>
     <xsl:value-of select="ns:SetType($name)"/>
   </xsl:template>
-  <xsl:template match="*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/*">
+  <xsl:template mode="var_type" match="*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/*">
     <xsl:param name="_indent" select="0"/>
     <xsl:variable name="name">
       <xsl:value-of select="local-name()"/>
--- a/plcopen/variables_infos.ysl2	Fri Oct 11 10:07:56 2013 +0200
+++ b/plcopen/variables_infos.ysl2	Fri Oct 11 12:10:40 2013 +0200
@@ -32,9 +32,21 @@
         }
     }
     
+    template "ppx:configuration" {
+        apply "ppx:globalVars";
+    }
+    
+    template "ppx:resource" {
+        apply "ppx:globalVars";
+    }
+    
+    template "ppx:pou" {
+        apply "ppx:interface/*";
+    }
+    
     template "ppx:returnType" {
         value "ns:AddTree()";
-        apply;
+        apply ".", mode="var_type";
     }
     
     function "variables_infos" {
@@ -59,7 +71,7 @@
                 }
             }
             value "ns:AddTree()";
-            apply "ppx:type";
+            apply "ppx:type", mode="var_type";
             value "ns:AddVariable(@name, $var_class, $var_option, @address, $initial_value, $edit, ppx:documentation/xhtml:p/text())";
         }
     }
@@ -106,26 +118,26 @@
         }
     }
     
-    template "ppx:pou" {
-        apply "ppx:interface/*[self::ppx:inputVars or self::ppx:inOutVars or self::ppx:outputVars]/ppx:variable";
-    }
-    
-    template "ppx:variable" {
+    template "ppx:pou", mode="var_type" {
+        apply "ppx:interface/*[self::ppx:inputVars or self::ppx:inOutVars or self::ppx:outputVars]/ppx:variable", mode="var_type";
+    }
+    
+    template "ppx:variable", mode="var_type" {
         variable "name" > «@name»
         value "ns:AddTree($name)";
-        apply "ppx:type";
+        apply "ppx:type", mode="var_type";
         value "ns:AddVarToTree($name)";
     }
     
-    template "ppx:dataType" {
-        apply "ppx:baseType";
-    }
-    
-    template "*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:struct" {
-        apply "ppx:variable";
-    }
-    
-    template "*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:derived" {
+    template "ppx:dataType", mode="var_type" {
+        apply "ppx:baseType", mode="var_type";
+    }
+    
+    template "*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:struct", mode="var_type" {
+        apply "ppx:variable", mode="var_type";
+    }
+    
+    template "*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:derived", mode="var_type" {
         variable "type_name" > «@name»
         choose {
             when "$tree='True'" {
@@ -134,30 +146,30 @@
                          exsl:node-set($stdlib)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] |
                          exsl:node-set($stdlib)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name] |
                          exsl:node-set($extensions)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] |
-                         exsl:node-set($extensions)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name]""";
+                         exsl:node-set($extensions)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name]""", mode="var_type";
             }
         }
         value "ns:SetType($type_name)";
     }
      
-    template "*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:array" {
-        apply "ppx:baseType";
+    template "*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:array", mode="var_type" {
+        apply "ppx:baseType", mode="var_type";
         foreach "ppx:dimension" {
             value "ns:AddDimension(@lower, @upper)";
         }
     }
     
-    template "*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:string" {
+    template "*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:string", mode="var_type" {
         variable "name" > STRING
         value "ns:SetType($name)";
     }
     
-    template "*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:wstring" {
+    template "*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:wstring", mode="var_type" {
         variable "name" > WSTRING
         value "ns:SetType($name)";
     }
     
-    template "*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/*" {
+    template "*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/*", mode="var_type" {
         variable "name" > «local-name()»
         value "ns:SetType($name)";
     }