- Added new TIMER class.
This commit is contained in:
Frank 2020-08-29 20:26:20 +02:00
parent caef309547
commit 2d6092c114
13 changed files with 397 additions and 66 deletions

View File

@ -619,6 +619,7 @@ do -- FSM
if self[handler] then if self[handler] then
--[[
if step == "onafter" or step == "OnAfter" then if step == "onafter" or step == "OnAfter" then
self:T( ":::>" .. step .. params[2] .. " : " .. params[1] .. " >> " .. params[2] .. ">" .. step .. params[2] .. "()" .. " >> " .. params[3] ) self:T( ":::>" .. step .. params[2] .. " : " .. params[1] .. " >> " .. params[2] .. ">" .. step .. params[2] .. "()" .. " >> " .. params[3] )
elseif step == "onbefore" or step == "OnBefore" then elseif step == "onbefore" or step == "OnBefore" then
@ -630,6 +631,7 @@ do -- FSM
else else
self:T( ":::>" .. step .. " : " .. params[1] .. " >> " .. params[2] .. " >> " .. params[3] ) self:T( ":::>" .. step .. " : " .. params[1] .. " >> " .. params[2] .. " >> " .. params[3] )
end end
]]
self._EventSchedules[EventName] = nil self._EventSchedules[EventName] = nil
@ -930,9 +932,10 @@ do -- FSM
-- @return #boolean If true, FSM can do the event. -- @return #boolean If true, FSM can do the event.
-- @return #string To state. -- @return #string To state.
function FSM:can(e) function FSM:can(e)
local Event = self.Events[e] local Event = self.Events[e]
self:F3( { self.current, Event } ) --self:F3( { self.current, Event } )
local To = Event and Event.map[self.current] or Event.map['*'] local To = Event and Event.map[self.current] or Event.map['*']

View File

@ -560,6 +560,7 @@ do -- COORDINATE
self.z=z self.z=z
return self return self
else else
--env.info("FF translate with NEW coordinate T="..timer.getTime())
return COORDINATE:New(x, y, z) return COORDINATE:New(x, y, z)
end end
@ -1136,23 +1137,6 @@ do -- COORDINATE
return self return self
end end
--- Add a Distance in meters from the COORDINATE horizontal plane, with the given angle, and calculate the new COORDINATE.
-- @param #COORDINATE self
-- @param DCS#Distance Distance The Distance to be added in meters.
-- @param DCS#Angle Angle The Angle in degrees.
-- @return #COORDINATE The new calculated COORDINATE.
function COORDINATE:Translate( Distance, Angle )
local SX = self.x
local SZ = self.z
local Radians = Angle / 180 * math.pi
local TX = Distance * math.cos( Radians ) + SX
local TZ = Distance * math.sin( Radians ) + SZ
return COORDINATE:New( TX, self.y, TZ )
end
--- Build an air type route point. --- Build an air type route point.
-- @param #COORDINATE self -- @param #COORDINATE self
-- @param #COORDINATE.WaypointAltType AltType The altitude type. -- @param #COORDINATE.WaypointAltType AltType The altitude type.

View File

@ -0,0 +1,250 @@
--- **Core** - Timer scheduler.
--
-- **Main Features:**
--
-- * Delay function calls
-- * Easy set up and little overhead
-- * Set start, stop and time interval
-- * Define max function calls
--
-- ===
--
-- ### Author: **funkyfranky**
-- @module Core.Timer
-- @image CORE_Timer.png
--- TIMER class.
-- @type TIMER
-- @field #string ClassName Name of the class.
-- @field #string lid Class id string for output to DCS log file.
-- @field #number tid Timer ID returned by the DCS API function.
-- @field #function func Timer function.
-- @field #table para Parameters passed to the timer function.
-- @field #number Tstart Relative start time in seconds.
-- @field #number Tstop Relative stop time in seconds.
-- @field #number dT Time interval between function calls in seconds.
-- @field #number ncalls Counter of function calls.
-- @field #number ncallsMax Max number of function calls. If reached, timer is stopped.
-- @extends Core.Base#BASE
--- *Better three hours too soon than a minute too late.* William Shakespeare
--
-- ===
--
-- ![Banner Image](..\Presentations\Timer\TIMER_Main.jpg)
--
-- # The TIMER Concept
--
-- The TIMER class is the little sister of the SCHEDULER class. It does the same thing but is a bit easier to use and has less overhead. It should be sufficient in many cases.
--
-- # Construction
--
-- A new TIMER is created by the @{#TIMER.New}(*func*, *...*) function
--
-- local mytimer=TIMER:New(myfunction, a, b)
--
-- The first parameter *func* is the function that is called followed by the necessary comma separeted parameters that are passed to that function.
--
-- ## Starting the Timer
--
-- The timer is started by the @{#TIMER.Start}(*Tstart*, *dT*, *Duration*) function
--
-- mytimer:Start(5, 1, 20)
--
-- where
--
-- * *Tstart* is the relative start time in seconds. In the example, the first function call happens after 5 sec.
-- * *dT* is the time interval between function calls in seconds. Above, the function is called once per second.
-- * *Duration* is the duration in seconds after which the timer is stopped. This is relative to the start time. Here, the timer will run for 20 seconds.
--
-- Note that
--
-- * if *Tstart* is not specified (*nil*), the first function call happens immediately.
-- * if *dT* is not specified (*nil*), the function is called only once.
-- * if *Duration* is not specified (*nil*), the timer runs forever or until stopped manually or until the max function calls are reached (see below).
--
-- For example,
--
-- mytimer:Start(3) -- Will call the function once after 3 seconds.
-- mytimer:Start(nil, 0.5) -- Will call right now and then every 0.5 sec until all eternaty.
-- mytimer:Start(nil, 2.0, 20) -- Will call right now and then every 2.0 sec for 20 sec.
-- mytimer:Start(1.0, nil, 10) -- Does not make sense as the function is only called once anyway.
--
-- ## Stopping the Timer
--
-- The timer can be stopped manually by the @{#TIMER.Start}(*Delay*) function
--
-- mytimer:Stop()
--
-- If the optional paramter *Delay* is specified, the timer is stopped after *delay* seconds.
--
-- ## Limit Function Calls
--
-- The timer can be stopped after a certain amount of function calles with the @{#TIMER.SetMaxFunctionCalls}(*Nmax*) function
--
-- mytimer:SetMaxFunctionCalls(20)
--
-- where *Nmax* is the number of calls after which the timer is stopped, here 20.
--
-- For example,
--
-- mytimer:SetMaxFunctionCalls(66):Start(1.0, 0.1)
--
-- will start the timer after one second and call the function every 0.1 seconds. Once the function has been called 66 times, the timer is stopped.
--
--
-- @field #TIMER
TIMER = {
ClassName = "TIMER",
lid = nil,
}
--- TIMER class version.
-- @field #string version
TIMER.version="0.1.0"
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TODO list
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TODO: A lot.
-- TODO: Write docs.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- Constructor
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--- Create a new TIMER object.
-- @param #TIMER self
-- @param #function Function The function to call.
-- @param ... Parameters passed to the function if any.
-- @return #TIMER self
function TIMER:New(Function, ...)
-- Inherit BASE.
local self=BASE:Inherit(self, BASE:New()) --#TIMER
self.lid="TIMER | "
-- Function to call.
self.func=Function
-- Function arguments.
self.para=arg or {}
-- Number of function calls.
self.ncalls=0
return self
end
--- Create a new TIMER object.
-- @param #TIMER self
-- @param #number Tstart Relative start time in seconds.
-- @param #number dT Interval between function calls in seconds. If not specified `nil`, the function is called only once.
-- @param #number Duration Time in seconds for how long the timer is running. If not specified `nil`, the timer runs forever or until stopped manually by the `TIMER:Stop()` function.
-- @return #TIMER self
function TIMER:Start(Tstart, dT, Duration)
-- Current time.
local Tnow=timer.getTime()
-- Start time in sec.
self.Tstart=Tstart or Tnow
-- Set time interval.
self.dT=dT
-- Stop time.
if Duration then
self.Tstop=self.Tstart+Duration
end
-- Call DCS timer function.
self.tid=timer.scheduleFunction(TIMER._Function, self, self.Tstart)
-- Set log id.
self.lid=string.format("TIMER ID=%d | ", self.tid)
-- Debug info.
self:T(self.lid..string.format("Starting Timer in %.3f sec, dT=%s, Tstop=%s", self.Tstart-Tnow, tostring(self.dT), tostring(self.Tstop)))
return self
end
--- Stop the timer by removing the timer function.
-- @param #TIMER self
-- @param #number Delay (Optional) Delay in seconds, before the timer is stopped.
-- @return #TIMER self
function TIMER:Stop(Delay)
if Delay and Delay>0 then
self.Tstop=timer.getTime()+Delay
else
if self.tid then
self:T(self.lid..string.format("Stopping timer by removing timer function after %d calls!", self.ncalls))
timer.removeFunction(self.tid)
end
end
return self
end
--- Set max number of function calls. When the function has been called this many times, the TIMER is stopped.
-- @param #TIMER self
-- @param #number Nmax Set number of max function calls.
-- @return #TIMER self
function TIMER:SetMaxFunctionCalls(Nmax)
self.ncallsMax=Nmax
return self
end
--- Call timer function.
-- @param #TIMER self
-- @param #number time DCS model time in seconds.
-- @return #number Time when the function is called again or `nil` if the timer is stopped.
function TIMER:_Function(time)
-- Call function.
self.func(unpack(self.para))
-- Increase number of calls.
self.ncalls=self.ncalls+1
-- Next time.
local Tnext=self.dT and time+self.dT or nil
-- Check if we stop the timer.
local stopme=false
if Tnext==nil then
-- No next time.
self:T(self.lid..string.format("No next time as dT=nil ==> Stopping timer after %d function calls", self.ncalls))
stopme=true
elseif self.Tstop and Tnext>self.Tstop then
-- Stop time passed.
self:T(self.lid..string.format("Stop time passed %.3f > %.3f ==> Stopping timer after %d function calls", Tnext, self.Tstop, self.ncalls))
stopme=true
elseif self.ncallsMax and self.ncalls>=self.ncallsMax then
-- Number of max function calls reached.
self:T(self.lid..string.format("Max function calls Nmax=%d reached ==> Stopping timer after %d function calls", self.ncallsMax, self.ncalls))
stopme=true
end
if stopme then
-- Remove timer function.
self:Stop()
return nil
else
-- Call again in Tnext seconds.
return Tnext
end
end
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

View File

@ -443,6 +443,41 @@ function ZONE_RADIUS:New( ZoneName, Vec2, Radius )
return self return self
end end
--- Update zone from a 2D vector.
-- @param #ZONE_RADIUS self
-- @param DCS#Vec2 Vec2 The location of the zone.
-- @param DCS#Distance Radius The radius of the zone.
-- @return #ZONE_RADIUS self
function ZONE_RADIUS:UpdateFromVec2(Vec2, Radius)
-- New center of the zone.
self.Vec2=Vec2
if Radius then
self.Radius=Radius
end
return self
end
--- Update zone from a 2D vector.
-- @param #ZONE_RADIUS self
-- @param DCS#Vec3 Vec3 The location of the zone.
-- @param DCS#Distance Radius The radius of the zone.
-- @return #ZONE_RADIUS self
function ZONE_RADIUS:UpdateFromVec3(Vec3, Radius)
-- New center of the zone.
self.Vec2.x=Vec3.x
self.Vec2.y=Vec3.z
if Radius then
self.Radius=Radius
end
return self
end
--- Mark the zone with markers on the F10 map. --- Mark the zone with markers on the F10 map.
-- @param #ZONE_RADIUS self -- @param #ZONE_RADIUS self
-- @param #number Points (Optional) The amount of points in the circle. Default 360. -- @param #number Points (Optional) The amount of points in the circle. Default 360.
@ -1410,20 +1445,24 @@ ZONE_POLYGON_BASE = {
-- The @{Wrapper.Group#GROUP} waypoints define the polygon corners. The first and the last point are automatically connected. -- The @{Wrapper.Group#GROUP} waypoints define the polygon corners. The first and the last point are automatically connected.
-- @param #ZONE_POLYGON_BASE self -- @param #ZONE_POLYGON_BASE self
-- @param #string ZoneName Name of the zone. -- @param #string ZoneName Name of the zone.
-- @param #ZONE_POLYGON_BASE.ListVec2 PointsArray An array of @{DCS#Vec2}, forming a polygon.. -- @param #ZONE_POLYGON_BASE.ListVec2 PointsArray An array of @{DCS#Vec2}, forming a polygon.
-- @return #ZONE_POLYGON_BASE self -- @return #ZONE_POLYGON_BASE self
function ZONE_POLYGON_BASE:New( ZoneName, PointsArray ) function ZONE_POLYGON_BASE:New( ZoneName, PointsArray )
-- Inherit ZONE_BASE.
local self = BASE:Inherit( self, ZONE_BASE:New( ZoneName ) ) local self = BASE:Inherit( self, ZONE_BASE:New( ZoneName ) )
self:F( { ZoneName, PointsArray } ) self:F( { ZoneName, PointsArray } )
local i = 0 if PointsArray then
self._.Polygon = {} self._.Polygon = {}
for i = 1, #PointsArray do for i = 1, #PointsArray do
self._.Polygon[i] = {} self._.Polygon[i] = {}
self._.Polygon[i].x = PointsArray[i].x self._.Polygon[i].x = PointsArray[i].x
self._.Polygon[i].y = PointsArray[i].y self._.Polygon[i].y = PointsArray[i].y
end
end end
return self return self

View File

@ -25,6 +25,7 @@ __Moose.Include( 'Scripts/Moose/Core/RadioQueue.lua' )
__Moose.Include( 'Scripts/Moose/Core/RadioSpeech.lua' ) __Moose.Include( 'Scripts/Moose/Core/RadioSpeech.lua' )
__Moose.Include( 'Scripts/Moose/Core/Spawn.lua' ) __Moose.Include( 'Scripts/Moose/Core/Spawn.lua' )
__Moose.Include( 'Scripts/Moose/Core/SpawnStatic.lua' ) __Moose.Include( 'Scripts/Moose/Core/SpawnStatic.lua' )
__Moose.Include( 'Scripts/Moose/Core/Timer.lua' )
__Moose.Include( 'Scripts/Moose/Core/Goal.lua' ) __Moose.Include( 'Scripts/Moose/Core/Goal.lua' )
__Moose.Include( 'Scripts/Moose/Core/Spot.lua' ) __Moose.Include( 'Scripts/Moose/Core/Spot.lua' )
__Moose.Include( 'Scripts/Moose/Core/Astar.lua' ) __Moose.Include( 'Scripts/Moose/Core/Astar.lua' )

View File

@ -3385,6 +3385,11 @@ function AIRBOSS:onafterStart(From, Event, To)
self:HandleEvent(EVENTS.PlayerLeaveUnit, self._PlayerLeft) self:HandleEvent(EVENTS.PlayerLeaveUnit, self._PlayerLeft)
self:HandleEvent(EVENTS.MissionEnd) self:HandleEvent(EVENTS.MissionEnd)
--self.StatusScheduler=SCHEDULER:New(self)
--self.StatusScheduler:Schedule(self, self._Status, {}, 1, 0.5)
self.StatusTimer=TIMER:New(self._Status, self):Start(2, 0.5)
-- Start status check in 1 second. -- Start status check in 1 second.
self:__Status(1) self:__Status(1)
end end
@ -3501,14 +3506,21 @@ function AIRBOSS:onafterStatus(From, Event, To)
self:_ActivateBeacons() self:_ActivateBeacons()
end end
-- Call status every ~0.5 seconds.
self:__Status(-30)
end
--- Check AI status. Pattern queue AI in the groove? Marshal queue AI arrived in holding zone?
-- @param #AIRBOSS self
function AIRBOSS:_Status()
-- Check player status. -- Check player status.
self:_CheckPlayerStatus() self:_CheckPlayerStatus()
-- Check AI landing pattern status -- Check AI landing pattern status
self:_CheckAIStatus() self:_CheckAIStatus()
-- Call status every ~0.5 seconds.
self:__Status(-self.dTstatus)
end end
--- Check AI status. Pattern queue AI in the groove? Marshal queue AI arrived in holding zone? --- Check AI status. Pattern queue AI in the groove? Marshal queue AI arrived in holding zone?
@ -3559,12 +3571,16 @@ function AIRBOSS:_CheckAIStatus()
-- Get lineup and distance to carrier. -- Get lineup and distance to carrier.
local lineup=self:_Lineup(unit, true) local lineup=self:_Lineup(unit, true)
local unitcoord=unit:GetCoord()
local dist=unitcoord:Get2DDistance(self:GetCoord())
-- Distance in NM. -- Distance in NM.
local distance=UTILS.MetersToNM(unit:GetCoordinate():Get2DDistance(self:GetCoordinate())) local distance=UTILS.MetersToNM(dist)
-- Altitude in ft. -- Altitude in ft.
local alt=UTILS.MetersToFeet(unit:GetAltitude()) local alt=UTILS.MetersToFeet(unitcoord.y)
-- Check if parameters are right and flight is in the groove. -- Check if parameters are right and flight is in the groove.
if lineup<2 and distance<=0.75 and alt<500 and not element.ballcall then if lineup<2 and distance<=0.75 and alt<500 and not element.ballcall then
@ -10497,6 +10513,8 @@ end
-- @return Core.Zone#ZONE_POLYGON_BASE Initial zone. -- @return Core.Zone#ZONE_POLYGON_BASE Initial zone.
function AIRBOSS:_GetZoneInitial(case) function AIRBOSS:_GetZoneInitial(case)
self.zoneInitial=self.zoneInitial or ZONE_POLYGON_BASE:New("Zone CASE I/II Initial")
-- Get radial, i.e. inverse of BRC. -- Get radial, i.e. inverse of BRC.
local radial=self:GetRadial(2, false, false) local radial=self:GetRadial(2, false, false)
@ -10504,7 +10522,7 @@ function AIRBOSS:_GetZoneInitial(case)
local cv=self:GetCoordinate() local cv=self:GetCoordinate()
-- Vec2 array. -- Vec2 array.
local vec2 local vec2={}
if case==1 then if case==1 then
-- Case I -- Case I
@ -10535,9 +10553,12 @@ function AIRBOSS:_GetZoneInitial(case)
end end
-- Polygon zone. -- Polygon zone.
local zone=ZONE_POLYGON_BASE:New("Zone CASE I/II Initial", vec2) --local zone=ZONE_POLYGON_BASE:New("Zone CASE I/II Initial", vec2)
self.zoneInitial:UpdateFromVec2(vec2)
return zone --return zone
return self.zoneInitial
end end
--- Get lineup groove zone. --- Get lineup groove zone.
@ -10545,6 +10566,8 @@ end
-- @return Core.Zone#ZONE_POLYGON_BASE Lineup zone. -- @return Core.Zone#ZONE_POLYGON_BASE Lineup zone.
function AIRBOSS:_GetZoneLineup() function AIRBOSS:_GetZoneLineup()
self.zoneLineup=self.zoneLineup or ZONE_POLYGON_BASE:New("Zone Lineup")
-- Get radial, i.e. inverse of BRC. -- Get radial, i.e. inverse of BRC.
local fbi=self:GetRadial(1, false, false) local fbi=self:GetRadial(1, false, false)
@ -10560,11 +10583,14 @@ function AIRBOSS:_GetZoneLineup()
-- Vec2 array. -- Vec2 array.
local vec2={c1:GetVec2(), c2:GetVec2(), c3:GetVec2(), c4:GetVec2(), c5:GetVec2()} local vec2={c1:GetVec2(), c2:GetVec2(), c3:GetVec2(), c4:GetVec2(), c5:GetVec2()}
self.zoneLineup:UpdateFromVec2(vec2)
-- Polygon zone. -- Polygon zone.
local zone=ZONE_POLYGON_BASE:New("Zone Lineup", vec2) --local zone=ZONE_POLYGON_BASE:New("Zone Lineup", vec2)
--return zone
return zone
return self.zoneLineup
end end
@ -10576,6 +10602,8 @@ end
-- @return Core.Zone#ZONE_POLYGON_BASE Groove zone. -- @return Core.Zone#ZONE_POLYGON_BASE Groove zone.
function AIRBOSS:_GetZoneGroove(l, w, b) function AIRBOSS:_GetZoneGroove(l, w, b)
self.zoneGroove=self.zoneGroove or ZONE_POLYGON_BASE:New("Zone Groove")
l=l or 1.50 l=l or 1.50
w=w or 0.25 w=w or 0.25
b=b or 0.10 b=b or 0.10
@ -10596,11 +10624,14 @@ function AIRBOSS:_GetZoneGroove(l, w, b)
-- Vec2 array. -- Vec2 array.
local vec2={c1:GetVec2(), c2:GetVec2(), c3:GetVec2(), c4:GetVec2(), c5:GetVec2(), c6:GetVec2()} local vec2={c1:GetVec2(), c2:GetVec2(), c3:GetVec2(), c4:GetVec2(), c5:GetVec2(), c6:GetVec2()}
self.zoneGroove:UpdateFromVec2(vec2)
-- Polygon zone. -- Polygon zone.
local zone=ZONE_POLYGON_BASE:New("Zone Groove", vec2) --local zone=ZONE_POLYGON_BASE:New("Zone Groove", vec2)
--return zone
return zone
return self.zoneGroove
end end
--- Get Bullseye zone with radius 1 NM and DME 3 NM from the carrier. Radial depends on recovery case. --- Get Bullseye zone with radius 1 NM and DME 3 NM from the carrier. Radial depends on recovery case.
@ -10624,8 +10655,9 @@ function AIRBOSS:_GetZoneBullseye(case)
-- Create zone. -- Create zone.
local zone=ZONE_RADIUS:New("Zone Bullseye", vec2, radius) local zone=ZONE_RADIUS:New("Zone Bullseye", vec2, radius)
return zone return zone
--self.zoneBullseye=self.zoneBullseye or ZONE_RADIUS:New("Zone Bullseye", vec2, radius)
end end
--- Get dirty up zone with radius 1 NM and DME 9 NM from the carrier. Radial depends on recovery case. --- Get dirty up zone with radius 1 NM and DME 9 NM from the carrier. Radial depends on recovery case.
@ -10821,6 +10853,8 @@ end
-- @return Core.Zone#ZONE Zone surrounding the carrier. -- @return Core.Zone#ZONE Zone surrounding the carrier.
function AIRBOSS:_GetZoneCarrierBox() function AIRBOSS:_GetZoneCarrierBox()
self.zoneCarrierbox=self.zoneCarrierbox or ZONE_POLYGON_BASE:New("Carrier Box Zone")
-- Stern coordinate. -- Stern coordinate.
local S=self:_GetSternCoord() local S=self:_GetSternCoord()
@ -10849,9 +10883,12 @@ function AIRBOSS:_GetZoneCarrierBox()
end end
-- Create polygon zone. -- Create polygon zone.
local zone=ZONE_POLYGON_BASE:New("Carrier Box Zone", vec2) --local zone=ZONE_POLYGON_BASE:New("Carrier Box Zone", vec2)
--return zone
return zone
self.zoneCarrierbox:UpdateFromVec2(vec2)
return self.zoneCarrierbox
end end
--- Get zone of landing runway. --- Get zone of landing runway.
@ -10859,6 +10896,8 @@ end
-- @return Core.Zone#ZONE_POLYGON Zone surrounding landing runway. -- @return Core.Zone#ZONE_POLYGON Zone surrounding landing runway.
function AIRBOSS:_GetZoneRunwayBox() function AIRBOSS:_GetZoneRunwayBox()
self.zoneRunwaybox=self.zoneRunwaybox or ZONE_POLYGON_BASE:New("Landing Runway Zone")
-- Stern coordinate. -- Stern coordinate.
local S=self:_GetSternCoord() local S=self:_GetSternCoord()
@ -10881,9 +10920,12 @@ function AIRBOSS:_GetZoneRunwayBox()
end end
-- Create polygon zone. -- Create polygon zone.
local zone=ZONE_POLYGON_BASE:New("Landing Runway Zone", vec2) --local zone=ZONE_POLYGON_BASE:New("Landing Runway Zone", vec2)
--return zone
return zone
self.zoneRunwaybox:UpdateFromVec2(vec2)
return self.zoneRunwaybox
end end
@ -10986,12 +11028,14 @@ function AIRBOSS:_GetZoneHolding(case, stack)
-- Post 2.5 NM port of carrier. -- Post 2.5 NM port of carrier.
local Post=self:GetCoordinate():Translate(D, hdg+270) local Post=self:GetCoordinate():Translate(D, hdg+270)
--TODO: update zone not creating a new one.
-- Create holding zone. -- Create holding zone.
zoneHolding=ZONE_RADIUS:New("CASE I Holding Zone", Post:GetVec2(), self.marshalradius) self.zoneHolding=ZONE_RADIUS:New("CASE I Holding Zone", Post:GetVec2(), self.marshalradius)
-- Delta pattern. -- Delta pattern.
if self.carriertype==AIRBOSS.CarrierType.TARAWA then if self.carriertype==AIRBOSS.CarrierType.TARAWA then
zoneHolding=ZONE_RADIUS:New("CASE I Holding Zone", self.carrier:GetVec2(), UTILS.NMToMeters(5)) self.zoneHolding=ZONE_RADIUS:New("CASE I Holding Zone", self.carrier:GetVec2(), UTILS.NMToMeters(5))
end end
@ -11010,10 +11054,12 @@ function AIRBOSS:_GetZoneHolding(case, stack)
-- Square zone length=7NM width=6 NM behind the carrier starting at angels+15 NM behind the carrier. -- Square zone length=7NM width=6 NM behind the carrier starting at angels+15 NM behind the carrier.
-- So stay 0-5 NM (+1 NM error margin) port of carrier. -- So stay 0-5 NM (+1 NM error margin) port of carrier.
zoneHolding=ZONE_POLYGON_BASE:New("CASE II/III Holding Zone", p) self.zoneHolding=self.zoneHolding or ZONE_POLYGON_BASE:New("CASE II/III Holding Zone")
self.zoneHolding:UpdateFromVec2(p)
end end
return zoneHolding return self.zoneHolding
end end
--- Get zone where player are automatically commence when enter. --- Get zone where player are automatically commence when enter.
@ -11054,7 +11100,9 @@ function AIRBOSS:_GetZoneCommence(case, stack)
end end
-- Create holding zone. -- Create holding zone.
zone=ZONE_RADIUS:New("CASE I Commence Zone", Three:GetVec2(), R) self.zoneCommence=self.zoneCommence or ZONE_RADIUS:New("CASE I Commence Zone")
self.zoneCommence:UpdateFromVec2(Three:GetVec2(), R)
else else
-- Case II/III -- Case II/III
@ -11085,11 +11133,13 @@ function AIRBOSS:_GetZoneCommence(case, stack)
end end
-- Zone polygon. -- Zone polygon.
zone=ZONE_POLYGON_BASE:New("CASE II/III Commence Zone", p) self.zoneCommence=self.zoneCommence or ZONE_POLYGON_BASE:New("CASE II/III Commence Zone")
self.zoneCommence:UpdateFromVec2(p)
end end
return zone return self.zoneCommence
end end
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@ -14335,6 +14385,12 @@ function AIRBOSS:GetCoordinate()
return self.carrier:GetCoord() return self.carrier:GetCoord()
end end
--- Get carrier coordinate.
-- @param #AIRBOSS self
-- @return Core.Point#COORDINATE Carrier coordinate.
function AIRBOSS:GetCoord()
return self.carrier:GetCoord()
end
--- Get static weather of this mission from env.mission.weather. --- Get static weather of this mission from env.mission.weather.
-- @param #AIRBOSS self -- @param #AIRBOSS self

View File

@ -40,7 +40,7 @@ ARMYGROUP = {
--- Army Group version. --- Army Group version.
-- @field #string version -- @field #string version
ARMYGROUP.version="0.0.1" ARMYGROUP.version="0.1.0"
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TODO list -- TODO list

View File

@ -1772,13 +1772,9 @@ end
--- Assign airwing squadron(s) to the mission. Only these squads will be considered for the job. --- Assign airwing squadron(s) to the mission. Only these squads will be considered for the job.
-- @param #AUFTRAG self -- @param #AUFTRAG self
-- @param #table Squadrons A table of SQUADRONs or a single SQUADRON object. -- @param #table Squadrons A table of SQUADRON(s). **Has to be a table {}** even if a single squad is given.
-- @return #AUFTRAG self -- @return #AUFTRAG self
function AUFTRAG:AssignSquadrons(Squadrons) function AUFTRAG:AssignSquadrons(Squadrons)
if Squadrons:IsInstanceOf("SQUADRON") then
Squadrons={Squadrons}
end
for _,_squad in pairs(Squadrons) do for _,_squad in pairs(Squadrons) do
local squadron=_squad --Ops.Squadron#SQUADRON local squadron=_squad --Ops.Squadron#SQUADRON

View File

@ -332,6 +332,8 @@ function FLIGHTGROUP:New(group)
self:__Status(-2) self:__Status(-2)
self:__QueueUpdate(-3) self:__QueueUpdate(-3)
--self.Timer=SCHEDULER:New()
return self return self
end end

View File

@ -66,7 +66,7 @@ NAVYGROUP = {
--- NavyGroup version. --- NavyGroup version.
-- @field #string version -- @field #string version
NAVYGROUP.version="0.1.0" NAVYGROUP.version="0.5.0"
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TODO list -- TODO list

View File

@ -262,7 +262,7 @@ OPSGROUP.TaskType={
--- NavyGroup version. --- NavyGroup version.
-- @field #string version -- @field #string version
OPSGROUP.version="0.2.0" OPSGROUP.version="0.5.0"
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TODO list -- TODO list

View File

@ -37,10 +37,10 @@
-- @field #number callsigncounter Counter to increase callsign names for new assets. -- @field #number callsigncounter Counter to increase callsign names for new assets.
-- @field Ops.AirWing#AIRWING airwing The AIRWING object the squadron belongs to. -- @field Ops.AirWing#AIRWING airwing The AIRWING object the squadron belongs to.
-- @field #number Ngroups Number of asset flight groups this squadron has. -- @field #number Ngroups Number of asset flight groups this squadron has.
-- @field #number engageRange Engagement range in meters. -- @field #number engageRange Mission range in meters.
-- @field #string attribute Generalized attribute of the squadron template group. -- @field #string attribute Generalized attribute of the squadron template group.
-- @field #number tankerSystem For tanker squads, the refuel system used (boom=0 or probpe=1). Default nil. -- @field #number tankerSystem For tanker squads, the refuel system used (boom=0 or probpe=1). Default nil.
-- @field #number refuelSystem For refuelable squads, the refuel system used (boom=0 or probpe=1). Default nil. -- @field #number refuelSystem For refuelable squads, the refuel system used (boom=0 or probe=1). Default nil.
-- @field #table tacanChannel List of TACAN channels available to the squadron. -- @field #table tacanChannel List of TACAN channels available to the squadron.
-- @field #number radioFreq Radio frequency in MHz the squad uses. -- @field #number radioFreq Radio frequency in MHz the squad uses.
-- @field #number radioModu Radio modulation the squad uses. -- @field #number radioModu Radio modulation the squad uses.

View File

@ -110,7 +110,7 @@ _TARGETID=0
--- TARGET class version. --- TARGET class version.
-- @field #string version -- @field #string version
TARGET.version="0.0.1" TARGET.version="0.1.0"
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TODO list -- TODO list