--- a/svghmi/gen_index_xhtml.xslt Mon Apr 20 16:19:31 2020 +0200
+++ b/svghmi/gen_index_xhtml.xslt Wed Apr 22 15:33:53 2020 +0200
@@ -1,6 +1,6 @@
-<xsl:stylesheet xmlns:ns="beremiz" xmlns:definitions="definitions" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:func="http://exslt.org/functions" xmlns:epilogue="epilogue" xmlns:preamble="preamble" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:svg="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:str="http://exslt.org/strings" xmlns:regexp="http://exslt.org/regular-expressions" xmlns:exsl="http://exslt.org/common" xmlns:declarations="declarations" xmlns:debug="debug" exclude-result-prefixes="ns func exsl regexp str dyn debug preamble epilogue declarations definitions" extension-element-prefixes="ns func exsl regexp str dyn" version="1.0">
- <xsl:output method="xml" cdata-section-elements="xhtml:script"/>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common" xmlns:regexp="http://exslt.org/regular-expressions" xmlns:str="http://exslt.org/strings" xmlns:func="http://exslt.org/functions" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:debug="debug" xmlns:preamble="preamble" xmlns:declarations="declarations" xmlns:definitions="definitions" xmlns:epilogue="epilogue" xmlns:ns="beremiz" version="1.0" extension-element-prefixes="ns func exsl regexp str dyn" exclude-result-prefixes="ns func exsl regexp str dyn debug preamble epilogue declarations definitions"> + <xsl:output cdata-section-elements="xhtml:script" method="xml"/> <xsl:variable name="svg" select="/svg:svg"/>
<xsl:variable name="hmi_elements" select="//svg:*[starts-with(@inkscape:label, 'HMI:')]"/>
<xsl:variable name="hmitree" select="ns:GetHMITree()"/>
@@ -896,6 +896,131 @@
+ <xsl:template mode="widget_defs" match="widget[@type='Button']"> + <xsl:param name="hmi_element"/> + <xsl:text>frequency: 5, + <xsl:text>init: function() { + <xsl:text> this.element.addEventListener( + <xsl:text> "mousedown", + <xsl:text> change_hmi_value(this.indexes[0], "=1"); + <xsl:text> this.element.addEventListener( + <xsl:text> change_hmi_value(this.indexes[0], "=0"); + <xsl:template mode="widget_defs" match="widget[@type='CircularBar']"> + <xsl:param name="hmi_element"/> + <xsl:text>frequency: 10, + <xsl:call-template name="defs_by_labels"> + <xsl:with-param name="hmi_element" select="$hmi_element"/> + <xsl:with-param name="labels"> + <xsl:text>path</xsl:text> + <xsl:call-template name="defs_by_labels"> + <xsl:with-param name="hmi_element" select="$hmi_element"/> + <xsl:with-param name="labels"> + <xsl:text>value min max</xsl:text> + <xsl:with-param name="mandatory" select="'no'"/> + <xsl:text>dispatch: function(value) { + <xsl:text> if(this.value_elt) + <xsl:text> this.value_elt.textContent = String(value); + <xsl:text> let [min,max,start,end] = this.range; + <xsl:text> let [cx,cy] = this.center; + <xsl:text> let [rx,ry] = this.proportions; + <xsl:text> let tip = start + (end-start)*Number(value)/(max-min); + <xsl:text> let size = 0; + <xsl:text> if (tip-start > Math.PI) { + <xsl:text> this.path_elt.setAttribute('d', "M "+(cx+rx*Math.cos(start))+","+(cy+ry*Math.sin(start))+" A "+rx+","+ry+" 0 "+size+" 1 "+(cx+rx*Math.cos(tip))+","+(cy+ry*Math.sin(tip))); + <xsl:text>range: undefined, + <xsl:text>init: function() { + <xsl:text> let start = Number(this.path_elt.getAttribute('sodipodi:start')); + <xsl:text> let end = Number(this.path_elt.getAttribute('sodipodi:end')); + <xsl:text> let cx = Number(this.path_elt.getAttribute('sodipodi:cx')); + <xsl:text> let cy = Number(this.path_elt.getAttribute('sodipodi:cy')); + <xsl:text> let rx = Number(this.path_elt.getAttribute('sodipodi:rx')); + <xsl:text> let ry = Number(this.path_elt.getAttribute('sodipodi:ry')); + <xsl:text> if (ry == 0) { + <xsl:text> if (start > end) { + <xsl:text> end = end + 2*Math.PI; + <xsl:text> let min = this.min_elt ? + <xsl:text> Number(this.min_elt.textContent) : + <xsl:text> this.args.length >= 1 ? this.args[0] : 0; + <xsl:text> let max = this.max_elt ? + <xsl:text> Number(this.max_elt.textContent) : + <xsl:text> this.args.length >= 2 ? this.args[1] : 100; + <xsl:text> this.range = [min, max, start, end]; + <xsl:text> this.center = [cx, cy]; + <xsl:text> this.proportions = [rx, ry]; <xsl:template mode="widget_defs" match="widget[@type='Display']">
<xsl:param name="hmi_element"/>
@@ -2336,7 +2461,7 @@
<xsl:apply-templates select="."/>
- <html xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/1999/xhtml">
+ <html xmlns="http://www.w3.org/1999/xhtml" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <body style="margin:0;overflow:hidden;">
<xsl:copy-of select="$result_svg"/>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/svghmi/widget_button.ysl2 Wed Apr 22 15:33:53 2020 +0200
@@ -0,0 +1,18 @@
+template "widget[@type='Button']", mode="widget_defs" { + | this.element.addEventListener( + | change_hmi_value(this.indexes[0], "=1"); + | this.element.addEventListener( + | change_hmi_value(this.indexes[0], "=0"); \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/svghmi/widget_circularbar.ysl2 Wed Apr 22 15:33:53 2020 +0200
@@ -0,0 +1,48 @@
+// widget_circularbar.ysl2 +template "widget[@type='CircularBar']", mode="widget_defs" { + optional_labels("value min max"); + | dispatch: function(value) { + | this.value_elt.textContent = String(value); + | let [min,max,start,end] = this.range; + | let [cx,cy] = this.center; + | let [rx,ry] = this.proportions; + | let tip = start + (end-start)*Number(value)/(max-min); + | if (tip-start > Math.PI) { + | this.path_elt.setAttribute('d', "M "+(cx+rx*Math.cos(start))+","+(cy+ry*Math.sin(start))+" A "+rx+","+ry+" 0 "+size+" 1 "+(cx+rx*Math.cos(tip))+","+(cy+ry*Math.sin(tip))); + | let start = Number(this.path_elt.getAttribute('sodipodi:start')); + | let end = Number(this.path_elt.getAttribute('sodipodi:end')); + | let cx = Number(this.path_elt.getAttribute('sodipodi:cx')); + | let cy = Number(this.path_elt.getAttribute('sodipodi:cy')); + | let rx = Number(this.path_elt.getAttribute('sodipodi:rx')); + | let ry = Number(this.path_elt.getAttribute('sodipodi:ry')); + | end = end + 2*Math.PI; + | let min = this.min_elt ? + | Number(this.min_elt.textContent) : + | this.args.length >= 1 ? this.args[0] : 0; + | let max = this.max_elt ? + | Number(this.max_elt.textContent) : + | this.args.length >= 2 ? this.args[1] : 100; + | this.range = [min, max, start, end]; + | this.center = [cx, cy]; + | this.proportions = [rx, ry]; \ No newline at end of file