svghmi/gen_index_xhtml.xslt
changeset 3387 ecefd38d5c7d
parent 3383 a3b8cfd89648
child 3410 eac5832a1489
equal deleted inserted replaced
3386:608f48ad3dfc 3387:ecefd38d5c7d
   570         <func:result select="/.."/>
   570         <func:result select="/.."/>
   571       </xsl:otherwise>
   571       </xsl:otherwise>
   572     </xsl:choose>
   572     </xsl:choose>
   573   </func:function>
   573   </func:function>
   574   <xsl:variable name="required_page_elements" select="func:required_elements($hmi_pages | $keypads)/ancestor-or-self::svg:*"/>
   574   <xsl:variable name="required_page_elements" select="func:required_elements($hmi_pages | $keypads)/ancestor-or-self::svg:*"/>
   575   <xsl:variable name="required_list_elements" select="func:refered_elements(($hmi_lists | $hmi_textlists)[@id = $required_page_elements/@id])"/>
   575   <xsl:variable name="required_list_elements" select="func:refered_elements(($hmi_lists | $hmi_textlists)[@id = $required_page_elements/@id])/ancestor-or-self::svg:*"/>
   576   <xsl:variable name="required_elements" select="$defs | $required_list_elements | $required_page_elements"/>
   576   <xsl:variable name="required_elements" select="$defs | $required_list_elements | $required_page_elements"/>
   577   <xsl:variable name="discardable_elements" select="//svg:*[not(@id = $required_elements/@id)]"/>
   577   <xsl:variable name="discardable_elements" select="//svg:*[not(@id = $required_elements/@id)]"/>
   578   <func:function name="func:sumarized_elements">
   578   <func:function name="func:sumarized_elements">
   579     <xsl:param name="elements"/>
   579     <xsl:param name="elements"/>
   580     <xsl:variable name="short_list" select="$elements[not(ancestor::*/@id = $elements/@id)]"/>
   580     <xsl:variable name="short_list" select="$elements[not(ancestor::*/@id = $elements/@id)]"/>
   844     <xsl:attribute name="{name()}">
   844     <xsl:attribute name="{name()}">
   845       <xsl:value-of select="substring(., 2)"/>
   845       <xsl:value-of select="substring(., 2)"/>
   846     </xsl:attribute>
   846     </xsl:attribute>
   847   </xsl:template>
   847   </xsl:template>
   848   <xsl:variable name="targets_not_to_unlink" select="$hmi_lists/descendant-or-self::svg:*"/>
   848   <xsl:variable name="targets_not_to_unlink" select="$hmi_lists/descendant-or-self::svg:*"/>
   849   <xsl:variable name="to_unlink" select="$hmi_elements[not(@id = $hmi_pages/@id)]/descendant-or-self::svg:use"/>
   849   <xsl:variable name="to_unlink" select="$hmi_widgets/descendant-or-self::svg:use"/>
   850   <func:function name="func:is_unlinkable">
   850   <func:function name="func:is_unlinkable">
   851     <xsl:param name="targetid"/>
   851     <xsl:param name="targetid"/>
   852     <xsl:param name="eltid"/>
   852     <xsl:param name="eltid"/>
   853     <func:result select="$eltid = $to_unlink/@id and not($targetid = $targets_not_to_unlink/@id)"/>
   853     <func:result select="$eltid = $to_unlink/@id and not($targetid = $targets_not_to_unlink/@id)"/>
   854   </func:function>
   854   </func:function>
  4581 </xsl:text>
  4581 </xsl:text>
  4582       <xsl:text>SVG sub-elements of "data" labeled element.
  4582       <xsl:text>SVG sub-elements of "data" labeled element.
  4583 </xsl:text>
  4583 </xsl:text>
  4584       <xsl:text>
  4584       <xsl:text>
  4585 </xsl:text>
  4585 </xsl:text>
  4586       <xsl:text>Documentation to be written. see svbghmi exemple.
  4586       <xsl:text>Documentation to be written. see svghmi exemple.
  4587 </xsl:text>
  4587 </xsl:text>
  4588     </longdesc>
  4588     </longdesc>
  4589     <shortdesc>
  4589     <shortdesc>
  4590       <xsl:text>Http POST variables, spread JSON back</xsl:text>
  4590       <xsl:text>Http POST variables, spread JSON back</xsl:text>
  4591     </shortdesc>
  4591     </shortdesc>
  4831     <xsl:variable name="from_list" select="$hmi_lists[(@id | */@id) = $targetid]"/>
  4831     <xsl:variable name="from_list" select="$hmi_lists[(@id | */@id) = $targetid]"/>
  4832     <xsl:choose>
  4832     <xsl:choose>
  4833       <xsl:when test="count($from_list) &gt; 0">
  4833       <xsl:when test="count($from_list) &gt; 0">
  4834         <xsl:text>        id("</xsl:text>
  4834         <xsl:text>        id("</xsl:text>
  4835         <xsl:value-of select="@id"/>
  4835         <xsl:value-of select="@id"/>
  4836         <xsl:text>").setAttribute("xlink:href",
  4836         <xsl:text>").href.baseVal =
  4837 </xsl:text>
  4837 </xsl:text>
  4838         <xsl:text>            "#"+hmi_widgets["</xsl:text>
  4838         <xsl:text>            "#"+hmi_widgets["</xsl:text>
  4839         <xsl:value-of select="$from_list/@id"/>
  4839         <xsl:value-of select="$from_list/@id"/>
  4840         <xsl:text>"].items[</xsl:text>
  4840         <xsl:text>"].items[</xsl:text>
  4841         <xsl:value-of select="$expressions/expression[1]/@content"/>
  4841         <xsl:value-of select="$expressions/expression[1]/@content"/>
  4842         <xsl:text>]);
  4842         <xsl:text>];
  4843 </xsl:text>
  4843 </xsl:text>
  4844       </xsl:when>
  4844       </xsl:when>
  4845       <xsl:otherwise>
  4845       <xsl:otherwise>
  4846         <xsl:message terminate="no">
  4846         <xsl:message terminate="no">
  4847           <xsl:text>Clones (svg:use) in JsonTable Widget must point to a valid HMI:List widget or item. Reference "</xsl:text>
  4847           <xsl:text>Clones (svg:use) in JsonTable Widget must point to a valid HMI:List widget or item. Reference "</xsl:text>
  5673   <xsl:template match="widget[@type='List']" mode="widget_defs">
  5673   <xsl:template match="widget[@type='List']" mode="widget_defs">
  5674     <xsl:param name="hmi_element"/>
  5674     <xsl:param name="hmi_element"/>
  5675     <xsl:text>    items: {
  5675     <xsl:text>    items: {
  5676 </xsl:text>
  5676 </xsl:text>
  5677     <xsl:for-each select="$hmi_element/*[@inkscape:label]">
  5677     <xsl:for-each select="$hmi_element/*[@inkscape:label]">
  5678       <xsl:text>        </xsl:text>
  5678       <xsl:text>        "</xsl:text>
  5679       <xsl:value-of select="@inkscape:label"/>
  5679       <xsl:value-of select="@inkscape:label"/>
  5680       <xsl:text>: "</xsl:text>
  5680       <xsl:text>": "</xsl:text>
  5681       <xsl:value-of select="@id"/>
  5681       <xsl:value-of select="@id"/>
  5682       <xsl:text>",
  5682       <xsl:text>",
  5683 </xsl:text>
  5683 </xsl:text>
  5684     </xsl:for-each>
  5684     </xsl:for-each>
       
  5685     <xsl:text>    },
       
  5686 </xsl:text>
       
  5687   </xsl:template>
       
  5688   <xsl:template match="widget[@type='ListSwitch']" mode="widget_desc">
       
  5689     <type>
       
  5690       <xsl:value-of select="@type"/>
       
  5691     </type>
       
  5692     <longdesc>
       
  5693       <xsl:text>ListSwitch widget displays one item of an HMI:List depending on value of
       
  5694 </xsl:text>
       
  5695       <xsl:text>given variable. Main element of the widget must be a clone of the list or
       
  5696 </xsl:text>
       
  5697       <xsl:text>of an item of that list.  
       
  5698 </xsl:text>
       
  5699       <xsl:text>
       
  5700 </xsl:text>
       
  5701       <xsl:text>Given variable's current value is compared to list items
       
  5702 </xsl:text>
       
  5703       <xsl:text>label. For exemple if given variable type
       
  5704 </xsl:text>
       
  5705       <xsl:text>is HMI_INT and value is 1, then item with label '1' will be displayed.
       
  5706 </xsl:text>
       
  5707       <xsl:text>If matching variable of type HMI_STRING, then no quotes are needed. 
       
  5708 </xsl:text>
       
  5709       <xsl:text>For exemple, 'hello' match HMI_STRING 'hello'.
       
  5710 </xsl:text>
       
  5711     </longdesc>
       
  5712     <shortdesc>
       
  5713       <xsl:text>Displays item of an HMI:List whose label matches value.</xsl:text>
       
  5714     </shortdesc>
       
  5715     <path name="value" accepts="HMI_INT,HMI_STRING">
       
  5716       <xsl:text>value to compare to labels</xsl:text>
       
  5717     </path>
       
  5718   </xsl:template>
       
  5719   <xsl:template match="widget[@type='ListSwitch']" mode="widget_class">
       
  5720     <xsl:text>class </xsl:text>
       
  5721     <xsl:text>ListSwitchWidget</xsl:text>
       
  5722     <xsl:text> extends Widget{
       
  5723 </xsl:text>
       
  5724     <xsl:text>    frequency = 5;
       
  5725 </xsl:text>
       
  5726     <xsl:text>}
       
  5727 </xsl:text>
       
  5728   </xsl:template>
       
  5729   <xsl:template match="widget[@type='ListSwitch']" mode="widget_defs">
       
  5730     <xsl:param name="hmi_element"/>
       
  5731     <xsl:variable name="targetid" select="substring-after($hmi_element/@xlink:href,'#')"/>
       
  5732     <xsl:variable name="from_list" select="$hmi_lists[(@id | */@id) = $targetid]"/>
       
  5733     <xsl:text>    dispatch: function(value) {
       
  5734 </xsl:text>
       
  5735     <xsl:text>        this.element.href.baseVal = "#"+hmi_widgets["</xsl:text>
       
  5736     <xsl:value-of select="$from_list/@id"/>
       
  5737     <xsl:text>"].items[value];
       
  5738 </xsl:text>
  5685     <xsl:text>    },
  5739     <xsl:text>    },
  5686 </xsl:text>
  5740 </xsl:text>
  5687   </xsl:template>
  5741   </xsl:template>
  5688   <xsl:template match="widget[@type='Meter']" mode="widget_desc">
  5742   <xsl:template match="widget[@type='Meter']" mode="widget_desc">
  5689     <type>
  5743     <type>
  7237 </xsl:text>
  7291 </xsl:text>
  7238       <xsl:text>'"hello"' or '"hello"#another comment' match HMI_STRING 'hello'.
  7292       <xsl:text>'"hello"' or '"hello"#another comment' match HMI_STRING 'hello'.
  7239 </xsl:text>
  7293 </xsl:text>
  7240     </longdesc>
  7294     </longdesc>
  7241     <shortdesc>
  7295     <shortdesc>
  7242       <xsl:text>Show elements whose label match value.</xsl:text>
  7296       <xsl:text>Show elements whose label matches value.</xsl:text>
  7243     </shortdesc>
  7297     </shortdesc>
  7244     <path name="value" accepts="HMI_INT,HMI_STRING">
  7298     <path name="value" accepts="HMI_INT,HMI_STRING">
  7245       <xsl:text>value to compare to labels</xsl:text>
  7299       <xsl:text>value to compare to labels</xsl:text>
  7246     </path>
  7300     </path>
  7247   </xsl:template>
  7301   </xsl:template>
  8430 </xsl:text>
  8484 </xsl:text>
  8431           <xsl:text>
  8485           <xsl:text>
  8432 </xsl:text>
  8486 </xsl:text>
  8433           <xsl:text>// subscribe to per instance current page hmi variable
  8487           <xsl:text>// subscribe to per instance current page hmi variable
  8434 </xsl:text>
  8488 </xsl:text>
       
  8489           <xsl:text>// PLC must prefix page name with "!" for page switch to happen
       
  8490 </xsl:text>
  8435           <xsl:text>subscribers(current_page_var_index).add({
  8491           <xsl:text>subscribers(current_page_var_index).add({
  8436 </xsl:text>
  8492 </xsl:text>
  8437           <xsl:text>    frequency: 1,
  8493           <xsl:text>    frequency: 1,
  8438 </xsl:text>
  8494 </xsl:text>
  8439           <xsl:text>    indexes: [current_page_var_index],
  8495           <xsl:text>    indexes: [current_page_var_index],
  8440 </xsl:text>
  8496 </xsl:text>
  8441           <xsl:text>    new_hmi_value: function(index, value, oldval) {
  8497           <xsl:text>    new_hmi_value: function(index, value, oldval) {
  8442 </xsl:text>
  8498 </xsl:text>
  8443           <xsl:text>        switch_page(value);
  8499           <xsl:text>        if(value.startsWith("!"))
       
  8500 </xsl:text>
       
  8501           <xsl:text>            switch_page(value.slice(1));
  8444 </xsl:text>
  8502 </xsl:text>
  8445           <xsl:text>    }
  8503           <xsl:text>    }
  8446 </xsl:text>
  8504 </xsl:text>
  8447           <xsl:text>});
  8505           <xsl:text>});
  8448 </xsl:text>
  8506 </xsl:text>
  8944 </xsl:text>
  9002 </xsl:text>
  8945           <xsl:text>        jump_history.shift();
  9003           <xsl:text>        jump_history.shift();
  8946 </xsl:text>
  9004 </xsl:text>
  8947           <xsl:text>
  9005           <xsl:text>
  8948 </xsl:text>
  9006 </xsl:text>
  8949           <xsl:text>    apply_hmi_value(current_page_var_index,
  9007           <xsl:text>    apply_hmi_value(current_page_var_index, page_index == undefined
  8950 </xsl:text>
  9008 </xsl:text>
  8951           <xsl:text>                    page_index == undefined
  9009           <xsl:text>        ? page_name
  8952 </xsl:text>
  9010 </xsl:text>
  8953           <xsl:text>                        ? page_name
  9011           <xsl:text>        : page_name + "@" + hmitree_paths[page_index]);
  8954 </xsl:text>
       
  8955           <xsl:text>                        : page_name + "@" + hmitree_paths[page_index]);
       
  8956 </xsl:text>
  9012 </xsl:text>
  8957           <xsl:text>
  9013           <xsl:text>
  8958 </xsl:text>
  9014 </xsl:text>
  8959           <xsl:text>    return true;
  9015           <xsl:text>    return true;
  8960 </xsl:text>
  9016 </xsl:text>