mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
nillification of the unit processes for tasks is fixed.
This commit is contained in:
parent
65c15281fd
commit
d77405bf9b
@ -192,15 +192,6 @@ do -- ACT_ACCOUNT_DEADS
|
||||
self.TaskName = FsmAccount.TaskName
|
||||
end
|
||||
|
||||
|
||||
|
||||
function ACT_ACCOUNT_DEADS:_Destructor()
|
||||
self:E("_Destructor")
|
||||
|
||||
self:EventRemoveAll()
|
||||
|
||||
end
|
||||
|
||||
--- Process Events
|
||||
|
||||
--- StateMachine callback function
|
||||
|
||||
@ -256,12 +256,14 @@ function BASE:_Destructor()
|
||||
--self:EventRemoveAll()
|
||||
end
|
||||
|
||||
|
||||
-- THIS IS WHY WE NEED LUA 5.2 ...
|
||||
function BASE:_SetDestructor()
|
||||
|
||||
-- TODO: Okay, this is really technical...
|
||||
-- When you set a proxy to a table to catch __gc, weak tables don't behave like weak...
|
||||
-- Therefore, I am parking this logic until I've properly discussed all this with the community.
|
||||
--[[
|
||||
|
||||
local proxy = newproxy(true)
|
||||
local proxyMeta = getmetatable(proxy)
|
||||
|
||||
@ -276,7 +278,7 @@ function BASE:_SetDestructor()
|
||||
-- table is about to be garbage-collected - then the __gc hook
|
||||
-- will be invoked and the destructor called
|
||||
rawset( self, '__proxy', proxy )
|
||||
--]]
|
||||
|
||||
end
|
||||
|
||||
--- This is the worker method to inherit from a parent class.
|
||||
|
||||
@ -425,11 +425,11 @@ function EVENT:Init( EventID, EventClass )
|
||||
-- Each event has a subtable of EventClasses, ordered by EventPriority.
|
||||
local EventPriority = EventClass:GetEventPriority()
|
||||
if not self.Events[EventID][EventPriority] then
|
||||
self.Events[EventID][EventPriority] = {}
|
||||
self.Events[EventID][EventPriority] = setmetatable( {}, { __mode = "kv" } )
|
||||
end
|
||||
|
||||
if not self.Events[EventID][EventPriority][EventClass] then
|
||||
self.Events[EventID][EventPriority][EventClass] = setmetatable( {}, { __mode = "k" } )
|
||||
self.Events[EventID][EventPriority][EventClass] = {}
|
||||
end
|
||||
return self.Events[EventID][EventPriority][EventClass]
|
||||
end
|
||||
@ -517,9 +517,9 @@ end
|
||||
function EVENT:OnEventGeneric( EventFunction, EventClass, EventID )
|
||||
self:F2( { EventID } )
|
||||
|
||||
local Event = self:Init( EventID, EventClass )
|
||||
Event.EventFunction = EventFunction
|
||||
Event.EventClass = EventClass
|
||||
local EventData = self:Init( EventID, EventClass )
|
||||
EventData.EventFunction = EventFunction
|
||||
EventData.EventClass = EventClass
|
||||
|
||||
return self
|
||||
end
|
||||
@ -535,13 +535,13 @@ end
|
||||
function EVENT:OnEventForUnit( UnitName, EventFunction, EventClass, EventID )
|
||||
self:F2( UnitName )
|
||||
|
||||
local Event = self:Init( EventID, EventClass )
|
||||
if not Event.EventUnit then
|
||||
Event.EventUnit = {}
|
||||
local EventData = self:Init( EventID, EventClass )
|
||||
if not EventData.EventUnit then
|
||||
EventData.EventUnit = {}
|
||||
end
|
||||
Event.EventUnit[UnitName] = {}
|
||||
Event.EventUnit[UnitName].EventFunction = EventFunction
|
||||
Event.EventUnit[UnitName].EventClass = EventClass
|
||||
EventData.EventUnit[UnitName] = {}
|
||||
EventData.EventUnit[UnitName].EventFunction = EventFunction
|
||||
EventData.EventUnit[UnitName].EventClass = EventClass
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
@ -896,6 +896,7 @@ do -- FSM_PROCESS
|
||||
-- @return #FSM_PROCESS
|
||||
function FSM_PROCESS:Copy( Controllable, Task )
|
||||
self:T( { self:GetClassNameAndID() } )
|
||||
|
||||
|
||||
local NewFsm = self:New( Controllable, Task ) -- Core.Fsm#FSM_PROCESS
|
||||
|
||||
|
||||
@ -394,6 +394,7 @@ function TASK:AssignToUnit( TaskUnit )
|
||||
self:E({"Address FsmUnit", tostring( FsmUnit ) } )
|
||||
|
||||
FsmUnit:SetStartState( "Planned" )
|
||||
|
||||
FsmUnit:Accept() -- Each Task needs to start with an Accept event to start the flow.
|
||||
|
||||
return self
|
||||
@ -404,7 +405,7 @@ end
|
||||
-- @param Wrapper.Unit#UNIT TaskUnit
|
||||
-- @return #TASK self
|
||||
function TASK:UnAssignFromUnit( TaskUnit )
|
||||
self:F( TaskUnit )
|
||||
self:F( TaskUnit:GetName() )
|
||||
|
||||
self:RemoveStateMachine( TaskUnit )
|
||||
|
||||
@ -637,11 +638,10 @@ function TASK:MenuTaskStatus( TaskGroup )
|
||||
|
||||
end
|
||||
|
||||
function TASK.MenuTaskAbort( MenuParam )
|
||||
--- Report the task status.
|
||||
-- @param #TASK self
|
||||
function TASK:MenuTaskAbort( TaskGroup )
|
||||
|
||||
local self = MenuParam.self
|
||||
local TaskGroup = MenuParam.TaskGroup
|
||||
|
||||
self:Abort()
|
||||
end
|
||||
|
||||
@ -713,11 +713,15 @@ end
|
||||
function TASK:RemoveStateMachine( TaskUnit )
|
||||
self:F( { TaskUnit, self.Fsm[TaskUnit] ~= nil } )
|
||||
|
||||
self.Fsm[TaskUnit]:Remove()
|
||||
self:E( self.Fsm )
|
||||
for TaskUnitT, Fsm in pairs( self.Fsm ) do
|
||||
self:E( TaskUnitT )
|
||||
end
|
||||
|
||||
self.Fsm[TaskUnit] = nil
|
||||
|
||||
collectgarbage()
|
||||
self:T( "Garbage Collected, Processes should be finalized now ...")
|
||||
self:E( "Garbage Collected, Processes should be finalized now ...")
|
||||
end
|
||||
|
||||
--- Checks if there is a FiniteStateMachine assigned to Task@{Unit} for @{Task}
|
||||
|
||||
@ -68,6 +68,7 @@ do -- TASK_A2G
|
||||
self:F()
|
||||
|
||||
self.TargetSetUnit = TargetSetUnit
|
||||
self.TaskType = TaskType
|
||||
|
||||
Mission:AddTask( self )
|
||||
|
||||
@ -85,7 +86,7 @@ do -- TASK_A2G
|
||||
Fsm:AddTransition( { "ArrivedAtRendezVous", "HoldingAtRendezVous" }, "Engage", "Engaging" )
|
||||
Fsm:AddTransition( { "ArrivedAtRendezVous", "HoldingAtRendezVous" }, "HoldAtRendezVous", "HoldingAtRendezVous" )
|
||||
|
||||
Fsm:AddProcess ( "Engaging", "Account", ACT_ACCOUNT_DEADS:New( self.TargetSetUnit, TaskType ), { Accounted = "Success" } )
|
||||
Fsm:AddProcess ( "Engaging", "Account", ACT_ACCOUNT_DEADS:New( self.TargetSetUnit, self.TaskType ), { Accounted = "Success" } )
|
||||
Fsm:AddTransition( "Engaging", "RouteToTarget", "Engaging" )
|
||||
Fsm:AddProcess( "Engaging", "RouteToTargetZone", ACT_ROUTE_ZONE:New(), {} )
|
||||
Fsm:AddProcess( "Engaging", "RouteToTargetPoint", ACT_ROUTE_POINT:New(), {} )
|
||||
|
||||
@ -233,7 +233,7 @@ do -- TASK_A2G_DISPATCHER
|
||||
local TargetSetUnit = self:EvaluateCAS( DetectedItem ) -- Returns a SetUnit if there are targets to be SEADed...
|
||||
if TargetSetUnit then
|
||||
local Task = TASK_CAS:New( Mission, self.SetGroup, string.format( "CAS.%03d", ItemID ), TargetSetUnit )
|
||||
Task:SetTargetZone( DetectedZone )
|
||||
--Task:SetTargetZone( DetectedZone )
|
||||
CASTask = Mission:AddTask( Task )
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
env.info( '*** MOOSE DYNAMIC INCLUDE START *** ' )
|
||||
env.info( 'Moose Generation Timestamp: 20170313_1139' )
|
||||
env.info( 'Moose Generation Timestamp: 20170315_0507' )
|
||||
|
||||
local base = _G
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
env.info( '*** MOOSE DYNAMIC INCLUDE START *** ' )
|
||||
env.info( 'Moose Generation Timestamp: 20170313_1139' )
|
||||
env.info( 'Moose Generation Timestamp: 20170315_0507' )
|
||||
|
||||
local base = _G
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user