Progress Dispatcher

This commit is contained in:
FlightControl 2017-03-05 12:37:56 +01:00
parent 6710bfba26
commit 32d6233cf1
10 changed files with 105 additions and 65548 deletions

View File

@ -293,6 +293,9 @@ do -- DETECTION_BASE
-- Inherits from BASE
local self = BASE:Inherit( self, FSM:New() ) -- #DETECTION_BASE
self.DetectedItemCount = 0
self.DetectedItems = {}
self.DetectionSetGroup = DetectionSetGroup
self.DetectionInterval = 30
@ -918,8 +921,9 @@ do -- DETECTION_BASE
local DetectedItem = {}
DetectedItem.Set = Set or SET_UNIT:New()
DetectedItem.Zone = Zone
table.insert( self.DetectedItems, DetectedItem )
self.DetectedItemCount = self.DetectedItemCount + 1
self.DetectedItems[self.DetectedItemCount] = DetectedItem
return DetectedItem
end
@ -930,7 +934,8 @@ do -- DETECTION_BASE
-- @param #number DetectedItemIndex The index or position in the DetectedItems list where the item needs to be removed.
function DETECTION_BASE:RemoveDetectedItem( DetectedItemIndex )
table.remove( self.DetectedItems, DetectedItemIndex )
self.DetectedItemCount = self.DetectedItemCount + 1
self.DetectedItems[self.DetectedItemIndex] = nil
end
@ -947,7 +952,7 @@ do -- DETECTION_BASE
-- @return #number Count
function DETECTION_BASE:GetDetectedItemsCount()
local DetectedCount = #self.DetectedItems
local DetectedCount = self.DetectedItemCount
return DetectedCount
end
@ -1392,6 +1397,7 @@ do -- DETECTION_AREAS
end
--- Add a detected @{#DETECTION_AREAS.DetectedItem}.
-- @param #DETECTION_AREAS self
-- @param Core.Set#SET_UNIT Set -- The Set of Units in the detected area.
-- @param Core.Zone#ZONE_UNIT Zone -- The Zone of the detected area.
-- @return #DETECTION_AREAS.DetectedItem DetectedItem
@ -1401,7 +1407,7 @@ do -- DETECTION_AREAS
local DetectedItem = self:GetParent( self ).AddDetectedItem( self, Set, Zone )
DetectedItem.Removed = false
DetectedItem.AreaID = #self.DetectedItems+1
DetectedItem.AreaID = #self.DetectedItems + 1
self:T( { #self.DetectedItems, DetectedItem } )

View File

@ -68,22 +68,23 @@ function COMMANDCENTER:New( CommandCenterPositionable, CommandCenterName )
self:HandleEvent( EVENTS.Birth,
--- @param #COMMANDCENTER self
--- @param Core.Event#EVENTDATA EventData
-- @param Core.Event#EVENTDATA EventData
function( self, EventData )
self:E( { EventData } )
local EventGroup = GROUP:Find( EventData.IniDCSGroup )
if EventGroup and self:HasGroup( EventGroup ) then
local MenuReporting = MENU_GROUP:New( EventGroup, "Reporting", self.CommandCenterMenu )
local MenuMissionsSummary = MENU_GROUP_COMMAND:New( EventGroup, "Missions Summary Report", MenuReporting, self.ReportSummary, self, EventGroup )
local MenuMissionsDetails = MENU_GROUP_COMMAND:New( EventGroup, "Missions Details Report", MenuReporting, self.ReportDetails, self, EventGroup )
self:ReportSummary( EventGroup )
end
local PlayerUnit = EventData.IniUnit
for MissionID, Mission in pairs( self:GetMissions() ) do
local Mission = Mission -- Tasking.Mission#MISSION
local PlayerGroup = EventData.IniGroup -- The GROUP object should be filled!
Mission:JoinUnit( PlayerUnit, PlayerGroup )
Mission:ReportDetails()
if EventData.IniObjectCategory == 1 then
local EventGroup = GROUP:Find( EventData.IniDCSGroup )
if EventGroup and self:HasGroup( EventGroup ) then
local MenuReporting = MENU_GROUP:New( EventGroup, "Reporting", self.CommandCenterMenu )
local MenuMissionsSummary = MENU_GROUP_COMMAND:New( EventGroup, "Missions Summary Report", MenuReporting, self.ReportSummary, self, EventGroup )
local MenuMissionsDetails = MENU_GROUP_COMMAND:New( EventGroup, "Missions Details Report", MenuReporting, self.ReportDetails, self, EventGroup )
self:ReportSummary( EventGroup )
end
local PlayerUnit = EventData.IniUnit
for MissionID, Mission in pairs( self:GetMissions() ) do
local Mission = Mission -- Tasking.Mission#MISSION
local PlayerGroup = EventData.IniGroup -- The GROUP object should be filled!
Mission:JoinUnit( PlayerUnit, PlayerGroup )
Mission:ReportDetails()
end
end
end

View File

@ -88,6 +88,8 @@ do -- DETECTION MANAGER
self:SetReportInterval( 30 )
self:SetReportDisplayTime( 25 )
Detection:__Start( 5 )
return self
end
@ -288,14 +290,14 @@ do -- DETECTION_DISPATCHER
--- Creates a SEAD task when there are targets for it.
-- @param #DETECTION_DISPATCHER self
-- @param Functional.Detection#DETECTION_AREAS.DetectedArea DetectedArea
-- @param Functional.Detection#DETECTION_AREAS.DetectedItem DetectedItem
-- @return Set#SET_UNIT TargetSetUnit: The target set of units.
-- @return #nil If there are no targets to be set.
function DETECTION_DISPATCHER:EvaluateSEAD( DetectedArea )
self:F( { DetectedArea.AreaID } )
function DETECTION_DISPATCHER:EvaluateSEAD( DetectedItem )
self:F( { DetectedItem.AreaID } )
local DetectedSet = DetectedArea.Set
local DetectedZone = DetectedArea.Zone
local DetectedSet = DetectedItem.Set
local DetectedZone = DetectedItem.Zone
-- Determine if the set has radar targets. If it does, construct a SEAD task.
local RadarCount = DetectedSet:HasSEAD()
@ -375,12 +377,12 @@ do -- DETECTION_DISPATCHER
-- @param #DETECTION_DISPATCHER self
-- @param Tasking.Mission#MISSION Mission
-- @param Tasking.Task#TASK Task
-- @param Functional.Detection#DETECTION_AREAS.DetectedArea DetectedArea
-- @param Functional.Detection#DETECTION_AREAS.DetectedItem DetectedItem
-- @return Tasking.Task#TASK
function DETECTION_DISPATCHER:EvaluateRemoveTask( Mission, Task, DetectedArea )
function DETECTION_DISPATCHER:EvaluateRemoveTask( Mission, Task, DetectedItem )
if Task then
if Task:IsStatePlanned() and DetectedArea.Changed == true then
if Task:IsStatePlanned() and DetectedItem.Changed == true then
self:E( "Removing Tasking: " .. Task:GetTaskName() )
Task = Mission:RemoveTask( Task )
end
@ -420,7 +422,10 @@ do -- DETECTION_DISPATCHER
if not SEADTask then
local TargetSetUnit = self:EvaluateSEAD( DetectedItem ) -- Returns a SetUnit if there are targets to be SEADed...
if TargetSetUnit then
SEADTask = Mission:AddTask( TASK_SEAD:New( Mission, self.SetGroup, "SEAD." .. AreaID, TargetSetUnit , DetectedZone ) )
local Task = TASK_SEAD:New( Mission, self.SetGroup, "SEAD." .. AreaID, TargetSetUnit )
Task:SetTargetZone( DetectedZone )
SEADTask = Mission:AddTask( Task )
end
end
if SEADTask and SEADTask:IsStatePlanned() then
@ -429,55 +434,55 @@ do -- DETECTION_DISPATCHER
TaskMsg[#TaskMsg+1] = " - " .. SEADTask:GetStateString() .. " SEAD " .. AreaID .. " - " .. SEADTask.TargetSetUnit:GetUnitTypesText()
end
-- Evaluate CAS Tasking
local CASTask = Mission:GetTask( "CAS." .. AreaID )
CASTask = self:EvaluateRemoveTask( Mission, CASTask, DetectedItem )
if not CASTask then
local TargetSetUnit = self:EvaluateCAS( DetectedItem ) -- Returns a SetUnit if there are targets to be SEADed...
if TargetSetUnit then
CASTask = Mission:AddTask( TASK_A2G:New( Mission, self.SetGroup, "CAS." .. AreaID, "CAS", TargetSetUnit , DetectedZone, DetectedItem.NearestFAC ) )
end
end
if CASTask and CASTask:IsStatePlanned() then
--CASTask:SetPlannedMenu()
TaskMsg[#TaskMsg+1] = " - " .. CASTask:GetStateString() .. " CAS " .. AreaID .. " - " .. CASTask.TargetSetUnit:GetUnitTypesText()
end
-- -- Evaluate CAS Tasking
-- local CASTask = Mission:GetTask( "CAS." .. AreaID )
-- CASTask = self:EvaluateRemoveTask( Mission, CASTask, DetectedItem )
-- if not CASTask then
-- local TargetSetUnit = self:EvaluateCAS( DetectedItem ) -- Returns a SetUnit if there are targets to be SEADed...
-- if TargetSetUnit then
-- CASTask = Mission:AddTask( TASK_A2G:New( Mission, self.SetGroup, "CAS." .. AreaID, "CAS", TargetSetUnit , DetectedZone, DetectedItem.NearestFAC ) )
-- end
-- end
-- if CASTask and CASTask:IsStatePlanned() then
-- --CASTask:SetPlannedMenu()
-- TaskMsg[#TaskMsg+1] = " - " .. CASTask:GetStateString() .. " CAS " .. AreaID .. " - " .. CASTask.TargetSetUnit:GetUnitTypesText()
-- end
--
-- -- Evaluate BAI Tasking
-- local BAITask = Mission:GetTask( "BAI." .. AreaID )
-- BAITask = self:EvaluateRemoveTask( Mission, BAITask, DetectedItem )
-- if not BAITask then
-- local TargetSetUnit = self:EvaluateBAI( DetectedItem, self.CommandCenter:GetCoalition() ) -- Returns a SetUnit if there are targets to be SEADed...
-- if TargetSetUnit then
-- BAITask = Mission:AddTask( TASK_A2G:New( Mission, self.SetGroup, "BAI." .. AreaID, "BAI", TargetSetUnit , DetectedZone, DetectedItem.NearestFAC ) )
-- end
-- end
-- if BAITask and BAITask:IsStatePlanned() then
-- --BAITask:SetPlannedMenu()
-- TaskMsg[#TaskMsg+1] = " - " .. BAITask:GetStateString() .. " BAI " .. AreaID .. " - " .. BAITask.TargetSetUnit:GetUnitTypesText()
-- end
-- Evaluate BAI Tasking
local BAITask = Mission:GetTask( "BAI." .. AreaID )
BAITask = self:EvaluateRemoveTask( Mission, BAITask, DetectedItem )
if not BAITask then
local TargetSetUnit = self:EvaluateBAI( DetectedItem, self.CommandCenter:GetCoalition() ) -- Returns a SetUnit if there are targets to be SEADed...
if TargetSetUnit then
BAITask = Mission:AddTask( TASK_A2G:New( Mission, self.SetGroup, "BAI." .. AreaID, "BAI", TargetSetUnit , DetectedZone, DetectedItem.NearestFAC ) )
end
end
if BAITask and BAITask:IsStatePlanned() then
--BAITask:SetPlannedMenu()
TaskMsg[#TaskMsg+1] = " - " .. BAITask:GetStateString() .. " BAI " .. AreaID .. " - " .. BAITask.TargetSetUnit:GetUnitTypesText()
end
if #TaskMsg > 0 then
local ThreatLevel = Detection:GetTreatLevelA2G( DetectedItem )
local DetectedAreaVec3 = DetectedZone:GetVec3()
local DetectedAreaPointVec3 = POINT_VEC3:New( DetectedAreaVec3.x, DetectedAreaVec3.y, DetectedAreaVec3.z )
local DetectedAreaPointLL = DetectedAreaPointVec3:ToStringLL( 3, true )
AreaMsg[#AreaMsg+1] = string.format( " - Area #%d - %s - Threat Level [%s] (%2d)",
DetectedItemID,
DetectedAreaPointLL,
string.rep( "", ThreatLevel ),
ThreatLevel
)
-- Loop through the changes ...
local ChangeText = Detection:GetChangeText( DetectedItem )
if ChangeText ~= "" then
ChangeMsg[#ChangeMsg+1] = string.gsub( string.gsub( ChangeText, "\n", "%1 - " ), "^.", " - %1" )
end
end
-- if #TaskMsg > 0 then
--
-- local ThreatLevel = Detection:GetTreatLevelA2G( DetectedItem )
--
-- local DetectedAreaVec3 = DetectedZone:GetVec3()
-- local DetectedAreaPointVec3 = POINT_VEC3:New( DetectedAreaVec3.x, DetectedAreaVec3.y, DetectedAreaVec3.z )
-- local DetectedAreaPointLL = DetectedAreaPointVec3:ToStringLL( 3, true )
-- AreaMsg[#AreaMsg+1] = string.format( " - Area #%d - %s - Threat Level [%s] (%2d)",
-- DetectedItemID,
-- DetectedAreaPointLL,
-- string.rep( "■", ThreatLevel ),
-- ThreatLevel
-- )
--
-- -- Loop through the changes ...
-- local ChangeText = Detection:GetChangeText( DetectedItem )
--
-- if ChangeText ~= "" then
-- ChangeMsg[#ChangeMsg+1] = string.gsub( string.gsub( ChangeText, "\n", "%1 - " ), "^.", " - %1" )
-- end
-- end
-- OK, so the tasking has been done, now delete the changes reported for the area.
Detection:AcceptChanges( DetectedItem )
@ -487,15 +492,13 @@ do -- DETECTION_DISPATCHER
-- TODO set menus using the HQ coordinator
Mission:GetCommandCenter():SetMenu()
if #AreaMsg > 0 then
if #TaskMsg > 0 then
for TaskGroupID, TaskGroup in pairs( self.SetGroup:GetSet() ) do
if not TaskGroup:GetState( TaskGroup, "Assigned" ) then
self.CommandCenter:MessageToGroup(
string.format( "HQ Reporting - Target areas for mission '%s':\nAreas:\n%s\n\nTasks:\n%s\n\nChanges:\n%s ",
string.format( "HQ Reporting - Target areas for mission '%s':\nTasks:\n%s ",
self.Mission:GetName(),
table.concat( AreaMsg, "\n" ),
table.concat( TaskMsg, "\n" ),
table.concat( ChangeMsg, "\n" )
table.concat( TaskMsg, "\n" )
), self:GetReportDisplayTime(), TaskGroup
)
end

View File

@ -56,7 +56,7 @@ function STATIC:FindByName( StaticName, RaiseError )
self.StaticName = StaticName
if StaticFound then
StaticFound:F( { StaticName } )
StaticFound:F3( { StaticName } )
return StaticFound
end

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -23,10 +23,12 @@ local HQ = GROUP:FindByName( "HQ" )
local CC = COMMANDCENTER:New( HQ, "HQ" )
local RecceDetection1 = DETECTION_UNITS:New( RecceSetGroup1 )
local RecceDetection1 = DETECTION_AREAS:New( RecceSetGroup1, 1000 )
RecceDetection1:BoundDetectedZones()
local RecceDetection2 = DETECTION_UNITS:New( RecceSetGroup2 )
local RecceDetection2 = DETECTION_AREAS:New( RecceSetGroup2, 1000 )
RecceDetection2:SetDistanceProbability( 0.2 ) -- Set a 20% probability that a vehicle can be detected at 4km distance.
RecceDetection1:BoundDetectedZones()
RecceDetection1:Start()
RecceDetection2:Start()

View File

@ -5,11 +5,14 @@ local CommandCenter = COMMANDCENTER:New( HQ, "Lima" )
local Scoring = SCORING:New( "Detect Demo" )
local Mission = MISSION:New( CommandCenter, "Overlord", "High", "Attack Detect Mission Briefing", coalition.side.RED ):AddScoring( Scoring )
local Mission = MISSION
:New( CommandCenter, "Overlord", "High", "Attack Detect Mission Briefing", coalition.side.RED )
:AddScoring( Scoring )
local FACSet = SET_GROUP:New():FilterPrefixes( "FAC" ):FilterCoalitions("red"):FilterStart()
local FACDetection = DETECTION_AREAS:New( FACSet, 10000, 3000 )
local FACDetection = DETECTION_AREAS:New( FACSet, 500, 3000 )
FACDetection:BoundDetectedZones()
local AttackGroups = SET_GROUP:New():FilterCoalitions( "red" ):FilterPrefixes( "Attack" ):FilterStart()
local TaskAssign = DETECTION_DISPATCHER:New( Mission, HQ, AttackGroups, FACDetection )
local TaskDispatcher = DETECTION_DISPATCHER:New( Mission, HQ, AttackGroups, FACDetection )