getTimerManager

Get the timer manager for the context to access timers and perform operations on selected timers.

Syntax

ogscript.getTimerManager ( );

Parameters

N/A

Methods

The getTimerManager function is an object that has several methods. The following methods can be run on an existing timer. A timer can be created using the installTimer function or using the graphical editor. For more information about the installTimer function, see installTimer on page 168.

 

Method

Parameter Required

 

Description

isRunning()

N/A

Checks whether the time is running.

startTimer(Boolean reset)

Yes

true or false

Starts the timer.

If the boolean parameter is set to true, the timer resets to the starting time when the function is performed.

If the boolean parameter is set to false, the function is performed at the timer's current time.

stopTimer(Boolean reset)

Yes

true or false

Stops the timer.

If the boolean parameter is set to true, the timer resets to the starting time when the function is performed.

If the boolean parameter is set to false, the function is performed at the timer's current time.

resetTimer()

N/A

Resets the timer to the start time.

setStart(Long valueInMilliseconds)

Yes

Milliseconds (Long)

Sets the start time of the timer.

setStop(Long valueInMilliseconds)

Yes

Milliseconds (Long)

Sets the stop time of the timer.

setTime(Long valueInMilliseconds)

Yes

Milliseconds (Long)

Sets the current time of the timer.

getStart()

N/A

Returns the timer’s start time in milliseconds (Long).

getStop()

N/A

Returns the timer’s stop time in milliseconds (Long).

getCurrent()

N/A

Returns the timer’s current value in milliseconds (Long).

incrementTime(Long difference)

Yes

Milliseconds (Long)

Increments the timer value by the specified number of milliseconds

setPattern(String dateTimePattern)

Yes

Time format definition

Sets the time format pattern for displaying time values.

Returns

ContextTimerManager

Example 1 getTimerManager function using isRunning method

//verifyif timer named 'selftimer' is currently running

if (ogscript.getTimerManager().getTimer('selftimer').isRunning())

{

ogscript.debug('running = true');

}

else

{

ogscript.debug('running = false');

}

Example 2 getTimerManager function using startTimer method

//Startsa timer named'selftimer' ogscript.getTimerManager().getTimer('selftimer').startTimer(false);

Example 3 getTimerManager function using stopTimer method

//Stops a timernamed 'selftimer' ogscript.getTimerManager().getTimer('selftimer').stopTimer(false);

Example 4 getTimerManager function using resetTimer method

//Resetsa timer named 'selftimer' to the start time ogscript.getTimerManager().getTimer('selftimer').resetTimer();

Example 5 getTimerManager function using setStart method

//Set the start time of a timer named 'selftimer' to 30 seconds (30000ms)

ogscript.getTimerManager().getTimer('selftimer').setStart(30000);

Example 6 getTimerManager function using setStop method

//Set the stop time of a timer named 'selftimer' to two minutes (120000 ms)

ogscript.getTimerManager().getTimer('selftimer').setStop(120000);

Example 7 getTimerManager function using setTime method

//Set the current time of a timer named 'selftimer' to 59 seconds (59000 ms)

ogscript.getTimerManager().getTimer('selftimer').setTime(59000);

Example 8 getTimerManager function using getStart method

// Get the start time of a timer named  'selftimer' var startTime=

ogscript.getTimerManager().getTimer('selftimer').getStart();

Example 9 getTimerManager function using getStop method

// Get the stop time of a timer named 'selftimer' var stopTime =

ogscript.getTimerManager().getTimer('selftimer').getStop();

Example 10 getTimerManager function using getCurrent method

// Get the current time of a timer named 'selftimer' var currentTime =

ogscript.getTimerManager().getTimer('selftimer').getCurrent();

Example 11 getTimerManager function using incrementTime method

//increase the currenttime of a timer named  'selftimer' by 30 seconds

ogscript.getTimerManager().getTimer('selftimer').incrementTime(30000)

;

 

//decrease the currenttime of a timer named   'selftimer'by 5 seconds ogscript.getTimerManager().getTimer('selftimer').incrementTime(-5000)

;

Example 12 getTimerManager function using setPattern method

The following table describes the syntax for setting the time format. For some formats, repeating the letter returns more digits or a variation of the format. For example, when specifying M for month, one M shows the month number with no leading zero, two Ms adds a leading zero for months 0 to 9, three Ms shows the three letter month (such as Jan), and four or more Ms shows the full month name (such as January).

 

Letter

Date or Time Component

 

Presentation

 

Examples

D

Day

Number

189

H

Hour of the day (0-23)

Number

8

m

Minute of the hour

Number

30

s

Second of the minute

Number

55

S

Millisecond

Number

768

G

Era designator

Text

AD

Y

Year

Number

1969; 69

M

Month of the year

Text or number

September; Sep; 09

w

Week of the year

Number

27

W

Week of the month

Number

3

d

Day of the month

Number

12

F

Day of the week in the month

Number

1

If the day of the week is Tuesday, 1 would denote the first Tuesday of the month

E

Day of the week

Text

Friday; Fri

k

Hour of the day (1-24)

Number

22

K

Hour in AM/PM (0-11)

Number

0

h

Hour in AM/PM (1-12

Number

10

a

AM/PM marker

Text

PM

z

Time zone

General Time Zone

Pacific Standard Time, PST,

Z

Time zone

RFC 822 time zone

-0800

The following code example returns the date and time. An example of the date and time as returned by this example is Sep 30, 2013 2:35:34 PM.

//Sets the displayformat of a timer named 'simpleclock' to show full date and time

ogscript.getTimerManager().getTimer('simpleclock').setPattern('MMM dd, yyyy h:mm:ss a');