svghmi/widgets_common.ysl2
changeset 3455 2716cd8e498d
parent 3453 e5967a2ae2bb
child 3469 97622e9560b5
equal deleted inserted replaced
3454:0b5ab53007a9 3455:2716cd8e498d
    83         if "position()!=last()" > ,
    83         if "position()!=last()" > ,
    84     }
    84     }
    85 
    85 
    86     const "freq" choose {
    86     const "freq" choose {
    87         when "$widget/@freq"
    87         when "$widget/@freq"
    88             > «$widget/@freq»
    88             > "«$widget/@freq»"
    89         otherwise
    89         otherwise
    90             > undefined
    90             > undefined
    91     }
    91     }
    92 
    92 
    93     |   "«@id»": new «$widget/@type»Widget ("«@id»",«$freq»,[«$args»],[«$indexes»],[«$minmaxes»],{
    93     |   "«@id»": new «$widget/@type»Widget ("«@id»",«$freq»,[«$args»],[«$indexes»],[«$minmaxes»],{
   182             this.inhibit = indexes.map(() => undefined);
   182             this.inhibit = indexes.map(() => undefined);
   183             this.pending = indexes.map(() => undefined);
   183             this.pending = indexes.map(() => undefined);
   184             this.bound_unhinibit = this.unhinibit.bind(this);
   184             this.bound_unhinibit = this.unhinibit.bind(this);
   185             this.forced_frequency = freq;
   185             this.forced_frequency = freq;
   186             this.clip = true;
   186             this.clip = true;
       
   187         }
       
   188 
       
   189         do_init(){
       
   190             if(widget.forced_frequency !== undefined){
       
   191                 let s = widget.forced_frequency;
       
   192                 /*
       
   193                 once every 10 seconds : 10s
       
   194                 once per minute : 1m
       
   195                 once per hour : 1h
       
   196                 once per day : 1d
       
   197                 */
       
   198                 let unit = s.slice(-1);
       
   199                 let factor = {
       
   200                     "s":1,
       
   201                     "m":60,
       
   202                     "h":3600,
       
   203                     "d":86400}[unit];
       
   204 
       
   205                 widget.frequency = factor ? 1/(factor * Number(s.slice(0,-1)))
       
   206                                           : Number(s);
       
   207             }
       
   208 
       
   209             let init = this.init;
       
   210             if(typeof(init) == "function"){
       
   211                 try {
       
   212                     init.call(this);
       
   213                 } catch(err) {
       
   214                     console.log(err);
       
   215                 }
       
   216             }
   187         }
   217         }
   188 
   218 
   189         unsub(){
   219         unsub(){
   190             /* remove subsribers */
   220             /* remove subsribers */
   191             if(!this.unsubscribable)
   221             if(!this.unsubscribable)