svghmi/widgets_common.ysl2
branchsvghmi
changeset 3123 f8cba959553f
parent 3121 8094494113b6
parent 3120 7ecaefe38f6f
child 3125 1fb0c07bd97b
equal deleted inserted replaced
3122:229795c03e11 3123:f8cba959553f
    61     |   "«@id»": new «$widget/@type»Widget ("«@id»",[«$args»],[«$indexes»],[«$minmaxes»],{
    61     |   "«@id»": new «$widget/@type»Widget ("«@id»",[«$args»],[«$indexes»],[«$minmaxes»],{
    62     apply "$widget", mode="widget_defs" with "hmi_element",".";
    62     apply "$widget", mode="widget_defs" with "hmi_element",".";
    63     |   })`if "position()!=last()" > ,`
    63     |   })`if "position()!=last()" > ,`
    64 }
    64 }
    65 
    65 
    66 def "func:unique_types" {
       
    67     param "elts_with_type";
       
    68     choose {
       
    69         when "count($elts_with_type) > 1" {
       
    70             const "prior_results","func:unique_types($elts_with_type[position()!=last()])";
       
    71             choose {
       
    72                 when "$elts_with_type[last()][@type = $prior_results/@type]"{
       
    73                     // type already in
       
    74                     result "$prior_results";
       
    75                 }
       
    76                 otherwise {
       
    77                     result "$prior_results | $elts_with_type[last()]";
       
    78                 }
       
    79             }
       
    80         }
       
    81         otherwise {
       
    82             result "$elts_with_type";
       
    83         }
       
    84     }
       
    85 }
       
    86 
       
    87 emit "preamble:local-variable-indexes" {
    66 emit "preamble:local-variable-indexes" {
    88     ||
    67     ||
    89     let hmi_locals = {};
    68     let hmi_locals = {};
    90     var last_remote_index = hmitree_types.length - 1;
    69     var last_remote_index = hmitree_types.length - 1;
    91     var next_available_index = hmitree_types.length;
    70     var next_available_index = hmitree_types.length;
   274         }
   253         }
   275     }
   254     }
   276     ||
   255     ||
   277 }
   256 }
   278 
   257 
       
   258 const "excluded_types", "str:split('Page VarInit')";
       
   259 
       
   260 // Key to filter unique types
       
   261 key "TypesKey", "widget", "@type";
       
   262 
   279 emit "declarations:hmi-classes" {
   263 emit "declarations:hmi-classes" {
   280     const "used_widget_types", "func:unique_types($parsed_widgets/widget)";
   264     const "used_widget_types", """$parsed_widgets/widget[
       
   265                                     generate-id() = generate-id(key('TypesKey', @type)) and 
       
   266                                     not(@type = $excluded_types)]""";
   281     apply "$used_widget_types", mode="widget_class";
   267     apply "$used_widget_types", mode="widget_class";
   282 }
   268 }
   283 
   269 
   284 template "widget", mode="widget_class"
   270 template "widget", mode="widget_class"
   285 ||
   271 ||
   286 class «@type»Widget extends Widget{
   272 class «@type»Widget extends Widget{
   287     /* empty class, as «@type» widget didn't provide any */
   273     /* empty class, as «@type» widget didn't provide any */
   288 }
   274 }
   289 ||
   275 ||
   290 
   276 
   291 const "excluded_types", "str:split('Page VarInit')";
       
   292 const "included_ids","$parsed_widgets/widget[not(@type = $excluded_types) and not(@id = $discardable_elements/@id)]/@id";
   277 const "included_ids","$parsed_widgets/widget[not(@type = $excluded_types) and not(@id = $discardable_elements/@id)]/@id";
   293 const "hmi_widgets","$hmi_elements[@id = $included_ids]";
   278 const "hmi_widgets","$hmi_elements[@id = $included_ids]";
   294 
   279 
   295 emit "declarations:hmi-elements" {
   280 emit "declarations:hmi-elements" {
   296     | var hmi_widgets = {
   281     | var hmi_widgets = {