# HG changeset patch # User Edouard Tisserant # Date 1584694859 -3600 # Node ID ae8063127e959dc962f6cbf1f70fd61501ed092e # Parent 4eeed820fd3a9f97c8f12f4e86399a877838820c SVGHMI: make root HMI tree node a HMI_NODE, droped HMI_ROOT node type diff -r 4eeed820fd3a -r ae8063127e95 svghmi/gen_index_xhtml.xslt --- a/svghmi/gen_index_xhtml.xslt Thu Mar 19 19:23:56 2020 +0100 +++ b/svghmi/gen_index_xhtml.xslt Fri Mar 20 10:00:59 2020 +0100 @@ -5,9 +5,6 @@ - HMI_ROOT - - HMI_PLC_STATUS @@ -25,8 +22,12 @@ - - + + / + + + / + @@ -597,8 +598,11 @@ - + + /* + + */ , @@ -676,6 +680,51 @@ + + + frequency: 2, + + dispatch: function(value) { + + // do something + + }, + + init: function() { + + + id(" + + ").addEventListener( + + "click", + + evt => {let new_val = " + + "); + + // do something with new_val + + }); + + + }, + + + + sub: function(off){ + + subscribe.call(this,off) + + }, + + unsub: function(){ + + unsubscribe.call(this) + + }, + + frequency: 5, @@ -1134,6 +1183,8 @@ BOOL: (dv,offset) => [dv.getInt8(offset, true), 1], + NODE: (dv,offset) => [dv.getInt8(offset, true), 1], + STRING: (dv, offset) => { size = dv.getInt8(offset); @@ -1316,6 +1367,8 @@ BOOL: (truth) => new Int16Array([truth]), + NODE: (truth) => new Int16Array([truth]), + STRING: (str) => { // beremiz default string max size is 128 diff -r 4eeed820fd3a -r ae8063127e95 svghmi/hmi_tree.ysl2 --- a/svghmi/hmi_tree.ysl2 Thu Mar 19 19:23:56 2020 +0100 +++ b/svghmi/hmi_tree.ysl2 Fri Mar 20 10:00:59 2020 +0100 @@ -5,7 +5,6 @@ const "hmitree", "ns:GetHMITree()"; const "_categories" { - noindex > HMI_ROOT noindex > HMI_PLC_STATUS noindex > HMI_CURRENT_PAGE } @@ -21,7 +20,8 @@ const "content" { const "path" choose { - when "local-name() = 'HMI_ROOT'" > «$parentpath» + when "count(ancestor::*)=0" > / + when "count(ancestor::*)=1" > /«@name» otherwise > «$parentpath»/«@name» } choose { diff -r 4eeed820fd3a -r ae8063127e95 svghmi/svghmi.js --- a/svghmi/svghmi.js Thu Mar 19 19:23:56 2020 +0100 +++ b/svghmi/svghmi.js Fri Mar 20 10:00:59 2020 +0100 @@ -57,6 +57,7 @@ const dvgetters = { INT: (dv,offset) => [dv.getInt16(offset, true), 2], BOOL: (dv,offset) => [dv.getInt8(offset, true), 1], + NODE: (dv,offset) => [dv.getInt8(offset, true), 1], STRING: (dv, offset) => { size = dv.getInt8(offset); return [ @@ -148,6 +149,7 @@ const typedarray_types = { INT: (number) => new Int16Array([number]), BOOL: (truth) => new Int16Array([truth]), + NODE: (truth) => new Int16Array([truth]), STRING: (str) => { // beremiz default string max size is 128 str = str.slice(0,128); diff -r 4eeed820fd3a -r ae8063127e95 svghmi/svghmi.py --- 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() diff -r 4eeed820fd3a -r ae8063127e95 svghmi/widgets_common.ysl2 --- a/svghmi/widgets_common.ysl2 Thu Mar 19 19:23:56 2020 +0100 +++ b/svghmi/widgets_common.ysl2 Fri Mar 20 10:00:59 2020 +0100 @@ -28,7 +28,7 @@ warning > Widget «$widget/@type» id="«$eltid»" : No match for path "«@value»" in HMI tree } otherwise { - | «@index»`if "position()!=last()" > ,` + | «@index» /*«$widget/path»*/ `if "position()!=last()" > ,` } } }