--- a/svghmi/analyse_widget.xslt Wed Sep 14 12:41:44 2022 +0200
+++ b/svghmi/analyse_widget.xslt Fri Sep 16 09:03:59 2022 +0200
@@ -2,19 +2,48 @@
<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:svg="http://www.w3.org/2000/svg" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" version="1.0" extension-element-prefixes="ns func exsl regexp str dyn" exclude-result-prefixes="ns func exsl regexp str dyn svg inkscape">
<xsl:output method="xml"/>
<xsl:variable name="indexed_hmitree" select="/.."/>
- <xsl:variable name="pathregex" select="'^([^\[,]+)(\[[^\]]+\])?([-.\d,]*)$'"/>
+ <xsl:variable name="pathregex" select="'^(\w+=)?([^,=]+)([-.\d,]*)$'"/> + <xsl:variable name="newline"> + <xsl:variable name="twonewlines" select="concat($newline,$newline)"/> <xsl:template mode="parselabel" match="*">
<xsl:variable name="label" select="@inkscape:label"/>
+ <xsl:variable name="desc" select="svg:desc"/> + <xsl:variable name="len" select="string-length($label)"/> + <xsl:variable name="has_continuation" select="substring($label,$len,1)='\'"/> + <xsl:variable name="full_decl"> + <xsl:when test="$has_continuation"> + <xsl:variable name="_continuation" select="substring-before($desc, $twonewlines)"/> + <xsl:variable name="continuation"> + <xsl:when test="$_continuation"> + <xsl:value-of select="$_continuation"/> + <xsl:value-of select="$desc"/> + <xsl:value-of select="concat(substring($label,1,$len - 1),translate($continuation,$newline,''))"/> + <xsl:value-of select="$label"/> <xsl:variable name="id" select="@id"/>
- <xsl:variable name="description" select="substring-after($label,'HMI:')"/>
- <xsl:variable name="_args" select="substring-before($description,'@')"/>
+ <xsl:variable name="declaration" select="substring-after($full_decl,'HMI:')"/> + <xsl:variable name="_args" select="substring-before($declaration,'@')"/> <xsl:variable name="args">
<xsl:value-of select="$_args"/>
- <xsl:value-of select="$description"/>
+ <xsl:value-of select="$declaration"/> @@ -55,7 +84,7 @@
<xsl:text>Widget id:</xsl:text>
<xsl:value-of select="$id"/>
<xsl:text> label:</xsl:text>
- <xsl:value-of select="$label"/>
+ <xsl:value-of select="$full_decl"/> <xsl:text> has wrong syntax of frequency forcing </xsl:text>
<xsl:value-of select="$freq"/>
@@ -64,6 +93,25 @@
<xsl:value-of select="$freq"/>
+ <xsl:variable name="tail" select="substring-after($declaration,'@')"/> + <xsl:variable name="taillen" select="string-length($tail)"/> + <xsl:variable name="has_enable" select="contains($tail, '#')"/> + <xsl:variable name="paths"> + <xsl:when test="$has_enable"> + <xsl:value-of select="substring-before($tail,'#')"/> + <xsl:value-of select="$tail"/> + <xsl:if test="$has_enable"> + <xsl:variable name="enable_expr" select="substring-after($tail,'#')"/> + <xsl:attribute name="enable_expr"> + <xsl:value-of select="$enable_expr"/> <xsl:for-each select="str:split(substring-after($args, ':'), ':')">
<xsl:attribute name="value">
@@ -71,21 +119,29 @@
- <xsl:variable name="paths" select="substring-after($description,'@')"/>
<xsl:for-each select="str:split($paths, '@')">
<xsl:if test="string-length(.) > 0">
<xsl:variable name="path_match" select="regexp:match(.,$pathregex)"/>
+ <xsl:variable name="pathassign" select="substring-before($path_match[2],'=')"/> <xsl:variable name="pathminmax" select="str:split($path_match[4],',')"/>
- <xsl:variable name="path" select="$path_match[2]"/>
- <xsl:variable name="path_accepts" select="$path_match[3]"/>
+ <xsl:variable name="path" select="$path_match[3]"/> <xsl:variable name="pathminmaxcount" select="count($pathminmax)"/>
+ <xsl:if test="not($path)"> + <xsl:message terminate="yes"> + <xsl:text>Widget id:</xsl:text> + <xsl:value-of select="$id"/> + <xsl:text> label:</xsl:text> + <xsl:value-of select="$full_decl"/> + <xsl:text> has wrong syntax</xsl:text> <xsl:attribute name="value">
<xsl:value-of select="$path"/>
- <xsl:if test="string-length($path_accepts)">
- <xsl:attribute name="accepts">
- <xsl:value-of select="$path_accepts"/>
+ <xsl:if test="$pathassign"> + <xsl:attribute name="assign"> + <xsl:value-of select="$pathassign"/> @@ -102,7 +158,7 @@
<xsl:text>Widget id:</xsl:text>
<xsl:value-of select="$id"/>
<xsl:text> label:</xsl:text>
- <xsl:value-of select="$label"/>
+ <xsl:value-of select="$full_decl"/> <xsl:text> has wrong syntax of path section </xsl:text>
<xsl:value-of select="$pathminmax"/>
@@ -128,7 +184,7 @@
<xsl:text>Widget id:</xsl:text>
<xsl:value-of select="$id"/>
<xsl:text> label:</xsl:text>
- <xsl:value-of select="$label"/>
+ <xsl:value-of select="$full_decl"/> <xsl:text> path section </xsl:text>
<xsl:value-of select="$pathminmax"/>
<xsl:text> use min and max on non mumeric value</xsl:text>
@@ -148,11 +204,23 @@
- <xsl:if test="svg:desc">
- <xsl:value-of select="svg:desc/text()"/>
+ <xsl:when test="$has_continuation"> + <xsl:variable name="_continuation" select="substring-after($desc, $twonewlines)"/> + <xsl:if test="$_continuation"> + <xsl:value-of select="$_continuation"/> + <xsl:value-of select="$desc/text()"/> @@ -233,8 +301,6 @@
<xsl:template name="generated_button_class">
- <xsl:text> display = "inactive";
<xsl:text> state = "init";
<xsl:text> dispatch(value) {
@@ -261,19 +327,13 @@
<xsl:apply-templates mode="actions" select="$fsm"/>
- <xsl:text> this.set_activation_state(this.display == "active");
<xsl:text> this.bound_onmouseup = this.onmouseup.bind(this);
<xsl:text> this.element.addEventListener("pointerdown", this.onmousedown.bind(this));
- <xsl:text> this.set_activation_state(undefined);
+ <xsl:text> this.activity_state = undefined; @@ -563,15 +623,27 @@
<xsl:value-of select="@type"/>
- <xsl:text>Jump widget brings focus to a different page. Mandatory single argument
+ <xsl:text>Jump widget brings focus to a different page. Mandatory first argument <xsl:text>gives name of the page.
- <xsl:text>Optional single path is used as new reference when jumping to a relative
+ <xsl:text>If first path is pointint to HMI_NODE variable is used as new reference + <xsl:text>when jumping to a relative page. + <xsl:text>Additional arguments are unordered options: - <xsl:text>page, it must point to a HMI_NODE.
+ <xsl:text>- Absolute: force page jump to be not relative even if first path is of type HMI_NODE + <xsl:text>- name=value: Notify PLC about jump by setting variable with path having same name assigned @@ -581,9 +653,47 @@
- <xsl:text>"disabled" labeled element, if provided, is shown instead of "active" or
+ <xsl:text>Relative jump: + <xsl:text>HMI:Jump:RelativePage@/PUMP9 + <xsl:text>HMI:Jump:RelativePage@/PUMP9@role=.userrole#role=="admin" + <xsl:text>Absolute jump: + <xsl:text>HMI:Jump:AbsolutePage - <xsl:text>"inactive" widget when pointed HMI_NODE is null.
+ <xsl:text>HMI:Jump:AbsolutePage@role=.userrole#role=="admin" + <xsl:text>Forced absolute jump: + <xsl:text>HMI:Jump:AbsolutePage:Absolute@/PUMP9 + <xsl:text>HMI:Jump:AbsolutePage:Absolute:notify=1@notify=/PUMP9 + <xsl:text>Jump with feedback + <xsl:text>HMI:Jump:AbsolutePage:notify=1@notify=.did_jump @@ -596,6 +706,10 @@
<xsl:text>reference for relative jump</xsl:text>
+ <func:function name="func:is_relative_jump"> + <xsl:param name="widget"/> + <func:result select="$widget/path and $widget/path[1]/@type='HMI_NODE' and not($widget/arg[position()>1 and @value = 'Absolute'])"/> <xsl:template match="widget[@type='Keypad']" mode="widget_desc">
<xsl:value-of select="@type"/>
--- a/svghmi/gen_index_xhtml.xslt Wed Sep 14 12:41:44 2022 +0200
+++ b/svghmi/gen_index_xhtml.xslt Fri Sep 16 09:03:59 2022 +0200
@@ -159,19 +159,48 @@
- <xsl:variable name="pathregex" select="'^([^\[,]+)(\[[^\]]+\])?([-.\d,]*)$'"/>
+ <xsl:variable name="pathregex" select="'^(\w+=)?([^,=]+)([-.\d,]*)$'"/> + <xsl:variable name="newline"> + <xsl:variable name="twonewlines" select="concat($newline,$newline)"/> <xsl:template mode="parselabel" match="*">
<xsl:variable name="label" select="@inkscape:label"/>
+ <xsl:variable name="desc" select="svg:desc"/> + <xsl:variable name="len" select="string-length($label)"/> + <xsl:variable name="has_continuation" select="substring($label,$len,1)='\'"/> + <xsl:variable name="full_decl"> + <xsl:when test="$has_continuation"> + <xsl:variable name="_continuation" select="substring-before($desc, $twonewlines)"/> + <xsl:variable name="continuation"> + <xsl:when test="$_continuation"> + <xsl:value-of select="$_continuation"/> + <xsl:value-of select="$desc"/> + <xsl:value-of select="concat(substring($label,1,$len - 1),translate($continuation,$newline,''))"/> + <xsl:value-of select="$label"/> <xsl:variable name="id" select="@id"/>
- <xsl:variable name="description" select="substring-after($label,'HMI:')"/>
- <xsl:variable name="_args" select="substring-before($description,'@')"/>
+ <xsl:variable name="declaration" select="substring-after($full_decl,'HMI:')"/> + <xsl:variable name="_args" select="substring-before($declaration,'@')"/> <xsl:variable name="args">
<xsl:value-of select="$_args"/>
- <xsl:value-of select="$description"/>
+ <xsl:value-of select="$declaration"/> @@ -212,7 +241,7 @@
<xsl:text>Widget id:</xsl:text>
<xsl:value-of select="$id"/>
<xsl:text> label:</xsl:text>
- <xsl:value-of select="$label"/>
+ <xsl:value-of select="$full_decl"/> <xsl:text> has wrong syntax of frequency forcing </xsl:text>
<xsl:value-of select="$freq"/>
@@ -221,6 +250,25 @@
<xsl:value-of select="$freq"/>
+ <xsl:variable name="tail" select="substring-after($declaration,'@')"/> + <xsl:variable name="taillen" select="string-length($tail)"/> + <xsl:variable name="has_enable" select="contains($tail, '#')"/> + <xsl:variable name="paths"> + <xsl:when test="$has_enable"> + <xsl:value-of select="substring-before($tail,'#')"/> + <xsl:value-of select="$tail"/> + <xsl:if test="$has_enable"> + <xsl:variable name="enable_expr" select="substring-after($tail,'#')"/> + <xsl:attribute name="enable_expr"> + <xsl:value-of select="$enable_expr"/> <xsl:for-each select="str:split(substring-after($args, ':'), ':')">
<xsl:attribute name="value">
@@ -228,21 +276,29 @@
- <xsl:variable name="paths" select="substring-after($description,'@')"/>
<xsl:for-each select="str:split($paths, '@')">
<xsl:if test="string-length(.) > 0">
<xsl:variable name="path_match" select="regexp:match(.,$pathregex)"/>
+ <xsl:variable name="pathassign" select="substring-before($path_match[2],'=')"/> <xsl:variable name="pathminmax" select="str:split($path_match[4],',')"/>
- <xsl:variable name="path" select="$path_match[2]"/>
- <xsl:variable name="path_accepts" select="$path_match[3]"/>
+ <xsl:variable name="path" select="$path_match[3]"/> <xsl:variable name="pathminmaxcount" select="count($pathminmax)"/>
+ <xsl:if test="not($path)"> + <xsl:message terminate="yes"> + <xsl:text>Widget id:</xsl:text> + <xsl:value-of select="$id"/> + <xsl:text> label:</xsl:text> + <xsl:value-of select="$full_decl"/> + <xsl:text> has wrong syntax</xsl:text> <xsl:attribute name="value">
<xsl:value-of select="$path"/>
- <xsl:if test="string-length($path_accepts)">
- <xsl:attribute name="accepts">
- <xsl:value-of select="$path_accepts"/>
+ <xsl:if test="$pathassign"> + <xsl:attribute name="assign"> + <xsl:value-of select="$pathassign"/> @@ -259,7 +315,7 @@
<xsl:text>Widget id:</xsl:text>
<xsl:value-of select="$id"/>
<xsl:text> label:</xsl:text>
- <xsl:value-of select="$label"/>
+ <xsl:value-of select="$full_decl"/> <xsl:text> has wrong syntax of path section </xsl:text>
<xsl:value-of select="$pathminmax"/>
@@ -285,7 +341,7 @@
<xsl:text>Widget id:</xsl:text>
<xsl:value-of select="$id"/>
<xsl:text> label:</xsl:text>
- <xsl:value-of select="$label"/>
+ <xsl:value-of select="$full_decl"/> <xsl:text> path section </xsl:text>
<xsl:value-of select="$pathminmax"/>
<xsl:text> use min and max on non mumeric value</xsl:text>
@@ -305,11 +361,23 @@
- <xsl:if test="svg:desc">
- <xsl:value-of select="svg:desc/text()"/>
+ <xsl:when test="$has_continuation"> + <xsl:variable name="_continuation" select="substring-after($desc, $twonewlines)"/> + <xsl:if test="$_continuation"> + <xsl:value-of select="$_continuation"/> + <xsl:value-of select="$desc/text()"/> @@ -371,6 +439,11 @@
+ <xsl:value-of select="text()"/> <xsl:apply-templates mode="testtree" select="*">
<xsl:with-param name="indent">
<xsl:value-of select="concat($indent,'>')"/>
@@ -1200,6 +1273,14 @@
<xsl:variable name="indexes">
<xsl:for-each select="$widget/path">
+ <xsl:if test="position()!=last()"> + <xsl:variable name="variables"> + <xsl:for-each select="$widget/path"> <xsl:when test="not(@index)">
@@ -1236,25 +1317,23 @@
<xsl:value-of select="@index"/>
- <xsl:if test="position()!=last()">
+ <xsl:text>, {</xsl:text> + <xsl:if test="@min and @max"> + <xsl:text>minmax:[</xsl:text> + <xsl:value-of select="@min"/> + <xsl:text>, </xsl:text> + <xsl:value-of select="@max"/> + <xsl:if test="@assign">
- <xsl:variable name="minmaxes">
- <xsl:for-each select="$widget/path">
- <xsl:when test="@min and @max">
- <xsl:value-of select="@min"/>
- <xsl:value-of select="@max"/>
- <xsl:text>undefined</xsl:text>
+ <xsl:if test="@assign"> + <xsl:text>assign:"</xsl:text> + <xsl:value-of select="@assign"/> + <xsl:text>}]</xsl:text> <xsl:if test="position()!=last()">
@@ -1272,6 +1351,16 @@
+ <xsl:variable name="enable_expr"> + <xsl:when test="$widget/@enable_expr"> + <xsl:text>true</xsl:text> + <xsl:text>false</xsl:text> <xsl:value-of select="@id"/>
<xsl:text>": new </xsl:text>
@@ -1283,11 +1372,57 @@
<xsl:value-of select="$args"/>
- <xsl:value-of select="$indexes"/>
- <xsl:text>],[</xsl:text>
- <xsl:value-of select="$minmaxes"/>
+ <xsl:value-of select="$variables"/> + <xsl:text>],</xsl:text> + <xsl:value-of select="$enable_expr"/> + <xsl:if test="$widget/@enable_expr"> + <xsl:text> assignments: [], + <xsl:text> compute_enable: function(value, oldval, varnum) { + <xsl:text> let result = false; + <xsl:for-each select="$widget/path"> + <xsl:variable name="varid" select="generate-id()"/> + <xsl:variable name="varnum" select="position()-1"/> + <xsl:if test="@assign"> + <xsl:for-each select="$widget/path[@assign]"> + <xsl:if test="$varid = generate-id()"> + <xsl:text> if(varnum == </xsl:text> + <xsl:value-of select="$varnum"/> + <xsl:text>) this.assignments[</xsl:text> + <xsl:value-of select="position()-1"/> + <xsl:text> let </xsl:text> + <xsl:value-of select="@assign"/> + <xsl:text> = this.assignments[</xsl:text> + <xsl:value-of select="position()-1"/> + <xsl:text> if(</xsl:text> + <xsl:value-of select="@assign"/> + <xsl:text> == undefined) break; + <xsl:text> result = </xsl:text> + <xsl:value-of select="$widget/@enable_expr"/> + <xsl:text> this.enable(result); <xsl:apply-templates mode="widget_defs" select="$widget">
<xsl:with-param name="hmi_element" select="."/>
@@ -1474,7 +1609,7 @@
- <xsl:text>function set_activation_state(eltsub, state){
+ <xsl:text>function set_activity_state(eltsub, state){ <xsl:text> if(eltsub.active_elt != undefined){
@@ -1508,22 +1643,6 @@
- <xsl:text>function activate_activable(eltsub) {
- <xsl:text> set_activation_state(eltsub, true);
- <xsl:text>function inactivate_activable(eltsub) {
- <xsl:text> set_activation_state(eltsub, false);
@@ -1536,7 +1655,7 @@
- <xsl:text> constructor(elt_id, freq, args, indexes, minmaxes, members){
+ <xsl:text> constructor(elt_id, freq, args, variables, enable_expr, members){ <xsl:text> this.element_id = elt_id;
@@ -1544,27 +1663,41 @@
<xsl:text> this.args = args;
- <xsl:text> this.indexes = indexes;
- <xsl:text> this.minmaxes = minmaxes;
+ <xsl:text> [this.indexes, this.variables_options] = (variables.length>0) ? zip(...variables) : [[],[]]; + <xsl:text> this.indexes_length = this.indexes.length; + <xsl:text> this.enable_expr = enable_expr; + <xsl:text> this.enable_state = true; + <xsl:text> this.enable_displayed_state = true; + <xsl:text> this.enabled_elts = []; <xsl:text> Object.keys(members).forEach(prop => this[prop]=members[prop]);
- <xsl:text> this.lastapply = indexes.map(() => undefined);
- <xsl:text> this.inhibit = indexes.map(() => undefined);
- <xsl:text> this.pending = indexes.map(() => undefined);
+ <xsl:text> this.lastapply = this.indexes.map(() => undefined); + <xsl:text> this.inhibit = this.indexes.map(() => undefined); + <xsl:text> this.pending = this.indexes.map(() => undefined); <xsl:text> this.bound_uninhibit = this.uninhibit.bind(this);
- <xsl:text> this.lastdispatch = indexes.map(() => undefined);
- <xsl:text> this.deafen = indexes.map(() => undefined);
- <xsl:text> this.incoming = indexes.map(() => undefined);
+ <xsl:text> this.lastdispatch = this.indexes.map(() => undefined); + <xsl:text> this.deafen = this.indexes.map(() => undefined); + <xsl:text> this.incoming = this.indexes.map(() => undefined); <xsl:text> this.bound_undeafen = this.undeafen.bind(this);
@@ -1634,6 +1767,30 @@
+ <xsl:text> if(this.enable_expr){ + <xsl:text> this.enable_state = false; + <xsl:text> this.enable_displayed_state = false; + <xsl:text> for(let child of Array.from(this.element.children)){ + <xsl:text> let label = child.getAttribute("inkscape:label"); + <xsl:text> if(label!="disabled"){ + <xsl:text> this.enabled_elts.push(child); + <xsl:text> this.element.removeChild(child); @@ -1642,46 +1799,40 @@
<xsl:text> /* remove subsribers */
- <xsl:text> if(!this.unsubscribable)
- <xsl:text> for(let i = 0; i < this.indexes.length; i++) {
- <xsl:text> /* flush updates pending because of inhibition */
- <xsl:text> let inhibition = this.inhibit[i];
- <xsl:text> if(inhibition != undefined){
- <xsl:text> clearTimeout(inhibition);
- <xsl:text> this.lastapply[i] = undefined;
- <xsl:text> this.uninhibit(i);
- <xsl:text> let deafened = this.deafen[i];
- <xsl:text> if(deafened != undefined){
- <xsl:text> clearTimeout(deafened);
- <xsl:text> this.lastdispatch[i] = undefined;
- <xsl:text> this.undeafen(i);
- <xsl:text> let index = this.indexes[i];
- <xsl:text> if(this.relativeness[i])
- <xsl:text> index += this.offset;
- <xsl:text> subscribers(index).delete(this);
+ <xsl:text> for(let i = 0; i < this.indexes_length; i++) { + <xsl:text> /* flush updates pending because of inhibition */ + <xsl:text> let inhibition = this.inhibit[i]; + <xsl:text> if(inhibition != undefined){ + <xsl:text> clearTimeout(inhibition); + <xsl:text> this.lastapply[i] = undefined; + <xsl:text> this.uninhibit(i); + <xsl:text> let deafened = this.deafen[i]; + <xsl:text> if(deafened != undefined){ + <xsl:text> clearTimeout(deafened); + <xsl:text> this.lastdispatch[i] = undefined; + <xsl:text> this.undeafen(i); + <xsl:text> let index = this.get_variable_index(i); + <xsl:text> subscribers(index).delete(this); <xsl:text> this.offset = 0;
<xsl:text> this.relativeness = undefined;
@@ -1700,19 +1851,17 @@
<xsl:text> /* add this's subsribers */
- <xsl:text> if(!this.unsubscribable)
- <xsl:text> for(let i = 0; i < this.indexes.length; i++) {
- <xsl:text> let index = this.get_variable_index(i);
- <xsl:text> if(index == undefined) continue;
- <xsl:text> subscribers(index).add(this);
- <xsl:text> need_cache_apply.push(this);
+ <xsl:text> for(let i = 0; i < this.indexes_length; i++) { + <xsl:text> let index = this.get_variable_index(i); + <xsl:text> if(index == undefined) continue; + <xsl:text> subscribers(index).add(this); + <xsl:text> this.apply_cache(); @@ -1720,11 +1869,11 @@
<xsl:text> apply_cache() {
- <xsl:text> if(!this.unsubscribable) for(let index in this.indexes){
+ <xsl:text> for(let i = 0; i < this.indexes_length; i++) { <xsl:text> /* dispatch current cache in newly opened page widgets */
- <xsl:text> let realindex = this.get_variable_index(index);
+ <xsl:text> let realindex = this.get_variable_index(i); <xsl:text> if(realindex == undefined) continue;
@@ -1732,7 +1881,7 @@
<xsl:text> if(cached_val != undefined)
- <xsl:text> this._dispatch(cached_val, cached_val, index);
+ <xsl:text> this.feed_data_for_dispatch(cached_val, cached_val, i); @@ -1778,7 +1927,7 @@
<xsl:text> clip_min_max(index, new_val) {
- <xsl:text> let minmax = this.minmaxes[index];
+ <xsl:text> let minmax = this.variables_options[index].minmax; <xsl:text> if(minmax !== undefined && typeof new_val == "number") {
@@ -1904,7 +2053,7 @@
<xsl:text> // TODO avoid searching, store index at sub()
- <xsl:text> for(let i = 0; i < this.indexes.length; i++) {
+ <xsl:text> for(let i = 0; i < this.indexes_length; i++) { <xsl:text> let refindex = this.get_variable_index(i);
@@ -1914,7 +2063,7 @@
<xsl:text> if(index == refindex) {
- <xsl:text> this._dispatch(value, oldval, i);
+ <xsl:text> this.feed_data_for_dispatch(value, oldval, i); @@ -1934,17 +2083,93 @@
<xsl:text> this.incoming[index] = undefined;
- <xsl:text> this.dispatch(new_val, old_val, index);
- <xsl:text> _dispatch(value, oldval, varnum) {
- <xsl:text> let dispatch = this.dispatch;
- <xsl:text> if(dispatch != undefined){
+ <xsl:text> this.do_dispatch(new_val, old_val, index); + <xsl:text> enable(enabled){ + <xsl:text> if(this.enable_state != enabled){ + <xsl:text> this.enable_state = enabled; + <xsl:text> this.request_animate(); + <xsl:text> animate_enable(){ + <xsl:text> if(this.enable_state && !this.enable_displayed_state){ + <xsl:text> //show widget + <xsl:text> for(let child of this.enabled_elts){ + <xsl:text> this.element.appendChild(child); + <xsl:text> //hide disabled content + <xsl:text> if(this.disabled_elt && this.disabled_elt.parentNode != null) + <xsl:text> this.element.removeChild(this.disabled_elt); + <xsl:text> this.enable_displayed_state = true; + <xsl:text> }else if(!this.enable_state && this.enable_displayed_state){ + <xsl:text> //hide widget + <xsl:text> for(let child of this.enabled_elts){ + <xsl:text> if(child.parentNode != null) + <xsl:text> this.element.removeChild(child); + <xsl:text> //show disabled content + <xsl:text> if(this.disabled_elt) + <xsl:text> this.element.appendChild(this.disabled_elt); + <xsl:text> this.enable_displayed_state = false; + <xsl:text> // once disabled activity display is lost + <xsl:text> this.activity_displayed_state = undefined; + <xsl:text> feed_data_for_dispatch(value, oldval, varnum) { + <xsl:text> if(this.dispatch || this.enable_expr){ <xsl:text> if(this.deafen[varnum] == undefined){
@@ -1958,15 +2183,7 @@
<xsl:text> this.lastdispatch[varnum] = now;
- <xsl:text> dispatch.call(this, value, oldval, varnum);
- <xsl:text> } catch(err) {
- <xsl:text> console.log(err);
+ <xsl:text> this.do_dispatch(value, oldval, varnum) @@ -1994,9 +2211,51 @@
+ <xsl:text> do_dispatch(value, oldval, varnum) { + <xsl:text> if(this.dispatch) try { + <xsl:text> this.dispatch(value, oldval, varnum); + <xsl:text> } catch(err) { + <xsl:text> console.log(err); + <xsl:text> if(this.enable_expr) try { + <xsl:text> this.compute_enable(value, oldval, varnum); + <xsl:text> } catch(err) { + <xsl:text> console.log(err); - <xsl:text> this.animate();
+ <xsl:text> if(this.enable_expr) + <xsl:text> this.animate_enable(); + <xsl:text> // inhibit widget animation when disabled + <xsl:text> if(!this.enable_expr || this.enable_state){ + <xsl:text> if(this.has_activity) + <xsl:text> this.animate_activity(); + <xsl:text> if(this.animate != undefined) + <xsl:text> this.animate(); <xsl:text> this.pending_animate = false;
@@ -2020,9 +2279,15 @@
- <xsl:text> set_activation_state(state){
- <xsl:text> set_activation_state(this.activable_sub, state);
+ <xsl:text> animate_activity(){ + <xsl:text> if(this.activity_displayed_state != this.activity_state){ + <xsl:text> set_activity_state(this.activable_sub, this.activity_state); + <xsl:text> this.activity_displayed_state = this.activity_state; @@ -2647,9 +2912,9 @@
<xsl:template mode="actions" match="show">
- <xsl:text> this.display = "</xsl:text>
- <xsl:value-of select="@eltname"/>
+ <xsl:text> this.activity_state = </xsl:text> + <xsl:value-of select="@eltname = 'active'"/> <xsl:text> this.request_animate();
@@ -2662,8 +2927,6 @@
<xsl:template name="generated_button_class">
- <xsl:text> display = "inactive";
<xsl:text> state = "init";
<xsl:text> dispatch(value) {
@@ -2690,19 +2953,13 @@
<xsl:apply-templates mode="actions" select="$fsm"/>
- <xsl:text> this.set_activation_state(this.display == "active");
<xsl:text> this.bound_onmouseup = this.onmouseup.bind(this);
<xsl:text> this.element.addEventListener("pointerdown", this.onmousedown.bind(this));
- <xsl:text> this.set_activation_state(undefined);
+ <xsl:text> this.activity_state = undefined; @@ -2723,16 +2980,37 @@
<xsl:template match="widget[@type='Button']" mode="widget_defs">
<xsl:param name="hmi_element"/>
+ <xsl:variable name="disability"> + <xsl:call-template name="defs_by_labels"> + <xsl:with-param name="hmi_element" select="$hmi_element"/> + <xsl:with-param name="labels"> + <xsl:text>/disabled</xsl:text> + <xsl:with-param name="mandatory" select="'no'"/> + <xsl:value-of select="$disability"/> + <xsl:variable name="has_disability" select="string-length($disability)>0"/> <xsl:text> activable_sub:{
- <xsl:call-template name="defs_by_labels">
- <xsl:with-param name="hmi_element" select="$hmi_element"/>
- <xsl:with-param name="labels">
- <xsl:text>/active /inactive</xsl:text>
- <xsl:with-param name="mandatory" select="'warn'"/>
+ <xsl:variable name="activity"> + <xsl:call-template name="defs_by_labels"> + <xsl:with-param name="hmi_element" select="$hmi_element"/> + <xsl:with-param name="labels"> + <xsl:text>/active /inactive</xsl:text> + <xsl:with-param name="mandatory"> + <xsl:text>warn</xsl:text> + <xsl:value-of select="$activity"/> + <xsl:variable name="has_activity" select="string-length($activity)>0"/> + <xsl:text> has_activity: </xsl:text> + <xsl:value-of select="$has_activity"/> <xsl:template match="widget[@type='PushButton']" mode="widget_class">
@@ -2751,16 +3029,37 @@
<xsl:template match="widget[@type='PushButton']" mode="widget_defs">
<xsl:param name="hmi_element"/>
+ <xsl:variable name="disability"> + <xsl:call-template name="defs_by_labels"> + <xsl:with-param name="hmi_element" select="$hmi_element"/> + <xsl:with-param name="labels"> + <xsl:text>/disabled</xsl:text> + <xsl:with-param name="mandatory" select="'no'"/> + <xsl:value-of select="$disability"/> + <xsl:variable name="has_disability" select="string-length($disability)>0"/> <xsl:text> activable_sub:{
- <xsl:call-template name="defs_by_labels">
- <xsl:with-param name="hmi_element" select="$hmi_element"/>
- <xsl:with-param name="labels">
- <xsl:text>/active /inactive</xsl:text>
- <xsl:with-param name="mandatory" select="'warn'"/>
+ <xsl:variable name="activity"> + <xsl:call-template name="defs_by_labels"> + <xsl:with-param name="hmi_element" select="$hmi_element"/> + <xsl:with-param name="labels"> + <xsl:text>/active /inactive</xsl:text> + <xsl:with-param name="mandatory"> + <xsl:text>warn</xsl:text> + <xsl:value-of select="$activity"/> + <xsl:variable name="has_activity" select="string-length($activity)>0"/> + <xsl:text> has_activity: </xsl:text> + <xsl:value-of select="$has_activity"/> <xsl:template match="widget[@type='CircularBar']" mode="widget_desc">
@@ -2902,6 +3201,17 @@
<xsl:template match="widget[@type='CircularBar']" mode="widget_defs">
<xsl:param name="hmi_element"/>
+ <xsl:variable name="disability"> + <xsl:call-template name="defs_by_labels"> + <xsl:with-param name="hmi_element" select="$hmi_element"/> + <xsl:with-param name="labels"> + <xsl:text>/disabled</xsl:text> + <xsl:with-param name="mandatory" select="'no'"/> + <xsl:value-of select="$disability"/> + <xsl:variable name="has_disability" select="string-length($disability)>0"/> <xsl:call-template name="defs_by_labels">
<xsl:with-param name="hmi_element" select="$hmi_element"/>
<xsl:with-param name="labels">
@@ -3417,6 +3727,17 @@
<xsl:template match="widget[@type='CircularSlider']" mode="widget_defs">
<xsl:param name="hmi_element"/>
+ <xsl:variable name="disability"> + <xsl:call-template name="defs_by_labels"> + <xsl:with-param name="hmi_element" select="$hmi_element"/> + <xsl:with-param name="labels"> + <xsl:text>/disabled</xsl:text> + <xsl:with-param name="mandatory" select="'no'"/> + <xsl:value-of select="$disability"/> + <xsl:variable name="has_disability" select="string-length($disability)>0"/> <xsl:call-template name="defs_by_labels">
<xsl:with-param name="hmi_element" select="$hmi_element"/>
<xsl:with-param name="labels">
@@ -3497,6 +3818,17 @@
<xsl:template match="widget[@type='CustomHtml']" mode="widget_defs">
<xsl:param name="hmi_element"/>
+ <xsl:variable name="disability"> + <xsl:call-template name="defs_by_labels"> + <xsl:with-param name="hmi_element" select="$hmi_element"/> + <xsl:with-param name="labels"> + <xsl:text>/disabled</xsl:text> + <xsl:with-param name="mandatory" select="'no'"/> + <xsl:value-of select="$disability"/> + <xsl:variable name="has_disability" select="string-length($disability)>0"/> <xsl:call-template name="defs_by_labels">
<xsl:with-param name="hmi_element" select="$hmi_element"/>
<xsl:with-param name="labels">
@@ -3568,6 +3900,17 @@
<xsl:template match="widget[@type='Display']" mode="widget_defs">
<xsl:param name="hmi_element"/>
+ <xsl:variable name="disability"> + <xsl:call-template name="defs_by_labels"> + <xsl:with-param name="hmi_element" select="$hmi_element"/> + <xsl:with-param name="labels"> + <xsl:text>/disabled</xsl:text> + <xsl:with-param name="mandatory" select="'no'"/> + <xsl:value-of select="$disability"/> + <xsl:variable name="has_disability" select="string-length($disability)>0"/> <xsl:variable name="format">
<xsl:call-template name="defs_by_labels">
<xsl:with-param name="hmi_element" select="$hmi_element"/>
@@ -4374,6 +4717,17 @@
<xsl:template match="widget[@type='DropDown']" mode="widget_defs">
<xsl:param name="hmi_element"/>
+ <xsl:variable name="disability"> + <xsl:call-template name="defs_by_labels"> + <xsl:with-param name="hmi_element" select="$hmi_element"/> + <xsl:with-param name="labels"> + <xsl:text>/disabled</xsl:text> + <xsl:with-param name="mandatory" select="'no'"/> + <xsl:value-of select="$disability"/> + <xsl:variable name="has_disability" select="string-length($disability)>0"/> <xsl:call-template name="defs_by_labels">
<xsl:with-param name="hmi_element" select="$hmi_element"/>
<xsl:with-param name="labels">
@@ -4512,6 +4866,17 @@
<xsl:template match="widget[@type='ForEach']" mode="widget_defs">
<xsl:param name="hmi_element"/>
+ <xsl:variable name="disability"> + <xsl:call-template name="defs_by_labels"> + <xsl:with-param name="hmi_element" select="$hmi_element"/> + <xsl:with-param name="labels"> + <xsl:text>/disabled</xsl:text> + <xsl:with-param name="mandatory" select="'no'"/> + <xsl:value-of select="$disability"/> + <xsl:variable name="has_disability" select="string-length($disability)>0"/> <xsl:if test="count(path) != 1">
<xsl:message terminate="yes">
<xsl:text>ForEach widget </xsl:text>
@@ -4751,7 +5116,7 @@
<xsl:text> update_subscriptions();
- <xsl:text> need_cache_apply.push(this);
+ <xsl:text> this.apply_cache(); <xsl:text> jumps_need_update = true;
@@ -4864,6 +5229,17 @@
<xsl:template match="widget[@type='Input']" mode="widget_defs">
<xsl:param name="hmi_element"/>
+ <xsl:variable name="disability"> + <xsl:call-template name="defs_by_labels"> + <xsl:with-param name="hmi_element" select="$hmi_element"/> + <xsl:with-param name="labels"> + <xsl:text>/disabled</xsl:text> + <xsl:with-param name="mandatory" select="'no'"/> + <xsl:value-of select="$disability"/> + <xsl:variable name="has_disability" select="string-length($disability)>0"/> <xsl:variable name="value_elt">
<xsl:call-template name="defs_by_labels">
<xsl:with-param name="hmi_element" select="$hmi_element"/>
@@ -5395,6 +5771,17 @@
<xsl:template match="widget[@type='JsonTable']" mode="widget_defs">
<xsl:param name="hmi_element"/>
+ <xsl:variable name="disability"> + <xsl:call-template name="defs_by_labels"> + <xsl:with-param name="hmi_element" select="$hmi_element"/> + <xsl:with-param name="labels"> + <xsl:text>/disabled</xsl:text> + <xsl:with-param name="mandatory" select="'no'"/> + <xsl:value-of select="$disability"/> + <xsl:variable name="has_disability" select="string-length($disability)>0"/> <xsl:call-template name="defs_by_labels">
<xsl:with-param name="hmi_element" select="$hmi_element"/>
<xsl:with-param name="labels">
@@ -5444,15 +5831,27 @@
<xsl:value-of select="@type"/>
- <xsl:text>Jump widget brings focus to a different page. Mandatory single argument
+ <xsl:text>Jump widget brings focus to a different page. Mandatory first argument <xsl:text>gives name of the page.
- <xsl:text>Optional single path is used as new reference when jumping to a relative
- <xsl:text>page, it must point to a HMI_NODE.
+ <xsl:text>If first path is pointint to HMI_NODE variable is used as new reference + <xsl:text>when jumping to a relative page. + <xsl:text>Additional arguments are unordered options: + <xsl:text>- Absolute: force page jump to be not relative even if first path is of type HMI_NODE + <xsl:text>- name=value: Notify PLC about jump by setting variable with path having same name assigned @@ -5462,9 +5861,47 @@
- <xsl:text>"disabled" labeled element, if provided, is shown instead of "active" or
- <xsl:text>"inactive" widget when pointed HMI_NODE is null.
+ <xsl:text>Relative jump: + <xsl:text>HMI:Jump:RelativePage@/PUMP9 + <xsl:text>HMI:Jump:RelativePage@/PUMP9@role=.userrole#role=="admin" + <xsl:text>Absolute jump: + <xsl:text>HMI:Jump:AbsolutePage + <xsl:text>HMI:Jump:AbsolutePage@role=.userrole#role=="admin" + <xsl:text>Forced absolute jump: + <xsl:text>HMI:Jump:AbsolutePage:Absolute@/PUMP9 + <xsl:text>HMI:Jump:AbsolutePage:Absolute:notify=1@notify=/PUMP9 + <xsl:text>Jump with feedback + <xsl:text>HMI:Jump:AbsolutePage:notify=1@notify=.did_jump @@ -5484,72 +5921,10 @@
<xsl:text> activable = false;
- <xsl:text> active = false;
- <xsl:text> disabled = false;
<xsl:text> frequency = 2;
- <xsl:text> update_activity() {
- <xsl:text> if(this.active) {
- <xsl:text> /* show active */
- <xsl:text> this.active_elt.style.display = "";
- <xsl:text> /* hide inactive */
- <xsl:text> this.inactive_elt.style.display = "none";
- <xsl:text> /* show inactive */
- <xsl:text> this.inactive_elt.style.display = "";
- <xsl:text> /* hide active */
- <xsl:text> this.active_elt.style.display = "none";
- <xsl:text> update_disability() {
- <xsl:text> if(this.disabled) {
- <xsl:text> /* show disabled */
- <xsl:text> this.disabled_elt.style.display = "";
- <xsl:text> /* hide inactive */
- <xsl:text> this.inactive_elt.style.display = "none";
- <xsl:text> /* hide active */
- <xsl:text> this.active_elt.style.display = "none";
- <xsl:text> /* hide disabled */
- <xsl:text> this.disabled_elt.style.display = "none";
- <xsl:text> this.update_activity();
<xsl:text> make_on_click() {
<xsl:text> let that = this;
@@ -5558,18 +5933,28 @@
<xsl:text> return function(evt){
- <xsl:text> /* TODO: in order to allow jumps to page selected through for exemple a dropdown,
- <xsl:text> support path pointing to local variable whom value
- <xsl:text> would be an HMI_TREE index and then jump to a relative page not hard-coded in advance */
- <xsl:text> if(!that.disabled) {
- <xsl:text> const index = that.indexes.length > 0 ? that.indexes[0] + that.offset : undefined;
+ <xsl:text> /* TODO: in order to allow jumps to page selected through + <xsl:text> for exemple a dropdown, support path pointing to local + <xsl:text> variable whom value would be an HMI_TREE index and then + <xsl:text> jump to a relative page not hard-coded in advance + <xsl:text> if(that.enable_state) { + <xsl:text> const index = + <xsl:text> (that.is_relative && that.indexes.length > 0) ? + <xsl:text> that.indexes[0] + that.offset : undefined; <xsl:text> fading_page_switch(name, index);
+ <xsl:text> that.notify(); @@ -5580,96 +5965,122 @@
<xsl:text> notify_page_change(page_name, index) {
+ <xsl:text> // called from animate() <xsl:text> if(this.activable) {
<xsl:text> const ref_index = this.indexes.length > 0 ? this.indexes[0] + this.offset : undefined;
<xsl:text> const ref_name = this.args[0];
- <xsl:text> this.active = ((ref_name == undefined || ref_name == page_name) && index == ref_index);
- <xsl:text> this.update_state();
+ <xsl:text> this.activity_state = ((ref_name == undefined || ref_name == page_name) && index == ref_index); + <xsl:text> // Since called from animate, update activity directly + <xsl:text> if(this.enable_displayed_state && this.has_activity) { + <xsl:text> this.animate_activity();
- <xsl:text> dispatch(value) {
- <xsl:text> this.disabled = !Number(value);
- <xsl:text> // TODO : use RequestAnimate and animate()
- <xsl:text> this.update_state();
+ <func:function name="func:is_relative_jump"> + <xsl:param name="widget"/> + <func:result select="$widget/path and $widget/path[1]/@type='HMI_NODE' and not($widget/arg[position()>1 and @value = 'Absolute'])"/> <xsl:template match="widget[@type='Jump']" mode="widget_defs">
<xsl:param name="hmi_element"/>
- <xsl:variable name="activity">
+ <xsl:variable name="disability"> <xsl:call-template name="defs_by_labels">
<xsl:with-param name="hmi_element" select="$hmi_element"/>
<xsl:with-param name="labels">
- <xsl:text>active inactive</xsl:text>
+ <xsl:text>/disabled</xsl:text> <xsl:with-param name="mandatory" select="'no'"/>
- <xsl:variable name="have_activity" select="string-length($activity)>0"/>
- <xsl:value-of select="$activity"/>
- <xsl:variable name="disability">
+ <xsl:value-of select="$disability"/> + <xsl:variable name="has_disability" select="string-length($disability)>0"/> + <xsl:text> activable_sub:{ + <xsl:variable name="activity"> <xsl:call-template name="defs_by_labels">
<xsl:with-param name="hmi_element" select="$hmi_element"/>
<xsl:with-param name="labels">
- <xsl:text>disabled</xsl:text>
+ <xsl:text>/active /inactive</xsl:text> - <xsl:with-param name="mandatory" select="'no'"/>
+ <xsl:with-param name="mandatory"> + <xsl:text>no</xsl:text> - <xsl:variable name="have_disability" select="$have_activity and string-length($disability)>0"/>
- <xsl:value-of select="$disability"/>
+ <xsl:value-of select="$activity"/> + <xsl:variable name="has_activity" select="string-length($activity)>0"/> + <xsl:text> has_activity: </xsl:text> + <xsl:value-of select="$has_activity"/> + <xsl:variable name="jump_disability" select="$has_activity and $has_disability"/> <xsl:text> init: function() {
<xsl:text> this.element.onclick = this.make_on_click();
- <xsl:if test="$have_activity">
+ <xsl:if test="$has_activity"> <xsl:text> this.activable = true;
- <xsl:if test="not($have_disability)">
- <xsl:text> this.unsubscribable = true;
- <xsl:text> this.update_state = </xsl:text>
+ <xsl:text> this.is_relative = </xsl:text> - <xsl:when test="$have_disability">
- <xsl:text>this.update_disability</xsl:text>
- <xsl:when test="$have_activity">
- <xsl:text>this.update_activity</xsl:text>
+ <xsl:when test="func:is_relative_jump(.)"> + <xsl:text>true</xsl:text> - <xsl:text>null</xsl:text>
+ <xsl:text>false</xsl:text> + <xsl:text> notify: function() { + <xsl:variable name="paths" select="path"/> + <xsl:for-each select="arg[position()>1 and contains(@value,'=')]"> + <xsl:variable name="name" select="substring-before(@value,'=')"/> + <xsl:variable name="value" select="substring-after(@value,'=')"/> + <xsl:variable name="index"> + <xsl:for-each select="$paths"> + <xsl:if test="@assign = $name"> + <xsl:value-of select="position()-1"/> + <xsl:text> // </xsl:text> + <xsl:value-of select="@value"/> + <xsl:text> this.apply_hmi_value(</xsl:text> + <xsl:value-of select="$index"/> + <xsl:text>, </xsl:text> + <xsl:value-of select="$value"/> <xsl:template match="widget[@type='Jump']" mode="widget_page">
<xsl:param name="page_desc"/>
<xsl:param name="page_desc"/>
+ <xsl:if test="func:is_relative_jump(.)"> <xsl:variable name="target_page_name">
@@ -5754,6 +6165,8 @@
<xsl:text>function update_jumps() {
+ <xsl:text> // called from animate() <xsl:text> page_desc[current_visible_page].jumps.map(w=>w.notify_page_change(current_visible_page,current_page_index));
<xsl:text> jumps_need_update = false;
@@ -6002,7 +6415,7 @@
<xsl:text> this._shift = this.shift;
- <xsl:text> set_activation_state(this.Shift_sub, this.shift);
+ <xsl:text> set_activity_state(this.Shift_sub, this.shift); @@ -6010,7 +6423,7 @@
<xsl:text> this._caps = this.caps;
- <xsl:text> set_activation_state(this.CapsLock_sub, this.caps);
+ <xsl:text> set_activity_state(this.CapsLock_sub, this.caps); @@ -6021,6 +6434,17 @@
<xsl:template match="widget[@type='Keypad']" mode="widget_defs">
<xsl:param name="hmi_element"/>
+ <xsl:variable name="disability"> + <xsl:call-template name="defs_by_labels"> + <xsl:with-param name="hmi_element" select="$hmi_element"/> + <xsl:with-param name="labels"> + <xsl:text>/disabled</xsl:text> + <xsl:with-param name="mandatory" select="'no'"/> + <xsl:value-of select="$disability"/> + <xsl:variable name="has_disability" select="string-length($disability)>0"/> <xsl:call-template name="defs_by_labels">
<xsl:with-param name="hmi_element" select="$hmi_element"/>
<xsl:with-param name="labels">
@@ -6113,6 +6537,17 @@
<xsl:template match="widget[@type='List']" mode="widget_defs">
<xsl:param name="hmi_element"/>
+ <xsl:variable name="disability"> + <xsl:call-template name="defs_by_labels"> + <xsl:with-param name="hmi_element" select="$hmi_element"/> + <xsl:with-param name="labels"> + <xsl:text>/disabled</xsl:text> + <xsl:with-param name="mandatory" select="'no'"/> + <xsl:value-of select="$disability"/> + <xsl:variable name="has_disability" select="string-length($disability)>0"/> <xsl:for-each select="$hmi_element/*[@inkscape:label]">
@@ -6177,6 +6612,17 @@
<xsl:template match="widget[@type='ListSwitch']" mode="widget_defs">
<xsl:param name="hmi_element"/>
+ <xsl:variable name="disability"> + <xsl:call-template name="defs_by_labels"> + <xsl:with-param name="hmi_element" select="$hmi_element"/> + <xsl:with-param name="labels"> + <xsl:text>/disabled</xsl:text> + <xsl:with-param name="mandatory" select="'no'"/> + <xsl:value-of select="$disability"/> + <xsl:variable name="has_disability" select="string-length($disability)>0"/> <xsl:variable name="targetid" select="substring-after($hmi_element/@xlink:href,'#')"/>
<xsl:variable name="from_list" select="$hmi_lists[(@id | */@id) = $targetid]"/>
<xsl:text> dispatch: function(value) {
@@ -6283,6 +6729,17 @@
<xsl:template match="widget[@type='Meter']" mode="widget_defs">
<xsl:param name="hmi_element"/>
+ <xsl:variable name="disability"> + <xsl:call-template name="defs_by_labels"> + <xsl:with-param name="hmi_element" select="$hmi_element"/> + <xsl:with-param name="labels"> + <xsl:text>/disabled</xsl:text> + <xsl:with-param name="mandatory" select="'no'"/> + <xsl:value-of select="$disability"/> + <xsl:variable name="has_disability" select="string-length($disability)>0"/> <xsl:call-template name="defs_by_labels">
<xsl:with-param name="hmi_element" select="$hmi_element"/>
<xsl:with-param name="labels">
@@ -6299,6 +6756,17 @@
<xsl:template match="widget[@type='MultiState']" mode="widget_defs">
<xsl:param name="hmi_element"/>
+ <xsl:variable name="disability"> + <xsl:call-template name="defs_by_labels"> + <xsl:with-param name="hmi_element" select="$hmi_element"/> + <xsl:with-param name="labels"> + <xsl:text>/disabled</xsl:text> + <xsl:with-param name="mandatory" select="'no'"/> + <xsl:value-of select="$disability"/> + <xsl:variable name="has_disability" select="string-length($disability)>0"/> <xsl:text>Mutlistateh widget hides all subelements whose label do not match given
@@ -6414,6 +6882,17 @@
<xsl:template match="widget[@type='MultiState']" mode="widget_defs">
<xsl:param name="hmi_element"/>
+ <xsl:variable name="disability"> + <xsl:call-template name="defs_by_labels"> + <xsl:with-param name="hmi_element" select="$hmi_element"/> + <xsl:with-param name="labels"> + <xsl:text>/disabled</xsl:text> + <xsl:with-param name="mandatory" select="'no'"/> + <xsl:value-of select="$disability"/> + <xsl:variable name="has_disability" select="string-length($disability)>0"/> <xsl:variable name="regex" select="'^("[^"].*"|\-?[0-9]+|false|true)(#.*)?$'"/>
@@ -6776,6 +7255,17 @@
<xsl:template match="widget[@type='PathSlider']" mode="widget_defs">
<xsl:param name="hmi_element"/>
+ <xsl:variable name="disability"> + <xsl:call-template name="defs_by_labels"> + <xsl:with-param name="hmi_element" select="$hmi_element"/> + <xsl:with-param name="labels"> + <xsl:text>/disabled</xsl:text> + <xsl:with-param name="mandatory" select="'no'"/> + <xsl:value-of select="$disability"/> + <xsl:variable name="has_disability" select="string-length($disability)>0"/> <xsl:call-template name="defs_by_labels">
<xsl:with-param name="hmi_element" select="$hmi_element"/>
<xsl:with-param name="labels">
@@ -6984,6 +7474,17 @@
<xsl:template match="widget[@type='ScrollBar']" mode="widget_defs">
<xsl:param name="hmi_element"/>
+ <xsl:variable name="disability"> + <xsl:call-template name="defs_by_labels"> + <xsl:with-param name="hmi_element" select="$hmi_element"/> + <xsl:with-param name="labels"> + <xsl:text>/disabled</xsl:text> + <xsl:with-param name="mandatory" select="'no'"/> + <xsl:value-of select="$disability"/> + <xsl:variable name="has_disability" select="string-length($disability)>0"/> <xsl:call-template name="defs_by_labels">
<xsl:with-param name="hmi_element" select="$hmi_element"/>
<xsl:with-param name="labels">
@@ -7711,6 +8212,17 @@
<xsl:template match="widget[@type='Slider']" mode="widget_defs">
<xsl:param name="hmi_element"/>
+ <xsl:variable name="disability"> + <xsl:call-template name="defs_by_labels"> + <xsl:with-param name="hmi_element" select="$hmi_element"/> + <xsl:with-param name="labels"> + <xsl:text>/disabled</xsl:text> + <xsl:with-param name="mandatory" select="'no'"/> + <xsl:value-of select="$disability"/> + <xsl:variable name="has_disability" select="string-length($disability)>0"/> <xsl:call-template name="defs_by_labels">
<xsl:with-param name="hmi_element" select="$hmi_element"/>
<xsl:with-param name="labels">
@@ -7814,6 +8326,17 @@
<xsl:template match="widget[@type='Switch']" mode="widget_defs">
<xsl:param name="hmi_element"/>
+ <xsl:variable name="disability"> + <xsl:call-template name="defs_by_labels"> + <xsl:with-param name="hmi_element" select="$hmi_element"/> + <xsl:with-param name="labels"> + <xsl:text>/disabled</xsl:text> + <xsl:with-param name="mandatory" select="'no'"/> + <xsl:value-of select="$disability"/> + <xsl:variable name="has_disability" select="string-length($disability)>0"/> <xsl:variable name="regex" select="'^("[^"].*"|\-?[0-9]+|false|true)(#.*)?$'"/>
@@ -7887,6 +8410,17 @@
<xsl:template match="widget[@type='TextList']" mode="widget_defs">
<xsl:param name="hmi_element"/>
+ <xsl:variable name="disability"> + <xsl:call-template name="defs_by_labels"> + <xsl:with-param name="hmi_element" select="$hmi_element"/> + <xsl:with-param name="labels"> + <xsl:text>/disabled</xsl:text> + <xsl:with-param name="mandatory" select="'no'"/> + <xsl:value-of select="$disability"/> + <xsl:variable name="has_disability" select="string-length($disability)>0"/> <xsl:for-each select="func:refered_elements($hmi_element/*[@inkscape:label])[self::svg:text]">
@@ -7933,6 +8467,17 @@
<xsl:template match="widget[@type='TextStyleList']" mode="widget_defs">
<xsl:param name="hmi_element"/>
+ <xsl:variable name="disability"> + <xsl:call-template name="defs_by_labels"> + <xsl:with-param name="hmi_element" select="$hmi_element"/> + <xsl:with-param name="labels"> + <xsl:text>/disabled</xsl:text> + <xsl:with-param name="mandatory" select="'no'"/> + <xsl:value-of select="$disability"/> + <xsl:variable name="has_disability" select="string-length($disability)>0"/> <xsl:for-each select="$hmi_element/*[@inkscape:label]">
@@ -7981,8 +8526,6 @@
<xsl:text> frequency = 5;
<xsl:text> active_style = undefined;
<xsl:text> inactive_style = undefined;
@@ -7991,7 +8534,7 @@
<xsl:text> dispatch(value) {
- <xsl:text> this.state = value;
+ <xsl:text> this.activity_state = Boolean(value); <xsl:text> //redraw toggle button
@@ -8005,9 +8548,9 @@
<xsl:text> //toggle state and apply
- <xsl:text> this.state = this.state ? false : true;
- <xsl:text> this.apply_hmi_value(0, this.state);
+ <xsl:text> this.activity_state = this.activity_state ? false : true; + <xsl:text> this.apply_hmi_value(0, this.activity_state); @@ -8019,21 +8562,11 @@
- <xsl:text> // redraw toggle button on screen refresh
- <xsl:text> this.set_activation_state(this.state);
<xsl:text> this.element.onclick = (evt) => this.on_click(evt);
- <xsl:text> this.set_activation_state(undefined);
+ <xsl:text> this.activity_state = undefined; @@ -8042,16 +8575,37 @@
<xsl:template match="widget[@type='ToggleButton']" mode="widget_defs">
<xsl:param name="hmi_element"/>
+ <xsl:variable name="disability"> + <xsl:call-template name="defs_by_labels"> + <xsl:with-param name="hmi_element" select="$hmi_element"/> + <xsl:with-param name="labels"> + <xsl:text>/disabled</xsl:text> + <xsl:with-param name="mandatory" select="'no'"/> + <xsl:value-of select="$disability"/> + <xsl:variable name="has_disability" select="string-length($disability)>0"/> <xsl:text> activable_sub:{
- <xsl:call-template name="defs_by_labels">
- <xsl:with-param name="hmi_element" select="$hmi_element"/>
- <xsl:with-param name="labels">
- <xsl:text>/active /inactive</xsl:text>
- <xsl:with-param name="mandatory" select="'warn'"/>
+ <xsl:variable name="activity"> + <xsl:call-template name="defs_by_labels"> + <xsl:with-param name="hmi_element" select="$hmi_element"/> + <xsl:with-param name="labels"> + <xsl:text>/active /inactive</xsl:text> + <xsl:with-param name="mandatory"> + <xsl:text>warn</xsl:text> + <xsl:value-of select="$activity"/> + <xsl:variable name="has_activity" select="string-length($activity)>0"/> + <xsl:text> has_activity: </xsl:text> + <xsl:value-of select="$has_activity"/> <xsl:template match="widget[@type='XYGraph']" mode="widget_desc">
@@ -8525,6 +9079,17 @@
<xsl:template match="widget[@type='XYGraph']" mode="widget_defs">
<xsl:param name="hmi_element"/>
+ <xsl:variable name="disability"> + <xsl:call-template name="defs_by_labels"> + <xsl:with-param name="hmi_element" select="$hmi_element"/> + <xsl:with-param name="labels"> + <xsl:text>/disabled</xsl:text> + <xsl:with-param name="mandatory" select="'no'"/> + <xsl:value-of select="$disability"/> + <xsl:variable name="has_disability" select="string-length($disability)>0"/> <xsl:call-template name="defs_by_labels">
<xsl:with-param name="hmi_element" select="$hmi_element"/>
<xsl:with-param name="labels">
@@ -9402,6 +9967,436 @@
<body style="margin:0;overflow:hidden;user-select:none;touch-action:none;">
<xsl:copy-of select="$result_svg"/>
+ <xsl:text>From https://github.com/keyvan-m-sadeghi/pythonic + <xsl:text>Slightly modified in order to be usable in browser (i.e. not as a node.js module) + <xsl:text>The MIT License (MIT) + <xsl:text>Copyright (c) 2016 Assister.Ai + <xsl:text>Permission is hereby granted, free of charge, to any person obtaining a copy of + <xsl:text>this software and associated documentation files (the "Software"), to deal in + <xsl:text>the Software without restriction, including without limitation the rights to + <xsl:text>use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + <xsl:text>the Software, and to permit persons to whom the Software is furnished to do so, + <xsl:text>subject to the following conditions: + <xsl:text>The above copyright notice and this permission notice shall be included in all + <xsl:text>copies or substantial portions of the Software. + <xsl:text>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + <xsl:text>IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + <xsl:text>FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + <xsl:text>COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + <xsl:text>IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + <xsl:text>CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + <xsl:text>class Iterator { + <xsl:text> constructor(generator) { + <xsl:text> this[Symbol.iterator] = generator; + <xsl:text> async * [Symbol.asyncIterator]() { + <xsl:text> for (const element of this) { + <xsl:text> yield await element; + <xsl:text> forEach(callback) { + <xsl:text> for (const element of this) { + <xsl:text> callback(element); + <xsl:text> map(callback) { + <xsl:text> const result = []; + <xsl:text> for (const element of this) { + <xsl:text> result.push(callback(element)); + <xsl:text> return result; + <xsl:text> filter(callback) { + <xsl:text> const result = []; + <xsl:text> for (const element of this) { + <xsl:text> if (callback(element)) { + <xsl:text> result.push(element); + <xsl:text> return result; + <xsl:text> reduce(callback, initialValue) { + <xsl:text> let empty = typeof initialValue === 'undefined'; + <xsl:text> let accumulator = initialValue; + <xsl:text> let index = 0; + <xsl:text> for (const currentValue of this) { + <xsl:text> if (empty) { + <xsl:text> accumulator = currentValue; + <xsl:text> empty = false; + <xsl:text> accumulator = callback(accumulator, currentValue, index, this); + <xsl:text> if (empty) { + <xsl:text> throw new TypeError('Reduce of empty Iterator with no initial value'); + <xsl:text> return accumulator; + <xsl:text> some(callback) { + <xsl:text> for (const element of this) { + <xsl:text> if (callback(element)) { + <xsl:text> return true; + <xsl:text> return false; + <xsl:text> every(callback) { + <xsl:text> for (const element of this) { + <xsl:text> if (!callback(element)) { + <xsl:text> return false; + <xsl:text> return true; + <xsl:text> static fromIterable(iterable) { + <xsl:text> return new Iterator(function * () { + <xsl:text> for (const element of iterable) { + <xsl:text> yield element; + <xsl:text> return Array.from(this); + <xsl:text> if (!this.currentInvokedGenerator) { + <xsl:text> this.currentInvokedGenerator = this[Symbol.iterator](); + <xsl:text> return this.currentInvokedGenerator.next(); + <xsl:text> delete this.currentInvokedGenerator; + <xsl:text>function rangeSimple(stop) { + <xsl:text> return new Iterator(function * () { + <xsl:text> for (let i = 0; i < stop; i++) { + <xsl:text>function rangeOverload(start, stop, step = 1) { + <xsl:text> return new Iterator(function * () { + <xsl:text> for (let i = start; i < stop; i += step) { + <xsl:text>function range(...args) { + <xsl:text> if (args.length < 2) { + <xsl:text> return rangeSimple(...args); + <xsl:text> return rangeOverload(...args); + <xsl:text>function enumerate(iterable) { + <xsl:text> return new Iterator(function * () { + <xsl:text> let index = 0; + <xsl:text> for (const element of iterable) { + <xsl:text> yield [index, element]; + <xsl:text>const _zip = longest => (...iterables) => { + <xsl:text> if (iterables.length == 0) { + <xsl:text> // works starting with 1 iterable + <xsl:text> // [a,b,c] -> [[a],[b],[c]] + <xsl:text> // [a,b,c],[d,e,f] -> [[a,d],[b,e],[c,f]] + <xsl:text> throw new TypeError("zip takes 1 iterables at least, "+iterables.length+" given"); + <xsl:text> return new Iterator(function * () { + <xsl:text> const iterators = iterables.map(iterable => Iterator.fromIterable(iterable)); + <xsl:text> while (true) { + <xsl:text> const row = iterators.map(iterator => iterator.next()); + <xsl:text> const check = longest ? row.every.bind(row) : row.some.bind(row); + <xsl:text> if (check(next => next.done)) { + <xsl:text> yield row.map(next => next.value); + <xsl:text>const zip = _zip(false), zipLongest= _zip(true); + <xsl:text>function items(obj) { + <xsl:text> let {keys, get} = obj; + <xsl:text> if (obj instanceof Map) { + <xsl:text> keys = keys.bind(obj); + <xsl:text> get = get.bind(obj); + <xsl:text> keys = function () { + <xsl:text> return Object.keys(obj); + <xsl:text> get = function (key) { + <xsl:text> return obj[key]; + <xsl:text> return new Iterator(function * () { + <xsl:text> for (const key of keys()) { + <xsl:text> yield [key, get(key)]; + <xsl:text>module.exports = {Iterator, range, enumerate, zip: _zip(false), zipLongest: _zip(true), items}; @@ -10000,438 +10995,10 @@
<xsl:text>}(); // eslint-disable-line
- <xsl:text>From https://github.com/keyvan-m-sadeghi/pythonic
- <xsl:text>Slightly modified in order to be usable in browser (i.e. not as a node.js module)
- <xsl:text>The MIT License (MIT)
- <xsl:text>Copyright (c) 2016 Assister.Ai
- <xsl:text>Permission is hereby granted, free of charge, to any person obtaining a copy of
- <xsl:text>this software and associated documentation files (the "Software"), to deal in
- <xsl:text>the Software without restriction, including without limitation the rights to
- <xsl:text>use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
- <xsl:text>the Software, and to permit persons to whom the Software is furnished to do so,
- <xsl:text>subject to the following conditions:
- <xsl:text>The above copyright notice and this permission notice shall be included in all
- <xsl:text>copies or substantial portions of the Software.
- <xsl:text>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- <xsl:text>IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
- <xsl:text>FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
- <xsl:text>COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
- <xsl:text>IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- <xsl:text>CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- <xsl:text>class Iterator {
- <xsl:text> constructor(generator) {
- <xsl:text> this[Symbol.iterator] = generator;
- <xsl:text> async * [Symbol.asyncIterator]() {
- <xsl:text> for (const element of this) {
- <xsl:text> yield await element;
- <xsl:text> forEach(callback) {
- <xsl:text> for (const element of this) {
- <xsl:text> callback(element);
- <xsl:text> map(callback) {
- <xsl:text> const result = [];
- <xsl:text> for (const element of this) {
- <xsl:text> result.push(callback(element));
- <xsl:text> return result;
- <xsl:text> filter(callback) {
- <xsl:text> const result = [];
- <xsl:text> for (const element of this) {
- <xsl:text> if (callback(element)) {
- <xsl:text> result.push(element);
- <xsl:text> return result;
- <xsl:text> reduce(callback, initialValue) {
- <xsl:text> let empty = typeof initialValue === 'undefined';
- <xsl:text> let accumulator = initialValue;
- <xsl:text> let index = 0;
- <xsl:text> for (const currentValue of this) {
- <xsl:text> if (empty) {
- <xsl:text> accumulator = currentValue;
- <xsl:text> empty = false;
- <xsl:text> accumulator = callback(accumulator, currentValue, index, this);
- <xsl:text> if (empty) {
- <xsl:text> throw new TypeError('Reduce of empty Iterator with no initial value');
- <xsl:text> return accumulator;
- <xsl:text> some(callback) {
- <xsl:text> for (const element of this) {
- <xsl:text> if (callback(element)) {
- <xsl:text> return true;
- <xsl:text> return false;
- <xsl:text> every(callback) {
- <xsl:text> for (const element of this) {
- <xsl:text> if (!callback(element)) {
- <xsl:text> return false;
- <xsl:text> return true;
- <xsl:text> static fromIterable(iterable) {
- <xsl:text> return new Iterator(function * () {
- <xsl:text> for (const element of iterable) {
- <xsl:text> yield element;
- <xsl:text> return Array.from(this);
- <xsl:text> if (!this.currentInvokedGenerator) {
- <xsl:text> this.currentInvokedGenerator = this[Symbol.iterator]();
- <xsl:text> return this.currentInvokedGenerator.next();
- <xsl:text> delete this.currentInvokedGenerator;
- <xsl:text>function rangeSimple(stop) {
- <xsl:text> return new Iterator(function * () {
- <xsl:text> for (let i = 0; i < stop; i++) {
- <xsl:text>function rangeOverload(start, stop, step = 1) {
- <xsl:text> return new Iterator(function * () {
- <xsl:text> for (let i = start; i < stop; i += step) {
- <xsl:text>function range(...args) {
- <xsl:text> if (args.length < 2) {
- <xsl:text> return rangeSimple(...args);
- <xsl:text> return rangeOverload(...args);
- <xsl:text>function enumerate(iterable) {
- <xsl:text> return new Iterator(function * () {
- <xsl:text> let index = 0;
- <xsl:text> for (const element of iterable) {
- <xsl:text> yield [index, element];
- <xsl:text>const _zip = longest => (...iterables) => {
- <xsl:text> if (iterables.length < 2) {
- <xsl:text> throw new TypeError("zip takes 2 iterables at least, "+iterables.length+" given");
- <xsl:text> return new Iterator(function * () {
- <xsl:text> const iterators = iterables.map(iterable => Iterator.fromIterable(iterable));
- <xsl:text> while (true) {
- <xsl:text> const row = iterators.map(iterator => iterator.next());
- <xsl:text> const check = longest ? row.every.bind(row) : row.some.bind(row);
- <xsl:text> if (check(next => next.done)) {
- <xsl:text> yield row.map(next => next.value);
- <xsl:text>const zip = _zip(false), zipLongest= _zip(true);
- <xsl:text>function items(obj) {
- <xsl:text> let {keys, get} = obj;
- <xsl:text> if (obj instanceof Map) {
- <xsl:text> keys = keys.bind(obj);
- <xsl:text> get = get.bind(obj);
- <xsl:text> keys = function () {
- <xsl:text> return Object.keys(obj);
- <xsl:text> get = function (key) {
- <xsl:text> return obj[key];
- <xsl:text> return new Iterator(function * () {
- <xsl:text> for (const key of keys()) {
- <xsl:text> yield [key, get(key)];
- <xsl:text>module.exports = {Iterator, range, enumerate, zip: _zip(false), zipLongest: _zip(true), items};
- <xsl:text>var need_cache_apply = [];
<xsl:text>function dispatch_value(index, value) {
<xsl:text> let widgets = subscribers(index);
@@ -10600,20 +11167,10 @@
- <xsl:text> while(widget = need_cache_apply.pop()){
- <xsl:text> widget.apply_cache();
<xsl:text> if(jumps_need_update) update_jumps();
- <xsl:text> apply_updates();
<xsl:text> pending_widget_animates.forEach(widget => widget._animate());
@@ -10706,10 +11263,12 @@
+ <xsl:text> apply_updates(); <xsl:text> // register for rendering on next frame, since there are updates
- <xsl:text> requestHMIAnimation();
<xsl:text> } catch(err) {
<xsl:text> // 1003 is for "Unsupported Data"
@@ -11124,7 +11683,7 @@
<xsl:text> if(index > last_remote_index){
- <xsl:text> updates.set(index, value);
+ <xsl:text> dispatch_value(index, value); @@ -11138,8 +11697,6 @@
- <xsl:text> requestHMIAnimation();