# DETECTION

* Option to make Radar Blue decision visible in logs (self.debug) and/or screen (self.verbose)
This commit is contained in:
Applevangelist 2023-12-10 11:58:19 +01:00
parent d2d6fac7df
commit 87f1a5ed0d

View File

@ -46,6 +46,8 @@ do -- DETECTION_BASE
-- @field #DETECTION_BASE.DetectedObjects DetectedObjects The list of detected objects. -- @field #DETECTION_BASE.DetectedObjects DetectedObjects The list of detected objects.
-- @field #table DetectedObjectsIdentified Map of the DetectedObjects identified. -- @field #table DetectedObjectsIdentified Map of the DetectedObjects identified.
-- @field #number DetectionRun -- @field #number DetectionRun
-- @field #boolean debug
-- @field #boolean verbose
-- @extends Core.Fsm#FSM -- @extends Core.Fsm#FSM
--- Defines the core functions to administer detected objects. --- Defines the core functions to administer detected objects.
@ -273,6 +275,8 @@ do -- DETECTION_BASE
DetectedObjectsIdentified = {}, DetectedObjectsIdentified = {},
DetectedItems = {}, DetectedItems = {},
DetectedItemsByIndex = {}, DetectedItemsByIndex = {},
debug = false,
verbose = false,
} }
--- ---
@ -721,10 +725,10 @@ do -- DETECTION_BASE
end end
end end
-- Calculate radar blue probability -- Calculate radar blur probability
if self.RadarBlur then if self.RadarBlur then
BASE:I("RadarBlur") MESSAGE:New("Radar Blur",10):ToLogIf(self.debug):ToAllIf(self.verbose)
local minheight = self.RadarBlurMinHeight or 250 -- meters local minheight = self.RadarBlurMinHeight or 250 -- meters
local thresheight = self.RadarBlurThresHeight or 90 -- 10% chance to find a low flying group local thresheight = self.RadarBlurThresHeight or 90 -- 10% chance to find a low flying group
local thresblur = self.RadarBlurThresBlur or 85 -- 25% chance to escape the radar overall local thresblur = self.RadarBlurThresBlur or 85 -- 25% chance to escape the radar overall
@ -733,11 +737,11 @@ do -- DETECTION_BASE
local unit = UNIT:FindByName(DetectedObjectName) local unit = UNIT:FindByName(DetectedObjectName)
if unit and unit:IsAlive() then if unit and unit:IsAlive() then
local AGL = unit:GetAltitude(true) local AGL = unit:GetAltitude(true)
BASE:I("Unit "..DetectedObjectName.." is at "..AGL.."m.") MESSAGE:New("Unit "..DetectedObjectName.." is at "..math.floor(AGL).."m.",10):ToLogIf(self.debug):ToAllIf(self.verbose)
BASE:I(string.format("fheight = %d/%d | fblur = %d/%d",fheight,thresheight,fblur,thresblur)) MESSAGE:New(string.format("fheight = %d/%d | fblur = %d/%d",fheight,thresheight,fblur,thresblur),10):ToLogIf(self.debug):ToAllIf(self.verbose)
if fblur > thresblur then DetectionAccepted = false end if fblur > thresblur then DetectionAccepted = false end
if AGL <= minheight and fheight < thresheight then DetectionAccepted = false end if AGL <= minheight and fheight < thresheight then DetectionAccepted = false end
BASE:I("Detection Accepted = "..tostring(DetectionAccepted)) MESSAGE:New("Detection Accepted = "..tostring(DetectionAccepted),10):ToLogIf(self.debug):ToAllIf(self.verbose)
end end
end end