Merge branch 'develop' into FF/Ops

This commit is contained in:
Frank
2021-04-07 20:54:19 +02:00
4 changed files with 128 additions and 35 deletions

View File

@@ -119,6 +119,7 @@ AIRWING = {
pointsTANKER = {},
pointsAWACS = {},
wingcommander = nil,
markpoints = false,
}
--- Squadron asset.
@@ -209,6 +210,7 @@ function AIRWING:New(warehousename, airwingname)
self.nflightsTANKERprobe=0
self.nflightsRecoveryTanker=0
self.nflightsRescueHelo=0
self.markpoints = false
------------------------
--- Pseudo Functions ---
@@ -230,6 +232,24 @@ function AIRWING:New(warehousename, airwingname)
-- @function [parent=#AIRWING] __Stop
-- @param #AIRWING self
-- @param #number delay Delay in seconds.
--- On after "FlightOnMission" event. Triggered when an asset group starts a mission.
-- @function [parent=#AIRWING] OnAfterFlightOnMission
-- @param #AIRWING self
-- @param #string From The From state
-- @param #string Event The Event called
-- @param #string To The To state
-- @param Ops.FlightGroup#FLIGHTGROUP Flightgroup The Flightgroup on mission
-- @param Ops.Auftrag#AUFTRAG Mission The Auftrag of the Flightgroup
--- On after "AssetReturned" event. Triggered when an asset group returned to its airwing.
-- @function [parent=#AIRWING] OnAfterAssetReturned
-- @param #AIRWING self
-- @param #string From From state.
-- @param #string Event Event.
-- @param #string To To state.
-- @param Ops.Squadron#SQUADRON Squadron The asset squadron.
-- @param #AIRWING.SquadronAsset Asset The asset that returned.
return self
end
@@ -647,6 +667,19 @@ function AIRWING:SetNumberTankerBoom(Nboom)
return self
end
--- Set markers on the map for Patrol Points.
-- @param #AIRWING self
-- @param #boolean onoff Set to true to switch markers on.
-- @return #AIRWING self
function AIRWING:ShowPatrolPointMarkers(onoff)
if onoff then
self.markpoints = true
else
self.markpoints = false
end
return self
end
--- Set number of TANKER flights with Probe constantly in the air.
-- @param #AIRWING self
-- @param #number Nprobe Number of flights. Default 1.
@@ -689,12 +722,10 @@ end
--- Update marker of the patrol point.
-- @param #AIRWING.PatrolData point Patrol point table.
function AIRWING.UpdatePatrolPointMarker(point)
local text=string.format("%s Occupied=%d\nheading=%03d, leg=%d NM, alt=%d ft, speed=%d kts",
point.type, point.noccupied, point.heading, point.leg, point.altitude, point.speed)
point.marker:UpdateText(text, 1)
local text=string.format("%s Occupied=%d\nheading=%03d, leg=%d NM, alt=%d ft, speed=%d kts",
point.type, point.noccupied, point.heading, point.leg, point.altitude, point.speed)
point.marker:UpdateText(text, 1)
end
@@ -717,10 +748,12 @@ function AIRWING:NewPatrolPoint(Type, Coordinate, Altitude, Speed, Heading, LegL
patrolpoint.altitude=Altitude or math.random(10,20)*1000
patrolpoint.speed=Speed or 350
patrolpoint.noccupied=0
patrolpoint.marker=MARKER:New(Coordinate, "New Patrol Point"):ToAll()
AIRWING.UpdatePatrolPointMarker(patrolpoint)
if self.markpoints then
patrolpoint.marker=MARKER:New(Coordinate, "New Patrol Point"):ToAll()
AIRWING.UpdatePatrolPointMarker(patrolpoint)
end
return patrolpoint
end
@@ -928,7 +961,7 @@ function AIRWING:CheckCAP()
patrol.noccupied=patrol.noccupied+1
AIRWING.UpdatePatrolPointMarker(patrol)
if self.markpoints then AIRWING.UpdatePatrolPointMarker(patrol) end
self:AddMission(missionCAP)
@@ -972,7 +1005,7 @@ function AIRWING:CheckTANKER()
patrol.noccupied=patrol.noccupied+1
AIRWING.UpdatePatrolPointMarker(patrol)
if self.markpoints then AIRWING.UpdatePatrolPointMarker(patrol) end
self:AddMission(mission)
@@ -990,7 +1023,7 @@ function AIRWING:CheckTANKER()
patrol.noccupied=patrol.noccupied+1
AIRWING.UpdatePatrolPointMarker(patrol)
if self.markpoints then AIRWING.UpdatePatrolPointMarker(patrol) end
self:AddMission(mission)
@@ -1018,7 +1051,7 @@ function AIRWING:CheckAWACS()
patrol.noccupied=patrol.noccupied+1
AIRWING.UpdatePatrolPointMarker(patrol)
if self.markpoints then AIRWING.UpdatePatrolPointMarker(patrol) end
self:AddMission(mission)
@@ -1431,7 +1464,9 @@ function AIRWING:onafterMissionCancel(From, Event, To, Mission)
-- Info message.
self:I(self.lid..string.format("Cancel mission %s", Mission.name))
if Mission:IsPlanned() or Mission:IsQueued() or Mission:IsRequested() then
local Ngroups = Mission:CountOpsGroups()
if Mission:IsPlanned() or Mission:IsQueued() or Mission:IsRequested() or Ngroups == 0 then
Mission:Done()

View File

@@ -1,11 +1,11 @@
--- **Ops** - Office of Military Intelligence.
--
-- ## Main Features:
-- **Main Features:**
--
-- * Detect and track contacts consistently
-- * Detect and track clusters of contacts consistently
-- * Use FSM events to link functionality into your scripts
-- * Easy setup
-- * Easy setup
--
-- ===
--
@@ -80,6 +80,7 @@
-- `local m = MESSAGE:New(text,15,"KGB"):ToAll()`
-- `end`
--
--
-- @field #INTEL
INTEL = {
ClassName = "INTEL",
@@ -93,7 +94,7 @@ INTEL = {
ContactsUnknown = {},
Clusters = {},
clustercounter = 1,
clusterradius = 10,
clusterradius = 15,
}
--- Detected item info.
@@ -130,7 +131,7 @@ INTEL = {
--- INTEL class version.
-- @field #string version
INTEL.version="0.2.0"
INTEL.version="0.2.1"
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- ToDo list
@@ -350,7 +351,7 @@ function INTEL:RemoveRejectZone(RejectZone)
return self
end
--- Set forget contacts time interval. For unknown contacts only.
--- Set forget contacts time interval.
-- 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.
-- @param #INTEL self
@@ -465,7 +466,7 @@ end
-- @param #number radius The radius of the clusters
-- @return #INTEL self
function INTEL:SetClusterRadius(radius)
local radius = radius or 10
local radius = radius or 15
self.clusterradius = radius
return self
end
@@ -1082,7 +1083,7 @@ function INTEL:CalcClusterThreatlevelSum(cluster)
threatlevel=threatlevel+contact.threatlevel
end
cluster.threatlevelSum = threatlevel
cluster.threatlevelSum = threatlevel
return threatlevel
end
@@ -1094,7 +1095,7 @@ function INTEL:CalcClusterThreatlevelAverage(cluster)
local threatlevel=self:CalcClusterThreatlevelSum(cluster)
threatlevel=threatlevel/cluster.size
cluster.threatlevelAve = threatlevel
cluster.threatlevelAve = threatlevel
return threatlevel
end
@@ -1114,7 +1115,7 @@ function INTEL:CalcClusterThreatlevelMax(cluster)
end
end
cluster.threatlevelMax = threatlevel
cluster.threatlevelMax = threatlevel
return threatlevel
end
@@ -1155,7 +1156,7 @@ function INTEL:IsContactConnectedToCluster(contact, cluster)
--local dist=Contact.position:Get2DDistance(contact.position)
local dist=Contact.position:DistanceFromPointVec2(contact.position)
local radius = self.clusterradius or 10
local radius = self.clusterradius or 15
if dist<radius*1000 then
return true
end
@@ -1285,7 +1286,13 @@ function INTEL:UpdateClusterMarker(cluster)
local text=string.format("Cluster #%d. Size %d, Units %d, TLsum=%d", cluster.index, cluster.size, unitcount, cluster.threatlevelSum)
if not cluster.marker then
cluster.marker=MARKER:New(cluster.coordinate, text):ToAll()
if self.coalition == coalition.side.RED then
cluster.marker=MARKER:New(cluster.coordinate, text):ToRed()
elseif self.coalition == coalition.side.BLUE then
cluster.marker=MARKER:New(cluster.coordinate, text):ToBlue()
else
cluster.marker=MARKER:New(cluster.coordinate, text):ToNeutral()
end
else
local refresh=false