Facility Control

 View Only
  • 1.  Dashboard clock to pause at a specific time

    Posted 03-18-2020 21:53

    I have built a clock in dashboard to count up from 00:00 to 90:00. I have a button to start and stop the clock when needed. I am trying to find a way for the clock to automatically stop at a few specific times, 40:00, 80:00 and 85:00. Then when I click the start button the clock will resume.

    If anyone has any advice that would be great. Thanks



  • 2.  RE: Dashboard clock to pause at a specific time

    Posted 03-20-2020 15:44

    Hi Sam,

    with a bit of ogscript code you can hook up a timer task to monitor the current timer.

    Here's an example that runs a timer and will pause at 5 and 10 seconds. If you open the debug window you can see the timer output and messages appearing at these points.

    You can create a new panel and overwrite the contents with the markup below to see this running.

    I hope this helps.

    Colin.

     

    <abs contexttype="opengear" id="_top" keepalive="false">
    <meta>
    <params>
    <param access="1" maxlength="0" name="timer.to.stop" oid="timer.to.stop" type="STRING" value="00:00:00" widget="default"/>
    </params>
    </meta>
    <timer autostart="false" id="mytestClock" pattern="HH:mm:ss" rate="1000" start="00:00:00" stop="01:30:00">
    <timertask tasktype="ogscript">//
    var time = event.toString();
    var timeToStop = params.getValue( "timer.to.stop", 0 );

    if ( time == timeToStop){

    ogscript.debug( "first point reached ............................." + timeToStop );
    ogscript.getTimerManager().getTimer("mytestClock").stopTimer( false );
    ogscript.reveal( "start.timer.button" );
    return;
    }

    ogscript.debug( "Updated: " + time );</timertask>
    </timer>
    <button buttontype="push" height="79" id="start.timer.button" left="39" name="Start Timer" top="106" width="164">
    <task tasktype="ogscript">ogscript.debug( "START" );
    var timeToStop = params.getValue( "timer.to.stop", 0 );
    if ( timeToStop == "00:00:00" ){
    timeToStop = "00:00:05";
    }else if( timeToStop == "00:00:05" ){
    timeToStop = "00:00:10";
    }else{
    timeToStop = "never";
    }
    params.setValue( "timer.to.stop", 0, timeToStop );
    ogscript.getTimerManager().getTimer("mytestClock").startTimer( false );
    ogscript.hide( "start.timer.button" );</task>
    </button>
    <button buttontype="push" height="3" left="286" top="455" width="1"/>
    <param expand="true" height="43" left="235" oid="timer.to.stop" showlabel="false" top="144" widget="label" width="259"/>
    <label height="46" left="233" name="Time to Stop" style="txt-align:west" top="102" width="283"/>
    <button buttontype="push" height="79" left="35" name="Reset Timer" top="16" width="164">
    <task tasktype="ogscript">params.setValue( "timer.to.stop", 0, "00:00:00" );
    ogscript.getTimerManager().getTimer("mytestClock").stopTimer( true );
    ogscript.getTimerManager().getTimer("mytestClock").resetTimer;
    ogscript.reveal( "start.timer.button" );</task>
    </button>
    </abs>


    #DashBoard


  • 3.  RE: Dashboard clock to pause at a specific time

    Posted 03-21-2020 20:37

    Thank you Colin this works great.

    However when I add in a stop button for the operator to manually stop the clock, when the clock is stopped and then started again the timeToStop moves on to the next timeToStop.

    In your example the first time to stop is 00:05. If I was to manually stop the clock before it reaches that time, say 00:03 and then start it again the timeToStop changes to 00:10.

    Is it possible for the timeToStop remain at 00:05 even after I stop and start the clock?

    Thanks again for your help

     

    Here is my DashBoard if that helps.

    <abs contexttype="opengear" id="_top" keepalive="false">
    <button buttontype="push" height="80" id="start.timer.button" left="43" name="Start Clock" style="bg#009D02;size:22;" top="21" width="160">
    <task tasktype="ogscript">ogscript.debug( "START" );
    var timeToStop = params.getValue( "timer.to.stop", 0 );
    if ( timeToStop == "00:00" ){
    timeToStop = "00:05";
    }else if( timeToStop == "00:05" ){
    timeToStop = "00:10";
    }else if( timeToStop == "00:10" ){
    timeToStop = "40:00";
    }else{
    timeToStop = "never";
    }
    params.setValue( "timer.to.stop", 0, timeToStop );
    ogscript.getTimerManager().getTimer("mytestClock").startTimer( false );
    ogscript.hide( "start.timer.button" );
    ogscript.reveal( "stop.timer.button" );</task>
    </button>
    <abs height="139" left="59" top="220" width="281">
    <param expand="true" height="60" left="79" oid="gameclock" style="style:timerLabel;size:40;txt-align:center;" top="41" width="180"/>
    <button buttontype="push" height="60" left="19" name="R" style="size:26;bg#830000;look:normal;txt-align:south;" top="40" width="60">
    <task tasktype="ogscript">params.setValue( "timer.to.stop", 0, "00:00" );
    ogscript.getTimerManager().getTimer("mytestClock").stopTimer( false );
    ogscript.getTimerManager().getTimer("mytestClock").resetTimer;
    ogscript.reveal( "start.timer.button" );
    ogscript.hide( "stop.timer.button" );</task>
    <task tasktype="timercontrol">ogscript.getTimerManager().getTimer('mytestClock').resetTimer();</task>
    </button>
    <button buttontype="push" flat="true" height="28" left="103" name="▲" top="7" width="28">
    <task tasktype="timercontrol">ogscript.getTimerManager().getTimer('mytestClock').incrementTime(600000);</task>
    </button>
    <button buttontype="push" flat="true" height="28" left="134" name="▲" top="7" width="28">
    <task tasktype="timercontrol">ogscript.getTimerManager().getTimer('mytestClock').incrementTime(60000);</task>
    </button>
    <button buttontype="push" flat="true" height="28" left="174" name="▲" top="7" width="28">
    <task tasktype="timercontrol">ogscript.getTimerManager().getTimer('mytestClock').incrementTime(10000);</task>
    </button>
    <button buttontype="push" flat="true" height="28" left="205" name="▲" top="7" width="28">
    <task tasktype="timercontrol">ogscript.getTimerManager().getTimer('mytestClock').incrementTime(1000);</task>
    </button>
    <button buttontype="push" flat="true" height="28" left="205" name="▼" top="104" width="28">
    <task tasktype="timercontrol">ogscript.getTimerManager().getTimer('mytestClock').incrementTime(-1000);</task>
    </button>
    <button buttontype="push" flat="true" height="28" left="174" name="▼" top="105" width="28">
    <task tasktype="timercontrol">ogscript.getTimerManager().getTimer('mytestClock').incrementTime(-10000);</task>
    </button>
    <button buttontype="push" flat="true" height="28" left="134" name="▼" top="104" width="28">
    <task tasktype="timercontrol">ogscript.getTimerManager().getTimer('mytestClock').incrementTime(-60000);</task>
    </button>
    <button buttontype="push" flat="true" height="28" left="103" name="▼" top="104" width="28">
    <task tasktype="timercontrol">ogscript.getTimerManager().getTimer('mytestClock').incrementTime(-600000);</task>
    </button>
    </abs>
    <button buttontype="push" height="80" id="stop.timer.button" left="59" name="Stop Clock" style="bg#830000;size:22;txt-align:center;" top="100" width="160">
    <task tasktype="timercontrol">ogscript.getTimerManager().getTimer('mytestClock').stopTimer(false);</task>
    <task tasktype="ogscript">ogscript.hide( "stop.timer.button" );
    ogscript.reveal( "start.timer.button" );</task>
    </button>
    <meta>
    <params>
    <param access="1" maxlength="0" name="timer.to.stop" oid="timer.to.stop" type="STRING" value="00:10" widget="default"/>
    <param access="1" maxlength="0" name="gameclock" oid="gameclock" type="STRING" value="00:03" widget="label"/>
    </params>
    </meta>
    <timer autostart="false" id="mytestClock" pattern="mm:ss" rate="1000" start="00:00" stop="90:00">
    <timertask tasktype="ogparamset">params.setValue('gameclock', 0, event.getDisplay());</timertask>
    <timertask tasktype="ogscript">//
    var time = event.toString();
    var timeToStop = params.getValue( "timer.to.stop", 0 );

    if ( time == timeToStop){

    ogscript.debug( "first point reached ............................." + timeToStop );
    ogscript.getTimerManager().getTimer("mytestClock").stopTimer( false );
    ogscript.reveal( "start.timer.button" );
    return;
    }
    ogscript.debug( "Updated: " + time );</timertask>
    </timer>
    <button buttontype="push" height="3" left="286" top="455" width="1"/>
    <param expand="true" height="43" left="235" oid="timer.to.stop" showlabel="false" top="144" widget="label" width="259"/>
    <label height="46" left="233" name="Time to Stop" style="txt-align:west;" top="102" width="283"/>
    </abs>


    #DashBoard


  • 4.  RE: Dashboard clock to pause at a specific time

    Posted 03-23-2020 10:18

    Hi Sam

    The quickest and easiest way would be to create two states for the Stop button to check to see if the timer is running. I've updated your code and added my example code below.

    thanks

    Colin.

    <abs contexttype="opengear" id="_top" keepalive="false">
    <button buttontype="push" height="80" id="start.timer.button" left="58" name="Start Clock" style="bg#009D02;size:22;" top="19" width="160">
    <task tasktype="ogscript">ogscript.debug( "START" );
    var timeToStop = params.getValue( "timer.to.stop", 0 );
    if ( timeToStop == "00:00" ){
    timeToStop = "00:05";
    }else if( timeToStop == "00:05" ){
    timeToStop = "00:10";
    }else if( timeToStop == "00:10" ){
    timeToStop = "40:00";
    }else{
    timeToStop = "never";
    }
    params.setValue( "timer.to.stop", 0, timeToStop );
    ogscript.getTimerManager().getTimer("mytestClock").startTimer( false );
    ogscript.hide( "start.timer.button" );
    ogscript.rename( "stop.timer.button", "Stop" );
    ogscript.reveal( "stop.timer.button" );</task>
    </button>
    <abs height="139" left="59" top="220" width="281">
    <param expand="true" height="60" left="79" oid="gameclock" style="style:timerLabel;size:40;txt-align:center;" top="41" width="180"/>
    <button buttontype="push" height="60" left="19" name="R" style="size:26;bg#830000;look:normal;txt-align:south;" top="40" width="60">
    <task tasktype="ogscript">params.setValue( "timer.to.stop", 0, "00:00" );
    ogscript.getTimerManager().getTimer("mytestClock").stopTimer( false );
    ogscript.getTimerManager().getTimer("mytestClock").resetTimer;
    ogscript.reveal( "start.timer.button" );
    ogscript.hide( "stop.timer.button" );</task>
    <task tasktype="timercontrol">ogscript.getTimerManager().getTimer('mytestClock').resetTimer();</task>
    </button>
    <button buttontype="push" flat="true" height="28" left="103" name="▲" top="7" width="28">
    <task tasktype="timercontrol">ogscript.getTimerManager().getTimer('mytestClock').incrementTime(600000);</task>
    </button>
    <button buttontype="push" flat="true" height="28" left="134" name="▲" top="7" width="28">
    <task tasktype="timercontrol">ogscript.getTimerManager().getTimer('mytestClock').incrementTime(60000);</task>
    </button>
    <button buttontype="push" flat="true" height="28" left="174" name="▲" top="7" width="28">
    <task tasktype="timercontrol">ogscript.getTimerManager().getTimer('mytestClock').incrementTime(10000);</task>
    </button>
    <button buttontype="push" flat="true" height="28" left="205" name="▲" top="7" width="28">
    <task tasktype="timercontrol">ogscript.getTimerManager().getTimer('mytestClock').incrementTime(1000);</task>
    </button>
    <button buttontype="push" flat="true" height="28" left="205" name="▼" top="104" width="28">
    <task tasktype="timercontrol">ogscript.getTimerManager().getTimer('mytestClock').incrementTime(-1000);</task>
    </button>
    <button buttontype="push" flat="true" height="28" left="174" name="▼" top="105" width="28">
    <task tasktype="timercontrol">ogscript.getTimerManager().getTimer('mytestClock').incrementTime(-10000);</task>
    </button>
    <button buttontype="push" flat="true" height="28" left="134" name="▼" top="104" width="28">
    <task tasktype="timercontrol">ogscript.getTimerManager().getTimer('mytestClock').incrementTime(-60000);</task>
    </button>
    <button buttontype="push" flat="true" height="28" left="103" name="▼" top="104" width="28">
    <task tasktype="timercontrol">ogscript.getTimerManager().getTimer('mytestClock').incrementTime(-600000);</task>
    </button>
    </abs>
    <button buttontype="push" height="80" id="stop.timer.button" left="59" name="Stop Clock" style="bg#830000;size:22;txt-align:center;" top="100" visible="false" width="160">
    <task tasktype="ogscript">//
    if ( ogscript.isTimerRunning("mytestClock") ){
    ogscript.getTimerManager().getTimer("mytestClock").stopTimer( false );
    ogscript.rename( "stop.timer.button", "Resume" );
    }else{
    ogscript.getTimerManager().getTimer("mytestClock").startTimer( false );
    ogscript.rename( "stop.timer.button", "Stop" );

    }</task>
    </button>
    <meta>
    <params>
    <param access="1" maxlength="0" name="timer.to.stop" oid="timer.to.stop" type="STRING" value="00:00" widget="default"/>
    <param access="1" maxlength="0" name="gameclock" oid="gameclock" type="STRING" value="00:00" widget="label"/>
    </params>
    </meta>
    <timer autostart="false" id="mytestClock" pattern="mm:ss" rate="1000" start="00:00" stop="90:00">
    <timertask tasktype="ogparamset">params.setValue('gameclock', 0, event.getDisplay());</timertask>
    <timertask tasktype="ogscript">//
    var time = event.toString();
    var timeToStop = params.getValue( "timer.to.stop", 0 );

    if ( time == timeToStop){

    ogscript.debug( "first point reached ............................." + timeToStop );
    ogscript.getTimerManager().getTimer("mytestClock").stopTimer( false );
    ogscript.reveal( "start.timer.button" );

    ogscript.hide( "stop.timer.button" );


    return;
    }
    ogscript.debug( "Updated: " + time );</timertask>
    </timer>
    <button buttontype="push" height="3" left="286" top="455" width="1"/>
    <param expand="true" height="43" left="235" oid="timer.to.stop" showlabel="false" top="144" widget="label" width="259"/>
    <label height="46" left="233" name="Time to Stop" style="txt-align:west;" top="102" width="283"/>
    </abs>


    #DashBoard


  • 5.  RE: Dashboard clock to pause at a specific time

    Posted 03-24-2020 00:53

    Thanks Colin, much appreciated.


    #DashBoard