|
1 // widget_page.ysl2 |
|
2 |
|
3 widget_desc("Page") { |
|
4 longdesc |
|
5 || |
|
6 |
|
7 Arguments are either: |
|
8 |
|
9 - XXX reference path TODO |
|
10 |
|
11 - name=value: setting variable with literal value. |
|
12 - name=other_name: copy variable content into another |
|
13 |
|
14 "active"+"inactive" labeled elements can be provided to show feedback when pressed |
|
15 |
|
16 Exemples: |
|
17 |
|
18 HMI:Page:notify=1@notify=/PLCVAR |
|
19 HMI:Page:ack=2:notify=1@ack=.local_var@notify=/PLCVAR |
|
20 |
|
21 || |
|
22 |
|
23 shortdesc > Page |
|
24 |
|
25 } |
|
26 |
|
27 widget_defs("Page") { |
|
28 |
|
29 | assignments: {}, |
|
30 | dispatch: function(value, oldval, varnum) { |
|
31 const "widget", "."; |
|
32 foreach "path" { |
|
33 const "varid","generate-id()"; |
|
34 const "varnum","position()-1"; |
|
35 if "@assign" foreach "$widget/path[@assign]" if "$varid = generate-id()" { |
|
36 | if(varnum == «$varnum») this.assignments["«@assign»"] = value; |
|
37 } |
|
38 } |
|
39 | }, |
|
40 | assign: function() { |
|
41 const "paths","path"; |
|
42 foreach "arg[contains(@value,'=')]"{ |
|
43 const "name","substring-before(@value,'=')"; |
|
44 const "value","substring-after(@value,'=')"; |
|
45 const "index" foreach "$paths" if "@assign = $name" value "position()-1"; |
|
46 const "isVarName", "regexp:test($value,'^[a-zA-Z_][a-zA-Z0-9_]+$')"; |
|
47 choose { |
|
48 when "$isVarName"{ |
|
49 | const «$value» = this.assignments["«$value»"]; |
|
50 | if(«$value» != undefined) |
|
51 | this.apply_hmi_value(«$index», «$value»); |
|
52 } |
|
53 otherwise { |
|
54 | this.apply_hmi_value(«$index», «$value»); |
|
55 } |
|
56 } |
|
57 } |
|
58 | }, |
|
59 } |
|
60 |