mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
AUFTRAG
- Added push time
This commit is contained in:
parent
268eb1d60d
commit
1b717e4683
@ -233,7 +233,9 @@ do -- SET_BASE
|
||||
-- @param Core.Base#BASE Object The object itself.
|
||||
-- @return Core.Base#BASE The added BASE Object.
|
||||
function SET_BASE:Add( ObjectName, Object )
|
||||
self:I( { ObjectName = ObjectName, Object = Object } )
|
||||
|
||||
-- Debug info.
|
||||
self:T( { ObjectName = ObjectName, Object = Object } )
|
||||
|
||||
-- Ensure that the existing element is removed from the Set before a new one is inserted to the Set
|
||||
if self.Set[ObjectName] then
|
||||
@ -5908,12 +5910,13 @@ do -- SET_ZONE_GOAL
|
||||
-- @param Core.Event#EVENTDATA EventData
|
||||
function SET_ZONE_GOAL:OnEventNewZoneGoal( EventData )
|
||||
|
||||
self:I( { "New Zone Capture Coalition", EventData } )
|
||||
self:I( { "Zone Capture Coalition", EventData.ZoneGoal } )
|
||||
-- Debug info.
|
||||
self:T( { "New Zone Capture Coalition", EventData } )
|
||||
self:T( { "Zone Capture Coalition", EventData.ZoneGoal } )
|
||||
|
||||
if EventData.ZoneGoal then
|
||||
if EventData.ZoneGoal and self:IsIncludeObject( EventData.ZoneGoal ) then
|
||||
self:I( { "Adding Zone Capture Coalition", EventData.ZoneGoal.ZoneName, EventData.ZoneGoal } )
|
||||
self:T( { "Adding Zone Capture Coalition", EventData.ZoneGoal.ZoneName, EventData.ZoneGoal } )
|
||||
self:Add( EventData.ZoneGoal.ZoneName , EventData.ZoneGoal )
|
||||
end
|
||||
end
|
||||
|
||||
@ -392,6 +392,17 @@ function ARMYGROUP:onafterStatus(From, Event, To)
|
||||
self:_UpdateEngageTarget()
|
||||
end
|
||||
|
||||
-- Check if group is waiting.
|
||||
if self:IsWaiting() then
|
||||
if self.Twaiting and self.dTwait then
|
||||
if timer.getAbsTime()>self.Twaiting+self.dTwait then
|
||||
self.Twaiting=nil
|
||||
self.dTwait=nil
|
||||
self:Cruise()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if alive~=nil then
|
||||
|
||||
@ -39,9 +39,10 @@
|
||||
-- @field #number prio Mission priority.
|
||||
-- @field #boolean urgent Mission is urgent. Running missions with lower prio might be cancelled.
|
||||
-- @field #number importance Importance.
|
||||
-- @field #number Tstart Mission start time in seconds.
|
||||
-- @field #number Tstop Mission stop time in seconds.
|
||||
-- @field #number Tstart Mission start time in abs. seconds.
|
||||
-- @field #number Tstop Mission stop time in abs. seconds.
|
||||
-- @field #number duration Mission duration in seconds.
|
||||
-- @field #number Tpush Mission push/execute time in abs. seconds.
|
||||
-- @field Wrapper.Marker#MARKER marker F10 map marker.
|
||||
-- @field #boolean markerOn If true, display marker on F10 map with the AUFTRAG status.
|
||||
-- @field #number markerCoaliton Coalition to which the marker is dispayed.
|
||||
@ -442,7 +443,7 @@ AUFTRAG.TargetType={
|
||||
|
||||
--- AUFTRAG class version.
|
||||
-- @field #string version
|
||||
AUFTRAG.version="0.6.0"
|
||||
AUFTRAG.version="0.6.1"
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- TODO list
|
||||
@ -1436,6 +1437,24 @@ function AUFTRAG:SetTime(ClockStart, ClockStop)
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Set mission push time. This is the time the mission is executed. If the push time is not passed, the group will wait at the mission execution waypoint.
|
||||
-- @param #AUFTRAG self
|
||||
-- @param #string ClockPush Time the mission is executed, e.g. "05:00" for 5 am. Can also be given as a `#number`, where it is interpreted as relative push time in seconds.
|
||||
-- @return #AUFTRAG self
|
||||
function AUFTRAG:SetPushTime(ClockPush)
|
||||
|
||||
if ClockPush then
|
||||
if type(ClockPush)=="string" then
|
||||
self.Tpush=UTILS.ClockToSeconds(ClockPush)
|
||||
elseif type(ClockPush)=="number" then
|
||||
self.Tpush=timer.getAbsTime()+ClockPush
|
||||
end
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set mission priority and (optional) urgency. Urgent missions can cancel other running missions.
|
||||
-- @param #AUFTRAG self
|
||||
-- @param #number Prio Priority 1=high, 100=low. Default 50.
|
||||
|
||||
@ -609,13 +609,6 @@ function FLIGHTGROUP:IsCruising()
|
||||
return self:Is("Cruising")
|
||||
end
|
||||
|
||||
--- Check if flight is waiting after passing final waypoint.
|
||||
-- @param #FLIGHTGROUP self
|
||||
-- @return #boolean If true, flight is waiting.
|
||||
function FLIGHTGROUP:IsWaiting()
|
||||
return self:Is("Waiting")
|
||||
end
|
||||
|
||||
--- Check if flight is landing.
|
||||
-- @param #FLIGHTGROUP self
|
||||
-- @return #boolean If true, flight is landing, i.e. on final approach.
|
||||
@ -2556,15 +2549,15 @@ function FLIGHTGROUP:onbeforeWait(From, Event, To, Coord, Altitude, Speed)
|
||||
end
|
||||
|
||||
if Nsched>0 then
|
||||
self:I(self.lid..string.format("WARNING: Still got %d SCHEDULED tasks in the queue ==> WAIT event is suspended for 10 sec.", Nsched))
|
||||
Tsuspend=-10
|
||||
allowed=false
|
||||
--self:I(self.lid..string.format("WARNING: Still got %d SCHEDULED tasks in the queue ==> WAIT event is suspended for 10 sec.", Nsched))
|
||||
--Tsuspend=-10
|
||||
--allowed=false
|
||||
end
|
||||
|
||||
if Nwp>0 then
|
||||
self:I(self.lid..string.format("WARNING: Still got %d WAYPOINT tasks in the queue ==> WAIT event is suspended for 10 sec.", Nwp))
|
||||
Tsuspend=-10
|
||||
allowed=false
|
||||
--self:I(self.lid..string.format("WARNING: Still got %d WAYPOINT tasks in the queue ==> WAIT event is suspended for 10 sec.", Nwp))
|
||||
--Tsuspend=-10
|
||||
--allowed=false
|
||||
end
|
||||
|
||||
if Tsuspend and not allowed then
|
||||
|
||||
@ -522,6 +522,17 @@ function NAVYGROUP:onafterStatus(From, Event, To)
|
||||
|
||||
-- Check if group got stuck.
|
||||
self:_CheckStuck()
|
||||
|
||||
-- Check if group is waiting.
|
||||
if self:IsWaiting() then
|
||||
if self.Twaiting and self.dTwait then
|
||||
if timer.getAbsTime()>self.Twaiting+self.dTwait then
|
||||
self.Twaiting=nil
|
||||
self.dTwait=nil
|
||||
self:Cruise()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if self.verbose>=1 then
|
||||
|
||||
|
||||
@ -284,6 +284,7 @@ OPSGROUP.TaskType={
|
||||
--- Task structure.
|
||||
-- @type OPSGROUP.Task
|
||||
-- @field #string type Type of task: either SCHEDULED or WAYPOINT.
|
||||
-- @field #boolean ismission This is an AUFTRAG task.
|
||||
-- @field #number id Task ID. Running number to get the task.
|
||||
-- @field #number prio Priority.
|
||||
-- @field #number time Abs. mission time when to execute the task.
|
||||
@ -2876,6 +2877,57 @@ function OPSGROUP:GetTaskByID(id, status)
|
||||
return nil
|
||||
end
|
||||
|
||||
--- On before "TaskExecute" event.
|
||||
-- @param #OPSGROUP self
|
||||
-- @param #string From From state.
|
||||
-- @param #string Event Event.
|
||||
-- @param #string To To state.
|
||||
-- @param Ops.OpsGroup#OPSGROUP.Task Task The task.
|
||||
function OPSGROUP:onbeforeTaskExecute(From, Event, To, Task)
|
||||
|
||||
-- Get mission of this task (if any).
|
||||
local Mission=self:GetMissionByTaskID(Task.id)
|
||||
|
||||
if Mission then
|
||||
|
||||
if Mission.Tpush then
|
||||
|
||||
local Tnow=timer.getAbsTime()
|
||||
|
||||
-- Time to push
|
||||
local dt=Mission.Tpush-Tnow
|
||||
|
||||
-- Push time not reached.
|
||||
if Tnow<Mission.Tpush then
|
||||
|
||||
if self:IsWaiting() then
|
||||
-- Group is already waiting
|
||||
else
|
||||
self:Wait()
|
||||
end
|
||||
|
||||
-- Debug info.
|
||||
self:T(self.lid..string.format("Mission %s task execute suspended for %d seconds", Mission.name, dt))
|
||||
|
||||
-- Reexecute task.
|
||||
self:__TaskExecute(-dt, Task)
|
||||
|
||||
return false
|
||||
else
|
||||
-- Not waiting any more.
|
||||
self.Twaiting=nil
|
||||
self.dTwait=nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
else
|
||||
--env.info("FF no mission task execute")
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
--- On after "TaskExecute" event.
|
||||
-- @param #OPSGROUP self
|
||||
-- @param #string From From state.
|
||||
@ -2895,17 +2947,17 @@ function OPSGROUP:onafterTaskExecute(From, Event, To, Task)
|
||||
|
||||
-- Set current task.
|
||||
self.taskcurrent=Task.id
|
||||
|
||||
--
|
||||
if self:GetTaskCurrent()==nil then
|
||||
table.insert(self.taskqueue, Task)
|
||||
end
|
||||
|
||||
|
||||
-- Set time stamp.
|
||||
Task.timestamp=timer.getAbsTime()
|
||||
|
||||
-- Task status executing.
|
||||
Task.status=OPSGROUP.TaskStatus.EXECUTING
|
||||
|
||||
-- Insert into task queue. Not sure any more, why I added this. But probably if a task is just executed without having been put into the queue.
|
||||
if self:GetTaskCurrent()==nil then
|
||||
table.insert(self.taskqueue, Task)
|
||||
end
|
||||
|
||||
if Task.dcstask.id=="Formation" then
|
||||
|
||||
@ -2955,7 +3007,7 @@ function OPSGROUP:onafterTaskExecute(From, Event, To, Task)
|
||||
else
|
||||
|
||||
-- If task is scheduled (not waypoint) set task.
|
||||
if Task.type==OPSGROUP.TaskType.SCHEDULED then
|
||||
if Task.type==OPSGROUP.TaskType.SCHEDULED or Task.ismission then
|
||||
|
||||
local DCStasks={}
|
||||
if Task.dcstask.id=='ComboTask' then
|
||||
@ -2984,11 +3036,15 @@ function OPSGROUP:onafterTaskExecute(From, Event, To, Task)
|
||||
|
||||
-- Set task for group.
|
||||
self:SetTask(TaskFinal)
|
||||
|
||||
|
||||
elseif Task.type==OPSGROUP.TaskType.WAYPOINT then
|
||||
-- Waypoint tasks are executed elsewhere!
|
||||
else
|
||||
self:E(self.lid.."ERROR: Unknown task type: ")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
-- Get mission of this task (if any).
|
||||
local Mission=self:GetMissionByTaskID(self.taskcurrent)
|
||||
if Mission then
|
||||
@ -3390,9 +3446,6 @@ function OPSGROUP:onafterMissionStart(From, Event, To, Mission)
|
||||
|
||||
-- Set group mission status to STARTED.
|
||||
Mission:SetGroupStatus(self, AUFTRAG.GroupStatus.STARTED)
|
||||
|
||||
--
|
||||
|
||||
|
||||
-- Set mission status to STARTED.
|
||||
Mission:__Started(3)
|
||||
@ -3402,6 +3455,17 @@ function OPSGROUP:onafterMissionStart(From, Event, To, Mission)
|
||||
|
||||
end
|
||||
|
||||
--- On before "MissionExecute" event.
|
||||
-- @param #OPSGROUP self
|
||||
-- @param #string From From state.
|
||||
-- @param #string Event Event.
|
||||
-- @param #string To To state.
|
||||
-- @param Ops.Auftrag#AUFTRAG Mission The mission table.
|
||||
function OPSGROUP:onbeforeMissionExecute(From, Event, To, Mission)
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
--- On after "MissionExecute" event. Mission execution began.
|
||||
-- @param #OPSGROUP self
|
||||
-- @param #string From From state.
|
||||
@ -3698,6 +3762,7 @@ function OPSGROUP:RouteToMission(mission, delay)
|
||||
|
||||
-- Add waypoint task. UpdateRoute is called inside.
|
||||
local waypointtask=self:AddTaskWaypoint(mission.DCStask, waypoint, mission.name, mission.prio, mission.duration)
|
||||
waypointtask.ismission=true
|
||||
|
||||
-- Set waypoint task.
|
||||
mission:SetGroupWaypointTask(self, waypointtask)
|
||||
@ -3910,22 +3975,32 @@ function OPSGROUP:_SetWaypointTasks(Waypoint)
|
||||
|
||||
-- Debug info.
|
||||
local text=string.format("WP uid=%d tasks:", Waypoint.uid)
|
||||
local missiontask=nil --Ops.OpsGroup#OPSGROUP.Task
|
||||
if #tasks>0 then
|
||||
for i,_task in pairs(tasks) do
|
||||
local task=_task --#OPSGROUP.Task
|
||||
text=text..string.format("\n[%d] %s", i, task.description)
|
||||
if task.ismission then
|
||||
missiontask=task
|
||||
end
|
||||
end
|
||||
else
|
||||
text=text.." None"
|
||||
end
|
||||
self:T(self.lid..text)
|
||||
|
||||
-- Check if there is mission task
|
||||
if missiontask then
|
||||
env.info("FF executing mission task")
|
||||
self:TaskExecute(missiontask)
|
||||
return 1
|
||||
end
|
||||
|
||||
-- TODO: maybe set waypoint enroute tasks?
|
||||
|
||||
-- Tasks at this waypoints.
|
||||
local taskswp={}
|
||||
|
||||
-- TODO: maybe set waypoint enroute tasks?
|
||||
|
||||
for _,task in pairs(tasks) do
|
||||
local Task=task --Ops.OpsGroup#OPSGROUP.Task
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user