mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Merge pull request #608 from FlightControl-Master/Performance
Fixed performance issue
This commit is contained in:
commit
4c5aad51b3
@ -234,9 +234,9 @@ function BASE:New()
|
|||||||
|
|
||||||
-- This is for "private" methods...
|
-- This is for "private" methods...
|
||||||
-- When a __ is passed to a method as "self", the __index will search for the method on the public method list too!
|
-- When a __ is passed to a method as "self", the __index will search for the method on the public method list too!
|
||||||
if rawget( self, "__" ) then
|
-- if rawget( self, "__" ) then
|
||||||
setmetatable( self, { __index = self.__ } )
|
--setmetatable( self, { __index = self.__ } )
|
||||||
end
|
-- end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -250,7 +250,6 @@ function BASE:Inherit( Child, Parent )
|
|||||||
local Child = routines.utils.deepCopy( Child )
|
local Child = routines.utils.deepCopy( Child )
|
||||||
|
|
||||||
if Child ~= nil then
|
if Child ~= nil then
|
||||||
Child.ClassParent = Parent
|
|
||||||
|
|
||||||
-- This is for "private" methods...
|
-- This is for "private" methods...
|
||||||
-- When a __ is passed to a method as "self", the __index will search for the method on the public method list of the same object too!
|
-- When a __ is passed to a method as "self", the __index will search for the method on the public method list of the same object too!
|
||||||
@ -261,10 +260,8 @@ function BASE:Inherit( Child, Parent )
|
|||||||
setmetatable( Child, { __index = Parent } )
|
setmetatable( Child, { __index = Parent } )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--Child:_SetDestructor()
|
--Child:_SetDestructor()
|
||||||
end
|
end
|
||||||
--self:T( 'Inherited from ' .. Parent.ClassName )
|
|
||||||
return Child
|
return Child
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -278,8 +275,12 @@ end
|
|||||||
-- @param #BASE Child is the Child class from which the Parent class needs to be retrieved.
|
-- @param #BASE Child is the Child class from which the Parent class needs to be retrieved.
|
||||||
-- @return #BASE
|
-- @return #BASE
|
||||||
function BASE:GetParent( Child )
|
function BASE:GetParent( Child )
|
||||||
local Parent = Child.ClassParent
|
local Parent
|
||||||
-- env.info('Inherited class of ' .. Child.ClassName .. ' is ' .. Parent.ClassName )
|
if rawget( Child, "__" ) then
|
||||||
|
Parent = getmetatable( Child.__ ).__Index
|
||||||
|
else
|
||||||
|
Parent = getmetatable( Child ).__Index
|
||||||
|
end
|
||||||
return Parent
|
return Parent
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -418,7 +418,7 @@ do -- FSM
|
|||||||
-- @param #table ReturnEvents A table indicating for which returned events of the SubFSM which Event must be triggered in the FSM.
|
-- @param #table ReturnEvents A table indicating for which returned events of the SubFSM which Event must be triggered in the FSM.
|
||||||
-- @return Core.Fsm#FSM_PROCESS The SubFSM.
|
-- @return Core.Fsm#FSM_PROCESS The SubFSM.
|
||||||
function FSM:AddProcess( From, Event, Process, ReturnEvents )
|
function FSM:AddProcess( From, Event, Process, ReturnEvents )
|
||||||
self:T( { From, Event, Process, ReturnEvents } )
|
self:T( { From, Event } )
|
||||||
|
|
||||||
local Sub = {}
|
local Sub = {}
|
||||||
Sub.From = From
|
Sub.From = From
|
||||||
@ -541,7 +541,7 @@ do -- FSM
|
|||||||
end
|
end
|
||||||
|
|
||||||
function FSM:_submap( subs, sub, name )
|
function FSM:_submap( subs, sub, name )
|
||||||
self:F( { sub = sub, name = name } )
|
--self:F( { sub = sub, name = name } )
|
||||||
subs[sub.From] = subs[sub.From] or {}
|
subs[sub.From] = subs[sub.From] or {}
|
||||||
subs[sub.From][sub.Event] = subs[sub.From][sub.Event] or {}
|
subs[sub.From][sub.Event] = subs[sub.From][sub.Event] or {}
|
||||||
|
|
||||||
@ -844,7 +844,7 @@ do -- FSM_CONTROLLABLE
|
|||||||
-- @param Wrapper.Controllable#CONTROLLABLE FSMControllable
|
-- @param Wrapper.Controllable#CONTROLLABLE FSMControllable
|
||||||
-- @return #FSM_CONTROLLABLE
|
-- @return #FSM_CONTROLLABLE
|
||||||
function FSM_CONTROLLABLE:SetControllable( FSMControllable )
|
function FSM_CONTROLLABLE:SetControllable( FSMControllable )
|
||||||
self:F( FSMControllable )
|
--self:F( FSMControllable:GetName() )
|
||||||
self.Controllable = FSMControllable
|
self.Controllable = FSMControllable
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -904,7 +904,7 @@ do -- FSM_PROCESS
|
|||||||
|
|
||||||
local self = BASE:Inherit( self, FSM_CONTROLLABLE:New() ) -- Core.Fsm#FSM_PROCESS
|
local self = BASE:Inherit( self, FSM_CONTROLLABLE:New() ) -- Core.Fsm#FSM_PROCESS
|
||||||
|
|
||||||
self:F( Controllable, Task )
|
--self:F( Controllable )
|
||||||
|
|
||||||
self:Assign( Controllable, Task )
|
self:Assign( Controllable, Task )
|
||||||
|
|
||||||
@ -960,7 +960,7 @@ do -- FSM_PROCESS
|
|||||||
|
|
||||||
-- Copy Processes
|
-- Copy Processes
|
||||||
for ProcessID, Process in pairs( self:GetProcesses() ) do
|
for ProcessID, Process in pairs( self:GetProcesses() ) do
|
||||||
self:E( { Process} )
|
--self:E( { Process:GetName() } )
|
||||||
local FsmProcess = NewFsm:AddProcess( Process.From, Process.Event, Process.fsm:Copy( Controllable, Task ), Process.ReturnEvents )
|
local FsmProcess = NewFsm:AddProcess( Process.From, Process.Event, Process.fsm:Copy( Controllable, Task ), Process.ReturnEvents )
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1062,7 +1062,7 @@ end
|
|||||||
-- @param Wrapper.Unit#UNIT ProcessUnit
|
-- @param Wrapper.Unit#UNIT ProcessUnit
|
||||||
-- @return #FSM_PROCESS self
|
-- @return #FSM_PROCESS self
|
||||||
function FSM_PROCESS:Assign( ProcessUnit, Task )
|
function FSM_PROCESS:Assign( ProcessUnit, Task )
|
||||||
self:T( { Task, ProcessUnit } )
|
--self:T( { Task:GetName(), ProcessUnit:GetName() } )
|
||||||
|
|
||||||
self:SetControllable( ProcessUnit )
|
self:SetControllable( ProcessUnit )
|
||||||
self:SetTask( Task )
|
self:SetTask( Task )
|
||||||
@ -1092,7 +1092,7 @@ end
|
|||||||
-- @param #string From
|
-- @param #string From
|
||||||
-- @param #string To
|
-- @param #string To
|
||||||
function FSM_PROCESS:onstatechange( ProcessUnit, Task, From, Event, To, Dummy )
|
function FSM_PROCESS:onstatechange( ProcessUnit, Task, From, Event, To, Dummy )
|
||||||
self:T( { ProcessUnit, From, Event, To, Dummy, self:IsTrace() } )
|
self:T( { ProcessUnit:GetName(), From, Event, To, Dummy, self:IsTrace() } )
|
||||||
|
|
||||||
if self:IsTrace() then
|
if self:IsTrace() then
|
||||||
--MESSAGE:New( "@ Process " .. self:GetClassNameAndID() .. " : " .. Event .. " changed to state " .. To, 2 ):ToAll()
|
--MESSAGE:New( "@ Process " .. self:GetClassNameAndID() .. " : " .. Event .. " changed to state " .. To, 2 ):ToAll()
|
||||||
|
|||||||
@ -574,7 +574,6 @@ function TASK:AssignToUnit( TaskUnit )
|
|||||||
|
|
||||||
-- Assign a new FsmUnit to TaskUnit.
|
-- Assign a new FsmUnit to TaskUnit.
|
||||||
local FsmUnit = self:SetStateMachine( TaskUnit, FsmTemplate:Copy( TaskUnit, self ) ) -- Core.Fsm#FSM_PROCESS
|
local FsmUnit = self:SetStateMachine( TaskUnit, FsmTemplate:Copy( TaskUnit, self ) ) -- Core.Fsm#FSM_PROCESS
|
||||||
self:E({"Address FsmUnit", tostring( FsmUnit ) } )
|
|
||||||
|
|
||||||
FsmUnit:SetStartState( "Planned" )
|
FsmUnit:SetStartState( "Planned" )
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user