From dee7307adc693f696f73d0bbf47799b897421d4a Mon Sep 17 00:00:00 2001 From: Frank Date: Wed, 19 Aug 2020 01:06:28 +0200 Subject: [PATCH] Ops --- Moose Development/Moose/Ops/AirWing.lua | 5 +-- Moose Development/Moose/Ops/Auftrag.lua | 32 ++++++++++++------- Moose Development/Moose/Ops/FlightGroup.lua | 1 + Moose Development/Moose/Ops/OpsGroup.lua | 23 +++++-------- Moose Development/Moose/Ops/Squadron.lua | 10 ++---- .../Moose/Utilities/Profiler.lua | 23 ++++++++++--- 6 files changed, 53 insertions(+), 41 deletions(-) diff --git a/Moose Development/Moose/Ops/AirWing.lua b/Moose Development/Moose/Ops/AirWing.lua index d88e65a85..52214c1f2 100644 --- a/Moose Development/Moose/Ops/AirWing.lua +++ b/Moose Development/Moose/Ops/AirWing.lua @@ -1604,8 +1604,9 @@ function AIRWING:onafterAssetSpawned(From, Event, To, group, asset, request) flightgroup:SwitchRadio(radioFreq, radioModu) end - -- Set RTB on fuel critical. - flightgroup:SetFuelCriticalThreshold() + if squadron.fuellow then + flightgroup:SetFuelCriticalThreshold(squadron.fuellow) + end --- -- Mission diff --git a/Moose Development/Moose/Ops/Auftrag.lua b/Moose Development/Moose/Ops/Auftrag.lua index 5733adf65..e3345c937 100644 --- a/Moose Development/Moose/Ops/Auftrag.lua +++ b/Moose Development/Moose/Ops/Auftrag.lua @@ -1425,7 +1425,7 @@ end -- @param #AUFTRAG self -- @param #number Nrepeat Number of repeats. Default 0. -- @return #AUFTRAG self -function AUFTRAG:SetRepeatOnFailure(Nrepeat) +function AUFTRAG:SetRepeat(Nrepeat) self.Nrepeat=Nrepeat or 0 return self end @@ -2599,19 +2599,25 @@ 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.repeatedSuccess>=self.NrepeatSuccess then + local repeatme=self.repeatedFailure=%d] ==> Stopping mission!", self.repeatedSuccess, self.NrepeatSuccess)) - self:Stop() + if repeatme then + + -- Increase counter. + self.repeatedSuccess=self.repeatedSuccess+1 + + -- Number of repeats. + local N=math.max(self.NrepeatSuccess, self.Nrepeat) + + -- Repeat mission. + self:I(self.lid..string.format("Mission SUCCESS! Repeating mission for the %d time (max %d times) ==> Repeat mission!", self.repeated+1, N)) + self:Repeat() else - self.repeatedSuccess=self.repeatedSuccess+1 - - -- Repeat mission. - self:I(self.lid..string.format("Mission SUCCESS! Repeating mission for the %d time (max %d times) ==> Repeat mission!", self.repeatedSuccess, self.NrepeatSuccess)) - self:Repeat() + -- Stop mission. + self:I(self.lid..string.format("Mission SUCCESS! Number of max repeats %d reached ==> Stopping mission!", self.repeated+1)) + self:Stop() end @@ -2629,19 +2635,21 @@ function AUFTRAG:onafterFailed(From, Event, To) local repeatme=self.repeatedFailure=self.NrepeatFailure then + if repeatme then + -- Increase counter. self.repeatedFailure=self.repeatedFailure+1 + -- Number of repeats. local N=math.max(self.NrepeatFailure, self.Nrepeat) -- Repeat mission. self:I(self.lid..string.format("Mission FAILED! Repeating mission for the %d time (max %d times) ==> Repeat mission!", self.repeated+1, N)) self:Repeat() - else + -- Stop mission. self:I(self.lid..string.format("Mission FAILED! Number of max repeats %d reached ==> Stopping mission!", self.repeated+1)) self:Stop() diff --git a/Moose Development/Moose/Ops/FlightGroup.lua b/Moose Development/Moose/Ops/FlightGroup.lua index 221c09112..b3ecb9298 100644 --- a/Moose Development/Moose/Ops/FlightGroup.lua +++ b/Moose Development/Moose/Ops/FlightGroup.lua @@ -226,6 +226,7 @@ function FLIGHTGROUP:New(group) self.lid=string.format("FLIGHTGROUP %s | ", self.groupname) -- Defaults + self:SetVerbosity(3) self:SetFuelLowThreshold() self:SetFuelLowRTB() self:SetFuelCriticalThreshold() diff --git a/Moose Development/Moose/Ops/OpsGroup.lua b/Moose Development/Moose/Ops/OpsGroup.lua index 051f31476..6b64b3d73 100644 --- a/Moose Development/Moose/Ops/OpsGroup.lua +++ b/Moose Development/Moose/Ops/OpsGroup.lua @@ -3227,22 +3227,15 @@ function OPSGROUP:TurnOffTACAN() end - ---- Set default ICLS parameters. +--- Get current TACAN parameters. -- @param #OPSGROUP self --- @param #number Channel ICLS channel. --- @param #string Morse Morse code. Default "XXX". --- @param #string UnitName Name of the unit acting as beacon. --- @param #string Band ICLS mode. Default is "X" for ground and "Y" for airborne units. --- @return #OPSGROUP self -function OPSGROUP:SetDefaultICLS(Channel, Morse, UnitName) - - self.iclsDefault={} - self.iclsDefault.Channel=Channel - self.iclsDefault.Morse=Morse or "XXX" - self.iclsDefault.BeaconName=UnitName - - return self +-- @return #number TACAN channel. +-- @return #string TACAN Morse code. +-- @return #string TACAN band ("X" or "Y"). +-- @return #boolean TACAN is On (true) or Off (false). +-- @return #string UnitName Name of the unit acting as beacon. +function OPSGROUP:GetTACAN() + return self.tacan.Channel, self.tacan.Morse, self.tacan.Band, self.tacan.On, self.tacan.BeaconName end --- Activate/switch ICLS beacon settings. diff --git a/Moose Development/Moose/Ops/Squadron.lua b/Moose Development/Moose/Ops/Squadron.lua index e1ff5f966..2b7bdbc4f 100644 --- a/Moose Development/Moose/Ops/Squadron.lua +++ b/Moose Development/Moose/Ops/Squadron.lua @@ -41,9 +41,7 @@ -- @field #string attribute Generalized attribute of the squadron template group. -- @field #number tankerSystem For tanker squads, the refuel system used (boom=0 or probpe=1). Default nil. -- @field #number refuelSystem For refuelable squads, the refuel system used (boom=0 or probpe=1). Default nil. --- @field #number TACANmin TACAN min channel. --- @field #number TACANmax TACAN max channel. --- @field #table TACANused Table of used TACAN channels. +-- @field #table tacanChannel List of TACAN channels available to the squadron. -- @field #number radioFreq Radio frequency in MHz the squad uses. -- @field #number radioModu Radio modulation the squad uses. -- @extends Core.Fsm#FSM @@ -84,9 +82,7 @@ SQUADRON = { engageRange = nil, tankerSystem = nil, refuelSystem = nil, - TACANmin = nil, - TACANmax = nil, - TACANused = {}, + tacanChannel = {}, } --- SQUADRON class version. @@ -399,7 +395,7 @@ end -- @param #SQUADRON self -- @param #number LowFuel Low fuel threshold in percent. Default 25. -- @return #SQUADRON self -function SQUADRON:SetLowFuelThreshold(LowFuel) +function SQUADRON:SetFuelLowThreshold(LowFuel) self.fuellow=LowFuel or 25 return self end diff --git a/Moose Development/Moose/Utilities/Profiler.lua b/Moose Development/Moose/Utilities/Profiler.lua index 639e7174a..c1667bc3b 100644 --- a/Moose Development/Moose/Utilities/Profiler.lua +++ b/Moose Development/Moose/Utilities/Profiler.lua @@ -289,10 +289,10 @@ function PROFILER.showTable(data, f, runTimeGame) -- Calls per second. local cps=t.count/runTimeGame - if (cps>=PROFILER.lowCpsThres) then + if cps>=PROFILER.lowCpsThres then -- Output - local text=string.format("%30s: %8d calls %8.1f/sec - Time %8.3f sec (%.3f %%) %s line %s", t.func, t.count, cps, t.tm, t.tm/runTimeGame*100, tostring(t.src), tostring(t.line)) + local text=string.format("%30s: %8d calls %8.1f/sec - Time Total %8.3f sec (%.3f %%) - Per call %5.3f sec %s line %s", t.func, t.count, cps, t.tm, t.tm/runTimeGame*100, t.tm/t.count, tostring(t.src), tostring(t.line)) PROFILER._flog(f, text) end @@ -455,6 +455,19 @@ function PROFILER.showInfo(runTimeGame, runTimeOS) PROFILER._flog(f,"************************************************************************************************************************") PROFILER._flog(f,"") PROFILER.showTable(t, f, runTimeGame) + + -- Sort by number of calls. + table.sort(t, function(a,b) return a.tm/a.count>b.tm/b.count end) + + -- Detailed data. + PROFILER._flog(f,"") + PROFILER._flog(f,"************************************************************************************************************************") + PROFILER._flog(f,"") + PROFILER._flog(f,"--------------------------------------") + PROFILER._flog(f,"---- Data Sorted by Time per Call ----") + PROFILER._flog(f,"--------------------------------------") + PROFILER._flog(f,"") + PROFILER.showTable(t, f, runTimeGame) -- Sort by number of calls. table.sort(t, function(a,b) return a.count>b.count end) @@ -463,9 +476,9 @@ function PROFILER.showInfo(runTimeGame, runTimeOS) PROFILER._flog(f,"") PROFILER._flog(f,"************************************************************************************************************************") PROFILER._flog(f,"") - PROFILER._flog(f,"------------------------------") - PROFILER._flog(f,"---- Data Sorted by Calls ----") - PROFILER._flog(f,"------------------------------") + PROFILER._flog(f,"------------------------------------") + PROFILER._flog(f,"---- Data Sorted by Total Calls ----") + PROFILER._flog(f,"------------------------------------") PROFILER._flog(f,"") PROFILER.showTable(t, f, runTimeGame)