# HG changeset patch # User Edouard Tisserant # Date 1656060386 -7200 # Node ID 27d298c6f96167127746573cb9e0081e140017b9 # Parent 13282f91e6ff4b003f4eac8daca254a74cd5a91d SVGHMI: force initial state of Display widget to empty string. diff -r 13282f91e6ff -r 27d298c6f961 svghmi/svghmi.js --- a/svghmi/svghmi.js Fri Jun 24 09:24:19 2022 +0200 +++ b/svghmi/svghmi.js Fri Jun 24 10:46:26 2022 +0200 @@ -229,8 +229,8 @@ return(Array.prototype.map.call(elt.children, x=>x.textContent).join("\\\\n")); } -function multiline_to_svg_text(elt, str) { - str.split('\\\\n').map((line,i) => {elt.children[i].textContent = line;}); +function multiline_to_svg_text(elt, str, blank) { + str.split('\\\\n').map((line,i) => {elt.children[i].textContent = blank?"":line;}); } function switch_langnum(langnum) { diff -r 13282f91e6ff -r 27d298c6f961 svghmi/widget_display.ysl2 --- a/svghmi/widget_display.ysl2 Fri Jun 24 09:24:19 2022 +0200 +++ b/svghmi/widget_display.ysl2 Fri Jun 24 10:46:26 2022 +0200 @@ -15,12 +15,12 @@ format string as first argument. || - shortdesc > Printf-like formated text display + shortdesc > Printf-like formated text display arg name="format" count="optional" accepts="string" > printf-like format string when not given as svg:text path name="fields" count="many" accepts="HMI_INT,HMI_REAL,HMI_STRING,HMI_BOOL" > variables to be displayed - + } @@ -28,7 +28,11 @@ || frequency = 5; dispatch(value, oldval, index) { - this.fields[index] = value; + this.fields[index] = value; + if(!this.ready){ + this.readyfields[index] = true; + this.ready = this.readyfields.every(x=>x); + } this.request_animate(); } || @@ -49,6 +53,12 @@ if "position()!=last()" > , } | fields: [«$field_initializer»], + const "readyfield_initializer" foreach "path" { + > false + if "position()!=last()" > , + } + | readyfields: [«$readyfield_initializer»], + | ready: false, | animate: function(){ choose { when "$has_format" { @@ -57,18 +67,19 @@ | this.format_elt.removeAttribute("lang"); | } | let str = vsprintf(this.format,this.fields); - | multiline_to_svg_text(this.format_elt, str); + | multiline_to_svg_text(this.format_elt, str, !this.ready); } otherwise { | let str = this.args.length == 1 ? vsprintf(this.args[0],this.fields) : this.fields.join(' '); - | multiline_to_svg_text(this.element, str); + | multiline_to_svg_text(this.element, str, !this.ready); } } | }, - | + | + | init: function() { if "$has_format" { - | init: function() { | this.format = svg_text_to_multiline(this.format_elt); + } + | this.animate(); | }, - } }