mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Fixed problem with SchedulerObject in BASE. This caused conflicts in SPAWN and SCHEDULER.
This commit is contained in:
parent
5eeafd2fba
commit
3135639557
@ -199,6 +199,7 @@ BASE = {
|
|||||||
Events = {},
|
Events = {},
|
||||||
States = {},
|
States = {},
|
||||||
Debug = debug,
|
Debug = debug,
|
||||||
|
Scheduler = nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -706,10 +707,15 @@ do -- Scheduling
|
|||||||
ObjectName = self.ClassName .. self.ClassID
|
ObjectName = self.ClassName .. self.ClassID
|
||||||
|
|
||||||
self:F3( { "ScheduleOnce: ", ObjectName, Start } )
|
self:F3( { "ScheduleOnce: ", ObjectName, Start } )
|
||||||
self.SchedulerObject = self
|
|
||||||
|
if not self.Scheduler then
|
||||||
|
self.Scheduler = SCHEDULER:New( self )
|
||||||
|
end
|
||||||
|
|
||||||
|
self.Scheduler.SchedulerObject = self.Scheduler
|
||||||
|
|
||||||
local ScheduleID = _SCHEDULEDISPATCHER:AddSchedule(
|
local ScheduleID = _SCHEDULEDISPATCHER:AddSchedule(
|
||||||
self,
|
self.Scheduler,
|
||||||
SchedulerFunction,
|
SchedulerFunction,
|
||||||
{ ... },
|
{ ... },
|
||||||
Start,
|
Start,
|
||||||
@ -740,10 +746,15 @@ do -- Scheduling
|
|||||||
ObjectName = self.ClassName .. self.ClassID
|
ObjectName = self.ClassName .. self.ClassID
|
||||||
|
|
||||||
self:F3( { "ScheduleRepeat: ", ObjectName, Start, Repeat, RandomizeFactor, Stop } )
|
self:F3( { "ScheduleRepeat: ", ObjectName, Start, Repeat, RandomizeFactor, Stop } )
|
||||||
self.SchedulerObject = self
|
|
||||||
|
if not self.Scheduler then
|
||||||
|
self.Scheduler = SCHEDULER:New( self )
|
||||||
|
end
|
||||||
|
|
||||||
|
self.Scheduler.SchedulerObject = self.Scheduler
|
||||||
|
|
||||||
local ScheduleID = _SCHEDULEDISPATCHER:AddSchedule(
|
local ScheduleID = _SCHEDULEDISPATCHER:AddSchedule(
|
||||||
self,
|
self.Scheduler,
|
||||||
SchedulerFunction,
|
SchedulerFunction,
|
||||||
{ ... },
|
{ ... },
|
||||||
Start,
|
Start,
|
||||||
@ -764,7 +775,7 @@ do -- Scheduling
|
|||||||
|
|
||||||
self:F3( { "ScheduleStop:" } )
|
self:F3( { "ScheduleStop:" } )
|
||||||
|
|
||||||
_SCHEDULEDISPATCHER:Stop( self, self._.Schedules[SchedulerFunction] )
|
_SCHEDULEDISPATCHER:Stop( self.Scheduler, self._.Schedules[SchedulerFunction] )
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -87,7 +87,7 @@ function SCHEDULEDISPATCHER:AddSchedule( Scheduler, ScheduleFunction, ScheduleAr
|
|||||||
self:T3( self.Schedule[Scheduler][CallID] )
|
self:T3( self.Schedule[Scheduler][CallID] )
|
||||||
|
|
||||||
self.Schedule[Scheduler][CallID].CallHandler = function( CallID )
|
self.Schedule[Scheduler][CallID].CallHandler = function( CallID )
|
||||||
self:F2( CallID )
|
--self:E( CallID )
|
||||||
|
|
||||||
local ErrorHandler = function( errmsg )
|
local ErrorHandler = function( errmsg )
|
||||||
env.info( "Error in timer function: " .. errmsg )
|
env.info( "Error in timer function: " .. errmsg )
|
||||||
@ -111,7 +111,7 @@ function SCHEDULEDISPATCHER:AddSchedule( Scheduler, ScheduleFunction, ScheduleAr
|
|||||||
|
|
||||||
--self:T3( { Schedule = Schedule } )
|
--self:T3( { Schedule = Schedule } )
|
||||||
|
|
||||||
local ScheduleObject = Scheduler.SchedulerObject
|
local SchedulerObject = Scheduler.SchedulerObject
|
||||||
--local ScheduleObjectName = Scheduler.SchedulerObject:GetNameAndClassID()
|
--local ScheduleObjectName = Scheduler.SchedulerObject:GetNameAndClassID()
|
||||||
local ScheduleFunction = Schedule.Function
|
local ScheduleFunction = Schedule.Function
|
||||||
local ScheduleArguments = Schedule.Arguments
|
local ScheduleArguments = Schedule.Arguments
|
||||||
@ -122,9 +122,10 @@ function SCHEDULEDISPATCHER:AddSchedule( Scheduler, ScheduleFunction, ScheduleAr
|
|||||||
local ScheduleID = Schedule.ScheduleID
|
local ScheduleID = Schedule.ScheduleID
|
||||||
|
|
||||||
local Status, Result
|
local Status, Result
|
||||||
if ScheduleObject then
|
--self:E( { SchedulerObject = SchedulerObject } )
|
||||||
|
if SchedulerObject then
|
||||||
local function Timer()
|
local function Timer()
|
||||||
return ScheduleFunction( ScheduleObject, unpack( ScheduleArguments ) )
|
return ScheduleFunction( SchedulerObject, unpack( ScheduleArguments ) )
|
||||||
end
|
end
|
||||||
Status, Result = xpcall( Timer, ErrorHandler )
|
Status, Result = xpcall( Timer, ErrorHandler )
|
||||||
else
|
else
|
||||||
|
|||||||
@ -325,6 +325,7 @@ function SPAWN:New( SpawnTemplatePrefix )
|
|||||||
end
|
end
|
||||||
|
|
||||||
self:SetEventPriority( 5 )
|
self:SetEventPriority( 5 )
|
||||||
|
self.SpawnHookScheduler = SCHEDULER:New( nil )
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -370,6 +371,7 @@ function SPAWN:NewWithAlias( SpawnTemplatePrefix, SpawnAliasPrefix )
|
|||||||
end
|
end
|
||||||
|
|
||||||
self:SetEventPriority( 5 )
|
self:SetEventPriority( 5 )
|
||||||
|
self.SpawnHookScheduler = SCHEDULER:New( nil )
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -957,9 +959,7 @@ function SPAWN:SpawnWithIndex( SpawnIndex )
|
|||||||
-- If there is a SpawnFunction hook defined, call it.
|
-- If there is a SpawnFunction hook defined, call it.
|
||||||
if self.SpawnFunctionHook then
|
if self.SpawnFunctionHook then
|
||||||
-- delay calling this for .1 seconds so that it hopefully comes after the BIRTH event of the group.
|
-- delay calling this for .1 seconds so that it hopefully comes after the BIRTH event of the group.
|
||||||
self.SpawnHookScheduler = SCHEDULER:New( self )
|
|
||||||
self.SpawnHookScheduler:Schedule( nil, self.SpawnFunctionHook, { self.SpawnGroups[self.SpawnIndex].Group, unpack( self.SpawnFunctionArguments)}, 0.1 )
|
self.SpawnHookScheduler:Schedule( nil, self.SpawnFunctionHook, { self.SpawnGroups[self.SpawnIndex].Group, unpack( self.SpawnFunctionArguments)}, 0.1 )
|
||||||
--self.SpawnFunctionHook( self.SpawnGroups[self.SpawnIndex].Group, unpack( self.SpawnFunctionArguments ) )
|
|
||||||
end
|
end
|
||||||
-- TODO: Need to fix this by putting an "R" in the name of the group when the group repeats.
|
-- TODO: Need to fix this by putting an "R" in the name of the group when the group repeats.
|
||||||
--if self.Repeat then
|
--if self.Repeat then
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user