mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Fix the schedule dispatcher
-- Implemented a working Stop time.
This commit is contained in:
parent
2cf1801f1d
commit
2611ba0fe8
@ -62,7 +62,7 @@ function SCHEDULEDISPATCHER:AddSchedule( Scheduler, ScheduleFunction, ScheduleAr
|
|||||||
|
|
||||||
-- Initialize the ObjectSchedulers array, which is a weakly coupled table.
|
-- Initialize the ObjectSchedulers array, which is a weakly coupled table.
|
||||||
-- If the object used as the key is nil, then the garbage collector will remove the item from the Functions array.
|
-- If the object used as the key is nil, then the garbage collector will remove the item from the Functions array.
|
||||||
self.ObjectSchedulers = self.ObjectSchedulers or {} -- setmetatable( {}, { __mode = "v" } )
|
self.ObjectSchedulers = self.ObjectSchedulers or setmetatable( {}, { __mode = "v" } )
|
||||||
|
|
||||||
if Scheduler.MasterObject then
|
if Scheduler.MasterObject then
|
||||||
self.ObjectSchedulers[self.CallID] = Scheduler
|
self.ObjectSchedulers[self.CallID] = Scheduler
|
||||||
@ -133,10 +133,10 @@ function SCHEDULEDISPATCHER:AddSchedule( Scheduler, ScheduleFunction, ScheduleAr
|
|||||||
end
|
end
|
||||||
|
|
||||||
local CurrentTime = timer.getTime()
|
local CurrentTime = timer.getTime()
|
||||||
local StartTime = CurrentTime + Start
|
local StartTime = Schedule.StartTime
|
||||||
|
|
||||||
if Status and (( Result == nil ) or ( Result and Result ~= false ) ) then
|
if Status and (( Result == nil ) or ( Result and Result ~= false ) ) then
|
||||||
if Repeat ~= 0 and ( Stop == 0 ) or ( Stop ~= 0 and CurrentTime <= StartTime + Stop ) then
|
if Repeat ~= 0 and ( ( Stop == 0 ) or ( Stop ~= 0 and CurrentTime <= StartTime + Stop ) ) then
|
||||||
local ScheduleTime =
|
local ScheduleTime =
|
||||||
CurrentTime +
|
CurrentTime +
|
||||||
Repeat +
|
Repeat +
|
||||||
@ -182,6 +182,7 @@ function SCHEDULEDISPATCHER:Start( Scheduler, CallID )
|
|||||||
-- Only start when there is no ScheduleID defined!
|
-- Only start when there is no ScheduleID defined!
|
||||||
-- This prevents to "Start" the scheduler twice with the same CallID...
|
-- This prevents to "Start" the scheduler twice with the same CallID...
|
||||||
if not Schedule[CallID].ScheduleID then
|
if not Schedule[CallID].ScheduleID then
|
||||||
|
Schedule[CallID].StartTime = timer.getTime() -- Set the StartTime field to indicate when the scheduler started.
|
||||||
Schedule[CallID].ScheduleID = timer.scheduleFunction(
|
Schedule[CallID].ScheduleID = timer.scheduleFunction(
|
||||||
Schedule[CallID].CallHandler,
|
Schedule[CallID].CallHandler,
|
||||||
CallID,
|
CallID,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user