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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user