1 <?xml version="1.0"?> |
1 <?xml version="1.0"?> |
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common" xmlns:regexp="http://exslt.org/regular-expressions" xmlns:str="http://exslt.org/strings" xmlns:func="http://exslt.org/functions" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:debug="debug" xmlns:preamble="preamble" xmlns:declarations="declarations" xmlns:definitions="definitions" xmlns:epilogue="epilogue" xmlns:ns="beremiz" version="1.0" extension-element-prefixes="ns func exsl regexp str dyn" exclude-result-prefixes="ns func exsl regexp str dyn debug preamble epilogue declarations definitions"> |
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common" xmlns:regexp="http://exslt.org/regular-expressions" xmlns:str="http://exslt.org/strings" xmlns:func="http://exslt.org/functions" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:debug="debug" xmlns:preamble="preamble" xmlns:declarations="declarations" xmlns:definitions="definitions" xmlns:epilogue="epilogue" xmlns:ns="beremiz" version="1.0" extension-element-prefixes="ns func exsl regexp str dyn" exclude-result-prefixes="ns func exsl regexp str dyn debug preamble epilogue declarations definitions"> |
3 <xsl:output cdata-section-elements="xhtml:script" method="xml"/> |
3 <xsl:output cdata-section-elements="xhtml:script" method="xml"/> |
4 <xsl:variable name="svg" select="/svg:svg"/> |
4 <xsl:variable name="svg" select="/svg:svg"/> |
5 <xsl:variable name="hmi_elements" select="//svg:*[starts-with(@inkscape:label, 'HMI:')]"/> |
5 <xsl:variable name="hmi_elements" select="//svg:*[starts-with(@inkscape:label, 'HMI:')]"/> |
|
6 <xsl:param name="instance_name"/> |
6 <xsl:variable name="hmitree" select="ns:GetHMITree()"/> |
7 <xsl:variable name="hmitree" select="ns:GetHMITree()"/> |
7 <xsl:variable name="_categories"> |
8 <xsl:variable name="_categories"> |
8 <noindex> |
9 <noindex> |
9 <xsl:text>HMI_PLC_STATUS</xsl:text> |
10 <xsl:text>HMI_PLC_STATUS</xsl:text> |
10 </noindex> |
11 </noindex> |
37 <xsl:value-of select="$indexed_hmitree/*[@hmipath = '/HEARTBEAT']/@index"/> |
38 <xsl:value-of select="$indexed_hmitree/*[@hmipath = '/HEARTBEAT']/@index"/> |
38 <xsl:text>; |
39 <xsl:text>; |
39 </xsl:text> |
40 </xsl:text> |
40 <xsl:text> |
41 <xsl:text> |
41 </xsl:text> |
42 </xsl:text> |
|
43 <xsl:text>var current_page_var_index = </xsl:text> |
|
44 <xsl:value-of select="$indexed_hmitree/*[@hmipath = concat('/CURRENT_PAGE_', $instance_name)]/@index"/> |
|
45 <xsl:text>; |
|
46 </xsl:text> |
|
47 <xsl:text> |
|
48 </xsl:text> |
42 <xsl:text>var hmitree_types = [ |
49 <xsl:text>var hmitree_types = [ |
43 </xsl:text> |
50 </xsl:text> |
44 <xsl:for-each select="$indexed_hmitree/*"> |
51 <xsl:for-each select="$indexed_hmitree/*"> |
45 <xsl:text> /* </xsl:text> |
52 <xsl:text> "</xsl:text> |
46 <xsl:value-of select="@index"/> |
|
47 <xsl:text> */ "</xsl:text> |
|
48 <xsl:value-of select="substring(local-name(), 5)"/> |
53 <xsl:value-of select="substring(local-name(), 5)"/> |
49 <xsl:text>"</xsl:text> |
54 <xsl:text>"</xsl:text> |
50 <xsl:if test="position()!=last()"> |
55 <xsl:if test="position()!=last()"> |
51 <xsl:text>,</xsl:text> |
56 <xsl:text>,</xsl:text> |
52 </xsl:if> |
57 </xsl:if> |
58 <xsl:text> |
63 <xsl:text> |
59 </xsl:text> |
64 </xsl:text> |
60 <xsl:text>var hmitree_paths = [ |
65 <xsl:text>var hmitree_paths = [ |
61 </xsl:text> |
66 </xsl:text> |
62 <xsl:for-each select="$indexed_hmitree/*"> |
67 <xsl:for-each select="$indexed_hmitree/*"> |
63 <xsl:text> /* </xsl:text> |
68 <xsl:text> "</xsl:text> |
64 <xsl:value-of select="@index"/> |
|
65 <xsl:text> */ "</xsl:text> |
|
66 <xsl:value-of select="@hmipath"/> |
69 <xsl:value-of select="@hmipath"/> |
67 <xsl:text>"</xsl:text> |
70 <xsl:text>"</xsl:text> |
68 <xsl:if test="position()!=last()"> |
71 <xsl:if test="position()!=last()"> |
69 <xsl:text>,</xsl:text> |
72 <xsl:text>,</xsl:text> |
70 </xsl:if> |
73 </xsl:if> |
71 <xsl:text> |
74 <xsl:text> |
72 </xsl:text> |
75 </xsl:text> |
73 </xsl:for-each> |
76 </xsl:for-each> |
74 <xsl:text>]; |
77 <xsl:text>]; |
|
78 </xsl:text> |
|
79 <xsl:text> |
|
80 </xsl:text> |
|
81 <xsl:text>var hmitree_nodes = { |
|
82 </xsl:text> |
|
83 <xsl:for-each select="$indexed_hmitree/*[local-name() = 'HMI_NODE']"> |
|
84 <xsl:text> "</xsl:text> |
|
85 <xsl:value-of select="@hmipath"/> |
|
86 <xsl:text>" : [</xsl:text> |
|
87 <xsl:value-of select="@index"/> |
|
88 <xsl:text>, "</xsl:text> |
|
89 <xsl:value-of select="@class"/> |
|
90 <xsl:text>"]</xsl:text> |
|
91 <xsl:if test="position()!=last()"> |
|
92 <xsl:text>,</xsl:text> |
|
93 </xsl:if> |
|
94 <xsl:text> |
|
95 </xsl:text> |
|
96 </xsl:for-each> |
|
97 <xsl:text>}; |
75 </xsl:text> |
98 </xsl:text> |
76 <xsl:text> |
99 <xsl:text> |
77 </xsl:text> |
100 </xsl:text> |
78 <xsl:text> |
101 <xsl:text> |
79 </xsl:text> |
102 </xsl:text> |
654 </xsl:if> |
677 </xsl:if> |
655 <xsl:text> page_index: </xsl:text> |
678 <xsl:text> page_index: </xsl:text> |
656 <xsl:value-of select="$desc/path/@index"/> |
679 <xsl:value-of select="$desc/path/@index"/> |
657 <xsl:text>, |
680 <xsl:text>, |
658 </xsl:text> |
681 </xsl:text> |
|
682 <xsl:text> page_class: "</xsl:text> |
|
683 <xsl:value-of select="$indexed_hmitree/*[@hmipath = $desc/path/@value]/@class"/> |
|
684 <xsl:text>", |
|
685 </xsl:text> |
659 </xsl:if> |
686 </xsl:if> |
660 <xsl:text> widgets: [ |
687 <xsl:text> widgets: [ |
661 </xsl:text> |
688 </xsl:text> |
662 <xsl:for-each select="$page_managed_widgets"> |
689 <xsl:for-each select="$page_managed_widgets"> |
663 <xsl:variable name="widget_paths_relativeness"> |
690 <xsl:variable name="widget_paths_relativeness"> |
8043 </xsl:text> |
8070 </xsl:text> |
8044 <xsl:text> |
8071 <xsl:text> |
8045 </xsl:text> |
8072 </xsl:text> |
8046 <xsl:text>// Open WebSocket to relative "/ws" address |
8073 <xsl:text>// Open WebSocket to relative "/ws" address |
8047 </xsl:text> |
8074 </xsl:text> |
|
8075 <xsl:text>var has_watchdog = window.location.hash == "#watchdog"; |
|
8076 </xsl:text> |
8048 <xsl:text> |
8077 <xsl:text> |
8049 </xsl:text> |
8078 </xsl:text> |
8050 <xsl:text>var ws_url = |
8079 <xsl:text>var ws_url = |
8051 </xsl:text> |
8080 </xsl:text> |
8052 <xsl:text> window.location.href.replace(/^http(s?:\/\/[^\/]*)\/.*$/, 'ws$1/ws') |
8081 <xsl:text> window.location.href.replace(/^http(s?:\/\/[^\/]*)\/.*$/, 'ws$1/ws') |
8053 </xsl:text> |
8082 </xsl:text> |
8054 <xsl:text> + '?mode=' + (window.location.hash == "#watchdog" |
8083 <xsl:text> + '?mode=' + (has_watchdog ? "watchdog" : "multiclient"); |
8055 </xsl:text> |
8084 </xsl:text> |
8056 <xsl:text> ? "watchdog" |
8085 <xsl:text> |
8057 </xsl:text> |
|
8058 <xsl:text> : "multiclient"); |
|
8059 </xsl:text> |
8086 </xsl:text> |
8060 <xsl:text>var ws = new WebSocket(ws_url); |
8087 <xsl:text>var ws = new WebSocket(ws_url); |
8061 </xsl:text> |
8088 </xsl:text> |
8062 <xsl:text>ws.binaryType = 'arraybuffer'; |
8089 <xsl:text>ws.binaryType = 'arraybuffer'; |
8063 </xsl:text> |
8090 </xsl:text> |
8373 </xsl:text> |
8400 </xsl:text> |
8374 <xsl:text>} |
8401 <xsl:text>} |
8375 </xsl:text> |
8402 </xsl:text> |
8376 <xsl:text> |
8403 <xsl:text> |
8377 </xsl:text> |
8404 </xsl:text> |
8378 <xsl:text>// artificially subscribe the watchdog widget to "/heartbeat" hmi variable |
8405 <xsl:text>if(has_watchdog){ |
8379 </xsl:text> |
8406 </xsl:text> |
8380 <xsl:text>// Since dispatch directly calls change_hmi_value, |
8407 <xsl:text> // artificially subscribe the watchdog widget to "/heartbeat" hmi variable |
8381 </xsl:text> |
8408 </xsl:text> |
8382 <xsl:text>// PLC will periodically send variable at given frequency |
8409 <xsl:text> // Since dispatch directly calls change_hmi_value, |
8383 </xsl:text> |
8410 </xsl:text> |
8384 <xsl:text>subscribers(heartbeat_index).add({ |
8411 <xsl:text> // PLC will periodically send variable at given frequency |
8385 </xsl:text> |
8412 </xsl:text> |
8386 <xsl:text> /* type: "Watchdog", */ |
8413 <xsl:text> subscribers(heartbeat_index).add({ |
|
8414 </xsl:text> |
|
8415 <xsl:text> /* type: "Watchdog", */ |
|
8416 </xsl:text> |
|
8417 <xsl:text> frequency: 1, |
|
8418 </xsl:text> |
|
8419 <xsl:text> indexes: [heartbeat_index], |
|
8420 </xsl:text> |
|
8421 <xsl:text> new_hmi_value: function(index, value, oldval) { |
|
8422 </xsl:text> |
|
8423 <xsl:text> apply_hmi_value(heartbeat_index, value+1); |
|
8424 </xsl:text> |
|
8425 <xsl:text> } |
|
8426 </xsl:text> |
|
8427 <xsl:text> }); |
|
8428 </xsl:text> |
|
8429 <xsl:text>} |
|
8430 </xsl:text> |
|
8431 <xsl:text> |
|
8432 </xsl:text> |
|
8433 <xsl:text>// subscribe to per instance current page hmi variable |
|
8434 </xsl:text> |
|
8435 <xsl:text>subscribers(current_page_var_index).add({ |
8387 </xsl:text> |
8436 </xsl:text> |
8388 <xsl:text> frequency: 1, |
8437 <xsl:text> frequency: 1, |
8389 </xsl:text> |
8438 </xsl:text> |
8390 <xsl:text> indexes: [heartbeat_index], |
8439 <xsl:text> indexes: [current_page_var_index], |
8391 </xsl:text> |
8440 </xsl:text> |
8392 <xsl:text> new_hmi_value: function(index, value, oldval) { |
8441 <xsl:text> new_hmi_value: function(index, value, oldval) { |
8393 </xsl:text> |
8442 </xsl:text> |
8394 <xsl:text> apply_hmi_value(heartbeat_index, value+1); |
8443 <xsl:text> switch_page(value); |
8395 </xsl:text> |
8444 </xsl:text> |
8396 <xsl:text> } |
8445 <xsl:text> } |
8397 </xsl:text> |
8446 </xsl:text> |
8398 <xsl:text>}); |
8447 <xsl:text>}); |
8399 </xsl:text> |
8448 </xsl:text> |
8805 </xsl:text> |
8858 </xsl:text> |
8806 <xsl:text> } |
8859 <xsl:text> } |
8807 </xsl:text> |
8860 </xsl:text> |
8808 <xsl:text> |
8861 <xsl:text> |
8809 </xsl:text> |
8862 </xsl:text> |
8810 <xsl:text> if(page_index == undefined){ |
8863 <xsl:text> if(page_index == undefined) |
8811 </xsl:text> |
8864 </xsl:text> |
8812 <xsl:text> page_index = new_desc.page_index; |
8865 <xsl:text> page_index = new_desc.page_index; |
8813 </xsl:text> |
8866 </xsl:text> |
|
8867 <xsl:text> else if(typeof(page_index) == "string") { |
|
8868 </xsl:text> |
|
8869 <xsl:text> let hmitree_node = hmitree_nodes[page_index]; |
|
8870 </xsl:text> |
|
8871 <xsl:text> if(hmitree_node !== undefined){ |
|
8872 </xsl:text> |
|
8873 <xsl:text> let [int_index, hmiclass] = hmitree_node; |
|
8874 </xsl:text> |
|
8875 <xsl:text> if(hmiclass == new_desc.page_class) |
|
8876 </xsl:text> |
|
8877 <xsl:text> page_index = int_index; |
|
8878 </xsl:text> |
|
8879 <xsl:text> else |
|
8880 </xsl:text> |
|
8881 <xsl:text> page_index = new_desc.page_index; |
|
8882 </xsl:text> |
|
8883 <xsl:text> } else { |
|
8884 </xsl:text> |
|
8885 <xsl:text> page_index = new_desc.page_index; |
|
8886 </xsl:text> |
|
8887 <xsl:text> } |
|
8888 </xsl:text> |
8814 <xsl:text> } |
8889 <xsl:text> } |
8815 </xsl:text> |
8890 </xsl:text> |
8816 <xsl:text> |
8891 <xsl:text> |
8817 </xsl:text> |
8892 </xsl:text> |
8818 <xsl:text> if(old_desc){ |
8893 <xsl:text> if(old_desc){ |
8866 <xsl:text> jump_history.push([page_name, page_index]); |
8941 <xsl:text> jump_history.push([page_name, page_index]); |
8867 </xsl:text> |
8942 </xsl:text> |
8868 <xsl:text> if(jump_history.length > 42) |
8943 <xsl:text> if(jump_history.length > 42) |
8869 </xsl:text> |
8944 </xsl:text> |
8870 <xsl:text> jump_history.shift(); |
8945 <xsl:text> jump_history.shift(); |
|
8946 </xsl:text> |
|
8947 <xsl:text> |
|
8948 </xsl:text> |
|
8949 <xsl:text> apply_hmi_value(current_page_var_index, |
|
8950 </xsl:text> |
|
8951 <xsl:text> page_index == undefined |
|
8952 </xsl:text> |
|
8953 <xsl:text> ? page_name |
|
8954 </xsl:text> |
|
8955 <xsl:text> : page_name + "@" + hmitree_paths[page_index]); |
8871 </xsl:text> |
8956 </xsl:text> |
8872 <xsl:text> |
8957 <xsl:text> |
8873 </xsl:text> |
8958 </xsl:text> |
8874 <xsl:text> return true; |
8959 <xsl:text> return true; |
8875 </xsl:text> |
8960 </xsl:text> |