From 4ae586ebaa19c7ee40fc4eb8f52087149fc91865 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Tue, 19 Jul 2022 08:10:54 +0200 Subject: [PATCH] Controllable/Beacon - added function to switch on Link4 A2A - typo in documentation --- .../Moose/AI/AI_A2A_Dispatcher.lua | 2 +- Moose Development/Moose/Core/Beacon.lua | 26 +++++++++++++++++ .../Moose/Wrapper/Controllable.lua | 28 +++++++++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/Moose Development/Moose/AI/AI_A2A_Dispatcher.lua b/Moose Development/Moose/AI/AI_A2A_Dispatcher.lua index fe53bfe28..0ba77d4ea 100644 --- a/Moose Development/Moose/AI/AI_A2A_Dispatcher.lua +++ b/Moose Development/Moose/AI/AI_A2A_Dispatcher.lua @@ -425,7 +425,7 @@ do -- AI_A2A_DISPATCHER -- * @{#AI_A2A_DISPATCHER.SetSquadronTakeoffFromParkingHot}() will spawn new aircraft in with running engines at a parking spot at the airfield. -- * @{#AI_A2A_DISPATCHER.SetSquadronTakeoffFromRunway}() will spawn new aircraft at the runway at the airfield. -- - -- **The default landing method is to spawn new aircraft directly in the air.** + -- **The default take-off method is to spawn new aircraft directly in the air.** -- -- Use these methods to fine-tune for specific airfields that are known to create bottlenecks, or have reduced airbase efficiency. -- The more and the longer aircraft need to taxi at an airfield, the more risk there is that: diff --git a/Moose Development/Moose/Core/Beacon.lua b/Moose Development/Moose/Core/Beacon.lua index 98e2032af..23094ea88 100644 --- a/Moose Development/Moose/Core/Beacon.lua +++ b/Moose Development/Moose/Core/Beacon.lua @@ -245,6 +245,32 @@ function BEACON:ActivateICLS(Channel, Callsign, Duration) return self end +--- Activates a LINK4 BEACON. The unit the BEACON is attached to should be an aircraft carrier supporting this system. +-- @param #BEACON self +-- @param #number Frequency LINK4 FRequency in MHz, eg 336. +-- @param #string Morse The ID that is going to be coded in Morse and broadcasted by the beacon. +-- @param #number Duration How long will the beacon last in seconds. Omit for forever. +-- @return #BEACON self +function BEACON:ActivateLink4(Frequency, Morse, Duration) + self:F({Frequency=Frequency, Morse=Morse, Duration=Duration}) + + -- Attached unit. + local UnitID=self.Positionable:GetID() + + -- Debug + self:T2({"LINK4 BEACON started!"}) + + -- Start beacon. + self.Positionable:CommandActivateLink4(Frequency,UnitID,Morse) + + -- Stop sheduler + if Duration then -- Schedule the stop of the BEACON if asked by the MD + self.Positionable:DeactivateBeacon(Duration) + end + + return self +end + --- DEPRECATED: Please use @{BEACON:ActivateTACAN}() instead. -- Activates a TACAN BEACON on an Aircraft. -- @param #BEACON self diff --git a/Moose Development/Moose/Wrapper/Controllable.lua b/Moose Development/Moose/Wrapper/Controllable.lua index 3e280a09d..cd7d812eb 100644 --- a/Moose Development/Moose/Wrapper/Controllable.lua +++ b/Moose Development/Moose/Wrapper/Controllable.lua @@ -697,6 +697,34 @@ function CONTROLLABLE:CommandActivateICLS( Channel, UnitID, Callsign, Delay ) return self end +--- Activate LINK4 system of the CONTROLLABLE. The controllable should be an aircraft carrier! +-- @param #CONTROLLABLE self +-- @param #number Frequency Link4 Frequency in MHz, e.g. 336 +-- @param #number UnitID The ID of the unit the ICLS system is attached to. Useful if more units are in one group. +-- @param #string Callsign Morse code identification callsign. +-- @param #number Delay (Optional) Delay in seconds before the ICLS is deactivated. +-- @return #CONTROLLABLE self +function CONTROLLABLE:CommandActivateLink4(Frequency, UnitID, Callsign, Delay) + + -- Command to activate Link4 system. + local CommandActivateLink4= { + id = "ActivateLink4", + params= { + ["frequency "] = Frequency*1000, + ["unitId"] = UnitID, + ["name"] = Callsign, + } + } + + if Delay and Delay>0 then + SCHEDULER:New(nil, self.CommandActivateLink4, {self}, Delay) + else + self:SetCommand(CommandActivateLink4) + end + + return self +end + --- Deactivate the active beacon of the CONTROLLABLE. -- @param #CONTROLLABLE self -- @param #number Delay (Optional) Delay in seconds before the beacon is deactivated.