mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-17 03:11:28 +00:00
Ops
This commit is contained in:
@@ -8441,7 +8441,7 @@ end
|
|||||||
-- @return #string Text about warehouse stock
|
-- @return #string Text about warehouse stock
|
||||||
function WAREHOUSE:_UpdateWarehouseMarkText()
|
function WAREHOUSE:_UpdateWarehouseMarkText()
|
||||||
|
|
||||||
if self.makerOn then
|
if self.markerOn then
|
||||||
|
|
||||||
-- Create a mark with the current assets in stock.
|
-- Create a mark with the current assets in stock.
|
||||||
if self.markerid~=nil then
|
if self.markerid~=nil then
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
-- @field #number Nlanding Max number of aircraft groups in the landing pattern.
|
-- @field #number Nlanding Max number of aircraft groups in the landing pattern.
|
||||||
-- @field #number dTlanding Time interval in seconds between landing clearance.
|
-- @field #number dTlanding Time interval in seconds between landing clearance.
|
||||||
-- @field #number Nparkingspots Total number of parking spots.
|
-- @field #number Nparkingspots Total number of parking spots.
|
||||||
|
-- @field Core.Spawn#SPAWN parkingGuard Parking guard spawner.
|
||||||
-- @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.
|
||||||
@@ -106,8 +107,7 @@ FLIGHTCONTROL = {
|
|||||||
|
|
||||||
--- Parking spot data.
|
--- Parking spot data.
|
||||||
-- @type FLIGHTCONTROL.ParkingSpot
|
-- @type FLIGHTCONTROL.ParkingSpot
|
||||||
-- @field #boolean reserved If true, reserved.
|
-- @field Wrapper.Group#GROUP ParkingGuard Parking guard for this spot.
|
||||||
-- @field #number markerid ID of the marker.
|
|
||||||
-- @extends Wrapper.Airbase#AIRBASE.ParkingSpot
|
-- @extends Wrapper.Airbase#AIRBASE.ParkingSpot
|
||||||
|
|
||||||
--- Parking spot data.
|
--- Parking spot data.
|
||||||
@@ -140,6 +140,19 @@ FLIGHTCONTROL.FlightStatus={
|
|||||||
-- @field #number width Width of runway in meters.
|
-- @field #number width Width of runway in meters.
|
||||||
-- @field Core.Point#COORDINATE position Position of runway start.
|
-- @field Core.Point#COORDINATE position Position of runway start.
|
||||||
|
|
||||||
|
|
||||||
|
--- Sound file data.
|
||||||
|
-- @type FLIGHTCONTROL.Soundfile
|
||||||
|
-- @field #string filename Name of the file
|
||||||
|
-- @field #number duration Duration in seconds.
|
||||||
|
|
||||||
|
--- Sound files.
|
||||||
|
-- @type FLIGHTCONTROL.Sound
|
||||||
|
-- @field #FLIGHTCONTROL.Soundfile ActiveRunway
|
||||||
|
FLIGHTCONTROL.Sound = {
|
||||||
|
ActiveRunway={filename="ActiveRunway.ogg", duration=0.99},
|
||||||
|
}
|
||||||
|
|
||||||
--- FlightControl class version.
|
--- FlightControl class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
FLIGHTCONTROL.version="0.3.0"
|
FLIGHTCONTROL.version="0.3.0"
|
||||||
@@ -298,6 +311,18 @@ function FLIGHTCONTROL:SetActiveRunwayNumber(no)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Set the parking guard group.
|
||||||
|
-- @param #FLIGHTCONTROL self
|
||||||
|
-- @param #string TemplateGroupName Name of the template group.
|
||||||
|
-- @return #FLIGHTCONTROL self
|
||||||
|
function FLIGHTCONTROL:SetParkingGuard(TemplateGroupName)
|
||||||
|
|
||||||
|
self.parkingGuard=SPAWN:New(TemplateGroupName)
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- Status
|
-- Status
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -410,10 +435,19 @@ function FLIGHTCONTROL:OnEventBirth(EventData)
|
|||||||
self:I(self.lid..string.format("BIRTH: unit = %s", tostring(EventData.IniUnitName)))
|
self:I(self.lid..string.format("BIRTH: unit = %s", tostring(EventData.IniUnitName)))
|
||||||
self:T2(self.lid..string.format("BIRTH: group = %s", tostring(EventData.IniGroupName)))
|
self:T2(self.lid..string.format("BIRTH: group = %s", tostring(EventData.IniGroupName)))
|
||||||
|
|
||||||
|
-- Unit that was born.
|
||||||
|
local unit=EventData.IniUnit
|
||||||
|
|
||||||
-- We delay this, to have all elements of the group in the game.
|
-- We delay this, to have all elements of the group in the game.
|
||||||
if EventData.IniUnit:IsAir() then
|
if unit:IsAir() then
|
||||||
|
|
||||||
|
-- Coordinate.
|
||||||
|
local coordinate=unit:GetCoordinate()
|
||||||
|
|
||||||
self:ScheduleOnce(0.1, self._CreateFlightGroup, self, EventData.IniGroup)
|
self:ScheduleOnce(0.1, self._CreateFlightGroup, self, EventData.IniGroup)
|
||||||
|
|
||||||
|
self:SpawnParkingGuard(unit)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -591,18 +625,30 @@ function FLIGHTCONTROL:_CheckQueues()
|
|||||||
MESSAGE:New(text, 5, "FLIGHTCONTROL"):ToAll()
|
MESSAGE:New(text, 5, "FLIGHTCONTROL"):ToAll()
|
||||||
|
|
||||||
-- Start uncontrolled aircraft.
|
-- Start uncontrolled aircraft.
|
||||||
-- TODO: handle case with engines hot. That does not trigger a ENGINE_START event. More a FLIGHTGROUP issue.
|
if flight:IsUncontrolled() then
|
||||||
flight.group:StartUncontrolled()
|
flight:StartUncontrolled()
|
||||||
|
end
|
||||||
|
|
||||||
-- Add flight to takeoff queue.
|
-- Add flight to takeoff queue.
|
||||||
self:SetFlightStatus(flight, FLIGHTCONTROL.FlightStatus.TAKEOFF)
|
self:SetFlightStatus(flight, FLIGHTCONTROL.FlightStatus.TAKEOFF)
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
local text=string.format("HUMAN Flight %s, you are cleared for takeoff.", flight.groupname)
|
local text=string.format("HUMAN Flight %s, you are cleared for takeoff.", flight.groupname)
|
||||||
self:I(self.lid..text)
|
self:I(self.lid..text)
|
||||||
MESSAGE:New(text, 5, "FLIGHTCONTROL"):ToAll()
|
MESSAGE:New(text, 5, "FLIGHTCONTROL"):ToAll()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Remove parking guards.
|
||||||
|
for _,_element in pairs(flight.elements) do
|
||||||
|
local element=_element --Ops.FlightGroup#FLIGHTGROUP.Element
|
||||||
|
if element and element.parking then
|
||||||
|
local spot=self:GetParkingSpotByID(element.parking.TerminalID)
|
||||||
|
self:RemoveParkingGuard(spot)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
self:I(self.lid..string.format("FYI: Take of for flight %s denied as other flights are taking off (N=%d) or landing (N=%d).", flight.groupname, ntakeoff, nlanding))
|
self:I(self.lid..string.format("FYI: Take of for flight %s denied as other flights are taking off (N=%d) or landing (N=%d).", flight.groupname, ntakeoff, nlanding))
|
||||||
end
|
end
|
||||||
@@ -739,6 +785,9 @@ function FLIGHTCONTROL:_GetNextFightParking()
|
|||||||
|
|
||||||
-- First come, first serve.
|
-- First come, first serve.
|
||||||
return Qtaxiout[1]
|
return Qtaxiout[1]
|
||||||
|
|
||||||
|
else
|
||||||
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
local Qparking=self:GetFlights(FLIGHTCONTROL.FlightStatus.PARKING)
|
local Qparking=self:GetFlights(FLIGHTCONTROL.FlightStatus.PARKING)
|
||||||
@@ -1034,7 +1083,7 @@ end
|
|||||||
--- Get parking spot by its Terminal ID.
|
--- Get parking spot by its Terminal ID.
|
||||||
-- @param #FLIGHTCONTROL self
|
-- @param #FLIGHTCONTROL self
|
||||||
-- @param #number TerminalID
|
-- @param #number TerminalID
|
||||||
-- @return Wrapper.Airbase#AIRBASE.ParkingSpot Parking spot data table.
|
-- @return #FLIGHTCONTROL.ParkingSpot Parking spot data table.
|
||||||
function FLIGHTCONTROL:GetParkingSpotByID(TerminalID)
|
function FLIGHTCONTROL:GetParkingSpotByID(TerminalID)
|
||||||
return self.parking[TerminalID]
|
return self.parking[TerminalID]
|
||||||
end
|
end
|
||||||
@@ -1117,7 +1166,7 @@ function FLIGHTCONTROL:UpdateParkingMarker(spot)
|
|||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
spot.Marker=MARKER:New(spot.Coordinate, text):ToAll(Delay)
|
spot.Marker=MARKER:New(spot.Coordinate, text):ToAll()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1202,7 +1251,7 @@ end
|
|||||||
-- @param Core.Point#COORDINATE coordinate Reference coordinate.
|
-- @param Core.Point#COORDINATE coordinate Reference coordinate.
|
||||||
-- @param #number terminaltype (Optional) Check only this terminal type.
|
-- @param #number terminaltype (Optional) Check only this terminal type.
|
||||||
-- @param #boolean free (Optional) If true, check only free spots.
|
-- @param #boolean free (Optional) If true, check only free spots.
|
||||||
-- @return Wrapper.Airbase#AIRBASE.ParkingSpot Closest parking spot.
|
-- @return #FLIGHTCONTROL.ParkingSpot Closest parking spot.
|
||||||
function FLIGHTCONTROL:GetClosestParkingSpot(coordinate, terminaltype, free)
|
function FLIGHTCONTROL:GetClosestParkingSpot(coordinate, terminaltype, free)
|
||||||
|
|
||||||
local distmin=math.huge
|
local distmin=math.huge
|
||||||
@@ -1348,10 +1397,10 @@ function FLIGHTCONTROL:_PlayerRequestParking(groupname)
|
|||||||
MESSAGE:New(text, 10, "FLIGHCONTROL", true):ToAll()
|
MESSAGE:New(text, 10, "FLIGHCONTROL", true):ToAll()
|
||||||
|
|
||||||
-- Create mark on F10 map.
|
-- Create mark on F10 map.
|
||||||
if spot.MarkerID then
|
if spot.Marker then
|
||||||
coord:RemoveMark(spot.MarkerID)
|
spot.Marker:Remove()
|
||||||
end
|
end
|
||||||
spot.MarkerID=spot.Coordinate:MarkToGroup("Your assigned parking spot!", group)
|
spot.Marker:SetText("Your assigned parking spot!"):ToGroup(group)
|
||||||
|
|
||||||
-- TODO: get element of human player.
|
-- TODO: get element of human player.
|
||||||
local element=flight.elements[1] --Ops.FlightGroup#FLIGHTGROUP.Element
|
local element=flight.elements[1] --Ops.FlightGroup#FLIGHTGROUP.Element
|
||||||
@@ -1880,10 +1929,71 @@ function FLIGHTCONTROL:_GetHoldingpoint(flight)
|
|||||||
return holdingpoint
|
return holdingpoint
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-- Radio Functions
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
--- Transmission via RADIOQUEUE.
|
||||||
|
-- @param #FLIGHTCONTROL self
|
||||||
|
-- @param #FLIGHTCONTROL.Soundfile sound FLIGHTCONTROL sound object.
|
||||||
|
-- @param #number interval Interval in seconds after the last transmission finished.
|
||||||
|
-- @param #string subtitle Subtitle of the transmission.
|
||||||
|
-- @param #string path Path to sound file. Default self.soundpath.
|
||||||
|
function FLIGHTCONTROL:Transmission(sound, interval, subtitle, path)
|
||||||
|
self.radioqueue:NewTransmission(sound.filename, sound.duration, path or self.soundpath, nil, interval, subtitle, self.subduration)
|
||||||
|
end
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- Misc Functions
|
-- Misc Functions
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
--- Add parking guard in front of a parking aircraft.
|
||||||
|
-- @param #FLIGHTCONTROL self
|
||||||
|
-- @param Wrapper.Unit#UNIT Unit The aircraft.
|
||||||
|
function FLIGHTCONTROL:SpawnParkingGuard(unit)
|
||||||
|
|
||||||
|
if unit and self.parkingGuard then
|
||||||
|
|
||||||
|
local coordinate=unit:GetCoordinate()
|
||||||
|
|
||||||
|
-- Parking spot.
|
||||||
|
local spot=self:GetClosestParkingSpot(coordinate)
|
||||||
|
|
||||||
|
-- Current heading of the unit.
|
||||||
|
local heading=unit:GetHeading()
|
||||||
|
|
||||||
|
-- Length of the unit + 3 meters.
|
||||||
|
local _,distance=unit:GetObjectSize()+3
|
||||||
|
|
||||||
|
-- Coordinate for the guard.
|
||||||
|
local Coordinate=coordinate:Translate(distance, heading)
|
||||||
|
|
||||||
|
-- Let him face the aircraft.
|
||||||
|
local lookat=heading-180
|
||||||
|
|
||||||
|
-- Set heading and AI off to save resources.
|
||||||
|
self.parkingGuard:InitHeading(lookat,lookat):InitAIOff()
|
||||||
|
|
||||||
|
-- Group that is spawned.
|
||||||
|
spot.ParkingGuard=self.parkingGuard:SpawnFromCoordinate(Coordinate)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Remove parking guard.
|
||||||
|
-- @param #FLIGHTCONTROL self
|
||||||
|
-- @param #FLIGHTCONTROL.ParkingSpot spot
|
||||||
|
function FLIGHTCONTROL:RemoveParkingGuard(spot)
|
||||||
|
|
||||||
|
if spot.ParkingGuard then
|
||||||
|
spot.ParkingGuard:Destroy()
|
||||||
|
spot.ParkingGuard=nil
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Get coordinate of the airbase.
|
--- Get coordinate of the airbase.
|
||||||
-- @param #FLIGHTCONTROL self
|
-- @param #FLIGHTCONTROL self
|
||||||
-- @return Core.Point#COORDINATE Coordinate of the airbase.
|
-- @return Core.Point#COORDINATE Coordinate of the airbase.
|
||||||
|
|||||||
@@ -4680,14 +4680,14 @@ end
|
|||||||
|
|
||||||
--- Check if this group is currently "late activated" and needs to be "activated" to appear in the mission.
|
--- Check if this group is currently "late activated" and needs to be "activated" to appear in the mission.
|
||||||
-- @param #FLIGHTGROUP self
|
-- @param #FLIGHTGROUP self
|
||||||
-- @return #boolean Hot start?
|
-- @return #boolean Is this the group late activated?
|
||||||
function FLIGHTGROUP:IsLateActivated()
|
function FLIGHTGROUP:IsLateActivated()
|
||||||
return self.isLateActivated
|
return self.isLateActivated
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Check if this group is currently "uncontrolled" and needs to be "started" to begin its route.
|
--- Check if this group is currently "uncontrolled" and needs to be "started" to begin its route.
|
||||||
-- @param #FLIGHTGROUP self
|
-- @param #FLIGHTGROUP self
|
||||||
-- @return #boolean Hot start?
|
-- @return #boolean If this group uncontrolled.
|
||||||
function FLIGHTGROUP:IsUncontrolled()
|
function FLIGHTGROUP:IsUncontrolled()
|
||||||
return self.isUncontrolled
|
return self.isUncontrolled
|
||||||
end
|
end
|
||||||
@@ -5835,7 +5835,7 @@ end
|
|||||||
--- Get number of elements alive.
|
--- Get number of elements alive.
|
||||||
-- @param #FLIGHTGROUP self
|
-- @param #FLIGHTGROUP self
|
||||||
-- @param #string status (Optional) Only count number, which are in a special status.
|
-- @param #string status (Optional) Only count number, which are in a special status.
|
||||||
-- @return #number Holding time in seconds or -1 if flight is not holding.
|
-- @return #number Number of elements.
|
||||||
function FLIGHTGROUP:GetNelements(status)
|
function FLIGHTGROUP:GetNelements(status)
|
||||||
|
|
||||||
local n=0
|
local n=0
|
||||||
|
|||||||
@@ -344,6 +344,11 @@ function MARKER:ToAll(Delay)
|
|||||||
else
|
else
|
||||||
|
|
||||||
self.toall=true
|
self.toall=true
|
||||||
|
self.tocoaliton=nil
|
||||||
|
self.coalition=nil
|
||||||
|
self.togroup=nil
|
||||||
|
self.groupname=nil
|
||||||
|
self.groupid=nil
|
||||||
|
|
||||||
-- First remove an existing mark.
|
-- First remove an existing mark.
|
||||||
if self.shown then
|
if self.shown then
|
||||||
@@ -374,6 +379,10 @@ function MARKER:ToCoalition(Coalition, Delay)
|
|||||||
self.coalition=Coalition
|
self.coalition=Coalition
|
||||||
|
|
||||||
self.tocoaliton=true
|
self.tocoaliton=true
|
||||||
|
self.toall=false
|
||||||
|
self.togroup=false
|
||||||
|
self.groupname=nil
|
||||||
|
self.groupid=nil
|
||||||
|
|
||||||
-- First remove an existing mark.
|
-- First remove an existing mark.
|
||||||
if self.shown then
|
if self.shown then
|
||||||
@@ -439,6 +448,9 @@ function MARKER:ToGroup(Group, Delay)
|
|||||||
self.groupname=Group:GetName()
|
self.groupname=Group:GetName()
|
||||||
|
|
||||||
self.togroup=true
|
self.togroup=true
|
||||||
|
self.tocoaliton=nil
|
||||||
|
self.coalition=nil
|
||||||
|
self.toall=nil
|
||||||
|
|
||||||
-- First remove an existing mark.
|
-- First remove an existing mark.
|
||||||
if self.shown then
|
if self.shown then
|
||||||
@@ -480,6 +492,7 @@ function MARKER:UpdateText(Text, Delay)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Update the coordinate where the marker is displayed.
|
--- Update the coordinate where the marker is displayed.
|
||||||
@@ -501,6 +514,7 @@ function MARKER:UpdateCoordinate(Coordinate, Delay)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Refresh the marker.
|
--- Refresh the marker.
|
||||||
@@ -533,6 +547,7 @@ function MARKER:Refresh(Delay)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Remove a marker.
|
--- Remove a marker.
|
||||||
@@ -550,6 +565,7 @@ function MARKER:Remove(Delay)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get position of the marker.
|
--- Get position of the marker.
|
||||||
@@ -559,13 +575,22 @@ function MARKER:GetCoordinate()
|
|||||||
return self.coordinate
|
return self.coordinate
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get text that is dispayed in the marker panal.
|
--- Get text that is displayed in the marker panel.
|
||||||
-- @param #MARKER self
|
-- @param #MARKER self
|
||||||
-- @return #string Marker text.
|
-- @return #string Marker text.
|
||||||
function MARKER:GetText()
|
function MARKER:GetText()
|
||||||
return self.text
|
return self.text
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Set text that is displayed in the marker panel. Note this does not show the marker.
|
||||||
|
-- @param #MARKER self
|
||||||
|
-- @param #string Text Marker text.
|
||||||
|
-- @return #MARKER self
|
||||||
|
function MARKER:SetText(Text)
|
||||||
|
self.text=tostring(Text)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Check if marker is currently visible on the F10 map.
|
--- Check if marker is currently visible on the F10 map.
|
||||||
-- @param #MARKER self
|
-- @param #MARKER self
|
||||||
|
|||||||
Reference in New Issue
Block a user