# HG changeset patch # User Edouard Tisserant # Date 1583348535 -3600 # Node ID 1b529ba018ad08efb5e93758692bac29cf568fc6 # Parent 525211a54b1458700164bd0e7a771517c4db4c17 SVGHMI: More precise error message on missing HMI path. Meter widget now defaults 0-100 range when min and max elements arent's present, without error. diff -r 525211a54b14 -r 1b529ba018ad svghmi/gen_index_xhtml.xslt --- a/svghmi/gen_index_xhtml.xslt Wed Mar 04 16:46:35 2020 +0100 +++ b/svghmi/gen_index_xhtml.xslt Wed Mar 04 20:02:15 2020 +0100 @@ -423,6 +423,7 @@ + " ": { @@ -453,7 +454,11 @@ - No match for path " + Widget + + id=" + + " : No match for path " " in HMI tree @@ -1295,12 +1300,21 @@ - value min max needle range + needle range + + + + value min max + + + dispatch: function(value) { - this.value_elt.textContent = String(value); + if(this.value_elt) + + this.value_elt.textContent = String(value); let [min,max,totallength] = this.range; @@ -1318,7 +1332,11 @@ init: function() { - this.range = [Number(this.min_elt.textContent), Number(this.max_elt.textContent), this.range_elt.getTotalLength()] + let min = this.min_elt ? Number(this.min_elt.textContent) : 0; + + let max = this.max_elt ? Number(this.max_elt.textContent) : 100; + + this.range = [min, max, this.range_elt.getTotalLength()] this.origin = this.needle_elt.getPointAtLength(0); diff -r 525211a54b14 -r 1b529ba018ad svghmi/gen_index_xhtml.ysl2 --- a/svghmi/gen_index_xhtml.ysl2 Wed Mar 04 16:46:35 2020 +0100 +++ b/svghmi/gen_index_xhtml.ysl2 Wed Mar 04 20:02:15 2020 +0100 @@ -535,6 +535,7 @@ | var hmi_widgets = { foreach "$hmi_elements" { const "widget", "func:parselabel(@inkscape:label)/widget"; + const "eltid","@id"; | "«@id»": { | type: "«$widget/@type»", | args: [ @@ -547,7 +548,7 @@ const "hmitree_match","$indexed_hmitree/*[@hmipath = $hmipath]"; choose { when "count($hmitree_match) = 0" { - warning > No match for path "«$hmipath»" in HMI tree + warning > Widget «$widget/@type» id="«$eltid»" : No match for path "«$hmipath»" in HMI tree } otherwise { | «$hmitree_match/@index»`if "position()!=last()" > ,` @@ -706,9 +707,11 @@ template "widget[@type='Meter']", mode="widget_defs" { param "hmi_element"; | frequency: 10, - labels("value min max needle range"); + labels("needle range"); + optional_labels("value min max"); | dispatch: function(value) { - | this.value_elt.textContent = String(value); + | if(this.value_elt) + | this.value_elt.textContent = String(value); | let [min,max,totallength] = this.range; | let length = Math.max(0,Math.min(totallength,(Number(value)-min)*totallength/(max-min))); | let tip = this.range_elt.getPointAtLength(length); @@ -717,7 +720,9 @@ | origin: undefined, | range: undefined, | init: function() { - | this.range = [Number(this.min_elt.textContent), Number(this.max_elt.textContent), this.range_elt.getTotalLength()] + | let min = this.min_elt ? Number(this.min_elt.textContent) : 0; + | let max = this.max_elt ? Number(this.max_elt.textContent) : 100; + | this.range = [min, max, this.range_elt.getTotalLength()] | this.origin = this.needle_elt.getPointAtLength(0); | }, }