SVGHMI: more debug code moved to hmi_tree.ysl2 svghmi
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Tue, 17 Mar 2020 08:00:33 +0100
branchsvghmi
changeset 2874 b67af0b8dc72
parent 2873 022db76c3bff
child 2875 6a12e1084deb
SVGHMI: more debug code moved to hmi_tree.ysl2
svghmi/gen_index_xhtml.xslt
svghmi/gen_index_xhtml.ysl2
svghmi/hmi_tree.ysl2
--- a/svghmi/gen_index_xhtml.xslt	Tue Mar 17 07:39:50 2020 +0100
+++ b/svghmi/gen_index_xhtml.xslt	Tue Mar 17 08:00:33 2020 +0100
@@ -215,6 +215,36 @@
       </xsl:with-param>
     </xsl:apply-templates>
   </xsl:template>
+  <xsl:template mode="testtree" match="*">
+    <xsl:param name="indent" select="''"/>
+    <xsl:value-of select="$indent"/>
+    <xsl:text> </xsl:text>
+    <xsl:value-of select="local-name()"/>
+    <xsl:text> </xsl:text>
+    <xsl:for-each select="@*">
+      <xsl:value-of select="local-name()"/>
+      <xsl:text>="</xsl:text>
+      <xsl:value-of select="."/>
+      <xsl:text>" </xsl:text>
+    </xsl:for-each>
+    <xsl:text>
+</xsl:text>
+    <xsl:apply-templates mode="testtree" select="*">
+      <xsl:with-param name="indent">
+        <xsl:value-of select="concat($indent,'&gt;')"/>
+      </xsl:with-param>
+    </xsl:apply-templates>
+  </xsl:template>
+  <xsl:template name="debug_hmitree">
+    <xsl:text>Raw HMI tree
+</xsl:text>
+    <xsl:apply-templates mode="testtree" select="$hmitree"/>
+    <xsl:text>
+</xsl:text>
+    <xsl:text>Indexed HMI tree
+</xsl:text>
+    <xsl:apply-templates mode="testtree" select="$indexed_hmitree"/>
+  </xsl:template>
   <func:function name="func:is_descendant_path">
     <xsl:param name="descend"/>
     <xsl:param name="ancest"/>
@@ -345,10 +375,13 @@
 </xsl:text>
     </xsl:comment>
     <xsl:comment>
-      <xsl:apply-templates mode="testtree" select="$hmitree"/>
-    </xsl:comment>
-    <xsl:comment>
-      <xsl:apply-templates mode="testtree" select="$indexed_hmitree"/>
+      <xsl:text>
+</xsl:text>
+      <xsl:text>debug_hmitree:
+</xsl:text>
+      <xsl:call-template name="debug_hmitree"/>
+      <xsl:text>
+</xsl:text>
     </xsl:comment>
     <xsl:comment>
       <xsl:text>Detachable :
@@ -1468,26 +1501,6 @@
     <xsl:text>//})();
 </xsl:text>
   </xsl:template>
-  <xsl:template mode="testtree" match="*">
-    <xsl:param name="indent" select="''"/>
-    <xsl:value-of select="$indent"/>
-    <xsl:text> </xsl:text>
-    <xsl:value-of select="local-name()"/>
-    <xsl:text> </xsl:text>
-    <xsl:for-each select="@*">
-      <xsl:value-of select="local-name()"/>
-      <xsl:text>="</xsl:text>
-      <xsl:value-of select="."/>
-      <xsl:text>" </xsl:text>
-    </xsl:for-each>
-    <xsl:text>
-</xsl:text>
-    <xsl:apply-templates mode="testtree" select="*">
-      <xsl:with-param name="indent">
-        <xsl:value-of select="concat($indent,'&gt;')"/>
-      </xsl:with-param>
-    </xsl:apply-templates>
-  </xsl:template>
   <xsl:template name="defs_by_labels">
     <xsl:param name="labels" select="''"/>
     <xsl:param name="mandatory" select="'yes'"/>
--- a/svghmi/gen_index_xhtml.ysl2	Tue Mar 17 07:39:50 2020 +0100
+++ b/svghmi/gen_index_xhtml.ysl2	Tue Mar 17 08:00:33 2020 +0100
@@ -264,16 +264,9 @@
         comment > Made with SVGHMI. https://beremiz.org
 
         // use python to call all debug output from included definitions
-        // '&bug' is a workaround for old pyPEG that choke on empty python results
-        !"&bug "+"\n".join(["comment {|\n| %s:\n call \"%s\";\n| \n}"%(n,n) for n in debug_output_calls])!
-
-        // TODO
-        comment {
-            apply "$hmitree", mode="testtree";
-        }
-        comment {
-            apply "$indexed_hmitree", mode="testtree";
-        }
+        // '&bug' is a workaround for pyPEG that choke on yml2 python results not parsing to a single call
+        !"&bug {"+"\n".join(["comment {\n| \n| %s:\n call \"%s\";\n| \n}"%(n,n) for n in debug_output_calls]) +"}"!
+
         comment {
             | Detachable :
             foreach "$detachable_elements"{
@@ -514,17 +507,6 @@
     // }
 
 
-    /**/
-    template "*", mode="testtree"{
-        param "indent", "''";
-        > «$indent» «local-name()» 
-        foreach "@*" > «local-name()»="«.»" 
-        > \n
-        apply "*", mode="testtree" {
-            with "indent" value "concat($indent,'>')"
-        };
-    }
-    /**/
 
     function "defs_by_labels" {
         param "labels","''";
--- a/svghmi/hmi_tree.ysl2	Tue Mar 17 07:39:50 2020 +0100
+++ b/svghmi/hmi_tree.ysl2	Tue Mar 17 08:00:33 2020 +0100
@@ -45,3 +45,22 @@
         with "parentpath" > «$parentpath»
     }
 }
+
+// Debug data
+template "*", mode="testtree"{
+    param "indent", "''";
+    > «$indent» «local-name()» 
+    foreach "@*" > «local-name()»="«.»" 
+    > \n
+    apply "*", mode="testtree" {
+        with "indent" value "concat($indent,'>')"
+    };
+}
+function "debug_hmitree" {
+    | Raw HMI tree
+    apply "$hmitree", mode="testtree";
+    |
+    | Indexed HMI tree
+    apply "$indexed_hmitree", mode="testtree";
+}
+!debug_output_calls.append("debug_hmitree")