SVGHMI: rework the way cached values are applied to widgets when fresh data is missing.
authorEdouard Tisserant
Tue, 13 Sep 2022 16:29:21 +0200
changeset 3603 f1a00aa8cb3b
parent 3602 1bd8e077894e
child 3604 be87303d5b2d
SVGHMI: rework the way cached values are applied to widgets when fresh data is missing.
svghmi/svghmi.js
svghmi/widget_foreach.ysl2
svghmi/widgets_common.ysl2
--- a/svghmi/svghmi.js	Mon Sep 12 11:56:52 2022 +0200
+++ b/svghmi/svghmi.js	Tue Sep 13 16:29:21 2022 +0200
@@ -1,7 +1,5 @@
 // svghmi.js
 
-var need_cache_apply = [];
-
 function dispatch_value(index, value) {
     let widgets = subscribers(index);
 
@@ -86,10 +84,6 @@
             }
         }
 
-        while(widget = need_cache_apply.pop()){
-            widget.apply_cache();
-        }
-
         if(jumps_need_update) update_jumps();
 
 
--- a/svghmi/widget_foreach.ysl2	Mon Sep 12 11:56:52 2022 +0200
+++ b/svghmi/widget_foreach.ysl2	Tue Sep 13 16:29:21 2022 +0200
@@ -140,7 +140,7 @@
         this.unsub_items();
         this.sub_items();
         update_subscriptions();
-        need_cache_apply.push(this);
+        this.apply_cache(); 
         jumps_need_update = true;
         requestHMIAnimation();
     }
--- a/svghmi/widgets_common.ysl2	Mon Sep 12 11:56:52 2022 +0200
+++ b/svghmi/widgets_common.ysl2	Tue Sep 13 16:29:21 2022 +0200
@@ -343,9 +343,7 @@
                     this.lastdispatch[i] = undefined;
                     this.undeafen(i);
                 }
-                let index = this.indexes[i];
-                if(this.relativeness[i])
-                    index += this.offset;
+                let index = this.get_variable_index(i);
                 subscribers(index).delete(this);
             }
             this.offset = 0;
@@ -362,17 +360,17 @@
                 if(index == undefined) continue;
                 subscribers(index).add(this);
             }
-            need_cache_apply.push(this); 
+            this.apply_cache(); 
         }
 
         apply_cache() {
-            for(let index in this.indexes){
+            for(let i = 0; i < this.indexes_length; i++) {
                 /* dispatch current cache in newly opened page widgets */
-                let realindex = this.get_variable_index(index);
+                let realindex = this.get_variable_index(i);
                 if(realindex == undefined) continue;
                 let cached_val = cache[realindex];
                 if(cached_val != undefined)
-                    this.feed_data_for_dispatch(cached_val, cached_val, index);
+                    this.feed_data_for_dispatch(cached_val, cached_val, i);
             }
         }