How to implement a debouncing function in vbscript -



How to implement a debouncing function in vbscript -

i trying effort create sms script water municipality. want informed when water reservoir hints below 20%, must send sms , when it's above 20% sends sms confirm low alarm cleared.

doing easy task, there needs debouncing period, illustration if value changes must wait 10 seconds, after 10 seconds sends sms. same goes when value changes , during 10 sec waiting period changes 1 time again needs reset timer , start counting 10 again.

the next code shows continuous "do loop", since want code run forever.

the problem is, when value changes not wait 10 seconds , sends sms.

if has knowledge create debouncing function, please help appreciated.

please note: 3rd party application called adroid (not confused android ;) ). scada software monitor , command water schemes. happens has vbscript text editor in it.

sub main() dim output_1 dim output_2 dim commsstatus dim var_1 dim var_2 dim x dim status dim belowtimer dim abovetimer dim maintimer x = 1 status = 0 maintimer = 0 belowtimer = 0 abovetimer = 0 'all adroit functions build in adroit program. 'example: adroit.gettag built in function. 'zdm_man_fin_rs_rl1.value reservoir analog value var_1 = adroit.gettag("zdm_man_fin_rs_rl1.value") 'this message needs displayed on sms output_1 = "mandlakazi final reservoir level - " + cstr(round(var_1)) + "%" output_2 = "mandlakazi final reservoir level - " + cstr(round(var_1)) + "% clear" if (var_1 <= 19 , status = 1) if (maintimer - belowtimer) >= 10 status = 0 adroit.settag("quentin.rawvalue"), output_1 end if else belowtimer = maintimer end if if (var_1 > 20 , status = 0) if (maintimer - abovetimer) >= 10 status = 1 adroit.settag("quentin.rawvalue"), output_2 end if else abovetimer = maintimer end if maintimer = maintimer + timer loop until x = 0 end sub

vbscript debouncing

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -