Facility Control

 View Only
  • 1.  Timer and trigger

    Posted 11-04-2020 21:17

    Hello,

             I got a timer that countdown. I'd like to create a button that I can toggle on or off and that if the button is toggle on, when the timer hit 0:30, it will trigger an action. 

    I managed to do so but it only work if I push my button exactly when the clock show 0:30. It doesn't work if I hit the button prior to 0:30 and then wait 'til the clock go down to 0:30....

    I'm sure it's quite simple but I can't figure it out so if I can get help, it would be much appreciated.

    Thanks



  • 2.  RE: Timer and trigger

    Posted 11-04-2020 21:32

    Hi Guillaume,

    Here is a panel with a toggle parameter, and a timer that counts down from 10s.   When it hits 5 seconds, it prints out something on the console, if the parameter is toggled on.

     

    <abs contexttype="opengear" gridsize="20" id="_top" keepalive="false" style="">
    <timer autostart="false" id="Countdown" pattern="HH:mm:ss" rate="1000" start="00:00:10" stop="00:00:00">
    <timertask tasktype="ogparamset">params.setValue('time', 0, event.getDisplay());</timertask>
    <timertask tasktype="timercontrol">timer = ogscript.getTimerManager().getTimer('Countdown');
    if (timer.getCurrent() == 5000 &amp;&amp; params.getValue("toggle",0) == 1) {
    ogscript.debug("SOMETHING HAPPENED AT 5 SECONDS");
    }

    </timertask>
    </timer>
    <meta>
    <params>
    <param access="1" constrainttype="INT_CHOICE" name="Toggle" oid="toggle" precision="0" type="INT16" value="1" widget="toggle">
    <constraint key="0">Do Not Do Action</constraint>
    <constraint key="1">Do Action at 5s</constraint>
    </param>
    <param access="1" maxlength="0" name="time" oid="time" type="STRING" value="00:00:07" widget="label"/>
    </params>
    </meta>
    <param expand="true" height="60" left="80" oid="toggle" showlabel="false" top="100" width="200"/>
    <param expand="true" height="60" left="300" oid="time" style="style:timerLabel" top="100" width="260"/>
    <button buttontype="push" height="60" left="580" name="GO" top="100" width="120">
    <task tasktype="timercontrol">ogscript.getTimerManager().getTimer('Countdown').startTimer(true);</task>
    </button>
    </abs>

     

    Let me know if you have further questions.


    #DashBoard