mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-07-22 03:26:06 +00:00
Refactoring
This commit is contained in:
@@ -1662,7 +1662,7 @@ function AIRWING:IsAssetOnMission(asset, MissionTypes)
|
||||
if mission:IsNotOver() then
|
||||
|
||||
-- Get flight status.
|
||||
local status=mission:GetFlightStatus(asset.flightgroup)
|
||||
local status=mission:GetGroupStatus(asset.flightgroup)
|
||||
|
||||
-- Only if mission is started or executing.
|
||||
if (status==AUFTRAG.GroupStatus.STARTED or status==AUFTRAG.GroupStatus.EXECUTING) and self:CheckMissionType(mission.type, MissionTypes) then
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
-- @field #number auftragsnummer Auftragsnummer.
|
||||
-- @field #string type Mission type.
|
||||
-- @field #string status Mission status.
|
||||
-- @field #table groupdata Flight specific data.
|
||||
-- @field #table groupdata Group specific data.
|
||||
-- @field #string name Mission name.
|
||||
-- @field #number prio Mission priority.
|
||||
-- @field #boolean urgent Mission is urgent. Running missions with lower prio might be cancelled.
|
||||
@@ -262,10 +262,10 @@ AUFTRAG.Status={
|
||||
--- Mission status of an assigned group.
|
||||
-- @type AUFTRAG.GroupStatus
|
||||
-- @field #string SCHEDULED Mission is scheduled in a FLIGHGROUP queue waiting to be started.
|
||||
-- @field #string STARTED Flightgroup started this mission but it is not executed yet.
|
||||
-- @field #string EXECUTING Flightgroup is executing this mission.
|
||||
-- @field #string PAUSED Flightgroup has paused this mission, e.g. for refuelling.
|
||||
-- @field #string DONE Mission task of the flightgroup is done.
|
||||
-- @field #string STARTED Ops group started this mission but it is not executed yet.
|
||||
-- @field #string EXECUTING Ops group is executing this mission.
|
||||
-- @field #string PAUSED Ops group has paused this mission, e.g. for refuelling.
|
||||
-- @field #string DONE Mission task of the Ops group is done.
|
||||
-- @field #string CANCELLED Mission was cancelled.
|
||||
AUFTRAG.GroupStatus={
|
||||
SCHEDULED="scheduled",
|
||||
@@ -422,7 +422,7 @@ function AUFTRAG:New(Type)
|
||||
|
||||
self:AddTransition("*", "Repeat", AUFTRAG.Status.PLANNED)
|
||||
|
||||
self:AddTransition("*", "FlightDead", "*")
|
||||
self:AddTransition("*", "GroupDead", "*")
|
||||
self:AddTransition("*", "AssetDead", "*")
|
||||
|
||||
|
||||
@@ -1455,7 +1455,7 @@ function AUFTRAG:AddOpsGroup(OpsGroup)
|
||||
|
||||
end
|
||||
|
||||
--- Remove a flight group to the mission.
|
||||
--- Remove an Ops group from the mission.
|
||||
-- @param #AUFTRAG self
|
||||
-- @param Ops.OpsGroup#OPSGROUP OpsGroup The OPSGROUP object.
|
||||
function AUFTRAG:DelOpsGroup(OpsGroup)
|
||||
@@ -1463,7 +1463,7 @@ function AUFTRAG:DelOpsGroup(OpsGroup)
|
||||
|
||||
if OpsGroup then
|
||||
|
||||
-- Remove mission form flightgroup queue.
|
||||
-- Remove mission form queue.
|
||||
OpsGroup:RemoveMission(self)
|
||||
|
||||
self.groupdata[OpsGroup.groupname]=nil
|
||||
@@ -1684,7 +1684,7 @@ function AUFTRAG:onafterStatus(From, Event, To)
|
||||
-- Check if mission is not OVER yet.
|
||||
if self:IsNotOver() then
|
||||
|
||||
if self:CheckFlightsDone() then
|
||||
if self:CheckGroupsDone() then
|
||||
|
||||
-- All groups have reported MISSON DONE.
|
||||
self:Done()
|
||||
@@ -1810,34 +1810,34 @@ end
|
||||
--- Get asset data table.
|
||||
-- @param #AUFTRAG self
|
||||
-- @param #string AssetName Name of the asset.
|
||||
-- @return #AUFTRAG.GroupData Flight data or nil if OPS group does not exist.
|
||||
-- @return #AUFTRAG.GroupData Group data or *nil* if OPS group does not exist.
|
||||
function AUFTRAG:GetAssetDataByName(AssetName)
|
||||
return self.groupdata[tostring(AssetName)]
|
||||
end
|
||||
|
||||
--- Get flight data table.
|
||||
-- @param #AUFTRAG self
|
||||
-- @param Ops.OpsGroup#OPSGROUP flightgroup The flight group.
|
||||
-- @return #AUFTRAG.GroupData Flight data or nil if flightgroup does not exist.
|
||||
function AUFTRAG:GetFlightData(flightgroup)
|
||||
if flightgroup and self.groupdata then
|
||||
return self.groupdata[flightgroup.groupname]
|
||||
-- @param Ops.OpsGroup#OPSGROUP opsgroup The flight group.
|
||||
-- @return #AUFTRAG.GroupData Flight data or nil if opsgroup does not exist.
|
||||
function AUFTRAG:GetGroupData(opsgroup)
|
||||
if opsgroup and self.groupdata then
|
||||
return self.groupdata[opsgroup.groupname]
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
--- Set flightgroup mission status.
|
||||
--- Set opsgroup mission status.
|
||||
-- @param #AUFTRAG self
|
||||
-- @param Ops.OpsGroup#OPSGROUP flightgroup The flight group.
|
||||
-- @param Ops.OpsGroup#OPSGROUP opsgroup The flight group.
|
||||
-- @param #string status New status.
|
||||
function AUFTRAG:SetFlightStatus(flightgroup, status)
|
||||
self:I(self.lid..string.format("Setting flight %s to status %s", flightgroup and flightgroup.groupname or "nil", tostring(status)))
|
||||
function AUFTRAG:SetGroupStatus(opsgroup, status)
|
||||
self:I(self.lid..string.format("Setting flight %s to status %s", opsgroup and opsgroup.groupname or "nil", tostring(status)))
|
||||
|
||||
--env.info("FF trying to get flight status in AUFTRAG:GetFlightStatus")
|
||||
if self:GetFlightStatus(flightgroup)==AUFTRAG.GroupStatus.CANCELLED and status==AUFTRAG.GroupStatus.DONE then
|
||||
--env.info("FF trying to get flight status in AUFTRAG:GetGroupStatus")
|
||||
if self:GetGroupStatus(opsgroup)==AUFTRAG.GroupStatus.CANCELLED and status==AUFTRAG.GroupStatus.DONE then
|
||||
-- Do not overwrite a CANCELLED status with a DONE status.
|
||||
else
|
||||
local groupdata=self:GetFlightData(flightgroup)
|
||||
local groupdata=self:GetGroupData(opsgroup)
|
||||
if groupdata then
|
||||
groupdata.status=status
|
||||
else
|
||||
@@ -1846,10 +1846,10 @@ function AUFTRAG:SetFlightStatus(flightgroup, status)
|
||||
end
|
||||
|
||||
-- Debug info.
|
||||
self:I(self.lid..string.format("Setting flight %s status to %s. IsNotOver=%s CheckFlightsDone=%s", flightgroup.groupname, self:GetFlightStatus(flightgroup), tostring(self:IsNotOver()), tostring(self:CheckFlightsDone())))
|
||||
self:I(self.lid..string.format("Setting flight %s status to %s. IsNotOver=%s CheckGroupsDone=%s", opsgroup.groupname, self:GetGroupStatus(opsgroup), tostring(self:IsNotOver()), tostring(self:CheckGroupsDone())))
|
||||
|
||||
-- Check if ALL flights are done with their mission.
|
||||
if self:IsNotOver() and self:CheckFlightsDone() then
|
||||
if self:IsNotOver() and self:CheckGroupsDone() then
|
||||
self:I(self.lid.."All flights done ==> mission DONE!")
|
||||
self:Done()
|
||||
else
|
||||
@@ -1858,88 +1858,88 @@ function AUFTRAG:SetFlightStatus(flightgroup, status)
|
||||
|
||||
end
|
||||
|
||||
--- Get flightgroup mission status.
|
||||
--- Get ops group mission status.
|
||||
-- @param #AUFTRAG self
|
||||
-- @param Ops.OpsGroup#OPSGROUP flightgroup The flight group.
|
||||
function AUFTRAG:GetFlightStatus(flightgroup)
|
||||
self:T3(self.lid..string.format("Trying to get Flight status for flight group %s", flightgroup and flightgroup.groupname or "nil"))
|
||||
-- @param Ops.OpsGroup#OPSGROUP opsgroup The flight group.
|
||||
function AUFTRAG:GetGroupStatus(opsgroup)
|
||||
self:T3(self.lid..string.format("Trying to get Flight status for flight group %s", opsgroup and opsgroup.groupname or "nil"))
|
||||
|
||||
local groupdata=self:GetFlightData(flightgroup)
|
||||
local groupdata=self:GetGroupData(opsgroup)
|
||||
|
||||
if groupdata then
|
||||
return groupdata.status
|
||||
else
|
||||
|
||||
self:E(self.lid..string.format("WARNING: Could not GET groupdata for flightgroup %s. Returning status DONE.", flightgroup and flightgroup.groupname or "nil"))
|
||||
self:E(self.lid..string.format("WARNING: Could not GET groupdata for opsgroup %s. Returning status DONE.", opsgroup and opsgroup.groupname or "nil"))
|
||||
return AUFTRAG.GroupStatus.DONE
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--- Set flightgroup waypoint coordinate.
|
||||
--- Set Ops group waypoint coordinate.
|
||||
-- @param #AUFTRAG self
|
||||
-- @param Ops.OpsGroup#OPSGROUP flightgroup The flight group.
|
||||
-- @param Ops.OpsGroup#OPSGROUP opsgroup The flight group.
|
||||
-- @param Core.Point#COORDINATE coordinate Waypoint Coordinate.
|
||||
function AUFTRAG:SetFlightWaypointCoordinate(flightgroup, coordinate)
|
||||
local groupdata=self:GetFlightData(flightgroup)
|
||||
function AUFTRAG:SetGroupWaypointCoordinate(opsgroup, coordinate)
|
||||
local groupdata=self:GetGroupData(opsgroup)
|
||||
if groupdata then
|
||||
groupdata.waypointcoordinate=coordinate
|
||||
end
|
||||
end
|
||||
|
||||
--- Get flightgroup waypoint coordinate.
|
||||
--- Get opsgroup waypoint coordinate.
|
||||
-- @param #AUFTRAG self
|
||||
-- @return Core.Point#COORDINATE Waypoint Coordinate.
|
||||
function AUFTRAG:GetFlightWaypointCoordinate(flightgroup)
|
||||
local groupdata=self:GetFlightData(flightgroup)
|
||||
function AUFTRAG:GetGroupWaypointCoordinate(opsgroup)
|
||||
local groupdata=self:GetGroupData(opsgroup)
|
||||
if groupdata then
|
||||
return groupdata.waypointcoordinate
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--- Set flightgroup waypoint task.
|
||||
--- Set Ops group waypoint task.
|
||||
-- @param #AUFTRAG self
|
||||
-- @param Ops.OpsGroup#OPSGROUP flightgroup The flight group.
|
||||
-- @param Ops.OpsGroup#OPSGROUP opsgroup The flight group.
|
||||
-- @param Ops.OpsGroup#OPSGROUP.Task task Waypoint task.
|
||||
function AUFTRAG:SetFlightWaypointTask(flightgroup, task)
|
||||
function AUFTRAG:SetGroupWaypointTask(opsgroup, task)
|
||||
self:I(self.lid..string.format("Setting waypoint task %s", task and task.description or "WTF"))
|
||||
local groupdata=self:GetFlightData(flightgroup)
|
||||
local groupdata=self:GetGroupData(opsgroup)
|
||||
if groupdata then
|
||||
groupdata.waypointtask=task
|
||||
end
|
||||
end
|
||||
|
||||
--- Get flightgroup waypoint task.
|
||||
--- Get opsgroup waypoint task.
|
||||
-- @param #AUFTRAG self
|
||||
-- @param Ops.OpsGroup#OPSGROUP flightgroup The flight group.
|
||||
-- @param Ops.OpsGroup#OPSGROUP opsgroup The flight group.
|
||||
-- @return Ops.OpsGroup#OPSGROUP.Task task Waypoint task. Waypoint task.
|
||||
function AUFTRAG:GetFlightWaypointTask(flightgroup)
|
||||
local groupdata=self:GetFlightData(flightgroup)
|
||||
function AUFTRAG:GetGroupWaypointTask(opsgroup)
|
||||
local groupdata=self:GetGroupData(opsgroup)
|
||||
if groupdata then
|
||||
return groupdata.waypointtask
|
||||
end
|
||||
end
|
||||
|
||||
--- Set flightgroup waypoint index.
|
||||
--- Set opsgroup waypoint index.
|
||||
-- @param #AUFTRAG self
|
||||
-- @param Ops.OpsGroup#OPSGROUP flightgroup The flight group.
|
||||
-- @param Ops.OpsGroup#OPSGROUP opsgroup The flight group.
|
||||
-- @param #number waypointindex Waypoint index.
|
||||
function AUFTRAG:SetFlightWaypointIndex(flightgroup, waypointindex)
|
||||
function AUFTRAG:SetGroupWaypointIndex(opsgroup, waypointindex)
|
||||
self:I(self.lid..string.format("Setting waypoint index %d", waypointindex))
|
||||
local groupdata=self:GetFlightData(flightgroup)
|
||||
local groupdata=self:GetGroupData(opsgroup)
|
||||
if groupdata then
|
||||
groupdata.waypointindex=waypointindex
|
||||
end
|
||||
end
|
||||
|
||||
--- Get flightgroup waypoint index.
|
||||
--- Get opsgroup waypoint index.
|
||||
-- @param #AUFTRAG self
|
||||
-- @param Ops.OpsGroup#OPSGROUP flightgroup The flight group.
|
||||
-- @param Ops.OpsGroup#OPSGROUP opsgroup The flight group.
|
||||
-- @return #number Waypoint index
|
||||
function AUFTRAG:GetFlightWaypointIndex(flightgroup)
|
||||
local groupdata=self:GetFlightData(flightgroup)
|
||||
function AUFTRAG:GetGroupWaypointIndex(opsgroup)
|
||||
local groupdata=self:GetGroupData(opsgroup)
|
||||
if groupdata then
|
||||
return groupdata.waypointindex
|
||||
end
|
||||
@@ -1949,9 +1949,9 @@ end
|
||||
--- Check if all flights are done with their mission (or dead).
|
||||
-- @param #AUFTRAG self
|
||||
-- @return #boolean If true, all flights are done with the mission.
|
||||
function AUFTRAG:CheckFlightsDone()
|
||||
function AUFTRAG:CheckGroupsDone()
|
||||
|
||||
-- These are early stages, where we might not even have a flightgroup defined to be checked.
|
||||
-- These are early stages, where we might not even have a opsgroup defined to be checked.
|
||||
if self:IsPlanned() or self:IsQueued() or self:IsRequested() then
|
||||
return false
|
||||
end
|
||||
@@ -1996,7 +1996,7 @@ function AUFTRAG:OnEventUnitLost(EventData)
|
||||
for _,_groupdata in pairs(self.groupdata) do
|
||||
local groupdata=_groupdata --#AUFTRAG.GroupData
|
||||
if groupdata and groupdata.opsgroup and groupdata.opsgroup.groupname==EventData.IniGroupName then
|
||||
self:I(self.lid..string.format("UNIT LOST event for flightgroup %s unit %s", groupdata.opsgroup.groupname, EventData.IniUnitName))
|
||||
self:I(self.lid..string.format("UNIT LOST event for opsgroup %s unit %s", groupdata.opsgroup.groupname, EventData.IniUnitName))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2087,13 +2087,13 @@ function AUFTRAG:onafterDone(From, Event, To)
|
||||
end
|
||||
|
||||
|
||||
--- On after "FlightDead" event.
|
||||
--- On after "GroupDead" event.
|
||||
-- @param #AUFTRAG self
|
||||
-- @param #string From From state.
|
||||
-- @param #string Event Event.
|
||||
-- @param #string To To state.
|
||||
-- @param Ops.OpsGroup#OPSGROUP OpsGroup The ops group that is dead now.
|
||||
function AUFTRAG:onafterFlightDead(From, Event, To, OpsGroup)
|
||||
function AUFTRAG:onafterGroupDead(From, Event, To, OpsGroup)
|
||||
|
||||
local asset=self:GetAssetByName(OpsGroup.groupname)
|
||||
if asset then
|
||||
@@ -2110,7 +2110,7 @@ end
|
||||
-- @param Ops.AirWing#AIRWING.SquadronAsset Asset The asset.
|
||||
function AUFTRAG:onafterAssetDead(From, Event, To, Asset)
|
||||
|
||||
-- Remove flightgroup from mission.
|
||||
-- Remove opsgroup from mission.
|
||||
--self:DelOpsGroup(Asset.opsgroup)
|
||||
|
||||
local N=self:CountOpsGroups()
|
||||
@@ -2126,7 +2126,7 @@ function AUFTRAG:onafterAssetDead(From, Event, To, Asset)
|
||||
else
|
||||
|
||||
self:E(self.lid.."ERROR: All assets are dead not but mission was already over... Investigate!")
|
||||
-- Now this can happen, because when a flightgroup dies (sometimes!), the mission is DONE
|
||||
-- Now this can happen, because when a opsgroup dies (sometimes!), the mission is DONE
|
||||
|
||||
end
|
||||
end
|
||||
@@ -2265,9 +2265,9 @@ function AUFTRAG:onafterRepeat(From, Event, To)
|
||||
|
||||
for _,_groupdata in pairs(self.groupdata) do
|
||||
local groupdata=_groupdata --#AUFTRAG.GroupData
|
||||
local flightgroup=groupdata.opsgroup
|
||||
if flightgroup then
|
||||
self:DelOpsGroup(flightgroup)
|
||||
local opsgroup=groupdata.opsgroup
|
||||
if opsgroup then
|
||||
self:DelOpsGroup(opsgroup)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -885,7 +885,7 @@ function FLIGHTGROUP:onafterStatus(From, Event, To)
|
||||
local Cstart= UTILS.SecondsToClock(mission.Tstart, true)
|
||||
local Cstop = mission.Tstop and UTILS.SecondsToClock(mission.Tstop, true) or "INF"
|
||||
text=text..string.format("\n[%d] %s (%s) status=%s (%s), Time=%s-%s, prio=%d wp=%s targets=%d",
|
||||
i, tostring(mission.name), mission.type, mission:GetFlightStatus(self), tostring(mission.status), Cstart, Cstop, mission.prio, tostring(mission:GetFlightWaypointIndex(self)), mission:CountMissionTargets())
|
||||
i, tostring(mission.name), mission.type, mission:GetGroupStatus(self), tostring(mission.status), Cstart, Cstop, mission.prio, tostring(mission:GetGroupWaypointIndex(self)), mission:CountMissionTargets())
|
||||
end
|
||||
self:I(self.lid..text)
|
||||
end
|
||||
@@ -3019,11 +3019,11 @@ function FLIGHTGROUP:AddWaypoint(coordinate, wpnumber, speed, updateroute)
|
||||
local mission=_mission --Ops.Auftrag#AUFTRAG
|
||||
|
||||
-- Get mission waypoint index.
|
||||
local wpidx=mission:GetFlightWaypointIndex(self)
|
||||
local wpidx=mission:GetGroupWaypointIndex(self)
|
||||
|
||||
-- Increase number if this waypoint lies in the future.
|
||||
if wpidx and wpidx>=wpnumber then
|
||||
mission:SetFlightWaypointIndex(self, wpidx+1)
|
||||
mission:SetGroupWaypointIndex(self, wpidx+1)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -202,7 +202,7 @@ function NAVYGROUP:onafterStatus(From, Event, To)
|
||||
if #self.taskqueue>0 and self.verbose>1 then
|
||||
local text=string.format("Tasks #%d", #self.taskqueue)
|
||||
for i,_task in pairs(self.taskqueue) do
|
||||
local task=_task --#FLIGHTGROUP.Task
|
||||
local task=_task --Ops.OpsGroup#OPSGROUP.Task
|
||||
local name=task.description
|
||||
local taskid=task.dcstask.id or "unknown"
|
||||
local status=task.status
|
||||
@@ -245,7 +245,7 @@ function NAVYGROUP:onafterStatus(From, Event, To)
|
||||
local Cstart= UTILS.SecondsToClock(mission.Tstart, true)
|
||||
local Cstop = mission.Tstop and UTILS.SecondsToClock(mission.Tstop, true) or "INF"
|
||||
text=text..string.format("\n[%d] %s (%s) status=%s (%s), Time=%s-%s, prio=%d wp=%s targets=%d",
|
||||
i, tostring(mission.name), mission.type, mission:GetFlightStatus(self), tostring(mission.status), Cstart, Cstop, mission.prio, tostring(mission:GetFlightWaypointIndex(self)), mission:CountMissionTargets())
|
||||
i, tostring(mission.name), mission.type, mission:GetGroupStatus(self), tostring(mission.status), Cstart, Cstop, mission.prio, tostring(mission:GetGroupWaypointIndex(self)), mission:CountMissionTargets())
|
||||
end
|
||||
self:I(self.lid..text)
|
||||
end
|
||||
@@ -487,7 +487,7 @@ end
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
--- Add an a waypoint to the route.
|
||||
-- @param #FLIGHTGROUP self
|
||||
-- @param #NAVYGROUP self
|
||||
-- @param Core.Point#COORDINATE coordinate The coordinate of the waypoint. Use COORDINATE:SetAltitude(altitude) to define the altitude.
|
||||
-- @param #number wpnumber Waypoint number. Default at the end.
|
||||
-- @param #number speed Speed in knots. Default 11 kts.
|
||||
@@ -519,7 +519,7 @@ function NAVYGROUP:AddWaypoint(coordinate, wpnumber, speed, updateroute)
|
||||
|
||||
-- Shift all waypoint tasks after the inserted waypoint.
|
||||
for _,_task in pairs(self.taskqueue) do
|
||||
local task=_task --#FLIGHTGROUP.Task
|
||||
local task=_task --Ops.OpsGroup#OPSGROUP.Task
|
||||
if task.type==OPSGROUP.TaskType.WAYPOINT and task.waypoint and task.waypoint>=wpnumber then
|
||||
task.waypoint=task.waypoint+1
|
||||
end
|
||||
@@ -530,11 +530,11 @@ function NAVYGROUP:AddWaypoint(coordinate, wpnumber, speed, updateroute)
|
||||
local mission=_mission --Ops.Auftrag#AUFTRAG
|
||||
|
||||
-- Get mission waypoint index.
|
||||
local wpidx=mission:GetFlightWaypointIndex(self)
|
||||
local wpidx=mission:GetGroupWaypointIndex(self)
|
||||
|
||||
-- Increase number if this waypoint lies in the future.
|
||||
if wpidx and wpidx>=wpnumber then
|
||||
mission:SetFlightWaypointIndex(self, wpidx+1)
|
||||
mission:SetGroupWaypointIndex(self, wpidx+1)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -149,7 +149,7 @@ OPSGROUP.ElementStatus={
|
||||
DEAD="dead",
|
||||
}
|
||||
|
||||
--- Flight group task status.
|
||||
--- Ops group task status.
|
||||
-- @type OPSGROUP.TaskStatus
|
||||
-- @field #string SCHEDULED Task is scheduled.
|
||||
-- @field #string EXECUTING Task is being executed.
|
||||
@@ -162,7 +162,7 @@ OPSGROUP.TaskStatus={
|
||||
DONE="done",
|
||||
}
|
||||
|
||||
--- Flight group task status.
|
||||
--- Ops group task status.
|
||||
-- @type OPSGROUP.TaskType
|
||||
-- @field #string SCHEDULED Task is scheduled and will be executed at a given time.
|
||||
-- @field #string WAYPOINT Task is executed at a specific waypoint.
|
||||
@@ -279,9 +279,9 @@ function OPSGROUP:New(Group)
|
||||
self:AddTransition("*", "OutOfBombs", "*") -- Group is out of bombs.
|
||||
self:AddTransition("*", "OutOfMissiles", "*") -- Group is out of missiles.
|
||||
|
||||
self:AddTransition("*", "CheckZone", "*") -- Check if flight enters/leaves a certain zone.
|
||||
self:AddTransition("*", "EnterZone", "*") -- Flight entered a certain zone.
|
||||
self:AddTransition("*", "LeaveZone", "*") -- Flight leaves a certain zone.
|
||||
self:AddTransition("*", "CheckZone", "*") -- Check if group enters/leaves a certain zone.
|
||||
self:AddTransition("*", "EnterZone", "*") -- Group entered a certain zone.
|
||||
self:AddTransition("*", "LeaveZone", "*") -- Group leaves a certain zone.
|
||||
|
||||
self:AddTransition("*", "TaskExecute", "*") -- Group will execute a task.
|
||||
self:AddTransition("*", "TaskPause", "*") -- Pause current task. Not implemented yet!
|
||||
@@ -503,7 +503,7 @@ function OPSGROUP:SelfDestruction(Delay, ExplosionPower)
|
||||
|
||||
end
|
||||
|
||||
--- Check if flight is alive.
|
||||
--- Check if group is alive.
|
||||
-- @param #OPSGROUP self
|
||||
-- @return #boolean *true* if group is exists and is activated, *false* if group is exist but is NOT activated. *nil* otherwise, e.g. the GROUP object is *nil* or the group is not spawned yet.
|
||||
function OPSGROUP:IsAlive()
|
||||
@@ -522,28 +522,28 @@ function OPSGROUP:IsLateActivated()
|
||||
return self.isLateActivated
|
||||
end
|
||||
|
||||
--- Check if flight is in state in utero.
|
||||
--- Check if group is in state in utero.
|
||||
-- @param #OPSGROUP self
|
||||
-- @return #boolean If true, flight is not spawned yet.
|
||||
-- @return #boolean If true, group is not spawned yet.
|
||||
function OPSGROUP:IsInUtero()
|
||||
return self:Is("InUtero")
|
||||
end
|
||||
|
||||
--- Check if flight is in state spawned.
|
||||
--- Check if group is in state spawned.
|
||||
-- @param #OPSGROUP self
|
||||
-- @return #boolean If true, flight is spawned.
|
||||
-- @return #boolean If true, group is spawned.
|
||||
function OPSGROUP:IsSpawned()
|
||||
return self:Is("Spawned")
|
||||
end
|
||||
|
||||
--- Check if flight is dead.
|
||||
--- Check if group is dead.
|
||||
-- @param #OPSGROUP self
|
||||
-- @return #boolean If true, all units/elements of the flight are dead.
|
||||
-- @return #boolean If true, all units/elements of the group are dead.
|
||||
function OPSGROUP:IsDead()
|
||||
return self:Is("Dead")
|
||||
end
|
||||
|
||||
--- Check if flight FSM is stopped.
|
||||
--- Check if FSM is stopped.
|
||||
-- @param #OPSGROUP self
|
||||
-- @return #boolean If true, FSM state is stopped.
|
||||
function OPSGROUP:IsStopped()
|
||||
@@ -593,11 +593,11 @@ function OPSGROUP:RemoveWaypoint(wpindex)
|
||||
local mission=_mission --Ops.Auftrag#AUFTRAG
|
||||
|
||||
-- Get mission waypoint index.
|
||||
local wpidx=mission:GetFlightWaypointIndex(self)
|
||||
local wpidx=mission:GetGroupWaypointIndex(self)
|
||||
|
||||
-- Reduce number if this waypoint lies in the future.
|
||||
if wpidx and wpidx>wpindex then
|
||||
mission:SetFlightWaypointIndex(self, wpidx-1)
|
||||
mission:SetGroupWaypointIndex(self, wpidx-1)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1213,7 +1213,7 @@ function OPSGROUP:onafterTaskDone(From, Event, To, Task)
|
||||
|
||||
if Mission and Mission:IsNotOver() then
|
||||
|
||||
local status=Mission:GetFlightStatus(self)
|
||||
local status=Mission:GetGroupStatus(self)
|
||||
|
||||
if status~=AUFTRAG.GroupStatus.PAUSED then
|
||||
self:I(self.lid.."FF Task Done ==> Mission Done!")
|
||||
@@ -1238,11 +1238,11 @@ end
|
||||
-- @return #OPSGROUP self
|
||||
function OPSGROUP:AddMission(Mission)
|
||||
|
||||
-- Add flight group to mission.
|
||||
-- Add group to mission.
|
||||
Mission:AddOpsGroup(self)
|
||||
|
||||
-- Set flight status to SCHEDULED..
|
||||
Mission:SetFlightStatus(self, AUFTRAG.GroupStatus.SCHEDULED)
|
||||
-- Set group status to SCHEDULED..
|
||||
Mission:SetGroupStatus(self, AUFTRAG.GroupStatus.SCHEDULED)
|
||||
|
||||
-- Set mission status to SCHEDULED.
|
||||
Mission:Scheduled()
|
||||
@@ -1270,7 +1270,7 @@ function OPSGROUP:RemoveMission(Mission)
|
||||
if mission.auftragsnummer==Mission.auftragsnummer then
|
||||
|
||||
-- Remove mission waypoint task.
|
||||
local Task=Mission:GetFlightWaypointTask(self)
|
||||
local Task=Mission:GetGroupWaypointTask(self)
|
||||
|
||||
if Task then
|
||||
self:RemoveTask(Task)
|
||||
@@ -1300,8 +1300,8 @@ function OPSGROUP:CountRemainingMissison()
|
||||
|
||||
if mission and mission:IsNotOver() then
|
||||
|
||||
-- Get flight status.
|
||||
local status=mission:GetFlightStatus(self)
|
||||
-- Get group status.
|
||||
local status=mission:GetGroupStatus(self)
|
||||
|
||||
if status~=AUFTRAG.GroupStatus.DONE and status~=AUFTRAG.GroupStatus.CANCELLED then
|
||||
N=N+1
|
||||
@@ -1341,7 +1341,7 @@ function OPSGROUP:_GetNextMission()
|
||||
for _,_mission in pairs(self.missionqueue) do
|
||||
local mission=_mission --Ops.Auftrag#AUFTRAG
|
||||
|
||||
if mission:GetFlightStatus(self)==AUFTRAG.Status.SCHEDULED and (mission:IsReadyToGo() or self.airwing) then
|
||||
if mission:GetGroupStatus(self)==AUFTRAG.Status.SCHEDULED and (mission:IsReadyToGo() or self.airwing) then
|
||||
return mission
|
||||
end
|
||||
end
|
||||
@@ -1381,7 +1381,7 @@ function OPSGROUP:GetMissionByTaskID(taskid)
|
||||
for _,_mission in pairs(self.missionqueue) do
|
||||
local mission=_mission --Ops.Auftrag#AUFTRAG
|
||||
|
||||
local task=mission:GetFlightWaypointTask(self)
|
||||
local task=mission:GetGroupWaypointTask(self)
|
||||
|
||||
if task and task.id and task.id==taskid then
|
||||
return mission
|
||||
@@ -1449,13 +1449,13 @@ function OPSGROUP:onafterMissionStart(From, Event, To, Mission)
|
||||
-- Set current mission.
|
||||
self.currentmission=Mission.auftragsnummer
|
||||
|
||||
-- Set flight mission status to STARTED.
|
||||
Mission:SetFlightStatus(self, AUFTRAG.GroupStatus.STARTED)
|
||||
-- Set group mission status to STARTED.
|
||||
Mission:SetGroupStatus(self, AUFTRAG.GroupStatus.STARTED)
|
||||
|
||||
-- Set mission status to STARTED.
|
||||
Mission:Started()
|
||||
|
||||
-- Route flight to mission zone.
|
||||
-- Route group to mission zone.
|
||||
self:RouteToMission(Mission, 3)
|
||||
|
||||
end
|
||||
@@ -1472,8 +1472,8 @@ function OPSGROUP:onafterMissionExecute(From, Event, To, Mission)
|
||||
self:T(self.lid..text)
|
||||
MESSAGE:New(text, 30, self.groupname):ToAllIf(true)
|
||||
|
||||
-- Set flight mission status to EXECUTING.
|
||||
Mission:SetFlightStatus(self, AUFTRAG.GroupStatus.EXECUTING)
|
||||
-- Set group mission status to EXECUTING.
|
||||
Mission:SetGroupStatus(self, AUFTRAG.GroupStatus.EXECUTING)
|
||||
|
||||
-- Set mission status to EXECUTING.
|
||||
Mission:Executing()
|
||||
@@ -1496,11 +1496,11 @@ function OPSGROUP:onafterPauseMission(From, Event, To)
|
||||
|
||||
if Mission then
|
||||
|
||||
-- Set flight mission status to PAUSED.
|
||||
Mission:SetFlightStatus(self, AUFTRAG.GroupStatus.PAUSED)
|
||||
-- Set group mission status to PAUSED.
|
||||
Mission:SetGroupStatus(self, AUFTRAG.GroupStatus.PAUSED)
|
||||
|
||||
-- Get mission waypoint task.
|
||||
local Task=Mission:GetFlightWaypointTask(self)
|
||||
local Task=Mission:GetGroupWaypointTask(self)
|
||||
|
||||
-- Debug message.
|
||||
self:I(self.lid..string.format("FF pausing current mission %s. Task=%s", tostring(Mission.name), tostring(Task and Task.description or "WTF")))
|
||||
@@ -1549,15 +1549,15 @@ function OPSGROUP:onafterMissionCancel(From, Event, To, Mission)
|
||||
if self.currentmission and Mission.auftragsnummer==self.currentmission then
|
||||
|
||||
-- Get mission waypoint task.
|
||||
local Task=Mission:GetFlightWaypointTask(self)
|
||||
local Task=Mission:GetGroupWaypointTask(self)
|
||||
|
||||
-- Debug info.
|
||||
self:I(self.lid..string.format("FF Cancel current mission %s. Task=%s", tostring(Mission.name), tostring(Task and Task.description or "WTF")))
|
||||
|
||||
-- Cancelling the mission is actually cancelling the current task.
|
||||
-- Note that two things can happen.
|
||||
-- 1.) Flight is still on the way to the waypoint (status should be STARTED). In this case there would not be a current task!
|
||||
-- 2.) Flight already passed the mission waypoint (status should be EXECUTING).
|
||||
-- 1.) Group is still on the way to the waypoint (status should be STARTED). In this case there would not be a current task!
|
||||
-- 2.) Group already passed the mission waypoint (status should be EXECUTING).
|
||||
|
||||
self:TaskCancel(Task)
|
||||
|
||||
@@ -1566,10 +1566,10 @@ function OPSGROUP:onafterMissionCancel(From, Event, To, Mission)
|
||||
-- Not the current mission.
|
||||
-- TODO: remove mission from queue?
|
||||
|
||||
-- Set mission flight status.
|
||||
Mission:SetFlightStatus(self, AUFTRAG.GroupStatus.CANCELLED)
|
||||
-- Set mission group status.
|
||||
Mission:SetGroupStatus(self, AUFTRAG.GroupStatus.CANCELLED)
|
||||
|
||||
-- Send flight RTB or WAIT if nothing left to do.
|
||||
-- Send group RTB or WAIT if nothing left to do.
|
||||
self:_CheckGroupDone(1)
|
||||
|
||||
end
|
||||
@@ -1589,8 +1589,8 @@ function OPSGROUP:onafterMissionDone(From, Event, To, Mission)
|
||||
self:I(self.lid..text)
|
||||
MESSAGE:New(text, 30, self.groupname):ToAllIf(true)
|
||||
|
||||
-- Set Flight status.
|
||||
Mission:SetFlightStatus(self, AUFTRAG.GroupStatus.DONE)
|
||||
-- Set group status.
|
||||
Mission:SetGroupStatus(self, AUFTRAG.GroupStatus.DONE)
|
||||
|
||||
-- Set current mission to nil.
|
||||
if self.currentmission and Mission.auftragsnummer==self.currentmission then
|
||||
@@ -1598,7 +1598,7 @@ function OPSGROUP:onafterMissionDone(From, Event, To, Mission)
|
||||
end
|
||||
|
||||
-- Remove mission waypoint.
|
||||
local wpidx=Mission:GetFlightWaypointIndex(self)
|
||||
local wpidx=Mission:GetGroupWaypointIndex(self)
|
||||
if wpidx then
|
||||
self:RemoveWaypoint(wpidx)
|
||||
end
|
||||
@@ -1611,7 +1611,7 @@ function OPSGROUP:onafterMissionDone(From, Event, To, Mission)
|
||||
|
||||
-- TODO: reset mission specific parameters like radio, ROE etc.
|
||||
|
||||
-- Check if flight is done.
|
||||
-- Check if group is done.
|
||||
self:_CheckGroupDone(1)
|
||||
|
||||
end
|
||||
@@ -1674,10 +1674,10 @@ function OPSGROUP:RouteToMission(mission, delay)
|
||||
local waypointtask=self:AddTaskWaypoint(mission.DCStask, nextwaypoint, mission.name, mission.prio, mission.duration)
|
||||
|
||||
-- Set waypoint task.
|
||||
mission:SetFlightWaypointTask(self, waypointtask)
|
||||
mission:SetGroupWaypointTask(self, waypointtask)
|
||||
|
||||
-- Set waypoint index.
|
||||
mission:SetFlightWaypointIndex(self, nextwaypoint)
|
||||
mission:SetGroupWaypointIndex(self, nextwaypoint)
|
||||
|
||||
---
|
||||
-- Mission Specific Settings
|
||||
@@ -1814,7 +1814,7 @@ function OPSGROUP:onafterPassingWaypoint(From, Event, To, n, N)
|
||||
-- TODO: maybe set waypoint enroute tasks?
|
||||
|
||||
for _,task in pairs(tasks) do
|
||||
local Task=task --#FLIGHTGROUP.Task
|
||||
local Task=task --Ops.OpsGroup#OPSGROUP.Task
|
||||
|
||||
-- Task execute.
|
||||
table.insert(taskswp, self.group:TaskFunction("OPSGROUP._TaskExecute", self, Task))
|
||||
@@ -1938,7 +1938,7 @@ function OPSGROUP:onafterCheckZone(From, Event, To)
|
||||
end
|
||||
end
|
||||
|
||||
--- Check if flight is in zones.
|
||||
--- Check if group is in zones.
|
||||
-- @param #OPSGROUP self
|
||||
function OPSGROUP:_CheckInZones()
|
||||
|
||||
@@ -1948,7 +1948,7 @@ function OPSGROUP:_CheckInZones()
|
||||
local Ninside=self.inzones:Count()
|
||||
|
||||
-- Debug info.
|
||||
self:T(self.lid..string.format("Check if flight is in %d zones. Currently it is in %d zones.", self.checkzones:Count(), self.inzones:Count()))
|
||||
self:T(self.lid..string.format("Check if group is in %d zones. Currently it is in %d zones.", self.checkzones:Count(), self.inzones:Count()))
|
||||
|
||||
-- Firstly, check if group is still inside zone it was already in. If not, remove zones and trigger LeaveZone() event.
|
||||
local leftzones={}
|
||||
@@ -1974,7 +1974,7 @@ function OPSGROUP:_CheckInZones()
|
||||
for checkzonename,_checkzone in pairs(self.checkzones:GetSet()) do
|
||||
local checkzone=_checkzone --Core.Zone#ZONE
|
||||
|
||||
-- Is flight currtently in this check zone?
|
||||
-- Is group currtently in this check zone?
|
||||
local isincheckzone=self.group:IsPartlyOrCompletelyInZone(checkzone)
|
||||
|
||||
if isincheckzone and not self.inzones:_Find(checkzonename) then
|
||||
@@ -2181,33 +2181,33 @@ end
|
||||
|
||||
--- Function called when a task is executed.
|
||||
--@param Wrapper.Group#GROUP group Group which should execute the task.
|
||||
--@param #OPSGROUP flightgroup Flight group.
|
||||
--@param #OPSGROUP opsgroup Ops group.
|
||||
--@param #OPSGROUP.Task task Task.
|
||||
function OPSGROUP._TaskExecute(group, flightgroup, task)
|
||||
function OPSGROUP._TaskExecute(group, opsgroup, task)
|
||||
|
||||
-- Debug message.
|
||||
local text=string.format("_TaskExecute %s", task.description)
|
||||
flightgroup:T3(flightgroup.lid..text)
|
||||
opsgroup:T3(opsgroup.lid..text)
|
||||
|
||||
-- Set current task to nil so that the next in line can be executed.
|
||||
if flightgroup then
|
||||
flightgroup:TaskExecute(task)
|
||||
if opsgroup then
|
||||
opsgroup:TaskExecute(task)
|
||||
end
|
||||
end
|
||||
|
||||
--- Function called when a task is done.
|
||||
--@param Wrapper.Group#GROUP group Group for which the task is done.
|
||||
--@param #OPSGROUP flightgroup Flight group.
|
||||
--@param #OPSGROUP opsgroup Ops group.
|
||||
--@param #OPSGROUP.Task task Task.
|
||||
function OPSGROUP._TaskDone(group, flightgroup, task)
|
||||
function OPSGROUP._TaskDone(group, opsgroup, task)
|
||||
|
||||
-- Debug message.
|
||||
local text=string.format("_TaskDone %s", task.description)
|
||||
flightgroup:T3(flightgroup.lid..text)
|
||||
opsgroup:T3(opsgroup.lid..text)
|
||||
|
||||
-- Set current task to nil so that the next in line can be executed.
|
||||
if flightgroup then
|
||||
flightgroup:TaskDone(task)
|
||||
if opsgroup then
|
||||
opsgroup:TaskDone(task)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2284,7 +2284,7 @@ end
|
||||
-- Element and Group Status Functions
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
--- Check if all elements of the flight group have the same status (or are dead).
|
||||
--- Check if all elements of the group have the same status (or are dead).
|
||||
-- @param #OPSGROUP self
|
||||
-- @param #string unitname Name of unit.
|
||||
function OPSGROUP:_AllSameStatus(status)
|
||||
@@ -2304,7 +2304,7 @@ function OPSGROUP:_AllSameStatus(status)
|
||||
return true
|
||||
end
|
||||
|
||||
--- Check if all elements of the flight group have the same status (or are dead).
|
||||
--- Check if all elements of the group have the same status (or are dead).
|
||||
-- @param #OPSGROUP self
|
||||
-- @param #string status Status to check.
|
||||
-- @return #boolean If true, all elements have a similar status.
|
||||
@@ -2430,7 +2430,7 @@ function OPSGROUP:_AllSimilarStatus(status)
|
||||
return true
|
||||
end
|
||||
|
||||
--- Check if all elements of the flight group have the same status or are dead.
|
||||
--- Check if all elements of the group have the same status or are dead.
|
||||
-- @param #OPSGROUP self
|
||||
-- @param #OPSGROUP.Element element Element.
|
||||
-- @param #string newstatus New status of element
|
||||
|
||||
Reference in New Issue
Block a user