Facility Control

 View Only
  • 1.  Input a Timer Preset value

    Posted 05-28-2017 08:01
    Hi,

    I'm working on a Rugby League scoring interface. I think I have the scoring ok, but I'm trying to allow the operator to input a preset time for the game clock to start counting up from. This will only be used in emergency if the timer doesn't match the official time. Using the timer controls I can start, stop, reset and preset the timer, but the preset is only from the value that is on the button. I want to be able to enter the value in a text input field, then hit a Set Timer button to reflect this value. I have a parameter called Set Time, which will reflect the value from the input text field, but I'm not sure how to transfer this parameter's value to the timers value.

    I'm new to the world of Dashboard, and would be grateful for any suggestions. My next challenge will be sending this data across to Xpression.

    Thanks.


  • 2.  RE: Input a Timer Preset value

    Posted 05-29-2017 20:12

    Check out this example file:

    <abs contexttype="opengear" gridsize="20" style="">
    <meta>
    <params>
    <param access="1" maxlength="0" name="cddisplay" oid="cddisplay" stateless="true" type="STRING" value="40:00" widget="label"/>
    <param access="1" maxlength="0" name="cdvalue" oid="cdvalue" type="STRING" value="50:00" widget="text"/>
    </params>
    </meta>
    <timer autostart="false" id="cdtimer" pattern="mm:ss" rate="500" start="999:59" stop="00:00">
    <timertask tasktype="ogparamset">params.setValue('cddisplay', 0, event.getDisplay());</timertask>
    </timer>
    <param expand="true" height="60" left="40" oid="cddisplay" style="style:timerLabel" top="40" width="120"/>
    <param expand="true" height="60" left="40" oid="cdvalue" top="120" width="120"/>
    <button buttontype="push" height="60" left="180" name="Start / Pause" top="40" width="120">
    <task tasktype="ogscript">var timer = ogscript.getTimerManager().getTimer("cdtimer");
    if (!timer.isRunning())
    {
    timer.startTimer(false);
    }
    else
    {
    timer.stopTimer(false);
    }</task>
    </button>
    <button buttontype="push" height="60" left="180" name="Set Countdown" top="120" width="120">
    <task tasktype="timercontrol">var startValue = params.getValue('cdvalue', 0);
    var timer = ogscript.getTimerManager().getTimer('cdtimer');
    var parsedStartValue = timer.getFormat().parseObject(startValue);
    timer.setStart(parsedStartValue);
    timer.setTime(parsedStartValue);</task>
    </button>
    <button buttontype="push" height="140" left="320" name="Reset" top="40" width="80">
    <task tasktype="ogscript">var timer = ogscript.getTimerManager().getTimer('cdtimer');
    timer.resetTimer();</task>
    </button>
    </abs>

    The relevant script is in the "Set Countdown" button (note that you'll probably want to remove the call to "setStart" for how you are using things)

    var startValue = params.getValue('cdvalue', 0); //Get the text value of the time
    var timer = ogscript.getTimerManager().getTimer('cdtimer'); //Get the timer
    var parsedStartValue = timer.getFormat().parseObject(startValue); //Parse the text using the same format (mm:ss) as the timer
    timer.setStart(parsedStartValue); //You'll probably want to remove this the way you are using it
    timer.setTime(parsedStartValue); //Set the current time

    #DashBoard


  • 3.  RE: Input a Timer Preset value

    Posted 02-18-2019 13:39
    Hi!

    I tried using your code and ran into a problem. When i set the countdown, the direction of the timer changes. I want to be able to force the direction of the timer. How do I do that?
    #DashBoard


  • 4.  RE: Input a Timer Preset value

    Posted 02-19-2019 19:56

    Hermangud You can change the direction of the timer by changing the start/stop points:

    <abs contexttype="opengear" gridsize="20" style="">
    <meta>
    <params>
    <param access="1" maxlength="0" name="cddisplay" oid="cddisplay" stateless="true" type="STRING" value="00:00" widget="label"/>
    </params>
    </meta>
    <timer autostart="false" id="cdtimer" pattern="mm:ss" rate="500" start="00:00" stop="60:00">

    <timertask tasktype="ogparamset">params.setValue('cddisplay', 0, event.getDisplay());</timertask>
    </timer>
    <param expand="true" height="60" left="40" oid="cddisplay" style="style:timerLabel" top="40" width="120"/>

    <button buttontype="push" height="60" left="180" name="Start / Pause" top="40" width="120">
    <task tasktype="ogscript">var timer = ogscript.getTimerManager().getTimer("cdtimer");
    if (!timer.isRunning())
    {
    timer.startTimer(false);
    }
    else
    {
    timer.stopTimer(false);
    }</task>
    </button>
    <button buttontype="push" height="60" left="60" name="Count Up (60:00)" top="120" width="240">
    <task tasktype="timercontrol">var startValue = params.getValue('cdvalue', 0);
    var timer = ogscript.getTimerManager().getTimer('cdtimer');
    var parsedStartValue = timer.getFormat().parseObject("00:00");
    var parsedStopValue = timer.getFormat().parseObject("60:00");
    timer.stopTimer(false);
    timer.setStop(parsedStopValue);
    timer.setStart(parsedStartValue);
    timer.startTimer(false);</task>
    </button>
    <button buttontype="push" height="60" left="320" name="Reset" top="40" width="140">
    <task tasktype="ogscript">var timer = ogscript.getTimerManager().getTimer('cdtimer');
    timer.resetTimer();</task>
    </button>

    <button buttontype="push" height="60" left="60" name="Count Down (10:00)" top="200" width="240">
    <task tasktype="timercontrol">var startValue = params.getValue('cdstop', 0);
    var timer = ogscript.getTimerManager().getTimer('cdtimer');
    var parsedStartValue = timer.getFormat().parseObject("10:00");
    var parsedStopValue = timer.getFormat().parseObject("00:00");
    timer.stopTimer(false);
    timer.setStop(parsedStopValue);
    timer.setStart(parsedStartValue);
    timer.startTimer(true); //Reset the timer to 10:00</task>
    </button>
    </abs>

    #DashBoard