mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
OPS
- FSM pseudo function cleanup - Fixed bug when mission is cancelled
This commit is contained in:
@@ -512,8 +512,7 @@ function AUFTRAG:New(Type)
|
||||
-- State is planned.
|
||||
self.status=AUFTRAG.Status.PLANNED
|
||||
|
||||
-- Defaults
|
||||
--self:SetVerbosity(0)
|
||||
-- Defaults
|
||||
self:SetName()
|
||||
self:SetPriority()
|
||||
self:SetTime()
|
||||
@@ -2552,10 +2551,13 @@ end
|
||||
-- @return #AUFTRAG self
|
||||
function AUFTRAG:SetGroupStatus(opsgroup, status)
|
||||
|
||||
-- Debug info.
|
||||
self:T(self.lid..string.format("Setting OPSGROUP %s to status %s", opsgroup and opsgroup.groupname or "nil", tostring(status)))
|
||||
-- Current status.
|
||||
local oldstatus=self:GetGroupStatus(opsgroup)
|
||||
|
||||
if self:GetGroupStatus(opsgroup)==AUFTRAG.GroupStatus.CANCELLED and status==AUFTRAG.GroupStatus.DONE then
|
||||
-- Debug info.
|
||||
self:T(self.lid..string.format("Setting OPSGROUP %s to status %s-->%s", opsgroup and opsgroup.groupname or "nil", tostring(oldstatus), tostring(status)))
|
||||
|
||||
if oldstatus==AUFTRAG.GroupStatus.CANCELLED and status==AUFTRAG.GroupStatus.DONE then
|
||||
-- Do not overwrite a CANCELLED status with a DONE status.
|
||||
else
|
||||
local groupdata=self:GetGroupData(opsgroup)
|
||||
@@ -2566,12 +2568,18 @@ function AUFTRAG:SetGroupStatus(opsgroup, status)
|
||||
end
|
||||
end
|
||||
|
||||
-- Check if mission is NOT over.
|
||||
local isNotOver=self:IsNotOver()
|
||||
|
||||
-- Check if all assigned groups are done.
|
||||
local groupsDone=self:CheckGroupsDone()
|
||||
|
||||
-- Debug info.
|
||||
self:T2(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())))
|
||||
self:T2(self.lid..string.format("Setting OPSGROUP %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:CheckGroupsDone() then
|
||||
self:T3(self.lid.."All flights done ==> mission DONE!")
|
||||
if isNotOver and groupsDone then
|
||||
self:T3(self.lid.."All assigned OPSGROUPs done ==> mission DONE!")
|
||||
self:Done()
|
||||
else
|
||||
self:T3(self.lid.."Mission NOT DONE yet!")
|
||||
@@ -2747,6 +2755,7 @@ function AUFTRAG:CheckGroupsDone()
|
||||
if groupdata then
|
||||
if not (groupdata.status==AUFTRAG.GroupStatus.DONE or groupdata.status==AUFTRAG.GroupStatus.CANCELLED) then
|
||||
-- At least this flight is not DONE or CANCELLED.
|
||||
self:T(self.lid..string.format("CheckGroupsDone: OPSGROUP %s is not DONE or CANCELLED but in state %s. Mission NOT DONE!", groupdata.opsgroup.groupname, groupdata.status))
|
||||
return false
|
||||
end
|
||||
end
|
||||
@@ -2758,6 +2767,7 @@ function AUFTRAG:CheckGroupsDone()
|
||||
local status=self:GetLegionStatus(legion)
|
||||
if not status==AUFTRAG.Status.CANCELLED then
|
||||
-- At least one LEGION has not CANCELLED.
|
||||
self:T(self.lid..string.format("CheckGroupsDone: LEGION %s is not CANCELLED but in state %s. Mission NOT DONE!", legion.alias, status))
|
||||
return false
|
||||
end
|
||||
end
|
||||
@@ -2765,6 +2775,7 @@ function AUFTRAG:CheckGroupsDone()
|
||||
-- Check commander status.
|
||||
if self.commander then
|
||||
if not self.statusCommander==AUFTRAG.Status.CANCELLED then
|
||||
self:T(self.lid..string.format("CheckGroupsDone: COMMANDER is not CANCELLED but in state %s. Mission NOT DONE!", self.statusCommander))
|
||||
return false
|
||||
end
|
||||
end
|
||||
@@ -2772,18 +2783,21 @@ function AUFTRAG:CheckGroupsDone()
|
||||
-- Check chief status.
|
||||
if self.chief then
|
||||
if not self.statusChief==AUFTRAG.Status.CANCELLED then
|
||||
self:T(self.lid..string.format("CheckGroupsDone: CHIEF is not CANCELLED but in state %s. Mission NOT DONE!", self.statusChief))
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
-- These are early stages, where we might not even have a opsgroup defined to be checked. If there were any groups, we checked above.
|
||||
if self:IsPlanned() or self:IsQueued() or self:IsRequested() then
|
||||
if self:IsPlanned() or self:IsQueued() or self:IsRequested() then
|
||||
self:T(self.lid..string.format("CheckGroupsDone: Mission is still in state %s [FSM=%s] (PLANNED or QUEUED or REQUESTED). Mission NOT DONE!", self.status, self:GetState()))
|
||||
return false
|
||||
end
|
||||
|
||||
-- It could be that all flights were destroyed on the way to the mission execution waypoint.
|
||||
-- TODO: would be better to check if everybody is dead by now.
|
||||
if self:IsStarted() and self:CountOpsGroups()==0 then
|
||||
self:T(self.lid..string.format("CheckGroupsDone: Mission is STARTED state %s [FSM=%s] but count of alive OPSGROUP is zero. Mission DONE!", self.status, self:GetState()))
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user