# HG changeset patch # User Edouard Tisserant # Date 1573640573 -3600 # Node ID 2cabc47738859cc732c570c1031ad76db26efcca # Parent ac736a878188157dfa0b13933d642a15ebe46a1d SVGHMI: HMI_LABEL and HMI_CLASS become HMI_NODE. - Name of parent POU becomes HMI tree node name, - Name of HMI_NODE variable becomes class of the node. diff -r ac736a878188 -r 2cabc4773885 svghmi/gen_index_xhtml.xslt --- 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 @@ HMI_ROOT - HMI_LABEL - - - HMI_CLASS + HMI_NODE HMI_PLC_STATUS @@ -123,6 +120,15 @@ Made with SVGHMI. https://beremiz.org + + + + + + + + + @@ -225,9 +231,9 @@ - No match for HMI + No match for path " - ; + " in HMI tree @@ -799,6 +805,40 @@ //})(); + + ID: + + x: + + y: + + w: + + h: + + + + + + + + + + + + + = + + + + + + + + + + + diff -r ac736a878188 -r 2cabc4773885 svghmi/gen_index_xhtml.ysl2 --- 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 @@ const "_categories" { noindex > HMI_ROOT - noindex > HMI_LABEL - noindex > HMI_CLASS + noindex > HMI_NODE noindex > HMI_PLC_STATUS noindex > HMI_CURRENT_PAGE } @@ -122,7 +121,7 @@ /* copy root node and add geometry as comment for a test */ template "/" { comment > Made with SVGHMI. https://beremiz.org - /* DEBUG DATA + /* DEBUG DATA */ comment { apply "$hmi_geometry", mode="testgeo"; } @@ -132,7 +131,7 @@ comment { apply "$indexed_hmitree", mode="testtree"; } - */ + /**/ html xmlns="http://www.w3.org/1999/xhtml" { head; 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" { param "labels","''"; diff -r ac736a878188 -r 2cabc4773885 svghmi/pous.xml --- 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 @@ - - - - - - + diff -r ac736a878188 -r 2cabc4773885 svghmi/svghmi.py --- 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 @@ import targets HMI_TYPES_DESC = { - "HMI_CLASS":{}, - "HMI_LABEL":{}, + "HMI_NODE":{}, "HMI_STRING":{}, "HMI_INT":{}, "HMI_REAL":{} @@ -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.path = path self.name = name self.nodetype = nodetype + self.hmiclass = hmiclass if iectype is not None: self.iectype = iectype self.vartype = vartype - if nodetype in ["HMI_LABEL", "HMI_ROOT"]: + if nodetype in ["HMI_NODE", "HMI_ROOT"]: self.children = [] def pprint(self, indent = 0): @@ -73,7 +74,7 @@ if in_common > known_best_match: known_best_match = in_common best_child = child - 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) else: self.children.append(node) @@ -136,12 +137,12 @@ +->v1 HMI_INT +->v2 HMI_INT +->fb0 (type mhoo) - | +->va HMI_LABEL + | +->va HMI_NODE | +->v3 HMI_INT | +->v4 HMI_INT | +->fb1 (type mhoo) - | +->va HMI_LABEL + | +->va HMI_NODE | +->v3 HMI_INT | +->v4 HMI_INT | @@ -152,11 +153,11 @@ hmi0 +->v1 +->v2 - +->fb0_va + +->fb0 class:va | +-> v3 | +-> v4 | - +->fb1_va + +->fb1 class:va | +-> v3 | +-> v4 | @@ -180,7 +181,14 @@ # ignores variables starting with _TMP_ if path[-1].startswith("_TMP_"): continue - new_node = HMITreeNode(path, path[-1], v["derived"], v["type"], v["vartype"]) + derived = v["derived"] + kwargs={} + if derived == "HMI_NODE": + name = path[-2] + kwargs['hmiclass'] = path[-1] + else: + name = path[-1] + new_node = HMITreeNode(path, name, derived, v["type"], v["vartype"], **kwargs) hmi_tree_root.place_node(new_node) variable_decl_array = [] @@ -189,7 +197,7 @@ item_count = 0 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) variable_decl_array += [ "{&(" + ".".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) + try: + result = transform.transform(svgdom) + except XSLTApplyError as e: + self.FatalError("SVGHMI " + view_name + ": " + e.message) result.write(target_file, encoding="utf-8") # print(str(result)) diff -r ac736a878188 -r 2cabc4773885 tests/svghmi/plc.xml --- 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 @@ - + @@ -30,6 +30,11 @@ + + + + + @@ -57,6 +62,24 @@ TargetPressure + + + + + + + + + + + + + + + + + + @@ -65,7 +88,7 @@ - + diff -r ac736a878188 -r 2cabc4773885 tests/svghmi/svghmi_0@svghmi/svghmi.svg --- 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:pageopacity="0" inkscape:pageshadow="2" inkscape:document-units="px" - inkscape:current-layer="g110" + inkscape:current-layer="hmi0" showgrid="false" units="px" inkscape:zoom="0.8046875" - inkscape:cx="478.76479" - inkscape:cy="-403.42943" + inkscape:cx="959.69683" + inkscape:cy="656.6094" inkscape:window-width="1600" inkscape:window-height="886" inkscape:window-x="0" @@ -321,7 +321,7 @@ inkscape:label="=0" /> + inkscape:label="HMI:Meter@/PUMP0/SLOTH"> Home