Merge branch 'master' into FF/MasterDevel

This commit is contained in:
Frank
2024-06-29 13:59:50 +02:00
9 changed files with 337 additions and 166 deletions

View File

@@ -63,6 +63,8 @@
-- @field #number power Radio power in Watts. Default 100 W.
-- @field Sound.RadioQueue#RADIOQUEUE radioqueue Radio queue for broadcasing messages.
-- @field #string soundpath Path to sound files.
-- @field #string soundpathAirports Path to airport names sound files.
-- @field #string soundpathNato Path to NATO alphabet sound files.
-- @field #string relayunitname Name of the radio relay unit.
-- @field #table towerfrequency Table with tower frequencies.
-- @field #string activerunway The active runway specified by the user.
@@ -315,18 +317,18 @@
-- atis:Start()
--
-- This uses a male voice with US accent. It requires SRS to be installed in the `D:\DCS\_SRS\` directory. Note that backslashes need to be escaped or simply use slashes (as in linux).
--
-- ### SRS can use multiple frequencies:
--
--
-- ### SRS can use multiple frequencies:
--
-- atis=ATIS:New("Batumi", {305,103.85}, {radio.modulation.AM,radio.modulation.FM})
-- atis:SetSRS("D:\\DCS\\_SRS\\", "male", "en-US")
-- atis:Start()
--
--
-- ### SRS Localization
--
--
-- You can localize the SRS output, all you need is to provide a table of translations and set the `locale` of your instance. You need to provide the translations in your script **before you instantiate your ATIS**.
-- The German localization (already provided in the code) e.g. looks like follows:
--
--
-- ATIS.Messages.DE =
-- {
-- HOURS = "Uhr",
@@ -387,13 +389,13 @@
-- FARP = "Farp",
-- DELIMITER = "Komma", -- decimal delimiter
-- }
--
--
-- Then set up your ATIS and set the locale:
--
--
-- atis=ATIS:New("Batumi", 305, radio.modulation.AM)
-- atis:SetSRS("D:\\DCS\\_SRS\\", "female", "de_DE")
-- atis:SetLocale("de") -- available locales from source are "en", "de" and "es"
-- atis:Start()
-- atis:Start()
--
-- ## FARPS
--
@@ -1081,12 +1083,24 @@ function ATIS:SetLocale(locale)
return self
end
--- Set sound files folder within miz file.
--- Set sound files folder within miz file (not your local hard drive!).
-- @param #ATIS self
-- @param #string path Path for sound files. Default "ATIS Soundfiles/". Mind the slash "/" at the end!
-- @param #string pathMain Path to folder containing main sound files. Default "ATIS Soundfiles/". Mind the slash "/" at the end!
-- @param #string pathAirports Path folder containing the airport names sound files. Default is `"ATIS Soundfiles/<Map Name>"`, *e.g.* `"ATIS Soundfiles/Caucasus/"`.
-- @param #string pathNato Path folder containing the NATO alphabet sound files. Default is "ATIS Soundfiles/NATO Alphabet/".
-- @return #ATIS self
function ATIS:SetSoundfilesPath( path )
self.soundpath = tostring( path or "ATIS Soundfiles/" )
function ATIS:SetSoundfilesPath( pathMain, pathAirports, pathNato )
self.soundpath = tostring( pathMain or "ATIS Soundfiles/" )
if pathAirports==nil then
self.soundpathAirports=self.soundpath..env.mission.theatre.."/"
else
self.soundpathAirports=pathAirports
end
if pathNato==nil then
self.soundpathNato=self.soundpath.."NATO Alphabet/"
else
self.soundpathNato=pathNato
end
self:T( self.lid .. string.format( "Setting sound files path to %s", self.soundpath ) )
return self
end
@@ -1111,23 +1125,23 @@ function ATIS:SetSoundfilesInfoFile( csvfile )
-- Read csv file
local data=UTILS.ReadCSV(csvfile)
if data then
for i,sound in pairs(data) do
-- Get the ATIS.Soundfile
local soundfile=getSound(sound.filename..".ogg") --#ATIS.Soundfile
if soundfile then
-- Set duration
soundfile.duration=tonumber(sound.duration)
else
self:E(string.format("ERROR: Could not get info for sound file %s", sound.filename))
end
end
else
self:E(string.format("ERROR: Could not read sound csv file!"))
@@ -1587,13 +1601,13 @@ end
function ATIS:SetSRS(PathToSRS, Gender, Culture, Voice, Port, GoogleKey)
--if PathToSRS or MSRS.path then
self.useSRS=true
local path = PathToSRS or MSRS.path
local gender = Gender or MSRS.gender
local culture = Culture or MSRS.culture
local voice = Voice or MSRS.voice
local port = Port or MSRS.port or 5002
self.msrs=MSRS:New(path, self.frequency, self.modulation)
self.msrs:SetGender(gender)
self.msrs:SetCulture(culture)
@@ -1958,7 +1972,7 @@ function ATIS:onafterBroadcast( From, Event, To )
--------------------------
--- Sunrise and Sunset ---
--------------------------
local hours = self.gettext:GetEntry("HOURS",self.locale)
local sunrise = coord:GetSunrise()
sunrise = UTILS.Split( sunrise, ":" )
@@ -2059,10 +2073,45 @@ function ATIS:onafterBroadcast( From, Event, To )
-- Cloud preset (DCS 2.7)
local cloudspreset = clouds.preset or "Nothing"
env.info("FF cloud preset "..cloudspreset)
-- Precepitation: 0=None, 1=Rain, 2=Thunderstorm, 3=Snow, 4=Snowstorm.
local precepitation = 0
if cloudspreset:find( "Preset10" ) then
if cloudspreset:find( "RainyPreset1" ) then
-- Overcast + Rain
clouddens = 9
if temperature > 5 then
precepitation = 1 -- rain
else
precepitation = 3 -- snow
end
elseif cloudspreset:find( "RainyPreset2" ) then
-- Overcast + Rain
clouddens = 9
if temperature > 5 then
precepitation = 1 -- rain
else
precepitation = 3 -- snow
end
elseif cloudspreset:find( "RainyPreset3" ) then
-- Overcast + Rain
clouddens = 9
if temperature > 5 then
precepitation = 1 -- rain
else
precepitation = 3 -- snow
end
env.info("Fprecipt "..precepitation)
elseif cloudspreset:find( "RainyPreset" ) then
-- Overcast + Rain
clouddens = 9
if temperature > 5 then
precepitation = 1 -- rain
else
precepitation = 3 -- snow
end
elseif cloudspreset:find( "Preset10" ) then
-- Scattered 5
clouddens = 4
elseif cloudspreset:find( "Preset11" ) then
@@ -2143,38 +2192,8 @@ function ATIS:onafterBroadcast( From, Event, To )
elseif cloudspreset:find( "Preset9" ) then
-- Scattered 4
clouddens = 4
elseif cloudspreset:find( "RainyPreset" ) then
-- Overcast + Rain
clouddens = 9
if temperature > 5 then
precepitation = 1 -- rain
else
precepitation = 3 -- snow
end
elseif cloudspreset:find( "RainyPreset1" ) then
-- Overcast + Rain
clouddens = 9
if temperature > 5 then
precepitation = 1 -- rain
else
precepitation = 3 -- snow
end
elseif cloudspreset:find( "RainyPreset2" ) then
-- Overcast + Rain
clouddens = 9
if temperature > 5 then
precepitation = 1 -- rain
else
precepitation = 3 -- snow
end
elseif cloudspreset:find( "RainyPreset3" ) then
-- Overcast + Rain
clouddens = 9
if temperature > 5 then
precepitation = 1 -- rain
else
precepitation = 3 -- snow
end
else
self:E(string.format("WARNING! Unknown weather preset: %s", tostring(cloudspreset)))
end
local CLOUDBASE = string.format( "%d", UTILS.MetersToFeet( cloudbase ) )
@@ -2249,7 +2268,7 @@ function ATIS:onafterBroadcast( From, Event, To )
end
if not self.useSRS then
--self:I(string.format( "%s/%s.ogg", self.theatre, self.airbasename ))
self.radioqueue:NewTransmission( string.format( "%s/%s.ogg", self.theatre, self.airbasename ), 3.0, self.soundpath, nil, nil, subtitle, self.subduration )
self.radioqueue:NewTransmission( string.format( "%s.ogg", self.airbasename ), 3.0, self.soundpathAirports, nil, nil, subtitle, self.subduration )
end
local alltext = subtitle
@@ -2260,7 +2279,7 @@ function ATIS:onafterBroadcast( From, Event, To )
local _INFORMATION = subtitle
if not self.useSRS then
self:Transmission( self.Sound.Information, 0.5, subtitle )
self.radioqueue:NewTransmission( string.format( "NATO Alphabet/%s.ogg", NATO ), 0.75, self.soundpath )
self.radioqueue:NewTransmission( string.format( "%s.ogg", NATO ), 0.75, self.soundpathNato )
end
alltext = alltext .. ";\n" .. subtitle
@@ -2616,9 +2635,9 @@ function ATIS:onafterBroadcast( From, Event, To )
-- Active runway.
local subtitle = ""
if runwayLanding then
local actrun = self.gettext:GetEntry("ACTIVELANDING",self.locale)
subtitle=string.format("%s %s", actrun, runwayLanding)
if rwyLandingLeft==true then
subtitle=subtitle.." "..self.gettext:GetEntry("LEFT",self.locale)
@@ -2636,13 +2655,13 @@ function ATIS:onafterBroadcast( From, Event, To )
self:Transmission(self.Sound.Right, 0.2)
end
end
end
if runwayTakeoff then
local actrun = self.gettext:GetEntry("ACTIVERUN",self.locale)
subtitle=string.format("%s %s", actrun, runwayTakeoff)
if rwyTakeoffLeft==true then
subtitle=subtitle.." "..self.gettext:GetEntry("LEFT",self.locale)
@@ -2650,7 +2669,7 @@ function ATIS:onafterBroadcast( From, Event, To )
subtitle=subtitle.." "..self.gettext:GetEntry("RIGHT",self.locale)
end
alltext = alltext .. ";\n" .. subtitle
if not self.useSRS then
self:Transmission(self.Sound.ActiveRunwayDeparture, 1.0, subtitle)
self.radioqueue:Number2Transmission(runwayTakeoff)
@@ -2660,8 +2679,8 @@ function ATIS:onafterBroadcast( From, Event, To )
self:Transmission(self.Sound.Right, 0.2)
end
end
end
_RUNACT = subtitle
alltext = alltext .. ";\n" .. subtitle
@@ -2710,14 +2729,14 @@ function ATIS:onafterBroadcast( From, Event, To )
alltext = alltext .. ";\n" .. subtitle
end
end
-- Airfield elevation
if self.elevation then
local elev = self.gettext:GetEntry("ELEVATION",self.locale)
local meters = self.gettext:GetEntry("METERS",self.locale)
local feet = self.gettext:GetEntry("FEET",self.locale)
local elevation = self.airbase:GetHeight()
if not self.metric then
elevation = UTILS.MetersToFeet( elevation )
@@ -2875,7 +2894,7 @@ function ATIS:onafterBroadcast( From, Event, To )
if not self.useSRS then
self:Transmission( self.Sound.TACANChannel, 1.0, subtitle )
self.radioqueue:Number2Transmission( tostring( self.tacan ), nil, 0.2 )
self.radioqueue:NewTransmission( "NATO Alphabet/Xray.ogg", 0.75, self.soundpath, nil, 0.2 )
self.radioqueue:NewTransmission( "Xray.ogg", 0.75, self.soundpathNato, nil, 0.2 )
end
alltext = alltext .. ";\n" .. subtitle
end
@@ -2916,7 +2935,7 @@ function ATIS:onafterBroadcast( From, Event, To )
subtitle = string.format( "%s %s", advtxt, NATO )
if not self.useSRS then
self:Transmission( self.Sound.AdviceOnInitial, 0.5, subtitle )
self.radioqueue:NewTransmission( string.format( "NATO Alphabet/%s.ogg", NATO ), 0.75, self.soundpath )
self.radioqueue:NewTransmission( string.format( "%s.ogg", NATO ), 0.75, self.soundpathNato )
end
alltext = alltext .. ";\n" .. subtitle
@@ -2955,8 +2974,8 @@ function ATIS:onafterReport( From, Event, To, Text )
local emes = self.gettext:GetEntry("METERSPER",self.locale)
local tacan = self.gettext:GetEntry("TACAN",self.locale)
local farp = self.gettext:GetEntry("FARP",self.locale)
local text = string.gsub( text, "SM", statute )
text = string.gsub( text, "°C", degc )
text = string.gsub( text, "°F", degf )
@@ -2966,13 +2985,13 @@ function ATIS:onafterReport( From, Event, To, Text )
text = string.gsub( text, "m/s", emes )
text = string.gsub( text, "TACAN", tacan )
text = string.gsub( text, "FARP", farp )
local delimiter = self.gettext:GetEntry("DELIMITER",self.locale)
if string.lower(self.locale) ~= "en" then
text = string.gsub(text,"(%d+)(%.)(%d+)","%1 "..delimiter.." %3")
end
-- Replace ";" by "."
local text = string.gsub( text, ";", " . " )
@@ -3171,7 +3190,7 @@ end
-- @param #ATIS.Soundfile sound ATIS sound object.
-- @param #number interval Interval in seconds after the last transmission finished.
-- @param #string subtitle Subtitle of the transmission.
-- @param #string path Path to sound file. Default self.soundpath.
-- @param #string path Path to sound file. Default `self.soundpath`.
function ATIS:Transmission( sound, interval, subtitle, path )
self.radioqueue:NewTransmission( sound.filename, sound.duration, path or self.soundpath, nil, interval, subtitle, self.subduration )
end