SVGHMI: added "page_node" variable that reflects the HMI tree path of current relative page
--- a/svghmi/gen_index_xhtml.xslt Fri Mar 26 14:53:35 2021 +0100
+++ b/svghmi/gen_index_xhtml.xslt Mon Mar 29 10:26:21 2021 +0200
@@ -44,8 +44,6 @@
<xsl:for-each select="$indexed_hmitree/*">
<xsl:text> /* </xsl:text>
<xsl:value-of select="@index"/>
- <xsl:text> </xsl:text>
- <xsl:value-of select="@hmipath"/>
<xsl:text> */ "</xsl:text>
<xsl:value-of select="substring(local-name(), 5)"/>
<xsl:text>"</xsl:text>
@@ -59,6 +57,24 @@
</xsl:text>
<xsl:text>
</xsl:text>
+ <xsl:text>var hmitree_paths = [
+</xsl:text>
+ <xsl:for-each select="$indexed_hmitree/*">
+ <xsl:text> /* </xsl:text>
+ <xsl:value-of select="@index"/>
+ <xsl:text> */ "</xsl:text>
+ <xsl:value-of select="@hmipath"/>
+ <xsl:text>"</xsl:text>
+ <xsl:if test="position()!=last()">
+ <xsl:text>,</xsl:text>
+ </xsl:if>
+ <xsl:text>
+</xsl:text>
+ </xsl:for-each>
+ <xsl:text>];
+</xsl:text>
+ <xsl:text>
+</xsl:text>
<xsl:text>
</xsl:text>
</xsl:template>
@@ -3052,9 +3068,7 @@
</xsl:text>
<xsl:text> function sprintf(key) {
</xsl:text>
- <xsl:text> // </xsl:text>
- <arguments/>
- <xsl:text> is not an array, but should be fine for this call
+ <xsl:text> // arguments is not an array, but should be fine for this call
</xsl:text>
<xsl:text> return sprintf_format(sprintf_parse(key), arguments)
</xsl:text>
@@ -7603,6 +7617,8 @@
</xsl:text>
<xsl:text>var current_page_index;
</xsl:text>
+ <xsl:text>var page_node_local_index = hmi_local_index("page_node");
+</xsl:text>
<xsl:text>
</xsl:text>
<xsl:text>function prepare_svg() {
@@ -7701,6 +7717,20 @@
</xsl:text>
<xsl:text> current_page_index = page_index;
</xsl:text>
+ <xsl:text> let page_node;
+</xsl:text>
+ <xsl:text> if(page_index != undefined){
+</xsl:text>
+ <xsl:text> page_node = hmitree_paths[page_index];
+</xsl:text>
+ <xsl:text> }else{
+</xsl:text>
+ <xsl:text> page_node = "";
+</xsl:text>
+ <xsl:text> }
+</xsl:text>
+ <xsl:text> apply_hmi_value(page_node_local_index, page_node);
+</xsl:text>
<xsl:text>
</xsl:text>
<xsl:text> jumps_need_update = true;
--- a/svghmi/svghmi.js Fri Mar 26 14:53:35 2021 +0100
+++ b/svghmi/svghmi.js Mon Mar 29 10:26:21 2021 +0200
@@ -359,6 +359,7 @@
var current_visible_page;
var current_subscribed_page;
var current_page_index;
+var page_node_local_index = hmi_local_index("page_node");
function prepare_svg() {
// prevents context menu from appearing on right click and long touch
@@ -408,6 +409,13 @@
current_subscribed_page = page_name;
current_page_index = page_index;
+ let page_node;
+ if(page_index != undefined){
+ page_node = hmitree_paths[page_index];
+ }else{
+ page_node = "";
+ }
+ apply_hmi_value(page_node_local_index, page_node);
jumps_need_update = true;
--- a/tests/svghmi/svghmi_0@svghmi/svghmi.svg Fri Mar 26 14:53:35 2021 +0100
+++ b/tests/svghmi/svghmi_0@svghmi/svghmi.svg Mon Mar 29 10:26:21 2021 +0200
@@ -128,12 +128,12 @@
inkscape:current-layer="hmi0"
showgrid="false"
units="px"
- inkscape:zoom="1.6871126"
- inkscape:cx="-820.55411"
- inkscape:cy="162.70697"
- inkscape:window-width="3840"
- inkscape:window-height="2096"
- inkscape:window-x="1600"
+ inkscape:zoom="0.42177815"
+ inkscape:cx="1614.7137"
+ inkscape:cy="168.68416"
+ inkscape:window-width="1600"
+ inkscape:window-height="836"
+ inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1"
showguides="true"
@@ -6021,7 +6021,7 @@
sodipodi:role="line">filter</tspan></text>
<g
id="g909"
- inkscape:label="HMI:VarInit:""@.filter" />
+ inkscape:label="HMI:VarInit:"POS"@.filter" />
<g
transform="matrix(0.14295135,0,0,0.14295135,449.21833,37.615184)"
id="g4646"
@@ -7160,4 +7160,16 @@
id="rect1163"
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#ff6600;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.11429262px;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
</g>
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-weight:normal;font-size:40px;line-height:125%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.25px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ x="1569.0527"
+ y="594.56055"
+ id="text1042"
+ inkscape:label="HMI:Display@page_node"><tspan
+ sodipodi:role="line"
+ id="tspan1040"
+ x="1569.0527"
+ y="594.56055"
+ style="fill:#ffffff;fill-opacity:1;stroke-width:0.25px">page node</tspan></text>
</svg>