27 const "args" foreach "$widget/arg" > "«func:escape_quotes(@value)»"`if "position()!=last()" > ,` |
27 const "args" foreach "$widget/arg" > "«func:escape_quotes(@value)»"`if "position()!=last()" > ,` |
28 const "indexes" foreach "$widget/path" { |
28 const "indexes" foreach "$widget/path" { |
29 choose { |
29 choose { |
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 warning > Widget «$widget/@type» id="«$eltid»" : No match for path "«@value»" in HMI tree |
|
34 > undefined`if "position()!=last()" > ,` |
|
35 } |
34 when "@type = 'PAGE_LOCAL'" |
36 when "@type = 'PAGE_LOCAL'" |
35 > "«@value»"`if "position()!=last()" > ,` |
37 > "«@value»"`if "position()!=last()" > ,` |
36 when "@type = 'HMI_LOCAL'" |
38 when "@type = 'HMI_LOCAL'" |
37 > hmi_local_index("«@value»")`if "position()!=last()" > ,` |
39 > hmi_local_index("«@value»")`if "position()!=last()" > ,` |
38 } |
40 } |
150 this.container_id = container_id ; |
152 this.container_id = container_id ; |
151 /* add this's subsribers */ |
153 /* add this's subsribers */ |
152 if(!this.unsubscribable) |
154 if(!this.unsubscribable) |
153 for(let i = 0; i < this.indexes.length; i++) { |
155 for(let i = 0; i < this.indexes.length; i++) { |
154 let index = this.get_variable_index(i); |
156 let index = this.get_variable_index(i); |
|
157 if(index == undefined) continue; |
155 subscribers(index).add(this); |
158 subscribers(index).add(this); |
156 } |
159 } |
157 need_cache_apply.push(this); |
160 need_cache_apply.push(this); |
158 } |
161 } |
159 |
162 |
160 apply_cache() { |
163 apply_cache() { |
161 if(!this.unsubscribable) for(let index in this.indexes){ |
164 if(!this.unsubscribable) for(let index in this.indexes){ |
162 /* dispatch current cache in newly opened page widgets */ |
165 /* dispatch current cache in newly opened page widgets */ |
163 let realindex = this.get_variable_index(index); |
166 let realindex = this.get_variable_index(index); |
|
167 if(realindex == undefined) continue; |
164 let cached_val = cache[realindex]; |
168 let cached_val = cache[realindex]; |
165 if(cached_val != undefined) |
169 if(cached_val != undefined) |
166 this._dispatch(cached_val, cached_val, index); |
170 this._dispatch(cached_val, cached_val, index); |
167 } |
171 } |
168 } |
172 } |
176 index += this.offset; |
180 index += this.offset; |
177 } |
181 } |
178 } |
182 } |
179 return index; |
183 return index; |
180 } |
184 } |
181 change_hmi_value(index,opstr) { |
185 change_hmi_value(index, opstr) { |
182 return change_hmi_value(this.get_variable_index(index), opstr); |
186 let realindex = this.get_variable_index(index); |
|
187 if(realindex == undefined) return undefined; |
|
188 return change_hmi_value(realindex, opstr); |
183 } |
189 } |
184 |
190 |
185 apply_hmi_value(index, new_val) { |
191 apply_hmi_value(index, new_val) { |
186 return apply_hmi_value(this.get_variable_index(index), new_val); |
192 let realindex = this.get_variable_index(index); |
|
193 if(realindex == undefined) return undefined; |
|
194 return apply_hmi_value(realindex, new_val); |
187 } |
195 } |
188 |
196 |
189 new_hmi_value(index, value, oldval) { |
197 new_hmi_value(index, value, oldval) { |
190 // TODO avoid searching, store index at sub() |
198 // TODO avoid searching, store index at sub() |
191 for(let i = 0; i < this.indexes.length; i++) { |
199 for(let i = 0; i < this.indexes.length; i++) { |
192 let refindex = this.get_variable_index(i); |
200 let refindex = this.get_variable_index(i); |
|
201 if(refindex == undefined) continue; |
193 |
202 |
194 if(index == refindex) { |
203 if(index == refindex) { |
195 this._dispatch(value, oldval, i); |
204 this._dispatch(value, oldval, i); |
196 break; |
205 break; |
197 } |
206 } |