34 xmlns:ns="beremiz" |
34 xmlns:ns="beremiz" |
35 extension-element-prefixes="ns func exsl regexp str dyn" |
35 extension-element-prefixes="ns func exsl regexp str dyn" |
36 exclude-result-prefixes="ns str regexp exsl func dyn" { |
36 exclude-result-prefixes="ns str regexp exsl func dyn" { |
37 |
37 |
38 |
38 |
|
39 include hmi_tree.ysl2 |
|
40 |
|
41 include geometry.ysl2 |
|
42 |
39 const "svg_root_id", "/svg:svg/@id"; |
43 const "svg_root_id", "/svg:svg/@id"; |
40 const "hmi_elements", "//svg:*[starts-with(@inkscape:label, 'HMI:')]"; |
44 const "hmi_elements", "//svg:*[starts-with(@inkscape:label, 'HMI:')]"; |
41 |
45 |
42 const "hmi_pages", "$hmi_elements[func:parselabel(@inkscape:label)/widget/@type = 'Page']"; |
46 include detachable_pages.ysl2 |
43 |
|
44 const "default_page" choose { |
|
45 when "count($hmi_pages) > 1" { |
|
46 const "Home_page", |
|
47 "$hmi_pages[func:parselabel(@inkscape:label)/widget/arg[1]/@value = 'Home']"; |
|
48 choose { |
|
49 when "$Home_page" > Home |
|
50 otherwise { |
|
51 error "No Home page defined!"; |
|
52 } |
|
53 } |
|
54 } |
|
55 when "count($hmi_pages) = 0" { |
|
56 error "No page defined!"; |
|
57 } |
|
58 otherwise > «func:parselabel($hmi_pages/@inkscape:label)/widget/arg[1]/@value» |
|
59 } |
|
60 |
|
61 const "_categories" { |
|
62 noindex > HMI_ROOT |
|
63 noindex > HMI_PLC_STATUS |
|
64 noindex > HMI_CURRENT_PAGE |
|
65 } |
|
66 const "categories", "exsl:node-set($_categories)"; |
|
67 |
|
68 include geometry.ysl2 |
|
69 |
|
70 include detachable_elements.ysl2 |
|
71 |
|
72 include hmi_tree.ysl2 |
|
73 |
|
74 |
|
75 def "func:is_descendant_path" { |
|
76 param "descend"; |
|
77 param "ancest"; |
|
78 result "string-length($ancest) > 0 and starts-with($descend,$ancest)"; |
|
79 } |
|
80 |
47 |
81 //////////////// Inline SVG |
48 //////////////// Inline SVG |
82 |
49 |
83 // Identity template : |
50 // Identity template : |
84 // - copy every attributes |
51 // - copy every attributes |
228 path value="path1"; |
195 path value="path1"; |
229 path value="path2"; |
196 path value="path2"; |
230 } |
197 } |
231 */ |
198 */ |
232 |
199 |
233 def "func:parselabel" { |
|
234 param "label"; |
|
235 const "description", "substring-after($label,'HMI:')"; |
|
236 |
|
237 const "_args", "substring-before($description,'@')"; |
|
238 const "args" choose { |
|
239 when "$_args" value "$_args"; |
|
240 otherwise value "$description"; |
|
241 } |
|
242 |
|
243 const "_type", "substring-before($args,':')"; |
|
244 const "type" choose { |
|
245 when "$_type" value "$_type"; |
|
246 otherwise value "$args"; |
|
247 } |
|
248 |
|
249 const "ast" if "$type" widget { |
|
250 attrib "type" > «$type» |
|
251 foreach "str:split(substring-after($args, ':'), ':')" { |
|
252 arg { |
|
253 attrib "value" > «.» |
|
254 } |
|
255 } |
|
256 const "paths", "substring-after($description,'@')"; |
|
257 foreach "str:split($paths, '@')" { |
|
258 if "string-length(.) > 0" path { |
|
259 attrib "value" > «.» |
|
260 const "path", "."; |
|
261 const "item", "$indexed_hmitree/*[@hmipath = $path]"; |
|
262 if "count($item) = 1" |
|
263 attrib "index" > «$item/@index» |
|
264 } |
|
265 } |
|
266 } |
|
267 |
|
268 result "exsl:node-set($ast)"; |
|
269 } |
|
270 |
200 |
271 function "scripts" |
201 function "scripts" |
272 { |
202 { |
273 | //(function(){ |
203 | //(function(){ |
274 | |
204 | |
339 } |
269 } |
340 | } |
270 | } |
341 |
271 |
342 | |
272 | |
343 | var page_desc = { |
273 | var page_desc = { |
344 |
274 apply "$hmi_pages", mode="page_desc"; |
345 foreach "$hmi_pages" { |
|
346 const "desc", "func:parselabel(@inkscape:label)/widget"; |
|
347 const "page", "."; |
|
348 const "p", "$geometry[@Id = $page/@id]"; |
|
349 |
|
350 const "page_all_elements", "func:all_related_elements($page)"; |
|
351 |
|
352 const "all_page_widgets","$hmi_elements[@id = $page_all_elements/@id and @id != $page/@id]"; |
|
353 |
|
354 const "page_relative_widgets", |
|
355 "$all_page_widgets[func:is_descendant_path(func:parselabel(@inkscape:label)/widget/path/@value, $desc/path/@value)]"; |
|
356 |
|
357 // Take closest ancestor in detachable_elements |
|
358 // since nested detachable elements are filtered out |
|
359 const "required_detachables", |
|
360 """func:sumarized_elements($page_all_elements)/ |
|
361 ancestor-or-self::*[@id = $detachable_elements/@id]"""; |
|
362 |
|
363 | "«$desc/arg[1]/@value»": { |
|
364 | widget: hmi_widgets["«@id»"], |
|
365 | bbox: [«$p/@x», «$p/@y», «$p/@w», «$p/@h»], |
|
366 if "$desc/path/@value" { |
|
367 if "count($desc/path/@index)=0" |
|
368 warning > Page id="«$page/@id»" : No match for path "«$desc/path/@value»" in HMI tree |
|
369 | page_index: «$desc/path/@index», |
|
370 } |
|
371 | relative_widgets: [ |
|
372 foreach "$page_relative_widgets" { |
|
373 | hmi_widgets["«@id»"]`if "position()!=last()" > ,` |
|
374 } |
|
375 | ], |
|
376 | absolute_widgets: [ |
|
377 foreach "$all_page_widgets[not(@id = $page_relative_widgets/@id)]" { |
|
378 | hmi_widgets["«@id»"]`if "position()!=last()" > ,` |
|
379 } |
|
380 | ], |
|
381 | required_detachables: { |
|
382 foreach "$required_detachables" { |
|
383 | "«@id»": detachable_elements["«@id»"]`if "position()!=last()" > ,` |
|
384 } |
|
385 | } |
|
386 | }`if "position()!=last()" > ,` |
|
387 } |
|
388 | } |
275 | } |
389 |
276 |
390 | |
277 | |
391 | var default_page = "«$default_page»"; |
278 | var default_page = "«$default_page»"; |
392 | var svg_root = id("«$svg_root_id»"); |
279 | var svg_root = id("«$svg_root_id»"); |