Fixed bug in VariablePanel, function block variables in graphic viewers could be modified
--- a/PLCControler.py Tue Sep 24 12:35:57 2013 +0200
+++ b/PLCControler.py Tue Sep 24 12:40:36 2013 +0200
@@ -115,7 +115,7 @@
elif el.tag == "Tree":
return generate_var_tree(el)
elif el.tag == "Edit":
- return True
+ return el.text == "True"
elif el.text is None:
return ''
return el.text
@@ -157,6 +157,18 @@
self.apply_templates(context, datatype_infos, output_parent)
return
+class VarIsEdited(etree.XSLTExtension):
+
+ def __init__(self, controller, debug):
+ etree.XSLTExtension.__init__(self)
+ self.Controller = controller
+ self.Debug = debug
+
+ def execute(self, context, self_node, input_node, output_parent):
+ typename = input_node.get("name")
+ output_parent.text = str(
+ self.Controller.GetPou(typename, self.Debug) is None)
+
variables_infos_xslt = etree.parse(
os.path.join(ScriptDirectory, "plcopen", "variables_infos.xslt"))
@@ -1211,7 +1223,8 @@
variables_infos_xslt_tree = etree.XSLT(
variables_infos_xslt, extensions = {
("var_infos_ns", "add_variable"): AddVariable(variables),
- ("var_infos_ns", "var_tree"): VarTree(self, debug)})
+ ("var_infos_ns", "var_tree"): VarTree(self, debug),
+ ("var_infos_ns", "is_edited"): VarIsEdited(self, debug)})
variables_infos_xslt_tree(object_with_vars)
return variables
--- a/plcopen/variables_infos.xslt Tue Sep 24 12:35:57 2013 +0200
+++ b/plcopen/variables_infos.xslt Tue Sep 24 12:40:36 2013 +0200
@@ -69,7 +69,7 @@
<Option><xsl:value-of select="$var_option"/></Option>
<Location><xsl:value-of select="@address"/></Location>
<Initial_Value><xsl:apply-templates select="ppx:initialValue"/></Initial_Value>
- <Edit/>
+ <Edit><xsl:apply-templates select="ppx:type" mode="var_edit"/></Edit>
<Tree><xsl:apply-templates select="ppx:type" mode="var_tree"/></Tree>
<Documentation>
<xsl:value-of select="ppx:documentation/xhtml:p/text()"/>
@@ -104,7 +104,13 @@
<xsl:template match="*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/*">
<xsl:value-of select="local-name()"/>
</xsl:template>
- <xsl:template match="ppx:initialValue">
+ <xsl:template match="*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:derived" mode="var_edit">
+ <ns:is_edited/>
+ </xsl:template>
+ <xsl:template match="*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/*" mode="var_edit">
+ <xsl:text>True</xsl:text>
+ </xsl:template>
+ <xsl:template match="ppx:initialValue">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="ppx:value">