svghmi/widgets_common.ysl2
branchsvghmi
changeset 3006 bbffdefd2eed
parent 3005 ff9ae4f4e3be
child 3007 360300a8b995
equal deleted inserted replaced
3005:ff9ae4f4e3be 3006:bbffdefd2eed
   107             if(!this.unsubscribable) for(let index of this.indexes){
   107             if(!this.unsubscribable) for(let index of this.indexes){
   108                 /* dispatch current cache in newly opened page widgets */
   108                 /* dispatch current cache in newly opened page widgets */
   109                 let realindex = index+this.offset;
   109                 let realindex = index+this.offset;
   110                 let cached_val = cache[realindex];
   110                 let cached_val = cache[realindex];
   111                 if(cached_val != undefined)
   111                 if(cached_val != undefined)
   112                     dispatch_value_to_widget(this, realindex, cached_val, cached_val);
   112                     this.new_hmi_value(realindex, cached_val, cached_val);
   113             }
   113             }
   114         }
   114         }
   115 
   115 
   116         get_idx(index) {
   116         get_idx(index) {
   117              let orig = this.indexes[index];
   117              let orig = this.indexes[index];
   121             return change_hmi_value(this.get_idx(index), opstr);
   121             return change_hmi_value(this.get_idx(index), opstr);
   122         }
   122         }
   123 
   123 
   124         apply_hmi_value(index, new_val) {
   124         apply_hmi_value(index, new_val) {
   125             return apply_hmi_value(this.get_idx(0), new_val);
   125             return apply_hmi_value(this.get_idx(0), new_val);
       
   126         }
       
   127 
       
   128         new_hmi_value(index, value, oldval) {
       
   129             try {
       
   130                 // TODO avoid searching, store index at sub()
       
   131                 for(let i = 0; i < this.indexes.length; i++) {
       
   132                     let refindex = this.indexes[i];
       
   133                     if(this.relativeness[i])
       
   134                         refindex += this.offset;
       
   135 
       
   136                     if(index == refindex) {
       
   137                         let d = this.dispatch;
       
   138                         if(typeof(d) == "function"){
       
   139                             d.call(this, value, oldval, i);
       
   140                         }
       
   141                         else if(typeof(d) == "object"){
       
   142                             d[i].call(this, value, oldval);
       
   143                         }
       
   144                         /* else dispatch_0, ..., dispatch_n ? */
       
   145                         /*else {
       
   146                             throw new Error("Dunno how to dispatch to widget at index = " + index);
       
   147                         }*/
       
   148                         break;
       
   149                     }
       
   150                 }
       
   151             } catch(err) {
       
   152                 console.log(err);
       
   153             }
   126         }
   154         }
   127     }
   155     }
   128     ||
   156     ||
   129 }
   157 }
   130 
   158