svghmi/widgets_common.ysl2
branchsvghmi
changeset 2950 1e53d8b60ee9
parent 2949 e50908ddec60
child 2951 506fe9272660
equal deleted inserted replaced
2949:e50908ddec60 2950:1e53d8b60ee9
    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»": new «$widget/@type»Widget ({
    27     const "args" foreach "$widget/arg" > "«@value»"`if "position()!=last()" > ,`
    28     |     args: [
    28     const "indexes" foreach "$widget/path" {
    29     foreach "$widget/arg"
       
    30     |         "«@value»"`if "position()!=last()" > ,`
       
    31     |     ],
       
    32     |     offset: 0,
       
    33     |     indexes: [
       
    34     foreach "$widget/path" {
       
    35         choose {
    29         choose {
    36             when "not(@index)" {
    30             when "not(@index)" {
    37                 warning > Widget «$widget/@type» id="«$eltid»" : No match for path "«@value»" in HMI tree
    31                 warning > Widget «$widget/@type» id="«$eltid»" : No match for path "«@value»" in HMI tree
    38             }
    32             }
    39             otherwise {
    33             otherwise {
    40     |         «@index» /* «@value» */ `if "position()!=last()" > ,`
    34                 > «@index»`if "position()!=last()" > ,`
    41             }
    35             }
    42         }
    36         }
    43     }
    37     }
    44     |     ],
    38 
    45     |     element: id("«@id»"),
    39     |   "«@id»": new «$widget/@type»Widget ("«@id»",[«$args»],[«$indexes»],{
    46     apply "$widget", mode="widget_defs" with "hmi_element",".";
    40     apply "$widget", mode="widget_defs" with "hmi_element",".";
    47     apply "$widget", mode="widget_subscribe" with "hmi_element",".";
    41     apply "$widget", mode="widget_subscribe" with "hmi_element",".";
    48     |   })`if "position()!=last()" > ,`
    42     |   })`if "position()!=last()" > ,`
    49 }
    43 }
    50 
    44 
    70 }
    64 }
    71 
    65 
    72 emit "preamble:widget-base-class" {
    66 emit "preamble:widget-base-class" {
    73     ||    
    67     ||    
    74     class Widget {
    68     class Widget {
    75         constructor(members){
    69         constructor(elt_id,args,indexes,members){
       
    70             this.element = id(elt_id);
       
    71             this.args = args;
       
    72             this.indexes = indexes;
       
    73             this.offset = 0;
    76             Object.keys(members).forEach(prop => this[prop]=members[prop]);
    74             Object.keys(members).forEach(prop => this[prop]=members[prop]);
    77         }
    75         }
    78     }
    76     }
    79     ||
    77     ||
    80 }
    78 }