--- a/svghmi/gen_index_xhtml.xslt Wed Oct 02 11:31:02 2019 +0200
+++ b/svghmi/gen_index_xhtml.xslt Sat Oct 05 09:45:58 2019 +0200
@@ -1,8 +1,55 @@
-<xsl:stylesheet xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns="beremiz" xmlns:cc="http://creativecommons.org/ns#" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.w3.org/1999/xhtml" xmlns:str="http://exslt.org/strings" xmlns:regexp="http://exslt.org/regular-expressions" xmlns:exsl="http://exslt.org/common" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" exclude-result-prefixes="ns" extension-element-prefixes="ns" version="1.0">
+<xsl:stylesheet xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns="beremiz" xmlns:cc="http://creativecommons.org/ns#" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:str="http://exslt.org/strings" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:regexp="http://exslt.org/regular-expressions" xmlns:exsl="http://exslt.org/common" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" exclude-result-prefixes="ns" extension-element-prefixes="ns" version="1.0"> <xsl:output method="xml" cdata-section-elements="script"/>
<xsl:variable name="geometry" select="ns:GetSVGGeometry()"/>
<xsl:variable name="hmitree" select="ns:GetHMITree()"/>
+ <xsl:variable name="_categories"> + <xsl:text>HMI_ROOT</xsl:text> + <xsl:text>HMI_LABEL</xsl:text> + <xsl:text>HMI_CLASS</xsl:text> + <xsl:text>HMI_PLC_STATUS</xsl:text> + <xsl:text>HMI_CURRENT_PAGE</xsl:text> + <xsl:variable name="categories" select="exsl:node-set($_categories)"/> + <xsl:variable name="indexed_hmitree"> + <xsl:apply-templates mode="index" select="$hmitree"/> + <xsl:template mode="index" match="node()"> + <xsl:param name="index" select="0"/> + <xsl:variable name="content"> + <xsl:when test="not(local-name() = $categories/noindex)"> + <xsl:attribute name="index"> + <xsl:value-of select="$index"/> + <xsl:for-each select="@*"> + <xsl:apply-templates mode="index" select="*[1]"> + <xsl:with-param name="index" select="$index"/> + <xsl:copy-of select="$content"/> + <xsl:apply-templates mode="index" select="following-sibling::*[1]"> + <xsl:with-param name="index" select="$index + count(exsl:node-set($content)/*)"/> <xsl:template match="@* | node()">
<xsl:apply-templates select="@* | node()"/>
@@ -23,25 +70,14 @@
<xsl:apply-templates mode="testtree" select="$hmitree"/>
+ <xsl:apply-templates mode="testtree" select="exsl:node-set($indexed_hmitree)"/> <xsl:apply-templates select="@* | node()"/>
- <xsl:text>function evaluate_js_from_descriptions() {
- <xsl:text> var Display;
+ <xsl:text>var subscriptions = { - <xsl:text> var res = [];
- <xsl:variable name="midmark">
- <xsl:value-of select="$mark"/>
- <xsl:apply-templates mode="code_from_descs" select="//*[contains(child::svg:desc, $midmark) or starts-with(child::svg:desc, $mark)]"/>
@@ -96,6 +132,66 @@
+ <xsl:text> var pending_updates = {}; + <xsl:text> // subscription state, as it should be in hmi server + <xsl:text> // expected {index:period} + <xsl:text> var subscriptions = {}; + <xsl:text> // subscription state as needed by widget now + <xsl:text> // expected {index:[widgets]}; + <xsl:text> var subscribers = {}; + <xsl:text> // return the diff in between curently subscribed and subscription + <xsl:text> function update_subscriptions() { + <xsl:text> let result = []; + <xsl:text> Object.keys(subscribers).forEach(index => { + <xsl:text> let previous_period = subscriptions[index]; + <xsl:text> let new_period = Math.min(...widgets.map(widget => widget.period)); + <xsl:text> if(previous_period != new_period) + <xsl:text> result.push({index: index, period: new_period}); + <xsl:text> function update_value(index, value) { @@ -159,11 +255,12 @@
<xsl:value-of select="local-name()"/>
- <xsl:value-of select="@name"/>
- <xsl:value-of select="@type"/>
- <xsl:value-of select="@path"/>
+ <xsl:for-each select="@*"> + <xsl:value-of select="local-name()"/> + <xsl:value-of select="."/> <xsl:apply-templates mode="testtree" select="*">
--- a/svghmi/gen_index_xhtml.ysl2 Wed Oct 02 11:31:02 2019 +0200
+++ b/svghmi/gen_index_xhtml.ysl2 Sat Oct 05 09:45:58 2019 +0200
@@ -10,7 +10,7 @@
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:xhtml="http://www.w3.org/1999/xhtml" /* Our namespace to invoke python code */
@@ -23,7 +23,43 @@
variable "geometry", "ns:GetSVGGeometry()";
variable "hmitree", "ns:GetHMITree()";
+ variable "_categories" { + noindex > HMI_PLC_STATUS + noindex > HMI_CURRENT_PAGE + variable "categories", "exsl:node-set($_categories)"; + //variable "indexed_hmitree", "$hmitree[not(local-name() = $categories/noindex/text())]"; + variable "indexed_hmitree" apply "$hmitree", mode="index"; + template "node()", mode="index"{ + when "not(local-name() = $categories/noindex)" { + attrib "index" > «$index» + /* no node expected below value nodes */ + apply "*[1]", mode="index"{ + with "index", "$index"; + apply "following-sibling::*[1]", mode="index" { + with "index", "$index + count(exsl:node-set($content)/*)"; * - copy every attributes
* - copy every sub-elements
@@ -47,11 +83,15 @@
apply "$hmitree", mode="testtree";
+ apply "exsl:node-set($indexed_hmitree)", mode="testtree"; /* TODO : paste hmitree hash stored in hmi tree root node */
function evaluate_js_from_descriptions() {
@@ -67,6 +107,7 @@
@@ -74,6 +115,14 @@
+ // apply "$hmitree", mode="subscription_"; @@ -116,7 +165,9 @@
template "*", mode="testtree"{
- | «$indent» «local-name()» «@name» «@type» «@path»
+ > «$indent» «local-name()» + foreach "@*" > «local-name()»=«.» apply "*", mode="testtree" {
with "indent" value "concat($indent,'>')"