Updates in test

This commit is contained in:
FlightControl 2016-06-24 21:22:18 +02:00
parent 5e6043aeb3
commit a34c04e0f2
28 changed files with 59 additions and 22 deletions

View File

@ -119,6 +119,8 @@ end
function DATABASE:AddUnit( DCSUnitName )
if not self.UNITS[DCSUnitName] then
local UnitRegister = UNIT:Register( DCSUnitName )
self:E( UnitRegister.UnitName )
self.UNITS[DCSUnitName] = UNIT:Register( DCSUnitName )
end

View File

@ -52,7 +52,7 @@
-- @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.
-- @extends Set#SET_BASE
-- @extends Base#BASE
DETECTION_BASE = {
ClassName = "DETECTION_BASE",
DetectedSets = {},
@ -92,8 +92,6 @@ function DETECTION_BASE:New( FACGroup, DetectionRange, DetectionZoneRange )
self:InitDetectIRST( false )
self:InitDetectDLINK( false )
self.DetectionScheduler = SCHEDULER:New(self, self._DetectionScheduler, { self, "Detection" }, 10, 30, 0.2 )
return self
end
@ -207,6 +205,22 @@ function DETECTION_BASE:CreateDetectionSets()
end
--- Schedule the DETECTION construction.
-- @param #DETECTION_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.
-- @return #DETECTION_BASE self
function DETECTION_BASE:Schedule( DelayTime, RepeatInterval )
self:F2()
self.ScheduleDelayTime = DelayTime
self.ScheduleRepeatInterval = RepeatInterval
self.DetectionScheduler = SCHEDULER:New(self, self._DetectionScheduler, { self, "Detection" }, DelayTime, RepeatInterval )
return self
end
--- Form @{Set}s of detected @{Unit#UNIT}s in an array of @{Set#SET_BASE}s.
-- @param #DETECTION_BASE self
function DETECTION_BASE:_DetectionScheduler( SchedulerName )
@ -282,37 +296,41 @@ function DETECTION_BASE:_DetectionScheduler( SchedulerName )
end
end
--- @type DETECTION_UNITGROUPS.DetectedSets
-- @list <Set#SET_UNIT>
--
--- @type DETECTION_UNITGROUPS.DetectedZones
-- @list <Zone#ZONE_UNIT>
--
--- 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.
-- @field #DETECTION_UNITGROUPS.DetectedZones DetectedZones A list of @{Zone#ZONE_UNIT}s containing the zones of the reference detected units.
-- @extends Set#SET_BASE
-- @extends Detection#DETECTION_BASE
DETECTION_UNITGROUPS = {
ClassName = "DETECTION_UNITGROUPS",
DetectedZones = {},
}
--- @type DETECTION_UNITGROUPS.DetectedSets
-- @list <Set#SET_UNIT>
--- @type DETECTION_UNITGROUPS.DetectedZones
-- @list <Zone#ZONE_UNIT>
--- DETECTION_UNITGROUPS constructor.
-- @param #DETECTION_UNITGROUPS self
-- @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.
-- @return #DETECTION_UNITGROUPS self
-- @param Detection#DETECTION_UNITGROUPS 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#DETECTION_UNITGROUPS self
function DETECTION_UNITGROUPS:New( FACGroup, DetectionRange, DetectionZoneRange )
-- Inherits from DETECTION_BASE
local self = BASE:Inherit( self, DETECTION_BASE:New( FACGroup, DetectionRange, DetectionZoneRange ) )
self:Schedule( 10, 30 )
return self
end
@ -324,13 +342,14 @@ function DETECTION_UNITGROUPS:CreateDetectionSets()
self:F2()
for DetectedUnitName, DetectedUnitData in pairs( self.DetectedObjects ) do
self:T( DetectedUnitData.Name )
local DetectedUnit = UNIT:FindByName( DetectedUnitData.Name ) -- Unit#UNIT
if DetectedUnit and DetectedUnit:IsAlive() then
self:T( DetectedUnit:GetName() )
if #self.DetectedSets == 0 then
self:T( { "Adding Unit Set #", 1 } )
self.DetectedZones[1] = ZONE_UNIT:New( DetectedUnitName, DetectedUnit, self.DetectionZoneRange )
self.DetectedSets[1] = SET_BASE:New()
self.DetectedSets[1] = SET_UNIT:New()
self.DetectedSets[1]:AddUnit( DetectedUnit )
else
local AddedToSet = false
@ -349,7 +368,7 @@ function DETECTION_UNITGROUPS:CreateDetectionSets()
local DetectedZoneIndex = #self.DetectedZones + 1
self:T( "Adding new zone #" .. DetectedZoneIndex )
self.DetectedZones[DetectedZoneIndex] = ZONE_UNIT:New( DetectedUnitName, DetectedUnit, self.DetectionZoneRange )
self.DetectedSets[DetectedZoneIndex] = SET_BASE:New()
self.DetectedSets[DetectedZoneIndex] = SET_UNIT:New()
self.DetectedSets[DetectedZoneIndex]:AddUnit( DetectedUnit )
end
end

View File

@ -40,11 +40,11 @@
--- FAC_BASE class
--- FAC_BASE class.
-- @type FAC_BASE
-- @field Set#SET_CLIENT ClientSet The clients to which the FAC will report to.
-- @field Detection#DETECTION_BASE Detection The DETECTION_BASE object that is used to report the detected objects.
-- @extends Set#SET_BASE
-- @extends Base#BASE
FAC_BASE = {
ClassName = "FAC_BASE",
ClientSet = nil,
@ -80,6 +80,20 @@ function FAC_BASE:ReportDetected( DetectedSets )
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.
-- @return #FAC_BASE self
function FAC_BASE:Schedule( DelayTime, RepeatInterval )
self:F2()
self.ScheduleDelayTime = DelayTime
self.ScheduleRepeatInterval = RepeatInterval
self.FacScheduler = SCHEDULER:New(self, self._FacScheduler, { self, "Fac" }, DelayTime, RepeatInterval )
return self
end
--- Report the detected @{Unit#UNIT}s detected within the @{DetectION#DETECTION_BASE} object to the @{Set#SET_CLIENT}s.
-- @param #FAC_BASE self
@ -105,11 +119,12 @@ end
-- @type FAC_REPORTING
-- @field Set#SET_CLIENT ClientSet The clients to which the FAC will report to.
-- @field Detection#DETECTION_BASE Detection The DETECTION_BASE object that is used to report the detected objects.
-- @extends Set#SET_BASE
-- @extends #FAC_BASE
FAC_REPORTING = {
ClassName = "FAC_REPORTING",
}
--- FAC_REPORTING constructor.
-- @param #FAC_REPORTING self
-- @param Set#SET_CLIENT ClientSet
@ -118,11 +133,13 @@ FAC_REPORTING = {
function FAC_REPORTING:New( ClientSet, Detection )
-- Inherits from FAC_BASE
local self = BASE:Inherit( self, FAC_BASE:New( ClientSet, Detection ) )
local self = BASE:Inherit( self, FAC_BASE:New( ClientSet, Detection ) ) -- #FAC_REPORTING
self:Schedule( 5, 15 )
return self
end
--- Reports the detected items to the @{Set#SET_CLIENT}.
-- @param #FAC_REPORTING self
-- @param Client#CLIENT Client The @{Client} object to where the report needs to go.
@ -130,7 +147,6 @@ end
-- @return #boolean Return true if you want the reporting to continue... false will cancel the reporting loop.
function FAC_REPORTING:ReportDetected( Client, DetectedSets )
self:F2( Client )
DetectedSets:Flush()
local DetectedMsg = {}
for DetectedUnitSetID, DetectedUnitSet in pairs( DetectedSets ) do