--- a/svghmi/gen_index_xhtml.xslt Wed Nov 13 11:21:04 2019 +0100
+++ b/svghmi/gen_index_xhtml.xslt Wed Nov 13 11:22:53 2019 +0100
@@ -33,10 +33,7 @@
<xsl:text>HMI_ROOT</xsl:text>
- <xsl:text>HMI_LABEL</xsl:text>
- <xsl:text>HMI_CLASS</xsl:text>
+ <xsl:text>HMI_NODE</xsl:text> <xsl:text>HMI_PLC_STATUS</xsl:text>
@@ -123,6 +120,15 @@
<xsl:text>Made with SVGHMI. https://beremiz.org</xsl:text>
+ <xsl:apply-templates mode="testgeo" select="$hmi_geometry"/> + <xsl:apply-templates mode="testtree" select="$hmitree"/> + <xsl:apply-templates mode="testtree" select="$indexed_hmitree"/> <html xmlns="http://www.w3.org/1999/xhtml">
<body style="margin:0;overflow:hidden;">
@@ -225,9 +231,9 @@
<xsl:variable name="hmitree_match" select="$indexed_hmitree/*[@hmipath = $hmipath]"/>
<xsl:if test="count($hmitree_match) = 0">
<xsl:message terminate="yes">
- <xsl:text>No match for HMI </xsl:text>
+ <xsl:text>No match for path "</xsl:text> <xsl:value-of select="$hmipath"/>
+ <xsl:text>" in HMI tree</xsl:text> @@ -799,6 +805,40 @@
+ <xsl:template mode="testgeo" match="bbox"> + <xsl:text>ID: </xsl:text> + <xsl:value-of select="@Id"/> + <xsl:text> x: </xsl:text> + <xsl:value-of select="@x"/> + <xsl:text> y: </xsl:text> + <xsl:value-of select="@y"/> + <xsl:text> w: </xsl:text> + <xsl:value-of select="@w"/> + <xsl:text> h: </xsl:text> + <xsl:value-of select="@h"/> + <xsl:template mode="testtree" match="*"> + <xsl:param name="indent" select="''"/> + <xsl:value-of select="$indent"/> + <xsl:value-of select="local-name()"/> + <xsl:for-each select="@*"> + <xsl:value-of select="local-name()"/> + <xsl:value-of select="."/> + <xsl:apply-templates mode="testtree" select="*"> + <xsl:with-param name="indent"> + <xsl:value-of select="concat($indent,'>')"/> <xsl:template name="defs_by_labels">
<xsl:param name="labels" select="''"/>
<xsl:param name="mandatory" select="'yes'"/>
--- a/svghmi/gen_index_xhtml.ysl2 Wed Nov 13 11:21:04 2019 +0100
+++ b/svghmi/gen_index_xhtml.ysl2 Wed Nov 13 11:22:53 2019 +0100
@@ -55,8 +55,7 @@
noindex > HMI_CURRENT_PAGE
@@ -122,7 +121,7 @@
/* copy root node and add geometry as comment for a test */
comment > Made with SVGHMI. https://beremiz.org
apply "$hmi_geometry", mode="testgeo";
@@ -132,7 +131,7 @@
apply "$indexed_hmitree", mode="testtree";
html xmlns="http://www.w3.org/1999/xhtml" {
body style="margin:0;overflow:hidden;" {
@@ -229,7 +228,7 @@
const "hmipath","@value";
const "hmitree_match","$indexed_hmitree/*[@hmipath = $hmipath]";
if "count($hmitree_match) = 0"
- error > No match for HMI «$hmipath»;
+ error > No match for path "«$hmipath»" in HMI tree | «$hmitree_match/@index»`if "position()!=last()" > ,`
@@ -307,7 +306,7 @@
template "bbox", mode="testgeo"{
| ID: «@Id» x: «@x» y: «@y» w: «@w» h: «@h»
@@ -321,7 +320,7 @@
with "indent" value "concat($indent,'>')"
function "defs_by_labels" {
--- a/svghmi/pous.xml Wed Nov 13 11:21:04 2019 +0100
+++ b/svghmi/pous.xml Wed Nov 13 11:22:53 2019 +0100
@@ -36,12 +36,7 @@
- <dataType name="HMI_CLASS">
- <dataType name="HMI_LABEL">
+ <dataType name="HMI_NODE"> --- a/svghmi/svghmi.py Wed Nov 13 11:21:04 2019 +0100
+++ b/svghmi/svghmi.py Wed Nov 13 11:22:53 2019 +0100
@@ -25,8 +25,7 @@
@@ -35,19 +34,21 @@
HMI_TYPES = HMI_TYPES_DESC.keys()
from XSLTransform import XSLTransform
+from lxml.etree import XSLTApplyError ScriptDirectory = paths.AbsDir(__file__)
class HMITreeNode(object):
- def __init__(self, path, name, nodetype, iectype = None, vartype = None):
+ def __init__(self, path, name, nodetype, iectype = None, vartype = None, hmiclass = None): + self.hmiclass = hmiclass - if nodetype in ["HMI_LABEL", "HMI_ROOT"]:
+ if nodetype in ["HMI_NODE", "HMI_ROOT"]: def pprint(self, indent = 0):
@@ -73,7 +74,7 @@
if in_common > known_best_match:
known_best_match = in_common
- if best_child is not None and best_child.nodetype == "HMI_LABEL":
+ if best_child is not None and best_child.nodetype == "HMI_NODE": best_child.place_node(node)
self.children.append(node)
@@ -136,12 +137,12 @@
@@ -152,11 +153,11 @@
@@ -180,7 +181,14 @@
# ignores variables starting with _TMP_
if path[-1].startswith("_TMP_"):
- new_node = HMITreeNode(path, path[-1], v["derived"], v["type"], v["vartype"])
+ if derived == "HMI_NODE": + kwargs['hmiclass'] = path[-1] + new_node = HMITreeNode(path, name, derived, v["type"], v["vartype"], **kwargs) hmi_tree_root.place_node(new_node)
@@ -189,7 +197,7 @@
for node in hmi_tree_root.traverse():
if hasattr(node, "iectype") and \
- node.nodetype not in ["HMI_CLASS", "HMI_LABEL"]:
+ node.nodetype not in ["HMI_NODE"]: sz = DebugTypesSize.get(node.iectype, 0)
"{&(" + ".".join(node.path) + "), " + node.iectype + {
@@ -357,7 +365,10 @@
svgdom = etree.parse(svgfile)
# call xslt transform on Inkscape's SVG to generate XHTML
- result = transform.transform(svgdom)
+ result = transform.transform(svgdom) + except XSLTApplyError as e: + self.FatalError("SVGHMI " + view_name + ": " + e.message) result.write(target_file, encoding="utf-8")
--- a/tests/svghmi/plc.xml Wed Nov 13 11:21:04 2019 +0100
+++ b/tests/svghmi/plc.xml Wed Nov 13 11:22:53 2019 +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="2019-10-27T21:48:33">
+ <contentHeader name="Unnamed" modificationDateTime="2019-11-12T13:19:15"> @@ -30,6 +30,11 @@
<derived name="PumpControl"/>
+ <variable name="Pump1"> + <derived name="PumpControl"/> @@ -57,6 +62,24 @@
<expression>TargetPressure</expression>
+ <block localId="1" typeName="PumpControl" instanceName="Pump1" executionOrderId="0" height="40" width="127"> + <position x="605" y="145"/> + <variable formalParameter="TargetPressure"> + <relPosition x="0" y="30"/> + <connection refLocalId="5"> + <position x="605" y="175"/> + <position x="587" y="175"/> + <position x="587" y="80"/> + <position x="570" y="80"/> @@ -65,7 +88,7 @@
- <derived name="HMI_LABEL"/>
+ <derived name="HMI_NODE"/> <variable name="Pressure">
--- a/tests/svghmi/svghmi_0@svghmi/svghmi.svg Wed Nov 13 11:21:04 2019 +0100
+++ b/tests/svghmi/svghmi_0@svghmi/svghmi.svg Wed Nov 13 11:22:53 2019 +0100
@@ -113,12 +113,12 @@
inkscape:document-units="px"
- inkscape:current-layer="g110"
+ inkscape:current-layer="hmi0" inkscape:zoom="0.8046875"
- inkscape:cx="478.76479"
- inkscape:cy="-403.42943"
+ inkscape:cx="959.69683" inkscape:window-width="1600"
inkscape:window-height="886"
@@ -321,7 +321,7 @@
- inkscape:label="HMI:Display@/PUMP/PRESSURE"
+ inkscape:label="HMI:Display@/PUMP0/PRESSURE" @@ -335,7 +335,7 @@
transform="matrix(3.7795276,0,0,3.7795276,308.51002,630.30393)"
- inkscape:label="HMI:Meter@/PUMP/SLOTH">
+ inkscape:label="HMI:Meter@/PUMP0/SLOTH"> 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;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#3ee800;stroke-width:26.45833397;stroke-miterlimit:4;stroke-dasharray:2.64583333, 2.64583333;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
@@ -635,7 +635,7 @@
sodipodi:role="line">Home</tspan></text>
- inkscape:label="HMI:Meter@/PUMP/SLOTH"
+ inkscape:label="HMI:Meter@/PUMP0/SLOTH" transform="matrix(7.5590552,0,0,7.5590552,-244.3956,1321.2434)"
@@ -892,7 +892,7 @@
- inkscape:label="HMI:Display@/PUMP/PRESSURE"><tspan
+ inkscape:label="HMI:Display@/PUMP0/PRESSURE"><tspan