mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-21 02:31:39 +00:00
Update FlightControl.lua
This commit is contained in:
@@ -99,7 +99,7 @@ FLIGHTCONTROL = {
|
|||||||
|
|
||||||
--- FlightControl class version.
|
--- FlightControl class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
FLIGHTCONTROL.version="0.0.8"
|
FLIGHTCONTROL.version="0.0.9"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO list
|
-- TODO list
|
||||||
@@ -415,7 +415,7 @@ function FLIGHTCONTROL:_CheckQueues()
|
|||||||
local nparking=#self.Qparking
|
local nparking=#self.Qparking
|
||||||
|
|
||||||
-- Get next flight in line: either holding or parking.
|
-- Get next flight in line: either holding or parking.
|
||||||
local flight, isholding=self:_GetNextFight()
|
local flight, isholding=self:_GetNextFlight()
|
||||||
|
|
||||||
|
|
||||||
-- Check if somebody wants something.
|
-- Check if somebody wants something.
|
||||||
@@ -432,7 +432,7 @@ function FLIGHTCONTROL:_CheckQueues()
|
|||||||
|
|
||||||
|
|
||||||
-- Get number of alive elements.
|
-- Get number of alive elements.
|
||||||
local Ne=self:GetNelements()
|
local Ne=flight:GetNelements()
|
||||||
|
|
||||||
-- Message.
|
-- Message.
|
||||||
local text=string.format("Flight %s, you are cleared to land.", flight.groupname)
|
local text=string.format("Flight %s, you are cleared to land.", flight.groupname)
|
||||||
@@ -481,11 +481,12 @@ end
|
|||||||
-- @param #FLIGHTCONTROL self
|
-- @param #FLIGHTCONTROL self
|
||||||
-- @return Ops.FlightGroup#FLIGHTGROUP Marshal flight next in line and ready to enter the pattern. Or nil if no flight is ready.
|
-- @return Ops.FlightGroup#FLIGHTGROUP Marshal flight next in line and ready to enter the pattern. Or nil if no flight is ready.
|
||||||
-- @return #boolean If true, flight is holding and waiting for landing, if false, flight is parking and waiting for takeoff.
|
-- @return #boolean If true, flight is holding and waiting for landing, if false, flight is parking and waiting for takeoff.
|
||||||
function FLIGHTCONTROL:_GetNextFight()
|
function FLIGHTCONTROL:_GetNextFlight()
|
||||||
|
|
||||||
local flightholding=self:_GetNextFightHolding()
|
local flightholding=self:_GetNextFightHolding()
|
||||||
local flightparking=self:_GetNextFightParking()
|
local flightparking=self:_GetNextFightParking()
|
||||||
|
|
||||||
|
|
||||||
-- Free parking spots.
|
-- Free parking spots.
|
||||||
local nP=self:_GetFreeParkingSpots()
|
local nP=self:_GetFreeParkingSpots()
|
||||||
|
|
||||||
@@ -495,11 +496,17 @@ function FLIGHTCONTROL:_GetNextFight()
|
|||||||
nH=flightholding:GetNelements()
|
nH=flightholding:GetNelements()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
env.info("FF")
|
||||||
|
self:I({nextholding=flightholding})
|
||||||
|
self:I({nextparking=flightparking})
|
||||||
|
self:I(string.format("GetNext: holding=%d - parking=%d", nH, nP))
|
||||||
|
|
||||||
-- If no flight is waiting for takeoff return the holding flight or nil.
|
-- If no flight is waiting for takeoff return the holding flight or nil.
|
||||||
if not flightparking then
|
if not flightparking then
|
||||||
if nP>=nH then
|
if nP>=nH then
|
||||||
return flightholding, true
|
return flightholding, true
|
||||||
else
|
else
|
||||||
|
self:E(string.format("WARNING: No flight parking but no parking spots! nP=%d nH=%d", nP, nH))
|
||||||
return nil, nil
|
return nil, nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -515,13 +522,14 @@ function FLIGHTCONTROL:_GetNextFight()
|
|||||||
-- Return holding flight if fuel is low.
|
-- Return holding flight if fuel is low.
|
||||||
if flightholding.fuellow then
|
if flightholding.fuellow then
|
||||||
if nP>=nH then
|
if nP>=nH then
|
||||||
|
-- Enough parking ==> land
|
||||||
return flightholding, true
|
return flightholding, true
|
||||||
else
|
else
|
||||||
return nil, nil
|
-- Not enough parking ==> take off
|
||||||
|
return flightparking, false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Return the flight which is waiting longer.
|
-- Return the flight which is waiting longer.
|
||||||
if flightholding.Tholding>flightparking.Tparking and nP>=nH then
|
if flightholding.Tholding>flightparking.Tparking and nP>=nH then
|
||||||
return flightholding, true
|
return flightholding, true
|
||||||
@@ -1408,7 +1416,8 @@ function FLIGHTCONTROL:_LandAI(flight, parking)
|
|||||||
local x2=UTILS.NMToMeters(5)
|
local x2=UTILS.NMToMeters(5)
|
||||||
local h1=x1*math.tan(alpha)
|
local h1=x1*math.tan(alpha)
|
||||||
local h2=x2*math.tan(alpha)
|
local h2=x2*math.tan(alpha)
|
||||||
local SpeedLand=150
|
local SpeedLand=140
|
||||||
|
local SpeedTo=180
|
||||||
|
|
||||||
local runway=self:GetActiveRunway()
|
local runway=self:GetActiveRunway()
|
||||||
|
|
||||||
@@ -1416,7 +1425,7 @@ function FLIGHTCONTROL:_LandAI(flight, parking)
|
|||||||
local wp={}
|
local wp={}
|
||||||
|
|
||||||
-- Current pos.
|
-- Current pos.
|
||||||
wp[#wp+1]=self.group:GetCoordinate():WaypointAir(nil, COORDINATE.WaypointType.TurningPoint, COORDINATE.WaypointAction.FlyoverPoint, UTILS.KnotsToKmph(SpeedTo), true , nil, {}, "Current Pos")
|
wp[#wp+1]=flight.group:GetCoordinate():WaypointAir(nil, COORDINATE.WaypointType.TurningPoint, COORDINATE.WaypointAction.FlyoverPoint, UTILS.KnotsToKmph(SpeedTo), true , nil, {}, "Current Pos")
|
||||||
|
|
||||||
-- Approach point: 10 NN in direction of runway.
|
-- Approach point: 10 NN in direction of runway.
|
||||||
local papp=self.airbase:GetCoordinate():Translate(x1, runway.heading-180):SetAltitude(h1)
|
local papp=self.airbase:GetCoordinate():Translate(x1, runway.heading-180):SetAltitude(h1)
|
||||||
@@ -1436,7 +1445,7 @@ function FLIGHTCONTROL:_LandAI(flight, parking)
|
|||||||
flight.flaghold:Set(1)
|
flight.flaghold:Set(1)
|
||||||
|
|
||||||
-- Get group template.
|
-- Get group template.
|
||||||
local Template=self.group:GetTemplate()
|
local Template=flight.group:GetTemplate()
|
||||||
|
|
||||||
-- Set route points.
|
-- Set route points.
|
||||||
Template.route.points=wp
|
Template.route.points=wp
|
||||||
@@ -1452,10 +1461,10 @@ function FLIGHTCONTROL:_LandAI(flight, parking)
|
|||||||
MESSAGE:New("Respawning group"):ToAll()
|
MESSAGE:New("Respawning group"):ToAll()
|
||||||
|
|
||||||
--Respawn the group.
|
--Respawn the group.
|
||||||
self.group=self.group:Respawn(Template, true)
|
flight.group=flight.group:Respawn(Template, true)
|
||||||
|
|
||||||
-- Route the group.
|
-- Route the group.
|
||||||
self.group:Route(wp, 1)
|
flight.group:Route(wp, 1)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user