SVGHMI: Changes /CURRENT_PAGE_* behaviour to prevent problem whith multiclient : all clients were switching page when one was jumping.
authorEdouard Tisserant
Mon, 08 Nov 2021 14:06:29 +0100
changeset 3385 18621ce81f5f
parent 3384 bd337d21f686
child 3386 608f48ad3dfc
SVGHMI: Changes /CURRENT_PAGE_* behaviour to prevent problem whith multiclient : all clients were switching page when one was jumping.
- now PLC have to prefix page name with "!" to order page switch.
- HMI do not prefix with "!" when jumping, this avoiding looping incidently
- In case of multiple client:
CURRENT_PAGE reflects current page of last client hwo did jump
Setting CURRENT_PAGE with "!" affects all clients simultaneously
svghmi/svghmi.js
--- a/svghmi/svghmi.js	Mon Nov 08 14:03:21 2021 +0100
+++ b/svghmi/svghmi.js	Mon Nov 08 14:06:29 2021 +0100
@@ -210,11 +210,13 @@
 }
 
 // subscribe to per instance current page hmi variable
+// PLC must prefix page name with "!" for page switch to happen
 subscribers(current_page_var_index).add({
     frequency: 1,
     indexes: [current_page_var_index],
     new_hmi_value: function(index, value, oldval) {
-        switch_page(value);
+        if(value.startsWith("!"))
+            switch_page(value.slice(1));
     }
 });
 
@@ -467,10 +469,9 @@
     if(jump_history.length > 42)
         jump_history.shift();
 
-    apply_hmi_value(current_page_var_index,
-                    page_index == undefined
-                        ? page_name
-                        : page_name + "@" + hmitree_paths[page_index]);
+    apply_hmi_value(current_page_var_index, page_index == undefined
+        ? page_name
+        : page_name + "@" + hmitree_paths[page_index]);
 
     return true;
 };