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