mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Ops
This commit is contained in:
@@ -136,7 +136,7 @@ function DATABASE:New()
|
|||||||
self:_RegisterClients()
|
self:_RegisterClients()
|
||||||
self:_RegisterStatics()
|
self:_RegisterStatics()
|
||||||
--self:_RegisterPlayers()
|
--self:_RegisterPlayers()
|
||||||
self:_RegisterAirbases()
|
--self:_RegisterAirbases()
|
||||||
|
|
||||||
self.UNITS_Position = 0
|
self.UNITS_Position = 0
|
||||||
|
|
||||||
|
|||||||
@@ -100,6 +100,12 @@ TIMER = {
|
|||||||
lid = nil,
|
lid = nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
--- Timer ID.
|
||||||
|
_TIMERID=0
|
||||||
|
|
||||||
|
--- Timer data base.
|
||||||
|
_TIMERDB={}
|
||||||
|
|
||||||
--- TIMER class version.
|
--- TIMER class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
TIMER.version="0.1.0"
|
TIMER.version="0.1.0"
|
||||||
@@ -124,8 +130,6 @@ function TIMER:New(Function, ...)
|
|||||||
|
|
||||||
-- Inherit BASE.
|
-- Inherit BASE.
|
||||||
local self=BASE:Inherit(self, BASE:New()) --#TIMER
|
local self=BASE:Inherit(self, BASE:New()) --#TIMER
|
||||||
|
|
||||||
self.lid="TIMER | "
|
|
||||||
|
|
||||||
-- Function to call.
|
-- Function to call.
|
||||||
self.func=Function
|
self.func=Function
|
||||||
@@ -136,6 +140,18 @@ function TIMER:New(Function, ...)
|
|||||||
-- Number of function calls.
|
-- Number of function calls.
|
||||||
self.ncalls=0
|
self.ncalls=0
|
||||||
|
|
||||||
|
-- Increase counter
|
||||||
|
_TIMERID=_TIMERID+1
|
||||||
|
|
||||||
|
-- Set UID.
|
||||||
|
self.uid=_TIMERID
|
||||||
|
|
||||||
|
-- Log id.
|
||||||
|
self.lid=string.format("TIMER UID=%d | ", self.uid)
|
||||||
|
|
||||||
|
-- Add to DB.
|
||||||
|
_TIMERDB[self.uid]=self
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -151,7 +167,7 @@ function TIMER:Start(Tstart, dT, Duration)
|
|||||||
local Tnow=timer.getTime()
|
local Tnow=timer.getTime()
|
||||||
|
|
||||||
-- Start time in sec.
|
-- Start time in sec.
|
||||||
self.Tstart=Tstart or Tnow
|
self.Tstart=Tstart and Tnow+Tstart or Tnow+0.001 -- one millisecond delay if Tstart=nil
|
||||||
|
|
||||||
-- Set time interval.
|
-- Set time interval.
|
||||||
self.dT=dT
|
self.dT=dT
|
||||||
@@ -162,10 +178,10 @@ function TIMER:Start(Tstart, dT, Duration)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Call DCS timer function.
|
-- Call DCS timer function.
|
||||||
self.tid=timer.scheduleFunction(TIMER._Function, self, self.Tstart)
|
self.tid=timer.scheduleFunction(self._Function, self, self.Tstart)
|
||||||
|
|
||||||
-- Set log id.
|
-- Set log id.
|
||||||
self.lid=string.format("TIMER ID=%d | ", self.tid)
|
self.lid=string.format("TIMER UID=%d/%d | ", self.uid, self.tid)
|
||||||
|
|
||||||
-- Debug info.
|
-- 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)))
|
self:T(self.lid..string.format("Starting Timer in %.3f sec, dT=%s, Tstop=%s", self.Tstart-Tnow, tostring(self.dT), tostring(self.Tstop)))
|
||||||
@@ -186,8 +202,14 @@ function TIMER:Stop(Delay)
|
|||||||
else
|
else
|
||||||
|
|
||||||
if self.tid then
|
if self.tid then
|
||||||
|
|
||||||
|
-- Remove timer function.
|
||||||
self:T(self.lid..string.format("Stopping timer by removing timer function after %d calls!", self.ncalls))
|
self:T(self.lid..string.format("Stopping timer by removing timer function after %d calls!", self.ncalls))
|
||||||
timer.removeFunction(self.tid)
|
timer.removeFunction(self.tid)
|
||||||
|
|
||||||
|
-- Remove DB entry.
|
||||||
|
_TIMERDB[self.uid]=nil
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -210,6 +232,8 @@ end
|
|||||||
-- @return #number Time when the function is called again or `nil` if the timer is stopped.
|
-- @return #number Time when the function is called again or `nil` if the timer is stopped.
|
||||||
function TIMER:_Function(time)
|
function TIMER:_Function(time)
|
||||||
|
|
||||||
|
--self:I(self.lid.."FF calling timer _Function")
|
||||||
|
|
||||||
-- Call function.
|
-- Call function.
|
||||||
self.func(unpack(self.para))
|
self.func(unpack(self.para))
|
||||||
|
|
||||||
|
|||||||
@@ -3521,12 +3521,14 @@ function WAREHOUSE:_JobDone()
|
|||||||
---------------
|
---------------
|
||||||
|
|
||||||
-- Info on job.
|
-- Info on job.
|
||||||
local text=string.format("Warehouse %s: Job on request id=%d for warehouse %s done!\n", self.alias, request.uid, request.warehouse.alias)
|
if self.verbosity>=1 then
|
||||||
text=text..string.format("- %d of %d assets delivered. Casualties %d.", ncargodelivered, ncargotot, ncargodead)
|
local text=string.format("Warehouse %s: Job on request id=%d for warehouse %s done!\n", self.alias, request.uid, request.warehouse.alias)
|
||||||
if request.ntransport>0 then
|
text=text..string.format("- %d of %d assets delivered. Casualties %d.", ncargodelivered, ncargotot, ncargodead)
|
||||||
text=text..string.format("\n- %d of %d transports returned home. Casualties %d.", ntransporthome, ntransporttot, ntransportdead)
|
if request.ntransport>0 then
|
||||||
|
text=text..string.format("\n- %d of %d transports returned home. Casualties %d.", ntransporthome, ntransporttot, ntransportdead)
|
||||||
|
end
|
||||||
|
self:_InfoMessage(text, 20)
|
||||||
end
|
end
|
||||||
self:_InfoMessage(text, 20)
|
|
||||||
|
|
||||||
-- Mark request for deletion.
|
-- Mark request for deletion.
|
||||||
table.insert(done, request)
|
table.insert(done, request)
|
||||||
@@ -3575,13 +3577,13 @@ function WAREHOUSE:_JobDone()
|
|||||||
|
|
||||||
-- Debug text.
|
-- Debug text.
|
||||||
local text=string.format("Group %s: speed=%d km/h, onground=%s , airbase=%s, spawnzone=%s ==> ishome=%s", group:GetName(), speed, tostring(onground), airbase, tostring(inspawnzone), tostring(ishome))
|
local text=string.format("Group %s: speed=%d km/h, onground=%s , airbase=%s, spawnzone=%s ==> ishome=%s", group:GetName(), speed, tostring(onground), airbase, tostring(inspawnzone), tostring(ishome))
|
||||||
self:I(self.lid..text)
|
self:T(self.lid..text)
|
||||||
|
|
||||||
if ishome then
|
if ishome then
|
||||||
|
|
||||||
-- Info message.
|
-- Info message.
|
||||||
local text=string.format("Warehouse %s: Transport group arrived back home and no cargo left for request id=%d.\nSending transport group %s back to stock.", self.alias, request.uid, group:GetName())
|
local text=string.format("Warehouse %s: Transport group arrived back home and no cargo left for request id=%d.\nSending transport group %s back to stock.", self.alias, request.uid, group:GetName())
|
||||||
self:_InfoMessage(text)
|
self:T(self.lid..text)
|
||||||
|
|
||||||
-- Debug smoke.
|
-- Debug smoke.
|
||||||
if self.Debug then
|
if self.Debug then
|
||||||
@@ -4807,7 +4809,7 @@ function WAREHOUSE:onafterArrived(From, Event, To, group)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Move asset from pending queue into new warehouse.
|
-- Move asset from pending queue into new warehouse.
|
||||||
env.info("FF asset arrived in wh. adding in 60 sec")
|
self:T(self.lid.."Asset arrived at warehouse adding in 60 sec")
|
||||||
warehouse:__AddAsset(60, group)
|
warehouse:__AddAsset(60, group)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -4822,8 +4824,10 @@ end
|
|||||||
function WAREHOUSE:onafterDelivered(From, Event, To, request)
|
function WAREHOUSE:onafterDelivered(From, Event, To, request)
|
||||||
|
|
||||||
-- Debug info
|
-- Debug info
|
||||||
local text=string.format("Warehouse %s: All assets delivered to warehouse %s!", self.alias, request.warehouse.alias)
|
if self.verbosity>=1 then
|
||||||
self:_InfoMessage(text, 5)
|
local text=string.format("Warehouse %s: All assets delivered to warehouse %s!", self.alias, request.warehouse.alias)
|
||||||
|
self:_InfoMessage(text, 5)
|
||||||
|
end
|
||||||
|
|
||||||
-- Make some noise :)
|
-- Make some noise :)
|
||||||
if self.Debug then
|
if self.Debug then
|
||||||
@@ -5163,12 +5167,12 @@ function WAREHOUSE:onafterAssetSpawned(From, Event, To, group, asset, request)
|
|||||||
local assetitem=_asset --#WAREHOUSE.Assetitem
|
local assetitem=_asset --#WAREHOUSE.Assetitem
|
||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
self:I(self.lid..string.format("Asset %s spawned %s as %s", assetitem.templatename, tostring(assetitem.spawned), tostring(assetitem.spawngroupname)))
|
self:T(self.lid..string.format("Asset %s spawned %s as %s", assetitem.templatename, tostring(assetitem.spawned), tostring(assetitem.spawngroupname)))
|
||||||
|
|
||||||
if assetitem.spawned then
|
if assetitem.spawned then
|
||||||
n=n+1
|
n=n+1
|
||||||
else
|
else
|
||||||
self:E(self.lid.."FF What?! This should not happen!")
|
self:T(self.lid.."FF What?! This should not happen!")
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -8498,8 +8502,8 @@ end
|
|||||||
-- @param #number duration Message display duration in seconds. Default 20 sec. If duration is zero, no message is displayed.
|
-- @param #number duration Message display duration in seconds. Default 20 sec. If duration is zero, no message is displayed.
|
||||||
function WAREHOUSE:_InfoMessage(text, duration)
|
function WAREHOUSE:_InfoMessage(text, duration)
|
||||||
duration=duration or 20
|
duration=duration or 20
|
||||||
if duration>0 then
|
if duration>0 and self.Debug or self.Report then
|
||||||
MESSAGE:New(text, duration):ToCoalitionIf(self:GetCoalition(), self.Debug or self.Report)
|
MESSAGE:New(text, duration):ToCoalition(self:GetCoalition())
|
||||||
end
|
end
|
||||||
self:I(self.lid..text)
|
self:I(self.lid..text)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -15,4 +15,5 @@ _SETTINGS:SetPlayerMenuOn()
|
|||||||
|
|
||||||
_DATABASE:_RegisterCargos()
|
_DATABASE:_RegisterCargos()
|
||||||
_DATABASE:_RegisterZones()
|
_DATABASE:_RegisterZones()
|
||||||
|
_DATABASE:_RegisterAirbases()
|
||||||
|
|
||||||
|
|||||||
@@ -113,9 +113,13 @@ function ARMYGROUP:New(GroupName)
|
|||||||
self:HandleEvent(EVENTS.RemoveUnit, self.OnEventRemoveUnit)
|
self:HandleEvent(EVENTS.RemoveUnit, self.OnEventRemoveUnit)
|
||||||
|
|
||||||
-- Start the status monitoring.
|
-- Start the status monitoring.
|
||||||
self:__CheckZone(-1)
|
self:__Status(-1)
|
||||||
self:__Status(-2)
|
|
||||||
self:__QueueUpdate(-3)
|
-- Start check zone timer.
|
||||||
|
self.timerCheckZone=TIMER:New(self._CheckInZones, self):Start(2, 5)
|
||||||
|
|
||||||
|
-- Start queue update timer.
|
||||||
|
self.timerQueueUpdate=TIMER:New(self._QueueUpdate, self):Start(3, 30)
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@@ -292,7 +296,7 @@ end
|
|||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
-- @param #ARMYGROUP.Element Element The group element.
|
-- @param #ARMYGROUP.Element Element The group element.
|
||||||
function ARMYGROUP:onafterElementSpawned(From, Event, To, Element)
|
function ARMYGROUP:onafterElementSpawned(From, Event, To, Element)
|
||||||
self:I(self.lid..string.format("Element spawned %s", Element.name))
|
self:T(self.lid..string.format("Element spawned %s", Element.name))
|
||||||
|
|
||||||
-- Set element status.
|
-- Set element status.
|
||||||
self:_UpdateStatus(Element, OPSGROUP.ElementStatus.SPAWNED)
|
self:_UpdateStatus(Element, OPSGROUP.ElementStatus.SPAWNED)
|
||||||
@@ -318,7 +322,7 @@ end
|
|||||||
-- @param #string Event Event.
|
-- @param #string Event Event.
|
||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
function ARMYGROUP:onafterSpawned(From, Event, To)
|
function ARMYGROUP:onafterSpawned(From, Event, To)
|
||||||
self:I(self.lid..string.format("Group spawned!"))
|
self:T(self.lid..string.format("Group spawned!"))
|
||||||
|
|
||||||
if self.ai then
|
if self.ai then
|
||||||
|
|
||||||
|
|||||||
@@ -429,7 +429,7 @@ AUFTRAG.TargetType={
|
|||||||
|
|
||||||
--- AUFTRAG class version.
|
--- AUFTRAG class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
AUFTRAG.version="0.3.1"
|
AUFTRAG.version="0.5.0"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO list
|
-- TODO list
|
||||||
@@ -1801,7 +1801,7 @@ end
|
|||||||
-- @param #AUFTRAG self
|
-- @param #AUFTRAG self
|
||||||
-- @param Ops.OpsGroup#OPSGROUP OpsGroup The OPSGROUP object.
|
-- @param Ops.OpsGroup#OPSGROUP OpsGroup The OPSGROUP object.
|
||||||
function AUFTRAG:AddOpsGroup(OpsGroup)
|
function AUFTRAG:AddOpsGroup(OpsGroup)
|
||||||
self:I(self.lid..string.format("Adding Ops group %s", OpsGroup.groupname))
|
self:T(self.lid..string.format("Adding Ops group %s", OpsGroup.groupname))
|
||||||
|
|
||||||
local groupdata={} --#AUFTRAG.GroupData
|
local groupdata={} --#AUFTRAG.GroupData
|
||||||
groupdata.opsgroup=OpsGroup
|
groupdata.opsgroup=OpsGroup
|
||||||
@@ -1818,7 +1818,7 @@ end
|
|||||||
-- @param #AUFTRAG self
|
-- @param #AUFTRAG self
|
||||||
-- @param Ops.OpsGroup#OPSGROUP OpsGroup The OPSGROUP object.
|
-- @param Ops.OpsGroup#OPSGROUP OpsGroup The OPSGROUP object.
|
||||||
function AUFTRAG:DelOpsGroup(OpsGroup)
|
function AUFTRAG:DelOpsGroup(OpsGroup)
|
||||||
self:I(self.lid..string.format("Removing OPS group %s", OpsGroup and OpsGroup.groupname or "nil (ERROR)!"))
|
self:T(self.lid..string.format("Removing OPS group %s", OpsGroup and OpsGroup.groupname or "nil (ERROR)!"))
|
||||||
|
|
||||||
if OpsGroup then
|
if OpsGroup then
|
||||||
|
|
||||||
@@ -2139,15 +2139,24 @@ function AUFTRAG:Evaluate()
|
|||||||
-- Mission had targets
|
-- Mission had targets
|
||||||
---
|
---
|
||||||
|
|
||||||
-- Number of current targets is still >0 ==> Not everything was destroyed.
|
-- Check if failed.
|
||||||
if self.type==AUFTRAG.Type.TROOPTRANSPORT then
|
if self.type==AUFTRAG.Type.TROOPTRANSPORT then
|
||||||
|
|
||||||
|
-- Transported groups have to survive.
|
||||||
if Ntargets<Ntargets0 then
|
if Ntargets<Ntargets0 then
|
||||||
failed=true
|
failed=true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
elseif self.type==AUFTRAG.Type.RESCUEHELO then
|
||||||
|
|
||||||
|
-- Rescue helo has to survive.
|
||||||
|
if self.Nelements==self.Ncasualties then
|
||||||
|
failed=true
|
||||||
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
|
-- Still targets left.
|
||||||
if Ntargets>0 then
|
if Ntargets>0 then
|
||||||
failed=true
|
failed=true
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -328,11 +328,13 @@ function FLIGHTGROUP:New(group)
|
|||||||
self:_InitGroup()
|
self:_InitGroup()
|
||||||
|
|
||||||
-- Start the status monitoring.
|
-- Start the status monitoring.
|
||||||
self:__CheckZone(-1)
|
self:__Status(-1)
|
||||||
self:__Status(-2)
|
|
||||||
self:__QueueUpdate(-3)
|
-- Start queue update timer.
|
||||||
|
self.timerQueueUpdate=TIMER:New(self._QueueUpdate, self):Start(2, 5)
|
||||||
--self.Timer=SCHEDULER:New()
|
|
||||||
|
-- Start check zone timer.
|
||||||
|
self.timerCheckZone=TIMER:New(self._CheckInZones, self):Start(3, 10)
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@@ -356,7 +358,7 @@ end
|
|||||||
-- @param Ops.AirWing#AIRWING airwing The AIRWING object.
|
-- @param Ops.AirWing#AIRWING airwing The AIRWING object.
|
||||||
-- @return #FLIGHTGROUP self
|
-- @return #FLIGHTGROUP self
|
||||||
function FLIGHTGROUP:SetAirwing(airwing)
|
function FLIGHTGROUP:SetAirwing(airwing)
|
||||||
self:I(self.lid..string.format("Add flight to AIRWING %s", airwing.alias))
|
self:T(self.lid..string.format("Add flight to AIRWING %s", airwing.alias))
|
||||||
self.airwing=airwing
|
self.airwing=airwing
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@@ -2409,6 +2411,9 @@ function FLIGHTGROUP:onafterStop(From, Event, To)
|
|||||||
self:UnHandleEvent(EVENTS.Ejection)
|
self:UnHandleEvent(EVENTS.Ejection)
|
||||||
self:UnHandleEvent(EVENTS.Crash)
|
self:UnHandleEvent(EVENTS.Crash)
|
||||||
self:UnHandleEvent(EVENTS.RemoveUnit)
|
self:UnHandleEvent(EVENTS.RemoveUnit)
|
||||||
|
|
||||||
|
self.timerCheckZone:Stop()
|
||||||
|
self.timerQueueUpdate:Stop()
|
||||||
|
|
||||||
self.CallScheduler:Clear()
|
self.CallScheduler:Clear()
|
||||||
|
|
||||||
@@ -2437,7 +2442,7 @@ end
|
|||||||
-- @param Wrapper.Group#GROUP group Group object.
|
-- @param Wrapper.Group#GROUP group Group object.
|
||||||
-- @param #FLIGHTGROUP flightgroup Flight group object.
|
-- @param #FLIGHTGROUP flightgroup Flight group object.
|
||||||
function FLIGHTGROUP._ReachedHolding(group, flightgroup)
|
function FLIGHTGROUP._ReachedHolding(group, flightgroup)
|
||||||
flightgroup:I(flightgroup.lid..string.format("Group reached holding point"))
|
flightgroup:T2(flightgroup.lid..string.format("Group reached holding point"))
|
||||||
|
|
||||||
-- Trigger Holding event.
|
-- Trigger Holding event.
|
||||||
flightgroup:__Holding(-1)
|
flightgroup:__Holding(-1)
|
||||||
@@ -2447,7 +2452,7 @@ end
|
|||||||
-- @param Wrapper.Group#GROUP group Group object.
|
-- @param Wrapper.Group#GROUP group Group object.
|
||||||
-- @param #FLIGHTGROUP flightgroup Flight group object.
|
-- @param #FLIGHTGROUP flightgroup Flight group object.
|
||||||
function FLIGHTGROUP._ClearedToLand(group, flightgroup)
|
function FLIGHTGROUP._ClearedToLand(group, flightgroup)
|
||||||
flightgroup:I(flightgroup.lid..string.format("Group was cleared to land"))
|
flightgroup:T2(flightgroup.lid..string.format("Group was cleared to land"))
|
||||||
|
|
||||||
-- Trigger Landing event.
|
-- Trigger Landing event.
|
||||||
flightgroup:__Landing(-1)
|
flightgroup:__Landing(-1)
|
||||||
@@ -2457,7 +2462,7 @@ end
|
|||||||
-- @param Wrapper.Group#GROUP group Group object.
|
-- @param Wrapper.Group#GROUP group Group object.
|
||||||
-- @param #FLIGHTGROUP flightgroup Flight group object.
|
-- @param #FLIGHTGROUP flightgroup Flight group object.
|
||||||
function FLIGHTGROUP._FinishedRefuelling(group, flightgroup)
|
function FLIGHTGROUP._FinishedRefuelling(group, flightgroup)
|
||||||
flightgroup:T(flightgroup.lid..string.format("Group finished refueling"))
|
flightgroup:T2(flightgroup.lid..string.format("Group finished refueling"))
|
||||||
|
|
||||||
-- Trigger Holding event.
|
-- Trigger Holding event.
|
||||||
flightgroup:__Refueled(-1)
|
flightgroup:__Refueled(-1)
|
||||||
@@ -2633,7 +2638,7 @@ function FLIGHTGROUP:AddElementByName(unitname)
|
|||||||
|
|
||||||
local text=string.format("Adding element %s: status=%s, skill=%s, modex=%s, fuelmass=%.1f (%d), category=%d, categoryname=%s, callsign=%s, ai=%s",
|
local text=string.format("Adding element %s: status=%s, skill=%s, modex=%s, fuelmass=%.1f (%d), category=%d, categoryname=%s, callsign=%s, ai=%s",
|
||||||
element.name, element.status, element.skill, element.modex, element.fuelmass, element.fuelrel*100, element.category, element.categoryname, element.callsign, tostring(element.ai))
|
element.name, element.status, element.skill, element.modex, element.fuelmass, element.fuelrel*100, element.category, element.categoryname, element.callsign, tostring(element.ai))
|
||||||
self:I(self.lid..text)
|
self:T(self.lid..text)
|
||||||
|
|
||||||
-- Add element to table.
|
-- Add element to table.
|
||||||
table.insert(self.elements, element)
|
table.insert(self.elements, element)
|
||||||
|
|||||||
@@ -154,10 +154,14 @@ function NAVYGROUP:New(GroupName)
|
|||||||
self:HandleEvent(EVENTS.RemoveUnit, self.OnEventRemoveUnit)
|
self:HandleEvent(EVENTS.RemoveUnit, self.OnEventRemoveUnit)
|
||||||
|
|
||||||
-- Start the status monitoring.
|
-- Start the status monitoring.
|
||||||
self:__CheckZone(-1)
|
self:__Status(-1)
|
||||||
self:__Status(-2)
|
|
||||||
self:__QueueUpdate(-3)
|
-- Start check zone timer.
|
||||||
|
self.timerCheckZone=TIMER:New(self._CheckInZones, self):Start(2, 5)
|
||||||
|
|
||||||
|
-- Start queue update timer.
|
||||||
|
self.timerQueueUpdate=TIMER:New(self._QueueUpdate, self):Start(3, 60)
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -505,7 +509,7 @@ end
|
|||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
-- @param #NAVYGROUP.Element Element The group element.
|
-- @param #NAVYGROUP.Element Element The group element.
|
||||||
function NAVYGROUP:onafterElementSpawned(From, Event, To, Element)
|
function NAVYGROUP:onafterElementSpawned(From, Event, To, Element)
|
||||||
self:I(self.lid..string.format("Element spawned %s", Element.name))
|
self:T(self.lid..string.format("Element spawned %s", Element.name))
|
||||||
|
|
||||||
-- Set element status.
|
-- Set element status.
|
||||||
self:_UpdateStatus(Element, OPSGROUP.ElementStatus.SPAWNED)
|
self:_UpdateStatus(Element, OPSGROUP.ElementStatus.SPAWNED)
|
||||||
@@ -531,7 +535,7 @@ end
|
|||||||
-- @param #string Event Event.
|
-- @param #string Event Event.
|
||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
function NAVYGROUP:onafterSpawned(From, Event, To)
|
function NAVYGROUP:onafterSpawned(From, Event, To)
|
||||||
self:I(self.lid..string.format("Group spawned!"))
|
self:T(self.lid..string.format("Group spawned!"))
|
||||||
|
|
||||||
if self.ai then
|
if self.ai then
|
||||||
|
|
||||||
@@ -652,7 +656,7 @@ function NAVYGROUP:onafterUpdateRoute(From, Event, To, n, Speed, Depth)
|
|||||||
|
|
||||||
if #waypoints>1 then
|
if #waypoints>1 then
|
||||||
|
|
||||||
self:I(self.lid..string.format("Updateing route: WP %d-->%d-->%d (#%d), Speed=%.1f knots, Depth=%d m",
|
self:T(self.lid..string.format("Updateing route: WP %d-->%d-->%d (#%d), Speed=%.1f knots, Depth=%d m",
|
||||||
self.currentwp, n, #self.waypoints, #waypoints-1, UTILS.MpsToKnots(self.speed), depth))
|
self.currentwp, n, #self.waypoints, #waypoints-1, UTILS.MpsToKnots(self.speed), depth))
|
||||||
|
|
||||||
|
|
||||||
@@ -710,7 +714,7 @@ end
|
|||||||
-- @param #string Event Event.
|
-- @param #string Event Event.
|
||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
function NAVYGROUP:onafterDetourReached(From, Event, To)
|
function NAVYGROUP:onafterDetourReached(From, Event, To)
|
||||||
self:I(self.lid.."Group reached detour coordinate.")
|
self:T(self.lid.."Group reached detour coordinate.")
|
||||||
end
|
end
|
||||||
|
|
||||||
--- On after "TurnIntoWind" event.
|
--- On after "TurnIntoWind" event.
|
||||||
@@ -770,7 +774,8 @@ end
|
|||||||
-- @param #boolean Uturn Return to the place we came from.
|
-- @param #boolean Uturn Return to the place we came from.
|
||||||
function NAVYGROUP:onafterTurnIntoWindOver(From, Event, To)
|
function NAVYGROUP:onafterTurnIntoWindOver(From, Event, To)
|
||||||
|
|
||||||
env.info("FF Turn Into Wind Over!")
|
-- Debug message.
|
||||||
|
self:T2(self.lid.."Turn Into Wind Over!")
|
||||||
|
|
||||||
self.intowind.Over=true
|
self.intowind.Over=true
|
||||||
self.intowind.Open=false
|
self.intowind.Open=false
|
||||||
@@ -779,10 +784,10 @@ function NAVYGROUP:onafterTurnIntoWindOver(From, Event, To)
|
|||||||
self:RemoveWaypointByID(self.intowind.waypoint.uid)
|
self:RemoveWaypointByID(self.intowind.waypoint.uid)
|
||||||
|
|
||||||
if self.intowind.Uturn then
|
if self.intowind.Uturn then
|
||||||
env.info("FF Turn Into Wind Over Uturn!")
|
self:T(self.lid.."Turn Into Wind Over ==> Uturn!")
|
||||||
self:Detour(self.intowind.Coordinate, self:GetSpeedCruise(), 0, true)
|
self:Detour(self.intowind.Coordinate, self:GetSpeedCruise(), 0, true)
|
||||||
else
|
else
|
||||||
env.info("FF Turn Into Wind Over Next WP!")
|
self:T(self.lid.."FF Turn Into Wind Over ==> Next WP!")
|
||||||
local indx=self:GetWaypointIndexNext()
|
local indx=self:GetWaypointIndexNext()
|
||||||
local speed=self:GetWaypointSpeed(indx)
|
local speed=self:GetWaypointSpeed(indx)
|
||||||
self:__UpdateRoute(-1, indx, speed)
|
self:__UpdateRoute(-1, indx, speed)
|
||||||
@@ -1041,7 +1046,7 @@ function NAVYGROUP:AddWaypoint(Coordinate, Speed, AfterWaypointWithID, Depth, Up
|
|||||||
-- Check if a coordinate was given or at least a positionable.
|
-- Check if a coordinate was given or at least a positionable.
|
||||||
if not Coordinate:IsInstanceOf("COORDINATE") then
|
if not Coordinate:IsInstanceOf("COORDINATE") then
|
||||||
if Coordinate:IsInstanceOf("POSITIONABLE") or Coordinate:IsInstanceOf("ZONE_BASE") then
|
if Coordinate:IsInstanceOf("POSITIONABLE") or Coordinate:IsInstanceOf("ZONE_BASE") then
|
||||||
self:I(self.lid.."WARNING: Coordinate is not a COORDINATE but a POSITIONABLE. Trying to get coordinate")
|
self:T(self.lid.."WARNING: Coordinate is not a COORDINATE but a POSITIONABLE. Trying to get coordinate")
|
||||||
Coordinate=Coordinate:GetCoordinate()
|
Coordinate=Coordinate:GetCoordinate()
|
||||||
else
|
else
|
||||||
self:E(self.lid.."ERROR: Coordinate is neither a COORDINATE nor any POSITIONABLE!")
|
self:E(self.lid.."ERROR: Coordinate is neither a COORDINATE nor any POSITIONABLE!")
|
||||||
@@ -1070,7 +1075,7 @@ function NAVYGROUP:AddWaypoint(Coordinate, Speed, AfterWaypointWithID, Depth, Up
|
|||||||
self:_AddWaypoint(waypoint, wpnumber)
|
self:_AddWaypoint(waypoint, wpnumber)
|
||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
self:I(self.lid..string.format("Adding NAVAL waypoint index=%d uid=%d, speed=%.1f knots. Last waypoint passed was #%d. Total waypoints #%d", wpnumber, waypoint.uid, Speed, self.currentwp, #self.waypoints))
|
self:T(self.lid..string.format("Adding NAVAL waypoint index=%d uid=%d, speed=%.1f knots. Last waypoint passed was #%d. Total waypoints #%d", wpnumber, waypoint.uid, Speed, self.currentwp, #self.waypoints))
|
||||||
|
|
||||||
-- Update route.
|
-- Update route.
|
||||||
if Updateroute==nil or Updateroute==true then
|
if Updateroute==nil or Updateroute==true then
|
||||||
|
|||||||
@@ -45,6 +45,8 @@
|
|||||||
-- @field #boolean respawning Group is being respawned.
|
-- @field #boolean respawning Group is being respawned.
|
||||||
-- @field Core.Set#SET_ZONE checkzones Set of zones.
|
-- @field Core.Set#SET_ZONE checkzones Set of zones.
|
||||||
-- @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 Core.Timer#TIMER timerCheckZone Timer for check zones.
|
||||||
|
-- @field Core.Timer#TIMER timerQueueUpdate Timer for queue updates.
|
||||||
-- @field #boolean groupinitialized If true, group parameters were initialized.
|
-- @field #boolean groupinitialized If true, group parameters were initialized.
|
||||||
-- @field #boolean detectionOn If true, detected units of the group are analyzed.
|
-- @field #boolean detectionOn If true, detected units of the group are analyzed.
|
||||||
-- @field Ops.Auftrag#AUFTRAG missionpaused Paused mission.
|
-- @field Ops.Auftrag#AUFTRAG missionpaused Paused mission.
|
||||||
@@ -315,7 +317,6 @@ function OPSGROUP:New(Group)
|
|||||||
self:AddTransition("*", "Stop", "Stopped") -- Stop FSM.
|
self:AddTransition("*", "Stop", "Stopped") -- Stop FSM.
|
||||||
|
|
||||||
self:AddTransition("*", "Status", "*") -- Status update.
|
self:AddTransition("*", "Status", "*") -- Status update.
|
||||||
self:AddTransition("*", "QueueUpdate", "*") -- Update task and mission queues.
|
|
||||||
|
|
||||||
self:AddTransition("*", "UpdateRoute", "*") -- Update route of group. Only if airborne.
|
self:AddTransition("*", "UpdateRoute", "*") -- Update route of group. Only if airborne.
|
||||||
self:AddTransition("*", "Respawn", "*") -- Respawn group.
|
self:AddTransition("*", "Respawn", "*") -- Respawn group.
|
||||||
@@ -335,7 +336,6 @@ function OPSGROUP:New(Group)
|
|||||||
self:AddTransition("*", "OutOfBombs", "*") -- Group is out of bombs.
|
self:AddTransition("*", "OutOfBombs", "*") -- Group is out of bombs.
|
||||||
self:AddTransition("*", "OutOfMissiles", "*") -- Group is out of missiles.
|
self:AddTransition("*", "OutOfMissiles", "*") -- Group is out of missiles.
|
||||||
|
|
||||||
self:AddTransition("*", "CheckZone", "*") -- Check if group enters/leaves a certain zone.
|
|
||||||
self:AddTransition("*", "EnterZone", "*") -- Group entered a certain zone.
|
self:AddTransition("*", "EnterZone", "*") -- Group entered a certain zone.
|
||||||
self:AddTransition("*", "LeaveZone", "*") -- Group leaves a certain zone.
|
self:AddTransition("*", "LeaveZone", "*") -- Group leaves a certain zone.
|
||||||
|
|
||||||
@@ -1038,7 +1038,7 @@ function OPSGROUP:RemoveWaypoint(wpindex)
|
|||||||
local n=#self.waypoints
|
local n=#self.waypoints
|
||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
self:I(self.lid..string.format("Removing waypoint index %d, current wp index %d. N %d-->%d", wpindex, self.currentwp, N, n))
|
self:T(self.lid..string.format("Removing waypoint index %d, current wp index %d. N %d-->%d", wpindex, self.currentwp, N, n))
|
||||||
|
|
||||||
-- Waypoint was not reached yet.
|
-- Waypoint was not reached yet.
|
||||||
if wpindex > self.currentwp then
|
if wpindex > self.currentwp then
|
||||||
@@ -1188,7 +1188,7 @@ function OPSGROUP:AddTask(task, clock, description, prio, duration)
|
|||||||
table.insert(self.taskqueue, newtask)
|
table.insert(self.taskqueue, newtask)
|
||||||
|
|
||||||
-- Info.
|
-- Info.
|
||||||
self:I(self.lid..string.format("Adding SCHEDULED task %s starting at %s", newtask.description, UTILS.SecondsToClock(newtask.time, true)))
|
self:T(self.lid..string.format("Adding SCHEDULED task %s starting at %s", newtask.description, UTILS.SecondsToClock(newtask.time, true)))
|
||||||
self:T3({newtask=newtask})
|
self:T3({newtask=newtask})
|
||||||
|
|
||||||
return newtask
|
return newtask
|
||||||
@@ -1475,7 +1475,7 @@ function OPSGROUP:onafterTaskExecute(From, Event, To, Task)
|
|||||||
|
|
||||||
-- Debug message.
|
-- Debug message.
|
||||||
local text=string.format("Task %s ID=%d execute", tostring(Task.description), Task.id)
|
local text=string.format("Task %s ID=%d execute", tostring(Task.description), Task.id)
|
||||||
self:I(self.lid..text)
|
self:T(self.lid..text)
|
||||||
|
|
||||||
-- Cancel current task if there is any.
|
-- Cancel current task if there is any.
|
||||||
if self.taskcurrent>0 then
|
if self.taskcurrent>0 then
|
||||||
@@ -1585,7 +1585,7 @@ function OPSGROUP:onafterTaskCancel(From, Event, To, Task)
|
|||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
local text=string.format("Current task %s ID=%d cancelled (flag %s=%d)", Task.description, Task.id, Task.stopflag:GetName(), stopflag)
|
local text=string.format("Current task %s ID=%d cancelled (flag %s=%d)", Task.description, Task.id, Task.stopflag:GetName(), stopflag)
|
||||||
self:I(self.lid..text)
|
self:T(self.lid..text)
|
||||||
|
|
||||||
-- Set stop flag. When the flag is true, the _TaskDone function is executed and calls :TaskDone()
|
-- Set stop flag. When the flag is true, the _TaskDone function is executed and calls :TaskDone()
|
||||||
Task.stopflag:Set(1)
|
Task.stopflag:Set(1)
|
||||||
@@ -1601,7 +1601,7 @@ function OPSGROUP:onafterTaskCancel(From, Event, To, Task)
|
|||||||
else
|
else
|
||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
self:I(self.lid..string.format("TaskCancel: Setting task %s ID=%d to DONE", Task.description, Task.id))
|
self:T(self.lid..string.format("TaskCancel: Setting task %s ID=%d to DONE", Task.description, Task.id))
|
||||||
|
|
||||||
-- Call task done function.
|
-- Call task done function.
|
||||||
self:TaskDone(Task)
|
self:TaskDone(Task)
|
||||||
@@ -1645,7 +1645,7 @@ function OPSGROUP:onafterTaskDone(From, Event, To, Task)
|
|||||||
|
|
||||||
-- Debug message.
|
-- Debug message.
|
||||||
local text=string.format("Task done: %s ID=%d", Task.description, Task.id)
|
local text=string.format("Task done: %s ID=%d", Task.description, Task.id)
|
||||||
self:I(self.lid..text)
|
self:T(self.lid..text)
|
||||||
|
|
||||||
-- No current task.
|
-- No current task.
|
||||||
if Task.id==self.taskcurrent then
|
if Task.id==self.taskcurrent then
|
||||||
@@ -1703,7 +1703,7 @@ function OPSGROUP:AddMission(Mission)
|
|||||||
-- Info text.
|
-- Info text.
|
||||||
local text=string.format("Added %s mission %s starting at %s, stopping at %s",
|
local text=string.format("Added %s mission %s starting at %s, stopping at %s",
|
||||||
tostring(Mission.type), tostring(Mission.name), UTILS.SecondsToClock(Mission.Tstart, true), Mission.Tstop and UTILS.SecondsToClock(Mission.Tstop, true) or "INF")
|
tostring(Mission.type), tostring(Mission.name), UTILS.SecondsToClock(Mission.Tstart, true), Mission.Tstop and UTILS.SecondsToClock(Mission.Tstop, true) or "INF")
|
||||||
self:I(self.lid..text)
|
self:T(self.lid..text)
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@@ -2015,7 +2015,7 @@ function OPSGROUP:onafterMissionCancel(From, Event, To, Mission)
|
|||||||
local Task=Mission:GetGroupWaypointTask(self)
|
local Task=Mission:GetGroupWaypointTask(self)
|
||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
self:I(self.lid..string.format("Cancel current mission %s. Task=%s", tostring(Mission.name), tostring(Task and Task.description or "WTF")))
|
self:T(self.lid..string.format("Cancel current mission %s. Task=%s", tostring(Mission.name), tostring(Task and Task.description or "WTF")))
|
||||||
|
|
||||||
-- Cancelling the mission is actually cancelling the current task.
|
-- Cancelling the mission is actually cancelling the current task.
|
||||||
-- Note that two things can happen.
|
-- Note that two things can happen.
|
||||||
@@ -2053,7 +2053,7 @@ function OPSGROUP:onafterMissionDone(From, Event, To, Mission)
|
|||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
local text=string.format("Mission %s DONE!", Mission.name)
|
local text=string.format("Mission %s DONE!", Mission.name)
|
||||||
self:I(self.lid..text)
|
self:T(self.lid..text)
|
||||||
|
|
||||||
-- Set group status.
|
-- Set group status.
|
||||||
Mission:SetGroupStatus(self, AUFTRAG.GroupStatus.DONE)
|
Mission:SetGroupStatus(self, AUFTRAG.GroupStatus.DONE)
|
||||||
@@ -2196,10 +2196,9 @@ end
|
|||||||
|
|
||||||
--- On after "QueueUpdate" event.
|
--- On after "QueueUpdate" event.
|
||||||
-- @param #OPSGROUP self
|
-- @param #OPSGROUP self
|
||||||
-- @param #string From From state.
|
function OPSGROUP:_QueueUpdate()
|
||||||
-- @param #string Event Event.
|
|
||||||
-- @param #string To To state.
|
--env.info(self.lid.."FF queueupdate T="..timer.getTime())
|
||||||
function OPSGROUP:onafterQueueUpdate(From, Event, To)
|
|
||||||
|
|
||||||
---
|
---
|
||||||
-- Mission
|
-- Mission
|
||||||
@@ -2253,10 +2252,6 @@ function OPSGROUP:onafterQueueUpdate(From, Event, To)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Update queue every ~5 sec.
|
|
||||||
if not self:IsStopped() then
|
|
||||||
self:__QueueUpdate(-5)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -2427,22 +2422,6 @@ function OPSGROUP:onafterLeaveZone(From, Event, To, Zone)
|
|||||||
self.inzones:Remove(zonename, true)
|
self.inzones:Remove(zonename, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- On after "CheckZone" event.
|
|
||||||
-- @param #OPSGROUP self
|
|
||||||
-- @param #string From From state.
|
|
||||||
-- @param #string Event Event.
|
|
||||||
-- @param #string To To state.
|
|
||||||
function OPSGROUP:onafterCheckZone(From, Event, To)
|
|
||||||
|
|
||||||
if self:IsAlive()==true then
|
|
||||||
self:_CheckInZones()
|
|
||||||
end
|
|
||||||
|
|
||||||
if not self:IsStopped() then
|
|
||||||
self:__CheckZone(-10)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- Internal Check Functions
|
-- Internal Check Functions
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -2451,7 +2430,7 @@ end
|
|||||||
-- @param #OPSGROUP self
|
-- @param #OPSGROUP self
|
||||||
function OPSGROUP:_CheckInZones()
|
function OPSGROUP:_CheckInZones()
|
||||||
|
|
||||||
if self.checkzones then
|
if self.checkzones and self:IsAlive() then
|
||||||
|
|
||||||
local Ncheck=self.checkzones:Count()
|
local Ncheck=self.checkzones:Count()
|
||||||
local Ninside=self.inzones:Count()
|
local Ninside=self.inzones:Count()
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
-- @field #table CategoryName Names of airbase categories.
|
-- @field #table CategoryName Names of airbase categories.
|
||||||
-- @field #string AirbaseName Name of the airbase.
|
-- @field #string AirbaseName Name of the airbase.
|
||||||
-- @field #number AirbaseID Airbase ID.
|
-- @field #number AirbaseID Airbase ID.
|
||||||
|
-- @field Core.Zone#ZONE AirbaseZone Circular zone around the airbase with a radius of 2500 meters. For ships this is a ZONE_UNIT object.
|
||||||
-- @field #number category Airbase category.
|
-- @field #number category Airbase category.
|
||||||
-- @field #table descriptors DCS descriptors.
|
-- @field #table descriptors DCS descriptors.
|
||||||
-- @field #boolean isAirdrome Airbase is an airdrome.
|
-- @field #boolean isAirdrome Airbase is an airdrome.
|
||||||
@@ -493,8 +494,14 @@ function AIRBASE:Register(AirbaseName)
|
|||||||
self:GetCoordinate()
|
self:GetCoordinate()
|
||||||
|
|
||||||
if vec2 then
|
if vec2 then
|
||||||
-- TODO: For ships we need a moving zone.
|
if self.isShip then
|
||||||
self.AirbaseZone=ZONE_RADIUS:New( AirbaseName, vec2, 2500 )
|
local unit=UNIT:FindByName(AirbaseName)
|
||||||
|
if unit then
|
||||||
|
self.AirbaseZone=ZONE_UNIT:New(AirbaseName, unit, 2500)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
self.AirbaseZone=ZONE_RADIUS:New(AirbaseName, vec2, 2500)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
self:E(string.format("ERROR: Cound not get position Vec2 of airbase %s", AirbaseName))
|
self:E(string.format("ERROR: Cound not get position Vec2 of airbase %s", AirbaseName))
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user