mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-18 05:05:56 +00:00
Update FlightGroup.lua
This commit is contained in:
@@ -1293,9 +1293,16 @@ end
|
|||||||
function FLIGHTGROUP:onafterElementParking(From, Event, To, Element)
|
function FLIGHTGROUP:onafterElementParking(From, Event, To, Element)
|
||||||
self:I(self.lid..string.format("Element parking %s at spot %s", Element.name, tostring(Element.parking.TerminalID)))
|
self:I(self.lid..string.format("Element parking %s at spot %s", Element.name, tostring(Element.parking.TerminalID)))
|
||||||
|
|
||||||
|
|
||||||
-- Set element status.
|
-- Set element status.
|
||||||
self:_UpdateStatus(Element, FLIGHTGROUP.ElementStatus.PARKING)
|
self:_UpdateStatus(Element, FLIGHTGROUP.ElementStatus.PARKING)
|
||||||
|
|
||||||
|
if self:IsStartCold() then
|
||||||
|
-- Wait for engine startup event.
|
||||||
|
elseif self:IsStartHot() then
|
||||||
|
self:ElementTaxiing(Element)
|
||||||
|
elseif self:IsStartRunway() then
|
||||||
|
self:ElementTaxiing(Element)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- On after "ElementTaxiing" event.
|
--- On after "ElementTaxiing" event.
|
||||||
@@ -1306,16 +1313,18 @@ end
|
|||||||
-- @param #FLIGHTGROUP.Element Element The flight group element.
|
-- @param #FLIGHTGROUP.Element Element The flight group element.
|
||||||
function FLIGHTGROUP:onafterElementTaxiing(From, Event, To, Element)
|
function FLIGHTGROUP:onafterElementTaxiing(From, Event, To, Element)
|
||||||
|
|
||||||
local TerminalID="N/A"
|
-- Get terminal ID.
|
||||||
|
local TerminalID=Element.parking and tostring(Element.parking.TerminalID) or "N/A"
|
||||||
|
|
||||||
-- Remove marker.
|
-- Remove marker.
|
||||||
if self.flightcontrol and Element.parking then
|
if self.flightcontrol and Element.parking then
|
||||||
TerminalID=tostring(Element.parking.TerminalID)
|
|
||||||
local parking=self.flightcontrol.parking[Element.parking.TerminalID] --Wrapper.Airbase#AIRBASE.ParkingSpot
|
local parking=self.flightcontrol.parking[Element.parking.TerminalID] --Wrapper.Airbase#AIRBASE.ParkingSpot
|
||||||
if parking and parking.MarkerID then
|
if parking and parking.MarkerID then
|
||||||
parking.Coordinate:RemoveMark(parking.MarkerID)
|
parking.Coordinate:RemoveMark(parking.MarkerID)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Debug info.
|
||||||
self:I(self.lid..string.format("Element taxiing %s. Parking spot %s is now free", Element.name, TerminalID))
|
self:I(self.lid..string.format("Element taxiing %s. Parking spot %s is now free", Element.name, TerminalID))
|
||||||
|
|
||||||
-- Not parking any more.
|
-- Not parking any more.
|
||||||
@@ -1659,12 +1668,15 @@ end
|
|||||||
-- @param #number n Waypoint number.
|
-- @param #number n Waypoint number.
|
||||||
function FLIGHTGROUP:onafterUpdateRoute(From, Event, To, n)
|
function FLIGHTGROUP:onafterUpdateRoute(From, Event, To, n)
|
||||||
|
|
||||||
MESSAGE:New("Updating route", 10):ToAll()
|
|
||||||
self:I(self.lid.."Updating route")
|
|
||||||
|
|
||||||
-- TODO: what happens if currentwp=#waypoints
|
-- TODO: what happens if currentwp=#waypoints
|
||||||
n=n or self.currentwp+1
|
n=n or self.currentwp+1
|
||||||
|
|
||||||
|
-- Debug info.
|
||||||
|
local text=string.format("Updating route n=%d for group %s", n, self.groupname)
|
||||||
|
MESSAGE:New(text, 10):ToAll()
|
||||||
|
self:I(self.lid..text)
|
||||||
|
|
||||||
|
|
||||||
-- Update waypoint tasks, i.e. inject WP tasks into waypoint table.
|
-- Update waypoint tasks, i.e. inject WP tasks into waypoint table.
|
||||||
self:_UpdateWaypointTasks()
|
self:_UpdateWaypointTasks()
|
||||||
|
|
||||||
@@ -2570,6 +2582,85 @@ function FLIGHTGROUP:GetDestinationFromWaypoints()
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Check if this is a hot start.
|
||||||
|
-- @param #FLIGHTGROUP self
|
||||||
|
-- @return #boolean Hot start?
|
||||||
|
function FLIGHTGROUP:IsStartHot()
|
||||||
|
|
||||||
|
local wp=self:GetWaypoint(1)
|
||||||
|
|
||||||
|
if wp then
|
||||||
|
|
||||||
|
if wp.action and wp.action==COORDINATE.WaypointAction.FromParkingAreaHot then
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Check if this is a cold start.
|
||||||
|
-- @param #FLIGHTGROUP self
|
||||||
|
-- @return #boolean Cold start, i.e. engines off when spawned?
|
||||||
|
function FLIGHTGROUP:IsStartCold()
|
||||||
|
|
||||||
|
local wp=self:GetWaypoint(1)
|
||||||
|
|
||||||
|
if wp then
|
||||||
|
|
||||||
|
if wp.action and wp.action==COORDINATE.WaypointAction.FromParkingArea then
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Check if this is a runway start.
|
||||||
|
-- @param #FLIGHTGROUP self
|
||||||
|
-- @return #boolean Runway start?
|
||||||
|
function FLIGHTGROUP:IsStartRunway()
|
||||||
|
|
||||||
|
local wp=self:GetWaypoint(1)
|
||||||
|
|
||||||
|
if wp then
|
||||||
|
|
||||||
|
if wp.action and wp.action==COORDINATE.WaypointAction.FromRunway then
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Check if this is an air start.
|
||||||
|
-- @param #FLIGHTGROUP self
|
||||||
|
-- @return #boolean Air start?
|
||||||
|
function FLIGHTGROUP:IsStartAir()
|
||||||
|
|
||||||
|
local wp=self:GetWaypoint(1)
|
||||||
|
|
||||||
|
if wp then
|
||||||
|
|
||||||
|
if wp.action and wp.action==COORDINATE.WaypointAction.TurningPoint or wp.action==COORDINATE.WaypointAction.FlyoverPoint then
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
--- Check if task description is unique.
|
--- Check if task description is unique.
|
||||||
-- @param #FLIGHTGROUP self
|
-- @param #FLIGHTGROUP self
|
||||||
@@ -3143,6 +3234,7 @@ function FLIGHTGROUP:_CheckDetectedUnits()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Loop over units in detected set.
|
-- Loop over units in detected set.
|
||||||
|
local lost={}
|
||||||
for _,_unit in pairs(self.detectedunits:GetSet()) do
|
for _,_unit in pairs(self.detectedunits:GetSet()) do
|
||||||
local unit=_unit --Wrapper.Unit#UNIT
|
local unit=_unit --Wrapper.Unit#UNIT
|
||||||
|
|
||||||
@@ -3156,11 +3248,15 @@ function FLIGHTGROUP:_CheckDetectedUnits()
|
|||||||
end
|
end
|
||||||
|
|
||||||
if not gotit then
|
if not gotit then
|
||||||
|
table.insert(lost, unit:GetName())
|
||||||
self:DetectedUnitLost(unit)
|
self:DetectedUnitLost(unit)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Remove lost units from detected set.
|
||||||
|
self.detectedunits:RemoveUnitsByName(lost)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user