svghmi/analyse_widget.xslt
changeset 3506 ca312be56929
parent 3414 0ff608310312
child 3507 e87a2daace80
equal deleted inserted replaced
3505:a27b5862e363 3506:ca312be56929
     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:svg="http://www.w3.org/2000/svg" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" version="1.0" extension-element-prefixes="ns func exsl regexp str dyn" exclude-result-prefixes="ns func exsl regexp str dyn svg inkscape">
     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:svg="http://www.w3.org/2000/svg" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" version="1.0" extension-element-prefixes="ns func exsl regexp str dyn" exclude-result-prefixes="ns func exsl regexp str dyn svg inkscape">
     3   <xsl:output method="xml"/>
     3   <xsl:output method="xml"/>
     4   <xsl:variable name="indexed_hmitree" select="/.."/>
     4   <xsl:variable name="indexed_hmitree" select="/.."/>
     5   <xsl:variable name="pathregex" select="'^([^\[,]+)(\[[^\]]+\])?([\d,]*)$'"/>
     5   <xsl:variable name="pathregex" select="'^([^\[,]+)(\[[^\]]+\])?([-.\d,]*)$'"/>
     6   <xsl:template mode="parselabel" match="*">
     6   <xsl:template mode="parselabel" match="*">
     7     <xsl:variable name="label" select="@inkscape:label"/>
     7     <xsl:variable name="label" select="@inkscape:label"/>
     8     <xsl:variable name="id" select="@id"/>
     8     <xsl:variable name="id" select="@id"/>
     9     <xsl:variable name="description" select="substring-after($label,'HMI:')"/>
     9     <xsl:variable name="description" select="substring-after($label,'HMI:')"/>
    10     <xsl:variable name="_args" select="substring-before($description,'@')"/>
    10     <xsl:variable name="_args" select="substring-before($description,'@')"/>
    48         </xsl:attribute>
    48         </xsl:attribute>
    49         <xsl:attribute name="type">
    49         <xsl:attribute name="type">
    50           <xsl:value-of select="$type"/>
    50           <xsl:value-of select="$type"/>
    51         </xsl:attribute>
    51         </xsl:attribute>
    52         <xsl:if test="$freq">
    52         <xsl:if test="$freq">
       
    53           <xsl:if test="not(regexp:test($freq,'^[0-9]*(\.[0-9]+)?[smh]?'))">
       
    54             <xsl:message terminate="yes">
       
    55               <xsl:text>Widget id:</xsl:text>
       
    56               <xsl:value-of select="$id"/>
       
    57               <xsl:text> label:</xsl:text>
       
    58               <xsl:value-of select="$label"/>
       
    59               <xsl:text> has wrong syntax of frequency forcing </xsl:text>
       
    60               <xsl:value-of select="$freq"/>
       
    61             </xsl:message>
       
    62           </xsl:if>
    53           <xsl:attribute name="freq">
    63           <xsl:attribute name="freq">
    54             <xsl:value-of select="$freq"/>
    64             <xsl:value-of select="$freq"/>
    55           </xsl:attribute>
    65           </xsl:attribute>
    56         </xsl:if>
    66         </xsl:if>
    57         <xsl:for-each select="str:split(substring-after($args, ':'), ':')">
    67         <xsl:for-each select="str:split(substring-after($args, ':'), ':')">
   221       <xsl:text>Boolean variable</xsl:text>
   231       <xsl:text>Boolean variable</xsl:text>
   222     </path>
   232     </path>
   223   </xsl:template>
   233   </xsl:template>
   224   <xsl:template name="generated_button_class">
   234   <xsl:template name="generated_button_class">
   225     <xsl:param name="fsm"/>
   235     <xsl:param name="fsm"/>
   226     <xsl:text>    frequency = 5;
       
   227 </xsl:text>
       
   228     <xsl:text>    display = "inactive";
   236     <xsl:text>    display = "inactive";
   229 </xsl:text>
   237 </xsl:text>
   230     <xsl:text>    state = "init";
   238     <xsl:text>    state = "init";
   231 </xsl:text>
   239 </xsl:text>
   232     <xsl:text>    dispatch(value) {
   240     <xsl:text>    dispatch(value) {
   715   <xsl:template match="widget[@type='PathSlider']" mode="widget_desc">
   723   <xsl:template match="widget[@type='PathSlider']" mode="widget_desc">
   716     <type>
   724     <type>
   717       <xsl:value-of select="@type"/>
   725       <xsl:value-of select="@type"/>
   718     </type>
   726     </type>
   719     <longdesc>
   727     <longdesc>
   720       <xsl:text>PathSlider - 
   728       <xsl:text>PathSlider -
   721 </xsl:text>
   729 </xsl:text>
   722     </longdesc>
   730     </longdesc>
   723     <shortdesc>
   731     <shortdesc>
   724       <xsl:text>Slide an SVG element along a path by dragging it</xsl:text>
   732       <xsl:text>Slide an SVG element along a path by dragging it</xsl:text>
   725     </shortdesc>
   733     </shortdesc>
   874       <xsl:text>Toggle button reflecting given boolean variable</xsl:text>
   882       <xsl:text>Toggle button reflecting given boolean variable</xsl:text>
   875     </shortdesc>
   883     </shortdesc>
   876     <path name="value" accepts="HMI_BOOL">
   884     <path name="value" accepts="HMI_BOOL">
   877       <xsl:text>Boolean variable</xsl:text>
   885       <xsl:text>Boolean variable</xsl:text>
   878     </path>
   886     </path>
       
   887   </xsl:template>
       
   888   <xsl:template match="widget[@type='XYGraph']" mode="widget_desc">
       
   889     <type>
       
   890       <xsl:value-of select="@type"/>
       
   891     </type>
       
   892     <longdesc>
       
   893       <xsl:text>XYGraph draws a cartesian trend graph re-using styles given for axis,
       
   894 </xsl:text>
       
   895       <xsl:text>grid/marks, legends and curves.
       
   896 </xsl:text>
       
   897       <xsl:text>
       
   898 </xsl:text>
       
   899       <xsl:text>Elements labeled "x_axis" and "y_axis" are svg:groups containg:
       
   900 </xsl:text>
       
   901       <xsl:text> - "axis_label" svg:text gives style an alignment for axis labels.
       
   902 </xsl:text>
       
   903       <xsl:text> - "interval_major_mark" and "interval_minor_mark" are svg elements to be
       
   904 </xsl:text>
       
   905       <xsl:text>   duplicated along axis line to form intervals marks.
       
   906 </xsl:text>
       
   907       <xsl:text> - "axis_line"  svg:path is the axis line. Paths must be intersect and their
       
   908 </xsl:text>
       
   909       <xsl:text>   bounding box is the chart wall.
       
   910 </xsl:text>
       
   911       <xsl:text>
       
   912 </xsl:text>
       
   913       <xsl:text>Elements labeled "curve_0", "curve_1", ... are paths whose styles are used
       
   914 </xsl:text>
       
   915       <xsl:text>to draw curves corresponding to data from variables passed as HMI tree paths.
       
   916 </xsl:text>
       
   917       <xsl:text>"curve_0" is mandatory. HMI variables outnumbering given curves are ignored.
       
   918 </xsl:text>
       
   919       <xsl:text>
       
   920 </xsl:text>
       
   921     </longdesc>
       
   922     <shortdesc>
       
   923       <xsl:text>Cartesian trend graph showing values of given variables over time</xsl:text>
       
   924     </shortdesc>
       
   925     <path name="value" count="1+" accepts="HMI_INT,HMI_REAL">
       
   926       <xsl:text>value</xsl:text>
       
   927     </path>
       
   928     <arg name="size" accepts="int">
       
   929       <xsl:text>buffer size</xsl:text>
       
   930     </arg>
       
   931     <arg name="xformat" count="optional" accepts="string">
       
   932       <xsl:text>format string for X label</xsl:text>
       
   933     </arg>
       
   934     <arg name="yformat" count="optional" accepts="string">
       
   935       <xsl:text>format string for Y label</xsl:text>
       
   936     </arg>
       
   937     <arg name="xmin" count="optional" accepts="int,real">
       
   938       <xsl:text>minimum value foe X axis</xsl:text>
       
   939     </arg>
       
   940     <arg name="xmax" count="optional" accepts="int,real">
       
   941       <xsl:text>maximum value for X axis</xsl:text>
       
   942     </arg>
   879   </xsl:template>
   943   </xsl:template>
   880   <xsl:template mode="document" match="@* | node()">
   944   <xsl:template mode="document" match="@* | node()">
   881     <xsl:copy>
   945     <xsl:copy>
   882       <xsl:apply-templates mode="document" select="@* | node()"/>
   946       <xsl:apply-templates mode="document" select="@* | node()"/>
   883     </xsl:copy>
   947     </xsl:copy>