From b283406274c0b7221b6dea2e4aaa9752800b00d8 Mon Sep 17 00:00:00 2001 From: FlightControl Date: Sat, 23 Jul 2016 07:10:59 +0200 Subject: [PATCH] Updated Scheduler and documentation. -- Added SCHEDULER.Schedule method. -- Reworked SCHEDULER.New method. -- Renamed Mechanic to Mechanist. --- Moose Development/Moose/AIBalancer.lua | 22 +++---- Moose Development/Moose/AirbasePolice.lua | 4 +- Moose Development/Moose/Detection.lua | 9 ++- Moose Development/Moose/DetectionManager.lua | 2 +- Moose Development/Moose/Process.lua | 17 ++---- Moose Development/Moose/Scheduler.lua | 58 ++++++++++++------- Moose Development/Moose/Set.lua | 9 ++- .../l10n/DEFAULT/Moose.lua | 6 +- Moose Mission Setup/Moose.lua | 6 +- .../Moose_Test_FAC/l10n/DEFAULT/Moose.lua | 6 +- 10 files changed, 83 insertions(+), 56 deletions(-) diff --git a/Moose Development/Moose/AIBalancer.lua b/Moose Development/Moose/AIBalancer.lua index 8b9e32c20..c9bf675a9 100644 --- a/Moose Development/Moose/AIBalancer.lua +++ b/Moose Development/Moose/AIBalancer.lua @@ -23,22 +23,24 @@ -- 1.3) AIBALANCER allows AI to patrol specific zones: -- --------------------------------------------------- -- Use @{AIBalancer#AIBALANCER.SetPatrolZone}() to specify a zone where the AI needs to patrol. --- -- -- === -- --- CREDITS --- ======= --- **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 :-) +-- ### Contributions: -- --- **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. +-- * **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** +-- 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 --- @author FlightControl --- AIBALANCER class -- @type AIBALANCER diff --git a/Moose Development/Moose/AirbasePolice.lua b/Moose Development/Moose/AirbasePolice.lua index 9229a67cd..45a4dac05 100644 --- a/Moose Development/Moose/AirbasePolice.lua +++ b/Moose Development/Moose/AirbasePolice.lua @@ -49,8 +49,10 @@ -- * Creech -- * Groom Lake -- +-- ### Contributions: Dutch Baron - Concept & Testing +-- ### Author: FlightControl - Framework Design & Programming +-- -- @module AirbasePolice --- @author Flight Control & DUTCH BARON diff --git a/Moose Development/Moose/Detection.lua b/Moose Development/Moose/Detection.lua index 3e2783721..a68cf6109 100644 --- a/Moose Development/Moose/Detection.lua +++ b/Moose Development/Moose/Detection.lua @@ -63,8 +63,13 @@ -- -- === -- --- ### Contributions: Mechanic - Concept & Testing --- ### Authors: FlightControl : Design & Programming +-- ### Contributions: +-- +-- * Mechanist : Concept & Testing +-- +-- ### Authors: +-- +-- * FlightControl : Design & Programming -- -- @module Detection diff --git a/Moose Development/Moose/DetectionManager.lua b/Moose Development/Moose/DetectionManager.lua index 9c25cb542..29e4138b6 100644 --- a/Moose Development/Moose/DetectionManager.lua +++ b/Moose Development/Moose/DetectionManager.lua @@ -54,7 +54,7 @@ -- -- === -- --- ### Contributions: Mechanic, Prof_Hilactic, FlightControl - Concept & Testing +-- ### Contributions: Mechanist, Prof_Hilactic, FlightControl - Concept & Testing -- ### Author: FlightControl - Framework Design & Programming -- -- @module DetectionManager diff --git a/Moose Development/Moose/Process.lua b/Moose Development/Moose/Process.lua index 2f2e46801..dcee369b3 100644 --- a/Moose Development/Moose/Process.lua +++ b/Moose Development/Moose/Process.lua @@ -33,27 +33,20 @@ function PROCESS:New( ProcessName, Task, ProcessUnit ) self.Task = Task self.ProcessName = ProcessName - self.AllowEvents = true + self.ProcessScheduler = SCHEDULER:New( self.Fsm, self.NextEvent ) return self end --- @param #PROCESS self function PROCESS:NextEvent( NextEvent, ... ) - if self.AllowEvents == true then - self.ProcessScheduler = SCHEDULER:New( self.Fsm, NextEvent, arg, 1 ) - end + self.ProcessScheduler:Schedule( arg, 1 ) -- This schedules the next event, but only if scheduling is activated. end --- @param #PROCESS self -function PROCESS:StopEvents( ) - self:F2() - if self.ProcessScheduler then - self:E( "Stop" ) - self.ProcessScheduler:Stop() - self.ProcessScheduler = nil - self.AllowEvents = false - end +function PROCESS:StopEvents() + self:F( { "Stop Process ", self.ProcessName } ) + self.ProcessScheduler:Stop() end --- Adds a score for the PROCESS to be achieved. diff --git a/Moose Development/Moose/Scheduler.lua b/Moose Development/Moose/Scheduler.lua index afc2352f2..17a783791 100644 --- a/Moose Development/Moose/Scheduler.lua +++ b/Moose Development/Moose/Scheduler.lua @@ -17,8 +17,23 @@ -- * @{Scheduler#SCHEDULER.Start}: (Re-)Start 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 --- @author FlightControl --- The SCHEDULER class @@ -45,31 +60,34 @@ function SCHEDULER:New( TimeEventObject, TimeEventFunction, TimeEventFunctionArg self.TimeEventObject = TimeEventObject 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.StartSeconds = StartSeconds self.Repeat = false - - if RepeatSecondsInterval then - self.RepeatSecondsInterval = RepeatSecondsInterval - else - self.RepeatSecondsInterval = 0 - end - - if RandomizationFactor then - self.RandomizationFactor = RandomizationFactor - else - self.RandomizationFactor = 0 - end - - if StopSeconds then - self.StopSeconds = StopSeconds - end - + self.RepeatSecondsInterval = RepeatSecondsInterval or 0 + self.RandomizationFactor = RandomizationFactor or 0 + self.StopSeconds = StopSeconds self.StartTime = timer.getTime() - self:Start() - return self end diff --git a/Moose Development/Moose/Set.lua b/Moose Development/Moose/Set.lua index 1877542a4..92e333280 100644 --- a/Moose Development/Moose/Set.lua +++ b/Moose Development/Moose/Set.lua @@ -218,8 +218,15 @@ -- -- ==== -- +-- ### Contributions: +-- +-- * Mechanist : Concept & Testing +-- +-- ### Authors: +-- +-- * FlightControl : Design & Programming +-- -- @module Set --- @author FlightControl --- SET_BASE class diff --git a/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua b/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua index 21c7fa9fc..16f8660e2 100644 --- a/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua +++ b/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua @@ -22984,7 +22984,7 @@ end -- 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. --- * 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 � -- * Provide alerts when a missile would have killed your aircraft. -- * Provide alerts when the missile self destructs. -- * 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 -- -- @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 -- -- @module DetectionManager diff --git a/Moose Mission Setup/Moose.lua b/Moose Mission Setup/Moose.lua index 21c7fa9fc..16f8660e2 100644 --- a/Moose Mission Setup/Moose.lua +++ b/Moose Mission Setup/Moose.lua @@ -22984,7 +22984,7 @@ end -- 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. --- * 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 � -- * Provide alerts when a missile would have killed your aircraft. -- * Provide alerts when the missile self destructs. -- * 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 -- -- @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 -- -- @module DetectionManager diff --git a/Moose Test Missions/Moose_Test_FAC/Moose_Test_FAC/l10n/DEFAULT/Moose.lua b/Moose Test Missions/Moose_Test_FAC/Moose_Test_FAC/l10n/DEFAULT/Moose.lua index aa2ae1997..57fc377a6 100644 --- a/Moose Test Missions/Moose_Test_FAC/Moose_Test_FAC/l10n/DEFAULT/Moose.lua +++ b/Moose Test Missions/Moose_Test_FAC/Moose_Test_FAC/l10n/DEFAULT/Moose.lua @@ -22761,7 +22761,7 @@ end -- 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. --- * 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 � -- * Provide alerts when a missile would have killed your aircraft. -- * Provide alerts when the missile self destructs. -- * 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 -- -- @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 -- -- @module DetectionManager