Facility Control

 View Only
  • 1.  Timer sync

    Posted 10-29-2014 17:33
    I'm building a hockey score interface for use with Xpression, but I'm having an issue with the penalty clocks. Basically, if there is a penalty and I need to start the 2 minute penalty clock, the seconds don't change at the same time as the main game clock. Obviously this is just the nature of the timers; they run independently.

    So I'm wondering if there is a way to match the seconds in the two clocks so they change at the same time? Perhaps a script that I could add to my "stop" button that would round both timers up to the nearest second?

    Any insight would be appreciated. Thanks!


  • 2.  RE: Timer sync

    Posted 10-29-2014 17:41
    An easier option might be to use the game timer as the source for your penalty timer. That way starting/stopping one will start/stop the other and they tick at the same time. There are 4 types of timers: Manual, Simple Clock, Count Time Until, and "Other Timer" - "Other Timer" will allow you to make your penalty timer run off of the game timer.

    You can also try rounding to the second with getTime/setTime.

    Let me know if this helps.

    James

    #DashBoard


  • 3.  RE: Timer sync

    Posted 11-05-2014 16:00
    Thanks, James. This seems to work well with hockey! But I have another question.

    I'm also working on a Roller derby score-clock. It uses two timers: A 30min timer that runs continuously, and a 2min timer that starts, stops and resets with a referee's whistle. (Basically they are trying to do as many 2min bouts as possible within their 30min time limit)

    So the parent/child relationship with the timers works alright here.

    But sometimes when the 2min timer restarts, it can still sometimes be out of sync by what appears to be exactly half a second.

    Can you think of any way to get rid of that delay?

    Thanks again for your help!

    #DashBoard


  • 4.  RE: Timer sync

    Posted 11-10-2014 18:42
    Any chance you can send me a copy of your panel so I can take a closer look at what is going on?

    You can email me at jpeltzer@rossvideo.com

    #DashBoard


  • 5.  RE: Timer sync

    Posted 11-13-2014 19:30

    Got your CustomPanel - Thanks.

    What's likely happening is that when you tick the timer every 500ms, the main timer is counting 20:00:000, 19:59:500, 19:59:000, 19:58:500, etc. but you're only seeing the first 4 digits.

    If the penalty timer happens to start during one of the 500ms tics, then they will be out of sync.

    Naturally, this has a 50% chance of happening when there is a 500ms timer tick.

    2 quick things will help you out:

    1. Make sure you start the penalty timer before you start the game timer. This way you won't risk the game timer ticking before the penalty timer has started.

    2. We can make a quick adjustment to the timer before it starts and make sure that their sub-second values are aligned. It's your choice whether to make the game timer match the penalty timer or the penalty timer match the game timer. It's also your choice whether to add or subtract the difference. Here is the code from your panel but, before the timer is started, I add the difference to the penalty timer.

    ` var penTimer = ogscript.getTimerManager().getTimer('Home Pen 1');

    var periodTimer = ogscript.getTimerManager().getTimer('Period');

    var penMilliseconds = penTimer.getCurrent() % 1000;

    var periodMilliseconds = periodTimer.getCurrent() % 1000;

    if (penMilliseconds != periodMilliseconds)

    {

    ogscript.debug('adjusting penalty timer by ' + (periodMilliseconds - penMilliseconds) + 'milliseconds');

    penTimer.incrementTime(periodMilliseconds - penMilliseconds);

    }

    penTimer.startTimer(false);

    periodTimer.startTimer(false);`

    Hope this helps.


    #DashBoard