Scheduler Object

Top  Previous  Next

The schedules object:

Functions

Return

Signature

Notes

boolean

start()

starts the scheduler

boolean

stop()

stops the scheduler

 

destroy()

destroys the scheduler

taskId

minuteTask( every, repeat, begin, end )

adds a minute task.

taskId

hourTask( every, minute, repeat, begin, end)

adds an hour task.

taskId

dayTask( every, hour, minute, repeat, begin, end)

adds a day task.

taskId

dayOfWeekTask( every, dow, hour, minute, repeat, begin, end)

adds a day of week task.

taskId

dayOfMonthTask( every, dom, hour, minute, repeat, begin, end)

adds a day of month task.

taskId

sunsetTask( every, latitude, longitude, repeat, begin, end, offset, timezone)

adds a sunrise task.

taskId

sunriseTask( every, latitude, longitude, repeat, begin, end, offset, timezone)

adds a sunset task.

boolean

removeTask( taskId )

removes a task.

boolean

clear()

removes all tasks.

taskList

getTasks()

returns a table with all task properties.

task

getTask( taskId )

returns a table with all properties for task.

boolean

setRandomizer( taskId, min, max, dist )

sets the randomizer on task.

boolean

keepBeyondLua()

returns if this scheduler lives beyond lua.

boolean

isRunning()

returns if this scheduler is running.

string

getEventString()

returns the eventstring.

number

getDevice()

returns the event device.

number

getID

returns the scheduler id.

string

getUUID

returns the scheduler uuid.

 

Task manipulation

Tasks are the parts of a scheduler that dictate when the scheduler triggers it's event. All the functions have a few parameters in common.

Name

Type

Description

every

number

Determines if the task should skip any of it's trigger points. For example. every = 1 means that each trigger point should actually trigger. every = 3 means that after one actual trigger, the next two trigger points are skipped.

repeat

number

how many times the task may trigger between begin and end times.

begin

Date Object

Date to start triggering from.

end

Date Object

Date to end triggering on.

 

Task Randomization

To prevent tasks from running at exactly the same interval setRandomizer can be used. The dist parameter selects the distribution. Currently we have:

dist = 0, returns minimum at all times.

dist = 1, returns a linear distribution of random values between min and max.

The min and max parameters are task offsets in minutes.