--- a/svghmi/widgets_common.ysl2 Thu Dec 24 17:00:43 2020 +0100
+++ b/svghmi/widgets_common.ysl2 Tue Dec 29 15:35:39 2020 +0100
@@ -45,7 +45,17 @@
- | "«@id»": new «$widget/@type»Widget ("«@id»",[«$args»],[«$indexes»],{
+ const "minmaxes" foreach "$widget/path" { + if "position()!=last()" > , + | "«@id»": new «$widget/@type»Widget ("«@id»",[«$args»],[«$indexes»],[«$minmaxes»],{ apply "$widget", mode="widget_defs" with "hmi_element",".";
| })`if "position()!=last()" > ,`
@@ -125,11 +135,12 @@
- constructor(elt_id,args,indexes,members){
+ constructor(elt_id,args,indexes,minmaxes,members){ this.element_id = elt_id;
this.element = id(elt_id);
+ this.minmaxes = minmaxes; Object.keys(members).forEach(prop => this[prop]=members[prop]);
@@ -183,17 +194,41 @@
+ overshot(new_val, max) { + undershot(new_val, min) { + clip_min_max(index, new_val) { + let minmax = this.minmaxes[index]; + if(minmax !== undefined && typeof new_val == "number") { + let [min,max] = minmax; + this.undershot(new_val, min); + this.overshot(new_val, max); change_hmi_value(index, opstr) {
let realindex = this.get_variable_index(index);
if(realindex == undefined) return undefined;
let old_val = cache[realindex];
let new_val = eval_operation_string(old_val, opstr);
+ new_val = this.clip_min_max(index, new_val); return apply_hmi_value(realindex, new_val);
apply_hmi_value(index, new_val) {
let realindex = this.get_variable_index(index);
if(realindex == undefined) return undefined;
+ new_val = this.clip_min_max(index, new_val); return apply_hmi_value(realindex, new_val);