diff --git a/Moose Development/Moose/Core/Set.lua b/Moose Development/Moose/Core/Set.lua index 58cb5c386..4304cb260 100644 --- a/Moose Development/Moose/Core/Set.lua +++ b/Moose Development/Moose/Core/Set.lua @@ -37,7 +37,7 @@ -- === -- -- ### Author: **FlightControl** --- ### Contributions: +-- ### Contributions: **funkyfranky** -- -- === -- @@ -48,9 +48,10 @@ do -- SET_BASE --- @type SET_BASE - -- @field #table Filter - -- @field #table Set - -- @field #table List + -- @field #table Filter Table of filters. + -- @field #table Set Table of objects. + -- @field #table Index Table of indicies. + -- @field #table List Unused table. -- @field Core.Scheduler#SCHEDULER CallScheduler -- @extends Core.Base#BASE @@ -77,6 +78,10 @@ do -- SET_BASE Set = {}, List = {}, Index = {}, + Database = nil, + CallScheduler=nil, + TimeInterval=nil, + YieldInterval=nil, } @@ -224,8 +229,8 @@ do -- SET_BASE --- Adds a @{Core.Base#BASE} object in the @{Core.Set#SET_BASE}, using a given ObjectName as the index. -- @param #SET_BASE self - -- @param #string ObjectName - -- @param Core.Base#BASE Object + -- @param #string ObjectName The name of the object. + -- @param Core.Base#BASE Object The object itself. -- @return Core.Base#BASE The added BASE Object. function SET_BASE:Add( ObjectName, Object ) self:F2( { ObjectName = ObjectName, Object = Object } ) @@ -234,9 +239,14 @@ do -- SET_BASE if self.Set[ObjectName] then self:Remove( ObjectName, true ) end + + -- Add object to set. self.Set[ObjectName] = Object + + -- Add Object name to Index. table.insert( self.Index, ObjectName ) + -- Trigger Added event. self:Added( ObjectName, Object ) end @@ -253,6 +263,81 @@ do -- SET_BASE end + + --- Get the *union* of two sets. + -- @param #SET_BASE self + -- @param Core.Set#SET_BASE SetB Set *B*. + -- @return Core.Set#SET_BASE The union set, i.e. contains objects that are in set *A* **or** in set *B*. + function SET_BASE:GetSetUnion(SetB) + + local union=SET_BASE:New() + + for _,ObjectA in pairs(self.Set) do + union:AddObject(ObjectA) + end + + for _,ObjectB in pairs(SetB.Set) do + union:AddObject(ObjectB) + end + + return union + end + + --- Get the *intersection* of this set, called *A*, and another set. + -- @param #SET_BASE self + -- @param Core.Set#SET_BASE SetB Set other set, called *B*. + -- @return Core.Set#SET_BASE A set of objects that is included in set *A* **and** in set *B*. + function SET_BASE:GetSetIntersection(SetB) + + local intersection=SET_BASE:New() + + local union=self:GetSetUnion(SetB) + + for _,Object in pairs(union.Set) do + if self:IsIncludeObject(Object) and SetB:IsIncludeObject(Object) then + intersection:AddObject(intersection) + end + end + + return intersection + end + + --- Get the *complement* of two sets. + -- @param #SET_BASE self + -- @param Core.Set#SET_BASE SetB Set other set, called *B*. + -- @return Core.Set#SET_BASE The set of objects that are in set *B* but **not** in this set *A*. + function SET_BASE:GetSetComplement(SetB) + + local complement=SET_BASE:New() + + local union=self:GetSetUnion(SetA, SetB) + + for _,Object in pairs(union.Set) do + if SetA:IsIncludeObject(Object) and SetB:IsIncludeObject(Object) then + intersection:Add(intersection) + end + end + + return intersection + end + + + --- Compare two sets. + -- @param #SET_BASE self + -- @param Core.Set#SET_BASE SetA First set. + -- @param Core.Set#SET_BASE SetB Set to be merged into first set. + -- @return Core.Set#SET_BASE The set of objects that are included in SetA and SetB. + function SET_BASE:CompareSets(SetA, SetB) + + for _,ObjectB in pairs(SetB.Set) do + if SetA:IsIncludeObject(ObjectB) then + SetA:Add(ObjectB) + end + end + + return SetA + end + @@ -712,7 +797,7 @@ do -- SET_BASE --end - --- Decides whether to include the Object + --- Decides whether to include the Object. -- @param #SET_BASE self -- @param #table Object -- @return #SET_BASE self @@ -721,6 +806,16 @@ do -- SET_BASE return true end + + --- Decides whether to include the Object. + -- @param #SET_BASE self + -- @param #table Object + -- @return #SET_BASE self + function SET_BASE:IsInSet(ObjectName) + self:F3( Object ) + + return true + end --- Gets a string with all the object names. -- @param #SET_BASE self diff --git a/Moose Development/Moose/Ops/AirWing.lua b/Moose Development/Moose/Ops/AirWing.lua index eb7cf8bd0..522a02349 100644 --- a/Moose Development/Moose/Ops/AirWing.lua +++ b/Moose Development/Moose/Ops/AirWing.lua @@ -76,6 +76,12 @@ AIRWING.Task={ TANKER="Tanker", } +--- Mission. +-- @type AIRWING.Mission +-- @field #string type Mission type. +-- @field #string squadname Name of the assigned squadron. +-- @field #number nassets Number of required assets. + --- AIRWING class version. -- @field #string version AIRWING.version="0.0.5" @@ -92,7 +98,7 @@ AIRWING.version="0.0.5" --- Create a new AIRWING class object for a specific aircraft carrier unit. -- @param #AIRWING self --- @param #string warehousename Name of the warehouse static or unit object. +-- @param #string warehousename Name of the warehouse static or unit object representing the warehouse. -- @param #string airwingname Name of the air wing, e.g. "AIRWING-8". -- @return #AIRWING self function AIRWING:New(warehousename, airwingname) @@ -116,6 +122,9 @@ function AIRWING:New(warehousename, airwingname) -- Add FSM transitions. -- From State --> Event --> To State self:AddTransition("*", "AirwingStatus", "*") -- AIRWING status update. + + self:AddTransition("*", "NewMission", "*") -- Request CAP flight. + self:AddTransition("*", "RequestCAP", "*") -- Request CAP flight. self:AddTransition("*", "RequestIntercept", "*") -- Request Intercept. self:AddTransition("*", "RequestCAS", "*") -- Request CAS. @@ -178,20 +187,6 @@ end -- User Functions ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---- Optimized F10 radio menu for a single carrier. The menu entries will be stored directly under F10 Other/Skipper/ and not F10 Other/Skipper/"Carrier Alias"/. --- **WARNING**: If you use this with two AIRWING objects/carriers, the radio menu will be screwed up! --- @param #AIRWING self --- @param #boolean switch If true or nil single menu is enabled. If false, menu is for multiple carriers in the mission. --- @return #AIRWING self -function AIRWING:SetMenuSingleCarrier(switch) - if switch==true or switch==nil then - self.menusingle=true - else - self.menusingle=false - end - return self -end - --- Add a squadron to the carrier air wing. -- @param #AIRWING self -- @param #string name Name of the squadron, e.g. "VFA-37". @@ -223,14 +218,6 @@ function AIRWING:AddFlightToSquadron(squadron, flightgroup, ngroups) local text=string.format("FF Adding asset %s to squadron %s", flightgroup:GetName(), squadron.name) env.info(text) - function self:OnAfterNewAsset(From, Event, To, asset, assignment) - local text=string.format("FF assignment=%s, squadron=%s", assignment, squadron.name) - env.info(text) - if assignment==squadron.name then - table.insert(squadron.assets, asset) - end - end - self:AddAsset(flightgroup, ngroups, nil, nil, nil, nil, nil, {squadron.livery}, squadron.name) return self @@ -321,6 +308,26 @@ end -- FSM Events ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +--- On after "SelfRequest" event. +-- @param #AIRWING self +function AIRWING:onafterNewAsset(From, Event, To, asset, assignment) + + -- Call parent warehouse function first. + self:GetParent(self).onafterNewAsset(From, Event, To, asset, assignment) + + local squad=self:GetSquadron(assignment) + + if squad then + + local text=string.format("FF assignment=%s, squadron=%s", assignment, squad.name) + env.info(text) + + table.insert(squad.assets, asset) + + end +end + + --- On after "SelfRequest" event. -- @param #AIRWING self function AIRWING:onafterSelfRequest(From, Event, To, Groupset, Request) diff --git a/Moose Development/Moose/Ops/Aufklaerung.lua b/Moose Development/Moose/Ops/Aufklaerung.lua index 476b1ce85..35b3d3dcf 100644 --- a/Moose Development/Moose/Ops/Aufklaerung.lua +++ b/Moose Development/Moose/Ops/Aufklaerung.lua @@ -1,4 +1,4 @@ ---- **Ops** - (R2.5) - AI Squadron for Ops. +--- **Ops** - Office of Military Intelligence. -- -- **Main Features:** -- @@ -7,72 +7,73 @@ -- === -- -- ### Author: **funkyfranky** --- @module Ops.Squadron --- @image OPS_Squadron.png +-- @module Ops.Intel +-- @image OPS_Intel.png ---- AUFKLAERUNG class. --- @type AUFKLAERUNG +--- INTEL class. +-- @type INTEL -- @field #string ClassName Name of the class. -- @field #boolean Debug Debug mode. Messages to all about status. --- @field #string sid Class id string for output to DCS log file. --- @field #string livery Livery of the squadron. --- @field #table flights Table of flight groups. +-- @field #string lid Class id string for output to DCS log file. -- @extends Core.Fsm#FSM --- Be surprised! -- -- === -- --- ![Banner Image](..\Presentations\CarrierAirWing\AUFKLAERUNG_Main.jpg) +-- ![Banner Image](..\Presentations\CarrierAirWing\INTEL_Main.jpg) -- --- # The AUFKLAERUNG Concept +-- # The INTEL Concept -- -- -- --- @field #AUFKLAERUNG -AUFKLAERUNG = { - ClassName = "AUFKLAERUNG", +-- @field #INTEL +INTEL = { + ClassName = "INTEL", Debug = nil, lid = nil, + filter = nil, detectionset = nil, detecteditems = {}, + DetectedGroups = {} } ---- Flight group element. --- @type AUFKLAERUNG.DetectedItem --- @field Ops.FlightGroup#FLIGHTGROUP flightgroup The flight group object. --- @field #string mission Mission assigned to the flight. +--- Detected item info. +-- @type INTEL.DetectedItem +-- @field #string typename Type name of detected item. +-- @field #number category +-- @field #string categeryname +-- @field #number Tdetected Time stamp when this item was last detected. ---- AUFKLAERUNG class version. +--- INTEL class version. -- @field #string version -AUFKLAERUNG.version="0.0.1" +INTEL.version="0.0.1" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --- TODO list +-- ToDo list ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --- TODO: Add tasks. --- TODO: +-- TODO: A lot! ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- Constructor ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---- Create a new AUFKLAERUNG object and start the FSM. --- @param #AUFKLAERUNG self +--- Create a new INTEL object and start the FSM. +-- @param #INTEL self -- @param Core.Set#SET_GROUP DetectionSet Set of detection groups. --- @return #AUFKLAERUNG self -function AUFKLAERUNG:New(DetectionSet) +-- @return #INTEL self +function INTEL:New(DetectionSet) - -- Inherit everything from WAREHOUSE class. - local self=BASE:Inherit(self, FSM:New()) -- #AUFKLAERUNG + -- Inherit everything from FSM class. + local self=BASE:Inherit(self, FSM:New()) -- #INTEL --self.flightgroup=AIGroup self.detectionset=DetectionSet -- Set some string id for output to DCS.log file. - self.lid=string.format("AUFKLAERUNG %s | ", self.squadronname) + self.lid=string.format("INTEL %s | ", self.squadronname) -- Start State. self:SetStartState("Stopped") @@ -83,40 +84,46 @@ function AUFKLAERUNG:New(DetectionSet) -- Add FSM transitions. -- From State --> Event --> To State self:AddTransition("Stopped", "Start", "Running") -- Start FSM. - self:AddTransition("*", "Status", "*") -- AUFKLAERUNG status update + self:AddTransition("*", "Status", "*") -- INTEL status update - self:AddTransition("*", "Detect", "*") -- AUFKLAERUNG status update + self:AddTransition("*", "Detect", "*") -- INTEL status update self:AddTransition("*", "DetectedUnit", "*") -- + + self:AddTransition("*", "DetectedGroups", "*") -- All groups that are currently detected. + self:AddTransition("*", "DetectedGroupsUnknown", "*") -- Newly detected groups, which were previously unknown. + self:AddTransition("*", "DetectedGroupsDead", "*") -- Previously detected groups that could not be detected any more. + self:AddTransition("*", "DetectedGroupsLost", "*") -- Previously detected groups that could not be detected any more. + ------------------------ --- Pseudo Functions --- ------------------------ - --- Triggers the FSM event "Start". Starts the AUFKLAERUNG. Initializes parameters and starts event handlers. - -- @function [parent=#AUFKLAERUNG] Start - -- @param #AUFKLAERUNG self + --- Triggers the FSM event "Start". Starts the INTEL. Initializes parameters and starts event handlers. + -- @function [parent=#INTEL] Start + -- @param #INTEL self - --- Triggers the FSM event "Start" after a delay. Starts the AUFKLAERUNG. Initializes parameters and starts event handlers. - -- @function [parent=#AUFKLAERUNG] __Start - -- @param #AUFKLAERUNG self + --- Triggers the FSM event "Start" after a delay. Starts the INTEL. Initializes parameters and starts event handlers. + -- @function [parent=#INTEL] __Start + -- @param #INTEL self -- @param #number delay Delay in seconds. - --- Triggers the FSM event "Stop". Stops the AUFKLAERUNG and all its event handlers. - -- @param #AUFKLAERUNG self + --- Triggers the FSM event "Stop". Stops the INTEL and all its event handlers. + -- @param #INTEL self - --- Triggers the FSM event "Stop" after a delay. Stops the AUFKLAERUNG and all its event handlers. - -- @function [parent=#AUFKLAERUNG] __Stop - -- @param #AUFKLAERUNG self + --- Triggers the FSM event "Stop" after a delay. Stops the INTEL and all its event handlers. + -- @function [parent=#INTEL] __Stop + -- @param #INTEL self -- @param #number delay Delay in seconds. - --- Triggers the FSM event "FlightStatus". - -- @function [parent=#AUFKLAERUNG] SquadronStatus - -- @param #AUFKLAERUNG self + --- Triggers the FSM event "Status". + -- @function [parent=#INTEL] Status + -- @param #INTEL self - --- Triggers the FSM event "SkipperStatus" after a delay. - -- @function [parent=#AUFKLAERUNG] __SquadronStatus - -- @param #AUFKLAERUNG self + --- Triggers the FSM event "Status" after a delay. + -- @function [parent=#INTEL] __Status + -- @param #INTEL self -- @param #number delay Delay in seconds. @@ -138,10 +145,10 @@ end ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --- Set livery. --- @param #AUFKLAERUNG self +-- @param #INTEL self -- @param #string liveryname Name of the livery. --- @return #AUFKLAERUNG self -function AUFKLAERUNG:SetLivery(liveryname) +-- @return #INTEL self +function INTEL:SetLivery(liveryname) self.livery=liveryname end @@ -151,12 +158,12 @@ end ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --- On after Start event. Starts the FLIGHTGROUP FSM and event handlers. --- @param #AUFKLAERUNG self +-- @param #INTEL self -- @param Wrapper.Group#GROUP Group Flight group. -- @param #string From From state. -- @param #string Event Event. -- @param #string To To state. -function AUFKLAERUNG:onafterStart(From, Event, To) +function INTEL:onafterStart(From, Event, To) -- Short info. local text=string.format("Starting flight group %s.", self.groupname) @@ -166,13 +173,13 @@ function AUFKLAERUNG:onafterStart(From, Event, To) self:__Status(-1) end ---- On after "FlightStatus" event. --- @param #AUFKLAERUNG self +--- On after "Status" event. +-- @param #INTEL self -- @param Wrapper.Group#GROUP Group Flight group. -- @param #string From From state. -- @param #string Event Event. -- @param #string To To state. -function AUFKLAERUNG:onafterSquadronStatus(From, Event, To) +function INTEL:onafterStatus(From, Event, To) -- FSM state. local fsmstate=self:GetState() @@ -188,16 +195,31 @@ function AUFKLAERUNG:onafterSquadronStatus(From, Event, To) end ---- On after "FlightStatus" event. --- @param #AUFKLAERUNG self -function AUFKLAERUNG:_CheckFlightstatus() +--- Update detected items. +-- @param #INTEL self +function INTEL:_UpdateIntel() - for _,_flight in pairs(self.flights) do - local flight=_flight --#AUFKLAERUNG.Flight + -- Set of all detected units. + local DetectedSet=SET_UNIT:New() + + -- Loop over all units providing intel. + for _,_recce in pairs(self.detectionset:GetSet()) do + local recce=_recce --Wrapper.Unit#UNIT - flight.flightgroup:IsSpawned() + -- Get set of detected units. + local detectedunitset=recce:GetDetectedUnitSet() + + -- Add detected units to all set. + DetectedSet=DetectedSet:GetSetUnion(detectedunitset) end + + local detectednew=DetectedSet:GetSetComplement(self.detectedunits) + + local detectedlost=self.detectedunits:GetSetComplement(DetectedSet) + + + end diff --git a/Moose Development/Moose/Ops/FlightGroup.lua b/Moose Development/Moose/Ops/FlightGroup.lua index 40dded704..ac8886f5e 100644 --- a/Moose Development/Moose/Ops/FlightGroup.lua +++ b/Moose Development/Moose/Ops/FlightGroup.lua @@ -447,6 +447,11 @@ function FLIGHTGROUP:New(groupname, autostart) self:AddTransition("*", "TaskDone", "*") -- Group finished a task. self:AddTransition("*", "TaskCancel", "*") -- Cancel current task. self:AddTransition("*", "TaskPause", "*") -- Pause current task. + + self:AddTransition("*", "MissionStart", "OnMission") -- Tanker is on station and ready to refuel. + self:AddTransition("OnMission", "MissionDone", "Airborne") -- Tanker is on station and ready to refuel. + self:AddTransition("OnMission", "MissionAbort", "Airborne") -- Tanker is on station and ready to refuel. + self:AddTransition("*", "ElementSpawned", "*") -- An element was spawned. self:AddTransition("*", "ElementParking", "*") -- An element is parking. diff --git a/Moose Development/Moose/Ops/Squadron.lua b/Moose Development/Moose/Ops/Squadron.lua index c4f8322fa..cf0f770c9 100644 --- a/Moose Development/Moose/Ops/Squadron.lua +++ b/Moose Development/Moose/Ops/Squadron.lua @@ -54,7 +54,6 @@ SQUADRON.version="0.0.1" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- TODO: Add tasks. --- TODO: ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- Constructor @@ -62,13 +61,12 @@ SQUADRON.version="0.0.1" --- Create a new SQUADRON object and start the FSM. -- @param #SQUADRON self --- @param #string squadronname Name of the squadron, e.g. "VFA-37". --- @param Wrapper.Airbase#AIRBASE airbase Home airbase object of the squadron. --- @param #table Table of squadron tasks, e.g. {SQUADRON.Task.INTERCEPT, SQUADRON.Task.SEAD}. +-- @param #string SquadName Name of the squadron, e.g. "VFA-37". +-- @param #table tasks Table of squadron tasks, e.g. `{SQUADRON.Task.INTERCEPT, SQUADRON.Task.SEAD}`. -- @return #SQUADRON self -function SQUADRON:New(squadronname, airbase, tasks) +function SQUADRON:New(squadronname) - -- Inherit everything from WAREHOUSE class. + -- Inherit everything from FSM class. local self=BASE:Inherit(self, FSM:New()) -- #SQUADRON --self.flightgroup=AIGroup @@ -93,13 +91,8 @@ function SQUADRON:New(squadronname, airbase, tasks) -- From State --> Event --> To State self:AddTransition("Stopped", "Start", "Running") -- Start FSM. - self:AddTransition("*", "SquadronStatus", "*") -- SQUADRON status update - - self:AddTransition("*", "DetectedUnit", "*") -- - - self:AddTransition("*", "FlightSpawned", "*") -- - self:AddTransition("*", "FlightAirborne", "*") -- - self:AddTransition("*", "FlightDead", "*") -- + self:AddTransition("*", "Status", "*") -- SQUADRON status update + ------------------------ --- Pseudo Functions --- @@ -122,12 +115,12 @@ function SQUADRON:New(squadronname, airbase, tasks) -- @param #SQUADRON self -- @param #number delay Delay in seconds. - --- Triggers the FSM event "FlightStatus". - -- @function [parent=#SQUADRON] SquadronStatus + --- Triggers the FSM event "Status". + -- @function [parent=#SQUADRON] Status -- @param #SQUADRON self - --- Triggers the FSM event "SkipperStatus" after a delay. - -- @function [parent=#SQUADRON] __SquadronStatus + --- Triggers the FSM event "Status" after a delay. + -- @function [parent=#SQUADRON] __Status -- @param #SQUADRON self -- @param #number delay Delay in seconds. @@ -157,6 +150,15 @@ function SQUADRON:SetLivery(liveryname) self.livery=liveryname end +--- Set home airbase. +-- @param #SQUADRON self +-- @param Wrapper.Airbase#AIRBASE airbase Home airbase object of the squadron. +-- @return #SQUADRON self +function SQUADRON:SetHomeBase(airbase) + self.homebase=airbase +end + + --- Add a group to the squadron. -- @param #SQUADRON self -- @param #string groupname Name of the group as defined in the mission editor. diff --git a/Moose Development/Moose/Ops/WingCommander.lua b/Moose Development/Moose/Ops/WingCommander.lua index 89c4c3567..86a6633c1 100644 --- a/Moose Development/Moose/Ops/WingCommander.lua +++ b/Moose Development/Moose/Ops/WingCommander.lua @@ -1,4 +1,4 @@ ---- **Ops** - (R2.5) - Wing Commander for Ops. +--- **Ops** - Commander Air Wing. -- -- **Main Features:** -- @@ -60,29 +60,19 @@ WINGCOMMANDER.version="0.0.1" --- Create a new WINGCOMMANDER object and start the FSM. -- @param #WINGCOMMANDER self --- @param #string squadronname Name of the squadron, e.g. "VFA-37". --- @param Wrapper.Airbase#AIRBASE airbase Home airbase object of the squadron. --- @param #table Table of squadron tasks, e.g. {WINGCOMMANDER.Task.INTERCEPT, WINGCOMMANDER.Task.SEAD}. +-- @param Core.Set#SET_UNITS AgentSet Set of agents (units) providing intel. -- @return #WINGCOMMANDER self -function WINGCOMMANDER:New(detection) +function WINGCOMMANDER:New(AgentSet) - -- Inherit everything from WAREHOUSE class. - local self=BASE:Inherit(self, FSM:New()) -- #WINGCOMMANDER - - --self.flightgroup=AIGroup - self.squadronname=tostring(squadronname) - - -- Set home airbase. - self.homebase=airbase + -- 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.sid=string.format("WINGCOMMANDER %s | ", self.squadronname) + self.lid=string.format("WINGCOMMANDER | ") -- Start State. self:SetStartState("Stopped") - -- Init set of detected units. - self.detectedunits=SET_UNIT:New() -- TODO Tasks? self.tasks=tasks or {} @@ -91,13 +81,8 @@ function WINGCOMMANDER:New(detection) -- From State --> Event --> To State self:AddTransition("Stopped", "Start", "Running") -- Start FSM. - self:AddTransition("*", "WingCommanderStatus", "*") -- WINGCOMMANDER status update - - self:AddTransition("*", "DetectedUnit", "*") -- - - self:AddTransition("*", "FlightSpawned", "*") -- - self:AddTransition("*", "FlightAirborne", "*") -- - self:AddTransition("*", "FlightDead", "*") -- + self:AddTransition("*", "Sitrep", "*") -- WINGCOMMANDER status update + ------------------------ --- Pseudo Functions --- @@ -173,7 +158,7 @@ function WINGCOMMANDER:onafterStart(From, Event, To) self:I(self.sid..text) -- Start the status monitoring. - self:__WingCommanderStatus(-1) + self:__SitRep(-1) end --- On after "FlightStatus" event. @@ -182,18 +167,62 @@ end -- @param #string From From state. -- @param #string Event Event. -- @param #string To To state. -function WINGCOMMANDER:onafterWingCommanderStatus(From, Event, To) +function WINGCOMMANDER:onafterSitrep(From, Event, To) -- FSM state. local fsmstate=self:GetState() - -- Check if group has detected any units. - self:_CheckFlightStatus() - -- Short info. - local text=string.format("Flight status %s [%d/%d]. Task=%d/%d. Waypoint=%d/%d. Detected=%d", fsmstate, #self.element, #self.element, self.taskcurrent, #self.taskqueue, self.currentwp or 0, #self.waypoints or 0, self.detectedunits:Count()) + local text=string.format("No activities") self:I(self.sid..text) + if DetectedGroupsUnknown then + + for _,_group in pairs(DetectedGroupsUnknown) do + local group=_group --Wrapper.Group#GROUP + + if group and group:IsAlive() then + + local category=group:GetCategory() + + if category==Group.Category.AIRPLANE or category==Group.Category.AIRPLANE then + + elseif category==Group.Category.GROUND then + + elseif category==Group.Category.SHIP then + + + + end + + + end + + end + + + end end +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +-- Resources +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + +--- Check resources. +-- @param #WINGCOMMANDER self +function WINGCOMMANDER:CheckResources() + + + for _,_airwing in pairs(self.airwings) do + local airwing=_airwing --Ops.AirWing#AIRWING + + airwing:GetFlightsWhoCan() + + + end + +end + + +