mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-21 21:17:30 +00:00
FG/TG
This commit is contained in:
@@ -62,8 +62,14 @@
|
|||||||
-- @field Core.Set#SET_ZONE inzones Set of zones in which the group is currently in.
|
-- @field Core.Set#SET_ZONE inzones Set of zones in which the group is currently in.
|
||||||
-- @field #boolean groupinitialized If true, group parameters were initialized.
|
-- @field #boolean groupinitialized If true, group parameters were initialized.
|
||||||
-- @field Core.Radio#BEACON beacon The beacon object.
|
-- @field Core.Radio#BEACON beacon The beacon object.
|
||||||
-- @field #number tacanchannel TACAN channel.
|
-- @field #number TACANchannel TACAN channel.
|
||||||
-- @field #string tacanmorse TACAN morse code.
|
-- @field #string TACANmode TACAN mode, i.e. "Y" (or "X").
|
||||||
|
-- @field #string TACANmorse TACAN morse code.
|
||||||
|
-- @field #number RadioFreq Radio frequency in MHz.
|
||||||
|
-- @field #number RadioModu Radio modulation `radio.modulation.AM` or `radio.modulation.FM`.
|
||||||
|
-- @field #number CallsignName Call sign name.
|
||||||
|
-- @field #number CallsignNumber Call sign number.
|
||||||
|
-- @field #boolean EPLRS If true, turn EPLRS data link on.
|
||||||
-- @extends Core.Fsm#FSM
|
-- @extends Core.Fsm#FSM
|
||||||
|
|
||||||
--- *To invent an airplane is nothing. To build one is something. To fly is everything.* -- Otto Lilienthal
|
--- *To invent an airplane is nothing. To build one is something. To fly is everything.* -- Otto Lilienthal
|
||||||
@@ -317,7 +323,7 @@ FLIGHTGROUP.TaskType={
|
|||||||
|
|
||||||
--- FLIGHTGROUP class version.
|
--- FLIGHTGROUP class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
FLIGHTGROUP.version="0.2.5"
|
FLIGHTGROUP.version="0.2.6"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO list
|
-- TODO list
|
||||||
@@ -524,7 +530,7 @@ end
|
|||||||
-- @param #string description Brief text describing the task, e.g. "Attack SAM".
|
-- @param #string description Brief text describing the task, e.g. "Attack SAM".
|
||||||
-- @param #number prio Priority of the task.
|
-- @param #number prio Priority of the task.
|
||||||
-- @param #number duration Duration before task is cancelled in seconds counted after task started. Default never.
|
-- @param #number duration Duration before task is cancelled in seconds counted after task started. Default never.
|
||||||
-- @return #number Task ID.
|
-- @return #FLIGHTGROUP.Task The task structure.
|
||||||
function FLIGHTGROUP:AddTask(task, clock, description, prio, duration)
|
function FLIGHTGROUP:AddTask(task, clock, description, prio, duration)
|
||||||
|
|
||||||
-- Increase counter.
|
-- Increase counter.
|
||||||
@@ -564,7 +570,7 @@ function FLIGHTGROUP:AddTask(task, clock, description, prio, duration)
|
|||||||
-- Add to table.
|
-- Add to table.
|
||||||
table.insert(self.taskqueue, newtask)
|
table.insert(self.taskqueue, newtask)
|
||||||
|
|
||||||
return self.taskcounter
|
return newtask
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Add a *waypoint* task.
|
--- Add a *waypoint* task.
|
||||||
@@ -574,7 +580,7 @@ end
|
|||||||
-- @param #string description Brief text describing the task, e.g. "Attack SAM".
|
-- @param #string description Brief text describing the task, e.g. "Attack SAM".
|
||||||
-- @param #number prio Priority of the task. Number between 1 and 100. Default is 50.
|
-- @param #number prio Priority of the task. Number between 1 and 100. Default is 50.
|
||||||
-- @param #number duration Duration before task is cancelled in seconds counted after task started. Default never.
|
-- @param #number duration Duration before task is cancelled in seconds counted after task started. Default never.
|
||||||
-- @return #number Task ID.
|
-- @return #FLIGHTGROUP.Task The task structure.
|
||||||
function FLIGHTGROUP:AddTaskWaypoint(task, waypointindex, description, prio, duration)
|
function FLIGHTGROUP:AddTaskWaypoint(task, waypointindex, description, prio, duration)
|
||||||
|
|
||||||
-- Increase counter.
|
-- Increase counter.
|
||||||
@@ -605,7 +611,7 @@ function FLIGHTGROUP:AddTaskWaypoint(task, waypointindex, description, prio, dur
|
|||||||
-- Update route.
|
-- Update route.
|
||||||
self:__UpdateRoute(-1)
|
self:__UpdateRoute(-1)
|
||||||
|
|
||||||
return self.taskcounter
|
return newtask
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Add an *enroute* task.
|
--- Add an *enroute* task.
|
||||||
@@ -2275,9 +2281,9 @@ function FLIGHTGROUP:onafterPassingWaypoint(From, Event, To, n, N)
|
|||||||
local TaskCondition=self.group:TaskCondition(nil, Task.stopflag:GetName(), 1, nil, Task.duration)
|
local TaskCondition=self.group:TaskCondition(nil, Task.stopflag:GetName(), 1, nil, Task.duration)
|
||||||
|
|
||||||
-- Controlled task.
|
-- Controlled task.
|
||||||
--table.insert(taskswp, self.group:TaskControlled(Task.dcstask, TaskCondition))
|
table.insert(taskswp, self.group:TaskControlled(Task.dcstask, TaskCondition))
|
||||||
|
|
||||||
table.insert(taskswp, Task.dcstask)
|
--table.insert(taskswp, Task.dcstask)
|
||||||
|
|
||||||
-- Task done.
|
-- Task done.
|
||||||
table.insert(taskswp, self.group:TaskFunction("FLIGHTGROUP._TaskDone", self, Task))
|
table.insert(taskswp, self.group:TaskFunction("FLIGHTGROUP._TaskDone", self, Task))
|
||||||
@@ -2734,9 +2740,8 @@ function FLIGHTGROUP:onafterTaskDone(From, Event, To, Task)
|
|||||||
-- Task status done.
|
-- Task status done.
|
||||||
Task.status=FLIGHTGROUP.TaskStatus.ACCOMPLISHED
|
Task.status=FLIGHTGROUP.TaskStatus.ACCOMPLISHED
|
||||||
|
|
||||||
-- Update route.
|
-- Update route. This is necessary because of the route task beeing overwritten. But we want to fly to the remaining waypoints.
|
||||||
-- TODO: Is this really necessary?
|
self:__UpdateRoute(-1)
|
||||||
--self:__UpdateRoute(-1)
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -3559,6 +3564,7 @@ end
|
|||||||
function FLIGHTGROUP:AddWaypointAir(coordinate, wpnumber, speed)
|
function FLIGHTGROUP:AddWaypointAir(coordinate, wpnumber, speed)
|
||||||
|
|
||||||
-- Waypoint number.
|
-- Waypoint number.
|
||||||
|
--TODO: by default add after last AIR waypoint! Last WP could be landing...
|
||||||
wpnumber=wpnumber or #self.waypoints+1
|
wpnumber=wpnumber or #self.waypoints+1
|
||||||
|
|
||||||
-- Speed in knots.
|
-- Speed in knots.
|
||||||
|
|||||||
@@ -62,7 +62,8 @@ TANKERGROUP = {
|
|||||||
-- @type TANKERGROUP.Mission
|
-- @type TANKERGROUP.Mission
|
||||||
-- @field #string name Name of the mission.
|
-- @field #string name Name of the mission.
|
||||||
-- @field #number mid ID of the mission.
|
-- @field #number mid ID of the mission.
|
||||||
-- @field #number tid ID of the assigned FLIGHTGROUP task.
|
-- @field #string status Mission status.
|
||||||
|
-- @field Ops.FlightGroup#FLIGHTGROUP.Task task Task of mission.
|
||||||
-- @field Core.Zone#ZONE zone Mission zone.
|
-- @field Core.Zone#ZONE zone Mission zone.
|
||||||
-- @field #number duration Duration of mission.
|
-- @field #number duration Duration of mission.
|
||||||
-- @field #number altitude Altitude of orbit in meters ASL.
|
-- @field #number altitude Altitude of orbit in meters ASL.
|
||||||
@@ -74,6 +75,7 @@ TANKERGROUP = {
|
|||||||
-- @field #number Tstarted Time the mission was started.
|
-- @field #number Tstarted Time the mission was started.
|
||||||
-- @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.
|
||||||
|
-- @field #number prio Priority of the mission.
|
||||||
|
|
||||||
--- Mission status.
|
--- Mission status.
|
||||||
-- @type TANKERGROUP.MissionStatus
|
-- @type TANKERGROUP.MissionStatus
|
||||||
@@ -87,7 +89,7 @@ TANKERGROUP.MissionStatus={
|
|||||||
}
|
}
|
||||||
--- TANKERGROUP class version.
|
--- TANKERGROUP class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
TANKERGROUP.version="0.0.1"
|
TANKERGROUP.version="0.0.2"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO list
|
-- TODO list
|
||||||
@@ -131,6 +133,7 @@ function TANKERGROUP:New(groupname)
|
|||||||
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.
|
||||||
|
self:AddTransition("*", "MissionAccomplished", "*") -- Tanker is on station and ready to refuel.
|
||||||
|
|
||||||
|
|
||||||
-- Call status update.
|
-- Call status update.
|
||||||
@@ -155,9 +158,10 @@ end
|
|||||||
-- @param #number SpeedOrbit Orbit speed in knots. Default is 280 knots.
|
-- @param #number SpeedOrbit Orbit speed in knots. Default is 280 knots.
|
||||||
-- @param #string ClockStart Time the mission is started, e.g. "05:00" for 5 am. If specified as a #number, it will be relative (in seconds) to the current mission time.
|
-- @param #string ClockStart Time the mission is started, e.g. "05:00" for 5 am. If specified as a #number, it will be relative (in seconds) to the current mission time.
|
||||||
-- @param #string ClockStop Time the mission is stopped, e.g. "13:00" for 1 pm. If mission could not be started at that time, it will be removed from the queue. If specified as a #number it will be relative (in seconds) to the current mission time.
|
-- @param #string ClockStop Time the mission is stopped, e.g. "13:00" for 1 pm. If mission could not be started at that time, it will be removed from the queue. If specified as a #number it will be relative (in seconds) to the current mission time.
|
||||||
|
-- @param #number Prio Priority of the mission, i.e. a number between 1 and 100. Default 50.
|
||||||
-- @param #string Name Mission name. Default "Aerial Refueling #00X", where "#00X" is a running mission counter index starting at "#001".
|
-- @param #string Name Mission name. Default "Aerial Refueling #00X", where "#00X" is a running mission counter index starting at "#001".
|
||||||
-- @return #TANKERGROUP.Mission The mission table.
|
-- @return #TANKERGROUP.Mission The mission table.
|
||||||
function TANKERGROUP:AddMission(Zone, Altitude, Distance, Heading, SpeedOrbit, ClockStart, ClockStop, Name)
|
function TANKERGROUP:AddMission(Zone, Altitude, Distance, Heading, SpeedOrbit, ClockStart, ClockStop, Prio, Name)
|
||||||
|
|
||||||
-- Increase mission counter.
|
-- Increase mission counter.
|
||||||
self.missioncounter=self.missioncounter+1
|
self.missioncounter=self.missioncounter+1
|
||||||
@@ -193,10 +197,12 @@ 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
|
||||||
|
mission.status=TANKERGROUP.MissionStatus.SCHEDULED
|
||||||
if Tstop then
|
if Tstop then
|
||||||
mission.duration=mission.Tstop-mission.Tstart
|
mission.duration=mission.Tstop-mission.Tstart
|
||||||
end
|
end
|
||||||
mission.tid=nil
|
mission.prio=Prio or 50
|
||||||
|
mission.task=nil
|
||||||
|
|
||||||
-- Add mission to queue.
|
-- Add mission to queue.
|
||||||
table.insert(self.Qmissions, mission)
|
table.insert(self.Qmissions, mission)
|
||||||
@@ -220,9 +226,6 @@ end
|
|||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
function TANKERGROUP:onafterTankerState(From, Event, To)
|
function TANKERGROUP:onafterTankerState(From, Event, To)
|
||||||
|
|
||||||
-- First call flight status.
|
|
||||||
--self:GetParent(self).onafterFlightStatus(self, From, Event, To)
|
|
||||||
|
|
||||||
-- FSM state.
|
-- FSM state.
|
||||||
local fsmstate=self:GetState()
|
local fsmstate=self:GetState()
|
||||||
|
|
||||||
@@ -244,6 +247,10 @@ function TANKERGROUP:onafterTankerState(From, Event, To)
|
|||||||
|
|
||||||
-- Current status.
|
-- Current status.
|
||||||
local text=string.format("Tanker Status %s: Mission=%s (%d)", fsmstate, mymission, #self.Qmissions)
|
local text=string.format("Tanker Status %s: Mission=%s (%d)", fsmstate, mymission, #self.Qmissions)
|
||||||
|
for i,_mission in pairs(self.Qmissions) do
|
||||||
|
local mission=_mission --#TANKERGROUP.Mission
|
||||||
|
text=text..string.format("\n[%d] %s status=%s", i, tostring(mission.name), tostring(mission.status))
|
||||||
|
end
|
||||||
self:I(self.lid..text)
|
self:I(self.lid..text)
|
||||||
|
|
||||||
-- Nest status update in 30 sec.
|
-- Nest status update in 30 sec.
|
||||||
@@ -285,12 +292,50 @@ function TANKERGROUP:onafterMissionStart(From, Event, To, Mission)
|
|||||||
|
|
||||||
-- Set Tstarted time stamp.
|
-- Set Tstarted time stamp.
|
||||||
self.currentmission.Tstarted=timer.getAbsTime()
|
self.currentmission.Tstarted=timer.getAbsTime()
|
||||||
|
|
||||||
|
-- Set mission status.
|
||||||
|
self.currentmission.status=TANKERGROUP.MissionStatus.EXECUTING
|
||||||
|
|
||||||
-- Route flight to mission zone.
|
-- Route flight to mission zone.
|
||||||
self:RouteToMission(Mission, delay)
|
self:RouteToMission(Mission, delay)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- On after "TaskDone" event.
|
||||||
|
-- @param #TANKERGROUP self
|
||||||
|
-- @param #string From From state.
|
||||||
|
-- @param #string Event Event.
|
||||||
|
-- @param #string To To state.
|
||||||
|
-- @param Ops.FlightGroup#FLIGHTGROUP.Task Task.
|
||||||
|
function TANKERGROUP:onafterTaskDone(From, Event, To, Task)
|
||||||
|
|
||||||
|
-- First call flight status.
|
||||||
|
self:GetParent(self).onafterTaskDone(self, From, Event, To, Task)
|
||||||
|
|
||||||
|
if self.currentmission then
|
||||||
|
|
||||||
|
local missiontask=self.currentmission.task
|
||||||
|
|
||||||
|
if missiontask.id==Task.id then
|
||||||
|
self:MissionAccomplished(self.currentmission)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- On after "MissionAccomplished" event.
|
||||||
|
-- @param #TANKERGROUP self
|
||||||
|
-- @param #string From From state.
|
||||||
|
-- @param #string Event Event.
|
||||||
|
-- @param #string To To state.
|
||||||
|
-- @param #TANKERGROUP.Mission Mission
|
||||||
|
function TANKERGROUP:onafterMissionAccomplished(From, Event, To, Mission)
|
||||||
|
|
||||||
|
Mission.status=TANKERGROUP.MissionStatus.ACCOMPLISHED
|
||||||
|
self.currentmission=nil
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- MISC functions
|
-- MISC functions
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -300,22 +345,40 @@ end
|
|||||||
-- @return #TANKERGROUP.Mission Next mission or *nil*.
|
-- @return #TANKERGROUP.Mission Next mission or *nil*.
|
||||||
function TANKERGROUP:_GetNextMission()
|
function TANKERGROUP:_GetNextMission()
|
||||||
|
|
||||||
if #self.Qmissions==0 then
|
-- Number of missions.
|
||||||
|
local Nmissions=#self.Qmissions
|
||||||
|
|
||||||
|
-- Treat special cases.
|
||||||
|
if Nmissions==0 then
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
--TODO: Sort wrt start time and priority.
|
-- Sort results table wrt times they have already been engaged.
|
||||||
|
local function _sort(a, b)
|
||||||
|
local taskA=a --#TANKERGROUP.Mission
|
||||||
|
local taskB=b --#TANKERGROUP.Mission
|
||||||
|
return (taskA.Tstart<taskB.Tstart) or (taskA.Tstart==taskB.Tstart and taskA.prio<taskB.prio)
|
||||||
|
end
|
||||||
|
table.sort(self.Qmissions, _sort)
|
||||||
|
|
||||||
|
-- Current time.
|
||||||
|
local time=timer.getAbsTime()
|
||||||
|
|
||||||
local mission=self.Qmissions[1]
|
-- Look for first task that is not accomplished.
|
||||||
|
for _,_mission in pairs(self.Qmissions) do
|
||||||
|
local mission=_mission --#TANKERGROUP.Mission
|
||||||
|
if mission.status==TANKERGROUP.MissionStatus.SCHEDULED and time>=mission.Tstart then
|
||||||
|
return mission
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return mission
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Route group to mission. Also sets the
|
--- Route group to mission. Also sets the
|
||||||
-- @param #TANKERGROUP self
|
-- @param #TANKERGROUP self
|
||||||
-- @param #TANKERGROUP.Mission mission The mission table.
|
-- @param #TANKERGROUP.Mission mission The mission table.
|
||||||
-- @param #number delay Delay in seconds.
|
-- @param #number delay Delay in seconds.
|
||||||
-- @return #TANKERGROUP.Mission Next mission or *nil*.
|
|
||||||
function TANKERGROUP:RouteToMission(mission, delay)
|
function TANKERGROUP:RouteToMission(mission, delay)
|
||||||
|
|
||||||
if delay and delay>0 then
|
if delay and delay>0 then
|
||||||
@@ -339,7 +402,8 @@ function TANKERGROUP:RouteToMission(mission, delay)
|
|||||||
local taskorbit=self.group:TaskOrbit(Coordinate, mission.altitude, mission.speed, CoordRaceTrack)
|
local taskorbit=self.group:TaskOrbit(Coordinate, mission.altitude, mission.speed, CoordRaceTrack)
|
||||||
|
|
||||||
-- Add waypoint task.
|
-- Add waypoint task.
|
||||||
self:AddTaskWaypoint(taskorbit, #self.waypoints, mission.name, 10, mission.duration)
|
-- TODO: find last AIR waypoint! We dont want this at landing waypoints.
|
||||||
|
mission.task=self:AddTaskWaypoint(taskorbit, #self.waypoints, mission.name, 10, mission.duration)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user