Skip to content
QiTASC.com / intaQt Built-ins /
Timer Built-ins
/ .. /
Timer Built-ins





Timer Built-ins

Timer Built-ins periodically execute a reactor's function after an optional initial delay, without halting the feature execution.

Create Timer

Creates a new timer.

Syntax

1
<timer Timer> := timer()

Returns

The timer instance.

Example

1
myTimer = timer()

Cancel Timer

Terminates the timer instance, meaning all scheduled tasks will be canceled.

Syntax

1
<timer Timer>.cancel()

Parameter

  • timer - Name of the timer instance

Example

1
myTimer.cancel()

Execute Scheduled Task

Executes the scheduled task at the specified date and time. Periodic repetitions may be added. If the schedule date is in the past, it will execute immediately.

Note: If a scheduled function takes excessive time to complete, subsequent processes may not be successfully executed in time.

Execute Task Without Repetition

Executes the task once at the specified time, or immediately if the date is in the past.

Syntax

1
<timer Timer>.schedule(<functionRef FunctionRef()>, <date Date>)

Parameters

  • timer - Name of the timer instance

  • functionRef - The reference to a reactor function whose execution can be scheduled

  • date - The date and time of the first execution

Execute Task Periodically

Executes the task periodically after the first execution, according to the specified period.

Syntax

1
<timer Timer>.schedule(<functionRef FunctionRef()>, <date Date>, <periodInMillis Number>)

Parameters

  • timer - Name of the timer instance

  • functionRef - The reference to a reactor function whose execution can be scheduled

  • date - The date and time of the first execution

  • periodInMillis - The amount of milliseconds between reactor function executions

Execute After Delay

Executes the task once after an initial delay of n milliseconds.

Syntax

1
<timer Timer>.schedule(<functionRef FunctionRef()>, <delayInMillis Number>)

Parameters

  • timer - Name of the timer instance

  • functionRef - The reference to a reactor function whose execution can be scheduled

  • delayInMillis - The amount of milliseconds the first execution of a reactor function is delayed

Execute Periodically After Delay

Executes the task after an initial delay of n milliseconds and repeats periodically with a period of n milliseconds in between.

Syntax

1
<timer Timer>.schedule(<functionRef FunctionRef()>, <delayInMillis Number>, <periodInMillis Number>)

Parameters

  • timer - Name of the timer instance

  • functionRef - The reference to a reactor function whose execution can be scheduled

  • delayInMillis - The amount of milliseconds the first execution of a reactor function is delayed

  • periodInMillis - The amount of milliseconds between reactor function executions

Feature File Example

1
2
3
4
5
Feature: TimerFunction
  Scenario: test timer function
    Given execute timed function
    And wait for 1 second
    And print timed result

Stepdef Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
stepdef "execute timed function"
    TimedReactor.result := ""
    timer().schedule(TimedReactor::timed, 1000)
end

stepdef "print timed result"
    println(TimedReactor.result)
end

reactor TimedReactor
    func timed()
       TimedReactor.result := "QiTASC"
    end
end