mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Implemented DETECTION and FAC first classes
This commit is contained in:
@@ -5,37 +5,60 @@
|
||||
-- 1) @{Detection#DETECTION_BASE} class, extends @{Base#BASE}
|
||||
-- ==========================================================
|
||||
-- The @{Detection#DETECTION_BASE} class defines the core functions to administer detected objects.
|
||||
-- Detected objects are grouped in SETS of UNITS.
|
||||
--
|
||||
-- 1.1) DETECTION_BASE constructor:
|
||||
-- --------------------------------
|
||||
-- * @{Detection#DETECTION.New}(): Create a new DETECTION object.
|
||||
-- 1.1) DETECTION_BASE constructor
|
||||
-- -------------------------------
|
||||
-- Construct a new DETECTION_BASE instance using the @{Detection#DETECTION.New}() method.
|
||||
--
|
||||
-- 1.2) DETECTION_BASE initialization:
|
||||
-- -----------------------------------
|
||||
-- By default, detection will return detected objects with all the methods available.
|
||||
-- 1.2) DETECTION_BASE initialization
|
||||
-- ----------------------------------
|
||||
-- By default, detection will return detected objects with all the detection sensors available.
|
||||
-- However, you can ask how the objects were found with specific detection methods.
|
||||
-- If you use one of the below methods, the detection will work with the detection method specified.
|
||||
-- You can specify to apply multiple detection methods.
|
||||
--
|
||||
-- Use the following functions to report the objects it detected using the methods Visual, Optical, Radar, IRST, RWR, DLINK:
|
||||
--
|
||||
-- * @{Detection#DETECTION.InitDetectVisual}(): Detected using Visual.
|
||||
-- * @{Detection#DETECTION.InitDetectOptical}(): Detected using Optical.
|
||||
-- * @{Detection#DETECTION.InitDetectRadar}(): Detected using Radar.
|
||||
-- * @{Detection#DETECTION.InitDetectIRST}(): Detected using IRST.
|
||||
-- * @{Detection#DETECTION.InitDetectRWR}(): Detected using RWR.
|
||||
-- * @{Detection#DETECTION.InitDetectDLINK}(): Detected using DLINK.
|
||||
-- * @{Detection#DETECTION_BASE.InitDetectVisual}(): Detected using Visual.
|
||||
-- * @{Detection#DETECTION_BASE.InitDetectOptical}(): Detected using Optical.
|
||||
-- * @{Detection#DETECTION_BASE.InitDetectRadar}(): Detected using Radar.
|
||||
-- * @{Detection#DETECTION_BASE.InitDetectIRST}(): Detected using IRST.
|
||||
-- * @{Detection#DETECTION_BASE.InitDetectRWR}(): Detected using RWR.
|
||||
-- * @{Detection#DETECTION_BASE.InitDetectDLINK}(): Detected using DLINK.
|
||||
--
|
||||
-- 1.3) Obtain objects detected by DETECTION_BASE:
|
||||
-- -----------------------------------------------
|
||||
-- 1.3) Obtain objects detected by DETECTION_BASE
|
||||
-- ----------------------------------------------
|
||||
-- DETECTION_BASE builds @{Set}s of objects detected. These @{Set#SET_BASE}s can be retrieved using the method @{Detection#DETECTION_BASE.GetDetectedSets}().
|
||||
-- The method will return a list (table) of @{Set#SET_BASE} objects.
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- 2) @{Detection#DETECTION_UNITGROUPS} class, extends @{Detection#DETECTION_BASE}
|
||||
-- ===============================================================================
|
||||
-- The @{Detection#DETECTION_UNITGROUPS} class will detect units within the battle zone for a FAC group,
|
||||
-- and will build a list (table) of @{Set#SET_UNIT}s containing the @{Unit#UNIT}s detected.
|
||||
-- The class is group the detected units within zones given a DetectedZoneRange parameter.
|
||||
-- A set with multiple detected zones will be created as there are groups of units detected.
|
||||
--
|
||||
-- 2.1) Retrieve the Detected Unit sets and Detected Zones
|
||||
-- -------------------------------------------------------
|
||||
-- The DetectedUnitSets methods are implemented in @{Detection#DECTECTION_BASE} and the DetectedZones methods is implemented in @{Detection#DETECTION_UNITGROUPS}.
|
||||
--
|
||||
-- Retrieve the DetectedUnitSets with the method @{Detection#DETECTION_BASE.GetDetectedSets}(). A table will be return of @{Set#SET_UNIT}s.
|
||||
-- To understand the amount of sets created, use the method @{Detection#DETECTION_BASE.GetDetectedSetCount}().
|
||||
-- If you want to obtain a specific set from the DetectedSets, use the method @{Detection#DETECTION_BASE.GetDetectedSet}() with a given index.
|
||||
--
|
||||
-- Retrieve the formed @{Zone@ZONE_UNIT}s as a result of the grouping the detected units within the DetectionZoneRange, use the method @{Detection#DETECTION_BASE.GetDetectionZones}().
|
||||
-- To understand the amount of zones created, use the method @{Detection#DETECTION_BASE.GetDetectionZoneCount}().
|
||||
-- If you want to obtain a specific zone from the DetectedZones, use the method @{Detection#DETECTION_BASE.GetDetectionZone}() with a given index.
|
||||
--
|
||||
-- 1.4) Flare or Smoke detected units
|
||||
-- ----------------------------------
|
||||
-- Use the methods @{Detection#DETECTION_UNITGROUPS.FlareDetectedUnits}() or @{Detection#DETECTION_UNITGROUPS.SmokeDetectedUnits}() to flare or smoke the detected units when a new detection has taken place.
|
||||
--
|
||||
-- 1.5) Flare or Smoke detected zones
|
||||
-- ----------------------------------
|
||||
-- Use the methods @{Detection#DETECTION_UNITGROUPS.FlareDetectedZones}() or @{Detection#DETECTION_UNITGROUPS.SmokeDetectedZones}() to flare or smoke the detected zones when a new detection has taken place.
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
@@ -49,9 +72,7 @@
|
||||
-- @type DETECTION_BASE
|
||||
-- @field Group#GROUP FACGroup The GROUP in the Forward Air Controller role.
|
||||
-- @field DCSTypes#Distance DetectionRange The range till which targets are accepted to be detected.
|
||||
-- @field DCSTypes#Distance DetectionZoneRange The range till which targets are grouped upon the first detected target.
|
||||
-- @field #DETECTION_BASE.DetectedSets DetectedSets A list of @{Set#SET_BASE}s containing the objects in each set that were detected within a DetectedZoneRange.
|
||||
-- @field #DETECTION_BASE.DetectedZones DetectedZones A list of @{Zone#ZONE_BASE}s containing the zones of the reference detected objects.
|
||||
-- @field #DETECTION_BASE.DetectedSets DetectedSets A list of @{Set#SET_BASE}s containing the objects in each set that were detected. The base class will not build the detected sets, but will leave that to the derived classes.
|
||||
-- @extends Base#BASE
|
||||
DETECTION_BASE = {
|
||||
ClassName = "DETECTION_BASE",
|
||||
@@ -59,7 +80,6 @@ DETECTION_BASE = {
|
||||
DetectedObjects = {},
|
||||
FACGroup = nil,
|
||||
DetectionRange = nil,
|
||||
DetectionZoneRange = nil,
|
||||
}
|
||||
|
||||
--- @type DETECTION_BASE.DetectedSets
|
||||
@@ -74,16 +94,14 @@ DETECTION_BASE = {
|
||||
-- @param #DETECTION_BASE self
|
||||
-- @param Group#GROUP FACGroup The GROUP in the Forward Air Controller role.
|
||||
-- @param DCSTypes#Distance DetectionRange The range till which targets are accepted to be detected.
|
||||
-- @param DCSTypes#Distance DetectionZoneRange The range till which targets are grouped upon the first detected target.
|
||||
-- @return #DETECTION_BASE self
|
||||
function DETECTION_BASE:New( FACGroup, DetectionRange, DetectionZoneRange )
|
||||
function DETECTION_BASE:New( FACGroup, DetectionRange )
|
||||
|
||||
-- Inherits from BASE
|
||||
local self = BASE:Inherit( self, BASE:New() )
|
||||
|
||||
self.FACGroup = FACGroup
|
||||
self.DetectionRange = DetectionRange
|
||||
self.DetectionZoneRange = DetectionZoneRange
|
||||
|
||||
self:InitDetectVisual( false )
|
||||
self:InitDetectOptical( false )
|
||||
@@ -166,7 +184,7 @@ end
|
||||
--- Get the detected @{Set#SET_BASE}s.
|
||||
-- @param #DETECTION_BASE self
|
||||
-- @return #DETECTION_BASE.DetectedSets DetectedSets
|
||||
function DETECTION_BASE:GetDetectionSets()
|
||||
function DETECTION_BASE:GetDetectedSets()
|
||||
|
||||
local DetectionSets = self.DetectedSets
|
||||
return DetectionSets
|
||||
@@ -175,7 +193,7 @@ end
|
||||
--- Get the amount of SETs with detected objects.
|
||||
-- @param #DETECTION_BASE self
|
||||
-- @return #number Count
|
||||
function DETECTION_BASE:GetDetectionSetCount()
|
||||
function DETECTION_BASE:GetDetectedSetCount()
|
||||
|
||||
local DetectionSetCount = #self.DetectedSets
|
||||
return DetectionSetCount
|
||||
@@ -185,7 +203,7 @@ end
|
||||
-- @param #DETECTION_BASE self
|
||||
-- @param #number Index
|
||||
-- @return Set#SET_BASE
|
||||
function DETECTION_BASE:GetDetectionSet( Index )
|
||||
function DETECTION_BASE:GetDetectedSet( Index )
|
||||
|
||||
local DetectionSet = self.DetectedSets[Index]
|
||||
if DetectionSet then
|
||||
@@ -195,6 +213,7 @@ function DETECTION_BASE:GetDetectionSet( Index )
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
--- Make a DetectionSet table. This function will be overridden in the derived clsses.
|
||||
-- @param #DETECTION_BASE self
|
||||
-- @return #DETECTION_BASE self
|
||||
@@ -308,7 +327,8 @@ end
|
||||
|
||||
--- DETECTION_UNITGROUPS class
|
||||
-- @type DETECTION_UNITGROUPS
|
||||
-- @field #DETECTION_UNITGROUPS.DetectedSets DetectedSets A list of @{Set#SET_UNIT}s containing the units in each set that were detected within a DetectedZoneRange.
|
||||
-- @param DCSTypes#Distance DetectionZoneRange The range till which targets are grouped upon the first detected target.
|
||||
-- @field #DETECTION_UNITGROUPS.DetectedSets DetectedSets A list of @{Set#SET_UNIT}s containing the units in each set that were detected within a DetectionZoneRange.
|
||||
-- @field #DETECTION_UNITGROUPS.DetectedZones DetectedZones A list of @{Zone#ZONE_UNIT}s containing the zones of the reference detected units.
|
||||
-- @extends Detection#DETECTION_BASE
|
||||
DETECTION_UNITGROUPS = {
|
||||
@@ -327,13 +347,82 @@ DETECTION_UNITGROUPS = {
|
||||
function DETECTION_UNITGROUPS:New( FACGroup, DetectionRange, DetectionZoneRange )
|
||||
|
||||
-- Inherits from DETECTION_BASE
|
||||
local self = BASE:Inherit( self, DETECTION_BASE:New( FACGroup, DetectionRange, DetectionZoneRange ) )
|
||||
local self = BASE:Inherit( self, DETECTION_BASE:New( FACGroup, DetectionRange ) )
|
||||
self.DetectionZoneRange = DetectionZoneRange
|
||||
|
||||
self:Schedule( 10, 30 )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Get the detected @{Zone#ZONE_UNIT}s.
|
||||
-- @param #DETECTION_UNITGROUPS self
|
||||
-- @return #DETECTION_UNITGROUPS.DetectedZones DetectedZones
|
||||
function DETECTION_UNITGROUPS:GetDetectedZones()
|
||||
|
||||
local DetectedZones = self.DetectedZones
|
||||
return DetectedZones
|
||||
end
|
||||
|
||||
--- Get the amount of @{Zone#ZONE_UNIT}s with detected units.
|
||||
-- @param #DETECTION_UNITGROUPS self
|
||||
-- @return #number Count
|
||||
function DETECTION_UNITGROUPS:GetDetectedZoneCount()
|
||||
|
||||
local DetectedZoneCount = #self.DetectedZones
|
||||
return DetectedZoneCount
|
||||
end
|
||||
|
||||
--- Get a SET of detected objects using a given numeric index.
|
||||
-- @param #DETECTION_UNITGROUPS self
|
||||
-- @param #number Index
|
||||
-- @return Zone#ZONE_UNIT
|
||||
function DETECTION_UNITGROUPS:GetDetectedZone( Index )
|
||||
|
||||
local DetectedZone = self.DetectedZones[Index]
|
||||
if DetectedZone then
|
||||
return DetectedZone
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
--- Smoke the detected units
|
||||
-- @param #DETECTION_UNITGROUPS self
|
||||
-- @return #DETECTION_UNITGROUPS self
|
||||
function DETECTION_UNITGROUPS:SmokeDetectedUnits()
|
||||
self:F2()
|
||||
|
||||
self._SmokeDetectedUnits = true
|
||||
end
|
||||
|
||||
--- Flare the detected units
|
||||
-- @param #DETECTION_UNITGROUPS self
|
||||
-- @return #DETECTION_UNITGROUPS self
|
||||
function DETECTION_UNITGROUPS:SmokeDetectedUnits()
|
||||
self:F2()
|
||||
|
||||
self._FlareDetectedUnits = true
|
||||
end
|
||||
|
||||
--- Smoke the detected zones
|
||||
-- @param #DETECTION_UNITGROUPS self
|
||||
-- @return #DETECTION_UNITGROUPS self
|
||||
function DETECTION_UNITGROUPS:SmokeDetectedZones()
|
||||
self:F2()
|
||||
|
||||
self._SmokeDetectedZones = true
|
||||
end
|
||||
|
||||
--- Flare the detected zones
|
||||
-- @param #DETECTION_UNITGROUPS self
|
||||
-- @return #DETECTION_UNITGROUPS self
|
||||
function DETECTION_UNITGROUPS:FlareDetectedZones()
|
||||
self:F2()
|
||||
|
||||
self._FlareDetectedZones = true
|
||||
end
|
||||
|
||||
|
||||
--- Make a DetectionSet table. This function will be overridden in the derived clsses.
|
||||
-- @param #DETECTION_UNITGROUPS self
|
||||
@@ -385,10 +474,20 @@ function DETECTION_UNITGROUPS:CreateDetectionSets()
|
||||
--- @param Unit#UNIT DetectedUnit
|
||||
function( DetectedUnit )
|
||||
self:T( DetectedUnit:GetName() )
|
||||
DetectedUnit:FlareRed()
|
||||
if self._FlareDetectedUnits then
|
||||
DetectedUnit:FlareRed()
|
||||
end
|
||||
if self._SmokeDetectedUnits then
|
||||
DetectedUnit:SmokeRed()
|
||||
end
|
||||
end
|
||||
)
|
||||
DetectedZone:FlareZone( POINT_VEC3.SmokeColor.White, 30, math.random( 0,90 ) )
|
||||
if self._FlareDetectedZones then
|
||||
DetectedZone:FlareZone( POINT_VEC3.SmokeColor.White, 30, math.random( 0,90 ) )
|
||||
end
|
||||
if self._SmokeDetectedZones then
|
||||
DetectedZone:SmokeZone( POINT_VEC3.SmokeColor.White, 30 )
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -4,12 +4,8 @@
|
||||
--
|
||||
-- 1) @{Fac#FAC_BASE} class, extends @{Base#BASE}
|
||||
-- ==============================================
|
||||
-- The @{Fac#FAC_BASE} class defines the core functions to report detected objects to:
|
||||
--
|
||||
-- * CLIENTS
|
||||
-- * COALITIONS
|
||||
--
|
||||
-- Detected objects are grouped in SETS of UNITS.
|
||||
-- The @{Fac#FAC_BASE} class defines the core functions to report detected objects to clients.
|
||||
-- Reportings can be done in several manners, and it is up to the derived classes if FAC_BASE to model the reporting behaviour.
|
||||
--
|
||||
-- 1.1) FAC_BASE constructor:
|
||||
-- ----------------------------
|
||||
@@ -18,10 +14,16 @@
|
||||
-- 1.2) FAC_BASE reporting:
|
||||
-- ------------------------
|
||||
-- Derived FAC_BASE classes will reports detected units using the method @{Fac#FAC_BASE.ReportDetected}(). This method implements polymorphic behaviour.
|
||||
--
|
||||
-- The time interval in seconds of the reporting can be changed using the methods @{Fac#FAC_BASE.SetReportInterval}().
|
||||
-- To control how long a reporting message is displayed, use @{Fac#FAC_BASE.SetReportDisplayTime}().
|
||||
-- Derived classes need to implement the method @{Fac#FAC_BASE.GetReportDisplayTime}() to use the correct display time for displayed messages during a report.
|
||||
--
|
||||
-- Reporting can be started and stopped using the methods @{Fac#FAC_BASE.StartReporting}() and @{Fac#FAC_BASE.StopReporting}() respectively.
|
||||
-- If an ad-hoc report is requested, use the method @{Fac#FAC_BASE#ReportNow}().
|
||||
--
|
||||
-- The default reporting interval is every 60 seconds. The reporting messages are displayed 15 seconds.
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- 2) @{Fac#FAC_REPORTING} class, extends @{Fac#FAC_BASE}
|
||||
@@ -30,7 +32,7 @@
|
||||
--
|
||||
-- 2.1) FAC_REPORTING constructor:
|
||||
-- -------------------------------
|
||||
-- * @{Fac#FAC_REPORTING.New}(): Create a new FAC_REPORTING instance.
|
||||
-- The @{Fac#FAC_REPORTING.New}() method creates a new FAC_REPORTING instance.
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
@@ -59,16 +61,47 @@ FAC_BASE = {
|
||||
function FAC_BASE:New( ClientSet, Detection )
|
||||
|
||||
-- Inherits from BASE
|
||||
local self = BASE:Inherit( self, BASE:New() )
|
||||
local self = BASE:Inherit( self, BASE:New() ) -- Fac#FAC_BASE
|
||||
|
||||
self.ClientSet = ClientSet
|
||||
self.Detection = Detection
|
||||
|
||||
self.FacScheduler = SCHEDULER:New(self, self._FacScheduler, { self, "Fac" }, 5, 15 )
|
||||
|
||||
self:SetReportInterval( 60 )
|
||||
self:SetReportDisplayTime( 15 )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set the reporting time interval.
|
||||
-- @param #FAC_BASE self
|
||||
-- @param #number ReportInterval The interval in seconds when a report needs to be done.
|
||||
-- @return #FAC_BASE self
|
||||
function FAC_BASE:SetReportInterval( ReportInterval )
|
||||
self:F2()
|
||||
|
||||
self._ReportInterval = ReportInterval
|
||||
end
|
||||
|
||||
|
||||
--- Set the reporting message display time.
|
||||
-- @param #FAC_BASE self
|
||||
-- @param #number ReportDisplayTime The display time in seconds when a report needs to be done.
|
||||
-- @return #FAC_BASE self
|
||||
function FAC_BASE:SetReportDisplayTime( ReportDisplayTime )
|
||||
self:F2()
|
||||
|
||||
self._ReportDisplayTime = ReportDisplayTime
|
||||
end
|
||||
|
||||
--- Get the reporting message display time.
|
||||
-- @param #FAC_BASE self
|
||||
-- @return #number ReportDisplayTime The display time in seconds when a report needs to be done.
|
||||
function FAC_BASE:GetReportDisplayTime()
|
||||
self:F2()
|
||||
|
||||
return self._ReportDisplayTime
|
||||
end
|
||||
|
||||
--- Reports the detected items to the @{Set#SET_CLIENT}.
|
||||
-- @param #FAC_BASE self
|
||||
-- @param Set#SET_BASE DetectedSets The detected Sets created by the @{Detection#DETECTION_BASE} object.
|
||||
@@ -83,15 +116,16 @@ end
|
||||
--- Schedule the FAC reporting.
|
||||
-- @param #FAC_BASE self
|
||||
-- @param #number DelayTime The delay in seconds to wait the reporting.
|
||||
-- @param #number RepeatInterval The repeat interval in seconds for the reporting to happen repeatedly.
|
||||
-- @param #number ReportInterval The repeat interval in seconds for the reporting to happen repeatedly.
|
||||
-- @return #FAC_BASE self
|
||||
function FAC_BASE:Schedule( DelayTime, RepeatInterval )
|
||||
function FAC_BASE:Schedule( DelayTime, ReportInterval )
|
||||
self:F2()
|
||||
|
||||
self.ScheduleDelayTime = DelayTime
|
||||
self.ScheduleRepeatInterval = RepeatInterval
|
||||
self._ScheduleDelayTime = DelayTime
|
||||
|
||||
self.FacScheduler = SCHEDULER:New(self, self._FacScheduler, { self, "Fac" }, DelayTime, RepeatInterval )
|
||||
self:SetReportInterval( ReportInterval )
|
||||
|
||||
self.FacScheduler = SCHEDULER:New(self, self._FacScheduler, { self, "Fac" }, self._ScheduleDelayTime, self._ReportInterval )
|
||||
return self
|
||||
end
|
||||
|
||||
@@ -104,7 +138,7 @@ function FAC_BASE:_FacScheduler( SchedulerName )
|
||||
--- @param Client#CLIENT Client
|
||||
function( Client )
|
||||
if Client:IsAlive() then
|
||||
local DetectedSets = self.Detection:GetDetectionSets()
|
||||
local DetectedSets = self.Detection:GetDetectedSets()
|
||||
return self:ReportDetected( Client, DetectedSets )
|
||||
end
|
||||
end
|
||||
@@ -135,7 +169,7 @@ function FAC_REPORTING:New( ClientSet, Detection )
|
||||
-- Inherits from FAC_BASE
|
||||
local self = BASE:Inherit( self, FAC_BASE:New( ClientSet, Detection ) ) -- #FAC_REPORTING
|
||||
|
||||
self:Schedule( 5, 15 )
|
||||
self:Schedule( 5, 60 )
|
||||
return self
|
||||
end
|
||||
|
||||
@@ -169,7 +203,7 @@ function FAC_REPORTING:ReportDetected( Client, DetectedSets )
|
||||
DetectedMsg[#DetectedMsg+1] = " - Group #" .. DetectedUnitSetID .. ": " .. MessageText
|
||||
end
|
||||
local FACGroup = self.Detection:GetFACGroup()
|
||||
FACGroup:MessageToClient( "Reporting detected target groups:\n" .. table.concat( DetectedMsg, "\n" ), 12, Client )
|
||||
FACGroup:MessageToClient( "Reporting detected target groups:\n" .. table.concat( DetectedMsg, "\n" ), self:GetReportDisplayTime(), Client )
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -9,7 +9,6 @@ Include.File( "Controllable" )
|
||||
Include.File( "Scheduler" )
|
||||
Include.File( "Event" )
|
||||
Include.File( "Menu" )
|
||||
Include.File( "Controllable" )
|
||||
Include.File( "Group" )
|
||||
Include.File( "Unit" )
|
||||
Include.File( "Zone" )
|
||||
|
||||
Reference in New Issue
Block a user