From 731517dcf2b7ef83341179c7abf0e3dc7ac469ed Mon Sep 17 00:00:00 2001 From: funkyfranky Date: Wed, 12 Jun 2019 16:30:37 +0200 Subject: [PATCH] AB 1.0.3 --- Moose Development/Moose/Ops/Airboss.lua | 35 +++++++++----- Moose Development/Moose/Ops/Skipper.lua | 61 +++++++++++++++++++++++-- 2 files changed, 81 insertions(+), 15 deletions(-) diff --git a/Moose Development/Moose/Ops/Airboss.lua b/Moose Development/Moose/Ops/Airboss.lua index e6b13ad69..8ebe84dc4 100644 --- a/Moose Development/Moose/Ops/Airboss.lua +++ b/Moose Development/Moose/Ops/Airboss.lua @@ -1685,7 +1685,7 @@ AIRBOSS.MenuF10Root=nil --- Airboss class version. -- @field #string version -AIRBOSS.version="1.0.2" +AIRBOSS.version="1.0.3" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- TODO list @@ -3617,15 +3617,27 @@ function AIRBOSS:_CheckRecoveryTimes() if self:IsRecovering() and not recovery.OVER then - -- Set carrier to idle. - self:RecoveryStop() - state="closing now" + if #self.Qpattern>0 then + + local extmin=5*#self.Qpattern + recovery.STOP=recovery.STOP+extmin*60 + + local text=string.format("We still got flights in the pattern.\nRecovery time prolonged by %d minutes.\nNow get your act together and no more bolters!", extmin) + self:MessageToPattern(text, "AIRBOSS", "99", 10, false, nil) - -- Closed. - recovery.OPEN=false + else + + -- Set carrier to idle. + self:RecoveryStop() + state="closing now" + + -- Closed. + recovery.OPEN=false + + -- Window just closed. + recovery.OVER=true - -- Window just closed. - recovery.OVER=true + end else -- Carrier is already idle. @@ -3689,10 +3701,11 @@ function AIRBOSS:_CheckRecoveryTimes() --Debug info self:T(self.lid..string.format("Heading=%03d°, Wind=%03d° %.1f kts, Delta=%03d° ==> U-turn=%s", hdg, wind,UTILS.MpsToKnots(vwind), delta, tostring(uturn))) + + -- Time into the wind 1 day or if longer recovery time + the 5 min early. + local t=math.max(nextwindow.STOP-nextwindow.START+300, 60*60*24) - - -- Time into the wind + the 5 min early. - local t=nextwindow.STOP-nextwindow.START+300 + -- Recovery wind on deck in knots. local v=UTILS.KnotsToMps(nextwindow.SPEED) -- Check that we do not go above max possible speed. diff --git a/Moose Development/Moose/Ops/Skipper.lua b/Moose Development/Moose/Ops/Skipper.lua index 3d6ce938e..013d3dfd6 100644 --- a/Moose Development/Moose/Ops/Skipper.lua +++ b/Moose Development/Moose/Ops/Skipper.lua @@ -73,7 +73,7 @@ SKIPPER = { --- FlightControl class version. -- @field #string version -SKIPPER.version="0.0.1" +SKIPPER.version="0.0.2" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- TODO list @@ -135,6 +135,57 @@ function SKIPPER:New(carriername) -- From State --> Event --> To State self:AddTransition("Stopped", "Start", "Running") -- Start FSM. self:AddTransition("*", "Status", "*") -- Update status. + self:AddTransition("*", "IntruderAlert", "*") -- New intruder detected. + + ------------------------ + --- Pseudo Functions --- + ------------------------ + + --- Triggers the FSM event "Start". Starts the SKIPPER. Initializes parameters and starts event handlers. + -- @function [parent=#SKIPPER] Start + -- @param #SKIPPER self + + --- Triggers the FSM event "Start" after a delay. Starts the SKIPPER. Initializes parameters and starts event handlers. + -- @function [parent=#SKIPPER] __Start + -- @param #SKIPPER self + -- @param #number delay Delay in seconds. + + --- Triggers the FSM event "Stop". Stops the SKIPPER and all its event handlers. + -- @param #SKIPPER self + + --- Triggers the FSM event "Stop" after a delay. Stops the SKIPPER and all its event handlers. + -- @function [parent=#SKIPPER] __Stop + -- @param #SKIPPER self + -- @param #number delay Delay in seconds. + + --- Triggers the FSM event "Status". + -- @function [parent=#SKIPPER] Status + -- @param #SKIPPER self + + --- Triggers the FSM event "Status" after a delay. + -- @function [parent=#SKIPPER] __Status + -- @param #SKIPPER self + -- @param #number delay Delay in seconds. + + --- Triggers the FSM event "IntruderAlert". + -- @function [parent=#SKIPPER] IntruderAlert + -- @param #SKIPPER self + -- @param #SKIPPER.Intruder Intruder data table. + + --- Triggers the FSM delayed event "IntruderAlert". + -- @function [parent=#SKIPPER] __IntruderAlert + -- @param #SKIPPER self + -- @param #number delay Delay in seconds before the function is called. + -- @param #SKIPPER.Intruder Intruder data table + + --- On after "IntruderAlert" event user function. Called when a missile was launched. + -- @function [parent=#SKIPPER] OnAfterIntruderAlert + -- @param #SKIPPER self + -- @param #string From From state. + -- @param #string Event Event. + -- @param #string To To state. + -- @param #SKIPPER.Intruder Intruder data table. + -- Debug trace. if true then @@ -142,10 +193,9 @@ function SKIPPER:New(carriername) BASE:TraceOnOff(true) BASE:TraceClass(self.ClassName) BASE:TraceLevel(3) + self.arty:GetAmmo(true) end - - self.arty:GetAmmo(true) - + return self end @@ -348,6 +398,9 @@ function SKIPPER:_CheckIntruder() -- Add intruder to list. table.insert(self.intruders, intruder) + -- Trigger alert! + self:IntruderAlert(intruder) + end end