This commit is contained in:
Frank
2020-03-10 23:18:38 +01:00
parent 6305459056
commit fa9adaf046
3 changed files with 47 additions and 46 deletions
+2 -2
View File
@@ -493,7 +493,7 @@ function AIRWING:onafterStatus(From, Event, To)
local fsmstate=self:GetState() local fsmstate=self:GetState()
-- Check CAP missions. -- Check CAP missions.
self:CheckCAP() --self:CheckCAP()
--self:CheckTANKER() --self:CheckTANKER()
@@ -934,7 +934,7 @@ end
function AIRWING:onafterAssetDead(From, Event, To, asset, request) function AIRWING:onafterAssetDead(From, Event, To, asset, request)
-- Call parent warehouse function first. -- Call parent warehouse function first.
self:GetParent(self).onafterAssetDead(From, Event, To, asset, request) self:GetParent(self).onafterAssetDead(self, From, Event, To, asset, request)
-- Add group to the detection set of the WINGCOMMANDER. -- Add group to the detection set of the WINGCOMMANDER.
if self.wingcommander then if self.wingcommander then
+32 -24
View File
@@ -256,7 +256,7 @@ function AUFTRAG:New(Type)
self:SetMissionTime() self:SetMissionTime()
self.missionRepeated=0 self.missionRepeated=0
self.missionRepeatMax=1 self.missionRepeatMax=0
-- FMS start state is PLANNED. -- FMS start state is PLANNED.
self:SetStartState(self.status) self:SetStartState(self.status)
@@ -780,10 +780,6 @@ function AUFTRAG:onafterStatus(From, Event, To)
self:Cancel() self:Cancel()
end end
if self:IsNotOver() and #self.assets==0 then
self:Cancel()
end
-- Check if ALL flights are done with their mission. -- Check if ALL flights are done with their mission.
if self:IsNotOver() and self:CheckFlightsDone() then if self:IsNotOver() and self:CheckFlightsDone() then
self:Done() self:Done()
@@ -804,12 +800,9 @@ function AUFTRAG:onafterStatus(From, Event, To)
self:E(self.lid..string.format("ERROR: FSM state %s != %s mission status!", fsmstate, self.status)) self:E(self.lid..string.format("ERROR: FSM state %s != %s mission status!", fsmstate, self.status))
end end
-- Check if mission is OVER. -- Check if mission is OVER (done or cancelled).
if self:IsOver() then if self:IsOver() then
-- TODO: evaluate mission result. self.Ntargets>0 and Ntargets=? -- Evaluate success or failure of the mission.
-- TODO: if failed, repeat mission, i.e. set status to PLANNED? if success, stop and remove from ALL queues.
--self:Stop()
self:Evaluate() self:Evaluate()
else else
self:__Status(-30) self:__Status(-30)
@@ -1039,18 +1032,32 @@ function AUFTRAG:onafterAssetDead(From, Event, To, Asset)
if self:IsNotOver() then if self:IsNotOver() then
-- Mission failed. -- Cancel mission. Wait for next update to evaluate SUCCESS or FAILURE.
self:Failed() self:Cancel()
else else
self:Stop() self:E(self.lid.."ERROR: All assets are dead not but mission was already over... Investigate!")
end end
end end
end end
--- On after "Success" event.
-- @param #AUFTRAG self
-- @param #string From From state.
-- @param #string Event Event.
-- @param #string To To state.
function AUFTRAG:onafterSuccess(From, Event, To)
self.status=AUFTRAG.Status.SUCCESS
self:I(self.lid..string.format("New mission status=%s", self.status))
-- Stop mission.
self:Stop()
end
--- On after "Cancel" event. Cancells the mission. --- On after "Cancel" event. Cancells the mission.
-- @param #AUFTRAG self -- @param #AUFTRAG self
@@ -1109,6 +1116,9 @@ end
-- @param #string To To state. -- @param #string To To state.
function AUFTRAG:onafterRepeat(From, Event, To) function AUFTRAG:onafterRepeat(From, Event, To)
self.status=AUFTRAG.Status.PLANNED
self:I(self.lid..string.format("New mission status=%s (on Repeat)", self.status))
-- Increase repeat counter. -- Increase repeat counter.
self.missionRepeated=self.missionRepeated+1 self.missionRepeated=self.missionRepeated+1
@@ -1117,21 +1127,16 @@ function AUFTRAG:onafterRepeat(From, Event, To)
elseif self.airwing then elseif self.airwing then
else
end end
-- No mission assets.
self.assets={}
end end
--- On after "Success" event.
-- @param #AUFTRAG self
-- @param #string From From state.
-- @param #string Event Event.
-- @param #string To To state.
function AUFTRAG:onafterSuccess(From, Event, To)
self.status=AUFTRAG.Status.SUCCESS
self:I(self.lid..string.format("New mission status=%s", self.status))
end
--- On after "Stop" event. Remove mission from AIRWING and FLIGHTGROUP mission queues. --- On after "Stop" event. Remove mission from AIRWING and FLIGHTGROUP mission queues.
-- @param #AUFTRAG self -- @param #AUFTRAG self
@@ -1140,6 +1145,9 @@ end
-- @param #string To To state. -- @param #string To To state.
function AUFTRAG:onafterStop(From, Event, To) function AUFTRAG:onafterStop(From, Event, To)
self.status="Stopped"
self:I(self.lid..string.format("New mission status=%s. Removing missions from queues. Stopping CallScheduler!", self.status))
-- TODO: remove missions from queues in WINGCOMMANDER, AIRWING and FLIGHGROUPS! -- TODO: remove missions from queues in WINGCOMMANDER, AIRWING and FLIGHGROUPS!
-- TODO: Mission should be OVER! we dont want to remove running missions from any queues. -- TODO: Mission should be OVER! we dont want to remove running missions from any queues.
+13 -20
View File
@@ -596,7 +596,7 @@ function FLIGHTGROUP:AddTask(task, clock, description, prio, duration)
-- Info. -- Info.
self:I(self.lid..string.format("Adding SCHEDULED task %s starting at %s", newtask.description, UTILS.SecondsToClock(time, true))) self:I(self.lid..string.format("Adding SCHEDULED task %s starting at %s", newtask.description, UTILS.SecondsToClock(time, true)))
self:T2({newtask=newtask}) self:T3({newtask=newtask})
return newtask return newtask
end end
@@ -633,7 +633,7 @@ function FLIGHTGROUP:AddTaskWaypoint(task, waypointindex, description, prio, dur
-- Info. -- Info.
self:I(self.lid..string.format("Adding WAYPOINT task %s at WP %d", newtask.description, newtask.waypoint)) self:I(self.lid..string.format("Adding WAYPOINT task %s at WP %d", newtask.description, newtask.waypoint))
self:T2({newtask=newtask}) self:T3({newtask=newtask})
-- Update route. -- Update route.
self:__UpdateRoute(-1) self:__UpdateRoute(-1)
@@ -2218,10 +2218,10 @@ function FLIGHTGROUP:onbeforeUpdateRoute(From, Event, To, n)
if self.group and self.group:IsAlive() and self:IsAirborne() then if self.group and self.group:IsAlive() and self:IsAirborne() then
-- Alive & Airborne ==> Update route possible. -- Alive & Airborne ==> Update route possible.
self:T2(self.lid.."Update route possible. Group is ALIVE and AIRBORNE") self:T3(self.lid.."Update route possible. Group is ALIVE and AIRBORNE")
elseif self:IsDead() then elseif self:IsDead() then
-- Group is dead! No more updates. -- Group is dead! No more updates.
self:T3(self.lid.."FF update route denied. Group is DEAD!") self:E(self.lid.."Update route denied. Group is DEAD!")
allowed=false allowed=false
else else
-- Not airborne yet. Try again in 1 sec. -- Not airborne yet. Try again in 1 sec.
@@ -2231,14 +2231,12 @@ function FLIGHTGROUP:onbeforeUpdateRoute(From, Event, To, n)
end end
if n and n<1 then if n and n<1 then
self:T3(self.lid.."FF update route denied because n<1") self:E(self.lid.."Update route denied because waypoint n<1!")
self:__UpdateRoute(-1, n)
allowed=false allowed=false
end end
if not self.currentwp then if not self.currentwp then
self:T3(self.lid.."FF update route denied because self.currentwp=nil") self:E(self.lid.."Update route denied because self.currentwp=nil!")
self:__UpdateRoute(-1, n)
allowed=false allowed=false
end end
@@ -2250,12 +2248,12 @@ function FLIGHTGROUP:onbeforeUpdateRoute(From, Event, To, n)
end end
if self.taskcurrent>0 then if self.taskcurrent>0 then
self:I(self.lid.."FF update route denied because taskcurrent>0") self:E(self.lid.."Update route denied because taskcurrent>0")
allowed=false allowed=false
end end
-- Not good, because mission will never start. Better only check if there is a current task!
if self.currentmission then if self.currentmission then
-- Not good, because mission will never start. Better only check if there is a current task!
--self:I(self.lid.."FF update route denied because currentmission~=nil") --self:I(self.lid.."FF update route denied because currentmission~=nil")
--allowed=false --allowed=false
end end
@@ -2384,7 +2382,7 @@ function FLIGHTGROUP:onafterPassingWaypoint(From, Event, To, n, N)
else else
text=text.." None" text=text.." None"
end end
self:I(self.lid..text) self:T(self.lid..text)
-- Tasks at this waypoints. -- Tasks at this waypoints.
@@ -3229,7 +3227,7 @@ end
-- @param Ops.Auftrag#AUFTRAG Mission The mission table. -- @param Ops.Auftrag#AUFTRAG Mission The mission table.
function FLIGHTGROUP:onbeforeMissionStart(From, Event, To, Mission) function FLIGHTGROUP:onbeforeMissionStart(From, Event, To, Mission)
self:I(self.lid..string.format("FF Starting mission %s, FSM=%s, LateActivated=%s, UnControlled=%s", tostring(Mission.name), self:GetState(), tostring(self:IsLateActivated()), tostring(self:IsUncontrolled()))) self:I(self.lid..string.format("Starting mission %s, FSM=%s, LateActivated=%s, UnControlled=%s", tostring(Mission.name), self:GetState(), tostring(self:IsLateActivated()), tostring(self:IsUncontrolled())))
-- Delay for route to mission. Group needs to be activated and controlled. -- Delay for route to mission. Group needs to be activated and controlled.
local delay=0 local delay=0
@@ -3962,10 +3960,6 @@ function FLIGHTGROUP:GetNextWaypoint()
Nextwp=self.currentwp+1 Nextwp=self.currentwp+1
end end
-- Debug output
local text=string.format("Current WP=%d/%d, next WP=%d", self.currentwp, #self.waypoints, Nextwp)
self:T2(self.lid..text)
-- Next waypoint. -- Next waypoint.
local nextwp=self.waypoints[Nextwp] --Core.Point#COORDINATE local nextwp=self.waypoints[Nextwp] --Core.Point#COORDINATE
@@ -3992,7 +3986,8 @@ function FLIGHTGROUP:_UpdateWaypointTasks()
if i>self.currentwp or nwaypoints==1 then if i>self.currentwp or nwaypoints==1 then
self:I(self.lid..string.format("Updating waypoint task for waypoint %d/%d. Last waypoint passed %d.", i, nwaypoints, self.currentwp)) -- Debug info.
self:T2(self.lid..string.format("Updating waypoint task for waypoint %d/%d. Last waypoint passed %d.", i, nwaypoints, self.currentwp))
-- Tasks of this waypoint -- Tasks of this waypoint
local taskswp={} local taskswp={}
@@ -4363,7 +4358,7 @@ function FLIGHTGROUP:_AllSimilarStatus(status)
end end
-- Debug info. -- Debug info.
self:T2(self.lid..string.format("All %d elements have similar status %s ==> returning TRUE", #self.elements, status)) self:T3(self.lid..string.format("All %d elements have similar status %s ==> returning TRUE", #self.elements, status))
return true return true
end end
@@ -4860,7 +4855,6 @@ function FLIGHTGROUP:_GetPlayerUnitAndName(_unitName)
local playername=DCSunit:getPlayerName() local playername=DCSunit:getPlayerName()
local unit=UNIT:Find(DCSunit) local unit=UNIT:Find(DCSunit)
self:T2({DCSunit=DCSunit, unit=unit, playername=playername})
if DCSunit and unit and playername then if DCSunit and unit and playername then
return unit, playername return unit, playername
end end
@@ -4972,7 +4966,6 @@ function FLIGHTGROUP:GetParking(airbase)
local function _overlap(l1,l2,dist) local function _overlap(l1,l2,dist)
local safedist=(l1/2+l2/2)*1.05 -- 5% safety margine added to safe distance! local safedist=(l1/2+l2/2)*1.05 -- 5% safety margine added to safe distance!
local safe = (dist > safedist) local safe = (dist > safedist)
self:T3(string.format("l1=%.1f l2=%.1f s=%.1f d=%.1f ==> safe=%s", l1,l2,safedist,dist,tostring(safe)))
return safe return safe
end end