mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Merge pull request #1252 from FlightControl-Master/FF/Develop
ATIS v0.6.2 and Misc
This commit is contained in:
commit
ff0f62c01b
@ -1215,11 +1215,11 @@ do -- COORDINATE
|
||||
-- @param #COORDINATE self
|
||||
-- @param #number Speed (optional) Speed in km/h. The default speed is 20 km/h.
|
||||
-- @param #string Formation (optional) The route point Formation, which is a text string that specifies exactly the Text in the Type of the route point, like "Vee", "Echelon Right".
|
||||
-- @param #table DCSTasks A table of DCS tasks that are executed at the waypoints. Mind the curly brackets {}!
|
||||
-- @return #table The route point.
|
||||
function COORDINATE:WaypointGround( Speed, Formation )
|
||||
function COORDINATE:WaypointGround( Speed, Formation, DCSTasks )
|
||||
self:F2( { Formation, Speed } )
|
||||
|
||||
|
||||
local RoutePoint = {}
|
||||
RoutePoint.x = self.x
|
||||
RoutePoint.y = self.z
|
||||
@ -1242,12 +1242,10 @@ do -- COORDINATE
|
||||
-- }, -- end of ["params"]
|
||||
-- }, -- end of ["task"]
|
||||
|
||||
|
||||
RoutePoint.task = {}
|
||||
RoutePoint.task.id = "ComboTask"
|
||||
RoutePoint.task.params = {}
|
||||
RoutePoint.task.params.tasks = {}
|
||||
|
||||
RoutePoint.task.params.tasks = DCSTasks or {}
|
||||
|
||||
return RoutePoint
|
||||
end
|
||||
|
||||
@ -750,7 +750,7 @@ function ZONE_RADIUS:GetScannedUnits()
|
||||
end
|
||||
|
||||
|
||||
--- Count the number of different coalitions inside the zone.
|
||||
--- Get a set of scanned units.
|
||||
-- @param #ZONE_RADIUS self
|
||||
-- @return Core.Set#SET_UNIT Set of units and statics inside the zone.
|
||||
function ZONE_RADIUS:GetScannedSetUnit()
|
||||
@ -949,7 +949,6 @@ function ZONE_RADIUS:SearchZone( EvaluateFunction, ObjectCategories )
|
||||
|
||||
local function EvaluateZone( ZoneDCSUnit )
|
||||
|
||||
--env.info( ZoneDCSUnit:getName() )
|
||||
|
||||
local ZoneUnit = UNIT:Find( ZoneDCSUnit )
|
||||
|
||||
|
||||
@ -874,16 +874,23 @@ do -- ZONE_CAPTURE_COALITION
|
||||
self:Capture()
|
||||
end
|
||||
|
||||
-- Get red and blue unit sets.
|
||||
local unitsetRed=self:GetScannedSetUnit():FilterCoalitions(coalition.side.RED):FilterActive(true):FilterOnce()
|
||||
local unitsetBlu=self:GetScannedSetUnit():FilterCoalitions(coalition.side.BLUE):FilterActive(true):FilterOnce()
|
||||
|
||||
-- Count number of units.
|
||||
local nRed=unitsetRed:Count()
|
||||
local nBlu=unitsetBlu:Count()
|
||||
-- Count stuff in zone.
|
||||
local unitset=self:GetScannedSetUnit()
|
||||
local nRed=0
|
||||
local nBlue=0
|
||||
for _,object in pairs(unitset:GetSet()) do
|
||||
local coal=object:GetCoalition()
|
||||
if object:IsAlive() then
|
||||
if coal==coalition.side.RED then
|
||||
nRed=nRed+1
|
||||
elseif coal==coalition.side.BLUE then
|
||||
nBlue=nBlue+1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Status text.
|
||||
local text=string.format("CAPTURE ZONE %s: Owner=%s (Previous=%s): #blue=%d, #red=%d, Status %s", self:GetZoneName(), self:GetCoalitionName(), UTILS.GetCoalitionName(self:GetPreviousCoalition()), nBlu, nRed, State)
|
||||
local text=string.format("CAPTURE ZONE %s: Owner=%s (Previous=%s): #blue=%d, #red=%d, Status %s", self:GetZoneName(), self:GetCoalitionName(), UTILS.GetCoalitionName(self:GetPreviousCoalition()), nBlue, nRed, State)
|
||||
local NewState = self:GetState()
|
||||
if NewState~=State then
|
||||
text=text..string.format(" --> %s", NewState)
|
||||
|
||||
@ -82,6 +82,8 @@
|
||||
-- @field #number runwaym2t Optional correction for magnetic to true runway heading conversion (and vice versa) in degrees.
|
||||
-- @field #boolean windtrue Report true (from) heading of wind. Default is magnetic.
|
||||
-- @field #boolean altimeterQNH Report altimeter QNH.
|
||||
-- @field #boolean usemarker Use mark on the F10 map.
|
||||
-- @field #number markerid Numerical ID of the F10 map mark point.
|
||||
-- @extends Core.Fsm#FSM
|
||||
|
||||
--- *It is a very sad thing that nowadays there is so little useless information.* - Oscar Wilde
|
||||
@ -242,6 +244,10 @@
|
||||
--
|
||||
-- **Note** that the default folder name is *ATIS Soundfiles/*. If you want to change it, you can use the @{#ATIS.SetSoundfilesPath}(*path*), where *path* is the path of the directory. This must end with a slash "/"!
|
||||
--
|
||||
-- # Marks on the F10 Map
|
||||
--
|
||||
-- You can place marks on the F10 map via the @{#ATIS.SetMapMarks}() function. These will contain info about the ATIS frequency, the currently active runway and some basic info about the weather (wind, pressure and temperature).
|
||||
--
|
||||
-- # Examples
|
||||
--
|
||||
-- ## Caucasus: Batumi
|
||||
@ -309,6 +315,8 @@ ATIS = {
|
||||
runwaym2t = nil,
|
||||
windtrue = nil,
|
||||
altimeterQNH = nil,
|
||||
usemarker = nil,
|
||||
markerid = nil,
|
||||
}
|
||||
|
||||
--- NATO alphabet.
|
||||
@ -515,7 +523,7 @@ _ATIS={}
|
||||
|
||||
--- ATIS class version.
|
||||
-- @field #string version
|
||||
ATIS.version="0.6.1"
|
||||
ATIS.version="0.6.2"
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- TODO list
|
||||
@ -570,6 +578,7 @@ function ATIS:New(airbasename, frequency, modulation)
|
||||
self:SetRunwayCorrectionMagnetic2True()
|
||||
self:SetRadioPower()
|
||||
self:SetAltimeterQNH(true)
|
||||
self:SetMapMarks(false)
|
||||
|
||||
-- Start State.
|
||||
self:SetStartState("Stopped")
|
||||
@ -687,6 +696,19 @@ function ATIS:SetRadioPower(power)
|
||||
return self
|
||||
end
|
||||
|
||||
--- Use F10 map mark points.
|
||||
-- @param #ATIS self
|
||||
-- @param #boolean switch If *true* or *nil*, marks are placed on F10 map. If *false* this feature is set to off (default).
|
||||
-- @return #ATIS self
|
||||
function ATIS:SetMapMarks(switch)
|
||||
if switch==nil or switch==true then
|
||||
self.usemarker=true
|
||||
else
|
||||
self.usemarker=false
|
||||
end
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set magnetic runway headings as depicted on the runway, *e.g.* "13" for 130° or "25L" for the left runway with magnetic heading 250°.
|
||||
-- @param #ATIS self
|
||||
-- @param #table headings Magnetic headings. Inverse (-180°) headings are added automatically. You only need to specify one heading per runway direction. "L"eft and "R" right can also be appended.
|
||||
@ -955,6 +977,12 @@ end
|
||||
-- @param #ATIS self
|
||||
function ATIS:onafterStart(From, Event, To)
|
||||
|
||||
-- Check that this is an airdrome.
|
||||
if self.airbase:GetAirbaseCategory()~=Airbase.Category.AIRDROME then
|
||||
self:E(self.lid..string.format("ERROR: Cannot start ATIS for airbase %s! Only AIRDROMES are supported but NOT FARPS or SHIPS.", self.airbasename))
|
||||
return
|
||||
end
|
||||
|
||||
-- Info.
|
||||
self:I(self.lid..string.format("Starting ATIS v%s for airbase %s on %.3f MHz Modulation=%d", ATIS.version, self.airbasename, self.frequency, self.modulation))
|
||||
|
||||
@ -1000,8 +1028,10 @@ function ATIS:onafterStatus(From, Event, To)
|
||||
local relayunitstatus="N/A"
|
||||
if self.relayunitname then
|
||||
local ru=UNIT:FindByName(self.relayunitname)
|
||||
if ru then
|
||||
relayunitstatus=tostring(ru:IsAlive())
|
||||
end
|
||||
end
|
||||
|
||||
-- Info text.
|
||||
local text=string.format("State %s: Freq=%.3f MHz %s, Relay unit=%s (alive=%s)", fsmstate, self.frequency, UTILS.GetModulationName(self.modulation), tostring(self.relayunitname), relayunitstatus)
|
||||
@ -1313,6 +1343,7 @@ function ATIS:onafterBroadcast(From, Event, To)
|
||||
|
||||
-- Information tag
|
||||
subtitle=string.format("Information %s", NATO)
|
||||
local _INFORMATION=subtitle
|
||||
self:Transmission(ATIS.Sound.Information, 0.5, subtitle)
|
||||
self.radioqueue:NewTransmission(string.format("NATO Alphabet/%s.ogg", NATO), 0.75, self.soundpath)
|
||||
|
||||
@ -1434,6 +1465,7 @@ function ATIS:onafterBroadcast(From, Event, To)
|
||||
subtitle=string.format("Altimeter QNH %s.%s, QFE %s.%s inHg", QNH[1], QNH[2], QFE[1], QFE[2])
|
||||
end
|
||||
end
|
||||
local _ALTIMETER=subtitle
|
||||
self:Transmission(ATIS.Sound.Altimeter, 1.0, subtitle)
|
||||
self:Transmission(ATIS.Sound.QNH, 0.5)
|
||||
self.radioqueue:Number2Transmission(QNH[1])
|
||||
@ -1467,6 +1499,7 @@ function ATIS:onafterBroadcast(From, Event, To)
|
||||
subtitle=string.format("Temperature %s °C", TEMPERATURE)
|
||||
end
|
||||
end
|
||||
local _TEMPERATURE=subtitle
|
||||
self:Transmission(ATIS.Sound.Temperature, 1.0, subtitle)
|
||||
if temperature<0 then
|
||||
self:Transmission(ATIS.Sound.Minus, 0.2)
|
||||
@ -1487,6 +1520,7 @@ function ATIS:onafterBroadcast(From, Event, To)
|
||||
if turbulence>0 then
|
||||
subtitle=subtitle..", gusting"
|
||||
end
|
||||
local _WIND=subtitle
|
||||
self:Transmission(ATIS.Sound.WindFrom, 1.0, subtitle)
|
||||
self.radioqueue:Number2Transmission(WINDFROM)
|
||||
self:Transmission(ATIS.Sound.At, 0.2)
|
||||
@ -1507,6 +1541,7 @@ function ATIS:onafterBroadcast(From, Event, To)
|
||||
elseif rwyLeft==false then
|
||||
subtitle=subtitle.." Right"
|
||||
end
|
||||
local _RUNACT=subtitle
|
||||
self:Transmission(ATIS.Sound.ActiveRunway, 1.0, subtitle)
|
||||
self.radioqueue:Number2Transmission(runway)
|
||||
if rwyLeft==true then
|
||||
@ -1534,7 +1569,7 @@ function ATIS:onafterBroadcast(From, Event, To)
|
||||
subtitle=subtitle.." feet"
|
||||
end
|
||||
|
||||
-- Transmitt.
|
||||
-- Transmit.
|
||||
self:Transmission(ATIS.Sound.RunwayLength, 1.0, subtitle)
|
||||
if tonumber(L1000)>0 then
|
||||
self.radioqueue:Number2Transmission(L1000)
|
||||
@ -1699,6 +1734,38 @@ function ATIS:onafterBroadcast(From, Event, To)
|
||||
self:Transmission(ATIS.Sound.EndOfInformation, 0.5, subtitle)
|
||||
self.radioqueue:NewTransmission(string.format("NATO Alphabet/%s.ogg", NATO), 0.75, self.soundpath)
|
||||
|
||||
-- Update F10 marker.
|
||||
if self.usemarker then
|
||||
self:UpdateMarker(_INFORMATION, _RUNACT, _WIND, _ALTIMETER, _TEMPERATURE)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--- Update F10 map marker.
|
||||
-- @param #ATIS self
|
||||
-- @param #string information Information tag text.
|
||||
-- @param #string runact Active runway text.
|
||||
-- @param #string wind Wind text.
|
||||
-- @param #string altimeter Altimeter text.
|
||||
-- @param #string temperature Temperature text.
|
||||
-- @return #number Marker ID.
|
||||
function ATIS:UpdateMarker(information, runact, wind, altimeter, temperature)
|
||||
|
||||
if self.markerid then
|
||||
self.airbase:GetCoordinate():RemoveMark(self.markerid)
|
||||
end
|
||||
|
||||
local text=string.format("ATIS on %.3f %s, %s:\n", self.frequency, UTILS.GetModulationName(self.modulation), tostring(information))
|
||||
text=text..string.format("%s\n", tostring(runact))
|
||||
text=text..string.format("%s\n", tostring(wind))
|
||||
text=text..string.format("%s\n", tostring(altimeter))
|
||||
text=text..string.format("%s", tostring(temperature))
|
||||
-- More info is not displayed on the marker!
|
||||
|
||||
-- Place new mark
|
||||
self.markerid=self.airbase:GetCoordinate():MarkToAll(text, true)
|
||||
|
||||
return self.markerid
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@ -2136,8 +2136,10 @@ do -- Patrol methods
|
||||
-- @param #table ZoneList Table of zones.
|
||||
-- @param #number Speed Speed in km/h the group moves at.
|
||||
-- @param #string Formation (Optional) Formation the group should use.
|
||||
-- @param #number DelayMin Delay in seconds before the group progresses to the next route point. Default 1 sec.
|
||||
-- @param #number DelayMax Max. delay in seconds. Actual delay is randomly chosen between DelayMin and DelayMax. Default equal to DelayMin.
|
||||
-- @return #CONTROLLABLE
|
||||
function CONTROLLABLE:PatrolZones( ZoneList, Speed, Formation )
|
||||
function CONTROLLABLE:PatrolZones( ZoneList, Speed, Formation, DelayMin, DelayMax )
|
||||
|
||||
if not type( ZoneList ) == "table" then
|
||||
ZoneList = { ZoneList }
|
||||
@ -2149,13 +2151,17 @@ do -- Patrol methods
|
||||
PatrolGroup = self:GetGroup() -- Wrapper.Group#GROUP
|
||||
end
|
||||
|
||||
DelayMin=DelayMin or 1
|
||||
if not DelayMax or DelayMax<DelayMin then
|
||||
DelayMax=DelayMin
|
||||
end
|
||||
|
||||
local Delay=math.random(DelayMin, DelayMax)
|
||||
|
||||
self:F( { PatrolGroup = PatrolGroup:GetName() } )
|
||||
|
||||
if PatrolGroup:IsGround() or PatrolGroup:IsShip() then
|
||||
|
||||
local Waypoints = PatrolGroup:GetTemplateRoutePoints()
|
||||
local Waypoint = Waypoints[math.random( 1, #Waypoints )] -- Select random waypoint.
|
||||
|
||||
-- Calculate the new Route.
|
||||
local FromCoord = PatrolGroup:GetCoordinate()
|
||||
|
||||
@ -2169,11 +2175,11 @@ do -- Patrol methods
|
||||
Route[#Route+1] = ToCoord:WaypointGround( Speed, Formation )
|
||||
|
||||
|
||||
local TaskRouteToZone = PatrolGroup:TaskFunction( "CONTROLLABLE.PatrolZones", ZoneList, Speed, Formation )
|
||||
local TaskRouteToZone = PatrolGroup:TaskFunction( "CONTROLLABLE.PatrolZones", ZoneList, Speed, Formation, DelayMin, DelayMax )
|
||||
|
||||
PatrolGroup:SetTaskWaypoint( Route[#Route], TaskRouteToZone ) -- Set for the given Route at Waypoint 2 the TaskRouteToZone.
|
||||
|
||||
PatrolGroup:Route( Route, 1 ) -- Move after a random seconds to the Route. See the Route method for details.
|
||||
PatrolGroup:Route( Route, Delay ) -- Move after a random seconds to the Route. See the Route method for details.
|
||||
end
|
||||
end
|
||||
|
||||
@ -2374,7 +2380,8 @@ do -- Route methods
|
||||
|
||||
local FromCoordinate = self:GetCoordinate()
|
||||
|
||||
local FromWP = FromCoordinate:WaypointGround()
|
||||
--local FromWP = FromCoordinate:WaypointGround()
|
||||
local FromWP = FromCoordinate:WaypointGround(Speed, Formation)
|
||||
local ToWP = ToCoordinate:WaypointGround( Speed, Formation )
|
||||
|
||||
self:Route( { FromWP, ToWP }, DelaySeconds )
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user