Decreased Tracing

This commit is contained in:
Frank 2020-08-30 01:38:18 +02:00
parent a126906776
commit 7e73db505b
4 changed files with 120 additions and 113 deletions

View File

@ -154,7 +154,7 @@ AIRWING = {
--- AIRWING class version. --- AIRWING class version.
-- @field #string version -- @field #string version
AIRWING.version="0.3.0" AIRWING.version="0.5.0"
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- ToDo list -- ToDo list
@ -204,7 +204,7 @@ function AIRWING:New(warehousename, airwingname)
self:AddTransition("*", "FlightOnMission", "*") -- Flight was spawned with a mission. self:AddTransition("*", "FlightOnMission", "*") -- Flight was spawned with a mission.
-- Defaults: -- Defaults:
self:SetVerbosity(2) self:SetVerbosity(0)
self.nflightsCAP=0 self.nflightsCAP=0
self.nflightsAWACS=0 self.nflightsAWACS=0
self.nflightsTANKERboom=0 self.nflightsTANKERboom=0
@ -233,15 +233,6 @@ function AIRWING:New(warehousename, airwingname)
-- @param #AIRWING self -- @param #AIRWING self
-- @param #number delay Delay in seconds. -- @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 return self
end end
@ -341,7 +332,7 @@ function AIRWING:NewPayload(Unit, Npayloads, MissionTypes, Performance)
end end
-- Info -- 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, ", "))) payload.unitname, payload.aircrafttype, payload.uid, payload.navail, tostring(payload.unlimited), Performance, table.concat(MissionTypes, ", ")))
-- Add payload -- Add payload
@ -398,7 +389,7 @@ function AIRWING:FetchPayloadFromStock(UnitType, MissionType, Payloads)
-- Quick check if we have any payloads. -- Quick check if we have any payloads.
if not self.payloads or #self.payloads==0 then 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 return nil
end end
@ -466,7 +457,7 @@ function AIRWING:FetchPayloadFromStock(UnitType, MissionType, Payloads)
-- Debug. -- Debug.
if self.Debug then 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 for _,_payload in ipairs(self.payloads) do
local payload=_payload --#AIRWING.Payload local payload=_payload --#AIRWING.Payload
if payload.aircrafttype==UnitType and self:CheckMissionCapability(MissionType, payload.capabilities) then if payload.aircrafttype==UnitType and self:CheckMissionCapability(MissionType, payload.capabilities) then
@ -608,7 +599,7 @@ function AIRWING:AddMission(Mission)
-- Info text. -- Info text.
local text=string.format("Added mission %s (type=%s). Starting at %s. Stopping at %s", 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") 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 return self
end end
@ -641,13 +632,20 @@ function AIRWING:SetNumberCAP(n)
return self return self
end 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 #AIRWING self
-- @param #number Nboom Number of flights. Default 1. -- @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. -- @param #number Nprobe Number of flights. Default 1.
-- @return #AIRWING self -- @return #AIRWING self
function AIRWING:SetNumberTANKER(Nboom, Nprobe) function AIRWING:SetNumberTankerProbe(Nprobe)
self.nflightsTANKERboom=Nboom or 1
self.nflightsTANKERprobe=Nprobe or 1 self.nflightsTANKERprobe=Nprobe or 1
return self return self
end end
@ -833,6 +831,7 @@ function AIRWING:onafterStatus(From, Event, To)
------------------ ------------------
if self.verbose>=2 then if self.verbose>=2 then
local text=string.format("Missions Total=%d:", #self.missionqueue) local text=string.format("Missions Total=%d:", #self.missionqueue)
env.info("FF verbose "..self.verbose)
for i,_mission in pairs(self.missionqueue) do for i,_mission in pairs(self.missionqueue) do
local mission=_mission --Ops.Auftrag#AUFTRAG local mission=_mission --Ops.Auftrag#AUFTRAG
@ -1170,7 +1169,7 @@ function AIRWING:_GetNextMission()
end end
end 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. -- Now remove assets for which we don't have a payload.
for i=#assets,1,-1 do 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. -- Intercepts need to be carried out quickly. We prefer spawned assets.
if Mission.type==AUFTRAG.Type.INTERCEPT then if Mission.type==AUFTRAG.Type.INTERCEPT then
if asset.spawned 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 score=score+25
end end
end end
@ -1337,7 +1336,7 @@ function AIRWING:_OptimizeAssetSelection(assets, Mission, includePayload)
asset.dist=nil asset.dist=nil
asset.score=nil asset.score=nil
end end
self:I(self.lid..text) self:T2(self.lid..text)
end end
@ -1421,6 +1420,7 @@ end
-- @param Ops.Auftrag#AUFTRAG Mission The mission to be cancelled. -- @param Ops.Auftrag#AUFTRAG Mission The mission to be cancelled.
function AIRWING:onafterMissionCancel(From, Event, To, Mission) function AIRWING:onafterMissionCancel(From, Event, To, Mission)
-- Info message.
self:I(self.lid..string.format("Cancel mission %s", Mission.name)) self:I(self.lid..string.format("Cancel mission %s", Mission.name))
if Mission:IsPlanned() or Mission:IsQueued() or Mission:IsRequested() then if Mission:IsPlanned() or Mission:IsQueued() or Mission:IsRequested() then
@ -1465,7 +1465,7 @@ function AIRWING:onafterNewAsset(From, Event, To, asset, assignment)
-- Debug text. -- Debug text.
local text=string.format("New asset %s with assignment %s and request assignment %s", asset.spawngroupname, tostring(asset.assignment), tostring(assignment)) 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. -- Get squadron.
local squad=self:GetSquadron(asset.assignment) local squad=self:GetSquadron(asset.assignment)
@ -1479,7 +1479,7 @@ function AIRWING:onafterNewAsset(From, Event, To, asset, assignment)
-- Debug text. -- 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)) 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. -- Adjust number of elements in the group.
if squad.ngrouping then if squad.ngrouping then
@ -1538,7 +1538,7 @@ end
-- @param #AIRWING.SquadronAsset Asset The asset that returned. -- @param #AIRWING.SquadronAsset Asset The asset that returned.
function AIRWING:onafterSquadAssetReturned(From, Event, To, Squadron, Asset) function AIRWING:onafterSquadAssetReturned(From, Event, To, Squadron, Asset)
-- Debug message. -- 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. -- Stop flightgroup.
Asset.flightgroup:Stop() Asset.flightgroup:Stop()
@ -1607,7 +1607,11 @@ function AIRWING:onafterAssetSpawned(From, Event, To, group, asset, request)
end end
if squadron.fuellow then if squadron.fuellow then
flightgroup:SetFuelCriticalThreshold(squadron.fuellow) flightgroup:SetFuelLowThreshold(squadron.fuellow)
end
if squadron.fuellowRefuel then
flightgroup:SetFuelLowRefuel(squadron.fuellowRefuel)
end end
--- ---
@ -2111,7 +2115,7 @@ function AIRWING:CanMission(Mission)
local Npayloads=self:CountPayloadsInStock(Mission.type, unittypes, Mission.payloads) local Npayloads=self:CountPayloadsInStock(Mission.type, unittypes, Mission.payloads)
if Npayloads<Mission.nassets then 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 return false, Assets
end end
@ -2135,7 +2139,7 @@ function AIRWING:CanMission(Mission)
-- Debug output. -- 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) 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 end
@ -2143,7 +2147,7 @@ function AIRWING:CanMission(Mission)
-- Check if required assets are present. -- Check if required assets are present.
if Mission.nassets and Mission.nassets > #Assets then 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 Can=false
end end

View File

@ -227,7 +227,7 @@ function FLIGHTGROUP:New(group)
self.lid=string.format("FLIGHTGROUP %s | ", self.groupname) self.lid=string.format("FLIGHTGROUP %s | ", self.groupname)
-- Defaults -- Defaults
self:SetVerbosity(3) self:SetVerbosity(0)
self:SetFuelLowThreshold() self:SetFuelLowThreshold()
self:SetFuelLowRTB() self:SetFuelLowRTB()
self:SetFuelCriticalThreshold() self:SetFuelCriticalThreshold()
@ -614,7 +614,7 @@ function FLIGHTGROUP:StartUncontrolled(delay)
if self:IsAlive() then if self:IsAlive() then
--TODO: check Alive==true and Alive==false ==> Activate first --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.group:StartUncontrolled(delay)
self.isUncontrolled=true self.isUncontrolled=true
else else
@ -637,7 +637,7 @@ function FLIGHTGROUP:ClearToLand(Delay)
else else
if self:IsHolding() then 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) self.flaghold:Set(1)
end end
@ -729,7 +729,7 @@ function FLIGHTGROUP:onafterStatus(From, Event, To)
local nMissions=self:CountRemainingMissison() local nMissions=self:CountRemainingMissison()
-- Short info. -- 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", 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, 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") 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 end
-- Element status. -- Element status.
if self.verbose>1 then if self.verbose>=2 then
local text="Elements:" local text="Elements:"
for i,_element in pairs(self.elements) do for i,_element in pairs(self.elements) do
local element=_element --#FLIGHTGROUP.Element local element=_element --#FLIGHTGROUP.Element
@ -771,7 +771,7 @@ function FLIGHTGROUP:onafterStatus(From, Event, To)
-- Distance travelled -- 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() local time=timer.getAbsTime()
@ -933,7 +933,7 @@ function FLIGHTGROUP:OnEventBirth(EventData)
end end
-- Set element to spawned state. -- 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) self:ElementSpawned(element)
end end
@ -1364,7 +1364,7 @@ end
-- @param #string Event Event. -- @param #string Event Event.
-- @param #string To To state. -- @param #string To To state.
function FLIGHTGROUP:onafterSpawned(From, Event, To) 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 -- TODO: general routine in opsgroup
self.traveldist=0 self.traveldist=0
@ -1713,7 +1713,7 @@ function FLIGHTGROUP:onafterUpdateRoute(From, Event, To, n)
--- ---
if self:IsAirborne() then if self:IsAirborne() then
self:I(self.lid.."No waypoints left ==> CheckGroupDone") self:T(self.lid.."No waypoints left ==> CheckGroupDone")
self:_CheckGroupDone() self:_CheckGroupDone()
end end
@ -1786,25 +1786,25 @@ function FLIGHTGROUP:_CheckGroupDone(delay)
-- Send flight to destination. -- Send flight to destination.
if destbase then 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) self:__RTB(-3, destbase)
elseif destzone then 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) self:__RTZ(-3, destzone)
else 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) self:__Wait(-1)
end end
else 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) self:__Wait(-1)
end end
else 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 end
else 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) self:__UpdateRoute(-1)
end end
end end
@ -1912,7 +1912,7 @@ function FLIGHTGROUP:onafterRTB(From, Event, To, airbase, SpeedTo, SpeedHold, Sp
-- Check if mission is already over! -- Check if mission is already over!
if not (mystatus==AUFTRAG.GroupStatus.DONE or mystatus==AUFTRAG.GroupStatus.CANCELLED) then 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) 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) self:MissionCancel(mission)
end end
@ -2159,6 +2159,7 @@ end
-- @param #string Event Event. -- @param #string Event Event.
-- @param #string To To state. -- @param #string To To state.
function FLIGHTGROUP:onafterRefueled(From, Event, To) function FLIGHTGROUP:onafterRefueled(From, Event, To)
-- Debug message. -- Debug message.
local text=string.format("Flight group finished refuelling") local text=string.format("Flight group finished refuelling")
self:I(self.lid..text) self:I(self.lid..text)
@ -2558,6 +2559,7 @@ function FLIGHTGROUP:_InitGroup()
self.refueltype=select(2, unit:IsRefuelable()) self.refueltype=select(2, unit:IsRefuelable())
-- Debug info. -- Debug info.
if self.verbose>=1 then
local text=string.format("Initialized Flight Group %s:\n", self.groupname) 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("AC type = %s\n", self.actype)
text=text..string.format("Speed max = %.1f Knots\n", UTILS.KmphToKnots(self.speedmax)) text=text..string.format("Speed max = %.1f Knots\n", UTILS.KmphToKnots(self.speedmax))
@ -2580,6 +2582,7 @@ function FLIGHTGROUP:_InitGroup()
text=text..string.format("Start Hot = %s\n", tostring(self:IsTakeoffHot())) text=text..string.format("Start Hot = %s\n", tostring(self:IsTakeoffHot()))
text=text..string.format("Start Rwy = %s\n", tostring(self:IsTakeoffRunway())) text=text..string.format("Start Rwy = %s\n", tostring(self:IsTakeoffRunway()))
self:I(self.lid..text) self:I(self.lid..text)
end
-- Init done. -- Init done.
self.groupinitialized=true self.groupinitialized=true

View File

@ -486,8 +486,8 @@ end
-- @param #OPSGROUP self -- @param #OPSGROUP self
-- @return DCS#Vec3 Vector with x,y,z components. -- @return DCS#Vec3 Vector with x,y,z components.
function OPSGROUP:GetVec3() function OPSGROUP:GetVec3()
if self.group:IsAlive() then if self:IsAlive() then
self.group:GetVec3() return self.group:GetVec3()
end end
return nil return nil
end end
@ -1049,8 +1049,6 @@ function OPSGROUP:RemoveWaypoint(wpindex)
self.passedfinalwp=true self.passedfinalwp=true
end end
--env.info("FF passed final waypoint after remove! current wp = "..self.currentwp)
self:_CheckGroupDone(1) self:_CheckGroupDone(1)
else else
@ -1075,8 +1073,6 @@ function OPSGROUP:RemoveWaypoint(wpindex)
self.currentwp=self.currentwp-1 self.currentwp=self.currentwp-1
end end
--env.info("FF current waypoint after remove "..self.currentwp)
end end
end end
@ -1868,7 +1864,7 @@ end
function OPSGROUP:onbeforeMissionStart(From, Event, To, Mission) function OPSGROUP:onbeforeMissionStart(From, Event, To, Mission)
-- Debug info. -- 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. -- Delay for route to mission. Group needs to be activated and controlled.
local delay=0 local delay=0
@ -2075,30 +2071,22 @@ function OPSGROUP:onafterMissionDone(From, Event, To, Mission)
AIRWING.UpdatePatrolPointMarker(Mission.patroldata) AIRWING.UpdatePatrolPointMarker(Mission.patroldata)
end end
env.info("FF 000")
-- TACAN -- TACAN
if Mission.tacan then if Mission.tacan then
env.info("FF 100")
if self.tacanDefault then if self.tacanDefault then
env.info("FF 200")
self:_SwitchTACAN(self.tacanDefault) self:_SwitchTACAN(self.tacanDefault)
else else
env.info("FF 300")
self:TurnOffTACAN() self:TurnOffTACAN()
end end
local squadron=self.squadron --Ops.Squadron#SQUADRON local squadron=self.squadron --Ops.Squadron#SQUADRON
if squadron then if squadron then
env.info("FF 400")
squadron:ReturnTacan(Mission.tacan.Channel) squadron:ReturnTacan(Mission.tacan.Channel)
end end
local asset=Mission:GetAssetByName(self.groupname) local asset=Mission:GetAssetByName(self.groupname)
if asset then if asset then
env.info("FF 500")
asset.tacan=nil asset.tacan=nil
end end
end end
@ -2302,7 +2290,7 @@ function OPSGROUP:onafterPassingWaypoint(From, Event, To, Waypoint)
-- Debug info. -- Debug info.
local text=string.format("Group passed waypoint %s/%d ID=%d: final=%s detour=%s astar=%s", 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)) 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 end
@ -2604,7 +2592,7 @@ function OPSGROUP:_CheckGroupDone(delay)
-- Start route at first waypoint. -- Start route at first waypoint.
self:__UpdateRoute(-1, 1, speed) 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 self.passedfinalwp=false
@ -2612,7 +2600,7 @@ function OPSGROUP:_CheckGroupDone(delay)
-- No further waypoints. Command a full stop. -- No further waypoints. Command a full stop.
self:__FullStop(-1) 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 end
elseif #self.waypoints==1 then 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. 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. -- Get positive speed to first waypoint.
local speed=self:GetSpeedToWaypoint(1) local speed=self:GetSpeedToWaypoint(1)
@ -2639,7 +2627,7 @@ function OPSGROUP:_CheckGroupDone(delay)
else 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) self:__FullStop(-1)
@ -2661,7 +2649,7 @@ function OPSGROUP:_CheckGroupDone(delay)
--- ---
if #self.waypoints>0 then 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) self:__UpdateRoute(-1)
else else
self:E(self.lid..string.format("WARNING: No waypoints left! Commanding a Full Stop")) self:E(self.lid..string.format("WARNING: No waypoints left! Commanding a Full Stop"))
@ -2815,7 +2803,7 @@ function OPSGROUP:InitWaypoints()
end end
-- Debug info. -- 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. -- Update route.
if #self.waypoints>0 then if #self.waypoints>0 then
@ -2945,12 +2933,10 @@ function OPSGROUP._PassingWaypoint(group, opsgroup, uid)
-- Check special waypoints. -- Check special waypoints.
if waypoint.astar then if waypoint.astar then
env.info("FF removing Astar waypoint "..uid)
opsgroup:RemoveWaypointByID(uid) opsgroup:RemoveWaypointByID(uid)
elseif waypoint.detour then elseif waypoint.detour then
env.info("FF removing Detour waypoint "..uid)
opsgroup:RemoveWaypointByID(uid) opsgroup:RemoveWaypointByID(uid)
-- Trigger event. -- Trigger event.
@ -3035,12 +3021,12 @@ function OPSGROUP:SwitchROE(roe)
self.option.ROE=roe or ENUMS.ROE.ReturnFire self.option.ROE=roe or ENUMS.ROE.ReturnFire
if self:IsInUtero() then 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 else
self.group:OptionROE(roe) 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 end
@ -3078,12 +3064,12 @@ function OPSGROUP:SwitchROT(rot)
self.option.ROT=rot or ENUMS.ROT.PassiveDefense self.option.ROT=rot or ENUMS.ROT.PassiveDefense
if self:IsInUtero() then 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 else
self.group:OptionROT(self.option.ROT) 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 end
@ -3127,7 +3113,7 @@ function OPSGROUP:SwitchAlarmstate(alarmstate)
self.option.Alarm=alarmstate or 0 self.option.Alarm=alarmstate or 0
if self:IsInUtero() then 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 else
if self.option.Alarm==0 then if self.option.Alarm==0 then
@ -3142,7 +3128,7 @@ function OPSGROUP:SwitchAlarmstate(alarmstate)
self.option.Alarm=0 self.option.Alarm=0
end 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 end
else else
@ -3247,7 +3233,7 @@ function OPSGROUP:SwitchTACAN(Channel, Morse, UnitName, Band)
self.tacan.On=true self.tacan.On=true
if self:IsInUtero() then 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 else
-- Activate beacon. -- Activate beacon.
@ -3277,7 +3263,7 @@ function OPSGROUP:TurnOffTACAN()
self.tacan.BeaconUnit:CommandDeactivateBeacon() self.tacan.BeaconUnit:CommandDeactivateBeacon()
end end
self:I(self.lid..string.format("Switching TACAN OFF")) self:T(self.lid..string.format("Switching TACAN OFF"))
self.tacan.On=false self.tacan.On=false
end end
@ -3343,7 +3329,7 @@ function OPSGROUP:SwitchICLS(Channel, Morse, UnitName)
if self:IsInUtero() then 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 else
-- Activate beacon. -- Activate beacon.
@ -3371,7 +3357,7 @@ function OPSGROUP:TurnOffICLS()
self.icls.BeaconUnit:CommandDeactivateICLS() self.icls.BeaconUnit:CommandDeactivateICLS()
end end
self:I(self.lid..string.format("Switching ICLS OFF")) self:T(self.lid..string.format("Switching ICLS OFF"))
self.icls.On=false self.icls.On=false
end end
@ -3423,7 +3409,7 @@ function OPSGROUP:SwitchRadio(Frequency, Modulation)
self.radio.On=true self.radio.On=true
if self:IsInUtero() then 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 else
-- Give command -- Give command
@ -3458,7 +3444,7 @@ function OPSGROUP:TurnOffRadio()
-- Radio is off. -- Radio is off.
self.radio.On=false self.radio.On=false
self:I(self.lid..string.format("Switching radio OFF")) self:T(self.lid..string.format("Switching radio OFF"))
else else
self:E(self.lid.."ERROR: Radio can only be turned off for aircraft!") self:E(self.lid.."ERROR: Radio can only be turned off for aircraft!")
end end

View File

@ -27,6 +27,8 @@
-- @field #number ngrouping User defined number of units in the asset group. -- @field #number ngrouping User defined number of units in the asset group.
-- @field #table assets Squadron assets. -- @field #table assets Squadron assets.
-- @field #table missiontypes Capabilities (mission types and performances) of the squadron. -- @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 maintenancetime Time in seconds needed for maintenance of a returned flight.
-- @field #number repairtime Time in seconds for each -- @field #number repairtime Time in seconds for each
-- @field #string livery Livery of the squadron. -- @field #string livery Livery of the squadron.
@ -87,7 +89,7 @@ SQUADRON = {
--- SQUADRON class version. --- SQUADRON class version.
-- @field #string version -- @field #string version
SQUADRON.version="0.1.0" SQUADRON.version="0.5.0"
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TODO list -- TODO list
@ -315,7 +317,7 @@ function SQUADRON:AddMissionCapability(MissionTypes, Performance)
end end
-- Debug info. -- Debug info.
self:I(self.missiontypes) self:T2(self.missiontypes)
return self return self
end end
@ -400,6 +402,19 @@ function SQUADRON:SetFuelLowThreshold(LowFuel)
return self return self
end 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. --- Set airwing.
-- @param #SQUADRON self -- @param #SQUADRON self
-- @param Ops.AirWing#AIRWING Airwing The airwing. -- @param Ops.AirWing#AIRWING Airwing The airwing.
@ -409,7 +424,6 @@ function SQUADRON:SetAirwing(Airwing)
return self return self
end end
--- Add airwing asset to squadron. --- Add airwing asset to squadron.
-- @param #SQUADRON self -- @param #SQUADRON self
-- @param Ops.AirWing#AIRWING.SquadronAsset Asset The airwing asset. -- @param Ops.AirWing#AIRWING.SquadronAsset Asset The airwing asset.
@ -439,7 +453,7 @@ end
--- Get name of the squadron --- Get name of the squadron
-- @param #SQUADRON self -- @param #SQUADRON self
-- @return #sting Name of the squadron. -- @return #string Name of the squadron.
function SQUADRON:GetName() function SQUADRON:GetName()
return self.name return self.name
end end
@ -536,7 +550,7 @@ function SQUADRON:FetchTacan()
for channel,free in pairs(self.tacanChannel) do for channel,free in pairs(self.tacanChannel) do
if free then 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 self.tacanChannel[channel]=false
return channel return channel
end end
@ -549,7 +563,7 @@ end
-- @param #SQUADRON self -- @param #SQUADRON self
-- @param #number channel The channel that is available again. -- @param #number channel The channel that is available again.
function SQUADRON:ReturnTacan(channel) 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 self.tacanChannel[channel]=true
end end
@ -588,7 +602,7 @@ function SQUADRON:onafterStart(From, Event, To)
-- Short info. -- Short info.
local text=string.format("Starting SQUADRON", self.name) local text=string.format("Starting SQUADRON", self.name)
self:I(self.lid..text) self:T(self.lid..text)
-- Start the status monitoring. -- Start the status monitoring.
self:__Status(-1) self:__Status(-1)
@ -628,7 +642,7 @@ function SQUADRON:onafterStatus(From, Event, To)
end end
if not self:IsStopped() then if not self:IsStopped() then
self:__Status(-30) self:__Status(-60)
end end
end end
@ -745,13 +759,13 @@ function SQUADRON:CanMission(Mission)
-- On duty?= -- On duty?=
if not self:IsOnDuty() then 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 return false
end end
-- Check mission type. WARNING: This assumes that all assets of the squad can do the same mission types! -- 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 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 return false
end end
@ -761,7 +775,7 @@ function SQUADRON:CanMission(Mission)
if Mission.refuelSystem and Mission.refuelSystem==self.tankerSystem then if Mission.refuelSystem and Mission.refuelSystem==self.tankerSystem then
-- Correct refueling system. -- Correct refueling system.
else 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 return false
end end