mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-13 01:06:45 +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.
|
-- 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.
|
-- 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!
|
-- TODO: Need to check if my above comment not to confuse the dispatcher logic is broken by this!
|
||||||
group:Destroy(false)
|
group:Destroy()
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -294,10 +294,9 @@ end
|
|||||||
-- @return #FLIGHTCONTROL self
|
-- @return #FLIGHTCONTROL self
|
||||||
function FLIGHTCONTROL:SetParkingGuard(TemplateGroupName)
|
function FLIGHTCONTROL:SetParkingGuard(TemplateGroupName)
|
||||||
|
|
||||||
--self.parkingGuard=SPAWN:New(TemplateGroupName)
|
|
||||||
|
|
||||||
local alias=string.format("Parking Guard %s", self.airbasename)
|
local alias=string.format("Parking Guard %s", self.airbasename)
|
||||||
|
|
||||||
|
-- Need spawn with alias for multiple FCs.
|
||||||
self.parkingGuard=SPAWN:NewWithAlias(TemplateGroupName, alias)
|
self.parkingGuard=SPAWN:NewWithAlias(TemplateGroupName, alias)
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@@ -684,7 +683,7 @@ function FLIGHTCONTROL:_GetNextFlight()
|
|||||||
if parking then
|
if parking then
|
||||||
return flightholding, true, parking
|
return flightholding, true, parking
|
||||||
else
|
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
|
return nil, nil, nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -705,8 +704,8 @@ function FLIGHTCONTROL:_GetNextFlight()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Return the flight which is waiting longer.
|
-- 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
|
if flightholding.Tholding<flightparking.Tparking and parking then
|
||||||
return flightholding, true, parking
|
return flightholding, true, parking
|
||||||
else
|
else
|
||||||
return flightparking, false, nil
|
return flightparking, false, nil
|
||||||
@@ -878,8 +877,9 @@ function FLIGHTCONTROL:_PrintQueue(queue, name)
|
|||||||
local element=_element --Ops.FlightGroup#FLIGHTGROUP.Element
|
local element=_element --Ops.FlightGroup#FLIGHTGROUP.Element
|
||||||
local life=element.unit:GetLife()
|
local life=element.unit:GetLife()
|
||||||
local life0=element.unit:GetLife0()
|
local life0=element.unit:GetLife0()
|
||||||
text=text..string.format("\n (%d) %s (%s): status=%s, ai=%s, airborne=%s life=%.1f/%.1f",
|
local park=element.parking and tostring(element.parking.TerminalID) or "N/A"
|
||||||
j, tostring(element.modex), element.name, tostring(element.status), tostring(element.ai), tostring(element.unit:InAir()), life, life0)
|
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
|
end
|
||||||
end
|
end
|
||||||
@@ -1185,6 +1185,8 @@ function FLIGHTCONTROL:UpdateParkingMarker(spot)
|
|||||||
|
|
||||||
local spot=self:GetParkingSpotByID(spot.TerminalID)
|
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.
|
-- Only mark OCCUPIED and RESERVED spots.
|
||||||
if spot.Status==AIRBASE.SpotStatus.FREE then
|
if spot.Status==AIRBASE.SpotStatus.FREE then
|
||||||
|
|
||||||
@@ -1207,7 +1209,9 @@ function FLIGHTCONTROL:UpdateParkingMarker(spot)
|
|||||||
|
|
||||||
if spot.Marker then
|
if spot.Marker then
|
||||||
|
|
||||||
spot.Marker:UpdateText(text)
|
if text~=spot.Marker.text then
|
||||||
|
spot.Marker:UpdateText(text)
|
||||||
|
end
|
||||||
|
|
||||||
else
|
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)))
|
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=self.airbasename
|
||||||
|
local airbaseName=airbasename
|
||||||
|
if gotcontrol then
|
||||||
|
airbaseName=airbaseName.." *"
|
||||||
|
end
|
||||||
local Tag=airbasename
|
local Tag=airbasename
|
||||||
local Tnow=timer.getTime()
|
local Tnow=timer.getTime()
|
||||||
|
|
||||||
atcmenu[airbasename] = atcmenu[airbasename] or {}
|
atcmenu[airbasename] = atcmenu[airbasename] or {}
|
||||||
|
|
||||||
-- Airbase root menu.
|
-- 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
|
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)
|
MENU_GROUP_COMMAND_DELAYED:New(group, "ATIS", infomenu, self._PlayerRequestInfoATIS, self, groupname):SetTime(Tnow):SetTag(Tag)
|
||||||
|
|
||||||
-- Root Commands.
|
-- Root Commands.
|
||||||
if gotcontrol then
|
if gotcontrol then
|
||||||
|
|
||||||
---
|
---
|
||||||
-- FC is controlling this flight
|
-- FC is controlling this flight
|
||||||
@@ -1433,16 +1441,13 @@ function FLIGHTCONTROL:_CreatePlayerMenu(flight, atcmenu)
|
|||||||
---
|
---
|
||||||
|
|
||||||
if flight:IsAirborne() then
|
if flight:IsAirborne() then
|
||||||
|
|
||||||
MENU_GROUP_COMMAND_DELAYED:New(group, "Inbound", rootmenu, self._PlayerInbound, self, groupname):SetTime(Tnow):SetTag(Tag)
|
MENU_GROUP_COMMAND_DELAYED:New(group, "Inbound", rootmenu, self._PlayerInbound, self, groupname):SetTime(Tnow):SetTag(Tag)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if gotcontrol then
|
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
|
end
|
||||||
|
|
||||||
-- Reset the menu.
|
-- Reset the menu.
|
||||||
@@ -1495,38 +1500,28 @@ function FLIGHTCONTROL:_PlayerRequestInfo(groupname)
|
|||||||
local flight=_DATABASE:GetFlightGroup(groupname)
|
local flight=_DATABASE:GetFlightGroup(groupname)
|
||||||
|
|
||||||
if flight then
|
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)
|
MESSAGE:New(text, 5):ToGroup(flight.group)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Player menu request info.
|
--- Player menu request info.
|
||||||
-- @param #FLIGHTCONTROL self
|
-- @param #FLIGHTCONTROL self
|
||||||
-- @param #string groupname Name of the flight group.
|
-- @param #string groupname Name of the flight group.
|
||||||
function FLIGHTCONTROL:_PlayerRequestInfo(groupname)
|
function FLIGHTCONTROL:_PlayerRequestInfoATIS(groupname)
|
||||||
|
|
||||||
-- Get flight group.
|
-- Get flight group.
|
||||||
local flight=_DATABASE:GetFlightGroup(groupname)
|
local flight=_DATABASE:GetFlightGroup(groupname)
|
||||||
|
|
||||||
if flight then
|
if flight then
|
||||||
|
|
||||||
--
|
local text=string.format("Airbase %s ATIS:", self.airbasename)
|
||||||
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())
|
|
||||||
if self.atis then
|
if self.atis then
|
||||||
text=text..string.format("\nATIS %.3f MHz %s", self.atis.frequency, UTILS.GetModulationName(self.atis.modulation))
|
text=text..string.format("\nATIS %.3f MHz %s", self.atis.frequency, UTILS.GetModulationName(self.atis.modulation))
|
||||||
if self.atis.towerfrequency then
|
if self.atis.towerfrequency then
|
||||||
@@ -1551,6 +1546,37 @@ function FLIGHTCONTROL:_PlayerRequestInfo(groupname)
|
|||||||
|
|
||||||
MESSAGE:New(text, 5):ToGroup(flight.group)
|
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
|
else
|
||||||
MESSAGE:New(string.format("Cannot find flight group %s.", tostring(groupname)), 5):ToAll()
|
MESSAGE:New(string.format("Cannot find flight group %s.", tostring(groupname)), 5):ToAll()
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1494,7 +1494,7 @@ end
|
|||||||
function FLIGHTGROUP:onafterStop(From, Event, To)
|
function FLIGHTGROUP:onafterStop(From, Event, To)
|
||||||
|
|
||||||
-- Check if group is still alive.
|
-- 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).
|
-- Set element parking spot to FREE (after arrived for example).
|
||||||
if self.flightcontrol then
|
if self.flightcontrol then
|
||||||
@@ -1504,8 +1504,8 @@ function FLIGHTGROUP:onafterStop(From, Event, To)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Destroy group.
|
-- Destroy group. No event is generated.
|
||||||
self.group:Destroy()
|
self.group:Destroy(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Handle events:
|
-- Handle events:
|
||||||
@@ -2194,12 +2194,10 @@ function FLIGHTGROUP:onafterElementSpawned(From, Event, To, Element)
|
|||||||
local spot=self:GetParkingSpot(Element, 10)
|
local spot=self:GetParkingSpot(Element, 10)
|
||||||
|
|
||||||
if spot then
|
if spot then
|
||||||
|
|
||||||
-- Set
|
|
||||||
self:_SetElementParkingAt(Element, spot)
|
|
||||||
|
|
||||||
-- Trigger ElementParking event. Add a little delay because spawn is also delayed!
|
-- Trigger ElementParking event. Add a little delay because spawn is also delayed!
|
||||||
self:__ElementParking(0.11, Element)
|
self:__ElementParking(0.11, Element, spot)
|
||||||
|
|
||||||
else
|
else
|
||||||
-- TODO: This can happen if spawned on deck of a carrier!
|
-- 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."))
|
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 Event Event.
|
||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
-- @param #FLIGHTGROUP.Element Element The flight group element.
|
-- @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"))
|
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.
|
-- Set element status.
|
||||||
self:_UpdateStatus(Element, FLIGHTGROUP.ElementStatus.PARKING)
|
self:_UpdateStatus(Element, FLIGHTGROUP.ElementStatus.PARKING)
|
||||||
|
|
||||||
|
if Spot then
|
||||||
|
self:_SetElementParkingAt(Element, Spot)
|
||||||
|
end
|
||||||
|
|
||||||
if self:IsTakeoffCold() then
|
if self:IsTakeoffCold() then
|
||||||
-- Wait for engine startup event.
|
-- Wait for engine startup event.
|
||||||
elseif self:IsTakeoffHot() then
|
elseif self:IsTakeoffHot() then
|
||||||
@@ -5337,11 +5340,16 @@ function FLIGHTGROUP:_SetElementParkingAt(Element, Spot)
|
|||||||
|
|
||||||
-- Element is parking here.
|
-- Element is parking here.
|
||||||
Element.parking=Spot
|
Element.parking=Spot
|
||||||
|
|
||||||
|
if Spot then
|
||||||
|
|
||||||
if Spot and self.flightcontrol then
|
env.info(string.format("FF Element %s is parking on spot %d", Element.name, Spot.TerminalID))
|
||||||
|
|
||||||
-- Set parking spot to OCCUPIED.
|
if self.flightcontrol then
|
||||||
self.flightcontrol:SetParkingOccupied(Element.parking, Element.name)
|
|
||||||
|
-- Set parking spot to OCCUPIED.
|
||||||
|
self.flightcontrol:SetParkingOccupied(Element.parking, Element.name)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -6012,7 +6020,7 @@ function FLIGHTGROUP:GetParking(airbase)
|
|||||||
|
|
||||||
-- Check flightcontrol data.
|
-- Check flightcontrol data.
|
||||||
if self.flightcontrol and self.flightcontrol.airbasename==airbase:GetName() then
|
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
|
if problem then
|
||||||
free=false
|
free=false
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user