--- a/svghmi/gen_index_xhtml.xslt Tue Dec 29 15:39:48 2020 +0100
+++ b/svghmi/gen_index_xhtml.xslt Tue Dec 29 15:53:30 2020 +0100
@@ -59,26 +59,6 @@
- <xsl:text>var hmitree_paths = [
- <xsl:for-each select="$indexed_hmitree/*">
- <xsl:text> /* </xsl:text>
- <xsl:value-of select="@index"/>
- <xsl:value-of select="substring(local-name(), 5)"/>
- <xsl:text> */ "</xsl:text>
- <xsl:value-of select="@hmipath"/>
- <xsl:if test="position()!=last()">
@@ -978,35 +958,50 @@
<xsl:text>" in HMI tree</xsl:text>
<xsl:text>undefined</xsl:text>
- <xsl:if test="position()!=last()">
<xsl:when test="@type = 'PAGE_LOCAL'">
<xsl:value-of select="@value"/>
- <xsl:if test="position()!=last()">
<xsl:when test="@type = 'HMI_LOCAL'">
<xsl:text>hmi_local_index("</xsl:text>
<xsl:value-of select="@value"/>
- <xsl:if test="position()!=last()">
+ <xsl:message terminate="yes"> + <xsl:text>Internal error while processing widget's non indexed HMI tree path : unknown type</xsl:text> <xsl:value-of select="@index"/>
- <xsl:if test="position()!=last()">
+ <xsl:if test="position()!=last()"> + <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="position()!=last()"> @@ -1019,6 +1014,8 @@
<xsl:value-of select="$args"/>
<xsl:value-of select="$indexes"/>
+ <xsl:text>],[</xsl:text> + <xsl:value-of select="$minmaxes"/> <xsl:apply-templates mode="widget_defs" select="$widget">
@@ -1178,7 +1175,7 @@
- <xsl:text> constructor(elt_id,args,indexes,members){
+ <xsl:text> constructor(elt_id,args,indexes,minmaxes,members){ <xsl:text> this.element_id = elt_id;
@@ -1188,6 +1185,8 @@
<xsl:text> this.indexes = indexes;
+ <xsl:text> this.minmaxes = minmaxes; <xsl:text> Object.keys(members).forEach(prop => this[prop]=members[prop]);
@@ -1276,8 +1275,6 @@
<xsl:text> if(typeof(index) == "string"){
- <xsl:text> /* XXX return index as path */
<xsl:text> index = page_local_index(index, this.container_id);
@@ -1288,8 +1285,6 @@
- <xsl:text> /* XXX check for hmi_paths and return path */
@@ -1298,6 +1293,54 @@
+ <xsl:text> overshot(new_val, max) { + <xsl:text> // TODO: use a Toast + <xsl:text> undershot(new_val, min) { + <xsl:text> // TODO: use a Toast + <xsl:text> clip_min_max(index, new_val) { + <xsl:text> let minmax = this.minmaxes[index]; + <xsl:text> if(minmax !== undefined && typeof new_val == "number") { + <xsl:text> let [min,max] = minmax; + <xsl:text> if(new_val < min){ + <xsl:text> this.undershot(new_val, min); + <xsl:text> if(new_val > max){ + <xsl:text> this.overshot(new_val, max); + <xsl:text> return new_val; <xsl:text> change_hmi_value(index, opstr) {
<xsl:text> let realindex = this.get_variable_index(index);
@@ -1308,6 +1351,8 @@
<xsl:text> let new_val = eval_operation_string(old_val, opstr);
+ <xsl:text> new_val = this.clip_min_max(index, new_val); <xsl:text> return apply_hmi_value(realindex, new_val);
@@ -1320,6 +1365,8 @@
<xsl:text> if(realindex == undefined) return undefined;
+ <xsl:text> new_val = this.clip_min_max(index, new_val); <xsl:text> return apply_hmi_value(realindex, new_val);
@@ -4068,6 +4115,30 @@
+ <xsl:text> overshot(new_val, max) { + <xsl:text> this.last_display = "max: "+max; + <xsl:text> this.request_animate(); + <xsl:text> undershot(new_val, min) { + <xsl:text> this.last_display = "min: "+min; + <xsl:text> this.request_animate(); @@ -4116,11 +4187,21 @@
<xsl:if test="$have_value">
- <xsl:text> this.value_elt.textContent = String(value);
+ <xsl:text> this.last_display = value; + <xsl:text> this.request_animate(); + <xsl:if test="$have_value"> + <xsl:text> animate: function(){ + <xsl:text> this.value_elt.textContent = String(this.last_display); <xsl:text> init: function() {
<xsl:if test="$have_edit">
@@ -5139,7 +5220,7 @@
- <xsl:text> if(this.shift != this._shift){
+ <xsl:text> if(this.Shift_sub && this.shift != this._shift){ <xsl:text> this._shift = this.shift;
@@ -5147,7 +5228,7 @@
- <xsl:text> if(this.caps != this._caps){
+ <xsl:text> if(this.CapsLock_sub && this.caps != this._caps){ <xsl:text> this._caps = this.caps;