mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-07-17 07:33:56 +00:00
Ops
This commit is contained in:
@@ -3867,7 +3867,7 @@ function WAREHOUSE:onafterAddAsset(From, Event, To, group, ngroups, forceattribu
|
||||
-- Setting parameter to false, i.e. creating NO dead or remove unit event, seems to not confuse the dispatcher logic.
|
||||
-- Create a RemoveUnit event to let the FLIGHTCONTROL know, the parking is now free.
|
||||
-- TODO: Need to check if my above comment not to confuse the dispatcher logic is broken by this!
|
||||
group:Destroy(false)
|
||||
group:Destroy()
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
@@ -294,10 +294,9 @@ end
|
||||
-- @return #FLIGHTCONTROL self
|
||||
function FLIGHTCONTROL:SetParkingGuard(TemplateGroupName)
|
||||
|
||||
--self.parkingGuard=SPAWN:New(TemplateGroupName)
|
||||
|
||||
local alias=string.format("Parking Guard %s", self.airbasename)
|
||||
|
||||
|
||||
-- Need spawn with alias for multiple FCs.
|
||||
self.parkingGuard=SPAWN:NewWithAlias(TemplateGroupName, alias)
|
||||
|
||||
return self
|
||||
@@ -684,7 +683,7 @@ function FLIGHTCONTROL:_GetNextFlight()
|
||||
if parking then
|
||||
return flightholding, true, parking
|
||||
else
|
||||
self:E(string.format("WARNING: No flight parking but no parking spots! nP=%d nH=%d", #parking, nH))
|
||||
self:E(self.lid..string.format("WARNING: No flight parking but no parking spots! nP=%d nH=%d", #parking, nH))
|
||||
return nil, nil, nil
|
||||
end
|
||||
end
|
||||
@@ -705,8 +704,8 @@ function FLIGHTCONTROL:_GetNextFlight()
|
||||
end
|
||||
end
|
||||
|
||||
-- Return the flight which is waiting longer.
|
||||
if flightholding.Tholding>flightparking.Tparking and parking then
|
||||
-- Return the flight which is waiting longer. NOTE that Tholding and Tparking are abs. mission time. So a smaller value means waiting longer.
|
||||
if flightholding.Tholding<flightparking.Tparking and parking then
|
||||
return flightholding, true, parking
|
||||
else
|
||||
return flightparking, false, nil
|
||||
@@ -878,8 +877,9 @@ function FLIGHTCONTROL:_PrintQueue(queue, name)
|
||||
local element=_element --Ops.FlightGroup#FLIGHTGROUP.Element
|
||||
local life=element.unit:GetLife()
|
||||
local life0=element.unit:GetLife0()
|
||||
text=text..string.format("\n (%d) %s (%s): status=%s, ai=%s, airborne=%s life=%.1f/%.1f",
|
||||
j, tostring(element.modex), element.name, tostring(element.status), tostring(element.ai), tostring(element.unit:InAir()), life, life0)
|
||||
local park=element.parking and tostring(element.parking.TerminalID) or "N/A"
|
||||
text=text..string.format("\n (%d) %s (%s): status=%s, ai=%s, airborne=%s life=%d/%d spot=%s",
|
||||
j, tostring(element.modex), element.name, tostring(element.status), tostring(element.ai), tostring(element.unit:InAir()), life, life0, park)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1185,6 +1185,8 @@ function FLIGHTCONTROL:UpdateParkingMarker(spot)
|
||||
|
||||
local spot=self:GetParkingSpotByID(spot.TerminalID)
|
||||
|
||||
env.info(string.format("FF updateing spot %d status=%s", spot.TerminalID, spot.Status))
|
||||
|
||||
-- Only mark OCCUPIED and RESERVED spots.
|
||||
if spot.Status==AIRBASE.SpotStatus.FREE then
|
||||
|
||||
@@ -1207,7 +1209,9 @@ function FLIGHTCONTROL:UpdateParkingMarker(spot)
|
||||
|
||||
if spot.Marker then
|
||||
|
||||
spot.Marker:UpdateText(text)
|
||||
if text~=spot.Marker.text then
|
||||
spot.Marker:UpdateText(text)
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
@@ -1370,13 +1374,17 @@ function FLIGHTCONTROL:_CreatePlayerMenu(flight, atcmenu)
|
||||
self:I(self.lid..string.format("Creating ATC player menu for flight %s: in state=%s status=%s, gotcontrol=%s", tostring(flight.groupname), flight:GetState(), flightstatus, tostring(gotcontrol)))
|
||||
|
||||
local airbasename=self.airbasename
|
||||
local airbaseName=airbasename
|
||||
if gotcontrol then
|
||||
airbaseName=airbaseName.." *"
|
||||
end
|
||||
local Tag=airbasename
|
||||
local Tnow=timer.getTime()
|
||||
|
||||
atcmenu[airbasename] = atcmenu[airbasename] or {}
|
||||
|
||||
-- Airbase root menu.
|
||||
atcmenu[airbasename].root = MENU_GROUP_DELAYED:New(group, airbasename, atcmenu.root):SetTime(Tnow):SetTag(Tag)
|
||||
atcmenu[airbasename].root = MENU_GROUP_DELAYED:New(group, airbaseName, atcmenu.root):SetTime(Tnow):SetTag(Tag)
|
||||
|
||||
local rootmenu=atcmenu[airbasename].root --Core.Menu#MENU_GROUP_DELAYED
|
||||
|
||||
@@ -1390,7 +1398,7 @@ function FLIGHTCONTROL:_CreatePlayerMenu(flight, atcmenu)
|
||||
MENU_GROUP_COMMAND_DELAYED:New(group, "ATIS", infomenu, self._PlayerRequestInfoATIS, self, groupname):SetTime(Tnow):SetTag(Tag)
|
||||
|
||||
-- Root Commands.
|
||||
if gotcontrol then
|
||||
if gotcontrol then
|
||||
|
||||
---
|
||||
-- FC is controlling this flight
|
||||
@@ -1433,16 +1441,13 @@ function FLIGHTCONTROL:_CreatePlayerMenu(flight, atcmenu)
|
||||
---
|
||||
|
||||
if flight:IsAirborne() then
|
||||
|
||||
MENU_GROUP_COMMAND_DELAYED:New(group, "Inbound", rootmenu, self._PlayerInbound, self, groupname):SetTime(Tnow):SetTag(Tag)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
if gotcontrol then
|
||||
MENU_GROUP_COMMAND_DELAYED:New(group, "My Status", rootmenu, self._PlayerMyStatus, self, groupname):SetTime(Tnow):SetTag(Tag)
|
||||
MENU_GROUP_COMMAND_DELAYED:New(group, "My Status", rootmenu, self._PlayerMyStatus, self, groupname):SetTime(Tnow):SetTag(Tag)
|
||||
end
|
||||
|
||||
-- Reset the menu.
|
||||
@@ -1495,38 +1500,28 @@ function FLIGHTCONTROL:_PlayerRequestInfo(groupname)
|
||||
local flight=_DATABASE:GetFlightGroup(groupname)
|
||||
|
||||
if flight then
|
||||
|
||||
local text="No info implemented yet"
|
||||
|
||||
local text=string.format("Airbase %s Info:", self.airbasename)
|
||||
text=text..string.format("\nRunway %s", self:GetActiveRunwayText())
|
||||
|
||||
MESSAGE:New(text, 5):ToGroup(flight.group)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
--- Player menu request info.
|
||||
-- @param #FLIGHTCONTROL self
|
||||
-- @param #string groupname Name of the flight group.
|
||||
function FLIGHTCONTROL:_PlayerRequestInfo(groupname)
|
||||
function FLIGHTCONTROL:_PlayerRequestInfoATIS(groupname)
|
||||
|
||||
-- Get flight group.
|
||||
local flight=_DATABASE:GetFlightGroup(groupname)
|
||||
|
||||
if flight then
|
||||
|
||||
--
|
||||
local text=string.format("Airbase %s Status:", self.airbasename)
|
||||
text=text..string.format("\nFlights %d", #self.flights)
|
||||
text=text..string.format("\nQinbound %d", self:CountFlights(FLIGHTCONTROL.FlightStatus.INBOUND))
|
||||
text=text..string.format("\nQholding %d", self:CountFlights(FLIGHTCONTROL.FlightStatus.HOLDING))
|
||||
text=text..string.format("\nQlanding %d", self:CountFlights(FLIGHTCONTROL.FlightStatus.LANDING))
|
||||
text=text..string.format("\nQtaxiInb %d", self:CountFlights(FLIGHTCONTROL.FlightStatus.TAXIINB))
|
||||
text=text..string.format("\nQarrived %d", self:CountFlights(FLIGHTCONTROL.FlightStatus.ARRIVED))
|
||||
text=text..string.format("\nQparking %d", self:CountFlights(FLIGHTCONTROL.FlightStatus.PARKING))
|
||||
text=text..string.format("\nQtaxiOut %d", self:CountFlights(FLIGHTCONTROL.FlightStatus.TAXIOUT))
|
||||
text=text..string.format("\nQreadiTO %d", self:CountFlights(FLIGHTCONTROL.FlightStatus.READYTO))
|
||||
text=text..string.format("\nQtakeoff %d", self:CountFlights(FLIGHTCONTROL.FlightStatus.TAKEOFF))
|
||||
text=text..string.format("\nRunway %s", self:GetActiveRunwayText())
|
||||
local text=string.format("Airbase %s ATIS:", self.airbasename)
|
||||
|
||||
if self.atis then
|
||||
text=text..string.format("\nATIS %.3f MHz %s", self.atis.frequency, UTILS.GetModulationName(self.atis.modulation))
|
||||
if self.atis.towerfrequency then
|
||||
@@ -1551,6 +1546,37 @@ function FLIGHTCONTROL:_PlayerRequestInfo(groupname)
|
||||
|
||||
MESSAGE:New(text, 5):ToGroup(flight.group)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
--- Player menu request info.
|
||||
-- @param #FLIGHTCONTROL self
|
||||
-- @param #string groupname Name of the flight group.
|
||||
function FLIGHTCONTROL:_PlayerRequestInfoQueues(groupname)
|
||||
|
||||
-- Get flight group.
|
||||
local flight=_DATABASE:GetFlightGroup(groupname)
|
||||
|
||||
if flight then
|
||||
|
||||
--
|
||||
local text=string.format("Airbase %s Status:", self.airbasename)
|
||||
text=text..string.format("\nFlights %d", #self.flights)
|
||||
text=text..string.format("\nQinbound %d", self:CountFlights(FLIGHTCONTROL.FlightStatus.INBOUND))
|
||||
text=text..string.format("\nQholding %d", self:CountFlights(FLIGHTCONTROL.FlightStatus.HOLDING))
|
||||
text=text..string.format("\nQlanding %d", self:CountFlights(FLIGHTCONTROL.FlightStatus.LANDING))
|
||||
text=text..string.format("\nQtaxiInb %d", self:CountFlights(FLIGHTCONTROL.FlightStatus.TAXIINB))
|
||||
text=text..string.format("\nQarrived %d", self:CountFlights(FLIGHTCONTROL.FlightStatus.ARRIVED))
|
||||
text=text..string.format("\nQparking %d", self:CountFlights(FLIGHTCONTROL.FlightStatus.PARKING))
|
||||
text=text..string.format("\nQtaxiOut %d", self:CountFlights(FLIGHTCONTROL.FlightStatus.TAXIOUT))
|
||||
text=text..string.format("\nQreadiTO %d", self:CountFlights(FLIGHTCONTROL.FlightStatus.READYTO))
|
||||
text=text..string.format("\nQtakeoff %d", self:CountFlights(FLIGHTCONTROL.FlightStatus.TAKEOFF))
|
||||
text=text..string.format("\nRunway %s", self:GetActiveRunwayText())
|
||||
|
||||
MESSAGE:New(text, 5):ToGroup(flight.group)
|
||||
|
||||
else
|
||||
MESSAGE:New(string.format("Cannot find flight group %s.", tostring(groupname)), 5):ToAll()
|
||||
end
|
||||
|
||||
@@ -1494,7 +1494,7 @@ end
|
||||
function FLIGHTGROUP:onafterStop(From, Event, To)
|
||||
|
||||
-- Check if group is still alive.
|
||||
if self:IsAlive() and false then
|
||||
if self:IsAlive() then
|
||||
|
||||
-- Set element parking spot to FREE (after arrived for example).
|
||||
if self.flightcontrol then
|
||||
@@ -1504,8 +1504,8 @@ function FLIGHTGROUP:onafterStop(From, Event, To)
|
||||
end
|
||||
end
|
||||
|
||||
-- Destroy group.
|
||||
self.group:Destroy()
|
||||
-- Destroy group. No event is generated.
|
||||
self.group:Destroy(false)
|
||||
end
|
||||
|
||||
-- Handle events:
|
||||
@@ -2194,12 +2194,10 @@ function FLIGHTGROUP:onafterElementSpawned(From, Event, To, Element)
|
||||
local spot=self:GetParkingSpot(Element, 10)
|
||||
|
||||
if spot then
|
||||
|
||||
-- Set
|
||||
self:_SetElementParkingAt(Element, spot)
|
||||
|
||||
-- Trigger ElementParking event. Add a little delay because spawn is also delayed!
|
||||
self:__ElementParking(0.11, Element)
|
||||
self:__ElementParking(0.11, Element, spot)
|
||||
|
||||
else
|
||||
-- TODO: This can happen if spawned on deck of a carrier!
|
||||
self:E(self.lid..string.format("Element spawned not in air but not on any parking spot."))
|
||||
@@ -2214,12 +2212,17 @@ end
|
||||
-- @param #string Event Event.
|
||||
-- @param #string To To state.
|
||||
-- @param #FLIGHTGROUP.Element Element The flight group element.
|
||||
function FLIGHTGROUP:onafterElementParking(From, Event, To, Element)
|
||||
-- @param #FLIGHTGROUP.ParkingSpot Spot Parking Spot.
|
||||
function FLIGHTGROUP:onafterElementParking(From, Event, To, Element, Spot)
|
||||
self:T(self.lid..string.format("Element parking %s at spot %s", Element.name, Element.parking and tostring(Element.parking.TerminalID) or "N/A"))
|
||||
|
||||
-- Set element status.
|
||||
self:_UpdateStatus(Element, FLIGHTGROUP.ElementStatus.PARKING)
|
||||
|
||||
if Spot then
|
||||
self:_SetElementParkingAt(Element, Spot)
|
||||
end
|
||||
|
||||
if self:IsTakeoffCold() then
|
||||
-- Wait for engine startup event.
|
||||
elseif self:IsTakeoffHot() then
|
||||
@@ -5337,11 +5340,16 @@ function FLIGHTGROUP:_SetElementParkingAt(Element, Spot)
|
||||
|
||||
-- Element is parking here.
|
||||
Element.parking=Spot
|
||||
|
||||
if Spot then
|
||||
|
||||
if Spot and self.flightcontrol then
|
||||
|
||||
-- Set parking spot to OCCUPIED.
|
||||
self.flightcontrol:SetParkingOccupied(Element.parking, Element.name)
|
||||
env.info(string.format("FF Element %s is parking on spot %d", Element.name, Spot.TerminalID))
|
||||
|
||||
if self.flightcontrol then
|
||||
|
||||
-- Set parking spot to OCCUPIED.
|
||||
self.flightcontrol:SetParkingOccupied(Element.parking, Element.name)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -6012,7 +6020,7 @@ function FLIGHTGROUP:GetParking(airbase)
|
||||
|
||||
-- Check flightcontrol data.
|
||||
if self.flightcontrol and self.flightcontrol.airbasename==airbase:GetName() then
|
||||
local problem=self.flightcontrol:IsParkingReserved(parkingspot)
|
||||
local problem=self.flightcontrol:IsParkingReserved(parkingspot) or self.flightcontrol:IsParkingOccupied(parkingspot)
|
||||
if problem then
|
||||
free=false
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user