--- 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 @@
<xsl:variable name="hmitree" select="ns:GetHMITree()"/>
<xsl:variable name="_categories">
- <xsl:text>HMI_ROOT</xsl:text>
<xsl:text>HMI_PLC_STATUS</xsl:text>
@@ -25,8 +22,12 @@
<xsl:variable name="content">
<xsl:variable name="path">
- <xsl:when test="local-name() = 'HMI_ROOT'">
- <xsl:value-of select="$parentpath"/>
+ <xsl:when test="count(ancestor::*)=0"> + <xsl:when test="count(ancestor::*)=1"> + <xsl:value-of select="@name"/> <xsl:value-of select="$parentpath"/>
@@ -597,8 +598,11 @@
<xsl:value-of select="@index"/>
+ <xsl:text> /*</xsl:text> + <xsl:value-of select="$widget/path"/> + <xsl:text>*/ </xsl:text> <xsl:if test="position()!=last()">
@@ -676,6 +680,51 @@
+ <xsl:template mode="widget_defs" match="widget[@type='ForEach']"> + <xsl:param name="hmi_element"/> + <xsl:text> frequency: 2, + <xsl:text> dispatch: function(value) { + <xsl:text> // do something + <xsl:text> init: function() { + <xsl:for-each select="$hmi_element/*[regexp:test(@inkscape:label,'^[=+\-].+')]"> + <xsl:text> id("</xsl:text> + <xsl:value-of select="@id"/> + <xsl:text>").addEventListener( + <xsl:text> evt => {let new_val = "</xsl:text> + <xsl:value-of select="func:escape_quotes(@inkscape:label)"/> + <xsl:text> // do something with new_val + <xsl:template mode="widget_subscribe" match="widget[@type='ForEach']"> + <xsl:text> sub: function(off){ + <xsl:text> subscribe.call(this,off) + <xsl:text> unsub: function(){ + <xsl:text> unsubscribe.call(this) <xsl:template mode="widget_defs" match="widget[@type='Display']">
<xsl:param name="hmi_element"/>
@@ -1134,6 +1183,8 @@
<xsl:text> BOOL: (dv,offset) => [dv.getInt8(offset, true), 1],
+ <xsl:text> NODE: (dv,offset) => [dv.getInt8(offset, true), 1], <xsl:text> STRING: (dv, offset) => {
<xsl:text> size = dv.getInt8(offset);
@@ -1316,6 +1367,8 @@
<xsl:text> BOOL: (truth) => new Int16Array([truth]),
+ <xsl:text> NODE: (truth) => new Int16Array([truth]), <xsl:text> STRING: (str) => {
<xsl:text> // beremiz default string max size is 128
--- 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()";
noindex > HMI_CURRENT_PAGE
@@ -21,7 +20,8 @@
- when "local-name() = 'HMI_ROOT'" > «$parentpath»
+ when "count(ancestor::*)=0" > / + when "count(ancestor::*)=1" > /«@name» otherwise > «$parentpath»/«@name»
--- 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 @@
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);
@@ -148,6 +149,7 @@
const typedarray_types = {
INT: (number) => new Int16Array([number]),
BOOL: (truth) => new Int16Array([truth]),
+ NODE: (truth) => new Int16Array([truth]), // beremiz default string max size is 128
--- 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 @@
- if nodetype in ["HMI_NODE", "HMI_ROOT"]:
+ if nodetype in ["HMI_NODE"]: def pprint(self, indent = 0):
@@ -136,7 +136,8 @@
-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 @@
hmi_types_instances = [v for v in varlist if v["derived"] in HMI_TYPES]
- hmi_tree_root = HMITreeNode(None, "/", "HMI_ROOT")
+ # take first HMI_NODE (placed as special node), make it root + for i,v in enumerate(hmi_types_instances): + path = v["IEC_path"].split(".") + 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) + assert(hmi_tree_root is not None) # deduce HMI tree from PLC HMI_* instances
for v in hmi_types_instances:
@@ -444,12 +456,6 @@
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()
--- 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
- | «@index»`if "position()!=last()" > ,`
+ | «@index» /*«$widget/path»*/ `if "position()!=last()" > ,`