--- a/svghmi/svghmi.js Wed Jan 19 08:51:45 2022 +0100
+++ b/svghmi/svghmi.js Wed Jan 19 08:53:49 2022 +0100
@@ -332,8 +332,10 @@
function apply_hmi_value(index, new_val) {
- let old_val = cache[index];
- if(new_val != undefined && old_val != new_val)
+ // Similarly to previous comment, taking decision to update based + // on cache content is bad and can lead to inconsistency + /*let old_val = cache[index];*/ + if(new_val != undefined /*&& old_val != new_val*/) send_hmi_value(index, new_val);
--- a/svghmi/widget_button.ysl2 Wed Jan 19 08:51:45 2022 +0100
+++ b/svghmi/widget_button.ysl2 Wed Jan 19 08:53:49 2022 +0100
@@ -28,6 +28,41 @@
+const "_push_button_fsm" fsm { + on_dispatch "false" jump "reflect_off"; + on_dispatch "true" jump "reflect_on"; + on_mouse "down" jump "on"; + on_mouse "up" jump "off"; + on_dispatch "false" jump "reflect_off"; + on_mouse "up" jump "off"; + on_dispatch "false" jump "reflect_off"; + on_mouse "down" jump "on"; + on_mouse "up" jump "off"; + on_dispatch "true" jump "reflect_on"; + on_mouse "down" jump "on"; + on_dispatch "true" jump "reflect_on"; // State machine to drive HMI_BOOL on a potentially laggy connection
const "_button_fsm" fsm {
@@ -111,7 +146,7 @@
template "state", mode="actions" {
- //| console.log("Entering state «@name»");
+ | console.log("Entering state «@name»"); apply "*", mode="actions";
@@ -125,26 +160,24 @@
- const "fsm","exsl:node-set($_button_fsm)";
+function "generated_button_class" { - // | console.log("dispatch"+value);
apply "$fsm", mode="dispatch_transition";
| svg_root.removeEventListener("pointerup", this.bound_onmouseup, true);
- // | console.log("onmouseup");
apply "$fsm", mode="mouse_transition" with "position", "'up'";
| svg_root.addEventListener("pointerup", this.bound_onmouseup, true);
- // | console.log("onmousedown");
apply "$fsm", mode="mouse_transition" with "position", "'down'";
@@ -167,6 +200,22 @@
+ const "fsm","exsl:node-set($_button_fsm)"; + call "generated_button_class" with "fsm", "$fsm"; optional_labels("active inactive");
+widget_class("PushButton"){ + const "fsm","exsl:node-set($_push_button_fsm)"; + call "generated_button_class" with "fsm", "$fsm"; +widget_defs("PushButton") { + optional_labels("active inactive");