From cff9557217e63aa5aa2115e43fc2c2da2698f404 Mon Sep 17 00:00:00 2001 From: Frank Date: Thu, 14 Feb 2019 00:53:22 +0100 Subject: [PATCH] AB v0.9.8 wip --- Moose Development/Moose/Ops/Airboss.lua | 188 +++++++++++++++++++++--- 1 file changed, 164 insertions(+), 24 deletions(-) diff --git a/Moose Development/Moose/Ops/Airboss.lua b/Moose Development/Moose/Ops/Airboss.lua index fde40b486..20374dd40 100644 --- a/Moose Development/Moose/Ops/Airboss.lua +++ b/Moose Development/Moose/Ops/Airboss.lua @@ -203,6 +203,7 @@ -- @field #number dTbeacon Time interval to refresh the beacons. Default 5 minutes. -- @field #AIRBOSS.LSOCalls LSOCall Radio voice overs of the LSO. -- @field #AIRBOSS.MarshalCalls MarshalCall Radio voice over of the Marshal/Airboss. +-- @field #number lowfuelAI Low fuel threshold for AI groups in percent. -- @extends Core.Fsm#FSM --- Be the boss! @@ -1002,6 +1003,7 @@ AIRBOSS = { Tbeacon = nil, LSOCall = nil, MarshalCall = nil, + lowfuelAI = nil, } --- Aircraft types capable of landing on carrier (human+AI). @@ -2756,6 +2758,23 @@ end -- @param #AIRBOSS self function AIRBOSS:_CheckAIStatus() + -- Loop over all flights in Marshal stack. + for _,_flight in pairs(self.Qmarshal) do + local flight=_flight --#AIRBOSS.FlightGroup + + -- Only AI! + if flight.ai then + + -- TODO: Check that aircraft can be refueled. + local fuel=flight.group:GetFuelMin()*100 + + if self.lowfuelAI and fuelmath.abs(gd.LUE) then - self:T(self.lid..string.format("Got bigger Linue up error at %s: LUE %.3f>%.3f.", gs, lineupError, gd.LUE)) + self:T(self.lid..string.format("Got bigger Lineup error at %s: LUE %.3f>%.3f.", gs, lineupError, gd.LUE)) gd.LUE=lineupError end @@ -11508,6 +11607,36 @@ function AIRBOSS._ReachedHoldingZone(group, airboss, flight) end end +--- Function called when a group should be send to the Marshal stack. If stack is full, it is send to wait. +--@param Wrapper.Group#GROUP group Group that reached the holding zone. +--@param #AIRBOSS airboss Airboss object. +--@param #AIRBOSS.FlightGroup flight Flight group that has reached the holding zone. +function AIRBOSS._TaskFunctionMarshalAI(group, airboss, flight) + + -- Debug message. + local text=string.format("Flight %s is send to marshal.", group:GetName()) + MESSAGE:New(text,10):ToAllIf(airboss.Debug) + airboss:T(airboss.lid..text) + + -- Get the next free stack for current recovery case. + local stack=airboss:_GetFreeStack(flight.ai) + + if stack then + + -- Send AI to marshal stack. + airboss:_MarshalAI(flight, stack) + + else + + -- Send AI to orbit outside 10 NM zone and wait until the next Marshal stack is available. + if not airboss:_InQueue(airboss.Qwaiting, flight.group) then + airboss:_WaitAI(flight) + end + + end + +end + ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- MISC functions ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -11981,6 +12110,10 @@ end function AIRBOSS:RadioTransmission(radio, call, loud, delay) self:F2({radio=radio, call=call, loud=loud, delay=delay}) + if radio==nil or call==nil then + return + end + -- Create a new radio transmission item. local transmission={} --#AIRBOSS.Radioitem @@ -12577,18 +12710,24 @@ end -- @param #string charlie Charlie Time estimate. -- @param #string qfe Alitmeter inHg. function AIRBOSS:_MarshalCallArrived(modex, case, brc, altitude, charlie, qfe) + self:E({modex=modex,case=case,brc=brc,altitude=altitude,charlie=charlie,qfe=qfe}) -- Split strings etc. local angels=self:_GetAngels(altitude) - local QFE=UTILS.Split(tostring(qfe), ".") - local CT=UTILS.Split(select(1, UTILS.Split(alitmeter, "+")), ":") + local QFE=UTILS.Split(tostring(UTILS.Round(qfe,2)), ".") + local clock=UTILS.Split(charlie, "+") + self:E({clock=clock}) + local CT=UTILS.Split(clock[1], ":") -- Subtitle text. local text=string.format("Case %d, expected BRC %03d°, hold at angels %d. Expected Charlie Time %s.\n", case, brc, angels, charlie) text=text..string.format("Altimeter %.2f. Report see me.", qfe) -- Create new call to display complete subtitle. - local casecall=self:_NewRadioCall(self.MarshalCall.CASE, "MARSHAL", text, self.Tmessage, modex) + --local casecall=self:_NewRadioCall(self.MarshalCall.CASE, "MARSHAL", text, self.Tmessage, modex) + + -- Until we have a case sound we take the noise for testing + local casecall=self:_NewRadioCall(self.MarshalCall.NOISE, "MARSHAL", text, self.Tmessage, modex) -- Case.. self:RadioTransmission(self.MarshalRadio, casecall) @@ -12599,7 +12738,7 @@ function AIRBOSS:_MarshalCallArrived(modex, case, brc, altitude, charlie, qfe) -- BRC.. self:RadioTransmission(self.MarshalRadio, self.MarshalCall.BRC) -- XYZ.. - self:_Number2Radio(self.MarshalRadio, string.format("%d03", brc)) + self:_Number2Radio(self.MarshalRadio, string.format("%03d", brc)) -- hold at.. self:RadioTransmission(self.MarshalRadio, self.MarshalCall.HOLDAT) -- angels.. @@ -12624,7 +12763,8 @@ function AIRBOSS:_MarshalCallArrived(modex, case, brc, altitude, charlie, qfe) self:_Number2Radio(self.MarshalRadio, QFE[2]) -- Report see me. self:RadioTransmission(self.MarshalRadio, self.MarshalCall.REPORTSEEME) - + -- Click! + self:RadioTransmission(self.MarshalRadio, self.MarshalCall.CLICK) end -----------------------------------------------------------------------------------------------------------------------------------------------------------------------