svghmi/widgets_common.ysl2
branchsvghmi
changeset 3058 6ea4b7e1a9ed
parent 3040 acecaeadf20d
parent 3056 827bf284feec
child 3098 5823b73b132f
--- a/svghmi/widgets_common.ysl2	Tue Sep 15 13:57:06 2020 +0200
+++ b/svghmi/widgets_common.ysl2	Thu Sep 17 11:30:22 2020 +0200
@@ -29,8 +29,10 @@
         choose {
             when "not(@index)" {
                 choose {
-                    when "not(@type)" 
-                        error > Widget «$widget/@type» id="«$eltid»" : No match for path "«@value»" in HMI tree
+                    when "not(@type)" {
+                        warning > Widget «$widget/@type» id="«$eltid»" : No match for path "«@value»" in HMI tree
+                        > undefined`if "position()!=last()" > ,`
+                    }
                     when "@type = 'PAGE_LOCAL'" 
                         > "«@value»"`if "position()!=last()" > ,`
                     when "@type = 'HMI_LOCAL'" 
@@ -152,6 +154,7 @@
             if(!this.unsubscribable)
                 for(let i = 0; i < this.indexes.length; i++) {
                     let index = this.get_variable_index(i);
+                    if(index == undefined) continue;
                     subscribers(index).add(this);
                 }
             need_cache_apply.push(this); 
@@ -161,6 +164,7 @@
             if(!this.unsubscribable) for(let index in this.indexes){
                 /* dispatch current cache in newly opened page widgets */
                 let realindex = this.get_variable_index(index);
+                if(realindex == undefined) continue;
                 let cached_val = cache[realindex];
                 if(cached_val != undefined)
                     this._dispatch(cached_val, cached_val, index);
@@ -178,18 +182,23 @@
             }
             return index;
         }
-        change_hmi_value(index,opstr) {
-            return change_hmi_value(this.get_variable_index(index), opstr);
+        change_hmi_value(index, opstr) {
+            let realindex = this.get_variable_index(index);
+            if(realindex == undefined) return undefined;
+            return change_hmi_value(realindex, opstr);
         }
 
         apply_hmi_value(index, new_val) {
-            return apply_hmi_value(this.get_variable_index(index), new_val);
+            let realindex = this.get_variable_index(index);
+            if(realindex == undefined) return undefined;
+            return apply_hmi_value(realindex, new_val);
         }
 
         new_hmi_value(index, value, oldval) {
             // TODO avoid searching, store index at sub()
             for(let i = 0; i < this.indexes.length; i++) {
                 let refindex = this.get_variable_index(i);
+                if(refindex == undefined) continue;
 
                 if(index == refindex) {
                     this._dispatch(value, oldval, i);