This commit is contained in:
Frank
2020-03-26 23:59:30 +01:00
parent 0e78a11fd6
commit a95f3f2fa1
7 changed files with 87 additions and 47 deletions
@@ -3846,7 +3846,9 @@ function WAREHOUSE:onafterAddAsset(From, Event, To, group, ngroups, forceattribu
if group:IsAlive()==true then
self:_DebugMessage(string.format("Removing group %s.", group:GetName()), 5)
-- Setting parameter to false, i.e. creating NO dead or remove unit event, seems to not confuse the dispatcher logic.
group:Destroy(false)
-- Create a RemoveUnit event to let the FLIGHTCONTROL now, the parking is now free.
-- TODO: Need to check if my above comment not to confuse the dispatcher logic is broken by this!
group:Destroy()
end
else
+11 -2
View File
@@ -281,7 +281,7 @@ function AUFTRAG:New(Type)
-- Defaults
self:SetName()
self:SetPriority()
self:SetMissionTime()
self:SetTime()
self.engageAsGroup=true
self.missionRepeated=0
@@ -778,7 +778,7 @@ end
-- @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. Default is 5 seconds after mission was added.
-- @param #string ClockStop (Optional) 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.
-- @return #AUFTRAG self
function AUFTRAG:SetMissionTime(ClockStart, ClockStop)
function AUFTRAG:SetTime(ClockStart, ClockStop)
-- Current mission time.
local Tnow=timer.getAbsTime()
@@ -829,6 +829,15 @@ function AUFTRAG:SetRepeatOnFailure(Nrepeat)
return self
end
--- Define how many assets are required to do the job.
-- @param #AUFTRAG self
-- @param #number Nassets Number of asset groups. Default 1.
-- @return #AUFTRAG self
function AUFTRAG:SetRequiredAssets(Nassets)
self.nassets=Nassets or 1
return self
end
--- Set mission name.
-- @param #AUFTRAG self
-- @param #string Name Name of the mission.
+13 -13
View File
@@ -126,7 +126,7 @@ FLIGHTCONTROL.version="0.2.5"
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TODO: Accept and forbit parking spots.
-- TODO: Add FARPS?
-- NOGO: Add FARPS?
-- TODO: Add helos.
-- TODO: Talk me down option.
-- TODO: ATIS option.
@@ -546,8 +546,7 @@ function FLIGHTCONTROL:_CheckQueues()
-- Give AI the landing signal.
-- TODO: Humans have to confirm via F10 menu.
if flight.ai then
flight:FlightLanding()
if flight.ai then
self:_LandAI(flight, parking)
end
@@ -689,7 +688,7 @@ function FLIGHTCONTROL:_GetNextFightHolding()
local function _sortByTholding(a, b)
local flightA=a --Ops.FlightGroup#FLIGHTGROUP
local flightB=b --Ops.FlightGroup#FLIGHTGROUP
return flightA.Tholding>flightB.Tholding
return flightA.Tholding<flightB.Tholding -- Tholding is the abs. timestamp. So the one with the smallest time is holding the longest.
end
@@ -739,11 +738,17 @@ function FLIGHTCONTROL:_GetNextFightParking()
local function _sortByTparking(a, b)
local flightA=a --Ops.FlightGroup#FLIGHTGROUP
local flightB=b --Ops.FlightGroup#FLIGHTGROUP
return flightA.Tparking>flightB.Tparking
return flightA.Tparking<flightB.Tparking -- Tholding is the abs. timestamp. So the one with the smallest time is holding the longest.
end
-- Return flight waiting longest.
table.sort(self.Qparking, _sortByTparking)
table.sort(self.Qparking, _sortByTparking)
for i,_flight in pairs(self.Qparking) do
local flight=_flight --Ops.FlightGroup#FLIGHTGROUP
env.info(string.format("%d %s %.1f", i, flight.groupname, flight.Tparking))
end
return self.Qparking[1]
end
@@ -1914,7 +1919,7 @@ function FLIGHTCONTROL:_LandAI(flight, parking)
end
local respawn=true
local respawn=false
if respawn then
@@ -1949,18 +1954,13 @@ function FLIGHTCONTROL:_LandAI(flight, parking)
--Respawn the group.
flight:Respawn(Template)
--flight.group=flight.group:Respawn(Template, true)
else
-- Give signal to land.
flight:ClearToLand()
end
-- Route the group.
--flight.group:Route(wp, 1)
end
+26 -11
View File
@@ -1338,7 +1338,7 @@ end
function FLIGHTGROUP:onafterStop(From, Event, To)
-- Check if group is still alive.
if self:IsAlive() then
if self:IsAlive() and false then
-- Set element parking spot to FREE (after arrived for example).
if self.flightcontrol then
@@ -1923,8 +1923,8 @@ function FLIGHTGROUP:OnEventRemoveUnit(EventData)
local element=self:GetElementByName(unitname)
if element then
self:T3(self.lid..string.format("EVENT: Element %s removed ==> dead", element.name))
--self:ElementDead(element)
self:I(self.lid..string.format("EVENT: Element %s removed ==> dead", element.name))
self:ElementDead(element)
end
end
@@ -2113,6 +2113,10 @@ end
-- @param #FLIGHTGROUP.Element Element The flight group element.
function FLIGHTGROUP:onafterElementDead(From, Event, To, Element)
self:T(self.lid..string.format("Element dead %s.", Element.name))
if self.flightcontrol and Element.parking then
self.flightcontrol:SetParkingFree(Element.parking)
end
-- Not parking any more.
Element.parking=nil
@@ -2313,7 +2317,7 @@ function FLIGHTGROUP:onafterFlightDead(From, Event, To)
self.groupinitialized=false
-- Remove flight from all FC queues.
if self.flightcontrol then
if self.flightcontrol then
self.flightcontrol:_RemoveFlight(self)
self.flightcontrol=nil
end
@@ -2738,21 +2742,22 @@ function FLIGHTGROUP:onafterRTB(From, Event, To, airbase, SpeedTo, SpeedHold, Sp
-- Clear all tasks.
self:ClearTasks()
-- Set holding flag to 333.
self.flaghold:Set(333)
-- Set holding flag to 0=false.
self.flaghold:Set(0)
-- Task fuction when reached holding point.
local TaskArrived=self.group:TaskFunction("FLIGHTGROUP._ReachedHolding", self)
-- Orbit until flaghold=1 (true) but max 10 min.
-- Orbit until flaghold=1 (true) but max 10 min if no FC is giving the landing clearance.
local TaskOrbit=self.group:TaskOrbit(p0, nil, UTILS.KnotsToMps(SpeedHold), p1)
local TaskLand=self.group:TaskCondition(nil, self.flaghold.UserFlagName, 1, nil, 10*60)
local TaskLand=self.group:TaskCondition(nil, self.flaghold.UserFlagName, 1, nil, fc and nil or 10*60)
local TaskHold=self.group:TaskControlled(TaskOrbit, TaskLand)
local TaskKlar=self.group:TaskFunction("FLIGHTGROUP._ClearedToLand", self) -- Once the holding flag becomes true, set trigger FLIGHTLANDING, i.e. set flight STATUS to LANDING.
-- Waypoints from current position to holding point.
local wp={}
wp[#wp+1]=c0:WaypointAir(nil, COORDINATE.WaypointType.TurningPoint, COORDINATE.WaypointAction.TurningPoint, UTILS.KnotsToKmph(SpeedTo), true , nil, {}, "Current Pos")
wp[#wp+1]=p0:WaypointAir(nil, COORDINATE.WaypointType.TurningPoint, COORDINATE.WaypointAction.TurningPoint, UTILS.KnotsToKmph(SpeedTo), true , nil, {TaskArrived, TaskHold}, "Holding Point")
wp[#wp+1]=p0:WaypointAir(nil, COORDINATE.WaypointType.TurningPoint, COORDINATE.WaypointAction.TurningPoint, UTILS.KnotsToKmph(SpeedTo), true , nil, {TaskArrived, TaskHold, TaskKlar}, "Holding Point")
-- Approach point: 10 NN in direction of runway.
local papp=airbase:GetCoordinate():Translate(x1, runway.heading-180):SetAltitude(h1)
@@ -2921,8 +2926,8 @@ end
-- @param #string To To state.
function FLIGHTGROUP:onafterHolding(From, Event, To)
-- Set holding flag to 666.
self.flaghold:Set(666)
-- Set holding flag to 0 (just in case).
self.flaghold:Set(0)
local text=string.format("Flight group %s is HOLDING now", self.groupname)
MESSAGE:New(text, 10, "DEBUG"):ToAllIf(self.Debug)
@@ -3741,6 +3746,16 @@ function FLIGHTGROUP._ReachedHolding(group, flightgroup)
flightgroup:__Holding(-1)
end
--- Function called when flight has reached the holding point.
-- @param Wrapper.Group#GROUP group Group object.
-- @param #FLIGHTGROUP flightgroup Flight group object.
function FLIGHTGROUP._ClearedToLand(group, flightgroup)
flightgroup:I(flightgroup.lid..string.format("Group was cleared to land"))
-- Trigger FlightLanding event.
flightgroup:__FlightLanding(-1)
end
--- Function called when flight finished refuelling.
-- @param Wrapper.Group#GROUP group Group object.
-- @param #FLIGHTGROUP flightgroup Flight group object.
+12 -14
View File
@@ -73,6 +73,7 @@ INTEL.version="0.0.3"
-- DONE: Accept zones.
-- TODO: Reject zones.
-- TODO: Filter detection methods.
-- NOGO: SetAttributeZone --> return groups of generalized attributes in a zone.
-- DONE: Loose units only if they remain undetected for a given time interval. We want to avoid fast oscillation between detected/lost states. Maybe 1-5 min would be a good time interval?!
-- DONE: Combine units to groups for all, new and lost.
@@ -93,24 +94,21 @@ function INTEL:New(DetectionSet, Coalition)
local self=BASE:Inherit(self, FSM:New()) -- #INTEL
-- Detection set.
self.detectionset=DetectionSet
local alias="SPECTRE"
--[[
self.detectionset=DetectionSet or SET_GROUP:New()
-- Determine coalition from first group in set.
self.coalition=DetectionSet:GetFirst():GetCoalition()
self.coalition=Coalition or DetectionSet:CountAlive()>0 and DetectionSet:GetFirst():GetCoalition() or nil
local alias="SPECTRE"
if self.coalition==coalition.side.RED then
alias="KGB"
elseif self.coalition==coalition.side.BLUE then
alias="CIA"
-- Set alias.
local alias="SPECTRE"
if self.coalition then
if self.coalition==coalition.side.RED then
alias="KGB"
elseif self.coalition==coalition.side.BLUE then
alias="CIA"
end
end
]]
-- Set some string id for output to DCS.log file.
self.lid=string.format("INTEL %s | ", alias)
@@ -122,7 +120,7 @@ function INTEL:New(DetectionSet, Coalition)
self:AddTransition("Stopped", "Start", "Running") -- Start FSM.
self:AddTransition("*", "Status", "*") -- INTEL status update
self:AddTransition("*", "Detect", "*") -- INTEL status update
self:AddTransition("*", "Detect", "*") -- Start detection run. Not implemented yet!
self:AddTransition("*", "NewContact", "*") -- New contact has been detected.
self:AddTransition("*", "LostContact", "*") -- Contact could not be detected any more.
+16 -3
View File
@@ -255,6 +255,15 @@ function SQUADRON:SetCallsign(Callsign, Index)
return self
end
--- Set modex.
-- @param #SQUADRON self
-- @param #string Modex
-- @return #SQUADRON self
function SQUADRON:SetModex(Modex)
self.modex=Modex
return self
end
--- Set airwing.
-- @param #SQUADRON self
-- @param Ops.AirWing#AIRWING Airwing The airwing.
@@ -303,7 +312,7 @@ function SQUADRON:GetCallsign(Asset)
local callsign={}
callsign[1]=self.callsignName
callsign[2]=self.callsigncounter / 10
callsign[2]=math.floor(self.callsigncounter / 10)
callsign[3]=self.callsigncounter % 10
if callsign[3]==0 then
callsign[3]=1
@@ -313,6 +322,8 @@ function SQUADRON:GetCallsign(Asset)
end
Asset.callsign[i]=callsign
self:I({callsign=callsign})
--TODO: there is also a table entry .name, which is a string.
end
@@ -328,15 +339,17 @@ end
-- @return #SQUADRON self
function SQUADRON:GetModex(Asset)
if self.callsignName then
if self.modex then
Asset.modex={}
for i=1,Asset.nunits do
Asset.modex[i]=tostring(self.modex+self.modexcounter)
Asset.modex[i]=string.format("%03d", self.modex+self.modexcounter)
self.modexcounter=self.modexcounter+1
self:I({modex=Asset.modex[i]})
end
@@ -64,15 +64,18 @@ WINGCOMMANDER.version="0.0.3"
--- Create a new WINGCOMMANDER object and start the FSM.
-- @param #WINGCOMMANDER self
-- @param Core.Set#SET_UNITS AgentSet Set of agents (units) providing intel.
-- @param Core.Set#SET_GROUP AgentSet Set of agents (groups) providing intel. Default is an empty set.
-- @param #number Coalition Coalition side, e.g. `coaliton.side.BLUE`. Can also be passed as a string "red", "blue" or "neutral".
-- @return #WINGCOMMANDER self
function WINGCOMMANDER:New(AgentSet)
function WINGCOMMANDER:New(AgentSet, Coalition)
AgentSet=AgentSet or SET_GROUP:New()
-- Inherit everything from INTEL class.
local self=BASE:Inherit(self, INTEL:New(AgentSet)) --#WINGCOMMANDER
-- Set some string id for output to DCS.log file.
self.lid=string.format("WINGCOMMANDER | ")
--self.lid=string.format("WINGCOMMANDER | ")
-- Add FSM transitions.
-- From State --> Event --> To State