--- a/svghmi/svghmi.py Fri Nov 15 10:34:14 2019 +0100
+++ b/svghmi/svghmi.py Tue Dec 03 09:44:48 2019 +0100
@@ -57,17 +57,17 @@
def pprint(self, indent = 0):
res = ">"*indent + pformat(self.__dict__, indent = indent, depth = 1) + "\n"
- if hasattr(self, "children"):
+ if hasattr(self, "children"): res += "\n".join([child.pprint(indent = indent + 1)
for child in self.children])
def place_node(self, node):
- for child in self.children :
+ for child in self.children: if child.path is not None:
for child_path_item, node_path_item in izip(child.path, node.path):
@@ -82,7 +82,7 @@
best_child.place_node(node)
self.children.append(node)
def etree(self, add_hash=False):
attribs = dict(name=self.name)
@@ -97,7 +97,7 @@
res = etree.Element(self.nodetype, **attribs)
- if hasattr(self, "children"):
+ if hasattr(self, "children"): for child_etree in imap(lambda c:c.etree(), self.children):
@@ -105,7 +105,7 @@
- if hasattr(self, "children"):
+ if hasattr(self, "children"): for yoodl in c.traverse():
@@ -116,29 +116,29 @@
# limit size to HMI_HASH_SIZE as in svghmi.c
- return map(ord,s.digest())[:8]
+ return map(ord,s.digest())[:8] s.update(str((self.name,self.nodetype)))
- if hasattr(self, "children"):
+ if hasattr(self, "children"): # module scope for HMITree root
# so that CTN can use HMITree deduced in Library
-# note: this only works because library's Generate_C is
+# note: this only works because library's Generate_C is # systematicaly invoked before CTN's CTNGenerate_C
+on_hmitree_update = None class SVGHMILibrary(POULibrary):
def GetLibraryPath(self):
return paths.AbsNeighbourFile(__file__, "pous.xml")
def Generate_C(self, buildpath, varlist, IECCFLAGS):
- global hmi_tree_root, hmi_tree_updated, hmi_tree_unique_id
+ global hmi_tree_root, on_hmitree_update, hmi_tree_unique_id @@ -179,7 +179,7 @@
hmi_tree_root = HMITreeNode(None, "/", "HMI_ROOT")
map(lambda (n,t): hmi_tree_root.children.append(HMITreeNode(None,n,t)), [
("plc_status", "HMI_PLC_STATUS"),
("current_page", "HMI_CURRENT_PAGE")])
@@ -200,8 +200,8 @@
new_node = HMITreeNode(path, name, derived, v["type"], v["vartype"], **kwargs)
hmi_tree_root.place_node(new_node)
- if hmi_tree_updated is not None:
+ if on_hmitree_update is not None: extern_variables_declarations = []
@@ -243,7 +243,7 @@
svghmi_c_file = open(svghmi_c_filepath, 'r')
svghmi_c_code = svghmi_c_file.read()
- svghmi_c_code = svghmi_c_code % {
+ svghmi_c_code = svghmi_c_code % { "variable_decl_array": ",\n".join(variable_decl_array),
"extern_variables_declarations": "\n".join(extern_variables_declarations),
"buffer_size": buf_index,
@@ -445,7 +445,7 @@
result = transform.transform(svgdom)
except XSLTApplyError as e:
self.FatalError("SVGHMI " + view_name + ": " + e.message)
result.write(target_file, encoding="utf-8")
# print(transform.xslt.error_log)
@@ -455,7 +455,7 @@
# - ... maybe something to have a global view of what is declared in SVG.
- # TODO : use default svg that expose the HMI tree as-is
+ # TODO : use default svg that expose the HMI tree as-is target_file.write("""<!DOCTYPE html>