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:
@@ -233,7 +233,9 @@ do -- SET_BASE
|
|||||||
-- @param Core.Base#BASE Object The object itself.
|
-- @param Core.Base#BASE Object The object itself.
|
||||||
-- @return Core.Base#BASE The added BASE Object.
|
-- @return Core.Base#BASE The added BASE Object.
|
||||||
function SET_BASE:Add( ObjectName, 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
|
-- Ensure that the existing element is removed from the Set before a new one is inserted to the Set
|
||||||
if self.Set[ObjectName] then
|
if self.Set[ObjectName] then
|
||||||
@@ -5908,12 +5910,13 @@ do -- SET_ZONE_GOAL
|
|||||||
-- @param Core.Event#EVENTDATA EventData
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
function SET_ZONE_GOAL:OnEventNewZoneGoal( EventData )
|
function SET_ZONE_GOAL:OnEventNewZoneGoal( EventData )
|
||||||
|
|
||||||
self:I( { "New Zone Capture Coalition", EventData } )
|
-- Debug info.
|
||||||
self:I( { "Zone Capture Coalition", EventData.ZoneGoal } )
|
self:T( { "New Zone Capture Coalition", EventData } )
|
||||||
|
self:T( { "Zone Capture Coalition", EventData.ZoneGoal } )
|
||||||
|
|
||||||
if EventData.ZoneGoal then
|
if EventData.ZoneGoal then
|
||||||
if EventData.ZoneGoal and self:IsIncludeObject( 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 )
|
self:Add( EventData.ZoneGoal.ZoneName , EventData.ZoneGoal )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -392,6 +392,17 @@ function ARMYGROUP:onafterStatus(From, Event, To)
|
|||||||
self:_UpdateEngageTarget()
|
self:_UpdateEngageTarget()
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
if alive~=nil then
|
if alive~=nil then
|
||||||
|
|||||||
@@ -39,9 +39,10 @@
|
|||||||
-- @field #number prio Mission priority.
|
-- @field #number prio Mission priority.
|
||||||
-- @field #boolean urgent Mission is urgent. Running missions with lower prio might be cancelled.
|
-- @field #boolean urgent Mission is urgent. Running missions with lower prio might be cancelled.
|
||||||
-- @field #number importance Importance.
|
-- @field #number importance Importance.
|
||||||
-- @field #number Tstart Mission start time in seconds.
|
-- @field #number Tstart Mission start time in abs. seconds.
|
||||||
-- @field #number Tstop Mission stop time in seconds.
|
-- @field #number Tstop Mission stop time in abs. seconds.
|
||||||
-- @field #number duration Mission duration in 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 Wrapper.Marker#MARKER marker F10 map marker.
|
||||||
-- @field #boolean markerOn If true, display marker on F10 map with the AUFTRAG status.
|
-- @field #boolean markerOn If true, display marker on F10 map with the AUFTRAG status.
|
||||||
-- @field #number markerCoaliton Coalition to which the marker is dispayed.
|
-- @field #number markerCoaliton Coalition to which the marker is dispayed.
|
||||||
@@ -442,7 +443,7 @@ AUFTRAG.TargetType={
|
|||||||
|
|
||||||
--- AUFTRAG class version.
|
--- AUFTRAG class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
AUFTRAG.version="0.6.0"
|
AUFTRAG.version="0.6.1"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO list
|
-- TODO list
|
||||||
@@ -1436,6 +1437,24 @@ function AUFTRAG:SetTime(ClockStart, ClockStop)
|
|||||||
return self
|
return self
|
||||||
end
|
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.
|
--- Set mission priority and (optional) urgency. Urgent missions can cancel other running missions.
|
||||||
-- @param #AUFTRAG self
|
-- @param #AUFTRAG self
|
||||||
-- @param #number Prio Priority 1=high, 100=low. Default 50.
|
-- @param #number Prio Priority 1=high, 100=low. Default 50.
|
||||||
|
|||||||
@@ -609,13 +609,6 @@ function FLIGHTGROUP:IsCruising()
|
|||||||
return self:Is("Cruising")
|
return self:Is("Cruising")
|
||||||
end
|
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.
|
--- Check if flight is landing.
|
||||||
-- @param #FLIGHTGROUP self
|
-- @param #FLIGHTGROUP self
|
||||||
-- @return #boolean If true, flight is landing, i.e. on final approach.
|
-- @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
|
end
|
||||||
|
|
||||||
if Nsched>0 then
|
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))
|
--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
|
--Tsuspend=-10
|
||||||
allowed=false
|
--allowed=false
|
||||||
end
|
end
|
||||||
|
|
||||||
if Nwp>0 then
|
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))
|
--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
|
--Tsuspend=-10
|
||||||
allowed=false
|
--allowed=false
|
||||||
end
|
end
|
||||||
|
|
||||||
if Tsuspend and not allowed then
|
if Tsuspend and not allowed then
|
||||||
|
|||||||
@@ -523,6 +523,17 @@ function NAVYGROUP:onafterStatus(From, Event, To)
|
|||||||
-- Check if group got stuck.
|
-- Check if group got stuck.
|
||||||
self:_CheckStuck()
|
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
|
if self.verbose>=1 then
|
||||||
|
|
||||||
-- Get number of tasks and missions.
|
-- Get number of tasks and missions.
|
||||||
|
|||||||
@@ -284,6 +284,7 @@ OPSGROUP.TaskType={
|
|||||||
--- Task structure.
|
--- Task structure.
|
||||||
-- @type OPSGROUP.Task
|
-- @type OPSGROUP.Task
|
||||||
-- @field #string type Type of task: either SCHEDULED or WAYPOINT.
|
-- @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 id Task ID. Running number to get the task.
|
||||||
-- @field #number prio Priority.
|
-- @field #number prio Priority.
|
||||||
-- @field #number time Abs. mission time when to execute the task.
|
-- @field #number time Abs. mission time when to execute the task.
|
||||||
@@ -2876,6 +2877,57 @@ function OPSGROUP:GetTaskByID(id, status)
|
|||||||
return nil
|
return nil
|
||||||
end
|
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.
|
--- On after "TaskExecute" event.
|
||||||
-- @param #OPSGROUP self
|
-- @param #OPSGROUP self
|
||||||
-- @param #string From From state.
|
-- @param #string From From state.
|
||||||
@@ -2896,17 +2948,17 @@ function OPSGROUP:onafterTaskExecute(From, Event, To, Task)
|
|||||||
-- Set current task.
|
-- Set current task.
|
||||||
self.taskcurrent=Task.id
|
self.taskcurrent=Task.id
|
||||||
|
|
||||||
--
|
|
||||||
if self:GetTaskCurrent()==nil then
|
|
||||||
table.insert(self.taskqueue, Task)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Set time stamp.
|
-- Set time stamp.
|
||||||
Task.timestamp=timer.getAbsTime()
|
Task.timestamp=timer.getAbsTime()
|
||||||
|
|
||||||
-- Task status executing.
|
-- Task status executing.
|
||||||
Task.status=OPSGROUP.TaskStatus.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
|
if Task.dcstask.id=="Formation" then
|
||||||
|
|
||||||
-- Set of group(s) to follow Mother.
|
-- Set of group(s) to follow Mother.
|
||||||
@@ -2955,7 +3007,7 @@ function OPSGROUP:onafterTaskExecute(From, Event, To, Task)
|
|||||||
else
|
else
|
||||||
|
|
||||||
-- If task is scheduled (not waypoint) set task.
|
-- 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={}
|
local DCStasks={}
|
||||||
if Task.dcstask.id=='ComboTask' then
|
if Task.dcstask.id=='ComboTask' then
|
||||||
@@ -2985,6 +3037,10 @@ function OPSGROUP:onafterTaskExecute(From, Event, To, Task)
|
|||||||
-- Set task for group.
|
-- Set task for group.
|
||||||
self:SetTask(TaskFinal)
|
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
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -3391,9 +3447,6 @@ function OPSGROUP:onafterMissionStart(From, Event, To, Mission)
|
|||||||
-- Set group mission status to STARTED.
|
-- Set group mission status to STARTED.
|
||||||
Mission:SetGroupStatus(self, AUFTRAG.GroupStatus.STARTED)
|
Mission:SetGroupStatus(self, AUFTRAG.GroupStatus.STARTED)
|
||||||
|
|
||||||
--
|
|
||||||
|
|
||||||
|
|
||||||
-- Set mission status to STARTED.
|
-- Set mission status to STARTED.
|
||||||
Mission:__Started(3)
|
Mission:__Started(3)
|
||||||
|
|
||||||
@@ -3402,6 +3455,17 @@ function OPSGROUP:onafterMissionStart(From, Event, To, Mission)
|
|||||||
|
|
||||||
end
|
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.
|
--- On after "MissionExecute" event. Mission execution began.
|
||||||
-- @param #OPSGROUP self
|
-- @param #OPSGROUP self
|
||||||
-- @param #string From From state.
|
-- @param #string From From state.
|
||||||
@@ -3698,6 +3762,7 @@ function OPSGROUP:RouteToMission(mission, delay)
|
|||||||
|
|
||||||
-- Add waypoint task. UpdateRoute is called inside.
|
-- Add waypoint task. UpdateRoute is called inside.
|
||||||
local waypointtask=self:AddTaskWaypoint(mission.DCStask, waypoint, mission.name, mission.prio, mission.duration)
|
local waypointtask=self:AddTaskWaypoint(mission.DCStask, waypoint, mission.name, mission.prio, mission.duration)
|
||||||
|
waypointtask.ismission=true
|
||||||
|
|
||||||
-- Set waypoint task.
|
-- Set waypoint task.
|
||||||
mission:SetGroupWaypointTask(self, waypointtask)
|
mission:SetGroupWaypointTask(self, waypointtask)
|
||||||
@@ -3910,22 +3975,32 @@ function OPSGROUP:_SetWaypointTasks(Waypoint)
|
|||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
local text=string.format("WP uid=%d tasks:", Waypoint.uid)
|
local text=string.format("WP uid=%d tasks:", Waypoint.uid)
|
||||||
|
local missiontask=nil --Ops.OpsGroup#OPSGROUP.Task
|
||||||
if #tasks>0 then
|
if #tasks>0 then
|
||||||
for i,_task in pairs(tasks) do
|
for i,_task in pairs(tasks) do
|
||||||
local task=_task --#OPSGROUP.Task
|
local task=_task --#OPSGROUP.Task
|
||||||
text=text..string.format("\n[%d] %s", i, task.description)
|
text=text..string.format("\n[%d] %s", i, task.description)
|
||||||
|
if task.ismission then
|
||||||
|
missiontask=task
|
||||||
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
text=text.." None"
|
text=text.." None"
|
||||||
end
|
end
|
||||||
self:T(self.lid..text)
|
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.
|
-- Tasks at this waypoints.
|
||||||
local taskswp={}
|
local taskswp={}
|
||||||
|
|
||||||
-- TODO: maybe set waypoint enroute tasks?
|
|
||||||
|
|
||||||
for _,task in pairs(tasks) do
|
for _,task in pairs(tasks) do
|
||||||
local Task=task --Ops.OpsGroup#OPSGROUP.Task
|
local Task=task --Ops.OpsGroup#OPSGROUP.Task
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user