mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-07-27 17:11:11 +00:00
Ops
This commit is contained in:
@@ -113,6 +113,7 @@ function AIRWING:New(warehousename, airwingname)
|
||||
self:AddTransition("*", "MissionNew", "*") -- Add a new mission.
|
||||
self:AddTransition("*", "MissionRequest", "*") -- Add a (mission) request to the warehouse.
|
||||
self:AddTransition("*", "MissionDone", "*") -- Mission is over.
|
||||
self:AddTransition("*", "MissionCancel", "*") -- Mission is over.
|
||||
|
||||
------------------------
|
||||
--- Pseudo Functions ---
|
||||
@@ -507,7 +508,7 @@ end
|
||||
--- Optimize chosen assets for the mission at hand.
|
||||
-- @param #AIRWING self
|
||||
-- @param #table assets Table of (unoptimized) assets.
|
||||
-- @param Ops.Auftrag#AUFTRAG Next mission or *nil*.
|
||||
-- @param Ops.Auftrag#AUFTRAG Mission Next mission or *nil*.
|
||||
function AIRWING:_OptimizeAssetSelection(assets, Mission)
|
||||
|
||||
local TargetCoordinate=Mission:GetTargetCoordinate()
|
||||
@@ -585,15 +586,27 @@ function AIRWING:onafterNewAsset(From, Event, To, asset, assignment)
|
||||
end
|
||||
end
|
||||
|
||||
--- On after "MissionNew" event.
|
||||
--- On after "MissionCancel" event.
|
||||
-- @param #AIRWING self
|
||||
-- @param #string From From state.
|
||||
-- @param #string Event Event.
|
||||
-- @param #string To To state.
|
||||
-- @param Ops.Auftrag#AUFTRAG Mission
|
||||
function AIRWING:onafterMissionNew(From, Event, To, Mission)
|
||||
-- @param Ops.Auftrag#AUFTRAG Mission The mission to be cancelled.
|
||||
function AIRWING:onafterMissionCancel(From, Event, To, Mission)
|
||||
|
||||
self:I(self.lid..string.format("Cancel mission %s", Mission.name))
|
||||
|
||||
for _,_asset in pairs(Mission.assets) do
|
||||
local asset=_asset --#AIRWING.SquadronAsset
|
||||
|
||||
local flightgroup=asset.flightgroup
|
||||
|
||||
if flightgroup then
|
||||
flightgroup:MissionCancel(Mission)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
self:I(self.lid..string.format("New mission %s", Mission.name))
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
-- @field #string status Mission status.
|
||||
-- @field #string name Mission name.
|
||||
-- @field #number prio Mission priority.
|
||||
-- @field #boolean urgent Mission is urgent. Running missions with lower prio might be cancelled.
|
||||
-- @field #number Tstart Mission start time in seconds.
|
||||
-- @field #number Tstop Mission stop time in seconds.
|
||||
-- @field #number duration Mission duration in seconds.
|
||||
@@ -408,7 +409,7 @@ end
|
||||
-- @return #AUFTRAG self
|
||||
function AUFTRAG:SetPriority(Prio, Urgent)
|
||||
self.prio=Prio or 50
|
||||
self.isurgent=Urgent
|
||||
self.urgent=Urgent
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
@@ -1398,12 +1398,26 @@ function FLIGHTGROUP:onafterQueueUpdate(From, Event, To)
|
||||
---
|
||||
|
||||
-- First check if group is alive? Late activated groups are activated and uncontrolled units are started automatically.
|
||||
if self:IsAlive()~=nil and not self.currentmission then
|
||||
if self:IsAlive()~=nil then
|
||||
|
||||
local mission=self:_GetNextMission()
|
||||
|
||||
if mission then
|
||||
self:MissionStart(mission)
|
||||
|
||||
local currentmission=self:GetMissionCurrent()
|
||||
|
||||
if currentmission then
|
||||
|
||||
-- Current mission but new mission is urgent with higher prio.
|
||||
if mission.urgent and mission.prio<currentmission.prio then
|
||||
self:MissionCancel(currentmission)
|
||||
self:MissionStart(mission)
|
||||
end
|
||||
|
||||
else
|
||||
-- No current mission.
|
||||
self:MissionStart(mission)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2260,24 +2274,21 @@ function FLIGHTGROUP:onafterUpdateRoute(From, Event, To, n)
|
||||
---
|
||||
|
||||
self:E(self.lid.."WARNING: No waypoints left. Dunno what to do!")
|
||||
|
||||
--[[
|
||||
|
||||
-- Get destination or home airbase.
|
||||
local airbase=self.destbase or self.homebase
|
||||
|
||||
if self:IsAirborne() then
|
||||
|
||||
-- TODO: check if no more scheduled tasks.
|
||||
|
||||
if airbase then
|
||||
-- Route flight to destination/home.
|
||||
--self:RTB(airbase)
|
||||
else
|
||||
-- Let flight orbit.
|
||||
--self:Orbit(self.group:GetCoordinate(), UTILS.FeetToMeters(20000), self.group:GetSpeedMax()*0.4)
|
||||
end
|
||||
|
||||
-- Send flight to destination. NOTE that if there are still remaining tasks, the RTB call is delayed by 10 sec until all tasks are done.
|
||||
if self.destbase then
|
||||
self:__RTB(-1, self.destbase)
|
||||
elseif self.destzone then
|
||||
self:__RTZ(-1, self.destzone)
|
||||
else
|
||||
self:__Wait(-1)
|
||||
self:E(self.lid.."ERROR: Reached final waypoint but no destination set! Don't know what to do?!")
|
||||
end
|
||||
|
||||
]]
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@@ -2365,6 +2376,8 @@ function FLIGHTGROUP:onafterPassingWaypoint(From, Event, To, n, N)
|
||||
--TODO: Find better way to RTB!
|
||||
self:I(self.lid.."FF group passed final waypoint!")
|
||||
|
||||
--[[
|
||||
|
||||
-- Send flight to destination. NOTE that if there are still remaining tasks, the RTB call is delayed by 10 sec until all tasks are done.
|
||||
if self.destbase then
|
||||
self:__RTB(-1, self.destbase)
|
||||
@@ -2374,6 +2387,8 @@ function FLIGHTGROUP:onafterPassingWaypoint(From, Event, To, n, N)
|
||||
self:__Wait(-1)
|
||||
self:E(self.lid.."ERROR: Reached final waypoint but no destination set! Don't know what to do?!")
|
||||
end
|
||||
|
||||
]]
|
||||
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user