Updated Scheduler and documentation.

-- Added SCHEDULER.Schedule method.
-- Reworked SCHEDULER.New method.
-- Renamed Mechanic to Mechanist.
This commit is contained in:
FlightControl 2016-07-23 07:10:59 +02:00
parent cf8d105b33
commit b283406274
10 changed files with 83 additions and 56 deletions

View File

@ -23,22 +23,24 @@
-- 1.3) AIBALANCER allows AI to patrol specific zones: -- 1.3) AIBALANCER allows AI to patrol specific zones:
-- --------------------------------------------------- -- ---------------------------------------------------
-- Use @{AIBalancer#AIBALANCER.SetPatrolZone}() to specify a zone where the AI needs to patrol. -- Use @{AIBalancer#AIBALANCER.SetPatrolZone}() to specify a zone where the AI needs to patrol.
--
-- --
-- === -- ===
-- --
-- CREDITS -- ### Contributions:
-- =======
-- **Dutch_Baron (James)** Who you can search on the Eagle Dynamics Forums.
-- Working together with James has resulted in the creation of the AIBALANCER class.
-- James has shared his ideas on balancing AI with air units, and together we made a first design which you can use now :-)
-- --
-- **SNAFU** -- * **Dutch_Baron (James)** Who you can search on the Eagle Dynamics Forums.
-- Had a couple of mails with the guys to validate, if the same concept in the GCI/CAP script could be reworked within MOOSE. -- Working together with James has resulted in the creation of the AIBALANCER class.
-- None of the script code has been used however within the new AIBALANCER moose class. -- James has shared his ideas on balancing AI with air units, and together we made a first design which you can use now :-)
--
-- * **SNAFU**
-- Had a couple of mails with the guys to validate, if the same concept in the GCI/CAP script could be reworked within MOOSE.
-- None of the script code has been used however within the new AIBALANCER moose class.
--
-- ### Authors:
--
-- * FlightControl - Framework Design & Programming
-- --
-- @module AIBalancer -- @module AIBalancer
-- @author FlightControl
--- AIBALANCER class --- AIBALANCER class
-- @type AIBALANCER -- @type AIBALANCER

View File

@ -49,8 +49,10 @@
-- * Creech -- * Creech
-- * Groom Lake -- * Groom Lake
-- --
-- ### Contributions: Dutch Baron - Concept & Testing
-- ### Author: FlightControl - Framework Design & Programming
--
-- @module AirbasePolice -- @module AirbasePolice
-- @author Flight Control & DUTCH BARON

View File

@ -63,8 +63,13 @@
-- --
-- === -- ===
-- --
-- ### Contributions: Mechanic - Concept & Testing -- ### Contributions:
-- ### Authors: FlightControl : Design & Programming --
-- * Mechanist : Concept & Testing
--
-- ### Authors:
--
-- * FlightControl : Design & Programming
-- --
-- @module Detection -- @module Detection

View File

@ -54,7 +54,7 @@
-- --
-- === -- ===
-- --
-- ### Contributions: Mechanic, Prof_Hilactic, FlightControl - Concept & Testing -- ### Contributions: Mechanist, Prof_Hilactic, FlightControl - Concept & Testing
-- ### Author: FlightControl - Framework Design & Programming -- ### Author: FlightControl - Framework Design & Programming
-- --
-- @module DetectionManager -- @module DetectionManager

View File

@ -33,27 +33,20 @@ function PROCESS:New( ProcessName, Task, ProcessUnit )
self.Task = Task self.Task = Task
self.ProcessName = ProcessName self.ProcessName = ProcessName
self.AllowEvents = true self.ProcessScheduler = SCHEDULER:New( self.Fsm, self.NextEvent )
return self return self
end end
--- @param #PROCESS self --- @param #PROCESS self
function PROCESS:NextEvent( NextEvent, ... ) function PROCESS:NextEvent( NextEvent, ... )
if self.AllowEvents == true then self.ProcessScheduler:Schedule( arg, 1 ) -- This schedules the next event, but only if scheduling is activated.
self.ProcessScheduler = SCHEDULER:New( self.Fsm, NextEvent, arg, 1 )
end
end end
--- @param #PROCESS self --- @param #PROCESS self
function PROCESS:StopEvents( ) function PROCESS:StopEvents()
self:F2() self:F( { "Stop Process ", self.ProcessName } )
if self.ProcessScheduler then self.ProcessScheduler:Stop()
self:E( "Stop" )
self.ProcessScheduler:Stop()
self.ProcessScheduler = nil
self.AllowEvents = false
end
end end
--- Adds a score for the PROCESS to be achieved. --- Adds a score for the PROCESS to be achieved.

View File

@ -17,8 +17,23 @@
-- * @{Scheduler#SCHEDULER.Start}: (Re-)Start the scheduler. -- * @{Scheduler#SCHEDULER.Start}: (Re-)Start the scheduler.
-- * @{Scheduler#SCHEDULER.Stop}: Stop the scheduler. -- * @{Scheduler#SCHEDULER.Stop}: Stop the scheduler.
-- --
-- 1.3) Reschedule new time event
-- ------------------------------
-- With @{Scheduler#SCHEDULER.Schedule} a new time event can be scheduled.
--
-- ===
--
-- ### Contributions:
--
-- * Mechanist : Concept & Testing
--
-- ### Authors:
--
-- * FlightControl : Design & Programming
--
-- ===
--
-- @module Scheduler -- @module Scheduler
-- @author FlightControl
--- The SCHEDULER class --- The SCHEDULER class
@ -45,31 +60,34 @@ function SCHEDULER:New( TimeEventObject, TimeEventFunction, TimeEventFunctionArg
self.TimeEventObject = TimeEventObject self.TimeEventObject = TimeEventObject
self.TimeEventFunction = TimeEventFunction self.TimeEventFunction = TimeEventFunction
self:Schedule( TimeEventFunctionArguments, StartSeconds, RepeatSecondsInterval, RandomizationFactor, StopSeconds )
self:Start()
return self
end
--- Schedule a new time event. Note that the schedule will only take place if the scheduler is *started*. Even for a single schedule event, the scheduler needs to be started also.
-- @param #SCHEDULER self
-- @param #table TimeEventFunctionArguments Optional arguments that can be given as part of scheduler. The arguments need to be given as a table { param1, param 2, ... }.
-- @param #number StartSeconds Specifies the amount of seconds that will be waited before the scheduling is started, and the event function is called.
-- @param #number RepeatSecondsInterval Specifies the interval in seconds when the scheduler will call the event function.
-- @param #number RandomizationFactor Specifies a randomization factor between 0 and 1 to randomize the RepeatSecondsInterval.
-- @param #number StopSeconds Specifies the amount of seconds when the scheduler will be stopped.
-- @return #SCHEDULER self
function SCHEDULER:Schedule( TimeEventFunctionArguments, StartSeconds, RepeatSecondsInterval, RandomizationFactor, StopSeconds )
self:F2( { TimeEventFunctionArguments, StartSeconds, RepeatSecondsInterval, RandomizationFactor, StopSeconds } )
self.TimeEventFunctionArguments = TimeEventFunctionArguments self.TimeEventFunctionArguments = TimeEventFunctionArguments
self.StartSeconds = StartSeconds self.StartSeconds = StartSeconds
self.Repeat = false self.Repeat = false
self.RepeatSecondsInterval = RepeatSecondsInterval or 0
if RepeatSecondsInterval then self.RandomizationFactor = RandomizationFactor or 0
self.RepeatSecondsInterval = RepeatSecondsInterval self.StopSeconds = StopSeconds
else
self.RepeatSecondsInterval = 0
end
if RandomizationFactor then
self.RandomizationFactor = RandomizationFactor
else
self.RandomizationFactor = 0
end
if StopSeconds then
self.StopSeconds = StopSeconds
end
self.StartTime = timer.getTime() self.StartTime = timer.getTime()
self:Start()
return self return self
end end

View File

@ -218,8 +218,15 @@
-- --
-- ==== -- ====
-- --
-- ### Contributions:
--
-- * Mechanist : Concept & Testing
--
-- ### Authors:
--
-- * FlightControl : Design & Programming
--
-- @module Set -- @module Set
-- @author FlightControl
--- SET_BASE class --- SET_BASE class

View File

@ -22984,7 +22984,7 @@ end
-- It suports the following functionality: -- It suports the following functionality:
-- --
-- * Track the missiles fired at you and other players, providing bearing and range information of the missiles towards the airplanes. -- * Track the missiles fired at you and other players, providing bearing and range information of the missiles towards the airplanes.
-- * Provide alerts of missile launches, including detailed information of the units launching, including bearing, range -- * Provide alerts of missile launches, including detailed information of the units launching, including bearing, range <EFBFBD>
-- * Provide alerts when a missile would have killed your aircraft. -- * Provide alerts when a missile would have killed your aircraft.
-- * Provide alerts when the missile self destructs. -- * Provide alerts when the missile self destructs.
-- * Enable / Disable and Configure the Missile Trainer using the various menu options. -- * Enable / Disable and Configure the Missile Trainer using the various menu options.
@ -25434,7 +25434,7 @@ end
-- --
-- === -- ===
-- --
-- ### Contributions: Mechanic - Concept & Testing -- ### Contributions: Mechanist - Concept & Testing
-- ### Authors: FlightControl : Design & Programming -- ### Authors: FlightControl : Design & Programming
-- --
-- @module Detection -- @module Detection
@ -26405,7 +26405,7 @@ end
-- --
-- === -- ===
-- --
-- ### Contributions: Mechanic, Prof_Hilactic, FlightControl - Concept & Testing -- ### Contributions: Mechanist, Prof_Hilactic, FlightControl - Concept & Testing
-- ### Author: FlightControl - Framework Design & Programming -- ### Author: FlightControl - Framework Design & Programming
-- --
-- @module DetectionManager -- @module DetectionManager

View File

@ -22984,7 +22984,7 @@ end
-- It suports the following functionality: -- It suports the following functionality:
-- --
-- * Track the missiles fired at you and other players, providing bearing and range information of the missiles towards the airplanes. -- * Track the missiles fired at you and other players, providing bearing and range information of the missiles towards the airplanes.
-- * Provide alerts of missile launches, including detailed information of the units launching, including bearing, range -- * Provide alerts of missile launches, including detailed information of the units launching, including bearing, range <EFBFBD>
-- * Provide alerts when a missile would have killed your aircraft. -- * Provide alerts when a missile would have killed your aircraft.
-- * Provide alerts when the missile self destructs. -- * Provide alerts when the missile self destructs.
-- * Enable / Disable and Configure the Missile Trainer using the various menu options. -- * Enable / Disable and Configure the Missile Trainer using the various menu options.
@ -25434,7 +25434,7 @@ end
-- --
-- === -- ===
-- --
-- ### Contributions: Mechanic - Concept & Testing -- ### Contributions: Mechanist - Concept & Testing
-- ### Authors: FlightControl : Design & Programming -- ### Authors: FlightControl : Design & Programming
-- --
-- @module Detection -- @module Detection
@ -26405,7 +26405,7 @@ end
-- --
-- === -- ===
-- --
-- ### Contributions: Mechanic, Prof_Hilactic, FlightControl - Concept & Testing -- ### Contributions: Mechanist, Prof_Hilactic, FlightControl - Concept & Testing
-- ### Author: FlightControl - Framework Design & Programming -- ### Author: FlightControl - Framework Design & Programming
-- --
-- @module DetectionManager -- @module DetectionManager

View File

@ -22761,7 +22761,7 @@ end
-- It suports the following functionality: -- It suports the following functionality:
-- --
-- * Track the missiles fired at you and other players, providing bearing and range information of the missiles towards the airplanes. -- * Track the missiles fired at you and other players, providing bearing and range information of the missiles towards the airplanes.
-- * Provide alerts of missile launches, including detailed information of the units launching, including bearing, range -- * Provide alerts of missile launches, including detailed information of the units launching, including bearing, range <EFBFBD>
-- * Provide alerts when a missile would have killed your aircraft. -- * Provide alerts when a missile would have killed your aircraft.
-- * Provide alerts when the missile self destructs. -- * Provide alerts when the missile self destructs.
-- * Enable / Disable and Configure the Missile Trainer using the various menu options. -- * Enable / Disable and Configure the Missile Trainer using the various menu options.
@ -25211,7 +25211,7 @@ end
-- --
-- === -- ===
-- --
-- ### Contributions: Mechanic - Concept & Testing -- ### Contributions: Mechanist - Concept & Testing
-- ### Authors: FlightControl : Design & Programming -- ### Authors: FlightControl : Design & Programming
-- --
-- @module Detection -- @module Detection
@ -26184,7 +26184,7 @@ end
-- --
-- === -- ===
-- --
-- ### Contributions: Mechanic, Prof_Hilactic, FlightControl - Concept & Testing -- ### Contributions: Mechanist, Prof_Hilactic, FlightControl - Concept & Testing
-- ### Author: FlightControl - Framework Design & Programming -- ### Author: FlightControl - Framework Design & Programming
-- --
-- @module DetectionManager -- @module DetectionManager