--- a/svghmi/analyse_widget.xslt Mon Nov 08 14:09:44 2021 +0100
+++ b/svghmi/analyse_widget.xslt Mon Nov 08 14:10:36 2021 +0100
@@ -471,7 +471,7 @@
- <xsl:text>Documentation to be written. see svbghmi exemple.
+ <xsl:text>Documentation to be written. see svghmi exemple. @@ -566,6 +566,37 @@
+ <xsl:template match="widget[@type='ListSwitch']" mode="widget_desc"> + <xsl:value-of select="@type"/> + <xsl:text>ListSwitch widget displays one item of an HMI:List depending on value of + <xsl:text>given variable. Main element of the widget must be a clone of the list or + <xsl:text>of an item of that list. + <xsl:text>Given variable's current value is compared to list items + <xsl:text>label. For exemple if given variable type + <xsl:text>is HMI_INT and value is 1, then item with label '1' will be displayed. + <xsl:text>If matching variable of type HMI_STRING, then no quotes are needed. + <xsl:text>For exemple, 'hello' match HMI_STRING 'hello'. + <xsl:text>Displays item of an HMI:List whose label matches value.</xsl:text> + <path name="value" accepts="HMI_INT,HMI_STRING"> + <xsl:text>value to compare to labels</xsl:text> <xsl:template match="widget[@type='Meter']" mode="widget_desc">
<xsl:value-of select="@type"/>
@@ -687,7 +718,7 @@
- <xsl:text>Show elements whose label match value.</xsl:text>
+ <xsl:text>Show elements whose label matches value.</xsl:text> <path name="value" accepts="HMI_INT,HMI_STRING">
<xsl:text>value to compare to labels</xsl:text>
--- a/svghmi/gen_index_xhtml.xslt Mon Nov 08 14:09:44 2021 +0100
+++ b/svghmi/gen_index_xhtml.xslt Mon Nov 08 14:10:36 2021 +0100
@@ -572,7 +572,7 @@
<xsl:variable name="required_page_elements" select="func:required_elements($hmi_pages | $keypads)/ancestor-or-self::svg:*"/>
- <xsl:variable name="required_list_elements" select="func:refered_elements(($hmi_lists | $hmi_textlists)[@id = $required_page_elements/@id])"/>
+ <xsl:variable name="required_list_elements" select="func:refered_elements(($hmi_lists | $hmi_textlists)[@id = $required_page_elements/@id])/ancestor-or-self::svg:*"/> <xsl:variable name="required_elements" select="$defs | $required_list_elements | $required_page_elements"/>
<xsl:variable name="discardable_elements" select="//svg:*[not(@id = $required_elements/@id)]"/>
<func:function name="func:sumarized_elements">
@@ -846,7 +846,7 @@
<xsl:variable name="targets_not_to_unlink" select="$hmi_lists/descendant-or-self::svg:*"/>
- <xsl:variable name="to_unlink" select="$hmi_elements[not(@id = $hmi_pages/@id)]/descendant-or-self::svg:use"/>
+ <xsl:variable name="to_unlink" select="$hmi_widgets/descendant-or-self::svg:use"/> <func:function name="func:is_unlinkable">
<xsl:param name="targetid"/>
<xsl:param name="eltid"/>
@@ -4583,7 +4583,7 @@
- <xsl:text>Documentation to be written. see svbghmi exemple.
+ <xsl:text>Documentation to be written. see svghmi exemple. @@ -4833,13 +4833,13 @@
<xsl:when test="count($from_list) > 0">
<xsl:text> id("</xsl:text>
<xsl:value-of select="@id"/>
- <xsl:text>").setAttribute("xlink:href",
+ <xsl:text>").href.baseVal = <xsl:text> "#"+hmi_widgets["</xsl:text>
<xsl:value-of select="$from_list/@id"/>
<xsl:text>"].items[</xsl:text>
<xsl:value-of select="$expressions/expression[1]/@content"/>
@@ -5675,9 +5675,9 @@
<xsl:for-each select="$hmi_element/*[@inkscape:label]">
+ <xsl:text> "</xsl:text> <xsl:value-of select="@inkscape:label"/>
- <xsl:text>: "</xsl:text>
+ <xsl:text>": "</xsl:text> <xsl:value-of select="@id"/>
@@ -5685,6 +5685,60 @@
+ <xsl:template match="widget[@type='ListSwitch']" mode="widget_desc"> + <xsl:value-of select="@type"/> + <xsl:text>ListSwitch widget displays one item of an HMI:List depending on value of + <xsl:text>given variable. Main element of the widget must be a clone of the list or + <xsl:text>of an item of that list. + <xsl:text>Given variable's current value is compared to list items + <xsl:text>label. For exemple if given variable type + <xsl:text>is HMI_INT and value is 1, then item with label '1' will be displayed. + <xsl:text>If matching variable of type HMI_STRING, then no quotes are needed. + <xsl:text>For exemple, 'hello' match HMI_STRING 'hello'. + <xsl:text>Displays item of an HMI:List whose label matches value.</xsl:text> + <path name="value" accepts="HMI_INT,HMI_STRING"> + <xsl:text>value to compare to labels</xsl:text> + <xsl:template match="widget[@type='ListSwitch']" mode="widget_class"> + <xsl:text>class </xsl:text> + <xsl:text>ListSwitchWidget</xsl:text> + <xsl:text> extends Widget{ + <xsl:text> frequency = 5; + <xsl:template match="widget[@type='ListSwitch']" mode="widget_defs"> + <xsl:param name="hmi_element"/> + <xsl:variable name="targetid" select="substring-after($hmi_element/@xlink:href,'#')"/> + <xsl:variable name="from_list" select="$hmi_lists[(@id | */@id) = $targetid]"/> + <xsl:text> dispatch: function(value) { + <xsl:text> this.element.href.baseVal = "#"+hmi_widgets["</xsl:text> + <xsl:value-of select="$from_list/@id"/> + <xsl:text>"].items[value]; <xsl:template match="widget[@type='Meter']" mode="widget_desc">
<xsl:value-of select="@type"/>
@@ -7239,7 +7293,7 @@
- <xsl:text>Show elements whose label match value.</xsl:text>
+ <xsl:text>Show elements whose label matches value.</xsl:text> <path name="value" accepts="HMI_INT,HMI_STRING">
<xsl:text>value to compare to labels</xsl:text>
@@ -8432,6 +8486,8 @@
<xsl:text>// subscribe to per instance current page hmi variable
+ <xsl:text>// PLC must prefix page name with "!" for page switch to happen <xsl:text>subscribers(current_page_var_index).add({
@@ -8440,7 +8496,9 @@
<xsl:text> new_hmi_value: function(index, value, oldval) {
- <xsl:text> switch_page(value);
+ <xsl:text> if(value.startsWith("!")) + <xsl:text> switch_page(value.slice(1)); @@ -8946,13 +9004,11 @@
- <xsl:text> apply_hmi_value(current_page_var_index,
- <xsl:text> page_index == undefined
- <xsl:text> : page_name + "@" + hmitree_paths[page_index]);
+ <xsl:text> apply_hmi_value(current_page_var_index, page_index == undefined + <xsl:text> : page_name + "@" + hmitree_paths[page_index]); --- a/tests/svghmi/plc.xml Mon Nov 08 14:09:44 2021 +0100
+++ b/tests/svghmi/plc.xml Mon Nov 08 14:10:36 2021 +0100
@@ -1,7 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<project xmlns:ns1="http://www.plcopen.org/xml/tc6_0201" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.plcopen.org/xml/tc6_0201">
<fileHeader companyName="Unknown" productName="Unnamed" productVersion="1" creationDateTime="2019-08-06T14:23:42"/>
- <contentHeader name="Unnamed" modificationDateTime="2021-11-04T11:35:21">
+ <contentHeader name="Unnamed" modificationDateTime="2021-11-08T13:54:01"> @@ -376,7 +376,7 @@
<relPosition x="220" y="10"/>
- <expression>'RelativePageTest@/TRUMP2'</expression>
+ <expression>'!RelativePageTest@/PUMP2'</expression> <block localId="17" typeName="R_TRIG" instanceName="R_TRIG0" executionOrderId="0" height="40" width="60">
<position x="220" y="185"/>
--- a/tests/svghmi/svghmi_0@svghmi/svghmi.svg Mon Nov 08 14:09:44 2021 +0100
+++ b/tests/svghmi/svghmi_0@svghmi/svghmi.svg Mon Nov 08 14:10:36 2021 +0100
@@ -128,14 +128,14 @@
inkscape:current-layer="hmi0"
- inkscape:zoom="0.42177818"
- inkscape:cx="543.13877"
- inkscape:cy="-467.92793"
- inkscape:window-width="2400"
- inkscape:window-height="2096"
- inkscape:window-x="3200"
+ inkscape:zoom="0.84355636" + inkscape:cx="-1054.5035" + inkscape:cy="482.64214" + inkscape:window-width="1600" + inkscape:window-height="836" - inkscape:window-maximized="0"
+ inkscape:window-maximized="1" inkscape:guide-bbox="true"
inkscape:snap-global="true"
@@ -7538,4 +7538,26 @@
style="text-align:center;text-anchor:middle;fill:#ff6600;stroke-width:0.99999994px"
id="tspan1330">000</tspan></text>
+ transform="translate(-2307.336,346.33773)" + inkscape:transform-center-x="0.14620371" + inkscape:transform-center-y="2.9995242" + inkscape:label="HMI:ListSwitch@/ALARMSTATUS" /> + inkscape:transform-center-y="2.9995242" + inkscape:transform-center-x="0.14620371" + transform="translate(-2307.336,1146.3377)" + inkscape:label="HMI:ListSwitch@/ALARMSTATUS" />