mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Progress
This commit is contained in:
@@ -42,6 +42,7 @@
|
||||
-- @extends Core.Base#BASE
|
||||
SCHEDULER = {
|
||||
ClassName = "SCHEDULER",
|
||||
Schedules = {},
|
||||
}
|
||||
|
||||
--- SCHEDULER constructor.
|
||||
@@ -58,26 +59,88 @@ function SCHEDULER:New( TimeEventObject, TimeEventFunction, TimeEventFunctionArg
|
||||
local self = BASE:Inherit( self, BASE:New() )
|
||||
self:F2( { StartSeconds, RepeatSecondsInterval, RandomizationFactor, StopSeconds } )
|
||||
|
||||
self.TimeEventObject = TimeEventObject
|
||||
self.TimeEventFunction = TimeEventFunction
|
||||
self.TimeEventFunctionArguments = TimeEventFunctionArguments
|
||||
self.StartSeconds = StartSeconds
|
||||
self.Repeat = false
|
||||
self.RepeatSecondsInterval = RepeatSecondsInterval or 0
|
||||
self.RandomizationFactor = RandomizationFactor or 0
|
||||
self.StopSeconds = StopSeconds
|
||||
|
||||
self.StartTime = timer.getTime()
|
||||
|
||||
self.CallID = _TIMERDISPATCHER:AddSchedule( self )
|
||||
self:Schedule( TimeEventObject, TimeEventFunction, TimeEventFunctionArguments, StartSeconds, RepeatSecondsInterval, RandomizationFactor, StopSeconds )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
function SCHEDULER:_Destructor()
|
||||
--self:E("_Destructor")
|
||||
--function SCHEDULER:_Destructor()
|
||||
-- --self:E("_Destructor")
|
||||
--
|
||||
-- _TIMERDISPATCHER:RemoveSchedule( self.CallID )
|
||||
--end
|
||||
|
||||
_TIMERDISPATCHER:RemoveSchedule( self.CallID )
|
||||
--- 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.
|
||||
-- @param #SCHEDULER self
|
||||
-- @param #table TimeEventObject 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.
|
||||
-- @param #function TimeEventFunction The event function to be called when a timer event occurs. The event function needs to accept the parameters specified in TimeEventFunctionArguments.
|
||||
-- @param #table TimeEventFunctionArguments Optional arguments that can be given as part of scheduler. The arguments need to be given as a table { param1, param 2, ... }.
|
||||
-- @param #number StartSeconds Specifies the amount of seconds that will be waited before the scheduling is started, and the event function is called.
|
||||
-- @param #number RepeatSecondsInterval Specifies the interval in seconds when the scheduler will call the event function.
|
||||
-- @param #number RandomizationFactor Specifies a randomization factor between 0 and 1 to randomize the RepeatSecondsInterval.
|
||||
-- @param #number StopSeconds Specifies the amount of seconds when the scheduler will be stopped.
|
||||
-- @return #SCHEDULER self
|
||||
function SCHEDULER:Schedule( TimeEventObject, TimeEventFunction, TimeEventFunctionArguments, StartSeconds, RepeatSecondsInterval, RandomizationFactor, StopSeconds )
|
||||
self:F2( { StartSeconds, RepeatSecondsInterval, RandomizationFactor, StopSeconds } )
|
||||
self:T3( { TimeEventFunctionArguments } )
|
||||
|
||||
|
||||
self.TimeEventObject = TimeEventObject
|
||||
|
||||
self.Schedules[#self.Schedules+1] = _TIMERDISPATCHER:AddSchedule(
|
||||
self,
|
||||
TimeEventFunction,
|
||||
TimeEventFunctionArguments,
|
||||
StartSeconds,
|
||||
RepeatSecondsInterval,
|
||||
RandomizationFactor,
|
||||
StopSeconds
|
||||
)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- (Re-)Starts the scheduler.
|
||||
-- @param #SCHEDULER self
|
||||
-- @return #SCHEDULER self
|
||||
function SCHEDULER:Start()
|
||||
self:F2()
|
||||
|
||||
if self.RepeatSecondsInterval ~= 0 then
|
||||
self.Repeat = true
|
||||
end
|
||||
|
||||
if self.StartSeconds then
|
||||
self:T( { self.StartSeconds } )
|
||||
self.Schedules[#self.Schedules+1] = _TIMERDISPATCHER:AddSchedule(
|
||||
self,
|
||||
self.TimeEventObject,
|
||||
self.TimeEventFunction,
|
||||
self.TimeEventFunctionArguments,
|
||||
self.StartSeconds,
|
||||
self.RepeatSecondsInterval,
|
||||
self.RandomizationFactor,
|
||||
self.StopSeconds
|
||||
)
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Stops the scheduler.
|
||||
-- @param #SCHEDULER self
|
||||
-- @return #SCHEDULER self
|
||||
function SCHEDULER:Stop()
|
||||
self:F2( self.TimeEventObject )
|
||||
|
||||
self.Repeat = false
|
||||
if self.ScheduleID then
|
||||
self:E( "Stop Schedule" )
|
||||
timer.removeFunction( self.ScheduleID )
|
||||
end
|
||||
self.ScheduleID = nil
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
@@ -94,4 +157,3 @@ end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user