mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
MANTIS - Added FSM Events for SeadSuppressionPlanned/Start/ENd
This commit is contained in:
parent
21a93652cd
commit
84eff098eb
@ -20,7 +20,7 @@
|
|||||||
-- @module Functional.Mantis
|
-- @module Functional.Mantis
|
||||||
-- @image Functional.Mantis.jpg
|
-- @image Functional.Mantis.jpg
|
||||||
--
|
--
|
||||||
-- Date: July 2021
|
-- Date: Nov 2021
|
||||||
|
|
||||||
-------------------------------------------------------------------------
|
-------------------------------------------------------------------------
|
||||||
--- **MANTIS** class, extends Core.Base#BASE
|
--- **MANTIS** class, extends Core.Base#BASE
|
||||||
@ -198,6 +198,7 @@ MANTIS = {
|
|||||||
DLink = false,
|
DLink = false,
|
||||||
DLTimeStamp = 0,
|
DLTimeStamp = 0,
|
||||||
Padding = 10,
|
Padding = 10,
|
||||||
|
SuppressedGroups = {},
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Advanced state enumerator
|
--- Advanced state enumerator
|
||||||
@ -284,6 +285,7 @@ do
|
|||||||
self.SamStateTracker = {} -- table to hold alert states, so we don't trigger state changes twice in adv mode
|
self.SamStateTracker = {} -- table to hold alert states, so we don't trigger state changes twice in adv mode
|
||||||
self.DLink = false
|
self.DLink = false
|
||||||
self.Padding = Padding or 10
|
self.Padding = Padding or 10
|
||||||
|
self.SuppressedGroups = {}
|
||||||
|
|
||||||
if EmOnOff then
|
if EmOnOff then
|
||||||
if EmOnOff == false then
|
if EmOnOff == false then
|
||||||
@ -331,7 +333,7 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
self.version="0.6.2"
|
self.version="0.7.1"
|
||||||
self:I(string.format("***** Starting MANTIS Version %s *****", self.version))
|
self:I(string.format("***** Starting MANTIS Version %s *****", self.version))
|
||||||
|
|
||||||
--- FSM Functions ---
|
--- FSM Functions ---
|
||||||
@ -348,6 +350,9 @@ do
|
|||||||
self:AddTransition("*", "RedState", "*") -- MANTIS A SAM switching to RED state.
|
self:AddTransition("*", "RedState", "*") -- MANTIS A SAM switching to RED state.
|
||||||
self:AddTransition("*", "AdvStateChange", "*") -- MANTIS advanced mode state change.
|
self:AddTransition("*", "AdvStateChange", "*") -- MANTIS advanced mode state change.
|
||||||
self:AddTransition("*", "ShoradActivated", "*") -- MANTIS woke up a connected SHORAD.
|
self:AddTransition("*", "ShoradActivated", "*") -- MANTIS woke up a connected SHORAD.
|
||||||
|
self:AddTransition("*", "SeadSuppressionStart", "*") -- SEAD has switched off one group.
|
||||||
|
self:AddTransition("*", "SeadSuppressionEnd", "*") -- SEAD has switched on one group.
|
||||||
|
self:AddTransition("*", "SeadSuppressionPlanned", "*") -- SEAD has planned a suppression.
|
||||||
self:AddTransition("*", "Stop", "Stopped") -- Stop FSM.
|
self:AddTransition("*", "Stop", "Stopped") -- Stop FSM.
|
||||||
|
|
||||||
------------------------
|
------------------------
|
||||||
@ -427,6 +432,35 @@ do
|
|||||||
-- @param #number Radius Radius around the named group to find SHORAD groups
|
-- @param #number Radius Radius around the named group to find SHORAD groups
|
||||||
-- @param #number Ontime Seconds the SHORAD will stay active
|
-- @param #number Ontime Seconds the SHORAD will stay active
|
||||||
|
|
||||||
|
--- On After "SeadSuppressionPlanned" event. Mantis has planned to switch off a site to defend SEAD attack.
|
||||||
|
-- @function [parent=#MANTIS] OnAfterSeadSuppressionPlanned
|
||||||
|
-- @param #MANTIS self
|
||||||
|
-- @param #string From The From State
|
||||||
|
-- @param #string Event The Event
|
||||||
|
-- @param #string To The To State
|
||||||
|
-- @param Wrapper.Group#GROUP Group The suppressed GROUP object
|
||||||
|
-- @param #string Name Name of the suppressed group
|
||||||
|
-- @param #number SuppressionStartTime Model start time of the suppression from `timer.getTime()`
|
||||||
|
-- @param #number SuppressionEndTime Model end time of the suppression from `timer.getTime()`
|
||||||
|
|
||||||
|
--- On After "SeadSuppressionStart" event. Mantis has switched off a site to defend a SEAD attack.
|
||||||
|
-- @function [parent=#MANTIS] OnAfterSeadSuppressionStart
|
||||||
|
-- @param #MANTIS self
|
||||||
|
-- @param #string From The From State
|
||||||
|
-- @param #string Event The Event
|
||||||
|
-- @param #string To The To State
|
||||||
|
-- @param Wrapper.Group#GROUP Group The suppressed GROUP object
|
||||||
|
-- @param #string Name Name of the suppressed groupe
|
||||||
|
|
||||||
|
--- On After "SeadSuppressionEnd" event. Mantis has switched on a site after a SEAD attack.
|
||||||
|
-- @function [parent=#MANTIS] OnAfterSeadSuppressionEnd
|
||||||
|
-- @param #MANTIS self
|
||||||
|
-- @param #string From The From State
|
||||||
|
-- @param #string Event The Event
|
||||||
|
-- @param #string To The To State
|
||||||
|
-- @param Wrapper.Group#GROUP Group The suppressed GROUP object
|
||||||
|
-- @param #string Name Name of the suppressed group
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -891,6 +925,7 @@ do
|
|||||||
local group = _group -- Wrapper.Group#GROUP
|
local group = _group -- Wrapper.Group#GROUP
|
||||||
-- TODO: add emissions on/off
|
-- TODO: add emissions on/off
|
||||||
if self.UseEmOnOff then
|
if self.UseEmOnOff then
|
||||||
|
group:OptionAlarmStateRed()
|
||||||
group:EnableEmission(false)
|
group:EnableEmission(false)
|
||||||
--group:SetAIOff()
|
--group:SetAIOff()
|
||||||
else
|
else
|
||||||
@ -909,6 +944,10 @@ do
|
|||||||
-- make SAMs evasive
|
-- make SAMs evasive
|
||||||
local mysead = SEAD:New( SEAD_Grps, self.Padding ) -- Functional.Sead#SEAD
|
local mysead = SEAD:New( SEAD_Grps, self.Padding ) -- Functional.Sead#SEAD
|
||||||
mysead:SetEngagementRange(engagerange)
|
mysead:SetEngagementRange(engagerange)
|
||||||
|
mysead:AddCallBack(self)
|
||||||
|
if self.UseEmOnOff then
|
||||||
|
mysead:SwitchEmissions(true)
|
||||||
|
end
|
||||||
self.mysead = mysead
|
self.mysead = mysead
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -995,22 +1034,24 @@ do
|
|||||||
local name = _data[1]
|
local name = _data[1]
|
||||||
local samgroup = GROUP:FindByName(name)
|
local samgroup = GROUP:FindByName(name)
|
||||||
local IsInZone, Distance = self:CheckObjectInZone(detset, samcoordinate)
|
local IsInZone, Distance = self:CheckObjectInZone(detset, samcoordinate)
|
||||||
if IsInZone then --check any target in zone
|
local suppressed = self.SuppressedGroups[name] or false
|
||||||
|
if IsInZone then --check any target in zone and not curr managed by SEAD
|
||||||
if samgroup:IsAlive() then
|
if samgroup:IsAlive() then
|
||||||
-- switch on SAM
|
-- switch on SAM
|
||||||
if self.UseEmOnOff then
|
if self.UseEmOnOff and not suppressed then
|
||||||
-- TODO: add emissions on/off
|
-- DONE: add emissions on/off
|
||||||
--samgroup:SetAIOn()
|
--samgroup:SetAIOn()
|
||||||
samgroup:EnableEmission(true)
|
samgroup:EnableEmission(true)
|
||||||
end
|
elseif not self.UseEmOnOff and not suppressed then
|
||||||
samgroup:OptionAlarmStateRed()
|
samgroup:OptionAlarmStateRed()
|
||||||
if self.SamStateTracker[name] ~= "RED" then
|
end
|
||||||
|
if self.SamStateTracker[name] ~= "RED" and not suppressed then
|
||||||
self:__RedState(1,samgroup)
|
self:__RedState(1,samgroup)
|
||||||
self.SamStateTracker[name] = "RED"
|
self.SamStateTracker[name] = "RED"
|
||||||
end
|
end
|
||||||
-- link in to SHORAD if available
|
-- link in to SHORAD if available
|
||||||
-- DONE: Test integration fully
|
-- DONE: Test integration fully
|
||||||
if self.ShoradLink and Distance < self.ShoradActDistance then -- don't give SHORAD position away too early
|
if self.ShoradLink and (Distance < self.ShoradActDistance or suppressed) then -- don't give SHORAD position away too early
|
||||||
local Shorad = self.Shorad
|
local Shorad = self.Shorad
|
||||||
local radius = self.checkradius
|
local radius = self.checkradius
|
||||||
local ontime = self.ShoradTime
|
local ontime = self.ShoradTime
|
||||||
@ -1018,7 +1059,7 @@ do
|
|||||||
self:__ShoradActivated(1,name, radius, ontime)
|
self:__ShoradActivated(1,name, radius, ontime)
|
||||||
end
|
end
|
||||||
-- debug output
|
-- debug output
|
||||||
if self.debug or self.verbose then
|
if self.debug or self.verbose and not suppressed then
|
||||||
local text = string.format("SAM %s switched to alarm state RED!", name)
|
local text = string.format("SAM %s switched to alarm state RED!", name)
|
||||||
local m=MESSAGE:New(text,10,"MANTIS"):ToAllIf(self.debug)
|
local m=MESSAGE:New(text,10,"MANTIS"):ToAllIf(self.debug)
|
||||||
if self.verbose then self:I(self.lid..text) end
|
if self.verbose then self:I(self.lid..text) end
|
||||||
@ -1027,15 +1068,16 @@ do
|
|||||||
else
|
else
|
||||||
if samgroup:IsAlive() then
|
if samgroup:IsAlive() then
|
||||||
-- switch off SAM
|
-- switch off SAM
|
||||||
if self.UseEmOnOff then
|
if self.UseEmOnOff and not suppressed then
|
||||||
samgroup:EnableEmission(false)
|
samgroup:EnableEmission(false)
|
||||||
end
|
elseif not self.UseEmOnOff and not suppressed then
|
||||||
samgroup:OptionAlarmStateGreen()
|
samgroup:OptionAlarmStateGreen()
|
||||||
if self.SamStateTracker[name] ~= "GREEN" then
|
end
|
||||||
|
if self.SamStateTracker[name] ~= "GREEN" and not suppressed then
|
||||||
self:__GreenState(1,samgroup)
|
self:__GreenState(1,samgroup)
|
||||||
self.SamStateTracker[name] = "GREEN"
|
self.SamStateTracker[name] = "GREEN"
|
||||||
end
|
end
|
||||||
if self.debug or self.verbose then
|
if self.debug or self.verbose and not suppressed then
|
||||||
local text = string.format("SAM %s switched to alarm state GREEN!", name)
|
local text = string.format("SAM %s switched to alarm state GREEN!", name)
|
||||||
local m=MESSAGE:New(text,10,"MANTIS"):ToAllIf(self.debug)
|
local m=MESSAGE:New(text,10,"MANTIS"):ToAllIf(self.debug)
|
||||||
if self.verbose then self:I(self.lid..text) end
|
if self.verbose then self:I(self.lid..text) end
|
||||||
@ -1264,6 +1306,47 @@ do
|
|||||||
self:T({From, Event, To, Name, Radius, Ontime})
|
self:T({From, Event, To, Name, Radius, Ontime})
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- [Internal] Function triggered by Event SeadSuppressionStart
|
||||||
|
-- @param #MANTIS self
|
||||||
|
-- @param #string From The From State
|
||||||
|
-- @param #string Event The Event
|
||||||
|
-- @param #string To The To State
|
||||||
|
-- @param Wrapper.Group#GROUP Group The suppressed GROUP object
|
||||||
|
-- @param #string Name Name of the suppressed group
|
||||||
|
function MANTIS:onafterSeadSuppressionStart(From, Event, To, Group, Name)
|
||||||
|
self:T({From, Event, To, Name})
|
||||||
|
self.SuppressedGroups[Name] = true
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- [Internal] Function triggered by Event SeadSuppressionEnd
|
||||||
|
-- @param #MANTIS self
|
||||||
|
-- @param #string From The From State
|
||||||
|
-- @param #string Event The Event
|
||||||
|
-- @param #string To The To State
|
||||||
|
-- @param Wrapper.Group#GROUP Group The suppressed GROUP object
|
||||||
|
-- @param #string Name Name of the suppressed group
|
||||||
|
function MANTIS:onafterSeadSuppressionEnd(From, Event, To, Group, Name)
|
||||||
|
self:T({From, Event, To, Name})
|
||||||
|
self.SuppressedGroups[Name] = false
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- [Internal] Function triggered by Event SeadSuppressionPlanned
|
||||||
|
-- @param #MANTIS self
|
||||||
|
-- @param #string From The From State
|
||||||
|
-- @param #string Event The Event
|
||||||
|
-- @param #string To The To State
|
||||||
|
-- @param Wrapper.Group#GROUP Group The suppressed GROUP object
|
||||||
|
-- @param #string Name Name of the suppressed group
|
||||||
|
-- @param #number SuppressionStartTime Model start time of the suppression from `timer.getTime()`
|
||||||
|
-- @param #number SuppressionEndTime Model end time of the suppression from `timer.getTime()`
|
||||||
|
function MANTIS:onafterSeadSuppressionPlanned(From, Event, To, Group, Name, SuppressionStartTime, SuppressionEndTime)
|
||||||
|
self:T({From, Event, To, Name})
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
-- MANTIS end
|
-- MANTIS end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user