--- a/svghmi/gen_index_xhtml.xslt Tue Oct 22 22:58:55 2019 +0200
+++ b/svghmi/gen_index_xhtml.xslt Thu Oct 24 10:02:07 2019 +0200
@@ -320,16 +320,16 @@
+ <xsl:text>var cache = hmitree_types.map(_ignored => undefined); <xsl:text>function dispatch_value(index, value) {
<xsl:text> let widgets = subscribers[index];
- <xsl:text> // TODO : value cache
<xsl:text> if(widgets.size > 0) {
<xsl:text> for(let widget of widgets){
@@ -364,6 +364,12 @@
+ <xsl:text> cache[index] = value; @@ -622,6 +628,8 @@
+ <xsl:text> cache[index] = value; @@ -630,13 +638,39 @@
<xsl:text> let op = opstr[0];
- <xsl:text> if(op == "=")
+ <xsl:text> let given_val = opstr.slice(1); + <xsl:text> let old_val = cache[index] + <xsl:text> let new_val; - <xsl:text> return send_hmi_value(index, Number(opstr.slice(1)));
+ <xsl:text> eval("new_val"+opstr);
+ <xsl:text> if(old_val != undefined) - <xsl:text> alert('Change '+opstr+" TODO !!! (index :"+index+")");
+ <xsl:text> new_val = eval("old_val"+opstr); + <xsl:text> if(new_val != undefined && old_val != new_val) + <xsl:text> return send_hmi_value(index, new_val); --- a/svghmi/svghmi.js Tue Oct 22 22:58:55 2019 +0200
+++ b/svghmi/svghmi.js Thu Oct 24 10:02:07 2019 +0200
@@ -1,10 +1,10 @@
+var cache = hmitree_types.map(_ignored => undefined); function dispatch_value(index, value) {
let widgets = subscribers[index];
for(let widget of widgets){
let idxidx = widget.indexes.indexOf(index);
@@ -22,6 +22,9 @@
function init_widgets() {
@@ -147,14 +150,28 @@
new Uint32Array([index]),
function change_hmi_value(index, opstr) {
- return send_hmi_value(index, Number(opstr.slice(1)));
- alert('Change '+opstr+" TODO !!! (index :"+index+")");
+ let given_val = opstr.slice(1); + let old_val = cache[index] + if(old_val != undefined) + new_val = eval("old_val"+opstr); + if(new_val != undefined && old_val != new_val) + return send_hmi_value(index, new_val);