# HG changeset patch # User Edouard Tisserant # Date 1572211731 -3600 # Node ID 7d0e81cdedb0d2352a8c38528bf4daa5f13208fb # Parent e521e0d133d5032d8e1d998245434abfcc49f4aa SVGHMI: Quicker update path for input widget when pressing on buttons, do not wait until data comes back, and simply update value text of the pressed widget. Updated PLC prog for more amimated value to display diff -r e521e0d133d5 -r 7d0e81cdedb0 svghmi/gen_index_xhtml.xslt --- a/svghmi/gen_index_xhtml.xslt Sun Oct 27 21:38:10 2019 +0100 +++ b/svghmi/gen_index_xhtml.xslt Sun Oct 27 22:28:51 2019 +0100 @@ -426,8 +426,6 @@ let i = 0; - //console.log("Recv something."); - try { for(let hash_int of hmi_hash) { @@ -444,16 +442,10 @@ - //console.log("Recv something GOOD."); - - - while(i < data.byteLength){ let index = dv.getUint32(i, true); - //console.log("Recv something index is "+index); - i += 4; let iectype = hmitree_types[index]; @@ -586,7 +578,7 @@ } - + if(previous_period != new_period) { @@ -596,14 +588,12 @@ new Uint8Array([2]), /* subscribe = 2 */ - new Uint32Array([index]), + new Uint32Array([index]), new Uint16Array([new_period])); } - - } send_blob(delta); @@ -670,7 +660,9 @@ if(new_val != undefined && old_val != new_val) - return send_hmi_value(index, new_val); + send_hmi_value(index, new_val); + + return new_val; } @@ -901,9 +893,11 @@ "click", - evt => change_hmi_value(this.indexes[0], " + evt => {let new_val = change_hmi_value(this.indexes[0], " - ")); + "); + + this.value_elt.textContent = String(new_val);}); }, diff -r e521e0d133d5 -r 7d0e81cdedb0 svghmi/gen_index_xhtml.ysl2 --- a/svghmi/gen_index_xhtml.ysl2 Sun Oct 27 21:38:10 2019 +0100 +++ b/svghmi/gen_index_xhtml.ysl2 Sun Oct 27 22:28:51 2019 +0100 @@ -345,7 +345,9 @@ foreach "$hmi_element/*[regexp:test(@inkscape:label,'^[=+\-][0-9]+')]" { | document.getElementById("«@id»").addEventListener( | "click", - | evt => change_hmi_value(this.indexes[0], "«@inkscape:label»")); + | evt => {let new_val = change_hmi_value(this.indexes[0], "«@inkscape:label»"); + | this.value_elt.textContent = String(new_val);}); + /* could gray out value until refreshed */ } | }, } diff -r e521e0d133d5 -r 7d0e81cdedb0 svghmi/svghmi.js --- a/svghmi/svghmi.js Sun Oct 27 21:38:10 2019 +0100 +++ b/svghmi/svghmi.js Sun Oct 27 22:28:51 2019 +0100 @@ -134,10 +134,9 @@ subscriptions[index] = new_period; delta.push( new Uint8Array([2]), /* subscribe = 2 */ - new Uint32Array([index]), + new Uint32Array([index]), new Uint16Array([new_period])); } - } send_blob(delta); }; @@ -171,7 +170,8 @@ break; } if(new_val != undefined && old_val != new_val) - return send_hmi_value(index, new_val); + send_hmi_value(index, new_val); + return new_val; } var current_page; diff -r e521e0d133d5 -r 7d0e81cdedb0 tests/svghmi/plc.xml --- a/tests/svghmi/plc.xml Sun Oct 27 21:38:10 2019 +0100 +++ b/tests/svghmi/plc.xml Sun Oct 27 22:28:51 2019 +0100 @@ -1,7 +1,7 @@ - + @@ -91,43 +91,159 @@ - - - - - - 23 - - - + + + + + + TargetPressure + + + - - - + + + + + + Sloth - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Pressure + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Sloth + + + - - - - - + + + Pressure - - - - - - TargetPressure + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 100