equal
deleted
inserted
replaced
22 }; |
22 }; |
23 |
23 |
24 template "svg:*", mode="hmi_elements" { |
24 template "svg:*", mode="hmi_elements" { |
25 const "widget", "func:widget(@id)"; |
25 const "widget", "func:widget(@id)"; |
26 const "eltid","@id"; |
26 const "eltid","@id"; |
27 | "«@id»": { |
27 | "«@id»": new «$widget/@type»Widget ({ |
28 | type: "«$widget/@type»", |
|
29 | args: [ |
28 | args: [ |
30 foreach "$widget/arg" |
29 foreach "$widget/arg" |
31 | "«@value»"`if "position()!=last()" > ,` |
30 | "«@value»"`if "position()!=last()" > ,` |
32 | ], |
31 | ], |
33 | offset: 0, |
32 | offset: 0, |
44 } |
43 } |
45 | ], |
44 | ], |
46 | element: id("«@id»"), |
45 | element: id("«@id»"), |
47 apply "$widget", mode="widget_defs" with "hmi_element","."; |
46 apply "$widget", mode="widget_defs" with "hmi_element","."; |
48 apply "$widget", mode="widget_subscribe" with "hmi_element","."; |
47 apply "$widget", mode="widget_subscribe" with "hmi_element","."; |
49 | }`if "position()!=last()" > ,` |
48 | })`if "position()!=last()" > ,` |
|
49 } |
50 |
50 |
51 def "func:unique_types" { |
51 def "func:unique_types" { |
52 param "elts_with_type"; |
52 param "elts_with_type"; |
53 choose { |
53 choose { |
54 when "count($elts_with_type) > 1" { |
54 when "count($elts_with_type) > 1" { |
67 result "$elts_with_type"; |
67 result "$elts_with_type"; |
68 } |
68 } |
69 } |
69 } |
70 } |
70 } |
71 |
71 |
|
72 emit "preamble:widget-base-class" { |
|
73 || |
|
74 class Widget { |
|
75 constructor(members){ |
|
76 Object.keys(members).forEach(prop => this[prop]=members[prop]); |
|
77 } |
|
78 } |
|
79 || |
|
80 } |
|
81 |
72 emit "preamble:hmi-classes" { |
82 emit "preamble:hmi-classes" { |
73 const "used_widget_types", "func:unique_types($parsed_widgets/widget)"; |
83 const "used_widget_types", "func:unique_types($parsed_widgets/widget)"; |
74 apply "$used_widget_types", mode="widget_class"; |
84 apply "$used_widget_types", mode="widget_class"; |
75 } |
85 } |
|
86 |
|
87 template "widget", mode="widget_class" |
|
88 || |
|
89 class «@type»Widget extends Widget{ |
|
90 /* empty class, as «@type» widget didn't provide any */ |
|
91 } |
|
92 || |
76 |
93 |
77 emit "preamble:hmi-elements" { |
94 emit "preamble:hmi-elements" { |
78 | var hmi_widgets = { |
95 | var hmi_widgets = { |
79 apply "$hmi_elements", mode="hmi_elements"; |
96 apply "$hmi_elements", mode="hmi_elements"; |
80 | } |
97 | } |
81 } |
98 } |
|
99 |
82 |
100 |
83 // default : normal subscribing |
101 // default : normal subscribing |
84 template "widget", mode="widget_subscribe" { |
102 template "widget", mode="widget_subscribe" { |
85 | sub: subscribe, |
103 | sub: subscribe, |
86 | unsub: unsubscribe, |
104 | unsub: unsubscribe, |