svghmi/gen_index_xhtml.ysl2
branchsvghmi
changeset 2797 c5ba1e77f054
parent 2796 c7a22ce8c156
child 2798 ddb2c4668a6b
equal deleted inserted replaced
2796:c7a22ce8c156 2797:c5ba1e77f054
    22      * <bbox x="0" y="0" w="42" h="42">
    22      * <bbox x="0" y="0" w="42" h="42">
    23      */
    23      */
    24     const "geometry", "ns:GetSVGGeometry()";
    24     const "geometry", "ns:GetSVGGeometry()";
    25     const "hmitree", "ns:GetHMITree()";
    25     const "hmitree", "ns:GetHMITree()";
    26 
    26 
    27     const "hmi_elements", "//*[starts-with(@inkscape:label, 'HMI:')]";
    27     const "hmi_elements", "//svg:*[starts-with(@inkscape:label, 'HMI:')]";
    28     const "hmi_geometry", "$geometry[@Id = $hmi_elements/@id]";
    28     const "hmi_geometry", "$geometry[@Id = $hmi_elements/@id]";
    29 
    29 
    30     const "hmi_pages", "$hmi_elements[func:parselabel(@inkscape:label)/widget/@type = 'Page']";
    30     const "hmi_pages", "$hmi_elements[func:parselabel(@inkscape:label)/widget/@type = 'Page']";
    31 
    31 
    32     const "default_page" choose {
    32     const "default_page" choose {
   161         func:result select="exsl:node-set($ast)"
   161         func:result select="exsl:node-set($ast)"
   162     }
   162     }
   163 
   163 
   164     function "scripts"
   164     function "scripts"
   165     {
   165     {
   166         /* TODO : paste hmitree hash stored in hmi tree root node */
   166         /* paste hmitree hash stored in hmi tree root node */
       
   167         | var hmi_hash = [«$hmitree/@hash»]; 
   167 
   168 
   168         /* TODO re-enable
   169         /* TODO re-enable
   169         ||
   170         ||
   170         function evaluate_js_from_descriptions() {
   171         function evaluate_js_from_descriptions() {
   171             var Page;
   172             var Page;
   181             return res;
   182             return res;
   182         }
   183         }
   183         ||
   184         ||
   184         */
   185         */
   185 
   186 
   186         /*TODO add :
   187         | var hmi_widgets = {
   187           - pages content
   188         foreach "$hmi_elements" {
   188             + with ref to elt ?
   189             const "widget", "func:parselabel(@inkscape:label)/widget";
   189           - widgets parameters
   190             | «@id»: {
   190         */
   191             |     type: "«$widget/@type»",
   191 
   192             |     frequency: `apply "$widget", mode="refresh_frequency"`,
   192         | var hmi_index = {
   193             |     args: [
       
   194             foreach "$widget/arg"
       
   195             |         "«@value»"`if "position()!=last()" > ,`
       
   196             |     ],
       
   197             |     paths: [
       
   198             foreach "$widget/path" {
       
   199                 const "hmipath","@value";
       
   200                 const "hmitree_match","$indexed_hmitree/*[@hmipath = $hmipath]";
       
   201                 if "count($hmitree_match) = 0"
       
   202                     error > No match for HMI «$hmipath»;
       
   203             |         «$hmitree_match/@index»`if "position()!=last()" > ,`
       
   204             }
       
   205             |     ]
       
   206             | }`if "position()!=last()" > ,`
       
   207         }
       
   208         | }
       
   209         |
       
   210         | var hmi_index = [
   193 
   211 
   194         const "svg","/"; /* foreach loses document root */
   212         const "svg","/"; /* foreach loses document root */
   195         foreach "$indexed_hmitree/*" {
   213         foreach "$indexed_hmitree/*" {
   196             | «@index»: {
   214             | {   /* «@index»  «@hmipath» */
   197             |     name: "«@name»",
   215             |     type: "«local-name()»",
   198             |     hmipath: "«@hmipath»"
       
   199             |     ids: [
   216             |     ids: [
   200             const "hmipath","@hmipath";
   217             const "hmipath","@hmipath";
   201             foreach "$svg//*[substring-after(@inkscape:label,'@') = $hmipath]" {
   218             foreach "$svg//*[substring-after(@inkscape:label,'@') = $hmipath]" {
   202             |         "«@id»"`if "position()!=last()" > ,`
   219             |         hmi_widgets["«@id»"]`if "position()!=last()" > ,`
   203             }
   220             }
   204             |     ]
   221             |     ]
   205             | }`if "position()!=last()" > ,`
   222             | }`if "position()!=last()" > ,`
   206         }
   223         }
   207 
   224 
   208         | }
   225         | ]
   209         |
   226         |
   210         | var page_desc = {
   227         | var page_desc = {
   211 
   228 
   212         foreach "$hmi_pages" {
   229         foreach "$hmi_pages" {
   213             const "desc", "func:parselabel(@inkscape:label)/widget";
   230             const "desc", "func:parselabel(@inkscape:label)/widget";
       
   231             const "page", "."; 
       
   232             const "p", "$hmi_geometry[@Id = $page/@id]"; 
       
   233             const "page_ids","""$hmi_geometry[@Id != $page/@id and 
       
   234                                 @x >= $p/@x and @y >= $p/@y and 
       
   235                                 @x+@w <= $p/@x+$p/@w and @y+@h <= $p/@y+$p/@h]/@Id""";
       
   236             const "page_elements", "$hmi_elements[@id = $page_ids]";
   214             |     "«$desc/arg[1]/@value»": {
   237             |     "«$desc/arg[1]/@value»": {
   215             |         id: "«@id»",
   238             |         id: "«@id»",
   216             |         widgets: [
   239             |         widgets: [
   217             const "page", "."; 
   240             foreach "$page_ids" {
   218             const "p", "$hmi_geometry[@Id = $page/@id]"; 
   241             |             "«.»"`if "position()!=last()" > ,`
   219             foreach """$hmi_geometry[@Id != $page/@id and 
       
   220                        @x >= $p/@x and @y >= $p/@y and 
       
   221                        @x+@w <= $p/@x+$p/@w and @y+@h <= $p/@y+$p/@h]""" {
       
   222                 |             "«@Id»"`if "position()!=last()" > ,`
       
   223             }
   242             }
   224             |         ]
   243             |         ]
       
   244             |         subscriptions: [
       
   245             foreach "$page_elements" {
       
   246                 const "hmipaths", "func:parselabel(@inkscape:label)/widget/path/@value";
       
   247                 const "notlast", "position()!=last()";
       
   248                 foreach "$hmipaths" {
       
   249                     const "hmipath",".";
       
   250             |             «$indexed_hmitree/*[@hmipath = $hmipath]/@index»`if "$notlast or position()!=last()" > ,`
       
   251                 }
       
   252             }
       
   253             |         ]
       
   254             |     }`if "position()!=last()" > ,`
   225         }
   255         }
   226         | }
   256         | }
   227 
   257 
   228         |
   258         |
   229         | var default_page = "«$default_page»";
   259         | var default_page = "«$default_page»";
   289         > \n
   319         > \n
   290         apply "*", mode="testtree" {
   320         apply "*", mode="testtree" {
   291             with "indent" value "concat($indent,'>')"
   321             with "indent" value "concat($indent,'>')"
   292         };
   322         };
   293     }
   323     }
       
   324 
       
   325     template "widget", mode="refresh_frequency" > 10
       
   326     template "widget[@type='Meter']", mode="refresh_frequency" > 10
       
   327     template "widget[@type='Display']", mode="refresh_frequency" > 5
       
   328     template "widget[@type='Input']", mode="refresh_frequency" > 5
   294 }
   329 }