mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Ops
This commit is contained in:
@@ -204,6 +204,7 @@ function AIRWING:New(warehousename, airwingname)
|
||||
self:AddTransition("*", "FlightOnMission", "*") -- Flight was spawned with a mission.
|
||||
|
||||
-- Defaults:
|
||||
self:SetVerbosity(0)
|
||||
self.nflightsCAP=0
|
||||
self.nflightsAWACS=0
|
||||
self.nflightsTANKERboom=0
|
||||
@@ -559,6 +560,15 @@ function AIRWING:GetSquadron(SquadronName)
|
||||
return nil
|
||||
end
|
||||
|
||||
--- Set verbosity level.
|
||||
-- @param #AIRWING self
|
||||
-- @param #number VerbosityLevel Level of output (higher=more). Default 0.
|
||||
-- @return #AIRWING self
|
||||
function AIRWING:SetVerbosity(VerbosityLevel)
|
||||
self.verbose=VerbosityLevel or 0
|
||||
return self
|
||||
end
|
||||
|
||||
--- Get squadron of an asset.
|
||||
-- @param #AIRWING self
|
||||
-- @param #AIRWING.SquadronAsset Asset The squadron asset.
|
||||
@@ -792,93 +802,52 @@ function AIRWING:onafterStatus(From, Event, To)
|
||||
-- Check Rescue Helo missions.
|
||||
self:CheckRescuhelo()
|
||||
|
||||
-- Count missions not over yet.
|
||||
local nmissions=self:CountMissionsInQueue()
|
||||
|
||||
-- Count ALL payloads in stock. If any payload is unlimited, this gives 999.
|
||||
local Npayloads=self:CountPayloadsInStock(AUFTRAG.Type)
|
||||
|
||||
-- General info:
|
||||
-- TODO: assets total
|
||||
local text=string.format("%s: Missions=%d, Payloads=%d (%d), Squads=%d", fsmstate, nmissions, Npayloads, #self.payloads, #self.squadrons)
|
||||
self:I(self.lid..text)
|
||||
if self.verbose>=1 then
|
||||
|
||||
-- Count missions not over yet.
|
||||
local nmissions=self:CountMissionsInQueue()
|
||||
|
||||
-- Count ALL payloads in stock. If any payload is unlimited, this gives 999.
|
||||
local Npayloads=self:CountPayloadsInStock(AUFTRAG.Type)
|
||||
|
||||
-- TODO: assets total
|
||||
|
||||
-- Output.
|
||||
local text=string.format("%s: Missions=%d, Payloads=%d (%d), Squads=%d", fsmstate, nmissions, Npayloads, #self.payloads, #self.squadrons)
|
||||
self:I(self.lid..text)
|
||||
end
|
||||
|
||||
------------------
|
||||
-- Mission Info --
|
||||
------------------
|
||||
local text=string.format("Missions Total=%d:", #self.missionqueue)
|
||||
for i,_mission in pairs(self.missionqueue) do
|
||||
local mission=_mission --Ops.Auftrag#AUFTRAG
|
||||
text=text..string.format("\n[%d] %s: Status=%s, Nassets=%d, Prio=%d, ID=%d (%s)", i, mission.type, mission.status, mission.nassets, mission.prio, mission.auftragsnummer, mission.name)
|
||||
if self.verbose>=2 then
|
||||
local text=string.format("Missions Total=%d:", #self.missionqueue)
|
||||
for i,_mission in pairs(self.missionqueue) do
|
||||
local mission=_mission --Ops.Auftrag#AUFTRAG
|
||||
text=text..string.format("\n[%d] %s: Status=%s, Nassets=%d, Prio=%d, ID=%d (%s)", i, mission.type, mission.status, mission.nassets, mission.prio, mission.auftragsnummer, mission.name)
|
||||
end
|
||||
self:I(self.lid..text)
|
||||
end
|
||||
self:I(self.lid..text)
|
||||
|
||||
|
||||
-------------------
|
||||
-- Squadron Info --
|
||||
-------------------
|
||||
local text="Squadrons:"
|
||||
for i,_squadron in pairs(self.squadrons) do
|
||||
local squadron=_squadron --Ops.Squadron#SQUADRON
|
||||
|
||||
local callsign=squadron.callsignName and UTILS.GetCallsignName(squadron.callsignName) or "N/A"
|
||||
local modex=squadron.modex and squadron.modex or -1
|
||||
local skill=squadron.skill and tostring(squadron.skill) or "N/A"
|
||||
|
||||
-- Squadron text
|
||||
text=text..string.format("\n* %s %s: %s*%d/%d, Callsign=%s, Modex=%d, Skill=%s", squadron.name, squadron:GetState(), squadron.aircrafttype, squadron:CountAssetsInStock(), #squadron.assets, callsign, modex, skill)
|
||||
|
||||
-- Loop over all assets.
|
||||
if self.verbose>1 then
|
||||
for j,_asset in pairs(squadron.assets) do
|
||||
local asset=_asset --#AIRWING.SquadronAsset
|
||||
local assignment=asset.assignment or "none"
|
||||
local name=asset.templatename
|
||||
local spawned=tostring(asset.spawned)
|
||||
local groupname=asset.spawngroupname
|
||||
local typename=asset.unittype
|
||||
|
||||
local mission=self:GetAssetCurrentMission(asset)
|
||||
local missiontext=""
|
||||
if mission then
|
||||
local distance=asset.flightgroup and UTILS.MetersToNM(mission:GetTargetDistance(asset.flightgroup.group:GetCoordinate())) or 0
|
||||
missiontext=string.format(" [%s (%s): status=%s, distance=%.1f NM]", mission.type, mission.name, mission.status, distance)
|
||||
end
|
||||
|
||||
-- Mission info.
|
||||
text=text..string.format("\n -[%d] %s*%d \"%s\": spawned=%s, mission=%s%s", j, typename, asset.nunits, asset.spawngroupname, spawned, tostring(self:IsAssetOnMission(asset)), missiontext)
|
||||
|
||||
-- Payload info.
|
||||
local payload=asset.payload and table.concat(self:GetPayloadMissionTypes(asset.payload), ", ") or "None"
|
||||
text=text.." payload="..payload
|
||||
|
||||
-- Flight status.
|
||||
text=text..", flight: "
|
||||
if asset.flightgroup and asset.flightgroup:IsAlive() then
|
||||
local status=asset.flightgroup:GetState()
|
||||
local fuelmin=asset.flightgroup:GetFuelMin()
|
||||
local fuellow=asset.flightgroup:IsFuelLow()
|
||||
local fuelcri=asset.flightgroup:IsFuelCritical()
|
||||
|
||||
text=text..string.format("%s fuel=%d", status, fuelmin)
|
||||
if fuelcri then
|
||||
text=text.." (critical!)"
|
||||
elseif fuellow then
|
||||
text=text.." (low)"
|
||||
end
|
||||
|
||||
local lifept, lifept0=asset.flightgroup:GetLifePoints()
|
||||
text=text..string.format(" life=%d/%d", lifept, lifept0)
|
||||
|
||||
local ammo=asset.flightgroup:GetAmmoTot()
|
||||
text=text..string.format(" ammo=[G=%d, R=%d, B=%d, M=%d]", ammo.Guns, ammo.Rockets, ammo.Bombs, ammo.Missiles)
|
||||
else
|
||||
text=text.."N/A"
|
||||
end
|
||||
end
|
||||
if self.verbose>=3 then
|
||||
local text="Squadrons:"
|
||||
for i,_squadron in pairs(self.squadrons) do
|
||||
local squadron=_squadron --Ops.Squadron#SQUADRON
|
||||
|
||||
local callsign=squadron.callsignName and UTILS.GetCallsignName(squadron.callsignName) or "N/A"
|
||||
local modex=squadron.modex and squadron.modex or -1
|
||||
local skill=squadron.skill and tostring(squadron.skill) or "N/A"
|
||||
|
||||
-- Squadron text
|
||||
text=text..string.format("\n* %s %s: %s*%d/%d, Callsign=%s, Modex=%d, Skill=%s", squadron.name, squadron:GetState(), squadron.aircrafttype, squadron:CountAssetsInStock(), #squadron.assets, callsign, modex, skill)
|
||||
end
|
||||
self:I(self.lid..text)
|
||||
end
|
||||
self:I(self.lid..text)
|
||||
|
||||
--------------
|
||||
-- Mission ---
|
||||
|
||||
@@ -98,8 +98,9 @@
|
||||
--
|
||||
-- @field #table enrouteTasks Mission enroute tasks.
|
||||
--
|
||||
-- @field #number missionRepeated Number of times mission was repeated.
|
||||
-- @field #number missionRepeatMax Number of times mission is repeated if failed.
|
||||
-- @field #number repeated Number of times mission was repeated.
|
||||
-- @field #number NrepeatFailure Number of times mission is repeated if failed.
|
||||
-- @field #number NrepeatSuccess Number of times mission is repeated if successful.
|
||||
--
|
||||
-- @field Ops.OpsGroup#OPSGROUP.Radio radio Radio freq and modulation.
|
||||
-- @field Ops.OpsGroup#OPSGROUP.Beacon tacan TACAN setting.
|
||||
@@ -259,7 +260,7 @@
|
||||
AUFTRAG = {
|
||||
ClassName = "AUFTRAG",
|
||||
Debug = false,
|
||||
verbose = 2,
|
||||
verbose = 0,
|
||||
lid = nil,
|
||||
auftragsnummer = nil,
|
||||
groupdata = {},
|
||||
@@ -473,19 +474,20 @@ function AUFTRAG:New(Type)
|
||||
-- Auftragsnummer.
|
||||
self.auftragsnummer=_AUFTRAGSNR
|
||||
|
||||
-- Log id.
|
||||
-- Log ID.
|
||||
self:_SetLogID()
|
||||
|
||||
-- State is planned.
|
||||
self.status=AUFTRAG.Status.PLANNED
|
||||
|
||||
-- Defaults
|
||||
self:SetVerbosity(0)
|
||||
self:SetName()
|
||||
self:SetPriority()
|
||||
self:SetTime()
|
||||
self.engageAsGroup=true
|
||||
self.missionRepeated=0
|
||||
self.missionRepeatMax=0
|
||||
self.repeated=0
|
||||
self.NrepeatFailure=0
|
||||
self.NrepeatSuccess=0
|
||||
self.nassets=1
|
||||
self.dTevaluate=0
|
||||
@@ -1413,16 +1415,16 @@ function AUFTRAG:SetPriority(Prio, Urgent)
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set how many times the mission is repeated if it fails.
|
||||
--- Set how many times the mission is repeated if it fails. Only valid if the mission is handled by an AIRWING or higher level.
|
||||
-- @param #AUFTRAG self
|
||||
-- @param #number Nrepeat Number of repeats. Default 0.
|
||||
-- @return #AUFTRAG self
|
||||
function AUFTRAG:SetRepeatOnFailure(Nrepeat)
|
||||
self.missionRepeatMax=Nrepeat or 0
|
||||
self.NrepeatFailure=Nrepeat or 0
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set how many times the mission is repeated if it was successful.
|
||||
--- Set how many times the mission is repeated if it was successful. Only valid if the mission is handled by an AIRWING or higher level.
|
||||
-- @param #AUFTRAG self
|
||||
-- @param #number Nrepeat Number of repeats. Default 0.
|
||||
-- @return #AUFTRAG self
|
||||
@@ -1431,7 +1433,7 @@ function AUFTRAG:SetRepeatOnSuccess(Nrepeat)
|
||||
return self
|
||||
end
|
||||
|
||||
--- Define how many assets are required to do the job.
|
||||
--- Define how many assets are required to do the job. Only valid if the mission is handled by an AIRWING or higher level.
|
||||
-- @param #AUFTRAG self
|
||||
-- @param #number Nassets Number of asset groups. Default 1.
|
||||
-- @return #AUFTRAG self
|
||||
@@ -1459,6 +1461,15 @@ function AUFTRAG:SetEnableMarkers(Coalition)
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set verbosity level.
|
||||
-- @param #AUFTRAG self
|
||||
-- @param #number VerbosityLevel Level of output (higher=more). Default 0.
|
||||
-- @return #AUFTRAG self
|
||||
function AUFTRAG:SetVerbosity(VerbosityLevel)
|
||||
self.verbose=VerbosityLevel or 0
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set weapon type used for the engagement.
|
||||
-- @param #AUFTRAG self
|
||||
-- @param #number WeaponType Weapon type. Default is `ENUMS.WeaponFlag.Auto`.
|
||||
@@ -1537,11 +1548,11 @@ function AUFTRAG:SetMissionSpeed(Speed)
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set max engage range.
|
||||
--- Set max mission range. Only applies if the AUFTRAG is handled by an AIRWING or CHIEF. This is the max allowed distance from the airbase to the target.
|
||||
-- @param #AUFTRAG self
|
||||
-- @param #number Range Max range in NM. Default 100 NM.
|
||||
-- @return #AUFTRAG self
|
||||
function AUFTRAG:SetEngageRange(Range)
|
||||
function AUFTRAG:SetMissionRange(Range)
|
||||
self.engageRange=UTILS.NMToMeters(Range or 100)
|
||||
return self
|
||||
end
|
||||
@@ -2003,6 +2014,7 @@ function AUFTRAG:onafterStatus(From, Event, To)
|
||||
self:E(self.lid..string.format("ERROR: FSM state %s != %s mission status!", fsmstate, self.status))
|
||||
end
|
||||
|
||||
-- General info.
|
||||
if self.verbose>=1 then
|
||||
|
||||
-- Mission start stop time.
|
||||
@@ -2018,6 +2030,7 @@ function AUFTRAG:onafterStatus(From, Event, To)
|
||||
self:I(self.lid..string.format("Status %s: Target=%s, T=%s-%s, assets=%d, groups=%d, targets=%d, wing=%s, commander=%s", self.status, targetname, Cstart, Cstop, #self.assets, Ngroups, Ntargets, airwing, commander))
|
||||
end
|
||||
|
||||
-- Group info.
|
||||
if self.verbose>=2 then
|
||||
-- Data on assigned groups.
|
||||
local text="Group data:"
|
||||
@@ -2508,8 +2521,8 @@ function AUFTRAG:onafterCancel(From, Event, To)
|
||||
self.Tover=timer.getAbsTime()
|
||||
|
||||
-- No more repeats.
|
||||
self.missionRepeatMax=self.missionRepeated
|
||||
self.NrepeatSuccess=self.missionRepeated
|
||||
self.NrepeatFailure=self.repeated
|
||||
self.NrepeatSuccess=self.repeated
|
||||
|
||||
-- Not necessary to delay the evaluaton?!
|
||||
self.dTevaluate=0
|
||||
@@ -2556,16 +2569,16 @@ function AUFTRAG:onafterSuccess(From, Event, To)
|
||||
self.status=AUFTRAG.Status.SUCCESS
|
||||
self:T(self.lid..string.format("New mission status=%s", self.status))
|
||||
|
||||
if self.missionRepeated>=self.NrepeatSuccess then
|
||||
if self.repeated>=self.NrepeatSuccess then
|
||||
|
||||
-- Stop mission.
|
||||
self:I(self.lid..string.format("Mission SUCCESS! Number of max repeats reached [%d>=%d] ==> Stopping mission!", self.missionRepeated, self.NrepeatSuccess))
|
||||
self:I(self.lid..string.format("Mission SUCCESS! Number of max repeats reached [%d>=%d] ==> Stopping mission!", self.repeated, self.NrepeatSuccess))
|
||||
self:Stop()
|
||||
|
||||
else
|
||||
|
||||
-- Repeat mission.
|
||||
self:I(self.lid..string.format("Mission SUCCESS! Repeating mission for the %d time (max %d times) ==> Repeat mission!", self.missionRepeated+1, self.NrepeatSuccess))
|
||||
self:I(self.lid..string.format("Mission SUCCESS! Repeating mission for the %d time (max %d times) ==> Repeat mission!", self.repeated+1, self.NrepeatSuccess))
|
||||
self:Repeat()
|
||||
|
||||
end
|
||||
@@ -2582,15 +2595,15 @@ function AUFTRAG:onafterFailed(From, Event, To)
|
||||
self.status=AUFTRAG.Status.FAILED
|
||||
self:T(self.lid..string.format("New mission status=%s", self.status))
|
||||
|
||||
if self.missionRepeated>=self.missionRepeatMax then
|
||||
if self.repeated>=self.NrepeatFailure then
|
||||
|
||||
self:I(self.lid..string.format("Mission FAILED! Number of max repeats reached [%d>=%d] ==> Stopping mission!", self.missionRepeated, self.missionRepeatMax))
|
||||
self:I(self.lid..string.format("Mission FAILED! Number of max repeats reached [%d>=%d] ==> Stopping mission!", self.repeated, self.NrepeatFailure))
|
||||
self:Stop()
|
||||
|
||||
else
|
||||
|
||||
-- Repeat mission.
|
||||
self:I(self.lid..string.format("Mission FAILED! Repeating mission for the %d time (max %d times) ==> Repeat mission!", self.missionRepeated+1, self.missionRepeatMax))
|
||||
self:I(self.lid..string.format("Mission FAILED! Repeating mission for the %d time (max %d times) ==> Repeat mission!", self.repeated+1, self.NrepeatFailure))
|
||||
self:Repeat()
|
||||
|
||||
end
|
||||
@@ -2611,17 +2624,22 @@ function AUFTRAG:onafterRepeat(From, Event, To)
|
||||
self:T(self.lid..string.format("New mission status=%s (on Repeat)", self.status))
|
||||
|
||||
-- Increase repeat counter.
|
||||
self.missionRepeated=self.missionRepeated+1
|
||||
self.repeated=self.repeated+1
|
||||
|
||||
if self.wingcommander then
|
||||
if self.chief then
|
||||
|
||||
elseif self.wingcommander then
|
||||
|
||||
|
||||
|
||||
elseif self.airwing then
|
||||
|
||||
-- Already at the airwing ==> Queued()
|
||||
self:Queued(self.airwing)
|
||||
|
||||
else
|
||||
|
||||
self:E(self.lid.."ERROR: Mission can only be repeated by a CHIEF, WINGCOMMANDER or AIRWING! Stopping AUFTRAG")
|
||||
self:Stop()
|
||||
end
|
||||
|
||||
|
||||
@@ -2822,8 +2840,8 @@ end
|
||||
-- @return #string Name of the target or "N/A".
|
||||
function AUFTRAG:GetTargetName()
|
||||
|
||||
if self.engageTarget.Target then
|
||||
return self.engageTarget.Name
|
||||
if self.engageTarget then
|
||||
return self.engageTarget:GetName()
|
||||
end
|
||||
|
||||
return "N/A"
|
||||
|
||||
@@ -1503,7 +1503,6 @@ function FLIGHTGROUP:onafterAirborne(From, Event, To)
|
||||
if self.ai then
|
||||
self:_CheckGroupDone(1)
|
||||
else
|
||||
--if not self.ai then
|
||||
self:_UpdateMenu()
|
||||
end
|
||||
end
|
||||
@@ -1706,7 +1705,7 @@ function FLIGHTGROUP:onafterUpdateRoute(From, Event, To, n)
|
||||
---
|
||||
|
||||
if self:IsAirborne() then
|
||||
self:T2(self.lid.."No waypoints left ==> CheckGroupDone")
|
||||
self:I(self.lid.."No waypoints left ==> CheckGroupDone")
|
||||
self:_CheckGroupDone()
|
||||
end
|
||||
|
||||
@@ -1897,7 +1896,15 @@ function FLIGHTGROUP:onafterRTB(From, Event, To, airbase, SpeedTo, SpeedHold, Sp
|
||||
-- Cancel all missions.
|
||||
for _,_mission in pairs(self.missionqueue) do
|
||||
local mission=_mission --Ops.Auftrag#AUFTRAG
|
||||
self:MissionCancel(mission)
|
||||
local mystatus=mission:GetGroupStatus(self)
|
||||
|
||||
-- Check if mission is already over!
|
||||
if not (mystatus==AUFTRAG.GroupStatus.DONE or mystatus==AUFTRAG.GroupStatus.CANCELLED) then
|
||||
local text=string.format("Canceling mission %s in state=%s", mission.name, mission.status)
|
||||
env.info(text)
|
||||
self:MissionCancel(mission)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- Defaults:
|
||||
@@ -1907,7 +1914,6 @@ function FLIGHTGROUP:onafterRTB(From, Event, To, airbase, SpeedTo, SpeedHold, Sp
|
||||
|
||||
-- Debug message.
|
||||
local text=string.format("Flight group set to hold at airbase %s. SpeedTo=%d, SpeedHold=%d, SpeedLand=%d", airbase:GetName(), SpeedTo, SpeedHold, SpeedLand)
|
||||
MESSAGE:New(text, 10, "DEBUG"):ToAllIf(self.Debug)
|
||||
self:T(self.lid..text)
|
||||
|
||||
local althold=self.ishelo and 1000+math.random(10)*100 or math.random(4,10)*1000
|
||||
@@ -2087,7 +2093,6 @@ function FLIGHTGROUP:onafterWait(From, Event, To, Coord, Altitude, Speed)
|
||||
|
||||
-- Debug message.
|
||||
local text=string.format("Flight group set to wait/orbit at altitude %d m and speed %.1f km/h", Altitude, Speed)
|
||||
MESSAGE:New(text, 30, "DEBUG"):ToAllIf(self.Debug)
|
||||
self:T(self.lid..text)
|
||||
|
||||
--TODO: set ROE passive. introduce roe event/state/variable.
|
||||
@@ -2111,7 +2116,6 @@ function FLIGHTGROUP:onafterRefuel(From, Event, To, Coordinate)
|
||||
|
||||
-- Debug message.
|
||||
local text=string.format("Flight group set to refuel at the nearest tanker")
|
||||
MESSAGE:New(text, 30, "DEBUG"):ToAllIf(self.Debug)
|
||||
self:I(self.lid..text)
|
||||
|
||||
--TODO: set ROE passive. introduce roe event/state/variable.
|
||||
@@ -2146,7 +2150,6 @@ end
|
||||
function FLIGHTGROUP:onafterRefueled(From, Event, To)
|
||||
-- Debug message.
|
||||
local text=string.format("Flight group finished refuelling")
|
||||
MESSAGE:New(text, 30, "DEBUG"):ToAllIf(self.Debug)
|
||||
self:I(self.lid..text)
|
||||
|
||||
-- Check if flight is done.
|
||||
@@ -2169,7 +2172,6 @@ function FLIGHTGROUP:onafterHolding(From, Event, To)
|
||||
self.Tholding=timer.getAbsTime()
|
||||
|
||||
local text=string.format("Flight group %s is HOLDING now", self.groupname)
|
||||
MESSAGE:New(text, 10, "DEBUG"):ToAllIf(self.Debug)
|
||||
self:T(self.lid..text)
|
||||
|
||||
-- Add flight to waiting/holding queue.
|
||||
@@ -2280,7 +2282,6 @@ function FLIGHTGROUP:onafterFuelLow(From, Event, To)
|
||||
|
||||
-- Debug message.
|
||||
local text=string.format("Low fuel for flight group %s", self.groupname)
|
||||
MESSAGE:New(text, 30, "DEBUG"):ToAllIf(self.Debug)
|
||||
self:I(self.lid..text)
|
||||
|
||||
-- Set switch to true.
|
||||
@@ -2350,7 +2351,6 @@ function FLIGHTGROUP:onafterFuelCritical(From, Event, To)
|
||||
|
||||
-- Debug message.
|
||||
local text=string.format("Critical fuel for flight group %s", self.groupname)
|
||||
MESSAGE:New(text, 30, "DEBUG"):ToAllIf(self.Debug)
|
||||
self:I(self.lid..text)
|
||||
|
||||
-- Set switch to true.
|
||||
|
||||
@@ -410,11 +410,6 @@ function NAVYGROUP:onafterStatus(From, Event, To)
|
||||
if self.detectionOn then
|
||||
self:_CheckDetectedUnits()
|
||||
end
|
||||
|
||||
-- Current heading and position of the carrier.
|
||||
local hdg=self:GetHeading()
|
||||
local pos=self:GetCoordinate()
|
||||
local speed=self.group:GetVelocityKNOTS()
|
||||
|
||||
-- Update last known position, orientation, velocity.
|
||||
self:_UpdatePosition()
|
||||
@@ -450,35 +445,40 @@ function NAVYGROUP:onafterStatus(From, Event, To)
|
||||
|
||||
-- Check if group got stuck.
|
||||
self:_CheckStuck()
|
||||
|
||||
-- Get number of tasks and missions.
|
||||
local nTaskTot, nTaskSched, nTaskWP=self:CountRemainingTasks()
|
||||
local nMissions=self:CountRemainingMissison()
|
||||
|
||||
local intowind=self:IsSteamingIntoWind() and UTILS.SecondsToClock(self.intowind.Tstop-timer.getAbsTime(), true) or "N/A"
|
||||
local turning=tostring(self:IsTurning())
|
||||
local alt=pos.y
|
||||
local speedExpected=UTILS.MpsToKnots(self.speed or 0)
|
||||
|
||||
local wpidxCurr=self.currentwp
|
||||
local wpuidCurr=0
|
||||
local wpidxNext=self:GetWaypointIndexNext()
|
||||
local wpuidNext=0
|
||||
local wpDist=UTILS.MetersToNM(self:GetDistanceToWaypoint())
|
||||
local wpETA=UTILS.SecondsToClock(self:GetTimeToWaypoint(), true)
|
||||
local roe=self:GetROE() or 0
|
||||
local als=self:GetAlarmstate() or 0
|
||||
if self.verbose>=1 then
|
||||
|
||||
-- Info text.
|
||||
local text=string.format("%s [ROE=%d,AS=%d, T/M=%d/%d]: Wp=%d[%d]-->%d[%d] (of %d) Dist=%.1f NM ETA=%s - Speed=%.1f (%.1f) kts, Depth=%.1f m, Hdg=%03d, Turn=%s Collision=%d IntoWind=%s",
|
||||
fsmstate, roe, als, nTaskTot, nMissions, wpidxCurr, wpuidCurr, wpidxNext, wpuidNext, #self.waypoints, wpDist, wpETA, speed, speedExpected, alt, hdg, turning, freepath, intowind)
|
||||
self:I(self.lid..text)
|
||||
-- Get number of tasks and missions.
|
||||
local nTaskTot, nTaskSched, nTaskWP=self:CountRemainingTasks()
|
||||
local nMissions=self:CountRemainingMissison()
|
||||
|
||||
local intowind=self:IsSteamingIntoWind() and UTILS.SecondsToClock(self.intowind.Tstop-timer.getAbsTime(), true) or "N/A"
|
||||
local turning=tostring(self:IsTurning())
|
||||
local alt=self.position.y
|
||||
local speed=UTILS.MpsToKnots(self.velocity)
|
||||
local speedExpected=UTILS.MpsToKnots(self.speed or 0)
|
||||
|
||||
local wpidxCurr=self.currentwp
|
||||
local wpuidCurr=0
|
||||
local wpidxNext=self:GetWaypointIndexNext()
|
||||
local wpuidNext=0
|
||||
local wpDist=UTILS.MetersToNM(self:GetDistanceToWaypoint())
|
||||
local wpETA=UTILS.SecondsToClock(self:GetTimeToWaypoint(), true)
|
||||
local roe=self:GetROE() or 0
|
||||
local als=self:GetAlarmstate() or 0
|
||||
|
||||
-- Info text.
|
||||
local text=string.format("%s [ROE=%d,AS=%d, T/M=%d/%d]: Wp=%d[%d]-->%d[%d] (of %d) Dist=%.1f NM ETA=%s - Speed=%.1f (%.1f) kts, Depth=%.1f m, Hdg=%03d, Turn=%s Collision=%d IntoWind=%s",
|
||||
fsmstate, roe, als, nTaskTot, nMissions, wpidxCurr, wpuidCurr, wpidxNext, wpuidNext, #self.waypoints, wpDist, wpETA, speed, speedExpected, alt, self.heading, turning, freepath, intowind)
|
||||
self:I(self.lid..text)
|
||||
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
-- Info text.
|
||||
local text=string.format("State %s: Alive=%s", fsmstate, tostring(self:IsAlive()))
|
||||
self:I(self.lid..text)
|
||||
self:T(self.lid..text)
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -401,7 +401,17 @@ function OPSGROUP:GetLifePoints()
|
||||
end
|
||||
end
|
||||
|
||||
--- Set default cruise speed..
|
||||
|
||||
--- Set verbosity level.
|
||||
-- @param #OPSGROUP self
|
||||
-- @param #number VerbosityLevel Level of output (higher=more). Default 0.
|
||||
-- @return #OPSGROUP self
|
||||
function OPSGROUP:SetVerbosity(VerbosityLevel)
|
||||
self.verbose=VerbosityLevel or 0
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set default cruise speed.
|
||||
-- @param #OPSGROUP self
|
||||
-- @param #number Speed Speed in knots.
|
||||
-- @return #OPSGROUP self
|
||||
@@ -1017,7 +1027,7 @@ function OPSGROUP:RemoveWaypoint(wpindex)
|
||||
self.passedfinalwp=true
|
||||
end
|
||||
|
||||
env.info("FF passed final waypoint after remove! current wp = "..self.currentwp)
|
||||
--env.info("FF passed final waypoint after remove! current wp = "..self.currentwp)
|
||||
|
||||
self:_CheckGroupDone(1)
|
||||
|
||||
@@ -1043,8 +1053,7 @@ function OPSGROUP:RemoveWaypoint(wpindex)
|
||||
self.currentwp=self.currentwp-1
|
||||
end
|
||||
|
||||
--self.currentwp=math.max(1, self.currentwp-1)
|
||||
env.info("FF current waypoint after remove "..self.currentwp)
|
||||
--env.info("FF current waypoint after remove "..self.currentwp)
|
||||
|
||||
end
|
||||
|
||||
@@ -1099,7 +1108,7 @@ function OPSGROUP:SetTask(DCSTask)
|
||||
text=text..string.format("\n[%d] %s", i, tostring(task.id))
|
||||
end
|
||||
end
|
||||
self:I(self.lid..text)
|
||||
self:T(self.lid..text)
|
||||
end
|
||||
|
||||
return self
|
||||
@@ -1123,7 +1132,7 @@ function OPSGROUP:PushTask(DCSTask)
|
||||
text=text..string.format("\n[%d] %s", i, tostring(task.id))
|
||||
end
|
||||
end
|
||||
self:I(self.lid..text)
|
||||
self:T(self.lid..text)
|
||||
end
|
||||
|
||||
return self
|
||||
@@ -1367,7 +1376,6 @@ function OPSGROUP:RemoveTask(Task)
|
||||
-- Update route if this is a waypoint task.
|
||||
if task.type==OPSGROUP.TaskType.WAYPOINT and task.status==OPSGROUP.TaskStatus.SCHEDULED then
|
||||
self:_CheckGroupDone(1)
|
||||
--self:__UpdateRoute(-1)
|
||||
end
|
||||
|
||||
return true
|
||||
@@ -1445,7 +1453,6 @@ function OPSGROUP:onafterTaskExecute(From, Event, To, Task)
|
||||
|
||||
-- Debug message.
|
||||
local text=string.format("Task %s ID=%d execute", tostring(Task.description), Task.id)
|
||||
MESSAGE:New(text, 10, "DEBUG"):ToAllIf(self.Debug)
|
||||
self:I(self.lid..text)
|
||||
|
||||
-- Cancel current task if there is any.
|
||||
@@ -1556,7 +1563,6 @@ function OPSGROUP:onafterTaskCancel(From, Event, To, Task)
|
||||
|
||||
-- Debug info.
|
||||
local text=string.format("Current task %s ID=%d cancelled (flag %s=%d)", Task.description, Task.id, Task.stopflag:GetName(), stopflag)
|
||||
MESSAGE:New(text, 10, "DEBUG"):ToAllIf(self.Debug)
|
||||
self:I(self.lid..text)
|
||||
|
||||
-- Set stop flag. When the flag is true, the _TaskDone function is executed and calls :TaskDone()
|
||||
@@ -1617,7 +1623,6 @@ function OPSGROUP:onafterTaskDone(From, Event, To, Task)
|
||||
|
||||
-- Debug message.
|
||||
local text=string.format("Task done: %s ID=%d", Task.description, Task.id)
|
||||
MESSAGE:New(text, 10, "DEBUG"):ToAllIf(self.Debug)
|
||||
self:I(self.lid..text)
|
||||
|
||||
-- No current task.
|
||||
@@ -1979,7 +1984,11 @@ end
|
||||
function OPSGROUP:onafterMissionCancel(From, Event, To, Mission)
|
||||
|
||||
if self.currentmission and Mission.auftragsnummer==self.currentmission then
|
||||
|
||||
|
||||
---
|
||||
-- Current Mission
|
||||
---
|
||||
|
||||
-- Get mission waypoint task.
|
||||
local Task=Mission:GetGroupWaypointTask(self)
|
||||
|
||||
@@ -1995,11 +2004,15 @@ function OPSGROUP:onafterMissionCancel(From, Event, To, Mission)
|
||||
|
||||
else
|
||||
|
||||
-- Not the current mission.
|
||||
-- TODO: remove mission from queue?
|
||||
---
|
||||
-- NOT the current mission
|
||||
---
|
||||
|
||||
-- Set mission group status.
|
||||
Mission:SetGroupStatus(self, AUFTRAG.GroupStatus.CANCELLED)
|
||||
Mission:SetGroupStatus(self, AUFTRAG.GroupStatus.CANCELLED)
|
||||
|
||||
-- Remove mission from queue
|
||||
self:RemoveMission(Mission)
|
||||
|
||||
-- Send group RTB or WAIT if nothing left to do.
|
||||
self:_CheckGroupDone(1)
|
||||
@@ -2019,7 +2032,6 @@ function OPSGROUP:onafterMissionDone(From, Event, To, Mission)
|
||||
-- Debug info.
|
||||
local text=string.format("Mission %s DONE!", Mission.name)
|
||||
self:I(self.lid..text)
|
||||
MESSAGE:New(text, 30, self.groupname):ToAllIf(self.Debug)
|
||||
|
||||
-- Set group status.
|
||||
Mission:SetGroupStatus(self, AUFTRAG.GroupStatus.DONE)
|
||||
@@ -2241,7 +2253,6 @@ function OPSGROUP:onafterPassingWaypoint(From, Event, To, Waypoint)
|
||||
local text=string.format("Group passed waypoint %s/%d ID=%d: final=%s detour=%s astar=%s",
|
||||
tostring(wpindex), #self.waypoints, Waypoint.uid, tostring(self.passedfinalwp), tostring(Waypoint.detour), tostring(Waypoint.astar))
|
||||
self:I(self.lid..text)
|
||||
MESSAGE:New(text, 30, "DEBUG"):ToAllIf(self.Debug)
|
||||
|
||||
end
|
||||
|
||||
@@ -2623,12 +2634,12 @@ end
|
||||
-- @param #OPSGROUP self
|
||||
function OPSGROUP:_PrintTaskAndMissionStatus()
|
||||
|
||||
---
|
||||
-- Tasks: verbose >= 2
|
||||
---
|
||||
-- Tasks: verbose >= 3
|
||||
---
|
||||
|
||||
-- Task queue.
|
||||
if #self.taskqueue>0 and self.verbose>=2 then
|
||||
if self.verbose>=3 and #self.taskqueue>0 then
|
||||
local text=string.format("Tasks #%d", #self.taskqueue)
|
||||
for i,_task in pairs(self.taskqueue) do
|
||||
local task=_task --Ops.OpsGroup#OPSGROUP.Task
|
||||
@@ -2660,11 +2671,11 @@ function OPSGROUP:_PrintTaskAndMissionStatus()
|
||||
end
|
||||
|
||||
---
|
||||
-- Missions: verbose>=1
|
||||
-- Missions: verbose>=2
|
||||
---
|
||||
|
||||
-- Current mission name.
|
||||
if self.verbose>0 then
|
||||
if self.verbose>=2 then
|
||||
local Mission=self:GetMissionByID(self.currentmission)
|
||||
|
||||
-- Current status.
|
||||
@@ -2687,7 +2698,8 @@ end
|
||||
|
||||
--- Enhance waypoint table.
|
||||
-- @param #OPSGROUP self
|
||||
-- @return #OPSGROUP.Waypoint Waypoint data.
|
||||
-- @param #OPSGROUP.Waypoint Waypoint data.
|
||||
-- @return #OPSGROUP.Waypoint Modified waypoint data.
|
||||
function OPSGROUP:_CreateWaypoint(waypoint)
|
||||
|
||||
-- Set uid.
|
||||
|
||||
@@ -136,15 +136,20 @@ function SQUADRON:New(TemplateGroupName, Ngroups, SquadronName)
|
||||
|
||||
-- Defaults.
|
||||
self.Ngroups=Ngroups or 3
|
||||
self:SetEngagementRange()
|
||||
self:SetMissionRange()
|
||||
self:SetSkill(AI.Skill.GOOD)
|
||||
self:SetVerbosity(0)
|
||||
|
||||
-- Everyone can ORBIT.
|
||||
self:AddMissionCapability(AUFTRAG.Type.ORBIT)
|
||||
|
||||
-- Generalized attribute.
|
||||
self.attribute=self.templategroup:GetAttribute()
|
||||
|
||||
-- Aircraft type.
|
||||
self.aircrafttype=self.templategroup:GetTypeName()
|
||||
|
||||
-- Refueling system.
|
||||
self.refuelSystem=select(2, self.templategroup:GetUnit(1):IsRefuelable())
|
||||
self.tankerSystem=select(2, self.templategroup:GetUnit(1):IsTanker())
|
||||
|
||||
@@ -201,8 +206,6 @@ function SQUADRON:New(TemplateGroupName, Ngroups, SquadronName)
|
||||
BASE:TraceClass(self.ClassName)
|
||||
BASE:TraceLevel(1)
|
||||
end
|
||||
self.Debug=true
|
||||
|
||||
|
||||
return self
|
||||
end
|
||||
@@ -241,10 +244,19 @@ function SQUADRON:SetSkill(Skill)
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set verbosity level.
|
||||
-- @param #SQUADRON self
|
||||
-- @param #number VerbosityLevel Level of output (higher=more). Default 0.
|
||||
-- @return #SQUADRON self
|
||||
function SQUADRON:SetVerbosity(VerbosityLevel)
|
||||
self.verbose=VerbosityLevel or 0
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set turnover and repair time. If an asset returns from a mission to the airwing, it will need some time until the asset is available for further missions.
|
||||
-- @param #SQUADRON self
|
||||
-- @param #number MaintenanceTime Time in minutes it takes until a flight is combat ready again. Default is 0 min.
|
||||
-- @param #number RepairTime Time in minutes it takes to repair a flight for each percent damage taken. Default is 0 min.
|
||||
-- @param #number RepairTime Time in minutes it takes to repair a flight for each life point taken. Default is 0 min.
|
||||
-- @return #SQUADRON self
|
||||
function SQUADRON:SetTurnoverTime(MaintenanceTime, RepairTime)
|
||||
self.maintenancetime=MaintenanceTime and MaintenanceTime*60 or 0
|
||||
@@ -350,12 +362,12 @@ function SQUADRON:GetMissionPeformance(MissionType)
|
||||
return -1
|
||||
end
|
||||
|
||||
--- Set max engagement range.
|
||||
--- Set max mission range. Only missions in a circle of this radius around the squadron airbase are executed.
|
||||
-- @param #SQUADRON self
|
||||
-- @param #number EngageRange Engagement range in NM. Default 80 NM.
|
||||
-- @param #number Range Range in NM. Default 100 NM.
|
||||
-- @return #SQUADRON self
|
||||
function SQUADRON:SetEngagementRange(EngageRange)
|
||||
self.engageRange=UTILS.NMToMeters(EngageRange or 80)
|
||||
function SQUADRON:SetMissionRange(Range)
|
||||
self.engageRange=UTILS.NMToMeters(Range or 100)
|
||||
return self
|
||||
end
|
||||
|
||||
@@ -565,27 +577,31 @@ end
|
||||
-- @param #string To To state.
|
||||
function SQUADRON:onafterStatus(From, Event, To)
|
||||
|
||||
-- FSM state.
|
||||
local fsmstate=self:GetState()
|
||||
if self.verbose>=1 then
|
||||
|
||||
local callsign=self.callsignName and UTILS.GetCallsignName(self.callsignName) or "N/A"
|
||||
local modex=self.modex and self.modex or -1
|
||||
local skill=self.skill and tostring(self.skill) or "N/A"
|
||||
-- FSM state.
|
||||
local fsmstate=self:GetState()
|
||||
|
||||
local NassetsTot=#self.assets
|
||||
local NassetsInS=self:CountAssetsInStock()
|
||||
local NassetsQP=0 ; local NassetsP=0 ; local NassetsQ=0
|
||||
if self.airwing then
|
||||
NassetsQP, NassetsP, NassetsQ=self.airwing:CountAssetsOnMission(nil, self)
|
||||
end
|
||||
|
||||
-- Short info.
|
||||
local text=string.format("%s [Type=%s, Callsign=%s, Modex=%d, Skill=%s]: Assets Total=%d, InStock=%d, OnMission=%d [P=%d, Q=%d]",
|
||||
fsmstate, self.aircrafttype, callsign, modex, skill, NassetsTot, NassetsInS, NassetsQP, NassetsP, NassetsQ)
|
||||
self:I(self.lid..text)
|
||||
|
||||
-- Check if group has detected any units.
|
||||
self:_CheckAssetStatus()
|
||||
local callsign=self.callsignName and UTILS.GetCallsignName(self.callsignName) or "N/A"
|
||||
local modex=self.modex and self.modex or -1
|
||||
local skill=self.skill and tostring(self.skill) or "N/A"
|
||||
|
||||
local NassetsTot=#self.assets
|
||||
local NassetsInS=self:CountAssetsInStock()
|
||||
local NassetsQP=0 ; local NassetsP=0 ; local NassetsQ=0
|
||||
if self.airwing then
|
||||
NassetsQP, NassetsP, NassetsQ=self.airwing:CountAssetsOnMission(nil, self)
|
||||
end
|
||||
|
||||
-- Short info.
|
||||
local text=string.format("%s [Type=%s, Call=%s, Modex=%d, Skill=%s]: Assets Total=%d, Stock=%d, Mission=%d [Active=%d, Queue=%d]",
|
||||
fsmstate, self.aircrafttype, callsign, modex, skill, NassetsTot, NassetsInS, NassetsQP, NassetsP, NassetsQ)
|
||||
self:I(self.lid..text)
|
||||
|
||||
-- Check if group has detected any units.
|
||||
self:_CheckAssetStatus()
|
||||
|
||||
end
|
||||
|
||||
if not self:IsStopped() then
|
||||
self:__Status(-30)
|
||||
@@ -597,7 +613,8 @@ end
|
||||
-- @param #SQUADRON self
|
||||
function SQUADRON:_CheckAssetStatus()
|
||||
|
||||
if self.verbose>=0 then
|
||||
if self.verbose>=2 then
|
||||
|
||||
local text=""
|
||||
for j,_asset in pairs(self.assets) do
|
||||
local asset=_asset --Ops.AirWing#AIRWING.SquadronAsset
|
||||
@@ -647,8 +664,7 @@ function SQUADRON:_CheckAssetStatus()
|
||||
-- Payload info.
|
||||
local payload=asset.payload and table.concat(self.airwing:GetPayloadMissionTypes(asset.payload), ", ") or "None"
|
||||
text=text..", Payload={"..payload.."}"
|
||||
|
||||
|
||||
|
||||
else
|
||||
|
||||
---
|
||||
|
||||
@@ -136,9 +136,12 @@ function TARGET:New(TargetObject)
|
||||
self:AddObject(TargetObject)
|
||||
|
||||
local Target=self.targets[1] --#TARGET.Object
|
||||
|
||||
self.name=self:GetTargetName(Target)
|
||||
|
||||
self.category=self:GetTargetCategory(Target)
|
||||
|
||||
-- Log ID.
|
||||
self.lid=string.format("TARGET #%03d %s | ", _TARGETID, self.category)
|
||||
|
||||
-- Start state.
|
||||
@@ -660,6 +663,56 @@ function TARGET:GetTargetCoordinate(Target)
|
||||
return nil
|
||||
end
|
||||
|
||||
--- Get target name.
|
||||
-- @param #TARGET self
|
||||
-- @param #TARGET.Object Target Target object.
|
||||
-- @return #string Name of the target object.
|
||||
function TARGET:GetTargetName(Target)
|
||||
|
||||
if Target.Type==TARGET.ObjectType.GROUP then
|
||||
|
||||
if Target.Object and Target.Object:IsAlive() then
|
||||
|
||||
return Target.Object:GetName()
|
||||
|
||||
end
|
||||
|
||||
elseif Target.Type==TARGET.ObjectType.UNIT then
|
||||
|
||||
if Target.Object and Target.Object:IsAlive() then
|
||||
return Target.Object:GetName()
|
||||
end
|
||||
|
||||
elseif Target.Type==TARGET.ObjectType.STATIC then
|
||||
|
||||
if Target.Object and Target.Object:IsAlive() then
|
||||
return Target.Object:GetName()
|
||||
end
|
||||
|
||||
elseif Target.Type==TARGET.ObjectType.AIRBASE then
|
||||
|
||||
if Target.Status==TARGET.ObjectStatus.ALIVE then
|
||||
return Target.Object:GetName()
|
||||
end
|
||||
|
||||
elseif Target.Type==TARGET.ObjectType.COORDINATE then
|
||||
|
||||
local coord=Target.Object --Core.Point#COORDINATE
|
||||
|
||||
return coord:ToStringMGRS()
|
||||
|
||||
end
|
||||
|
||||
return "Unknown"
|
||||
end
|
||||
|
||||
--- Get name.
|
||||
-- @param #TARGET self
|
||||
-- @return #string Name of the target usually the first object.
|
||||
function TARGET:GetName()
|
||||
return self.name
|
||||
end
|
||||
|
||||
--- Get coordinate.
|
||||
-- @param #TARGET self
|
||||
-- @return Core.Point#COORDINATE Coordinate of the target.
|
||||
|
||||
Reference in New Issue
Block a user