beremiz

Parents 3ee337c8c769
Children ddce4ebdf010
SVGHMI: HMI is not speculating on PLC variable update anymore when sending new variable value.

HMI variable cache in JS was changed in advance for more responsive behaviour when updating a HMI tree variable. This was leading to display value different from hmi tree variable in case the expected update did not happen because PLC program did revert it.
--- a/svghmi/gen_index_xhtml.xslt Sat Apr 04 22:32:54 2020 +0200
+++ b/svghmi/gen_index_xhtml.xslt Tue Apr 07 10:01:23 2020 +0200
@@ -984,10 +984,6 @@
</xsl:text>
<xsl:text> let new_val = change_hmi_value(this.indexes[0], opstr);
</xsl:text>
- <xsl:if test="$have_value">
- <xsl:text> this.value_elt.textContent = String(new_val);
-</xsl:text>
- </xsl:if>
<xsl:text> },
</xsl:text>
<xsl:text> on_edit_click: function(opstr) {
@@ -1004,10 +1000,6 @@
</xsl:text>
<xsl:text> apply_hmi_value(this.indexes[0], new_val);
</xsl:text>
- <xsl:if test="$have_value">
- <xsl:text> this.value_elt.textContent = String(new_val);
-</xsl:text>
- </xsl:if>
<xsl:text> },
</xsl:text>
</xsl:template>
@@ -1567,6 +1559,7 @@
<xsl:comment>
<xsl:text>Made with SVGHMI. https://beremiz.org</xsl:text>
</xsl:comment>
+ <xsl:apply-templates mode="debug_as_comment" select="document('')/*/reflect:*"/>
<html xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/1999/xhtml">
<head/>
<body style="margin:0;overflow:hidden;">
@@ -2152,7 +2145,9 @@
</xsl:text>
<xsl:text>
</xsl:text>
- <xsl:text> cache[index] = value;
+ <xsl:text> // DON'T DO THAT unless read_iterator in svghmi.c modifies wbuf as well, not only rbuf
+</xsl:text>
+ <xsl:text> // cache[index] = value;
</xsl:text>
<xsl:text>};
</xsl:text>
@@ -2162,10 +2157,16 @@
</xsl:text>
<xsl:text> let old_val = cache[index]
</xsl:text>
- <xsl:text> if(new_val != undefined &amp;&amp; old_val != new_val)
+ <xsl:text> console.log("apply", index, new_val);
+</xsl:text>
+ <xsl:text> if(new_val != undefined &amp;&amp; old_val != new_val){
+</xsl:text>
+ <xsl:text> console.log("sending", new_val);
</xsl:text>
<xsl:text> send_hmi_value(index, new_val);
</xsl:text>
+ <xsl:text> }
+</xsl:text>
<xsl:text> return new_val;
</xsl:text>
<xsl:text>}
--- a/svghmi/svghmi.js Sat Apr 04 22:32:54 2020 +0200
+++ b/svghmi/svghmi.js Tue Apr 07 10:01:23 2020 +0200
@@ -236,7 +236,8 @@
new Uint32Array([index]),
tobinary(value)]);
- cache[index] = value;
+ // DON'T DO THAT unless read_iterator in svghmi.c modifies wbuf as well, not only rbuf
+ // cache[index] = value;
};
function apply_hmi_value(index, new_val) {
--- a/svghmi/widget_input.ysl2 Sat Apr 04 22:32:54 2020 +0200
+++ b/svghmi/widget_input.ysl2 Tue Apr 07 10:01:23 2020 +0200
@@ -27,10 +27,10 @@
| },
| on_op_click: function(opstr) {
| let new_val = change_hmi_value(this.indexes[0], opstr);
- if "$have_value"{
- | this.value_elt.textContent = String(new_val);
- /* TODO gray out value until refreshed */
- }
+ // if "$have_value"{
+ // | this.value_elt.textContent = String(new_val);
+ // /* TODO gray out value until refreshed */
+ // }
| },
| on_edit_click: function(opstr) {
| edit_value("«path/@value»", "«path/@type»", this, this.last_val);
@@ -38,9 +38,9 @@
| edit_callback: function(new_val) {
| apply_hmi_value(this.indexes[0], new_val);
- if "$have_value"{
- | this.value_elt.textContent = String(new_val);
- /* TODO gray out value until refreshed */
- }
+ // if "$have_value"{
+ // | this.value_elt.textContent = String(new_val);
+ // /* TODO gray out value until refreshed */
+ // }
| },
}