shankar_r's avatar
shankar_r
Community Hero
8 years ago
Status:
New Idea

Indicator Timer

My Test Complete execution normally takes more than a Hour or so. Hence in the Indicator popup if we have the timer which will display the HH : MM : SS running.

 

This will help us to know approx. when it will end or knowing other stuffs wrt timings.

 

I'm expecting something like below,

 

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    OK... message me if you want the actual extension file.

    Basically, the implementation is like so...

    First, in your project, create a simple wrapper function somewhere to call the timer object method.  The reason being is that timer objects cannot call script extension methods directly.  Something like this:

    function timerExecution() {
        IndicatorTimer.updateIndicatorTimer();
    }



     

    Next, at the beginning of your project, make the following call:

     

     

        IndicatorTimer.projectStartTime = aqDateTime.Now();

    This initializes the timer at the start of your project run so we can get the elapsed time.

    Then, create your timer:

        myTimer = Utils.Timers.Add(1000, 'Unit1.timerExecution', true);

    And boom... there ya go... every second now, the Indicator will update to include a formatted text showing hours, minutes, and seconds of elapsed time.

    You can even include at the end of your project a line like:

    Log.Message('Overall elapsed time = ' + aqConvert.DateTimeToFormatStr(IndicatorTimer.projectElapsedTime, '[%H:%M:%S]'));

    One caveat that I haven't found a work around for...

    The indicator gets updated a LOT during a test run... especially with "WaitNNN" calls and the like.  Anytime the indicator gets updated like that, it blows away the time text in the indicator... however, all you have to do is wait a second or so and it will show up again.  You could also decrease the timer interval from 1000 to 100... every 10th of a second then we'll update the indicator.  This seems to do pretty well but I'm not sure about performance overhead.

    Again... let me know if you want the extension... 

     

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Ditto on the idea... although, you could potentially do something like that already... if you combine a Timer object, the HISUtils.StopWatch object, and methods on the Indicator object, you could probably hack together a really cool little thingie to do exactly what you want.

     

    Actually... you've inspired me... currently, the timer object is not available in script extensions... so that would have to be something handled in code... HOWEVER... the Indicator object IS available... as is the aqDateTime object... so, combing those into an Indicator pop/push set, called by a timer in your project, could do the same thing...

    Give me a few free hours, I might even code something like that. :)