2 <xsl:stylesheet xmlns:func="http://exslt.org/functions" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:svg="http://www.w3.org/2000/svg" xmlns:str="http://exslt.org/strings" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:exsl="http://exslt.org/common" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ns="beremiz" xmlns:cc="http://creativecommons.org/ns#" xmlns:regexp="http://exslt.org/regular-expressions" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dc="http://purl.org/dc/elements/1.1/" extension-element-prefixes="ns func exsl regexp str dyn" version="1.0" exclude-result-prefixes="ns str regexp exsl func dyn"> |
2 <xsl:stylesheet xmlns:func="http://exslt.org/functions" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:svg="http://www.w3.org/2000/svg" xmlns:str="http://exslt.org/strings" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:exsl="http://exslt.org/common" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ns="beremiz" xmlns:cc="http://creativecommons.org/ns#" xmlns:regexp="http://exslt.org/regular-expressions" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dc="http://purl.org/dc/elements/1.1/" extension-element-prefixes="ns func exsl regexp str dyn" version="1.0" exclude-result-prefixes="ns str regexp exsl func dyn"> |
3 <xsl:output method="xml" cdata-section-elements="xhtml:script"/> |
3 <xsl:output method="xml" cdata-section-elements="xhtml:script"/> |
4 <xsl:variable name="hmi_elements" select="//svg:*[starts-with(@inkscape:label, 'HMI:')]"/> |
4 <xsl:variable name="hmi_elements" select="//svg:*[starts-with(@inkscape:label, 'HMI:')]"/> |
5 <xsl:variable name="hmitree" select="ns:GetHMITree()"/> |
5 <xsl:variable name="hmitree" select="ns:GetHMITree()"/> |
6 <xsl:variable name="_categories"> |
6 <xsl:variable name="_categories"> |
7 <noindex> |
|
8 <xsl:text>HMI_ROOT</xsl:text> |
|
9 </noindex> |
|
10 <noindex> |
7 <noindex> |
11 <xsl:text>HMI_PLC_STATUS</xsl:text> |
8 <xsl:text>HMI_PLC_STATUS</xsl:text> |
12 </noindex> |
9 </noindex> |
13 <noindex> |
10 <noindex> |
14 <xsl:text>HMI_CURRENT_PAGE</xsl:text> |
11 <xsl:text>HMI_CURRENT_PAGE</xsl:text> |
23 <xsl:param name="index" select="0"/> |
20 <xsl:param name="index" select="0"/> |
24 <xsl:param name="parentpath" select="''"/> |
21 <xsl:param name="parentpath" select="''"/> |
25 <xsl:variable name="content"> |
22 <xsl:variable name="content"> |
26 <xsl:variable name="path"> |
23 <xsl:variable name="path"> |
27 <xsl:choose> |
24 <xsl:choose> |
28 <xsl:when test="local-name() = 'HMI_ROOT'"> |
25 <xsl:when test="count(ancestor::*)=0"> |
29 <xsl:value-of select="$parentpath"/> |
26 <xsl:text>/</xsl:text> |
|
27 </xsl:when> |
|
28 <xsl:when test="count(ancestor::*)=1"> |
|
29 <xsl:text>/</xsl:text> |
|
30 <xsl:value-of select="@name"/> |
30 </xsl:when> |
31 </xsl:when> |
31 <xsl:otherwise> |
32 <xsl:otherwise> |
32 <xsl:value-of select="$parentpath"/> |
33 <xsl:value-of select="$parentpath"/> |
33 <xsl:text>/</xsl:text> |
34 <xsl:text>/</xsl:text> |
34 <xsl:value-of select="@name"/> |
35 <xsl:value-of select="@name"/> |
595 <xsl:value-of select="@value"/> |
596 <xsl:value-of select="@value"/> |
596 <xsl:text>" in HMI tree</xsl:text> |
597 <xsl:text>" in HMI tree</xsl:text> |
597 </xsl:message> |
598 </xsl:message> |
598 </xsl:when> |
599 </xsl:when> |
599 <xsl:otherwise> |
600 <xsl:otherwise> |
600 <xsl:text> </xsl:text> |
601 <xsl:text> </xsl:text> |
601 <xsl:value-of select="@index"/> |
602 <xsl:value-of select="@index"/> |
|
603 <xsl:text> /*</xsl:text> |
|
604 <xsl:value-of select="$widget/path"/> |
|
605 <xsl:text>*/ </xsl:text> |
602 <xsl:if test="position()!=last()"> |
606 <xsl:if test="position()!=last()"> |
603 <xsl:text>,</xsl:text> |
607 <xsl:text>,</xsl:text> |
604 </xsl:if> |
608 </xsl:if> |
605 <xsl:text> |
609 <xsl:text> |
606 </xsl:text> |
610 </xsl:text> |
674 <xsl:otherwise> |
678 <xsl:otherwise> |
675 <func:result select="$txt"/> |
679 <func:result select="$txt"/> |
676 </xsl:otherwise> |
680 </xsl:otherwise> |
677 </xsl:choose> |
681 </xsl:choose> |
678 </func:function> |
682 </func:function> |
|
683 <xsl:template mode="widget_defs" match="widget[@type='ForEach']"> |
|
684 <xsl:param name="hmi_element"/> |
|
685 <xsl:text> frequency: 2, |
|
686 </xsl:text> |
|
687 <xsl:text> dispatch: function(value) { |
|
688 </xsl:text> |
|
689 <xsl:text> // do something |
|
690 </xsl:text> |
|
691 <xsl:text> }, |
|
692 </xsl:text> |
|
693 <xsl:text> init: function() { |
|
694 </xsl:text> |
|
695 <xsl:for-each select="$hmi_element/*[regexp:test(@inkscape:label,'^[=+\-].+')]"> |
|
696 <xsl:text> id("</xsl:text> |
|
697 <xsl:value-of select="@id"/> |
|
698 <xsl:text>").addEventListener( |
|
699 </xsl:text> |
|
700 <xsl:text> "click", |
|
701 </xsl:text> |
|
702 <xsl:text> evt => {let new_val = "</xsl:text> |
|
703 <xsl:value-of select="func:escape_quotes(@inkscape:label)"/> |
|
704 <xsl:text>"); |
|
705 </xsl:text> |
|
706 <xsl:text> // do something with new_val |
|
707 </xsl:text> |
|
708 <xsl:text> }); |
|
709 </xsl:text> |
|
710 </xsl:for-each> |
|
711 <xsl:text> }, |
|
712 </xsl:text> |
|
713 </xsl:template> |
|
714 <xsl:template mode="widget_subscribe" match="widget[@type='ForEach']"> |
|
715 <xsl:text> sub: function(off){ |
|
716 </xsl:text> |
|
717 <xsl:text> subscribe.call(this,off) |
|
718 </xsl:text> |
|
719 <xsl:text> }, |
|
720 </xsl:text> |
|
721 <xsl:text> unsub: function(){ |
|
722 </xsl:text> |
|
723 <xsl:text> unsubscribe.call(this) |
|
724 </xsl:text> |
|
725 <xsl:text> }, |
|
726 </xsl:text> |
|
727 </xsl:template> |
679 <xsl:template mode="widget_defs" match="widget[@type='Display']"> |
728 <xsl:template mode="widget_defs" match="widget[@type='Display']"> |
680 <xsl:param name="hmi_element"/> |
729 <xsl:param name="hmi_element"/> |
681 <xsl:text> frequency: 5, |
730 <xsl:text> frequency: 5, |
682 </xsl:text> |
731 </xsl:text> |
683 <xsl:text> dispatch: function(value) { |
732 <xsl:text> dispatch: function(value) { |
1132 </xsl:text> |
1181 </xsl:text> |
1133 <xsl:text> INT: (dv,offset) => [dv.getInt16(offset, true), 2], |
1182 <xsl:text> INT: (dv,offset) => [dv.getInt16(offset, true), 2], |
1134 </xsl:text> |
1183 </xsl:text> |
1135 <xsl:text> BOOL: (dv,offset) => [dv.getInt8(offset, true), 1], |
1184 <xsl:text> BOOL: (dv,offset) => [dv.getInt8(offset, true), 1], |
1136 </xsl:text> |
1185 </xsl:text> |
|
1186 <xsl:text> NODE: (dv,offset) => [dv.getInt8(offset, true), 1], |
|
1187 </xsl:text> |
1137 <xsl:text> STRING: (dv, offset) => { |
1188 <xsl:text> STRING: (dv, offset) => { |
1138 </xsl:text> |
1189 </xsl:text> |
1139 <xsl:text> size = dv.getInt8(offset); |
1190 <xsl:text> size = dv.getInt8(offset); |
1140 </xsl:text> |
1191 </xsl:text> |
1141 <xsl:text> return [ |
1192 <xsl:text> return [ |
1314 </xsl:text> |
1365 </xsl:text> |
1315 <xsl:text> INT: (number) => new Int16Array([number]), |
1366 <xsl:text> INT: (number) => new Int16Array([number]), |
1316 </xsl:text> |
1367 </xsl:text> |
1317 <xsl:text> BOOL: (truth) => new Int16Array([truth]), |
1368 <xsl:text> BOOL: (truth) => new Int16Array([truth]), |
1318 </xsl:text> |
1369 </xsl:text> |
|
1370 <xsl:text> NODE: (truth) => new Int16Array([truth]), |
|
1371 </xsl:text> |
1319 <xsl:text> STRING: (str) => { |
1372 <xsl:text> STRING: (str) => { |
1320 </xsl:text> |
1373 </xsl:text> |
1321 <xsl:text> // beremiz default string max size is 128 |
1374 <xsl:text> // beremiz default string max size is 128 |
1322 </xsl:text> |
1375 </xsl:text> |
1323 <xsl:text> str = str.slice(0,128); |
1376 <xsl:text> str = str.slice(0,128); |