mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-18 13:16:03 +00:00
FG/TG
This commit is contained in:
@@ -509,14 +509,17 @@ end
|
|||||||
-- @param #SPAWN self
|
-- @param #SPAWN self
|
||||||
-- @param #string AirbaseName Name of the airbase.
|
-- @param #string AirbaseName Name of the airbase.
|
||||||
-- @param #number Takeoff (Optional) Takeoff type. Can be SPAWN.Takeoff.Hot (default), SPAWN.Takeoff.Cold or SPAWN.Takeoff.Runway.
|
-- @param #number Takeoff (Optional) Takeoff type. Can be SPAWN.Takeoff.Hot (default), SPAWN.Takeoff.Cold or SPAWN.Takeoff.Runway.
|
||||||
|
-- @param #number TerminalTyple (Optional) The terminal type.
|
||||||
-- @return #SPAWN self
|
-- @return #SPAWN self
|
||||||
function SPAWN:InitAirbase( AirbaseName, Takeoff )
|
function SPAWN:InitAirbase( AirbaseName, Takeoff, TerminalType )
|
||||||
self:F( )
|
self:F( )
|
||||||
|
|
||||||
self.SpawnInitAirbase=AIRBASE:FindByName(AirbaseName)
|
self.SpawnInitAirbase=AIRBASE:FindByName(AirbaseName)
|
||||||
|
|
||||||
self.SpawnInitTakeoff=Takeoff or SPAWN.Takeoff.Hot
|
self.SpawnInitTakeoff=Takeoff or SPAWN.Takeoff.Hot
|
||||||
|
|
||||||
|
self.SpawnInitTerminalType=TerminalType
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1133,7 +1136,7 @@ function SPAWN:Spawn()
|
|||||||
self:F( { self.SpawnTemplatePrefix, self.SpawnIndex, self.AliveUnits } )
|
self:F( { self.SpawnTemplatePrefix, self.SpawnIndex, self.AliveUnits } )
|
||||||
|
|
||||||
if self.SpawnInitAirbase then
|
if self.SpawnInitAirbase then
|
||||||
return self:SpawnAtAirbase(self.SpawnInitAirbase, self.SpawnInitTakeoff)
|
return self:SpawnAtAirbase(self.SpawnInitAirbase, self.SpawnInitTakeoff, nil, self.SpawnInitTerminalType)
|
||||||
else
|
else
|
||||||
return self:SpawnWithIndex( self.SpawnIndex + 1 )
|
return self:SpawnWithIndex( self.SpawnIndex + 1 )
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
do -- UserFlag
|
do -- UserFlag
|
||||||
|
|
||||||
--- @type USERFLAG
|
--- @type USERFLAG
|
||||||
|
-- @field #string ClassName Name of the class
|
||||||
|
-- @field #string UserFlagName Name of the flag.
|
||||||
-- @extends Core.Base#BASE
|
-- @extends Core.Base#BASE
|
||||||
|
|
||||||
|
|
||||||
@@ -30,7 +32,8 @@ do -- UserFlag
|
|||||||
--
|
--
|
||||||
-- @field #USERFLAG
|
-- @field #USERFLAG
|
||||||
USERFLAG = {
|
USERFLAG = {
|
||||||
ClassName = "USERFLAG",
|
ClassName = "USERFLAG",
|
||||||
|
UserFlagName = nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
--- USERFLAG Constructor.
|
--- USERFLAG Constructor.
|
||||||
@@ -46,6 +49,12 @@ do -- UserFlag
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Get the userflag name.
|
||||||
|
-- @param #USERFLAG self
|
||||||
|
-- @return #string Name of the user flag.
|
||||||
|
function USERFLAG:GetName()
|
||||||
|
return self.UserFlagName
|
||||||
|
end
|
||||||
|
|
||||||
--- Set the userflag to a given Number.
|
--- Set the userflag to a given Number.
|
||||||
-- @param #USERFLAG self
|
-- @param #USERFLAG self
|
||||||
|
|||||||
@@ -305,6 +305,7 @@ FLIGHTGROUP.TaskType={
|
|||||||
-- @field #number duration Duration before task is cancelled in seconds. Default never.
|
-- @field #number duration Duration before task is cancelled in seconds. Default never.
|
||||||
-- @field #number timestamp Abs. mission time, when task was started.
|
-- @field #number timestamp Abs. mission time, when task was started.
|
||||||
-- @field #number waypoint Waypoint index if task is a waypoint task.
|
-- @field #number waypoint Waypoint index if task is a waypoint task.
|
||||||
|
-- @field Core.UserFlag#USERFLAG stopflag If flag is set to 1 (=true), the task is stopped.
|
||||||
|
|
||||||
|
|
||||||
--- FLIGHTGROUP class version.
|
--- FLIGHTGROUP class version.
|
||||||
@@ -501,6 +502,14 @@ end
|
|||||||
-- User functions
|
-- User functions
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
--- Add a *scheduled* task.
|
||||||
|
-- @param #FLIGHTGROUP self
|
||||||
|
-- @param #number id Task id.
|
||||||
|
-- @return #string Name of the stop flag
|
||||||
|
function FLIGHTGROUP:StopTaskFlagname(id)
|
||||||
|
return string.format("StopTaskFlag %d", id)
|
||||||
|
end
|
||||||
|
|
||||||
--- Add a *scheduled* task.
|
--- Add a *scheduled* task.
|
||||||
-- @param #FLIGHTGROUP self
|
-- @param #FLIGHTGROUP self
|
||||||
-- @param #table task DCS task table structure.
|
-- @param #table task DCS task table structure.
|
||||||
@@ -535,6 +544,9 @@ function FLIGHTGROUP:AddTask(task, clock, description, prio, duration)
|
|||||||
newtask.duration=duration
|
newtask.duration=duration
|
||||||
newtask.waypoint=-1
|
newtask.waypoint=-1
|
||||||
newtask.type=FLIGHTGROUP.TaskType.SCHEDULED
|
newtask.type=FLIGHTGROUP.TaskType.SCHEDULED
|
||||||
|
newtask.stopflag=USERFLAG:New(self:StopTaskFlagname(newtask.id))
|
||||||
|
newtask.stopflag:Set(0)
|
||||||
|
|
||||||
|
|
||||||
-- Info.
|
-- Info.
|
||||||
self:I(self.lid..string.format("Adding task %s scheduled at %s", newtask.description, UTILS.SecondsToClock(time, true)))
|
self:I(self.lid..string.format("Adding task %s scheduled at %s", newtask.description, UTILS.SecondsToClock(time, true)))
|
||||||
@@ -572,6 +584,8 @@ function FLIGHTGROUP:AddTaskWaypoint(task, waypointindex, description, prio, dur
|
|||||||
newtask.time=0
|
newtask.time=0
|
||||||
newtask.waypoint=waypointindex or (self.currentwp and self.currentwp+1 or 2)
|
newtask.waypoint=waypointindex or (self.currentwp and self.currentwp+1 or 2)
|
||||||
newtask.type=FLIGHTGROUP.TaskType.WAYPOINT
|
newtask.type=FLIGHTGROUP.TaskType.WAYPOINT
|
||||||
|
newtask.stopflag=USERFLAG:New(self:StopTaskFlagname(newtask.id))
|
||||||
|
newtask.stopflag:Set(0)
|
||||||
|
|
||||||
self:T2({newtask=newtask})
|
self:T2({newtask=newtask})
|
||||||
|
|
||||||
@@ -587,6 +601,27 @@ function FLIGHTGROUP:AddTaskWaypoint(task, waypointindex, description, prio, dur
|
|||||||
return self.taskcounter
|
return self.taskcounter
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Add an *enroute* task.
|
||||||
|
-- @param #FLIGHTGROUP self
|
||||||
|
-- @param #table task DCS task table stucture.
|
||||||
|
function FLIGHTGROUP:AddTaskEnroute(task)
|
||||||
|
if not self.taskenroute then
|
||||||
|
self.taskenroute={}
|
||||||
|
end
|
||||||
|
table.insert(self.taskenroute, task)
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Add an *enroute* task to attack targets in a certain **cicular** zone.
|
||||||
|
-- @param #FLIGHTGROUP self
|
||||||
|
-- @param Core.Zone#ZONE_RADIUS ZoneRadius The circular zone, where to engage targets.
|
||||||
|
-- @param #table TargetTypes (Optional) The target types, passed as a table, i.e. mind the cirly brackets {}.
|
||||||
|
-- @param #number Priority (Optional) Priority.
|
||||||
|
function FLIGHTGROUP:AddTaskEnrouteEngageTargetsInZone(ZoneRadius, TargetTypes, Priority)
|
||||||
|
local Task=self.group:EnRouteTaskEngageTargetsInZone(ZoneRadius:GetVec2(), ZoneRadius:GetRadius(), TargetTypes, Priority)
|
||||||
|
self:AddTaskEnroute(Task)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Remove task.
|
--- Remove task.
|
||||||
-- @param #FLIGHTGROUP self
|
-- @param #FLIGHTGROUP self
|
||||||
-- @param #number taskid ID of the task to remove.
|
-- @param #number taskid ID of the task to remove.
|
||||||
@@ -1150,7 +1185,7 @@ function FLIGHTGROUP:onafterFlightStatus(From, Event, To)
|
|||||||
if task.type==FLIGHTGROUP.TaskType.SCHEDULED then
|
if task.type==FLIGHTGROUP.TaskType.SCHEDULED then
|
||||||
text=text..string.format("\n[%d] %s: %s: status=%s, scheduled=%s (%d sec), started=%s, duration=%d", i, taskid, name, status, clock, eta, started, duration)
|
text=text..string.format("\n[%d] %s: %s: status=%s, scheduled=%s (%d sec), started=%s, duration=%d", i, taskid, name, status, clock, eta, started, duration)
|
||||||
elseif task.type==FLIGHTGROUP.TaskType.WAYPOINT then
|
elseif task.type==FLIGHTGROUP.TaskType.WAYPOINT then
|
||||||
text=text..string.format("\n[%d] %s: %s: status=%s, waypoint=%d, started=%s, duration=%d", i, taskid, name, status, task.waypoint, started, duration)
|
text=text..string.format("\n[%d] %s: %s: status=%s, waypoint=%d, started=%s, duration=%d, stopflag=%d", i, taskid, name, status, task.waypoint, started, duration, task.stopflag:Get())
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if #self.taskqueue>0 then
|
if #self.taskqueue>0 then
|
||||||
@@ -2110,7 +2145,7 @@ function FLIGHTGROUP:onafterPassingWaypoint(From, Event, To, n, N)
|
|||||||
|
|
||||||
local tasks=self:GetTasksWaypoint(n)
|
local tasks=self:GetTasksWaypoint(n)
|
||||||
|
|
||||||
local text=string.format("WP %d/N tasks:", n, N)
|
local text=string.format("WP %d/%d tasks:", n, N)
|
||||||
if tasks then
|
if tasks then
|
||||||
for i,_task in pairs(tasks) do
|
for i,_task in pairs(tasks) do
|
||||||
local task=_task --#FLIGHTGROUP.Task
|
local task=_task --#FLIGHTGROUP.Task
|
||||||
@@ -2121,9 +2156,36 @@ function FLIGHTGROUP:onafterPassingWaypoint(From, Event, To, n, N)
|
|||||||
end
|
end
|
||||||
self:I(self.lid..text)
|
self:I(self.lid..text)
|
||||||
|
|
||||||
|
|
||||||
|
local taskswp={}
|
||||||
|
for _,task in pairs(tasks) do
|
||||||
|
local Task=task --#FLIGHTGROUP.Task
|
||||||
|
|
||||||
|
-- Task execute.
|
||||||
|
table.insert(taskswp, self.group:TaskFunction("FLIGHTGROUP._TaskExecute", self, Task))
|
||||||
|
|
||||||
|
-- Stop condition if userflag is set to 1.
|
||||||
|
local TaskCondition=self.group:TaskCondition(nil, Task.stopflag:GetName(), 1, nil, Task.duration)
|
||||||
|
|
||||||
|
-- Controlled task.
|
||||||
|
table.insert(taskswp, self.group:TaskControlled(Task.dcstask, TaskCondition))
|
||||||
|
|
||||||
|
--table.insert(taskswp, Task.dcstask)
|
||||||
|
|
||||||
|
-- Task done.
|
||||||
|
table.insert(taskswp, self.group:TaskFunction("FLIGHTGROUP._TaskDone", self, Task))
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- At the final AIR waypoint, we set the flight to hold.
|
-- At the final AIR waypoint, we set the flight to hold.
|
||||||
if self.destbase and n>1 and n==N-1 then
|
if self.destbase and n>1 and n==N-1 then
|
||||||
self:__Hold(-1, self.destbase)
|
self:__Hold(-1, self.destbase)
|
||||||
|
else
|
||||||
|
-- Waypoint task combo.
|
||||||
|
if #taskswp>0 then
|
||||||
|
self.group:SetTask(self.group:TaskCombo(taskswp))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -2414,6 +2476,15 @@ function FLIGHTGROUP:onafterLandAt(From, Event, To, Coordinate, Duration)
|
|||||||
-- Add task with high priority.
|
-- Add task with high priority.
|
||||||
self:AddTask(task, 1, "Task_Land_At", 0)
|
self:AddTask(task, 1, "Task_Land_At", 0)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Create a DCS task sandwitch.
|
||||||
|
-- @param #FLIGHTGROUP self
|
||||||
|
-- @param #FLIGHTGROUP.Task Task The task.
|
||||||
|
-- @param #table DCS task sandwitch
|
||||||
|
function FLIGHTGROUP:_GetTaskSandwitch(Task)
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- On after TaskExecute event.
|
--- On after TaskExecute event.
|
||||||
@@ -2444,13 +2515,11 @@ function FLIGHTGROUP:onafterTaskExecute(From, Event, To, Task)
|
|||||||
Task.status=FLIGHTGROUP.TaskStatus.EXECUTING
|
Task.status=FLIGHTGROUP.TaskStatus.EXECUTING
|
||||||
|
|
||||||
-- If task is scheduled (not waypoint) set task.
|
-- If task is scheduled (not waypoint) set task.
|
||||||
if Task.type==FLIGHTGROUP.TaskType.SCHEDULED or true then
|
if Task.type==FLIGHTGROUP.TaskType.SCHEDULED then
|
||||||
|
|
||||||
-- Clear all tasks.
|
-- Clear all tasks.
|
||||||
--self.group:ClearTasks()
|
--self.group:ClearTasks()
|
||||||
|
|
||||||
-- Task done.
|
|
||||||
local TaskDone=self.group:TaskFunction("FLIGHTGROUP._TaskDone", self, Task)
|
|
||||||
|
|
||||||
local DCStasks={}
|
local DCStasks={}
|
||||||
if Task.dcstask.id=='ComboTask' then
|
if Task.dcstask.id=='ComboTask' then
|
||||||
@@ -2461,16 +2530,31 @@ function FLIGHTGROUP:onafterTaskExecute(From, Event, To, Task)
|
|||||||
else
|
else
|
||||||
table.insert(DCStasks, Task.dcstask)
|
table.insert(DCStasks, Task.dcstask)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Task done.
|
||||||
|
local TaskDone=self.group:TaskFunction("FLIGHTGROUP._TaskDone", self, Task)
|
||||||
table.insert(DCStasks, TaskDone)
|
table.insert(DCStasks, TaskDone)
|
||||||
|
|
||||||
|
env.info("FF DCS task combo")
|
||||||
|
for i,DCStask in pairs(DCStasks) do
|
||||||
|
self:I{{DCStask=DCStask}}
|
||||||
|
end
|
||||||
|
|
||||||
-- Combo task.
|
-- Combo task.
|
||||||
local TaskCombo=self.group:TaskCombo(DCStasks)
|
local TaskCombo=self.group:TaskCombo(DCStasks)
|
||||||
|
|
||||||
|
|
||||||
|
-- Stop condition!
|
||||||
|
local TaskCondition=self.group:TaskCondition(nil, Task.stopflag:GetName(), 1)
|
||||||
|
|
||||||
env.info("FF executing Taskcombo:")
|
-- Controlled task.
|
||||||
self:I({task=TaskCombo})
|
local TaskControlled=self.group:TaskControlled(TaskCombo, TaskCondition)
|
||||||
|
|
||||||
|
env.info("FF executing controlled Task:")
|
||||||
|
self:I({task=TaskControlled})
|
||||||
|
|
||||||
-- Set task for group.
|
-- Set task for group.
|
||||||
self.group:SetTask(TaskCombo, 1)
|
self.group:SetTask(TaskControlled, 1)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -2512,7 +2596,9 @@ function FLIGHTGROUP:onafterTaskCancel(From, Event, To)
|
|||||||
MESSAGE:New(text, 10, "DEBUG"):ToAllIf(self.Debug)
|
MESSAGE:New(text, 10, "DEBUG"):ToAllIf(self.Debug)
|
||||||
self:I(self.lid..text)
|
self:I(self.lid..text)
|
||||||
-- Clear tasks.
|
-- Clear tasks.
|
||||||
self.group:ClearTasks()
|
--self.group:ClearTasks()
|
||||||
|
--self.group:PopCurrentTask()
|
||||||
|
task.stopflag:Set(1)
|
||||||
self:TaskDone(task)
|
self:TaskDone(task)
|
||||||
else
|
else
|
||||||
local text=string.format("WARNING: No current task to cancel!")
|
local text=string.format("WARNING: No current task to cancel!")
|
||||||
@@ -2702,8 +2788,8 @@ end
|
|||||||
function FLIGHTGROUP._TaskExecute(group, flightgroup, task)
|
function FLIGHTGROUP._TaskExecute(group, flightgroup, task)
|
||||||
|
|
||||||
-- Debug message.
|
-- Debug message.
|
||||||
local text=string.format("Task Execute %s", task.description)
|
local text=string.format("_TaskExecute %s", task.description)
|
||||||
flightgroup:T2(flightgroup.lid..text)
|
flightgroup:I(flightgroup.lid..text)
|
||||||
|
|
||||||
-- Set current task to nil so that the next in line can be executed.
|
-- Set current task to nil so that the next in line can be executed.
|
||||||
if flightgroup then
|
if flightgroup then
|
||||||
@@ -2719,8 +2805,8 @@ end
|
|||||||
function FLIGHTGROUP._TaskDone(group, flightgroup, task)
|
function FLIGHTGROUP._TaskDone(group, flightgroup, task)
|
||||||
|
|
||||||
-- Debug message.
|
-- Debug message.
|
||||||
local text=string.format("Task Done %s", task.description)
|
local text=string.format("_TaskDone %s", task.description)
|
||||||
flightgroup:T2(flightgroup.lid..text)
|
flightgroup:I(flightgroup.lid..text)
|
||||||
|
|
||||||
-- Set current task to nil so that the next in line can be executed.
|
-- Set current task to nil so that the next in line can be executed.
|
||||||
if flightgroup then
|
if flightgroup then
|
||||||
@@ -2738,6 +2824,7 @@ function FLIGHTGROUP._PassingWaypoint(group, flightgroup, i)
|
|||||||
|
|
||||||
-- Debug message.
|
-- Debug message.
|
||||||
local text=string.format("Group %s passing waypoint %d of %d.", group:GetName(), i, final)
|
local text=string.format("Group %s passing waypoint %d of %d.", group:GetName(), i, final)
|
||||||
|
env.info(text)
|
||||||
|
|
||||||
-- Debug smoke and marker.
|
-- Debug smoke and marker.
|
||||||
if flightgroup.Debug then
|
if flightgroup.Debug then
|
||||||
@@ -3269,27 +3356,51 @@ function FLIGHTGROUP:_UpdateWaypointTasks()
|
|||||||
|
|
||||||
-- Tasks of this waypoint
|
-- Tasks of this waypoint
|
||||||
local taskswp={}
|
local taskswp={}
|
||||||
|
|
||||||
|
if self.taskenroute then
|
||||||
|
table.insert(taskswp, self.taskenroute[1])
|
||||||
|
end
|
||||||
|
|
||||||
-- At each waypoint report passing.
|
-- At each waypoint report passing.
|
||||||
local TaskPassingWaypoint=self.group:TaskFunction("FLIGHTGROUP._PassingWaypoint", self, i)
|
local TaskPassingWaypoint=self.group:TaskFunction("FLIGHTGROUP._PassingWaypoint", self, i)
|
||||||
table.insert(taskswp, TaskPassingWaypoint)
|
table.insert(taskswp, TaskPassingWaypoint)
|
||||||
|
|
||||||
|
|
||||||
|
-- For some reason THIS DOES NOT WORK if executed at the last waypoint if it is an AIR WAYPOINT.
|
||||||
|
-- I have moved it to the onafterpassingwaypoint function instead.
|
||||||
|
|
||||||
|
--[[
|
||||||
|
|
||||||
-- Get taks
|
-- Get taks
|
||||||
local tasks=self:GetTasksWaypoint(i)
|
local tasks=self:GetTasksWaypoint(i)
|
||||||
|
|
||||||
for _,task in pairs(tasks) do
|
for _,task in pairs(tasks) do
|
||||||
local Task=task --#FLIGHTGROUP.Task
|
local Task=task --#FLIGHTGROUP.Task
|
||||||
|
|
||||||
-- Add task execute.
|
-- Task execute.
|
||||||
table.insert(taskswp, self.group:TaskFunction("FLIGHTGROUP._TaskExecute", self, Task))
|
table.insert(taskswp, self.group:TaskFunction("FLIGHTGROUP._TaskExecute", self, Task))
|
||||||
|
|
||||||
|
-- Stop condition if userflag is set to 1.
|
||||||
|
local TaskCondition=self.group:TaskCondition(nil, Task.stopflag:GetName(), 1, nil, Task.duration)
|
||||||
|
|
||||||
|
-- Controlled task.
|
||||||
|
table.insert(taskswp, self.group:TaskControlled(Task.dcstask, TaskCondition))
|
||||||
|
|
||||||
|
--table.insert(taskswp, Task.dcstask)
|
||||||
|
|
||||||
|
-- Task done.
|
||||||
|
table.insert(taskswp, self.group:TaskFunction("FLIGHTGROUP._TaskDone", self, Task))
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
]]
|
||||||
|
|
||||||
-- Waypoint task combo.
|
-- Waypoint task combo.
|
||||||
wp.task=self.group:TaskCombo(taskswp)
|
wp.task=self.group:TaskCombo(taskswp)
|
||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
self:T3({wptask=taskswp})
|
env.info("FF task waypoint combo:")
|
||||||
|
self:I({wptask=taskswp})
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -75,12 +75,20 @@ TANKERGROUP = {
|
|||||||
-- @field #number Tstop Time the mission is stopped.
|
-- @field #number Tstop Time the mission is stopped.
|
||||||
-- @field #number Tsopped Time the mission was stopped.
|
-- @field #number Tsopped Time the mission was stopped.
|
||||||
|
|
||||||
|
--- Mission status.
|
||||||
|
-- @type TANKERGROUP.MissionStatus
|
||||||
|
-- @field #string SCHEDULED Task is scheduled.
|
||||||
|
-- @field #string EXECUTING Task is being executed.
|
||||||
|
-- @field #string ACCOMPLISHED Task is accomplished.
|
||||||
|
TANKERGROUP.MissionStatus={
|
||||||
|
SCHEDULED="scheduled",
|
||||||
|
EXECUTING="executing",
|
||||||
|
ACCOMPLISHED="accomplished",
|
||||||
|
}
|
||||||
--- TANKERGROUP class version.
|
--- TANKERGROUP class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
TANKERGROUP.version="0.0.1"
|
TANKERGROUP.version="0.0.1"
|
||||||
|
|
||||||
_TANKERGROUPS={}
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO list
|
-- TODO list
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -118,20 +126,17 @@ function TANKERGROUP:New(groupname)
|
|||||||
|
|
||||||
-- Add FSM transitions.
|
-- Add FSM transitions.
|
||||||
-- From State --> Event --> To State
|
-- From State --> Event --> To State
|
||||||
--self:AddTransition("*", "TankerState", "*") -- Tanker is on station and ready to refuel.
|
self:AddTransition("*", "TankerState", "*") -- Tanker is on station and ready to refuel.
|
||||||
self:AddTransition("*", "OnStation", "Ready2Refuel") -- Tanker is on station and ready to refuel.
|
self:AddTransition("*", "OnStation", "Ready2Refuel") -- Tanker is on station and ready to refuel.
|
||||||
self:AddTransition("*", "MissionStart", "*") -- Tanker is on station and ready to refuel.
|
self:AddTransition("*", "MissionStart", "*") -- Tanker is on station and ready to refuel.
|
||||||
|
|
||||||
|
|
||||||
-- Scheduler to update the status.
|
-- Scheduler to update the status.
|
||||||
self.Statusupdater=SCHEDULER:New(self, TANKERGROUP.TankerState, {self}, 1, 5)
|
--self.Statusupdater=SCHEDULER:New(self, TANKERGROUP.TankerState, {self}, 1, 5)
|
||||||
|
|
||||||
-- Call status update.
|
-- Call status update.
|
||||||
-- TODO: WARNING, if the call is delayed, it is NOT executed!
|
-- TODO: WARNING, if the call is delayed, it is NOT executed!
|
||||||
--self:__TankerState(5)
|
self:__TankerState(-5)
|
||||||
|
|
||||||
--_TANKERGROUPS[groupname]=self
|
|
||||||
--table.insert(_TANKERGROUPS, self)
|
|
||||||
|
|
||||||
self:Start()
|
self:Start()
|
||||||
|
|
||||||
@@ -189,6 +194,9 @@ function TANKERGROUP:AddMission(Zone, Altitude, Distance, Heading, SpeedOrbit, C
|
|||||||
mission.Tadded=Tnow
|
mission.Tadded=Tnow
|
||||||
mission.Tstart=Tstart
|
mission.Tstart=Tstart
|
||||||
mission.Tstop=Tstop
|
mission.Tstop=Tstop
|
||||||
|
if Tstop then
|
||||||
|
mission.duration=mission.Tstop-mission.Tstart
|
||||||
|
end
|
||||||
mission.tid=nil
|
mission.tid=nil
|
||||||
|
|
||||||
-- Add mission to queue.
|
-- Add mission to queue.
|
||||||
@@ -211,7 +219,7 @@ end
|
|||||||
-- @param #string From From state.
|
-- @param #string From From state.
|
||||||
-- @param #string Event Event.
|
-- @param #string Event Event.
|
||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
function TANKERGROUP:TankerState(From, Event, To)
|
function TANKERGROUP:onafterTankerState(From, Event, To)
|
||||||
|
|
||||||
-- First call flight status.
|
-- First call flight status.
|
||||||
--self:GetParent(self).onafterFlightStatus(self, From, Event, To)
|
--self:GetParent(self).onafterFlightStatus(self, From, Event, To)
|
||||||
@@ -240,7 +248,7 @@ function TANKERGROUP:TankerState(From, Event, To)
|
|||||||
self:I(self.lid..text)
|
self:I(self.lid..text)
|
||||||
|
|
||||||
-- Nest status update in 30 sec.
|
-- Nest status update in 30 sec.
|
||||||
--self:__TankerState(0.5)
|
self:__TankerState(-30)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- On after "MissionStart" event.
|
--- On after "MissionStart" event.
|
||||||
@@ -275,6 +283,9 @@ function TANKERGROUP:onafterMissionStart(From, Event, To, Mission)
|
|||||||
|
|
||||||
-- Set current mission.
|
-- Set current mission.
|
||||||
self.currentmission=Mission
|
self.currentmission=Mission
|
||||||
|
|
||||||
|
-- Set Tstarted time stamp.
|
||||||
|
self.currentmission.Tstarted=timer.getAbsTime()
|
||||||
|
|
||||||
-- Route flight to mission zone.
|
-- Route flight to mission zone.
|
||||||
self:RouteToMission(Mission, delay)
|
self:RouteToMission(Mission, delay)
|
||||||
|
|||||||
Reference in New Issue
Block a user