# HG changeset patch # User Edouard Tisserant # Date 1636023823 -3600 # Node ID a3b8cfd896480c3c695d43a57cae2f1b903d1da2 # Parent 589abe084e57cffc945f70c63cbd6f77d1fa69e7 SVGHMI: update generated XSLT diff -r 589abe084e57 -r a3b8cfd89648 svghmi/gen_index_xhtml.xslt --- a/svghmi/gen_index_xhtml.xslt Thu Nov 04 12:02:08 2021 +0100 +++ b/svghmi/gen_index_xhtml.xslt Thu Nov 04 12:03:43 2021 +0100 @@ -3,6 +3,7 @@ + @@ -39,12 +40,16 @@ + var current_page_var_index = + + ; + + + var hmitree_types = [ - /* - - */ " + " " @@ -60,9 +65,7 @@ var hmitree_paths = [ - /* - - */ " + " " @@ -75,6 +78,26 @@ + var hmitree_nodes = { + + + " + + " : [ + + , " + + "] + + , + + + + + }; + + + @@ -656,6 +679,10 @@ , + page_class: " + + ", + widgets: [ @@ -8045,17 +8072,17 @@ // Open WebSocket to relative "/ws" address + var has_watchdog = window.location.hash == "#watchdog"; + var ws_url = window.location.href.replace(/^http(s?:\/\/[^\/]*)\/.*$/, 'ws$1/ws') - + '?mode=' + (window.location.hash == "#watchdog" - - ? "watchdog" - - : "multiclient"); + + '?mode=' + (has_watchdog ? "watchdog" : "multiclient"); + + var ws = new WebSocket(ws_url); @@ -8375,23 +8402,45 @@ - // artificially subscribe the watchdog widget to "/heartbeat" hmi variable - - // Since dispatch directly calls change_hmi_value, - - // PLC will periodically send variable at given frequency - - subscribers(heartbeat_index).add({ - - /* type: "Watchdog", */ + if(has_watchdog){ + + // artificially subscribe the watchdog widget to "/heartbeat" hmi variable + + // Since dispatch directly calls change_hmi_value, + + // PLC will periodically send variable at given frequency + + subscribers(heartbeat_index).add({ + + /* type: "Watchdog", */ + + frequency: 1, + + indexes: [heartbeat_index], + + new_hmi_value: function(index, value, oldval) { + + apply_hmi_value(heartbeat_index, value+1); + + } + + }); + + } + + + + // subscribe to per instance current page hmi variable + + subscribers(current_page_var_index).add({ frequency: 1, - indexes: [heartbeat_index], + indexes: [current_page_var_index], new_hmi_value: function(index, value, oldval) { - apply_hmi_value(heartbeat_index, value+1); + switch_page(value); } @@ -8787,7 +8836,11 @@ page_name = current_subscribed_page; - + else if(page_index == undefined){ + + [page_name, page_index] = page_name.split('@') + + } @@ -8807,10 +8860,32 @@ - if(page_index == undefined){ + if(page_index == undefined) page_index = new_desc.page_index; + else if(typeof(page_index) == "string") { + + let hmitree_node = hmitree_nodes[page_index]; + + if(hmitree_node !== undefined){ + + let [int_index, hmiclass] = hmitree_node; + + if(hmiclass == new_desc.page_class) + + page_index = int_index; + + else + + page_index = new_desc.page_index; + + } else { + + page_index = new_desc.page_index; + + } + } @@ -8871,6 +8946,16 @@ + apply_hmi_value(current_page_var_index, + + page_index == undefined + + ? page_name + + : page_name + "@" + hmitree_paths[page_index]); + + + return true; };