mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-18 13:16:03 +00:00
Ops
This commit is contained in:
@@ -595,7 +595,7 @@ function AIRWING:onafterMissionRequest(From, Event, To, Mission)
|
|||||||
-- Set mission status to ASSIGNED.
|
-- Set mission status to ASSIGNED.
|
||||||
Mission.status=AUFTRAG.Status.ASSIGNED
|
Mission.status=AUFTRAG.Status.ASSIGNED
|
||||||
|
|
||||||
--TODO: Some assets might already be spawned and even on a different mission (orbit).
|
-- Some assets might already be spawned and even on a different mission (orbit).
|
||||||
-- Need to dived to set into spawned and instock assets and handle the other
|
-- Need to dived to set into spawned and instock assets and handle the other
|
||||||
|
|
||||||
-- Assets to be requested
|
-- Assets to be requested
|
||||||
@@ -603,18 +603,26 @@ function AIRWING:onafterMissionRequest(From, Event, To, Mission)
|
|||||||
|
|
||||||
for _,_asset in pairs(Mission.assets) do
|
for _,_asset in pairs(Mission.assets) do
|
||||||
local asset=_asset --#AIRWING.SquadronAsset
|
local asset=_asset --#AIRWING.SquadronAsset
|
||||||
|
|
||||||
if asset.spawned then
|
if asset.spawned then
|
||||||
|
|
||||||
|
if asset.flightgroup then
|
||||||
|
--TODO: cancel current mission if there is any!
|
||||||
|
asset.flightgroup:AddMission(asset.mission, asset.mission.waypointcoord, asset.mission.waypointindex)
|
||||||
|
else
|
||||||
|
--TODO: create flightgroup. should already be there actually!
|
||||||
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
|
-- These assets need to be requested and spawned.
|
||||||
table.insert(areq, asset)
|
table.insert(areq, asset)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--TODO: Check that mission prio is same as warehouse prio (small=high or the other way around).
|
-- Add request to airwing warehouse.
|
||||||
self:AddRequest(self, WAREHOUSE.Descriptor.ASSETLIST, areq, #areq, nil, nil, Mission.prio, tostring(Mission.auftragsnummer))
|
if #areq>0 then
|
||||||
|
self:AddRequest(self, WAREHOUSE.Descriptor.ASSETLIST, areq, #areq, nil, nil, Mission.prio, tostring(Mission.auftragsnummer))
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -660,10 +668,21 @@ function AIRWING:onafterAssetSpawned(From, Event, To, group, asset, request)
|
|||||||
-- Call parent warehouse function first.
|
-- Call parent warehouse function first.
|
||||||
self:GetParent(self).onafterAssetSpawned(self, From, Event, To, group, asset, request)
|
self:GetParent(self).onafterAssetSpawned(self, From, Event, To, group, asset, request)
|
||||||
|
|
||||||
local mid=tonumber(request.assignment)
|
-- Create a flight group.
|
||||||
|
self:_CreateFlightGroup(asset)
|
||||||
|
|
||||||
-- Set mission.
|
-- Get Mission (if any).
|
||||||
asset.mission=self:GetMissionByID(mid)
|
local mission=self:GetMissionByID(request.assignment)
|
||||||
|
|
||||||
|
-- Add mission to flightgroup queue.
|
||||||
|
if mission then
|
||||||
|
|
||||||
|
-- Set mission.
|
||||||
|
asset.mission=mission
|
||||||
|
|
||||||
|
-- Add mission to flightgroup queue.
|
||||||
|
asset.flightgroup:AddMission(asset.mission, asset.mission.waypointcoord, asset.mission.waypointindex)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -702,18 +721,15 @@ end
|
|||||||
|
|
||||||
--- Create a new flight group after an asset was spawned.
|
--- Create a new flight group after an asset was spawned.
|
||||||
-- @param #AIRWING self
|
-- @param #AIRWING self
|
||||||
-- @param Wrapper.Group#GROUP group The group.
|
|
||||||
-- @param #AIRWING.SquadronAsset asset The asset.
|
-- @param #AIRWING.SquadronAsset asset The asset.
|
||||||
function AIRWING:_CreateFlightGroup(group, asset)
|
function AIRWING:_CreateFlightGroup(asset)
|
||||||
|
|
||||||
-- Create flightgroup.
|
-- Create flightgroup.
|
||||||
local flightgroup=FLIGHTGROUP:New(group:GetName())
|
local flightgroup=FLIGHTGROUP:New(asset.spawngroupname)
|
||||||
|
|
||||||
asset.flightgroup=flightgroup
|
|
||||||
|
|
||||||
|
-- Set airwing.
|
||||||
flightgroup:SetAirwing(self)
|
flightgroup:SetAirwing(self)
|
||||||
|
|
||||||
|
|
||||||
--- Check if out of missiles. For A2A missions ==> RTB.
|
--- Check if out of missiles. For A2A missions ==> RTB.
|
||||||
function flightgroup:OnAfterOutOfMissiles()
|
function flightgroup:OnAfterOutOfMissiles()
|
||||||
local airwing=flightgroup:GetAirWing()
|
local airwing=flightgroup:GetAirWing()
|
||||||
@@ -745,13 +761,6 @@ function AIRWING:_CreateFlightGroup(group, asset)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Add mission to flightgroup queue.
|
|
||||||
if asset.mission then
|
|
||||||
local Cstart=UTILS.SecondsToClock(asset.mission.Tstart)
|
|
||||||
local Cstop=asset.mission.Tstop and UTILS.SecondsToClock(asset.mission.Tstop) or nil
|
|
||||||
asset.flightgroup:AddMission(asset.mission, asset.mission.waypointcoord, asset.mission.waypointindex, Cstart, Cstop, asset.mission.name)
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@@ -779,8 +788,21 @@ function AIRWING:SquadronCanMission(Squadron, MissionType, Nassets)
|
|||||||
for _,_asset in pairs(Squadron.assets) do
|
for _,_asset in pairs(Squadron.assets) do
|
||||||
local asset=_asset --#AIRWING.SquadronAsset
|
local asset=_asset --#AIRWING.SquadronAsset
|
||||||
|
|
||||||
-- Check if has already a mission assigned.
|
-- Check if has already any missions in the queue.
|
||||||
if asset.mission==nil then
|
if self:IsAssetOnMission() then
|
||||||
|
|
||||||
|
--TODO: This only checks if it has an ORBIT mission. It could have others as well!
|
||||||
|
if self:IsAssetOnMission(AUFTRAG.Type.ORBIT) then
|
||||||
|
|
||||||
|
-- Check if the payload of this asset is compatible with the mission.
|
||||||
|
if self:CheckMissionType(MissionType, asset.payload.missiontypes) then
|
||||||
|
-- TODO: check if asset actually has weapons left!
|
||||||
|
table.insert(assets, asset)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
---
|
---
|
||||||
-- This asset as no current mission
|
-- This asset as no current mission
|
||||||
@@ -801,13 +823,6 @@ function AIRWING:SquadronCanMission(Squadron, MissionType, Nassets)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif asset.mission==AUFTRAG.Type.ORBIT then
|
|
||||||
|
|
||||||
-- Check if the payload of this asset is compatible with the mission.
|
|
||||||
if self:CheckMissionType(MissionType, asset.payload.missiontypes) then
|
|
||||||
-- TODO: check if asset actually has weapons left!
|
|
||||||
table.insert(assets, asset)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -822,11 +837,38 @@ function AIRWING:SquadronCanMission(Squadron, MissionType, Nassets)
|
|||||||
return cando, assets
|
return cando, assets
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Check if assets for a given mission type are available.
|
--- Check if an asset is currently on a mission or has one in the queue.
|
||||||
-- @param #AIRWING self
|
-- @param #AIRWING self
|
||||||
-- @return #boolean If true, enough assets are available.
|
-- @param #AIRWING.SquadronAsset asset The asset.
|
||||||
function AIRWING:IsAssetOnMission()
|
-- @param #table MissionTypes Types on mission to be checked. Default all.
|
||||||
|
-- @return #boolean If true, asset has at least one mission of that type in the queue.
|
||||||
|
function AIRWING:IsAssetOnMission(asset, MissionTypes)
|
||||||
|
|
||||||
|
if MissionTypes then
|
||||||
|
if type(MissionTypes)~="table" then
|
||||||
|
MissionTypes={MissionTypes}
|
||||||
|
end
|
||||||
|
else
|
||||||
|
-- Check all possible types.
|
||||||
|
MissionTypes=AUFTRAG.Type
|
||||||
|
end
|
||||||
|
|
||||||
|
if asset.flightgroup then
|
||||||
|
|
||||||
|
-- Loop over mission queue.
|
||||||
|
for _,_mission in pairs(asset.flightgroup.missionqueue or {}) do
|
||||||
|
local mission=_mission --Ops.Auftrag#AUFTRAG
|
||||||
|
|
||||||
|
-- Only if mission is not already over.
|
||||||
|
if mission.status~=AUFTRAG.Status.DONE and self:CheckMissionType(mission.type, MissionTypes) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Check if assets for a given mission type are available.
|
--- Check if assets for a given mission type are available.
|
||||||
@@ -867,7 +909,7 @@ function AIRWING:CanMission(MissionType, Nassets)
|
|||||||
-- Now clear all reserved payloads.
|
-- Now clear all reserved payloads.
|
||||||
for _,_asset in pairs(Assets) do
|
for _,_asset in pairs(Assets) do
|
||||||
local asset=_asset --#AIRWING.SquadronAsset
|
local asset=_asset --#AIRWING.SquadronAsset
|
||||||
self:ReturnPayloadFromAsset(asset,payload)
|
self:ReturnPayloadFromAsset(asset)
|
||||||
end
|
end
|
||||||
|
|
||||||
return Can, Assets
|
return Can, Assets
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
-- @field #table DCStask DCS task structure.
|
-- @field #table DCStask DCS task structure.
|
||||||
-- @field Core.Point#COORDINATE waypointcoord Coordinate of the waypoint task.
|
-- @field Core.Point#COORDINATE waypointcoord Coordinate of the waypoint task.
|
||||||
-- @field #number waypointindex Waypoint number at which the task is executed.
|
-- @field #number waypointindex Waypoint number at which the task is executed.
|
||||||
-- @field Ops.FlightGroup#AUFTRAG.Task waypointtask Waypoint task.
|
-- @field Ops.FlightGroup#FLIGHTGROUP.Task waypointtask Waypoint task.
|
||||||
-- @field #number marker F10 map marker ID.
|
-- @field #number marker F10 map marker ID.
|
||||||
-- @field Core.Point#COORDINATE coordOrbit Coordinate where to orbit.
|
-- @field Core.Point#COORDINATE coordOrbit Coordinate where to orbit.
|
||||||
-- @field #number speedOrbit Orbit speed in m/s.
|
-- @field #number speedOrbit Orbit speed in m/s.
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
-- @field #string squadname Name of the assigned squadron.
|
-- @field #string squadname Name of the assigned squadron.
|
||||||
-- @field #table assets Assets assigned for this mission.
|
-- @field #table assets Assets assigned for this mission.
|
||||||
-- @field #number nassets Number of required assets.
|
-- @field #number nassets Number of required assets.
|
||||||
-- @extends Ops.FlightGroup#AUFTRAG
|
-- @extends Core.Fsm#FSM
|
||||||
|
|
||||||
--- *To invent an airplane is nothing. To build one is something. To fly is everything.* -- Otto Lilienthal
|
--- *To invent an airplane is nothing. To build one is something. To fly is everything.* -- Otto Lilienthal
|
||||||
--
|
--
|
||||||
@@ -115,16 +115,19 @@ AUFTRAG.Type={
|
|||||||
|
|
||||||
--- Mission status.
|
--- Mission status.
|
||||||
-- @type AUFTRAG.Status
|
-- @type AUFTRAG.Status
|
||||||
-- @field #string SCHEDULED Mission is scheduled.
|
-- @field #string PLANNED Mission is at the early planning stage.
|
||||||
-- @field #string ASSIGNED Mission was assigned.
|
-- @field #string SCHEDULED Mission is scheduled in a queue waiting to be assigned.
|
||||||
|
-- @field #string ASSIGNED Mission was assigned to somebody.
|
||||||
|
-- @field #string STARTED Mission started but is not executed yet.
|
||||||
-- @field #string EXECUTING Mission is being executed.
|
-- @field #string EXECUTING Mission is being executed.
|
||||||
-- @field #string ACCOMPLISHED Mission is accomplished.
|
-- @field #string DONE Mission is over.
|
||||||
AUFTRAG.Status={
|
AUFTRAG.Status={
|
||||||
|
PLANNED="planned",
|
||||||
SCHEDULED="scheduled",
|
SCHEDULED="scheduled",
|
||||||
ASSIGNED="assigned",
|
ASSIGNED="assigned",
|
||||||
|
STARTED="started",
|
||||||
EXECUTING="executing",
|
EXECUTING="executing",
|
||||||
ACCOMPLISHED="accomplished",
|
DONE="Done",
|
||||||
FAILED="failed",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user