Update Intelligence.lua

- added reject zones
This commit is contained in:
Frank 2020-12-29 11:22:47 +01:00
parent 9abd71f681
commit f56457bc28

View File

@ -14,7 +14,6 @@
--- INTEL class. --- INTEL class.
-- @type INTEL -- @type INTEL
-- @field #string ClassName Name of the class. -- @field #string ClassName Name of the class.
-- @field #boolean Debug Debug mode. Messages to all about status.
-- @field #number verbose Verbosity level. -- @field #number verbose Verbosity level.
-- @field #string lid Class id string for output to DCS log file. -- @field #string lid Class id string for output to DCS log file.
-- @field #number coalition Coalition side number, e.g. `coalition.side.RED`. -- @field #number coalition Coalition side number, e.g. `coalition.side.RED`.
@ -47,7 +46,6 @@
-- @field #INTEL -- @field #INTEL
INTEL = { INTEL = {
ClassName = "INTEL", ClassName = "INTEL",
Debug = nil,
verbose = 2, verbose = 2,
lid = nil, lid = nil,
alias = nil, alias = nil,
@ -91,19 +89,19 @@ INTEL = {
--- INTEL class version. --- INTEL class version.
-- @field #string version -- @field #string version
INTEL.version="0.0.3" INTEL.version="0.1.0"
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- ToDo list -- ToDo list
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- DONE: Accept zones.
-- TODO: Reject zones.
-- TODO: Filter detection methods. -- TODO: Filter detection methods.
-- TODO: process detected set asynchroniously for better performance.
-- DONE: Accept zones.
-- DONE: Reject zones.
-- NOGO: SetAttributeZone --> return groups of generalized attributes in a zone. -- NOGO: SetAttributeZone --> return groups of generalized attributes in a zone.
-- DONE: Loose units only if they remain undetected for a given time interval. We want to avoid fast oscillation between detected/lost states. Maybe 1-5 min would be a good time interval?! -- DONE: Loose units only if they remain undetected for a given time interval. We want to avoid fast oscillation between detected/lost states. Maybe 1-5 min would be a good time interval?!
-- DONE: Combine units to groups for all, new and lost. -- DONE: Combine units to groups for all, new and lost.
-- TODO: process detected set asynchroniously for better performance.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- Constructor -- Constructor
@ -181,6 +179,7 @@ function INTEL:New(DetectionSet, Coalition, Alias)
-- Defaults -- Defaults
self:SetForgetTime() self:SetForgetTime()
self:SetAcceptZones() self:SetAcceptZones()
self:SetRejectZones()
------------------------ ------------------------
--- Pseudo Functions --- --- Pseudo Functions ---
@ -212,15 +211,6 @@ function INTEL:New(DetectionSet, Coalition, Alias)
-- @param #INTEL self -- @param #INTEL self
-- @param #number delay Delay in seconds. -- @param #number delay Delay in seconds.
-- Debug trace.
if false then
self.Debug=true
BASE:TraceOnOff(true)
BASE:TraceClass(self.ClassName)
BASE:TraceLevel(1)
end
return self return self
end end
@ -230,14 +220,14 @@ end
--- Set accept zones. Only contacts detected in this/these zone(s) are considered. --- Set accept zones. Only contacts detected in this/these zone(s) are considered.
-- @param #INTEL self -- @param #INTEL self
-- @param Core.Set#SET_ZONE AcceptZoneSet Set of accept zones -- @param Core.Set#SET_ZONE AcceptZoneSet Set of accept zones.
-- @return #INTEL self -- @return #INTEL self
function INTEL:SetAcceptZones(AcceptZoneSet) function INTEL:SetAcceptZones(AcceptZoneSet)
self.acceptzoneset=AcceptZoneSet or SET_ZONE:New() self.acceptzoneset=AcceptZoneSet or SET_ZONE:New()
return self return self
end end
--- Set accept zones. Only contacts detected in this zone are considered. --- Add an accept zone. Only contacts detected in this zone are considered.
-- @param #INTEL self -- @param #INTEL self
-- @param Core.Zone#ZONE AcceptZone Add a zone to the accept zone set. -- @param Core.Zone#ZONE AcceptZone Add a zone to the accept zone set.
-- @return #INTEL self -- @return #INTEL self
@ -246,6 +236,44 @@ function INTEL:AddAcceptZone(AcceptZone)
return self return self
end end
--- Remove an accept zone from the accept zone set.
-- @param #INTEL self
-- @param Core.Zone#ZONE AcceptZone Remove a zone from the accept zone set.
-- @return #INTEL self
function INTEL:RemoveAcceptZone(AcceptZone)
self.acceptzoneset:Remove(AcceptZone:GetName(), true)
return self
end
--- Set reject zones. Contacts detected in this/these zone(s) are rejected and not reported by the detection.
-- Note that reject zones overrule accept zones, i.e. if a unit is inside and accept zone and inside a reject zone, it is rejected.
-- @param #INTEL self
-- @param Core.Set#SET_ZONE RejectZoneSet Set of reject zone(s).
-- @return #INTEL self
function INTEL:SetRejectZones(RejectZoneSet)
self.rejectzoneset=RejectZoneSet or SET_ZONE:New()
return self
end
--- Add a reject zone. Contacts detected in this zone are rejected and not reported by the detection.
-- Note that reject zones overrule accept zones, i.e. if a unit is inside and accept zone and inside a reject zone, it is rejected.
-- @param #INTEL self
-- @param Core.Zone#ZONE RejectZone Add a zone to the reject zone set.
-- @return #INTEL self
function INTEL:AddRejectZone(RejectZone)
self.rejectzoneset:AddZone(RejectZone)
return self
end
--- Remove a reject zone from the reject zone set.
-- @param #INTEL self
-- @param Core.Zone#ZONE RejectZone Remove a zone from the reject zone set.
-- @return #INTEL self
function INTEL:RemoveRejectZone(RejectZone)
self.rejectzoneset:Remove(RejectZone:GetName(), true)
return self
end
--- Set forget contacts time interval. --- Set forget contacts time interval.
-- Previously known contacts that are not detected any more, are "lost" after this time. -- Previously known contacts that are not detected any more, are "lost" after this time.
-- This avoids fast oscillations between a contact being detected and undetected. -- This avoids fast oscillations between a contact being detected and undetected.
@ -411,7 +439,6 @@ function INTEL:UpdateIntel()
end end
end end
-- TODO: Filter units from reject zones.
-- TODO: Filter detection methods? -- TODO: Filter detection methods?
local remove={} local remove={}
for unitname,_unit in pairs(DetectedUnits) do for unitname,_unit in pairs(DetectedUnits) do
@ -434,6 +461,23 @@ function INTEL:UpdateIntel()
end end
end end
-- Check if unit is in any of the reject zones.
if self.rejectzoneset:Count()>0 then
local inzone=false
for _,_zone in pairs(self.rejectzoneset.Set) do
local zone=_zone --Core.Zone#ZONE
if unit:IsInZone(zone) then
inzone=true
break
end
end
-- Unit is inside a reject zone ==> remove!
if inzone then
table.insert(remove, unitname)
end
end
-- Filter unit categories. -- Filter unit categories.
if #self.filterCategory>0 then if #self.filterCategory>0 then
local unitcategory=unit:GetUnitCategory() local unitcategory=unit:GetUnitCategory()