Facility Control

Expand all | Collapse all

Trigger function after holding a button for more than X seconds

  • 1.  Trigger function after holding a button for more than X seconds

    Posted 15 days ago
    Hello!

    Apology if the question has already been posted, i searched and couldn't find a related thread.

    I would like to know if there is a way to trigger a function after pressing a button for more than 3 seconds for example ?

    Thanks in advance!

    ------------------------------
    Guillaume HANOCQ
    CVS ENGINEERING
    ------------------------------


  • 2.  RE: Trigger function after holding a button for more than X seconds

    Posted 11 days ago
    Hello Ross,
    May i update this thread. Would you have some tips for me ?
    Thanks in advance !

    ------------------------------
    Guillaume HANOCQ
    CVS ENGINEERING
    ------------------------------



  • 3.  RE: Trigger function after holding a button for more than X seconds

    Ross Staff
    Posted 7 days ago
    Hi Guillaume
    Sorry for the delayed response. Here is an example of doing just what you are requesting:
    <abs contexttype="opengear" keepalive="true" style="bg#dark;">
    <meta>
    <params>
    <param access="1" constrainttype="INT_CHOICE" name="Trigger On Extended Hold" oid="Trigger_On_Extended_Hold" precision="0" type="INT32" value="0" widget="toggle">
    <constraint key="0">BUTTON</constraint>
    <constraint key="1">BUTTON</constraint>
    </param>
    </params>
    </meta>
    <param expand="true" height="85" left="63" oid="Trigger_On_Extended_Hold" style="style:toggleButton;" top="76" width="233">
    <config key="w.instantoff">true</config>
    <task tasktype="ogscript">var propertyName = 'button-1-time';

    if (this.getValue() == 1)
    {
    var myTime = (new Date()).getTime(); //TRACK THE CURRENT TIME
    ogscript.putObject(propertyName, myTime); //STORE IT IN A PANEL-WIDE VARIABLE

    function delayedAction()
    {
    if (myTime != ogscript.getObject(propertyName))
    {
    ogscript.debug("DID NOT HOLD LONG ENOUGH");
    return;
    }

    ogscript.debug("RUN THE ACTION");
    }
    ogscript.asyncExec(delayedAction, 3000); //IN 3 SECONDS, ATTEMPT TO RUN THE ACTION
    }
    else
    {
    ogscript.putObject(propertyName, null);
    }
    </task>
    </param>
    </abs>

    ------------------------------
    James Peltzer
    Ross Video
    ------------------------------



  • 4.  RE: Trigger function after holding a button for more than X seconds

    Posted 7 days ago
    Hey James,

    Thanks for your feedback on this.
    Will try the code in my custom panel ;).

    Have a great day !

    ------------------------------
    Guillaume HANOCQ
    CVS ENGINEERING
    ------------------------------