mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-20 07:43:07 +00:00
Ops
This commit is contained in:
@@ -93,6 +93,7 @@ FLIGHTCONTROL = {
|
|||||||
-- @field #boolean free If true, spot is free.
|
-- @field #boolean free If true, spot is free.
|
||||||
-- @field #number drunway Distance to runway.
|
-- @field #number drunway Distance to runway.
|
||||||
-- @field #boolean reserved If true, reserved.
|
-- @field #boolean reserved If true, reserved.
|
||||||
|
-- @field #string reserved4 Flight group the spot is reserved for. Applies only to landing.
|
||||||
-- @field #number markerid ID of the marker.
|
-- @field #number markerid ID of the marker.
|
||||||
|
|
||||||
--- Runway data.
|
--- Runway data.
|
||||||
@@ -104,7 +105,7 @@ FLIGHTCONTROL = {
|
|||||||
|
|
||||||
--- FlightControl class version.
|
--- FlightControl class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
FLIGHTCONTROL.version="0.0.7"
|
FLIGHTCONTROL.version="0.0.8"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO list
|
-- TODO list
|
||||||
@@ -265,6 +266,8 @@ function FLIGHTCONTROL:onafterStatus()
|
|||||||
|
|
||||||
-- Check parking spots.
|
-- Check parking spots.
|
||||||
self:_CheckParking()
|
self:_CheckParking()
|
||||||
|
|
||||||
|
-- Update parking spots.
|
||||||
self:_UpdateParkingSpots()
|
self:_UpdateParkingSpots()
|
||||||
|
|
||||||
-- Check waiting and landing queue.
|
-- Check waiting and landing queue.
|
||||||
@@ -594,9 +597,22 @@ function FLIGHTCONTROL:_PrintQueue(queue, name)
|
|||||||
local fuel=flight.group:GetFuelMin()*100
|
local fuel=flight.group:GetFuelMin()*100
|
||||||
local ai=tostring(flight.ai)
|
local ai=tostring(flight.ai)
|
||||||
local actype=tostring(flight.actype)
|
local actype=tostring(flight.actype)
|
||||||
|
env.info("FF")
|
||||||
|
self:I({holding=flight.Tholding})
|
||||||
|
self:I({parking=flight.Tparking})
|
||||||
local holding=flight.Tholding and UTILS.SecondsToClock(flight.Tholding-time, true) or "X"
|
local holding=flight.Tholding and UTILS.SecondsToClock(flight.Tholding-time, true) or "X"
|
||||||
local parking=flight.Tparking and UTILS.SecondsToClock(flight.Tparking-time, true) or "X"
|
local parking=flight.Tparking and UTILS.SecondsToClock(flight.Tparking-time, true) or "X"
|
||||||
|
|
||||||
|
local holding=flight:GetHoldingTime()
|
||||||
|
if holding>=0 then
|
||||||
|
holding=UTILS.SecondsToClock(holding, true)
|
||||||
|
end
|
||||||
|
local parking=flight:GetParkingTime()
|
||||||
|
if parking>=0 then
|
||||||
|
parking=UTILS.SecondsToClock(parking, true)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
local nunits=flight.nunits or 1
|
local nunits=flight.nunits or 1
|
||||||
|
|
||||||
-- Main info.
|
-- Main info.
|
||||||
@@ -772,6 +788,7 @@ function FLIGHTCONTROL:_InitParkingSpots()
|
|||||||
-- Parking spots of airbase.
|
-- Parking spots of airbase.
|
||||||
local parkingdata=self.airbase:GetParkingSpotsTable()
|
local parkingdata=self.airbase:GetParkingSpotsTable()
|
||||||
|
|
||||||
|
-- Init parking spots table.
|
||||||
self.parking={}
|
self.parking={}
|
||||||
|
|
||||||
for _,_spot in pairs(parkingdata) do
|
for _,_spot in pairs(parkingdata) do
|
||||||
@@ -785,6 +802,7 @@ function FLIGHTCONTROL:_InitParkingSpots()
|
|||||||
parking.id=spot.TerminalID
|
parking.id=spot.TerminalID
|
||||||
parking.free=spot.Free
|
parking.free=spot.Free
|
||||||
parking.reserved=spot.TOAC
|
parking.reserved=spot.TOAC
|
||||||
|
parking.reserved4="none"
|
||||||
|
|
||||||
-- Mark position.
|
-- 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)
|
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)
|
||||||
@@ -858,7 +876,7 @@ function FLIGHTCONTROL:_GetFreeParkingSpots(terminal)
|
|||||||
for _,_parking in pairs(self.parking) do
|
for _,_parking in pairs(self.parking) do
|
||||||
local parking=_parking --#FLIGHTCONTROL.ParkingSpot
|
local parking=_parking --#FLIGHTCONTROL.ParkingSpot
|
||||||
|
|
||||||
if parking.free then
|
if parking.free and parking.reserved4=="none" then
|
||||||
if terminal==nil or terminal==parking.terminal then
|
if terminal==nil or terminal==parking.terminal then
|
||||||
n=n+1
|
n=n+1
|
||||||
table.insert(freespots, parking)
|
table.insert(freespots, parking)
|
||||||
@@ -897,9 +915,9 @@ function FLIGHTCONTROL:_UpdateParkingSpots()
|
|||||||
parking.position:RemoveMark(parking.markerid)
|
parking.position:RemoveMark(parking.markerid)
|
||||||
end
|
end
|
||||||
|
|
||||||
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)
|
local text=string.format("ID=%03d, Terminal=%03d, Free=%s, Reserved=%s, reserved4=%s, Dist=%.1f", parking.id, parking.terminal, tostring(parking.free), tostring(parking.reserved), parking.reserved4, parking.drunway)
|
||||||
message=message.."\n"..text
|
message=message.."\n"..text
|
||||||
if parking.free==false or parking.reserved then
|
if parking.free==false or parking.reserved or parking.reserved4~="none" then
|
||||||
parking.markerid=parking.position:MarkToAll(text)
|
parking.markerid=parking.position:MarkToAll(text)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1334,7 +1352,6 @@ function FLIGHTCONTROL:_LandAI(flight)
|
|||||||
self:I(self.lid..string.format("Landing AI flight %s.", flight.groupname))
|
self:I(self.lid..string.format("Landing AI flight %s.", flight.groupname))
|
||||||
|
|
||||||
-- Add flight to landing queue.
|
-- Add flight to landing queue.
|
||||||
--table.insert(self.Qlanding, flight)
|
|
||||||
self:_AddFlightToLandingQueue(flight)
|
self:_AddFlightToLandingQueue(flight)
|
||||||
|
|
||||||
-- Give signal to land.
|
-- Give signal to land.
|
||||||
|
|||||||
@@ -1242,6 +1242,7 @@ end
|
|||||||
-- @param #string Event Event.
|
-- @param #string Event Event.
|
||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
function FLIGHTGROUP:onafterFlightParking(From, Event, To)
|
function FLIGHTGROUP:onafterFlightParking(From, Event, To)
|
||||||
|
self:I(self.sid..string.format("Flight is parking %s.", self.groupname))
|
||||||
|
|
||||||
local airbase=self.group:GetCoordinate():GetClosestAirbase()
|
local airbase=self.group:GetCoordinate():GetClosestAirbase()
|
||||||
|
|
||||||
@@ -1596,7 +1597,7 @@ function FLIGHTGROUP:onafterHold(From, Event, To, airbase, SpeedTo, SpeedHold, S
|
|||||||
wp[#wp+1]=pland:WaypointAirLanding(UTILS.KnotsToKmph(SpeedLand), airbase, {}, "Landing")
|
wp[#wp+1]=pland:WaypointAirLanding(UTILS.KnotsToKmph(SpeedLand), airbase, {}, "Landing")
|
||||||
|
|
||||||
|
|
||||||
|
-- Respawn?
|
||||||
local respawn=true
|
local respawn=true
|
||||||
|
|
||||||
if respawn then
|
if respawn then
|
||||||
@@ -1607,6 +1608,25 @@ function FLIGHTGROUP:onafterHold(From, Event, To, airbase, SpeedTo, SpeedHold, S
|
|||||||
-- Set route points.
|
-- Set route points.
|
||||||
Template.route.points=wp
|
Template.route.points=wp
|
||||||
|
|
||||||
|
if fc then
|
||||||
|
local n,parking=fc:_GetFreeParkingSpots()
|
||||||
|
-- TODO: getsize
|
||||||
|
if n>=1 then
|
||||||
|
for i,unit in pairs(Template.units) do
|
||||||
|
local spot=parking[i] --Ops.FlightControl#FLIGHTCONTROL.ParkingSpot
|
||||||
|
spot.reserved4=unit.name
|
||||||
|
unit.parking_landing=spot.id
|
||||||
|
local text=string.format("FF Reserving parking spot %d for unit %s", spot.id, tostring(unit.name))
|
||||||
|
env.info(text)
|
||||||
|
end
|
||||||
|
--[[
|
||||||
|
for _,_spot in pairs(parking) do
|
||||||
|
local spot=_spot --Ops.FlightControl#FLIGHTCONTROL.ParkingSpot
|
||||||
|
end
|
||||||
|
]]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
MESSAGE:New("Respawning group"):ToAll()
|
MESSAGE:New("Respawning group"):ToAll()
|
||||||
|
|
||||||
--Respawn the group.
|
--Respawn the group.
|
||||||
@@ -1887,11 +1907,10 @@ function FLIGHTGROUP._PassingWaypoint(group, flightgroup, i)
|
|||||||
if flightgroup.Debug then
|
if flightgroup.Debug then
|
||||||
local pos=group:GetCoordinate()
|
local pos=group:GetCoordinate()
|
||||||
--pos:SmokeRed()
|
--pos:SmokeRed()
|
||||||
local MarkerID=pos:MarkToAll(string.format("Group %s reached waypoint %d", group:GetName(), i))
|
--local MarkerID=pos:MarkToAll(string.format("Group %s reached waypoint %d", group:GetName(), i))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Debug message.
|
-- Debug message.
|
||||||
--MESSAGE:New(text,10):ToAllIf(flightgroup.Debug)
|
|
||||||
flightgroup:T3(flightgroup.sid..text)
|
flightgroup:T3(flightgroup.sid..text)
|
||||||
|
|
||||||
-- Set current waypoint.
|
-- Set current waypoint.
|
||||||
@@ -1910,7 +1929,7 @@ end
|
|||||||
-- @param Wrapper.Group#GROUP group Group object.
|
-- @param Wrapper.Group#GROUP group Group object.
|
||||||
-- @param #FLIGHTGROUP flightgroup Flight group object.
|
-- @param #FLIGHTGROUP flightgroup Flight group object.
|
||||||
function FLIGHTGROUP._ReachedHolding(group, flightgroup)
|
function FLIGHTGROUP._ReachedHolding(group, flightgroup)
|
||||||
env.info(string.format("FF group %s reached holding point", group:GetName()))
|
flightgroup:T(flightgroup.sid..string.format("Group %s reached holding point", group:GetName()))
|
||||||
|
|
||||||
if flightgroup.Debug then
|
if flightgroup.Debug then
|
||||||
group:GetCoordinate():MarkToAll("Holding Point Reached")
|
group:GetCoordinate():MarkToAll("Holding Point Reached")
|
||||||
@@ -2261,7 +2280,7 @@ function FLIGHTGROUP:_UpdateRoute(n)
|
|||||||
for i=n, #self.waypoints do
|
for i=n, #self.waypoints do
|
||||||
local w=self.waypoints[i]
|
local w=self.waypoints[i]
|
||||||
if self.Debug then
|
if self.Debug then
|
||||||
self:GetWaypointCoordinate(w):MarkToAll(string.format("UpdateRoute Waypoint %d", i))
|
--self:GetWaypointCoordinate(w):MarkToAll(string.format("UpdateRoute Waypoint %d", i))
|
||||||
end
|
end
|
||||||
table.insert(wp, w)
|
table.insert(wp, w)
|
||||||
end
|
end
|
||||||
@@ -3070,24 +3089,24 @@ end
|
|||||||
|
|
||||||
--- Get holding time.
|
--- Get holding time.
|
||||||
-- @param #FLIGHTGROUP self
|
-- @param #FLIGHTGROUP self
|
||||||
-- @return #number Holding time in seconds or 0 if flight is not holding.
|
-- @return #number Holding time in seconds or -1 if flight is not holding.
|
||||||
function FLIGHTGROUP:GetHoldingTime()
|
function FLIGHTGROUP:GetHoldingTime()
|
||||||
if self.Tholding then
|
if self.Tholding then
|
||||||
return timer.getAbsTime()-self.Tholding
|
return timer.getAbsTime()-self.Tholding
|
||||||
end
|
end
|
||||||
|
|
||||||
return 0
|
return -1
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get parking time.
|
--- Get parking time.
|
||||||
-- @param #FLIGHTGROUP self
|
-- @param #FLIGHTGROUP self
|
||||||
-- @return #number Holding time in seconds or 0 if flight is not holding.
|
-- @return #number Holding time in seconds or -1 if flight is not holding.
|
||||||
function FLIGHTGROUP:GetParkingTime()
|
function FLIGHTGROUP:GetParkingTime()
|
||||||
if self.Tparking then
|
if self.Tparking then
|
||||||
return timer.getAbsTime()-self.Tparking
|
return timer.getAbsTime()-self.Tparking
|
||||||
end
|
end
|
||||||
|
|
||||||
return 0
|
return -1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user