svghmi/widgets_common.ysl2
branchsvghmi
changeset 2948 faaf677ea99d
parent 2941 ef13a4007538
child 2949 e50908ddec60
equal deleted inserted replaced
2947:25f593573579 2948:faaf677ea99d
    45     |     ],
    45     |     ],
    46     |     element: id("«@id»"),
    46     |     element: id("«@id»"),
    47     apply "$widget", mode="widget_defs" with "hmi_element",".";
    47     apply "$widget", mode="widget_defs" with "hmi_element",".";
    48     apply "$widget", mode="widget_subscribe" with "hmi_element",".";
    48     apply "$widget", mode="widget_subscribe" with "hmi_element",".";
    49     |   }`if "position()!=last()" > ,`
    49     |   }`if "position()!=last()" > ,`
       
    50 
       
    51 def "func:unique_types" {
       
    52     param "elts_with_type";
       
    53     choose {
       
    54         when "count($elts_with_type) > 1" {
       
    55             const "prior_results","func:unique_types($elts_with_type[position()!=last()])";
       
    56             choose {
       
    57                 when "$elts_with_type[last()][@type = $prior_results/@type]"{
       
    58                     // type already in
       
    59                     result "$prior_results";
       
    60                 }
       
    61                 otherwise {
       
    62                     result "$prior_results | $elts_with_type[last()]";
       
    63                 }
       
    64             }
       
    65         }
       
    66         otherwise {
       
    67             result "$elts_with_type";
       
    68         }
       
    69     }
       
    70 }
       
    71 
       
    72 emit "preamble:hmi-classes" {
       
    73     const "used_widget_types", "func:unique_types($parsed_widgets/widget)";
       
    74     apply "$used_widget_types", mode="widget_class";
    50 }
    75 }
    51 
    76 
    52 emit "preamble:hmi-elements" {
    77 emit "preamble:hmi-elements" {
    53     | var hmi_widgets = {
    78     | var hmi_widgets = {
    54     apply "$hmi_elements", mode="hmi_elements";
    79     apply "$hmi_elements", mode="hmi_elements";