svghmi/widgets_common.ysl2
changeset 3455 2716cd8e498d
parent 3453 e5967a2ae2bb
child 3469 97622e9560b5
--- a/svghmi/widgets_common.ysl2	Thu May 05 10:37:36 2022 +0200
+++ b/svghmi/widgets_common.ysl2	Thu May 05 11:48:43 2022 +0200
@@ -85,7 +85,7 @@
 
     const "freq" choose {
         when "$widget/@freq"
-            > «$widget/@freq»
+            > "«$widget/@freq»"
         otherwise
             > undefined
     }
@@ -186,6 +186,36 @@
             this.clip = true;
         }
 
+        do_init(){
+            if(widget.forced_frequency !== undefined){
+                let s = widget.forced_frequency;
+                /*
+                once every 10 seconds : 10s
+                once per minute : 1m
+                once per hour : 1h
+                once per day : 1d
+                */
+                let unit = s.slice(-1);
+                let factor = {
+                    "s":1,
+                    "m":60,
+                    "h":3600,
+                    "d":86400}[unit];
+
+                widget.frequency = factor ? 1/(factor * Number(s.slice(0,-1)))
+                                          : Number(s);
+            }
+
+            let init = this.init;
+            if(typeof(init) == "function"){
+                try {
+                    init.call(this);
+                } catch(err) {
+                    console.log(err);
+                }
+            }
+        }
+
         unsub(){
             /* remove subsribers */
             if(!this.unsubscribable)