mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-11 03:43:38 +00:00
Ops FG & FC
This commit is contained in:
@@ -177,7 +177,7 @@ function FLIGHTCONTROL:New(airbasename)
|
||||
self:AddTransition("*", "Status", "*") -- Update status.
|
||||
|
||||
-- Debug trace.
|
||||
if false then
|
||||
if true then
|
||||
self.Debug=true
|
||||
BASE:TraceOnOff(true)
|
||||
BASE:TraceClass(self.ClassName)
|
||||
@@ -263,10 +263,9 @@ function FLIGHTCONTROL:onafterStatus()
|
||||
-- Check zone for flights inbound.
|
||||
--self:_CheckInbound()
|
||||
|
||||
--self:_UpdateParkingSpots()
|
||||
|
||||
-- Check parking spots.
|
||||
self:_CheckParking()
|
||||
self:_UpdateParkingSpots()
|
||||
|
||||
-- Check waiting and landing queue.
|
||||
self:_CheckQueues()
|
||||
@@ -450,6 +449,7 @@ function FLIGHTCONTROL:_CheckQueues()
|
||||
|
||||
flight:_UpdateRoute(1)
|
||||
|
||||
env.info("FF remove flight from parking queue - if possible.")
|
||||
self:_RemoveFlightFromQueue(self.Qparking, flight, "parking")
|
||||
|
||||
self:_AddFlightToTakeoffQueue(flight)
|
||||
@@ -491,7 +491,7 @@ function FLIGHTCONTROL:_GetNextFight()
|
||||
|
||||
|
||||
-- Return the flight which is waiting longer.
|
||||
if flightholding.Tholding<flightparking.Tparking then
|
||||
if flightholding.Tholding>flightparking.Tparking then
|
||||
return flightholding, true
|
||||
else
|
||||
return flightparking, false
|
||||
@@ -788,7 +788,7 @@ function FLIGHTCONTROL:_InitParkingSpots()
|
||||
|
||||
-- Mark position.
|
||||
local text=string.format("ID=%d, Terminal=%d, Free=%s, Reserved=%s, Dist=%.1f", parking.id, parking.terminal, tostring(parking.free), tostring(parking.reserved), parking.drunway)
|
||||
parking.markerid=parking.position:MarkToAll(text)
|
||||
--parking.markerid=parking.position:MarkToAll(text)
|
||||
|
||||
-- Add to table.
|
||||
table.insert(self.parking, parking)
|
||||
@@ -821,7 +821,7 @@ function FLIGHTCONTROL:_CheckParking()
|
||||
local flight=_flight --Ops.FlightGroup#FLIGHTGROUP
|
||||
|
||||
-- Loop over all elements.
|
||||
for _,_element in pairs(_flight.elements) do
|
||||
for _,_element in pairs(flight.elements) do
|
||||
local element=_element --Ops.FlightGroup#FLIGHTGROUP.Element
|
||||
|
||||
if element.unit and element.unit:IsAlive() then
|
||||
@@ -841,7 +841,6 @@ function FLIGHTCONTROL:_CheckParking()
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -900,7 +899,9 @@ function FLIGHTCONTROL:_UpdateParkingSpots()
|
||||
|
||||
local text=string.format("ID=%d, Terminal=%d, Free=%s, Reserved=%s, Dist=%.1f", parking.id, parking.terminal, tostring(parking.free), tostring(parking.reserved), parking.drunway)
|
||||
message=message.."\n"..text
|
||||
parking.markerid=parking.position:MarkToAll(text)
|
||||
if parking.free==false or parking.reserved then
|
||||
parking.markerid=parking.position:MarkToAll(text)
|
||||
end
|
||||
|
||||
break
|
||||
end
|
||||
@@ -940,9 +941,12 @@ function FLIGHTCONTROL:_CreatePlayerMenu(flight)
|
||||
|
||||
local playermenu=self.playermenu[gid] --#FLIGHTCONTROL.PlayerMenu
|
||||
|
||||
playermenu.root = MENU_GROUP:New(group, "ATC")
|
||||
playermenu.MyStatus = MENU_GROUP_COMMAND:New(group, "My Status", playermenu.root, self._PlayerMyStatus, self, groupname)
|
||||
playermenu.RequestTaxi= MENU_GROUP_COMMAND:New(group, "Request Taxi", playermenu.root, self._PlayerRequestTaxi, self, groupname)
|
||||
playermenu.root = MENU_GROUP:New(group, "ATC")
|
||||
playermenu.MyStatus = MENU_GROUP_COMMAND:New(group, "My Status", playermenu.root, self._PlayerMyStatus, self, groupname)
|
||||
playermenu.RequestTaxi = MENU_GROUP_COMMAND:New(group, "Request Taxi", playermenu.root, self._PlayerRequestTaxi, self, groupname)
|
||||
playermenu.RequestTakeoff = MENU_GROUP_COMMAND:New(group, "Request Takeoff", playermenu.root, self._PlayerRequestTakeoff, self, groupname)
|
||||
playermenu.Inbound = MENU_GROUP_COMMAND:New(group, "Inbound", playermenu.root, self._PlayerInbound, self, groupname)
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -975,20 +979,41 @@ function FLIGHTCONTROL:_PlayerRequestTaxi(groupname)
|
||||
|
||||
MESSAGE:New("Request taxi to runway", 5):ToAll()
|
||||
|
||||
MESSAGE:New("You are cleared to taxi", 5):ToAll()
|
||||
|
||||
|
||||
local flight=_DATABASE:GetFlightGroup(groupname)
|
||||
|
||||
if flight then
|
||||
|
||||
MESSAGE:New("You are cleared to taxi", 5):ToAll()
|
||||
|
||||
for _,_element in pairs(flight.elements) do
|
||||
local element=_element --Ops.FlightGroup#FLIGHTGROUP.Element
|
||||
flight:ElementTaxiing(element)
|
||||
end
|
||||
|
||||
else
|
||||
MESSAGE:New(string.format("Could not clear group %s for taxi!", groupname), 5):ToAll()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--- Create player menu.
|
||||
-- @param #FLIGHTCONTROL self
|
||||
-- @param #string groupname Name of the flight group.
|
||||
function FLIGHTCONTROL:_PlayerRequestTakeoff(groupname)
|
||||
|
||||
MESSAGE:New("Request takeoff", 5):ToAll()
|
||||
|
||||
local flight=_DATABASE:GetFlightGroup(groupname)
|
||||
|
||||
if flight then
|
||||
if flight:IsTaxiing() then
|
||||
else
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- Flight and Element Functions
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -1140,6 +1165,82 @@ end
|
||||
-- Routing Functions
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
--- Scan airbase zone and find new flights.
|
||||
-- @param #FLIGHTCONTROL self
|
||||
function FLIGHTCONTROL:_CheckACstatus()
|
||||
|
||||
-- Airbase position.
|
||||
local coord=self:GetCoordinate()
|
||||
|
||||
-- Scan radius = 20 NM.
|
||||
local RCCZ=UTILS.NMToMeters(20)
|
||||
|
||||
-- Debug info.
|
||||
self:T(self.lid..string.format("Scanning airbase zone. Radius=%.1f NM.", UTILS.MetersToNM(RCCZ)))
|
||||
|
||||
-- Scan units in carrier zone.
|
||||
local _,_,_,unitscan=coord:ScanObjects(RCCZ, true, false, false)
|
||||
|
||||
-- Make a table with all groups currently in the CCA zone.
|
||||
local insideZone={}
|
||||
|
||||
for _,_unit in pairs(unitscan) do
|
||||
local unit=_unit --Wrapper.Unit#UNIT
|
||||
|
||||
-- Necessary conditions to be met:
|
||||
local aircraft=unit:IsAir()
|
||||
local inzone=unit:IsInZone(self.zoneAirbase)
|
||||
local friendly=self:GetCoalition()==unit:GetCoalition()
|
||||
|
||||
-- Check if this an aircraft and that it is inside the airbase zone and friendly.
|
||||
if aircraft and inzone then
|
||||
|
||||
local group=unit:GetGroup()
|
||||
local groupname=group:GetName()
|
||||
|
||||
-- Add group to table.
|
||||
if insideZone[groupname]==nil then
|
||||
insideZone[groupname]=groupname
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
-- Find new flights that are inside the airbase zone.
|
||||
for groupname,_ in pairs(insideZone) do
|
||||
local flight=_DATABASE:GetFlightGroup(groupname)
|
||||
|
||||
if flight then
|
||||
|
||||
for _,_element in pairs(flight.elements) do
|
||||
local element=_element --Ops.FlightGroup#FLIGHTGROUP.Element
|
||||
|
||||
local unit=element.unit
|
||||
|
||||
if unit and unit:IsAlive() then
|
||||
|
||||
if unit:InAir() then
|
||||
|
||||
else
|
||||
|
||||
if element.status==FLIGHTGROUP.ElementStatus.PARKING then
|
||||
if element.parking then
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--- Scan airbase zone and find new flights.
|
||||
-- @param #FLIGHTCONTROL self
|
||||
function FLIGHTCONTROL:_CheckInbound()
|
||||
@@ -1180,6 +1281,8 @@ function FLIGHTCONTROL:_CheckInbound()
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- Find new flights that are inside the airbase zone.
|
||||
for groupname,_group in pairs(insideZone) do
|
||||
|
||||
@@ -342,7 +342,7 @@ function FLIGHTGROUP:New(groupname)
|
||||
|
||||
|
||||
-- Debug trace.
|
||||
if true then
|
||||
if false then
|
||||
self.Debug=true
|
||||
BASE:TraceOnOff(true)
|
||||
BASE:TraceClass(self.ClassName)
|
||||
@@ -1219,7 +1219,7 @@ function FLIGHTGROUP:onafterFlightSpawned(From, Event, To)
|
||||
|
||||
for _,_element in pairs(self.elements) do
|
||||
local element=_element --#FLIGHTGROUP.Element
|
||||
element.ai=self:_IsHumanUnit(element.unit)
|
||||
element.ai=not self:_IsHumanUnit(element.unit)
|
||||
end
|
||||
|
||||
-- Init waypoints.
|
||||
@@ -1543,22 +1543,30 @@ function FLIGHTGROUP:onafterHold(From, Event, To, airbase, SpeedTo, SpeedHold, S
|
||||
p1=HoldingPoint.pos1
|
||||
|
||||
-- Debug marks.
|
||||
p0:MarkToAll("Holding point P0")
|
||||
p1:MarkToAll("Holding point P1")
|
||||
if self.Debug then
|
||||
p0:MarkToAll("Holding point P0")
|
||||
p1:MarkToAll("Holding point P1")
|
||||
end
|
||||
|
||||
-- Get active runway.
|
||||
local runway=fc:GetActiveRunway()
|
||||
|
||||
-- Approach point: 10 NN in direction of runway.
|
||||
local papp=airbase:GetCoordinate():Translate(x1, runway.heading-180):SetAltitude(h1)
|
||||
papp:MarkToAll(string.format("Final Approach: d=%d m, h=%d m", x1, h1))
|
||||
wpap=papp:WaypointAirTurningPoint(nil, UTILS.KnotsToKmph(SpeedLand), {}, "Final Approach")
|
||||
wpap=papp:WaypointAirTurningPoint(nil, UTILS.KnotsToKmph(SpeedLand), {}, "Final Approach")
|
||||
|
||||
if self.Debug then
|
||||
papp:MarkToAll(string.format("Final Approach: d=%d m, h=%d m", x1, h1))
|
||||
end
|
||||
|
||||
-- TODO: make dependend on AC type helos etc.
|
||||
|
||||
-- Approach point: 10 NN in direction of runway.
|
||||
pland=airbase:GetCoordinate():Translate(x2, runway.heading-180):SetAltitude(h2)
|
||||
pland:MarkToAll(string.format("Landing: d=%d m, h=%d m", x2, h2))
|
||||
|
||||
if self.Debug then
|
||||
pland:MarkToAll(string.format("Landing: d=%d m, h=%d m", x2, h2))
|
||||
end
|
||||
|
||||
-- Set flightcontrol for this flight.
|
||||
self:SetFlightControl(fc)
|
||||
@@ -1587,8 +1595,7 @@ function FLIGHTGROUP:onafterHold(From, Event, To, airbase, SpeedTo, SpeedHold, S
|
||||
-- Okay, it looks like it's best to specify the coordinates not at the airbase but a bit away. This causes a more direct landing approach.
|
||||
wp[#wp+1]=pland:WaypointAirLanding(UTILS.KnotsToKmph(SpeedLand), airbase, {}, "Landing")
|
||||
|
||||
-- This is NOT good! It causes the AC to fly to the airbase and then start landing, i.e. go back.
|
||||
--wp[#wp+1]=airbase:GetCoordinate():SetAltitude(UTILS.FeetToMeters(0)):WaypointAirLanding(UTILS.KnotsToKmph(SpeedLand), airbase, {}, "Landing")
|
||||
|
||||
|
||||
local respawn=true
|
||||
|
||||
@@ -1904,7 +1911,10 @@ end
|
||||
-- @param #FLIGHTGROUP flightgroup Flight group object.
|
||||
function FLIGHTGROUP._ReachedHolding(group, flightgroup)
|
||||
env.info(string.format("FF group %s reached holding point", group:GetName()))
|
||||
group:GetCoordinate():MarkToAll("Holding Point Reached")
|
||||
|
||||
if flightgroup.Debug then
|
||||
group:GetCoordinate():MarkToAll("Holding Point Reached")
|
||||
end
|
||||
|
||||
flightgroup.flaghold:Set(666)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user