--- a/svghmi/svghmi.py Thu Mar 19 19:23:56 2020 +0100
+++ b/svghmi/svghmi.py Fri Mar 20 10:00:59 2020 +0100
@@ -55,7 +55,7 @@
self.vartype = vartype
self.cpath = cpath
- if nodetype in ["HMI_NODE", "HMI_ROOT"]:
+ if nodetype in ["HMI_NODE"]:
self.children = []
def pprint(self, indent = 0):
@@ -136,7 +136,8 @@
on_hmitree_update = None
-SPECIAL_NODES = [("heartbeat", "HMI_INT")]
+SPECIAL_NODES = [("HMI_ROOT", "HMI_NODE"),
+ ("heartbeat", "HMI_INT")]
# ("current_page", "HMI_STRING")])
class SVGHMILibrary(POULibrary):
@@ -183,7 +184,18 @@
# Filter known HMI types
hmi_types_instances = [v for v in varlist if v["derived"] in HMI_TYPES]
- hmi_tree_root = HMITreeNode(None, "/", "HMI_ROOT")
+ hmi_tree_root = None
+
+ # take first HMI_NODE (placed as special node), make it root
+ for i,v in enumerate(hmi_types_instances):
+ path = v["IEC_path"].split(".")
+ derived = v["derived"]
+ if derived == "HMI_NODE" and ['CONFIG', 'HEARTBEAT'] :
+ hmi_tree_root = HMITreeNode(path, "", derived, v["type"], v["vartype"], v["C_path"])
+ hmi_types_instances.pop(i)
+ break
+
+ assert(hmi_tree_root is not None)
# deduce HMI tree from PLC HMI_* instances
for v in hmi_types_instances:
@@ -444,12 +456,6 @@
return res
def CTNGenerate_C(self, buildpath, locations):
- """
- Return C code generated by iec2c compiler
- when _generate_softPLC have been called
- @param locations: ignored
- @return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND
- """
location_str = "_".join(map(str, self.GetCurrentLocation()))
view_name = self.BaseParams.getName()