--- a/svghmi/detachable_pages.ysl2 Thu Mar 11 10:35:23 2021 +0100
+++ b/svghmi/detachable_pages.ysl2 Wed Mar 17 11:07:29 2021 +0100
@@ -85,9 +85,18 @@
}
}
+const "required_page_elements",
+ "func:required_elements($hmi_pages | $keypads)/ancestor-or-self::svg:*";
+
+const "hmi_lists_descs", "$parsed_widgets/widget[@type = 'List']";
+const "hmi_lists", "$hmi_elements[@id = $hmi_lists_descs/@id]";
+
+const "required_list_elements", "func:refered_elements($hmi_lists[@id = $required_page_elements/@id])";
+
const "required_elements",
"""//svg:defs/descendant-or-self::svg:*
- | func:required_elements($hmi_pages | $keypads)/ancestor-or-self::svg:*""";
+ | $required_list_elements
+ | $required_page_elements""";
const "discardable_elements", "//svg:*[not(@id = $required_elements/@id)]";
--- a/svghmi/gen_index_xhtml.xslt Thu Mar 11 10:35:23 2021 +0100
+++ b/svghmi/gen_index_xhtml.xslt Wed Mar 17 11:07:29 2021 +0100
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
-<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: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: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()"/>
@@ -472,7 +472,11 @@
</xsl:otherwise>
</xsl:choose>
</func:function>
- <xsl:variable name="required_elements" select="//svg:defs/descendant-or-self::svg:* | func:required_elements($hmi_pages | $keypads)/ancestor-or-self::svg:*"/>
+ <xsl:variable name="required_page_elements" select="func:required_elements($hmi_pages | $keypads)/ancestor-or-self::svg:*"/>
+ <xsl:variable name="hmi_lists_descs" select="$parsed_widgets/widget[@type = 'List']"/>
+ <xsl:variable name="hmi_lists" select="$hmi_elements[@id = $hmi_lists_descs/@id]"/>
+ <xsl:variable name="required_list_elements" select="func:refered_elements($hmi_lists[@id = $required_page_elements/@id])"/>
+ <xsl:variable name="required_elements" select="//svg:defs/descendant-or-self::svg:* | $required_list_elements | $required_page_elements"/>
<xsl:variable name="discardable_elements" select="//svg:*[not(@id = $required_elements/@id)]"/>
<func:function name="func:sumarized_elements">
<xsl:param name="elements"/>
@@ -740,8 +744,6 @@
<xsl:value-of select="substring(., 2)"/>
</xsl:attribute>
</xsl:template>
- <xsl:variable name="hmi_lists_descs" select="$parsed_widgets/widget[@type = 'List']"/>
- <xsl:variable name="hmi_lists" select="$hmi_elements[@id = $hmi_lists_descs/@id]"/>
<xsl:variable name="targets_not_to_unlink" select="$hmi_lists/descendant-or-self::svg:*"/>
<xsl:variable name="to_unlink" select="$hmi_elements[not(@id = $hmi_pages/@id)]/descendant-or-self::svg:use"/>
<func:function name="func:is_unlinkable">
@@ -1693,7 +1695,7 @@
</xsl:text>
</xsl:template>
<xsl:variable name="excluded_types" select="str:split('Page VarInit VarInitPersistent')"/>
- <xsl:key name="TypesKey" match="widget" use="@type"/>
+ <xsl:key use="@type" name="TypesKey" match="widget"/>
<declarations:hmi-classes/>
<xsl:template match="declarations:hmi-classes">
<xsl:text>
@@ -4420,11 +4422,37 @@
</xsl:text>
<xsl:text>
</xsl:text>
+ <xsl:text> is_inhibited = false;
+</xsl:text>
+ <xsl:text> alert(msg){
+</xsl:text>
+ <xsl:text> this.is_inhibited = true;
+</xsl:text>
+ <xsl:text> this.display = msg;
+</xsl:text>
+ <xsl:text> setTimeout(() => this.stopalert(), 1000);
+</xsl:text>
+ <xsl:text> this.request_animate();
+</xsl:text>
+ <xsl:text> }
+</xsl:text>
+ <xsl:text>
+</xsl:text>
+ <xsl:text> stopalert(){
+</xsl:text>
+ <xsl:text> this.is_inhibited = false;
+</xsl:text>
+ <xsl:text> this.display = this.last_value;
+</xsl:text>
+ <xsl:text> this.request_animate();
+</xsl:text>
+ <xsl:text> }
+</xsl:text>
+ <xsl:text>
+</xsl:text>
<xsl:text> overshot(new_val, max) {
</xsl:text>
- <xsl:text> this.last_display = "max: "+max;
-</xsl:text>
- <xsl:text> this.request_animate();
+ <xsl:text> this.alert("max");
</xsl:text>
<xsl:text> }
</xsl:text>
@@ -4432,9 +4460,7 @@
</xsl:text>
<xsl:text> undershot(new_val, min) {
</xsl:text>
- <xsl:text> this.last_display = "min: "+min;
-</xsl:text>
- <xsl:text> this.request_animate();
+ <xsl:text> this.alert("min");
</xsl:text>
<xsl:text> }
</xsl:text>
@@ -4478,19 +4504,25 @@
<xsl:if test="$have_value or $have_edit">
<xsl:choose>
<xsl:when test="count(arg) = 1">
- <xsl:text> this.last_display = vsprintf("</xsl:text>
+ <xsl:text> this.last_value = vsprintf("</xsl:text>
<xsl:value-of select="arg[1]/@value"/>
<xsl:text>", [value]);
</xsl:text>
</xsl:when>
<xsl:otherwise>
- <xsl:text> this.last_display = value;
+ <xsl:text> this.last_value = value;
</xsl:text>
</xsl:otherwise>
</xsl:choose>
- </xsl:if>
- <xsl:if test="$have_value">
- <xsl:text> this.request_animate();
+ <xsl:text> if(!this.is_inhibited){
+</xsl:text>
+ <xsl:text> this.display = this.last_value;
+</xsl:text>
+ <xsl:if test="$have_value">
+ <xsl:text> this.request_animate();
+</xsl:text>
+ </xsl:if>
+ <xsl:text> }
</xsl:text>
</xsl:if>
<xsl:text> },
@@ -4498,7 +4530,7 @@
<xsl:if test="$have_value">
<xsl:text> animate: function(){
</xsl:text>
- <xsl:text> this.value_elt.textContent = String(this.last_display);
+ <xsl:text> this.value_elt.textContent = String(this.display);
</xsl:text>
<xsl:text> },
</xsl:text>
@@ -4510,7 +4542,7 @@
<xsl:value-of select="path/@value"/>
<xsl:text>", "</xsl:text>
<xsl:value-of select="path/@type"/>
- <xsl:text>", this, this.last_display);
+ <xsl:text>", this, this.last_value);
</xsl:text>
<xsl:if test="$have_value">
<xsl:text> this.value_elt.style.pointerEvents = "none";
@@ -4533,7 +4565,7 @@
</xsl:text>
<xsl:text> // arbitrary defaults to avoid missing entries in query
</xsl:text>
- <xsl:text> cache = [0,100,50];
+ <xsl:text> cache = [0,0,0];
</xsl:text>
<xsl:text> init_common() {
</xsl:text>
@@ -4629,6 +4661,16 @@
</xsl:text>
<xsl:text>
</xsl:text>
+ <xsl:text> sub(...args){
+</xsl:text>
+ <xsl:text> this.cache[0] = undefined;
+</xsl:text>
+ <xsl:text> super.sub(...args);
+</xsl:text>
+ <xsl:text> }
+</xsl:text>
+ <xsl:text>
+</xsl:text>
<xsl:text> dispatch(value, oldval, index) {
</xsl:text>
<xsl:text>
@@ -6794,7 +6836,7 @@
<xsl:comment>
<xsl:apply-templates select="document('')/*/debug:*"/>
</xsl:comment>
- <html xmlns="http://www.w3.org/1999/xhtml" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <html xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/1999/xhtml">
<head/>
<body style="margin:0;overflow:hidden;user-select:none;touch-action:none;">
<xsl:copy-of select="$result_svg"/>
@@ -7461,7 +7503,7 @@
</xsl:text>
<xsl:text>function apply_hmi_value(index, new_val) {
</xsl:text>
- <xsl:text> let old_val = cache[index]
+ <xsl:text> let old_val = cache[index];
</xsl:text>
<xsl:text> if(new_val != undefined && old_val != new_val)
</xsl:text>
--- a/svghmi/inline_svg.ysl2 Thu Mar 11 10:35:23 2021 +0100
+++ b/svghmi/inline_svg.ysl2 Wed Mar 17 11:07:29 2021 +0100
@@ -55,8 +55,6 @@
// For now, clone unlinkink applies to descendants of all widget except HMI:Page
// TODO: narrow application of clone unlinking to active elements,
// while keeping static decoration cloned
-const "hmi_lists_descs", "$parsed_widgets/widget[@type = 'List']";
-const "hmi_lists", "$hmi_elements[@id = $hmi_lists_descs/@id]";
const "targets_not_to_unlink", "$hmi_lists/descendant-or-self::svg:*";
const "to_unlink", "$hmi_elements[not(@id = $hmi_pages/@id)]/descendant-or-self::svg:use";
--- a/svghmi/svghmi.js Thu Mar 11 10:35:23 2021 +0100
+++ b/svghmi/svghmi.js Wed Mar 17 11:07:29 2021 +0100
@@ -313,7 +313,7 @@
};
function apply_hmi_value(index, new_val) {
- let old_val = cache[index]
+ let old_val = cache[index];
if(new_val != undefined && old_val != new_val)
send_hmi_value(index, new_val);
return new_val;
--- a/svghmi/widget_input.ysl2 Thu Mar 11 10:35:23 2021 +0100
+++ b/svghmi/widget_input.ysl2 Wed Mar 17 11:07:29 2021 +0100
@@ -10,14 +10,26 @@
this.apply_hmi_value(0, new_val);
}
- overshot(new_val, max) {
- this.last_display = "max: "+max;
+ is_inhibited = false;
+ alert(msg){
+ this.is_inhibited = true;
+ this.display = msg;
+ setTimeout(() => this.stopalert(), 1000);
this.request_animate();
}
+ stopalert(){
+ this.is_inhibited = false;
+ this.display = this.last_value;
+ this.request_animate();
+ }
+
+ overshot(new_val, max) {
+ this.alert("max");
+ }
+
undershot(new_val, min) {
- this.last_display = "min: "+min;
- this.request_animate();
+ this.alert("min");
}
@@ -45,28 +57,31 @@
if "$have_value or $have_edit" {
choose{
when "count(arg) = 1" {
- | this.last_display = vsprintf("«arg[1]/@value»", [value]);
+ | this.last_value = vsprintf("«arg[1]/@value»", [value]);
}
otherwise {
- | this.last_display = value;
+ | this.last_value = value;
}
}
+ | if(!this.is_inhibited){
+ | this.display = this.last_value;
+ if "$have_value" {
+ | this.request_animate();
}
- if "$have_value" {
- | this.request_animate();
+ | }
}
| },
if "$have_value" {
| animate: function(){
- | this.value_elt.textContent = String(this.last_display);
+ | this.value_elt.textContent = String(this.display);
| },
}
| init: function() {
if "$have_edit" {
- | this.edit_elt.onclick = () => edit_value("«path/@value»", "«path/@type»", this, this.last_display);
+ | this.edit_elt.onclick = () => edit_value("«path/@value»", "«path/@type»", this, this.last_value);
if "$have_value" {
| this.value_elt.style.pointerEvents = "none";
}
--- a/svghmi/widget_jsontable.ysl2 Thu Mar 11 10:35:23 2021 +0100
+++ b/svghmi/widget_jsontable.ysl2 Wed Mar 17 11:07:29 2021 +0100
@@ -4,7 +4,7 @@
||
class JsonTableWidget extends Widget{
// arbitrary defaults to avoid missing entries in query
- cache = [0,100,50];
+ cache = [0,0,0];
init_common() {
this.spread_json_data_bound = this.spread_json_data.bind(this);
this.handle_http_response_bound = this.handle_http_response.bind(this);
@@ -52,6 +52,11 @@
super.unsub();
}
+ sub(...args){
+ this.cache[0] = undefined;
+ super.sub(...args);
+ }
+
dispatch(value, oldval, index) {
if(this.cache[index] != value)