Update FlightControl.lua

This commit is contained in:
Frank
2023-09-14 16:46:08 +02:00
parent 39f626390a
commit 2fda1709bc
+108 -16
View File
@@ -61,6 +61,7 @@
-- @field #number runwaydestroyed Time stamp (abs), when runway was destroyed. If `nil`, runway is operational. -- @field #number runwaydestroyed Time stamp (abs), when runway was destroyed. If `nil`, runway is operational.
-- @field #number runwayrepairtime Time in seconds until runway will be repaired after it was destroyed. Default is 3600 sec (one hour). -- @field #number runwayrepairtime Time in seconds until runway will be repaired after it was destroyed. Default is 3600 sec (one hour).
-- @field #boolean markerParking If `true`, occupied parking spots are marked. -- @field #boolean markerParking If `true`, occupied parking spots are marked.
-- @field #table warnings Warnings issued to flight groups.
-- @extends Core.Fsm#FSM -- @extends Core.Fsm#FSM
--- **Ground Control**: Airliner X, Good news, you are clear to taxi to the active. --- **Ground Control**: Airliner X, Good news, you are clear to taxi to the active.
@@ -270,6 +271,7 @@ FLIGHTCONTROL = {
Nparkingspots = nil, Nparkingspots = nil,
holdingpatterns = {}, holdingpatterns = {},
hpcounter = 0, hpcounter = 0,
warnings = {},
} }
--- Holding point. Contains holding stacks. --- Holding point. Contains holding stacks.
@@ -329,6 +331,21 @@ FLIGHTCONTROL.FlightStatus={
ARRIVED="Arrived", ARRIVED="Arrived",
} }
--- Violations
-- @type FLIGHTCONTROL.Violation
FLIGHTCONTROL.Violation={
Speeding="Speeding",
AltitudeDeviation="Altitude Deviation", --300 feet from assigned alt.
RunwayIncursion="Runway Incursion",
}
--- Warning.
-- @type FLIGHTCONTROL.Warning
-- @field Ops.FlightGroup#FLIGHTGROUP flight The flight group.
-- @field #string type Type of warning.
-- @field #number time Time stamp when warning was issued.
--- FlightControl class version. --- FlightControl class version.
-- @field #string version -- @field #string version
FLIGHTCONTROL.version="0.7.3" FLIGHTCONTROL.version="0.7.3"
@@ -336,6 +353,7 @@ FLIGHTCONTROL.version="0.7.3"
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TODO list -- TODO list
-- TODO: Progressive Taxi
-- TODO: Ground control for takeoff and taxi. -- TODO: Ground control for takeoff and taxi.
-- TODO: Improve approach pattern with new NAVIGATION classes. -- TODO: Improve approach pattern with new NAVIGATION classes.
-- TODO: SID procedure for departures. -- TODO: SID procedure for departures.
@@ -1390,6 +1408,7 @@ function FLIGHTCONTROL:_CheckQueues()
dTlanding=timer.getAbsTime()-self.Tlanding dTlanding=timer.getAbsTime()-self.Tlanding
end end
-- Check if parking is available and timely spacing okay.
if parking and dTlanding>=self.dTlanding then if parking and dTlanding>=self.dTlanding then
-- Get callsign. -- Get callsign.
@@ -3490,6 +3509,8 @@ function FLIGHTCONTROL:_PlayerRequestTaxi(groupname)
-- Set flight status to "Ready to Taxi". -- Set flight status to "Ready to Taxi".
self:SetFlightStatus(flight, FLIGHTCONTROL.FlightStatus.READYTX) self:SetFlightStatus(flight, FLIGHTCONTROL.FlightStatus.READYTX)
self.airbase:FindTaxiwaysFromAtoB(StartCoord,EndCoord)
elseif flight:IsTaxiing() then elseif flight:IsTaxiing() then
-- Runway for takeoff. -- Runway for takeoff.
@@ -4072,24 +4093,66 @@ function FLIGHTCONTROL:_CheckFlights()
end end
end end
-- Check speeding. -- Loop over all flights.
if self.speedLimitTaxi then
for _,_flight in pairs(self.flights) do for _,_flight in pairs(self.flights) do
local flight=_flight --Ops.FlightGroup#FLIGHTGROUP local flight=_flight --Ops.FlightGroup#FLIGHTGROUP
if not flight.isAI then
-- Get player element.
local playerElement=flight:GetPlayerElement()
-- Current flight status. -- Current flight status.
local flightstatus=self:GetFlightStatus(flight) local flightstatus=self:GetFlightStatus(flight)
if playerElement then if not flight.isAI then
-- Check if speeding while taxiing. -- Check if speeding while taxiing.
if (flightstatus==FLIGHTCONTROL.FlightStatus.TAXIINB or flightstatus==FLIGHTCONTROL.FlightStatus.TAXIOUT) and self.speedLimitTaxi then if (flightstatus==FLIGHTCONTROL.FlightStatus.TAXIINB or flightstatus==FLIGHTCONTROL.FlightStatus.TAXIOUT) then
if self.speedLimitTaxi then
self:_CheckFlightSpeeding(flight)
end
end
if (flightstatus==FLIGHTCONTROL.FlightStatus.TAXIINB or flightstatus==FLIGHTCONTROL.FlightStatus.TAXIOUT) then
end
if (flightstatus==FLIGHTCONTROL.FlightStatus.LANDING) then
--Talk down
end
if (flightstatus==FLIGHTCONTROL.FlightStatus.PARKING) then
--Check if still on parking spot!
end
if (flightstatus==FLIGHTCONTROL.FlightStatus.HOLDING) then
--Check altitude and position
end
if (flightstatus==FLIGHTCONTROL.FlightStatus.ARRIVED) then
--Check if still on correct parking spot!
end
if (flightstatus==FLIGHTCONTROL.FlightStatus.READYTX) then
-- ?
end
if (flightstatus==FLIGHTCONTROL.FlightStatus.READYTO) then
-- ?
end
end
end
end
--- Check if flight is speeding while taxiing and issue a warning.
-- @param #FLIGHTCONTROL self
-- @param Ops.FlightGroup#FLIGHTGROUP flight The flight to check.
function FLIGHTCONTROL:_CheckFlightSpeeding(flight)
-- Get player element.
local playerElement=flight:GetPlayerElement()
if playerElement then
-- Current speed in m/s. -- Current speed in m/s.
local speed=playerElement.unit:GetVelocityMPS() local speed=playerElement.unit:GetVelocityMPS()
@@ -4125,12 +4188,6 @@ function FLIGHTCONTROL:_CheckFlights()
end end
end end
end
end
end
end
--- Check status of all registered flights and do some sanity checks. --- Check status of all registered flights and do some sanity checks.
-- @param #FLIGHTCONTROL self -- @param #FLIGHTCONTROL self
@@ -4328,6 +4385,41 @@ function FLIGHTCONTROL:TransmissionTower(Text, Flight, Delay)
end end
--- Radio transmission from ground control.
-- @param #FLIGHTCONTROL self
-- @param #string Text The text to transmit.
-- @param Ops.FlightGroup#FLIGHTGROUP Flight The flight.
-- @param #number Delay Delay in seconds before the text is transmitted. Default 0 sec.
function FLIGHTCONTROL:TransmissionGround(Text, Flight, Delay)
-- Spoken text.
local text=self:_GetTextForSpeech(Text)
-- "Subtitle".
local subgroups=nil
if Flight and not Flight.isAI then
local playerData=Flight:_GetPlayerData()
if playerData.subtitles then
subgroups=subgroups or {}
table.insert(subgroups, Flight.group)
end
end
-- Use ground or tower if ground not set up.
local msrs=self.msrsGround~=nil and self.msrsGround or self.msrsTower
-- New transmission.
local transmission=self.msrsqueue:NewTransmission(text, nil, msrs, nil, 1, subgroups, Text)
-- Set time stamp. Can be in the future.
self.Tlastmessage=timer.getAbsTime() + (Delay or 0)
-- Debug message.
self:T(self.lid..string.format("Radio Tower: %s", Text))
end
--- Radio transmission. --- Radio transmission.
-- @param #FLIGHTCONTROL self -- @param #FLIGHTCONTROL self
-- @param #string Text The text to transmit. -- @param #string Text The text to transmit.