Module Scheduler

This module contains the SCHEDULER class.

1) Scheduler#SCHEDULER class, extends Base#BASE

The Scheduler#SCHEDULER class creates schedule.

1.1) SCHEDULER constructor

The SCHEDULER class is quite easy to use, but note that the New constructor has variable parameters:

  • Scheduler#SCHEDULER.New( nil ): Setup a new SCHEDULER object, which is persistently executed after garbage collection.
  • Scheduler#SCHEDULER.New( Object ): Setup a new SCHEDULER object, which is linked to the Object. When the Object is nillified or destroyed, the SCHEDULER object will also be destroyed and stopped after garbage collection.
  • Scheduler#SCHEDULER.New( nil, Function, FunctionArguments, Start, ... ): Setup a new persistent SCHEDULER object, and start a new schedule for the Function with the defined FunctionArguments according the Start and sequent parameters.
  • Scheduler#SCHEDULER.New( Object, Function, FunctionArguments, Start, ... ): Setup a new SCHEDULER object, linked to Object, and start a new schedule for the Function with the defined FunctionArguments according the Start and sequent parameters.

1.2) SCHEDULER timer stopping and (re-)starting.

The SCHEDULER can be stopped and restarted with the following methods:

  • Scheduler#SCHEDULER.Start(): (Re-)Start the schedules within the SCHEDULER object. If a CallID is provided to :Start(), only the schedule referenced by CallID will be (re-)started.
  • Scheduler#SCHEDULER.Stop(): Stop the schedules within the SCHEDULER object. If a CallID is provided to :Stop(), then only the schedule referenced by CallID will be stopped.

1.3) Create a new schedule

With Scheduler#SCHEDULER.Schedule() a new time event can be scheduled. This function is used by the :New() constructor when a new schedule is planned.


Contributions:

  • FlightControl : Concept & Testing

Authors:

  • FlightControl : Design & Programming

Test Missions:

  • SCH - Scheduler

Global(s)

SCHEDULER

Type SCHEDULER

SCHEDULER.ClassName
SCHEDULER:Clear()

Clears all pending schedules.

SCHEDULER:New(SchedulerObject, SchedulerFunction, SchedulerArguments, Start, Repeat, RandomizeFactor, Stop)

SCHEDULER constructor.

SCHEDULER:Remove(ScheduleID)

Removes a specific schedule if a valid ScheduleID is provided.

SCHEDULER:Schedule(SchedulerObject, SchedulerFunction, SchedulerArguments, Start, Repeat, RandomizeFactor, Stop)

Schedule a new time event.

SCHEDULER.ScheduleID

the ID of the scheduler.

SCHEDULER.SchedulerObject
SCHEDULER.Schedules
SCHEDULER:Start(ScheduleID)

(Re-)Starts the schedules or a specific schedule if a valid ScheduleID is provided.

SCHEDULER:Stop(ScheduleID)

Stops the schedules or a specific schedule if a valid ScheduleID is provided.

Global(s)

#SCHEDULER SCHEDULER

Type Scheduler

Type SCHEDULER

The SCHEDULER class

Field(s)

#string SCHEDULER.ClassName
SCHEDULER:Clear()

Clears all pending schedules.

SCHEDULER:New(SchedulerObject, SchedulerFunction, SchedulerArguments, Start, Repeat, RandomizeFactor, Stop)

SCHEDULER constructor.

Parameters

  • #table SchedulerObject : Specified for which Moose object the timer is setup. If a value of nil is provided, a scheduler will be setup without an object reference.

  • #function SchedulerFunction : The event function to be called when a timer event occurs. The event function needs to accept the parameters specified in SchedulerArguments.

  • #table SchedulerArguments : Optional arguments that can be given as part of scheduler. The arguments need to be given as a table { param1, param 2, ... }.

  • #number Start : Specifies the amount of seconds that will be waited before the scheduling is started, and the event function is called.

  • #number Repeat : Specifies the interval in seconds when the scheduler will call the event function.

  • #number RandomizeFactor : Specifies a randomization factor between 0 and 1 to randomize the Repeat.

  • #number Stop : Specifies the amount of seconds when the scheduler will be stopped.

Return values

  1. #SCHEDULER: self.

  2. #number: The ScheduleID of the planned schedule.

SCHEDULER:Remove(ScheduleID)

Removes a specific schedule if a valid ScheduleID is provided.

Parameter

  • #number ScheduleID : (optional) The ScheduleID of the planned (repeating) schedule.

SCHEDULER:Schedule(SchedulerObject, SchedulerFunction, SchedulerArguments, Start, Repeat, RandomizeFactor, Stop)

Schedule a new time event.

Note that the schedule will only take place if the scheduler is started. Even for a single schedule event, the scheduler needs to be started also.

Parameters

  • #table SchedulerObject : Specified for which Moose object the timer is setup. If a value of nil is provided, a scheduler will be setup without an object reference.

  • #function SchedulerFunction : The event function to be called when a timer event occurs. The event function needs to accept the parameters specified in SchedulerArguments.

  • #table SchedulerArguments : Optional arguments that can be given as part of scheduler. The arguments need to be given as a table { param1, param 2, ... }.

  • #number Start : Specifies the amount of seconds that will be waited before the scheduling is started, and the event function is called.

  • #number Repeat : Specifies the interval in seconds when the scheduler will call the event function.

  • #number RandomizeFactor : Specifies a randomization factor between 0 and 1 to randomize the Repeat.

  • #number Stop : Specifies the amount of seconds when the scheduler will be stopped.

Return value

#number: The ScheduleID of the planned schedule.

#number SCHEDULER.ScheduleID

the ID of the scheduler.

SCHEDULER.SchedulerObject
SCHEDULER.Schedules
SCHEDULER:Start(ScheduleID)

(Re-)Starts the schedules or a specific schedule if a valid ScheduleID is provided.

Parameter

  • #number ScheduleID : (optional) The ScheduleID of the planned (repeating) schedule.

SCHEDULER:Stop(ScheduleID)

Stops the schedules or a specific schedule if a valid ScheduleID is provided.

Parameter

  • #number ScheduleID : (optional) The ScheduleID of the planned (repeating) schedule.