svghmi/widgets_common.ysl2
branchsvghmi
changeset 3022 f6fe42b7ce60
parent 3017 15e2df3e5610
child 3024 0a9f6f29b7dd
equal deleted inserted replaced
3017:15e2df3e5610 3022:f6fe42b7ce60
    30             when "not(@index)" {
    30             when "not(@index)" {
    31                 choose {
    31                 choose {
    32                     when "not(@type)" 
    32                     when "not(@type)" 
    33                         error > Widget «$widget/@type» id="«$eltid»" : No match for path "«@value»" in HMI tree
    33                         error > Widget «$widget/@type» id="«$eltid»" : No match for path "«@value»" in HMI tree
    34                     when "@type = 'PAGE_LOCAL'" 
    34                     when "@type = 'PAGE_LOCAL'" 
    35                         > "«substring(1,@value)»"`if "position()!=last()" > ,`
    35                         > "«substring(@value, 1)»"`if "position()!=last()" > ,`
    36                     when "@type = 'HMI_LOCAL'" 
    36                     when "@type = 'HMI_LOCAL'" 
    37                         > hmi_local_index("«@value»")`if "position()!=last()" > ,`
    37                         > hmi_local_index("«@value»")`if "position()!=last()" > ,`
    38                 }
    38                 }
    39             }
    39             }
    40             otherwise {
    40             otherwise {
    73     ||
    73     ||
    74     let hmi_locals = {};
    74     let hmi_locals = {};
    75     var last_remote_index = hmitree_types.length - 1;
    75     var last_remote_index = hmitree_types.length - 1;
    76     var next_available_index = hmitree_types.length;
    76     var next_available_index = hmitree_types.length;
    77 
    77 
       
    78     var cache = hmitree_types.map(_ignored => undefined);
       
    79 
    78     function page_local_index(varname, pagename){
    80     function page_local_index(varname, pagename){
    79         let pagevars = hmi_locals[pagename];
    81         let pagevars = hmi_locals[pagename];
       
    82         let new_index;
    80         if(pagevars == undefined){
    83         if(pagevars == undefined){
    81             let new_index = next_available_index++;
    84             new_index = next_available_index++;
    82             hmi_locals[pagename] = {varname:new_index}
    85             hmi_locals[pagename] = {[varname]:new_index}
    83             return new_index;
       
    84         } else {
    86         } else {
    85             let result = pagevars[varname];
    87             let result = pagevars[varname];
    86             if(result==undefined){
    88             if(result != undefined) {
    87                 let new_index = next_available_index++;
    89                 return result;
    88                 pagevars[varname] = new_index;
    90             }
    89                 return new_index;
    91 
    90             }
    92             new_index = next_available_index++;
    91             return result;
    93             pagevars[varname] = new_index;
    92         }
    94         }
       
    95         cache[new_index] = "";
       
    96         return new_index;
    93     }
    97     }
    94 
    98 
    95     function hmi_local_index(varname){
    99     function hmi_local_index(varname){
    96         return page_local_index(varname, "HMI_LOCAL");
   100         return page_local_index(varname, "HMI_LOCAL");
    97     }
   101     }
   117             if(!this.unsubscribable)
   121             if(!this.unsubscribable)
   118                 for(let i = 0; i < this.indexes.length; i++) {
   122                 for(let i = 0; i < this.indexes.length; i++) {
   119                     let index = this.indexes[i];
   123                     let index = this.indexes[i];
   120                     if(this.relativeness[i])
   124                     if(this.relativeness[i])
   121                         index += this.offset;
   125                         index += this.offset;
   122                     subscribers[index].delete(this);
   126                     subscribers(index).delete(this);
   123                 }
   127                 }
   124             this.offset = 0;
   128             this.offset = 0;
   125             this.relativeness = undefined;
   129             this.relativeness = undefined;
   126         }
   130         }
   127 
   131 
   131             this.container_id = container_id ;
   135             this.container_id = container_id ;
   132             /* add this's subsribers */
   136             /* add this's subsribers */
   133             if(!this.unsubscribable)
   137             if(!this.unsubscribable)
   134                 for(let i = 0; i < this.indexes.length; i++) {
   138                 for(let i = 0; i < this.indexes.length; i++) {
   135                     let index = this.get_variable_index(i);
   139                     let index = this.get_variable_index(i);
   136                     if(index > last_remote_index) return;
   140                     subscribers(index).add(this);
   137                     subscribers[index].add(this);
       
   138                 }
   141                 }
   139             need_cache_apply.push(this); 
   142             need_cache_apply.push(this); 
   140         }
   143         }
   141 
   144 
   142         apply_cache() {
   145         apply_cache() {
   150         }
   153         }
   151 
   154 
   152         get_variable_index(varnum) {
   155         get_variable_index(varnum) {
   153             let index = this.indexes[varnum];
   156             let index = this.indexes[varnum];
   154             if(typeof(index) == "string"){
   157             if(typeof(index) == "string"){
   155                 let page = this.relativeness[varnum];
       
   156                 index = page_local_index(index, this.container_id);
   158                 index = page_local_index(index, this.container_id);
   157             } else {
   159             } else {
   158                 if(this.relativeness[varnum]){
   160                 if(this.relativeness[varnum]){
   159                     index += this.offset;
   161                     index += this.offset;
   160                 }
   162                 }