svghmi/gen_index_xhtml.xslt
branchsvghmi
changeset 3112 bd20f9112014
parent 3103 677764fba71d
child 3116 6da94ec04325
equal deleted inserted replaced
3111:5d9ae04ee50f 3112:bd20f9112014
     1 <?xml version="1.0"?>
     1 <?xml version="1.0"?>
     2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common" xmlns:regexp="http://exslt.org/regular-expressions" xmlns:str="http://exslt.org/strings" xmlns:func="http://exslt.org/functions" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:debug="debug" xmlns:preamble="preamble" xmlns:declarations="declarations" xmlns:definitions="definitions" xmlns:epilogue="epilogue" xmlns:ns="beremiz" version="1.0" extension-element-prefixes="ns func exsl regexp str dyn" exclude-result-prefixes="ns func exsl regexp str dyn debug preamble epilogue declarations definitions">
     2 <xsl:stylesheet xmlns:ns="beremiz" xmlns:definitions="definitions" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:func="http://exslt.org/functions" xmlns:epilogue="epilogue" xmlns:preamble="preamble" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:svg="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:str="http://exslt.org/strings" xmlns:regexp="http://exslt.org/regular-expressions" xmlns:exsl="http://exslt.org/common" xmlns:declarations="declarations" xmlns:debug="debug" exclude-result-prefixes="ns func exsl regexp str dyn debug preamble epilogue declarations definitions" extension-element-prefixes="ns func exsl regexp str dyn" version="1.0">
     3   <xsl:output cdata-section-elements="xhtml:script" method="xml"/>
     3   <xsl:output method="xml" cdata-section-elements="xhtml:script"/>
     4   <xsl:variable name="svg" select="/svg:svg"/>
     4   <xsl:variable name="svg" select="/svg:svg"/>
     5   <xsl:variable name="hmi_elements" select="//svg:*[starts-with(@inkscape:label, 'HMI:')]"/>
     5   <xsl:variable name="hmi_elements" select="//svg:*[starts-with(@inkscape:label, 'HMI:')]"/>
     6   <xsl:variable name="hmitree" select="ns:GetHMITree()"/>
     6   <xsl:variable name="hmitree" select="ns:GetHMITree()"/>
     7   <xsl:variable name="_categories">
     7   <xsl:variable name="_categories">
     8     <noindex>
     8     <noindex>
   571     <xsl:text>    ],
   571     <xsl:text>    ],
   572 </xsl:text>
   572 </xsl:text>
   573     <xsl:text>    jumps: [
   573     <xsl:text>    jumps: [
   574 </xsl:text>
   574 </xsl:text>
   575     <xsl:for-each select="$parsed_widgets/widget[@id = $all_page_widgets/@id and @type='Jump']">
   575     <xsl:for-each select="$parsed_widgets/widget[@id = $all_page_widgets/@id and @type='Jump']">
   576       <xsl:variable name="_id" select="@id"/>
   576       <xsl:text>        hmi_widgets["</xsl:text>
   577       <xsl:variable name="opts">
   577       <xsl:value-of select="@id"/>
   578         <xsl:call-template name="jump_widget_activity">
   578       <xsl:text>"]</xsl:text>
   579           <xsl:with-param name="hmi_element" select="$hmi_elements[@id=$_id]"/>
   579       <xsl:if test="position()!=last()">
   580         </xsl:call-template>
   580         <xsl:text>,</xsl:text>
   581       </xsl:variable>
       
   582       <xsl:if test="string-length($opts)&gt;0">
       
   583         <xsl:text>        hmi_widgets["</xsl:text>
       
   584         <xsl:value-of select="@id"/>
       
   585         <xsl:text>"]</xsl:text>
       
   586         <xsl:if test="position()!=last()">
       
   587           <xsl:text>,</xsl:text>
       
   588         </xsl:if>
       
   589         <xsl:text>
       
   590 </xsl:text>
       
   591       </xsl:if>
   581       </xsl:if>
       
   582       <xsl:text>
       
   583 </xsl:text>
   592     </xsl:for-each>
   584     </xsl:for-each>
   593     <xsl:text>    ],
   585     <xsl:text>    ],
   594 </xsl:text>
   586 </xsl:text>
   595     <xsl:text>    required_detachables: {
   587     <xsl:text>    required_detachables: {
   596 </xsl:text>
   588 </xsl:text>
   703   </xsl:template>
   695   </xsl:template>
   704   <xsl:template mode="inline_svg" match="sodipodi:namedview[@units!='px' or @inkscape:document-units!='px']">
   696   <xsl:template mode="inline_svg" match="sodipodi:namedview[@units!='px' or @inkscape:document-units!='px']">
   705     <xsl:message terminate="yes">
   697     <xsl:message terminate="yes">
   706       <xsl:text>All units must be set to "px" in Inkscape's document properties</xsl:text>
   698       <xsl:text>All units must be set to "px" in Inkscape's document properties</xsl:text>
   707     </xsl:message>
   699     </xsl:message>
       
   700   </xsl:template>
       
   701   <xsl:template xmlns="http://www.w3.org/2000/svg" mode="inline_svg" match="svg:text/@inkscape:label[starts-with(., '_')]">
       
   702     <xsl:attribute name="{name()}">
       
   703       <xsl:value-of select="substring(., 2)"/>
       
   704     </xsl:attribute>
   708   </xsl:template>
   705   </xsl:template>
   709   <xsl:variable name="hmi_lists_descs" select="$parsed_widgets/widget[@type = 'List']"/>
   706   <xsl:variable name="hmi_lists_descs" select="$parsed_widgets/widget[@type = 'List']"/>
   710   <xsl:variable name="hmi_lists" select="$hmi_elements[@id = $hmi_lists_descs/@id]"/>
   707   <xsl:variable name="hmi_lists" select="$hmi_elements[@id = $hmi_lists_descs/@id]"/>
   711   <xsl:variable name="targets_not_to_unlink" select="$hmi_lists/descendant-or-self::svg:*"/>
   708   <xsl:variable name="targets_not_to_unlink" select="$hmi_lists/descendant-or-self::svg:*"/>
   712   <xsl:variable name="to_unlink" select="$hmi_elements[not(@id = $hmi_pages/@id)]/descendant-or-self::svg:use"/>
   709   <xsl:variable name="to_unlink" select="$hmi_elements[not(@id = $hmi_pages/@id)]/descendant-or-self::svg:use"/>
   927 </xsl:text>
   924 </xsl:text>
   928     </xsl:for-each>
   925     </xsl:for-each>
   929     <xsl:text>
   926     <xsl:text>
   930 </xsl:text>
   927 </xsl:text>
   931   </xsl:template>
   928   </xsl:template>
       
   929   <xsl:template mode="extract_i18n" match="svg:tspan">
       
   930     <xsl:if test="string-length(.) &gt; 0">
       
   931       <line>
       
   932         <xsl:value-of select="."/>
       
   933       </line>
       
   934     </xsl:if>
       
   935   </xsl:template>
       
   936   <xsl:template mode="extract_i18n" match="svg:text">
       
   937     <msg>
       
   938       <xsl:attribute name="id">
       
   939         <xsl:value-of select="@id"/>
       
   940       </xsl:attribute>
       
   941       <xsl:attribute name="label">
       
   942         <xsl:value-of select="substring(@inkscape:label,2)"/>
       
   943       </xsl:attribute>
       
   944       <xsl:apply-templates mode="extract_i18n" select="svg:*"/>
       
   945     </msg>
       
   946   </xsl:template>
       
   947   <xsl:variable name="translatable_texts" select="//svg:text[starts-with(@inkscape:label, '_')]"/>
       
   948   <xsl:variable name="translatable_strings">
       
   949     <xsl:apply-templates mode="extract_i18n" select="$translatable_texts"/>
       
   950   </xsl:variable>
       
   951   <preamble:i18n/>
       
   952   <xsl:template match="preamble:i18n">
       
   953     <xsl:text>
       
   954 </xsl:text>
       
   955     <xsl:text>/* </xsl:text>
       
   956     <xsl:value-of select="local-name()"/>
       
   957     <xsl:text> */
       
   958 </xsl:text>
       
   959     <xsl:text>
       
   960 </xsl:text>
       
   961     <xsl:variable name="translations" select="ns:GetTranslations($translatable_strings)"/>
       
   962     <xsl:text>var translations = {
       
   963 </xsl:text>
       
   964     <xsl:for-each select="$translations/*">
       
   965       <xsl:text>    "</xsl:text>
       
   966       <xsl:value-of select="local-name()"/>
       
   967       <xsl:text>":{
       
   968 </xsl:text>
       
   969       <xsl:text>    }</xsl:text>
       
   970       <xsl:if test="position()!=last()">
       
   971         <xsl:text>,</xsl:text>
       
   972       </xsl:if>
       
   973       <xsl:text>
       
   974 </xsl:text>
       
   975     </xsl:for-each>
       
   976     <xsl:text>};
       
   977 </xsl:text>
       
   978     <xsl:text>
       
   979 </xsl:text>
       
   980     <xsl:text>
       
   981 </xsl:text>
       
   982   </xsl:template>
   932   <xsl:template mode="hmi_widgets" match="svg:*">
   983   <xsl:template mode="hmi_widgets" match="svg:*">
   933     <xsl:variable name="widget" select="func:widget(@id)"/>
   984     <xsl:variable name="widget" select="func:widget(@id)"/>
   934     <xsl:variable name="eltid" select="@id"/>
   985     <xsl:variable name="eltid" select="@id"/>
   935     <xsl:variable name="args">
   986     <xsl:variable name="args">
   936       <xsl:for-each select="$widget/arg">
   987       <xsl:for-each select="$widget/arg">
  1293 </xsl:text>
  1344 </xsl:text>
  1294     <xsl:text>
  1345     <xsl:text>
  1295 </xsl:text>
  1346 </xsl:text>
  1296     <xsl:text>    overshot(new_val, max) {
  1347     <xsl:text>    overshot(new_val, max) {
  1297 </xsl:text>
  1348 </xsl:text>
  1298     <xsl:text>        // TODO: use a Toast
       
  1299 </xsl:text>
       
  1300     <xsl:text>    }
  1349     <xsl:text>    }
  1301 </xsl:text>
  1350 </xsl:text>
  1302     <xsl:text>
  1351     <xsl:text>
  1303 </xsl:text>
  1352 </xsl:text>
  1304     <xsl:text>    undershot(new_val, min) {
  1353     <xsl:text>    undershot(new_val, min) {
  1305 </xsl:text>
       
  1306     <xsl:text>        // TODO: use a Toast
       
  1307 </xsl:text>
  1354 </xsl:text>
  1308     <xsl:text>    }
  1355     <xsl:text>    }
  1309 </xsl:text>
  1356 </xsl:text>
  1310     <xsl:text>
  1357     <xsl:text>
  1311 </xsl:text>
  1358 </xsl:text>
  2021 </xsl:text>
  2068 </xsl:text>
  2022     <xsl:text>
  2069     <xsl:text>
  2023 </xsl:text>
  2070 </xsl:text>
  2024     <xsl:text>    dispatch(value) {
  2071     <xsl:text>    dispatch(value) {
  2025 </xsl:text>
  2072 </xsl:text>
       
  2073     <xsl:text>        this.display_val = value;
       
  2074 </xsl:text>
       
  2075     <xsl:text>        this.request_animate();
       
  2076 </xsl:text>
       
  2077     <xsl:text>    }
       
  2078 </xsl:text>
       
  2079     <xsl:text>
       
  2080 </xsl:text>
       
  2081     <xsl:text>    animate(){
       
  2082 </xsl:text>
  2026     <xsl:text>        if(this.value_elt)
  2083     <xsl:text>        if(this.value_elt)
  2027 </xsl:text>
  2084 </xsl:text>
  2028     <xsl:text>            this.value_elt.textContent = String(value);
  2085     <xsl:text>            this.value_elt.textContent = String(this.display_val);
  2029 </xsl:text>
  2086 </xsl:text>
  2030     <xsl:text>        let [min,max,start,end] = this.range;
  2087     <xsl:text>        let [min,max,start,end] = this.range;
  2031 </xsl:text>
  2088 </xsl:text>
  2032     <xsl:text>        let [cx,cy] = this.center;
  2089     <xsl:text>        let [cx,cy] = this.center;
  2033 </xsl:text>
  2090 </xsl:text>
  2034     <xsl:text>        let [rx,ry] = this.proportions;
  2091     <xsl:text>        let [rx,ry] = this.proportions;
  2035 </xsl:text>
  2092 </xsl:text>
  2036     <xsl:text>        let tip = start + (end-start)*Number(value)/(max-min);
  2093     <xsl:text>        let tip = start + (end-start)*Number(this.display_val)/(max-min);
  2037 </xsl:text>
  2094 </xsl:text>
  2038     <xsl:text>        let size = 0;
  2095     <xsl:text>        let size = 0;
  2039 </xsl:text>
  2096 </xsl:text>
  2040     <xsl:text>        if (tip-start &gt; Math.PI) {
  2097     <xsl:text>
       
  2098 </xsl:text>
       
  2099     <xsl:text>        if (tip-start &gt; Math.PI)
  2041 </xsl:text>
  2100 </xsl:text>
  2042     <xsl:text>            size = 1;
  2101     <xsl:text>            size = 1;
  2043 </xsl:text>
  2102 </xsl:text>
  2044     <xsl:text>        } else {
  2103     <xsl:text>        else
  2045 </xsl:text>
  2104 </xsl:text>
  2046     <xsl:text>            size = 0;
  2105     <xsl:text>            size = 0;
  2047 </xsl:text>
  2106 </xsl:text>
  2048     <xsl:text>        }
  2107     <xsl:text>
  2049 </xsl:text>
  2108 </xsl:text>
  2050     <xsl:text>        this.path_elt.setAttribute('d', "M "+(cx+rx*Math.cos(start))+","+(cy+ry*Math.sin(start))+" A "+rx+","+ry+" 0 "+size+" 1 "+(cx+rx*Math.cos(tip))+","+(cy+ry*Math.sin(tip)));
  2109     <xsl:text>        this.path_elt.setAttribute('d', "M "+(cx+rx*Math.cos(start))+","+(cy+ry*Math.sin(start))+
       
  2110 </xsl:text>
       
  2111     <xsl:text>                                        " A "+rx+","+ry+
       
  2112 </xsl:text>
       
  2113     <xsl:text>                                        " 0 "+size+
       
  2114 </xsl:text>
       
  2115     <xsl:text>                                        " 1 "+(cx+rx*Math.cos(tip))+","+(cy+ry*Math.sin(tip)));
  2051 </xsl:text>
  2116 </xsl:text>
  2052     <xsl:text>    }
  2117     <xsl:text>    }
  2053 </xsl:text>
  2118 </xsl:text>
  2054     <xsl:text>
  2119     <xsl:text>
  2055 </xsl:text>
  2120 </xsl:text>
  2056     <xsl:text>    init() {
  2121     <xsl:text>    init() {
  2057 </xsl:text>
  2122 </xsl:text>
  2058     <xsl:text>        let start = Number(this.path_elt.getAttribute('sodipodi:start'));
  2123     <xsl:text>        let [start, end, cx, cy, rx, ry] = ["start", "end", "cx", "cy", "rx", "ry"].
  2059 </xsl:text>
  2124 </xsl:text>
  2060     <xsl:text>        let end = Number(this.path_elt.getAttribute('sodipodi:end'));
  2125     <xsl:text>            map(tag=&gt;Number(this.path_elt.getAttribute('sodipodi:'+tag)))
  2061 </xsl:text>
  2126 </xsl:text>
  2062     <xsl:text>        let cx = Number(this.path_elt.getAttribute('sodipodi:cx'));
  2127     <xsl:text>
  2063 </xsl:text>
  2128 </xsl:text>
  2064     <xsl:text>        let cy = Number(this.path_elt.getAttribute('sodipodi:cy'));
  2129     <xsl:text>        if (ry == 0) 
  2065 </xsl:text>
       
  2066     <xsl:text>        let rx = Number(this.path_elt.getAttribute('sodipodi:rx'));
       
  2067 </xsl:text>
       
  2068     <xsl:text>        let ry = Number(this.path_elt.getAttribute('sodipodi:ry'));
       
  2069 </xsl:text>
       
  2070     <xsl:text>        if (ry == 0) {
       
  2071 </xsl:text>
  2130 </xsl:text>
  2072     <xsl:text>            ry = rx;
  2131     <xsl:text>            ry = rx;
  2073 </xsl:text>
  2132 </xsl:text>
  2074     <xsl:text>        }
  2133     <xsl:text>
  2075 </xsl:text>
  2134 </xsl:text>
  2076     <xsl:text>        if (start &gt; end) {
  2135     <xsl:text>        if (start &gt; end)
  2077 </xsl:text>
  2136 </xsl:text>
  2078     <xsl:text>            end = end + 2*Math.PI;
  2137     <xsl:text>            end = end + 2*Math.PI;
  2079 </xsl:text>
  2138 </xsl:text>
  2080     <xsl:text>        }
  2139     <xsl:text>
  2081 </xsl:text>
  2140 </xsl:text>
  2082     <xsl:text>        let min = this.min_elt ?
  2141     <xsl:text>        let [min,max] = [[this.min_elt,0],[this.max_elt,100]].map(([elt,def],i)=&gt;elt?
  2083 </xsl:text>
  2142 </xsl:text>
  2084     <xsl:text>                  Number(this.min_elt.textContent) :
  2143     <xsl:text>            Number(elt.textContent) :
  2085 </xsl:text>
  2144 </xsl:text>
  2086     <xsl:text>                  this.args.length &gt;= 1 ? this.args[0] : 0;
  2145     <xsl:text>            this.args.length &gt;= i+1 ? this.args[i] : def);
  2087 </xsl:text>
  2146 </xsl:text>
  2088     <xsl:text>        let max = this.max_elt ?
  2147     <xsl:text>
  2089 </xsl:text>
       
  2090     <xsl:text>                  Number(this.max_elt.textContent) :
       
  2091 </xsl:text>
       
  2092     <xsl:text>                  this.args.length &gt;= 2 ? this.args[1] : 100;
       
  2093 </xsl:text>
  2148 </xsl:text>
  2094     <xsl:text>        this.range = [min, max, start, end];
  2149     <xsl:text>        this.range = [min, max, start, end];
  2095 </xsl:text>
  2150 </xsl:text>
  2096     <xsl:text>        this.center = [cx, cy];
  2151     <xsl:text>        this.center = [cx, cy];
  2097 </xsl:text>
  2152 </xsl:text>
  2115       <xsl:with-param name="labels">
  2170       <xsl:with-param name="labels">
  2116         <xsl:text>value min max</xsl:text>
  2171         <xsl:text>value min max</xsl:text>
  2117       </xsl:with-param>
  2172       </xsl:with-param>
  2118       <xsl:with-param name="mandatory" select="'no'"/>
  2173       <xsl:with-param name="mandatory" select="'no'"/>
  2119     </xsl:call-template>
  2174     </xsl:call-template>
  2120     <xsl:text>
       
  2121 </xsl:text>
       
  2122   </xsl:template>
  2175   </xsl:template>
  2123   <xsl:template mode="widget_class" match="widget[@type='CircularSlider']">
  2176   <xsl:template mode="widget_class" match="widget[@type='CircularSlider']">
  2124     <xsl:text>class CircularSliderWidget extends Widget{
  2177     <xsl:text>class CircularSliderWidget extends Widget{
  2125 </xsl:text>
  2178 </xsl:text>
  2126     <xsl:text>    frequency = 5;
  2179     <xsl:text>    frequency = 5;
  3833       <xsl:with-param name="hmi_element" select="$hmi_element"/>
  3886       <xsl:with-param name="hmi_element" select="$hmi_element"/>
  3834       <xsl:with-param name="labels">
  3887       <xsl:with-param name="labels">
  3835         <xsl:text>text box button highlight</xsl:text>
  3888         <xsl:text>text box button highlight</xsl:text>
  3836       </xsl:with-param>
  3889       </xsl:with-param>
  3837     </xsl:call-template>
  3890     </xsl:call-template>
  3838     <xsl:text>    // It is assumed that list content conforms to Array interface.
       
  3839 </xsl:text>
       
  3840     <xsl:text>    content: [
  3891     <xsl:text>    content: [
       
  3892 </xsl:text>
       
  3893     <xsl:text>    /* TODO : Support HMI:List */
  3841 </xsl:text>
  3894 </xsl:text>
  3842     <xsl:for-each select="arg">
  3895     <xsl:for-each select="arg">
  3843       <xsl:text>"</xsl:text>
  3896       <xsl:text>"</xsl:text>
  3844       <xsl:value-of select="@value"/>
  3897       <xsl:value-of select="@value"/>
  3845       <xsl:text>",
  3898       <xsl:text>",
  4636       <xsl:with-param name="widget_elts" select="$hmi_element/*[@inkscape:label = 'data']/descendant::svg:*"/>
  4689       <xsl:with-param name="widget_elts" select="$hmi_element/*[@inkscape:label = 'data']/descendant::svg:*"/>
  4637     </xsl:apply-templates>
  4690     </xsl:apply-templates>
  4638     <xsl:text>    }
  4691     <xsl:text>    }
  4639 </xsl:text>
  4692 </xsl:text>
  4640   </xsl:template>
  4693   </xsl:template>
  4641   <xsl:template name="jump_widget_activity">
  4694   <xsl:template mode="widget_class" match="widget[@type='Jump']">
  4642     <xsl:param name="hmi_element"/>
  4695     <xsl:text>    class JumpWidget extends Widget{
  4643     <xsl:call-template name="defs_by_labels">
  4696 </xsl:text>
  4644       <xsl:with-param name="hmi_element" select="$hmi_element"/>
  4697     <xsl:text>
  4645       <xsl:with-param name="labels">
  4698 </xsl:text>
  4646         <xsl:text>active inactive</xsl:text>
  4699     <xsl:text>        activable = false;
  4647       </xsl:with-param>
  4700 </xsl:text>
  4648       <xsl:with-param name="mandatory" select="'no'"/>
  4701     <xsl:text>        active = false;
  4649     </xsl:call-template>
  4702 </xsl:text>
  4650   </xsl:template>
  4703     <xsl:text>        disabled = false;
  4651   <xsl:template name="jump_widget_disability">
  4704 </xsl:text>
  4652     <xsl:param name="hmi_element"/>
  4705     <xsl:text>        frequency = 2;
  4653     <xsl:call-template name="defs_by_labels">
  4706 </xsl:text>
  4654       <xsl:with-param name="hmi_element" select="$hmi_element"/>
  4707     <xsl:text>
  4655       <xsl:with-param name="labels">
  4708 </xsl:text>
  4656         <xsl:text>disabled</xsl:text>
  4709     <xsl:text>        update_activity() {
  4657       </xsl:with-param>
  4710 </xsl:text>
  4658       <xsl:with-param name="mandatory" select="'no'"/>
  4711     <xsl:text>            if(this.active) {
  4659     </xsl:call-template>
  4712 </xsl:text>
       
  4713     <xsl:text>                 /* show active */ 
       
  4714 </xsl:text>
       
  4715     <xsl:text>                 this.active_elt.setAttribute("style", this.active_elt_style);
       
  4716 </xsl:text>
       
  4717     <xsl:text>                 /* hide inactive */ 
       
  4718 </xsl:text>
       
  4719     <xsl:text>                 this.inactive_elt.setAttribute("style", "display:none");
       
  4720 </xsl:text>
       
  4721     <xsl:text>            } else {
       
  4722 </xsl:text>
       
  4723     <xsl:text>                 /* show inactive */ 
       
  4724 </xsl:text>
       
  4725     <xsl:text>                 this.inactive_elt.setAttribute("style", this.inactive_elt_style);
       
  4726 </xsl:text>
       
  4727     <xsl:text>                 /* hide active */ 
       
  4728 </xsl:text>
       
  4729     <xsl:text>                 this.active_elt.setAttribute("style", "display:none");
       
  4730 </xsl:text>
       
  4731     <xsl:text>            }
       
  4732 </xsl:text>
       
  4733     <xsl:text>        }
       
  4734 </xsl:text>
       
  4735     <xsl:text>
       
  4736 </xsl:text>
       
  4737     <xsl:text>        make_on_click() {
       
  4738 </xsl:text>
       
  4739     <xsl:text>            let that = this;
       
  4740 </xsl:text>
       
  4741     <xsl:text>            const name = this.args[0];
       
  4742 </xsl:text>
       
  4743     <xsl:text>            return function(evt){
       
  4744 </xsl:text>
       
  4745     <xsl:text>                /* TODO: suport path pointing to local variable whom value 
       
  4746 </xsl:text>
       
  4747     <xsl:text>                   would be an HMI_TREE index to jump to a relative page */
       
  4748 </xsl:text>
       
  4749     <xsl:text>                const index = that.indexes.length &gt; 0 ? that.indexes[0] + that.offset : undefined;
       
  4750 </xsl:text>
       
  4751     <xsl:text>                switch_page(name, index);
       
  4752 </xsl:text>
       
  4753     <xsl:text>            }
       
  4754 </xsl:text>
       
  4755     <xsl:text>        }
       
  4756 </xsl:text>
       
  4757     <xsl:text>
       
  4758 </xsl:text>
       
  4759     <xsl:text>        notify_page_change(page_name, index) {
       
  4760 </xsl:text>
       
  4761     <xsl:text>            if(this.activable) {
       
  4762 </xsl:text>
       
  4763     <xsl:text>                const ref_index = this.indexes.length &gt; 0 ? this.indexes[0] + this.offset : undefined;
       
  4764 </xsl:text>
       
  4765     <xsl:text>                const ref_name = this.args[0];
       
  4766 </xsl:text>
       
  4767     <xsl:text>                this.active = ((ref_name == undefined || ref_name == page_name) &amp;&amp; index == ref_index);
       
  4768 </xsl:text>
       
  4769     <xsl:text>                this.update_activity();
       
  4770 </xsl:text>
       
  4771     <xsl:text>            }
       
  4772 </xsl:text>
       
  4773     <xsl:text>        }
       
  4774 </xsl:text>
       
  4775     <xsl:text>
       
  4776 </xsl:text>
       
  4777     <xsl:text>        dispatch(value) {
       
  4778 </xsl:text>
       
  4779     <xsl:text>            this.disabled = !Number(value);
       
  4780 </xsl:text>
       
  4781     <xsl:text>            if(this.disabled) {
       
  4782 </xsl:text>
       
  4783     <xsl:text>              /* show disabled */ 
       
  4784 </xsl:text>
       
  4785     <xsl:text>              this.disabled_elt.setAttribute("style", this.disabled_elt_style);
       
  4786 </xsl:text>
       
  4787     <xsl:text>              /* hide inactive */ 
       
  4788 </xsl:text>
       
  4789     <xsl:text>              this.inactive_elt.setAttribute("style", "display:none");
       
  4790 </xsl:text>
       
  4791     <xsl:text>              /* hide active */ 
       
  4792 </xsl:text>
       
  4793     <xsl:text>              this.active_elt.setAttribute("style", "display:none");
       
  4794 </xsl:text>
       
  4795     <xsl:text>            } else {
       
  4796 </xsl:text>
       
  4797     <xsl:text>              /* hide disabled */ 
       
  4798 </xsl:text>
       
  4799     <xsl:text>              this.disabled_elt.setAttribute("style", "display:none");
       
  4800 </xsl:text>
       
  4801     <xsl:text>              this.update_activity();
       
  4802 </xsl:text>
       
  4803     <xsl:text>            }
       
  4804 </xsl:text>
       
  4805     <xsl:text>        }
       
  4806 </xsl:text>
       
  4807     <xsl:text>    }
       
  4808 </xsl:text>
  4660   </xsl:template>
  4809   </xsl:template>
  4661   <xsl:template mode="widget_defs" match="widget[@type='Jump']">
  4810   <xsl:template mode="widget_defs" match="widget[@type='Jump']">
  4662     <xsl:param name="hmi_element"/>
  4811     <xsl:param name="hmi_element"/>
  4663     <xsl:variable name="activity">
  4812     <xsl:variable name="activity">
  4664       <xsl:call-template name="jump_widget_activity">
  4813       <xsl:call-template name="defs_by_labels">
  4665         <xsl:with-param name="hmi_element" select="$hmi_element"/>
  4814         <xsl:with-param name="hmi_element" select="$hmi_element"/>
       
  4815         <xsl:with-param name="labels">
       
  4816           <xsl:text>active inactive</xsl:text>
       
  4817         </xsl:with-param>
       
  4818         <xsl:with-param name="mandatory" select="'no'"/>
  4666       </xsl:call-template>
  4819       </xsl:call-template>
  4667     </xsl:variable>
  4820     </xsl:variable>
  4668     <xsl:variable name="have_activity" select="string-length($activity)&gt;0"/>
  4821     <xsl:variable name="have_activity" select="string-length($activity)&gt;0"/>
  4669     <xsl:value-of select="$activity"/>
  4822     <xsl:value-of select="$activity"/>
  4670     <xsl:variable name="disability">
  4823     <xsl:variable name="disability">
  4671       <xsl:call-template name="jump_widget_disability">
  4824       <xsl:call-template name="defs_by_labels">
  4672         <xsl:with-param name="hmi_element" select="$hmi_element"/>
  4825         <xsl:with-param name="hmi_element" select="$hmi_element"/>
       
  4826         <xsl:with-param name="labels">
       
  4827           <xsl:text>disabled</xsl:text>
       
  4828         </xsl:with-param>
       
  4829         <xsl:with-param name="mandatory" select="'no'"/>
  4673       </xsl:call-template>
  4830       </xsl:call-template>
  4674     </xsl:variable>
  4831     </xsl:variable>
  4675     <xsl:variable name="have_disability" select="$have_activity and string-length($disability)&gt;0"/>
  4832     <xsl:variable name="have_disability" select="$have_activity and string-length($disability)&gt;0"/>
  4676     <xsl:value-of select="$disability"/>
  4833     <xsl:value-of select="$disability"/>
  4677     <xsl:if test="$have_activity">
       
  4678       <xsl:text>    active: false,
       
  4679 </xsl:text>
       
  4680       <xsl:if test="$have_disability">
       
  4681         <xsl:text>    disabled: false,
       
  4682 </xsl:text>
       
  4683         <xsl:text>    frequency: 2,
       
  4684 </xsl:text>
       
  4685         <xsl:text>    dispatch: function(value) {
       
  4686 </xsl:text>
       
  4687         <xsl:text>        this.disabled = !Number(value);
       
  4688 </xsl:text>
       
  4689         <xsl:text>        this.update();
       
  4690 </xsl:text>
       
  4691         <xsl:text>    },
       
  4692 </xsl:text>
       
  4693       </xsl:if>
       
  4694       <xsl:text>    update: function(){
       
  4695 </xsl:text>
       
  4696       <xsl:if test="$have_disability">
       
  4697         <xsl:text>      if(this.disabled) {
       
  4698 </xsl:text>
       
  4699         <xsl:text>        /* show disabled */ 
       
  4700 </xsl:text>
       
  4701         <xsl:text>        this.disabled_elt.setAttribute("style", this.active_elt_style);
       
  4702 </xsl:text>
       
  4703         <xsl:text>        /* hide inactive */ 
       
  4704 </xsl:text>
       
  4705         <xsl:text>        this.inactive_elt.setAttribute("style", "display:none");
       
  4706 </xsl:text>
       
  4707         <xsl:text>        /* hide active */ 
       
  4708 </xsl:text>
       
  4709         <xsl:text>        this.active_elt.setAttribute("style", "display:none");
       
  4710 </xsl:text>
       
  4711         <xsl:text>      } else {
       
  4712 </xsl:text>
       
  4713         <xsl:text>        /* hide disabled */ 
       
  4714 </xsl:text>
       
  4715         <xsl:text>        this.disabled_elt.setAttribute("style", "display:none");
       
  4716 </xsl:text>
       
  4717       </xsl:if>
       
  4718       <xsl:text>        if(this.active) {
       
  4719 </xsl:text>
       
  4720       <xsl:text>             /* show active */ 
       
  4721 </xsl:text>
       
  4722       <xsl:text>             this.active_elt.setAttribute("style", this.active_elt_style);
       
  4723 </xsl:text>
       
  4724       <xsl:text>             /* hide inactive */ 
       
  4725 </xsl:text>
       
  4726       <xsl:text>             this.inactive_elt.setAttribute("style", "display:none");
       
  4727 </xsl:text>
       
  4728       <xsl:text>        } else {
       
  4729 </xsl:text>
       
  4730       <xsl:text>             /* show inactive */ 
       
  4731 </xsl:text>
       
  4732       <xsl:text>             this.inactive_elt.setAttribute("style", this.inactive_elt_style);
       
  4733 </xsl:text>
       
  4734       <xsl:text>             /* hide active */ 
       
  4735 </xsl:text>
       
  4736       <xsl:text>             this.active_elt.setAttribute("style", "display:none");
       
  4737 </xsl:text>
       
  4738       <xsl:text>        }
       
  4739 </xsl:text>
       
  4740       <xsl:if test="$have_disability">
       
  4741         <xsl:text>      }
       
  4742 </xsl:text>
       
  4743       </xsl:if>
       
  4744       <xsl:text>    },
       
  4745 </xsl:text>
       
  4746     </xsl:if>
       
  4747     <xsl:if test="$have_activity">
       
  4748       <xsl:text>    notify_page_change: function(page_name, index){
       
  4749 </xsl:text>
       
  4750       <xsl:text>        const ref_index = this.indexes.length &gt; 0 ? this.indexes[0] + this.offset : undefined;
       
  4751 </xsl:text>
       
  4752       <xsl:text>        const ref_name = this.args[0];
       
  4753 </xsl:text>
       
  4754       <xsl:text>        this.active =((ref_name == undefined || ref_name == page_name) &amp;&amp; index == ref_index);
       
  4755 </xsl:text>
       
  4756       <xsl:text>        this.update();
       
  4757 </xsl:text>
       
  4758       <xsl:text>    },
       
  4759 </xsl:text>
       
  4760     </xsl:if>
       
  4761     <xsl:text>    make_on_click(){
       
  4762 </xsl:text>
       
  4763     <xsl:text>        let that = this;
       
  4764 </xsl:text>
       
  4765     <xsl:text>        const name = this.args[0];
       
  4766 </xsl:text>
       
  4767     <xsl:text>        return function(evt){
       
  4768 </xsl:text>
       
  4769     <xsl:text>            const index = that.indexes.length &gt; 0 ? that.indexes[0] + that.offset : undefined;
       
  4770 </xsl:text>
       
  4771     <xsl:text>            switch_page(name, index);
       
  4772 </xsl:text>
       
  4773     <xsl:text>        }
       
  4774 </xsl:text>
       
  4775     <xsl:text>    },
       
  4776 </xsl:text>
       
  4777     <xsl:text>    init: function() {
  4834     <xsl:text>    init: function() {
  4778 </xsl:text>
  4835 </xsl:text>
  4779     <xsl:text>        this.element.onclick = this.make_on_click();
  4836     <xsl:text>        this.element.onclick = this.make_on_click();
  4780 </xsl:text>
  4837 </xsl:text>
  4781     <xsl:if test="$have_activity">
  4838     <xsl:if test="$have_activity">
  4782       <xsl:text>        this.active_elt_style = this.active_elt.getAttribute("style");
  4839       <xsl:text>        this.active_elt_style = this.active_elt.getAttribute("style");
  4783 </xsl:text>
  4840 </xsl:text>
  4784       <xsl:text>        this.inactive_elt_style = this.inactive_elt.getAttribute("style");
  4841       <xsl:text>        this.inactive_elt_style = this.inactive_elt.getAttribute("style");
       
  4842 </xsl:text>
       
  4843       <xsl:text>        this.activable = true;
  4785 </xsl:text>
  4844 </xsl:text>
  4786     </xsl:if>
  4845     </xsl:if>
  4787     <xsl:choose>
  4846     <xsl:choose>
  4788       <xsl:when test="$have_disability">
  4847       <xsl:when test="$have_disability">
  4789         <xsl:text>        this.disabled_elt_style = this.disabled_elt.getAttribute("style");
  4848         <xsl:text>        this.disabled_elt_style = this.disabled_elt.getAttribute("style");
  5358 </xsl:text>
  5417 </xsl:text>
  5359     <xsl:text>
  5418     <xsl:text>
  5360 </xsl:text>
  5419 </xsl:text>
  5361     <xsl:text>    dispatch(value) {
  5420     <xsl:text>    dispatch(value) {
  5362 </xsl:text>
  5421 </xsl:text>
       
  5422     <xsl:text>        this.display_val = value;
       
  5423 </xsl:text>
       
  5424     <xsl:text>        this.request_animate();
       
  5425 </xsl:text>
       
  5426     <xsl:text>    }
       
  5427 </xsl:text>
       
  5428     <xsl:text>
       
  5429 </xsl:text>
       
  5430     <xsl:text>    animate(){
       
  5431 </xsl:text>
  5363     <xsl:text>        if(this.value_elt)
  5432     <xsl:text>        if(this.value_elt)
  5364 </xsl:text>
  5433 </xsl:text>
  5365     <xsl:text>            this.value_elt.textContent = String(value);
  5434     <xsl:text>            this.value_elt.textContent = String(this.display_val);
  5366 </xsl:text>
  5435 </xsl:text>
  5367     <xsl:text>        let [min,max,totallength] = this.range;
  5436     <xsl:text>        let [min,max,totallength] = this.range;
  5368 </xsl:text>
  5437 </xsl:text>
  5369     <xsl:text>        let length = Math.max(0,Math.min(totallength,(Number(value)-min)*totallength/(max-min)));
  5438     <xsl:text>        let length = Math.max(0,Math.min(totallength,(Number(this.display_val)-min)*totallength/(max-min)));
  5370 </xsl:text>
  5439 </xsl:text>
  5371     <xsl:text>        let tip = this.range_elt.getPointAtLength(length);
  5440     <xsl:text>        let tip = this.range_elt.getPointAtLength(length);
  5372 </xsl:text>
  5441 </xsl:text>
  5373     <xsl:text>        this.needle_elt.setAttribute('d', "M "+this.origin.x+","+this.origin.y+" "+tip.x+","+tip.y);
  5442     <xsl:text>        this.needle_elt.setAttribute('d', "M "+this.origin.x+","+this.origin.y+" "+tip.x+","+tip.y);
  5374 </xsl:text>
  5443 </xsl:text>
  5376 </xsl:text>
  5445 </xsl:text>
  5377     <xsl:text>
  5446     <xsl:text>
  5378 </xsl:text>
  5447 </xsl:text>
  5379     <xsl:text>    init() {
  5448     <xsl:text>    init() {
  5380 </xsl:text>
  5449 </xsl:text>
  5381     <xsl:text>        let min = this.min_elt ?
  5450     <xsl:text>        let [min,max] = [[this.min_elt,0],[this.max_elt,100]].map(([elt,def],i)=&gt;elt?
  5382 </xsl:text>
  5451 </xsl:text>
  5383     <xsl:text>                    Number(this.min_elt.textContent) :
  5452     <xsl:text>            Number(elt.textContent) :
  5384 </xsl:text>
  5453 </xsl:text>
  5385     <xsl:text>                    this.args.length &gt;= 1 ? this.args[0] : 0;
  5454     <xsl:text>            this.args.length &gt;= i+1 ? this.args[i] : def);
  5386 </xsl:text>
  5455 </xsl:text>
  5387     <xsl:text>        let max = this.max_elt ?
  5456     <xsl:text>
  5388 </xsl:text>
       
  5389     <xsl:text>                    Number(this.max_elt.textContent) :
       
  5390 </xsl:text>
       
  5391     <xsl:text>                    this.args.length &gt;= 2 ? this.args[1] : 100;
       
  5392 </xsl:text>
  5457 </xsl:text>
  5393     <xsl:text>        this.range = [min, max, this.range_elt.getTotalLength()]
  5458     <xsl:text>        this.range = [min, max, this.range_elt.getTotalLength()]
  5394 </xsl:text>
  5459 </xsl:text>
  5395     <xsl:text>        this.origin = this.needle_elt.getPointAtLength(0);
  5460     <xsl:text>        this.origin = this.needle_elt.getPointAtLength(0);
  5396 </xsl:text>
  5461 </xsl:text>
  5414       <xsl:with-param name="labels">
  5479       <xsl:with-param name="labels">
  5415         <xsl:text>value min max</xsl:text>
  5480         <xsl:text>value min max</xsl:text>
  5416       </xsl:with-param>
  5481       </xsl:with-param>
  5417       <xsl:with-param name="mandatory" select="'no'"/>
  5482       <xsl:with-param name="mandatory" select="'no'"/>
  5418     </xsl:call-template>
  5483     </xsl:call-template>
  5419     <xsl:text>
       
  5420 </xsl:text>
       
  5421   </xsl:template>
  5484   </xsl:template>
  5422   <xsl:template mode="widget_class" match="widget[@type='MultiState']">
  5485   <xsl:template mode="widget_class" match="widget[@type='MultiState']">
  5423     <xsl:text>class MultiStateWidget extends Widget{
  5486     <xsl:text>class MultiStateWidget extends Widget{
  5424 </xsl:text>
  5487 </xsl:text>
  5425     <xsl:text>    frequency = 5;
  5488     <xsl:text>    frequency = 5;
  6394       <xsl:text>Made with SVGHMI. https://beremiz.org</xsl:text>
  6457       <xsl:text>Made with SVGHMI. https://beremiz.org</xsl:text>
  6395     </xsl:comment>
  6458     </xsl:comment>
  6396     <xsl:comment>
  6459     <xsl:comment>
  6397       <xsl:apply-templates select="document('')/*/debug:*"/>
  6460       <xsl:apply-templates select="document('')/*/debug:*"/>
  6398     </xsl:comment>
  6461     </xsl:comment>
  6399     <html xmlns="http://www.w3.org/1999/xhtml" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  6462     <html xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/1999/xhtml">
  6400       <head/>
  6463       <head/>
  6401       <body style="margin:0;overflow:hidden;user-select:none;touch-action:none;">
  6464       <body style="margin:0;overflow:hidden;user-select:none;touch-action:none;">
  6402         <xsl:copy-of select="$result_svg"/>
  6465         <xsl:copy-of select="$result_svg"/>
  6403         <script>
  6466         <script>
  6404           <xsl:text>
  6467           <xsl:text>