# HG changeset patch # User Edouard Tisserant # Date 1615975649 -3600 # Node ID 26b7c4aa7b3844f3a2691e01696208cfa304b4d0 # Parent 80dd371e15bb8cb6d771234bf6348c3cb689b3df# Parent 9038655c1b187b1a94983eb48b6f92ed42cde23f merged diff -r 9038655c1b18 -r 26b7c4aa7b38 svghmi/detachable_pages.ysl2 --- 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)]"; diff -r 9038655c1b18 -r 26b7c4aa7b38 svghmi/gen_index_xhtml.xslt --- 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 @@ - - + + @@ -472,7 +472,11 @@ - + + + + + @@ -740,8 +744,6 @@ - - @@ -1693,7 +1695,7 @@ - + @@ -4420,11 +4422,37 @@ + 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.last_display = "max: "+max; - - this.request_animate(); + this.alert("max"); } @@ -4432,9 +4460,7 @@ undershot(new_val, min) { - this.last_display = "min: "+min; - - this.request_animate(); + this.alert("min"); } @@ -4478,19 +4504,25 @@ - this.last_display = vsprintf(" + this.last_value = vsprintf(" ", [value]); - this.last_display = value; + this.last_value = value; - - - this.request_animate(); + if(!this.is_inhibited){ + + this.display = this.last_value; + + + this.request_animate(); + + + } }, @@ -4498,7 +4530,7 @@ animate: function(){ - this.value_elt.textContent = String(this.last_display); + this.value_elt.textContent = String(this.display); }, @@ -4510,7 +4542,7 @@ ", " - ", this, this.last_display); + ", this, this.last_value); this.value_elt.style.pointerEvents = "none"; @@ -4533,7 +4565,7 @@ // arbitrary defaults to avoid missing entries in query - cache = [0,100,50]; + cache = [0,0,0]; init_common() { @@ -4629,6 +4661,16 @@ + sub(...args){ + + this.cache[0] = undefined; + + super.sub(...args); + + } + + + dispatch(value, oldval, index) { @@ -6794,7 +6836,7 @@ - + @@ -7461,7 +7503,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) diff -r 9038655c1b18 -r 26b7c4aa7b38 svghmi/inline_svg.ysl2 --- 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"; diff -r 9038655c1b18 -r 26b7c4aa7b38 svghmi/svghmi.js --- 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; diff -r 9038655c1b18 -r 26b7c4aa7b38 svghmi/widget_input.ysl2 --- 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"; } diff -r 9038655c1b18 -r 26b7c4aa7b38 svghmi/widget_jsontable.ysl2 --- 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)