mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Decreased Tracing
This commit is contained in:
parent
a126906776
commit
7e73db505b
@ -154,7 +154,7 @@ AIRWING = {
|
||||
|
||||
--- AIRWING class version.
|
||||
-- @field #string version
|
||||
AIRWING.version="0.3.0"
|
||||
AIRWING.version="0.5.0"
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- ToDo list
|
||||
@ -204,7 +204,7 @@ function AIRWING:New(warehousename, airwingname)
|
||||
self:AddTransition("*", "FlightOnMission", "*") -- Flight was spawned with a mission.
|
||||
|
||||
-- Defaults:
|
||||
self:SetVerbosity(2)
|
||||
self:SetVerbosity(0)
|
||||
self.nflightsCAP=0
|
||||
self.nflightsAWACS=0
|
||||
self.nflightsTANKERboom=0
|
||||
@ -233,15 +233,6 @@ function AIRWING:New(warehousename, airwingname)
|
||||
-- @param #AIRWING self
|
||||
-- @param #number delay Delay in seconds.
|
||||
|
||||
|
||||
-- Debug trace.
|
||||
if false then
|
||||
self.Debug=true
|
||||
self:TraceOnOff(true)
|
||||
self:TraceClass(self.ClassName)
|
||||
self:TraceLevel(1)
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
@ -341,7 +332,7 @@ function AIRWING:NewPayload(Unit, Npayloads, MissionTypes, Performance)
|
||||
end
|
||||
|
||||
-- Info
|
||||
self:I(self.lid..string.format("Adding new payload from unit %s for aircraft type %s: ID=%d, N=%d (unlimited=%s), performance=%d, missions: %s",
|
||||
self:T(self.lid..string.format("Adding new payload from unit %s for aircraft type %s: ID=%d, N=%d (unlimited=%s), performance=%d, missions: %s",
|
||||
payload.unitname, payload.aircrafttype, payload.uid, payload.navail, tostring(payload.unlimited), Performance, table.concat(MissionTypes, ", ")))
|
||||
|
||||
-- Add payload
|
||||
@ -398,7 +389,7 @@ function AIRWING:FetchPayloadFromStock(UnitType, MissionType, Payloads)
|
||||
|
||||
-- Quick check if we have any payloads.
|
||||
if not self.payloads or #self.payloads==0 then
|
||||
self:I(self.lid.."WARNING: No payloads in stock!")
|
||||
self:T(self.lid.."WARNING: No payloads in stock!")
|
||||
return nil
|
||||
end
|
||||
|
||||
@ -466,7 +457,7 @@ function AIRWING:FetchPayloadFromStock(UnitType, MissionType, Payloads)
|
||||
|
||||
-- Debug.
|
||||
if self.Debug then
|
||||
self:I(self.lid..string.format("FF Sorted payloads for mission type X and aircraft type=Y:"))
|
||||
self:I(self.lid..string.format("Sorted payloads for mission type X and aircraft type=Y:"))
|
||||
for _,_payload in ipairs(self.payloads) do
|
||||
local payload=_payload --#AIRWING.Payload
|
||||
if payload.aircrafttype==UnitType and self:CheckMissionCapability(MissionType, payload.capabilities) then
|
||||
@ -608,7 +599,7 @@ function AIRWING:AddMission(Mission)
|
||||
-- Info text.
|
||||
local text=string.format("Added mission %s (type=%s). Starting at %s. Stopping at %s",
|
||||
tostring(Mission.name), tostring(Mission.type), UTILS.SecondsToClock(Mission.Tstart, true), Mission.Tstop and UTILS.SecondsToClock(Mission.Tstop, true) or "INF")
|
||||
self:I(self.lid..text)
|
||||
self:T(self.lid..text)
|
||||
|
||||
return self
|
||||
end
|
||||
@ -641,13 +632,20 @@ function AIRWING:SetNumberCAP(n)
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set number of TANKER flights constantly in the air.
|
||||
--- Set number of TANKER flights with Boom constantly in the air.
|
||||
-- @param #AIRWING self
|
||||
-- @param #number Nboom Number of flights. Default 1.
|
||||
-- @return #AIRWING self
|
||||
function AIRWING:SetNumberTankerBoom(Nboom)
|
||||
self.nflightsTANKERboom=Nboom or 1
|
||||
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.
|
||||
-- @return #AIRWING self
|
||||
function AIRWING:SetNumberTANKER(Nboom, Nprobe)
|
||||
self.nflightsTANKERboom=Nboom or 1
|
||||
function AIRWING:SetNumberTankerProbe(Nprobe)
|
||||
self.nflightsTANKERprobe=Nprobe or 1
|
||||
return self
|
||||
end
|
||||
@ -833,6 +831,7 @@ function AIRWING:onafterStatus(From, Event, To)
|
||||
------------------
|
||||
if self.verbose>=2 then
|
||||
local text=string.format("Missions Total=%d:", #self.missionqueue)
|
||||
env.info("FF verbose "..self.verbose)
|
||||
for i,_mission in pairs(self.missionqueue) do
|
||||
local mission=_mission --Ops.Auftrag#AUFTRAG
|
||||
|
||||
@ -1170,7 +1169,7 @@ function AIRWING:_GetNextMission()
|
||||
end
|
||||
end
|
||||
end
|
||||
self:I(self.lid..string.format("Provided %d assets with payloads. Could not get payload for %d assets", #gotpayload, #remove))
|
||||
self:T(self.lid..string.format("Provided %d assets with payloads. Could not get payload for %d assets", #gotpayload, #remove))
|
||||
|
||||
-- Now remove assets for which we don't have a payload.
|
||||
for i=#assets,1,-1 do
|
||||
@ -1263,7 +1262,7 @@ function AIRWING:CalculateAssetMissionScore(asset, Mission, includePayload)
|
||||
-- Intercepts need to be carried out quickly. We prefer spawned assets.
|
||||
if Mission.type==AUFTRAG.Type.INTERCEPT then
|
||||
if asset.spawned then
|
||||
self:I("FF adding 25 to asset because it is spawned")
|
||||
self:T(self.lid.."Adding 25 to asset because it is spawned")
|
||||
score=score+25
|
||||
end
|
||||
end
|
||||
@ -1337,7 +1336,7 @@ function AIRWING:_OptimizeAssetSelection(assets, Mission, includePayload)
|
||||
asset.dist=nil
|
||||
asset.score=nil
|
||||
end
|
||||
self:I(self.lid..text)
|
||||
self:T2(self.lid..text)
|
||||
|
||||
end
|
||||
|
||||
@ -1421,6 +1420,7 @@ end
|
||||
-- @param Ops.Auftrag#AUFTRAG Mission The mission to be cancelled.
|
||||
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
|
||||
@ -1465,7 +1465,7 @@ function AIRWING:onafterNewAsset(From, Event, To, asset, assignment)
|
||||
|
||||
-- Debug text.
|
||||
local text=string.format("New asset %s with assignment %s and request assignment %s", asset.spawngroupname, tostring(asset.assignment), tostring(assignment))
|
||||
self:I(self.lid..text)
|
||||
self:T3(self.lid..text)
|
||||
|
||||
-- Get squadron.
|
||||
local squad=self:GetSquadron(asset.assignment)
|
||||
@ -1479,7 +1479,7 @@ function AIRWING:onafterNewAsset(From, Event, To, asset, assignment)
|
||||
|
||||
-- Debug text.
|
||||
local text=string.format("Adding asset to squadron %s: assignment=%s, type=%s, attribute=%s, nunits=%d %s", squad.name, assignment, asset.unittype, asset.attribute, nunits, tostring(squad.ngrouping))
|
||||
self:I(self.lid..text)
|
||||
self:T(self.lid..text)
|
||||
|
||||
-- Adjust number of elements in the group.
|
||||
if squad.ngrouping then
|
||||
@ -1538,7 +1538,7 @@ end
|
||||
-- @param #AIRWING.SquadronAsset Asset The asset that returned.
|
||||
function AIRWING:onafterSquadAssetReturned(From, Event, To, Squadron, Asset)
|
||||
-- Debug message.
|
||||
self:I(self.lid..string.format("Asset %s from squadron %s returned! asset.assignment=\"%s\"", Asset.spawngroupname, Squadron.name, tostring(Asset.assignment)))
|
||||
self:T(self.lid..string.format("Asset %s from squadron %s returned! asset.assignment=\"%s\"", Asset.spawngroupname, Squadron.name, tostring(Asset.assignment)))
|
||||
|
||||
-- Stop flightgroup.
|
||||
Asset.flightgroup:Stop()
|
||||
@ -1607,8 +1607,12 @@ function AIRWING:onafterAssetSpawned(From, Event, To, group, asset, request)
|
||||
end
|
||||
|
||||
if squadron.fuellow then
|
||||
flightgroup:SetFuelCriticalThreshold(squadron.fuellow)
|
||||
flightgroup:SetFuelLowThreshold(squadron.fuellow)
|
||||
end
|
||||
|
||||
if squadron.fuellowRefuel then
|
||||
flightgroup:SetFuelLowRefuel(squadron.fuellowRefuel)
|
||||
end
|
||||
|
||||
---
|
||||
-- Mission
|
||||
@ -2111,7 +2115,7 @@ function AIRWING:CanMission(Mission)
|
||||
local Npayloads=self:CountPayloadsInStock(Mission.type, unittypes, Mission.payloads)
|
||||
|
||||
if Npayloads<Mission.nassets then
|
||||
self:I(self.lid..string.format("INFO: Not enough PAYLOADS available! Got %d but need at least %d", Npayloads, Mission.nassets))
|
||||
self:T(self.lid..string.format("INFO: Not enough PAYLOADS available! Got %d but need at least %d", Npayloads, Mission.nassets))
|
||||
return false, Assets
|
||||
end
|
||||
|
||||
@ -2135,7 +2139,7 @@ function AIRWING:CanMission(Mission)
|
||||
|
||||
-- Debug output.
|
||||
local text=string.format("Mission=%s, squadron=%s, payloads=%d, can=%s, assets=%d. Found %d/%d", Mission.type, squadron.name, Npayloads, tostring(can), #assets, #Assets, Mission.nassets)
|
||||
self:I(self.lid..text)
|
||||
self:T(self.lid..text)
|
||||
|
||||
end
|
||||
|
||||
@ -2143,7 +2147,7 @@ function AIRWING:CanMission(Mission)
|
||||
|
||||
-- Check if required assets are present.
|
||||
if Mission.nassets and Mission.nassets > #Assets then
|
||||
self:I(self.lid..string.format("INFO: Not enough assets available! Got %d but need at least %d", #Assets, Mission.nassets))
|
||||
self:T(self.lid..string.format("INFO: Not enough assets available! Got %d but need at least %d", #Assets, Mission.nassets))
|
||||
Can=false
|
||||
end
|
||||
|
||||
|
||||
@ -227,7 +227,7 @@ function FLIGHTGROUP:New(group)
|
||||
self.lid=string.format("FLIGHTGROUP %s | ", self.groupname)
|
||||
|
||||
-- Defaults
|
||||
self:SetVerbosity(3)
|
||||
self:SetVerbosity(0)
|
||||
self:SetFuelLowThreshold()
|
||||
self:SetFuelLowRTB()
|
||||
self:SetFuelCriticalThreshold()
|
||||
@ -614,7 +614,7 @@ function FLIGHTGROUP:StartUncontrolled(delay)
|
||||
|
||||
if self:IsAlive() then
|
||||
--TODO: check Alive==true and Alive==false ==> Activate first
|
||||
self:I(self.lid.."Starting uncontrolled group")
|
||||
self:T(self.lid.."Starting uncontrolled group")
|
||||
self.group:StartUncontrolled(delay)
|
||||
self.isUncontrolled=true
|
||||
else
|
||||
@ -637,7 +637,7 @@ function FLIGHTGROUP:ClearToLand(Delay)
|
||||
else
|
||||
|
||||
if self:IsHolding() then
|
||||
self:I(self.lid..string.format("Clear to land ==> setting holding flag to 1 (true)"))
|
||||
self:T(self.lid..string.format("Clear to land ==> setting holding flag to 1 (true)"))
|
||||
self.flaghold:Set(1)
|
||||
end
|
||||
|
||||
@ -729,7 +729,7 @@ function FLIGHTGROUP:onafterStatus(From, Event, To)
|
||||
local nMissions=self:CountRemainingMissison()
|
||||
|
||||
-- Short info.
|
||||
if self.verbose>0 then
|
||||
if self.verbose>=1 then
|
||||
local text=string.format("Status %s [%d/%d]: Tasks=%d (%d,%d) Curr=%d, Missions=%s, Waypoint=%d/%d, Detected=%d, Home=%s, Destination=%s",
|
||||
fsmstate, #self.elements, #self.elements, nTaskTot, nTaskSched, nTaskWP, self.taskcurrent, nMissions, self.currentwp or 0, self.waypoints and #self.waypoints or 0,
|
||||
self.detectedunits:Count(), self.homebase and self.homebase:GetName() or "unknown", self.destbase and self.destbase:GetName() or "unknown")
|
||||
@ -737,7 +737,7 @@ function FLIGHTGROUP:onafterStatus(From, Event, To)
|
||||
end
|
||||
|
||||
-- Element status.
|
||||
if self.verbose>1 then
|
||||
if self.verbose>=2 then
|
||||
local text="Elements:"
|
||||
for i,_element in pairs(self.elements) do
|
||||
local element=_element --#FLIGHTGROUP.Element
|
||||
@ -771,7 +771,7 @@ function FLIGHTGROUP:onafterStatus(From, Event, To)
|
||||
-- Distance travelled
|
||||
---
|
||||
|
||||
if self.verbose>1 and self:IsAlive() and self.position then
|
||||
if self.verbose>=3 and self:IsAlive() and self.position then
|
||||
|
||||
local time=timer.getAbsTime()
|
||||
|
||||
@ -933,7 +933,7 @@ function FLIGHTGROUP:OnEventBirth(EventData)
|
||||
end
|
||||
|
||||
-- Set element to spawned state.
|
||||
self:I(self.lid..string.format("EVENT: Element %s born at airbase %s==> spawned", element.name, self.homebase and self.homebase:GetName() or "unknown"))
|
||||
self:T(self.lid..string.format("EVENT: Element %s born at airbase %s==> spawned", element.name, self.homebase and self.homebase:GetName() or "unknown"))
|
||||
self:ElementSpawned(element)
|
||||
|
||||
end
|
||||
@ -1364,7 +1364,7 @@ end
|
||||
-- @param #string Event Event.
|
||||
-- @param #string To To state.
|
||||
function FLIGHTGROUP:onafterSpawned(From, Event, To)
|
||||
self:I(self.lid..string.format("Flight spawned"))
|
||||
self:T(self.lid..string.format("Flight spawned"))
|
||||
|
||||
-- TODO: general routine in opsgroup
|
||||
self.traveldist=0
|
||||
@ -1713,7 +1713,7 @@ function FLIGHTGROUP:onafterUpdateRoute(From, Event, To, n)
|
||||
---
|
||||
|
||||
if self:IsAirborne() then
|
||||
self:I(self.lid.."No waypoints left ==> CheckGroupDone")
|
||||
self:T(self.lid.."No waypoints left ==> CheckGroupDone")
|
||||
self:_CheckGroupDone()
|
||||
end
|
||||
|
||||
@ -1786,25 +1786,25 @@ function FLIGHTGROUP:_CheckGroupDone(delay)
|
||||
|
||||
-- Send flight to destination.
|
||||
if destbase then
|
||||
self:I(self.lid.."Passed Final WP and No current and/or future missions/task ==> RTB!")
|
||||
self:T(self.lid.."Passed Final WP and No current and/or future missions/task ==> RTB!")
|
||||
self:__RTB(-3, destbase)
|
||||
elseif destzone then
|
||||
self:I(self.lid.."Passed Final WP and No current and/or future missions/task ==> RTZ!")
|
||||
self:T(self.lid.."Passed Final WP and No current and/or future missions/task ==> RTZ!")
|
||||
self:__RTZ(-3, destzone)
|
||||
else
|
||||
self:I(self.lid.."Passed Final WP and NO Tasks/Missions left. No DestBase or DestZone ==> Wait!")
|
||||
self:T(self.lid.."Passed Final WP and NO Tasks/Missions left. No DestBase or DestZone ==> Wait!")
|
||||
self:__Wait(-1)
|
||||
end
|
||||
|
||||
else
|
||||
self:I(self.lid..string.format("Passed Final WP but Tasks=%d or Missions=%d left in the queue. Wait!", nTasks, nMissions))
|
||||
self:T(self.lid..string.format("Passed Final WP but Tasks=%d or Missions=%d left in the queue. Wait!", nTasks, nMissions))
|
||||
self:__Wait(-1)
|
||||
end
|
||||
else
|
||||
self:I(self.lid..string.format("Passed Final WP but still have current Task (#%s) or Mission (#%s) left to do", tostring(self.taskcurrent), tostring(self.currentmission)))
|
||||
self:T(self.lid..string.format("Passed Final WP but still have current Task (#%s) or Mission (#%s) left to do", tostring(self.taskcurrent), tostring(self.currentmission)))
|
||||
end
|
||||
else
|
||||
self:I(self.lid..string.format("Flight (status=%s) did NOT pass the final waypoint yet ==> update route", self:GetState()))
|
||||
self:T(self.lid..string.format("Flight (status=%s) did NOT pass the final waypoint yet ==> update route", self:GetState()))
|
||||
self:__UpdateRoute(-1)
|
||||
end
|
||||
end
|
||||
@ -1912,7 +1912,7 @@ function FLIGHTGROUP:onafterRTB(From, Event, To, airbase, SpeedTo, SpeedHold, Sp
|
||||
-- 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:T(self.lid..text)
|
||||
self:MissionCancel(mission)
|
||||
end
|
||||
|
||||
@ -2159,6 +2159,7 @@ end
|
||||
-- @param #string Event Event.
|
||||
-- @param #string To To state.
|
||||
function FLIGHTGROUP:onafterRefueled(From, Event, To)
|
||||
|
||||
-- Debug message.
|
||||
local text=string.format("Flight group finished refuelling")
|
||||
self:I(self.lid..text)
|
||||
@ -2558,28 +2559,30 @@ function FLIGHTGROUP:_InitGroup()
|
||||
self.refueltype=select(2, unit:IsRefuelable())
|
||||
|
||||
-- Debug info.
|
||||
local text=string.format("Initialized Flight Group %s:\n", self.groupname)
|
||||
text=text..string.format("AC type = %s\n", self.actype)
|
||||
text=text..string.format("Speed max = %.1f Knots\n", UTILS.KmphToKnots(self.speedmax))
|
||||
text=text..string.format("Range max = %.1f km\n", self.rangemax/1000)
|
||||
text=text..string.format("Ceiling = %.1f feet\n", UTILS.MetersToFeet(self.ceiling))
|
||||
text=text..string.format("Tanker type = %s\n", tostring(self.tankertype))
|
||||
text=text..string.format("Refuel type = %s\n", tostring(self.refueltype))
|
||||
text=text..string.format("AI = %s\n", tostring(self.ai))
|
||||
text=text..string.format("Helicopter = %s\n", tostring(self.group:IsHelicopter()))
|
||||
text=text..string.format("Elements = %d\n", #self.elements)
|
||||
text=text..string.format("Waypoints = %d\n", #self.waypoints)
|
||||
text=text..string.format("Radio = %.1f MHz %s %s\n", self.radio.Freq, UTILS.GetModulationName(self.radio.Modu), tostring(self.radio.On))
|
||||
text=text..string.format("Ammo = %d (G=%d/R=%d/B=%d/M=%d)\n", self.ammo.Total, self.ammo.Guns, self.ammo.Rockets, self.ammo.Bombs, self.ammo.Missiles)
|
||||
text=text..string.format("FSM state = %s\n", self:GetState())
|
||||
text=text..string.format("Is alive = %s\n", tostring(self.group:IsAlive()))
|
||||
text=text..string.format("LateActivate = %s\n", tostring(self:IsLateActivated()))
|
||||
text=text..string.format("Uncontrolled = %s\n", tostring(self:IsUncontrolled()))
|
||||
text=text..string.format("Start Air = %s\n", tostring(self:IsTakeoffAir()))
|
||||
text=text..string.format("Start Cold = %s\n", tostring(self:IsTakeoffCold()))
|
||||
text=text..string.format("Start Hot = %s\n", tostring(self:IsTakeoffHot()))
|
||||
text=text..string.format("Start Rwy = %s\n", tostring(self:IsTakeoffRunway()))
|
||||
self:I(self.lid..text)
|
||||
if self.verbose>=1 then
|
||||
local text=string.format("Initialized Flight Group %s:\n", self.groupname)
|
||||
text=text..string.format("AC type = %s\n", self.actype)
|
||||
text=text..string.format("Speed max = %.1f Knots\n", UTILS.KmphToKnots(self.speedmax))
|
||||
text=text..string.format("Range max = %.1f km\n", self.rangemax/1000)
|
||||
text=text..string.format("Ceiling = %.1f feet\n", UTILS.MetersToFeet(self.ceiling))
|
||||
text=text..string.format("Tanker type = %s\n", tostring(self.tankertype))
|
||||
text=text..string.format("Refuel type = %s\n", tostring(self.refueltype))
|
||||
text=text..string.format("AI = %s\n", tostring(self.ai))
|
||||
text=text..string.format("Helicopter = %s\n", tostring(self.group:IsHelicopter()))
|
||||
text=text..string.format("Elements = %d\n", #self.elements)
|
||||
text=text..string.format("Waypoints = %d\n", #self.waypoints)
|
||||
text=text..string.format("Radio = %.1f MHz %s %s\n", self.radio.Freq, UTILS.GetModulationName(self.radio.Modu), tostring(self.radio.On))
|
||||
text=text..string.format("Ammo = %d (G=%d/R=%d/B=%d/M=%d)\n", self.ammo.Total, self.ammo.Guns, self.ammo.Rockets, self.ammo.Bombs, self.ammo.Missiles)
|
||||
text=text..string.format("FSM state = %s\n", self:GetState())
|
||||
text=text..string.format("Is alive = %s\n", tostring(self.group:IsAlive()))
|
||||
text=text..string.format("LateActivate = %s\n", tostring(self:IsLateActivated()))
|
||||
text=text..string.format("Uncontrolled = %s\n", tostring(self:IsUncontrolled()))
|
||||
text=text..string.format("Start Air = %s\n", tostring(self:IsTakeoffAir()))
|
||||
text=text..string.format("Start Cold = %s\n", tostring(self:IsTakeoffCold()))
|
||||
text=text..string.format("Start Hot = %s\n", tostring(self:IsTakeoffHot()))
|
||||
text=text..string.format("Start Rwy = %s\n", tostring(self:IsTakeoffRunway()))
|
||||
self:I(self.lid..text)
|
||||
end
|
||||
|
||||
-- Init done.
|
||||
self.groupinitialized=true
|
||||
|
||||
@ -486,8 +486,8 @@ end
|
||||
-- @param #OPSGROUP self
|
||||
-- @return DCS#Vec3 Vector with x,y,z components.
|
||||
function OPSGROUP:GetVec3()
|
||||
if self.group:IsAlive() then
|
||||
self.group:GetVec3()
|
||||
if self:IsAlive() then
|
||||
return self.group:GetVec3()
|
||||
end
|
||||
return nil
|
||||
end
|
||||
@ -1048,8 +1048,6 @@ function OPSGROUP:RemoveWaypoint(wpindex)
|
||||
if self.currentwp>=n then
|
||||
self.passedfinalwp=true
|
||||
end
|
||||
|
||||
--env.info("FF passed final waypoint after remove! current wp = "..self.currentwp)
|
||||
|
||||
self:_CheckGroupDone(1)
|
||||
|
||||
@ -1074,8 +1072,6 @@ function OPSGROUP:RemoveWaypoint(wpindex)
|
||||
else
|
||||
self.currentwp=self.currentwp-1
|
||||
end
|
||||
|
||||
--env.info("FF current waypoint after remove "..self.currentwp)
|
||||
|
||||
end
|
||||
|
||||
@ -1868,7 +1864,7 @@ end
|
||||
function OPSGROUP:onbeforeMissionStart(From, Event, To, Mission)
|
||||
|
||||
-- Debug info.
|
||||
self:I(self.lid..string.format("Starting mission %s, FSM=%s, LateActivated=%s, UnControlled=%s", tostring(Mission.name), self:GetState(), tostring(self:IsLateActivated()), tostring(self:IsUncontrolled())))
|
||||
self:T(self.lid..string.format("Starting mission %s, FSM=%s, LateActivated=%s, UnControlled=%s", tostring(Mission.name), self:GetState(), tostring(self:IsLateActivated()), tostring(self:IsUncontrolled())))
|
||||
|
||||
-- Delay for route to mission. Group needs to be activated and controlled.
|
||||
local delay=0
|
||||
@ -2075,30 +2071,22 @@ function OPSGROUP:onafterMissionDone(From, Event, To, Mission)
|
||||
AIRWING.UpdatePatrolPointMarker(Mission.patroldata)
|
||||
end
|
||||
|
||||
env.info("FF 000")
|
||||
|
||||
-- TACAN
|
||||
if Mission.tacan then
|
||||
|
||||
env.info("FF 100")
|
||||
|
||||
if self.tacanDefault then
|
||||
env.info("FF 200")
|
||||
self:_SwitchTACAN(self.tacanDefault)
|
||||
else
|
||||
env.info("FF 300")
|
||||
self:TurnOffTACAN()
|
||||
end
|
||||
|
||||
local squadron=self.squadron --Ops.Squadron#SQUADRON
|
||||
if squadron then
|
||||
env.info("FF 400")
|
||||
squadron:ReturnTacan(Mission.tacan.Channel)
|
||||
end
|
||||
|
||||
local asset=Mission:GetAssetByName(self.groupname)
|
||||
if asset then
|
||||
env.info("FF 500")
|
||||
asset.tacan=nil
|
||||
end
|
||||
end
|
||||
@ -2302,7 +2290,7 @@ function OPSGROUP:onafterPassingWaypoint(From, Event, To, Waypoint)
|
||||
-- Debug info.
|
||||
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)
|
||||
self:T(self.lid..text)
|
||||
|
||||
end
|
||||
|
||||
@ -2604,7 +2592,7 @@ function OPSGROUP:_CheckGroupDone(delay)
|
||||
-- Start route at first waypoint.
|
||||
self:__UpdateRoute(-1, 1, speed)
|
||||
|
||||
self:I(self.lid..string.format("Passed final WP, #WP>1, adinfinitum=TRUE ==> Goto WP 1 at speed>0"))
|
||||
self:T(self.lid..string.format("Passed final WP, #WP>1, adinfinitum=TRUE ==> Goto WP 1 at speed>0"))
|
||||
|
||||
self.passedfinalwp=false
|
||||
|
||||
@ -2612,7 +2600,7 @@ function OPSGROUP:_CheckGroupDone(delay)
|
||||
-- No further waypoints. Command a full stop.
|
||||
self:__FullStop(-1)
|
||||
|
||||
self:I(self.lid..string.format("Passed final WP, #WP>1, adinfinitum=FALSE ==> Full Stop"))
|
||||
self:T(self.lid..string.format("Passed final WP, #WP>1, adinfinitum=FALSE ==> Full Stop"))
|
||||
end
|
||||
|
||||
elseif #self.waypoints==1 then
|
||||
@ -2627,7 +2615,7 @@ function OPSGROUP:_CheckGroupDone(delay)
|
||||
|
||||
if self.adinfinitum and dist>1000 then -- Note that dist>100 caused the same wp to be passed a lot of times.
|
||||
|
||||
self:I(self.lid..string.format("Passed final WP, #WP=1, adinfinitum=TRUE dist>1000 ==> Goto WP 1 at speed>0"))
|
||||
self:T(self.lid..string.format("Passed final WP, #WP=1, adinfinitum=TRUE dist>1000 ==> Goto WP 1 at speed>0"))
|
||||
|
||||
-- Get positive speed to first waypoint.
|
||||
local speed=self:GetSpeedToWaypoint(1)
|
||||
@ -2639,7 +2627,7 @@ function OPSGROUP:_CheckGroupDone(delay)
|
||||
|
||||
else
|
||||
|
||||
self:I(self.lid..string.format("Passed final WP, #WP=1, adinfinitum=FALSE or dist<1000 ==> Full Stop"))
|
||||
self:T(self.lid..string.format("Passed final WP, #WP=1, adinfinitum=FALSE or dist<1000 ==> Full Stop"))
|
||||
|
||||
self:__FullStop(-1)
|
||||
|
||||
@ -2661,7 +2649,7 @@ function OPSGROUP:_CheckGroupDone(delay)
|
||||
---
|
||||
|
||||
if #self.waypoints>0 then
|
||||
self:I(self.lid..string.format("NOT Passed final WP, #WP>0 ==> Update Route"))
|
||||
self:T(self.lid..string.format("NOT Passed final WP, #WP>0 ==> Update Route"))
|
||||
self:__UpdateRoute(-1)
|
||||
else
|
||||
self:E(self.lid..string.format("WARNING: No waypoints left! Commanding a Full Stop"))
|
||||
@ -2815,7 +2803,7 @@ function OPSGROUP:InitWaypoints()
|
||||
end
|
||||
|
||||
-- Debug info.
|
||||
self:I(self.lid..string.format("Initializing %d waypoints", #self.waypoints))
|
||||
self:T(self.lid..string.format("Initializing %d waypoints", #self.waypoints))
|
||||
|
||||
-- Update route.
|
||||
if #self.waypoints>0 then
|
||||
@ -2945,12 +2933,10 @@ function OPSGROUP._PassingWaypoint(group, opsgroup, uid)
|
||||
-- Check special waypoints.
|
||||
if waypoint.astar then
|
||||
|
||||
env.info("FF removing Astar waypoint "..uid)
|
||||
opsgroup:RemoveWaypointByID(uid)
|
||||
|
||||
elseif waypoint.detour then
|
||||
|
||||
env.info("FF removing Detour waypoint "..uid)
|
||||
opsgroup:RemoveWaypointByID(uid)
|
||||
|
||||
-- Trigger event.
|
||||
@ -3035,12 +3021,12 @@ function OPSGROUP:SwitchROE(roe)
|
||||
self.option.ROE=roe or ENUMS.ROE.ReturnFire
|
||||
|
||||
if self:IsInUtero() then
|
||||
self:I(self.lid..string.format("Setting current ROE=%d when GROUP is SPAWNED", self.option.ROE))
|
||||
self:T2(self.lid..string.format("Setting current ROE=%d when GROUP is SPAWNED", self.option.ROE))
|
||||
else
|
||||
|
||||
self.group:OptionROE(roe)
|
||||
|
||||
self:I(self.lid..string.format("Setting current ROE=%d (0=WeaponFree, 1=OpenFireWeaponFree, 2=OpenFire, 3=ReturnFire, 4=WeaponHold)", self.option.ROE))
|
||||
self:T(self.lid..string.format("Setting current ROE=%d (0=WeaponFree, 1=OpenFireWeaponFree, 2=OpenFire, 3=ReturnFire, 4=WeaponHold)", self.option.ROE))
|
||||
end
|
||||
|
||||
|
||||
@ -3078,12 +3064,12 @@ function OPSGROUP:SwitchROT(rot)
|
||||
self.option.ROT=rot or ENUMS.ROT.PassiveDefense
|
||||
|
||||
if self:IsInUtero() then
|
||||
self:I(self.lid..string.format("Setting current ROT=%d when GROUP is SPAWNED", self.option.ROT))
|
||||
self:T2(self.lid..string.format("Setting current ROT=%d when GROUP is SPAWNED", self.option.ROT))
|
||||
else
|
||||
|
||||
self.group:OptionROT(self.option.ROT)
|
||||
|
||||
self:I(self.lid..string.format("Setting current ROT=%d (0=NoReaction, 1=Passive, 2=Evade, 3=ByPass, 4=AllowAbort)", self.option.ROT))
|
||||
self:T(self.lid..string.format("Setting current ROT=%d (0=NoReaction, 1=Passive, 2=Evade, 3=ByPass, 4=AllowAbort)", self.option.ROT))
|
||||
end
|
||||
|
||||
|
||||
@ -3127,7 +3113,7 @@ function OPSGROUP:SwitchAlarmstate(alarmstate)
|
||||
self.option.Alarm=alarmstate or 0
|
||||
|
||||
if self:IsInUtero() then
|
||||
self:I(self.lid..string.format("Setting current Alarm State=%d when GROUP is SPAWNED", self.option.Alarm))
|
||||
self:T2(self.lid..string.format("Setting current Alarm State=%d when GROUP is SPAWNED", self.option.Alarm))
|
||||
else
|
||||
|
||||
if self.option.Alarm==0 then
|
||||
@ -3142,7 +3128,7 @@ function OPSGROUP:SwitchAlarmstate(alarmstate)
|
||||
self.option.Alarm=0
|
||||
end
|
||||
|
||||
self:I(self.lid..string.format("Setting current Alarm State=%d (0=Auto, 1=Green, 2=Red)", self.option.Alarm))
|
||||
self:T(self.lid..string.format("Setting current Alarm State=%d (0=Auto, 1=Green, 2=Red)", self.option.Alarm))
|
||||
|
||||
end
|
||||
else
|
||||
@ -3247,7 +3233,7 @@ function OPSGROUP:SwitchTACAN(Channel, Morse, UnitName, Band)
|
||||
self.tacan.On=true
|
||||
|
||||
if self:IsInUtero() then
|
||||
self:I(self.lid..string.format("Switching TACAN to Channel %d%s Morse %s on unit %s when GROUP is SPAWNED", self.tacan.Channel, self.tacan.Band, tostring(self.tacan.Morse), self.tacan.BeaconName))
|
||||
self:T(self.lid..string.format("Switching TACAN to Channel %d%s Morse %s on unit %s when GROUP is SPAWNED", self.tacan.Channel, self.tacan.Band, tostring(self.tacan.Morse), self.tacan.BeaconName))
|
||||
else
|
||||
|
||||
-- Activate beacon.
|
||||
@ -3277,7 +3263,7 @@ function OPSGROUP:TurnOffTACAN()
|
||||
self.tacan.BeaconUnit:CommandDeactivateBeacon()
|
||||
end
|
||||
|
||||
self:I(self.lid..string.format("Switching TACAN OFF"))
|
||||
self:T(self.lid..string.format("Switching TACAN OFF"))
|
||||
self.tacan.On=false
|
||||
|
||||
end
|
||||
@ -3343,7 +3329,7 @@ function OPSGROUP:SwitchICLS(Channel, Morse, UnitName)
|
||||
|
||||
|
||||
if self:IsInUtero() then
|
||||
self:I(self.lid..string.format("Switching ICLS to Channel %d Morse %s on unit %s when GROUP is SPAWNED", self.icls.Channel, tostring(self.icls.Morse), self.icls.BeaconName))
|
||||
self:T2(self.lid..string.format("Switching ICLS to Channel %d Morse %s on unit %s when GROUP is SPAWNED", self.icls.Channel, tostring(self.icls.Morse), self.icls.BeaconName))
|
||||
else
|
||||
|
||||
-- Activate beacon.
|
||||
@ -3371,7 +3357,7 @@ function OPSGROUP:TurnOffICLS()
|
||||
self.icls.BeaconUnit:CommandDeactivateICLS()
|
||||
end
|
||||
|
||||
self:I(self.lid..string.format("Switching ICLS OFF"))
|
||||
self:T(self.lid..string.format("Switching ICLS OFF"))
|
||||
self.icls.On=false
|
||||
|
||||
end
|
||||
@ -3423,7 +3409,7 @@ function OPSGROUP:SwitchRadio(Frequency, Modulation)
|
||||
self.radio.On=true
|
||||
|
||||
if self:IsInUtero() then
|
||||
self:I(self.lid..string.format("Switching radio to frequency %.3f MHz %s when GROUP is SPAWNED", self.radio.Freq, UTILS.GetModulationName(self.radio.Modu)))
|
||||
self:T2(self.lid..string.format("Switching radio to frequency %.3f MHz %s when GROUP is SPAWNED", self.radio.Freq, UTILS.GetModulationName(self.radio.Modu)))
|
||||
else
|
||||
|
||||
-- Give command
|
||||
@ -3458,7 +3444,7 @@ function OPSGROUP:TurnOffRadio()
|
||||
-- Radio is off.
|
||||
self.radio.On=false
|
||||
|
||||
self:I(self.lid..string.format("Switching radio OFF"))
|
||||
self:T(self.lid..string.format("Switching radio OFF"))
|
||||
else
|
||||
self:E(self.lid.."ERROR: Radio can only be turned off for aircraft!")
|
||||
end
|
||||
|
||||
@ -27,6 +27,8 @@
|
||||
-- @field #number ngrouping User defined number of units in the asset group.
|
||||
-- @field #table assets Squadron assets.
|
||||
-- @field #table missiontypes Capabilities (mission types and performances) of the squadron.
|
||||
-- @field #number fuellow Low fuel threshold.
|
||||
-- @field #boolean fuellowRefuel If `true`, flight tries to refuel at the nearest tanker.
|
||||
-- @field #number maintenancetime Time in seconds needed for maintenance of a returned flight.
|
||||
-- @field #number repairtime Time in seconds for each
|
||||
-- @field #string livery Livery of the squadron.
|
||||
@ -87,7 +89,7 @@ SQUADRON = {
|
||||
|
||||
--- SQUADRON class version.
|
||||
-- @field #string version
|
||||
SQUADRON.version="0.1.0"
|
||||
SQUADRON.version="0.5.0"
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- TODO list
|
||||
@ -315,7 +317,7 @@ function SQUADRON:AddMissionCapability(MissionTypes, Performance)
|
||||
end
|
||||
|
||||
-- Debug info.
|
||||
self:I(self.missiontypes)
|
||||
self:T2(self.missiontypes)
|
||||
|
||||
return self
|
||||
end
|
||||
@ -400,6 +402,19 @@ function SQUADRON:SetFuelLowThreshold(LowFuel)
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set if low fuel threshold is reached, flight tries to refuel at the neares tanker.
|
||||
-- @param #SQUADRON self
|
||||
-- @param #boolean switch If true or nil, flight goes for refuelling. If false, turn this off.
|
||||
-- @return #SQUADRON self
|
||||
function SQUADRON:SetFuelLowRefuel(switch)
|
||||
if switch==false then
|
||||
self.fuellowRefuel=false
|
||||
else
|
||||
self.fuellowRefuel=true
|
||||
end
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set airwing.
|
||||
-- @param #SQUADRON self
|
||||
-- @param Ops.AirWing#AIRWING Airwing The airwing.
|
||||
@ -409,7 +424,6 @@ function SQUADRON:SetAirwing(Airwing)
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Add airwing asset to squadron.
|
||||
-- @param #SQUADRON self
|
||||
-- @param Ops.AirWing#AIRWING.SquadronAsset Asset The airwing asset.
|
||||
@ -439,7 +453,7 @@ end
|
||||
|
||||
--- Get name of the squadron
|
||||
-- @param #SQUADRON self
|
||||
-- @return #sting Name of the squadron.
|
||||
-- @return #string Name of the squadron.
|
||||
function SQUADRON:GetName()
|
||||
return self.name
|
||||
end
|
||||
@ -536,7 +550,7 @@ function SQUADRON:FetchTacan()
|
||||
|
||||
for channel,free in pairs(self.tacanChannel) do
|
||||
if free then
|
||||
self:I(self.lid..string.format("Checking out Tacan channel %d", channel))
|
||||
self:T(self.lid..string.format("Checking out Tacan channel %d", channel))
|
||||
self.tacanChannel[channel]=false
|
||||
return channel
|
||||
end
|
||||
@ -549,7 +563,7 @@ end
|
||||
-- @param #SQUADRON self
|
||||
-- @param #number channel The channel that is available again.
|
||||
function SQUADRON:ReturnTacan(channel)
|
||||
self:I(self.lid..string.format("Returning Tacan channel %d", channel))
|
||||
self:T(self.lid..string.format("Returning Tacan channel %d", channel))
|
||||
self.tacanChannel[channel]=true
|
||||
end
|
||||
|
||||
@ -588,7 +602,7 @@ function SQUADRON:onafterStart(From, Event, To)
|
||||
|
||||
-- Short info.
|
||||
local text=string.format("Starting SQUADRON", self.name)
|
||||
self:I(self.lid..text)
|
||||
self:T(self.lid..text)
|
||||
|
||||
-- Start the status monitoring.
|
||||
self:__Status(-1)
|
||||
@ -628,7 +642,7 @@ function SQUADRON:onafterStatus(From, Event, To)
|
||||
end
|
||||
|
||||
if not self:IsStopped() then
|
||||
self:__Status(-30)
|
||||
self:__Status(-60)
|
||||
end
|
||||
end
|
||||
|
||||
@ -745,13 +759,13 @@ function SQUADRON:CanMission(Mission)
|
||||
|
||||
-- On duty?=
|
||||
if not self:IsOnDuty() then
|
||||
self:I(self.lid..string.format("Squad in not OnDuty but in state %s. Cannot do mission %s with target %s", self:GetState(), Mission.name, Mission:GetTargetName()))
|
||||
self:T(self.lid..string.format("Squad in not OnDuty but in state %s. Cannot do mission %s with target %s", self:GetState(), Mission.name, Mission:GetTargetName()))
|
||||
return false
|
||||
end
|
||||
|
||||
-- Check mission type. WARNING: This assumes that all assets of the squad can do the same mission types!
|
||||
if not self:CheckMissionType(Mission.type, self:GetMissionTypes()) then
|
||||
self:I(self.lid..string.format("INFO: Squad cannot do mission type %s (%s, %s)", Mission.type, Mission.name, Mission:GetTargetName()))
|
||||
self:T(self.lid..string.format("INFO: Squad cannot do mission type %s (%s, %s)", Mission.type, Mission.name, Mission:GetTargetName()))
|
||||
return false
|
||||
end
|
||||
|
||||
@ -761,7 +775,7 @@ function SQUADRON:CanMission(Mission)
|
||||
if Mission.refuelSystem and Mission.refuelSystem==self.tankerSystem then
|
||||
-- Correct refueling system.
|
||||
else
|
||||
self:I(self.lid..string.format("INFO: Wrong refueling system requested=%s != %s=available", tostring(Mission.refuelSystem), tostring(self.tankerSystem)))
|
||||
self:T(self.lid..string.format("INFO: Wrong refueling system requested=%s != %s=available", tostring(Mission.refuelSystem), tostring(self.tankerSystem)))
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user