mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Updated documentation of SCHEDULER and ZONE and FSM
This commit is contained in:
@@ -2172,6 +2172,7 @@ self</p>
|
||||
<dl class="function">
|
||||
<dt>
|
||||
|
||||
<em>#number</em>
|
||||
<a id="#(DETECTION_BASE).DetectedItemCount" >
|
||||
<strong>DETECTION_BASE.DetectedItemCount</strong>
|
||||
</a>
|
||||
@@ -2185,6 +2186,7 @@ self</p>
|
||||
<dl class="function">
|
||||
<dt>
|
||||
|
||||
<em>#number</em>
|
||||
<a id="#(DETECTION_BASE).DetectedItemMax" >
|
||||
<strong>DETECTION_BASE.DetectedItemMax</strong>
|
||||
</a>
|
||||
|
||||
@@ -102,6 +102,8 @@ are design patterns allowing efficient (long-lasting) processes and workflows.</
|
||||
|
||||
<hr/>
|
||||
|
||||
<p>A Finite State Machine (FSM) models a process flow that transitions between various <strong>States</strong> through triggered <strong>Events</strong>.</p>
|
||||
|
||||
<p>A FSM can only be in one of a finite number of states.
|
||||
The machine is in only one state at a time; the state it is in at any given time is called the <strong>current state</strong>.
|
||||
It can change from one state to another when initiated by an <strong><strong>internal</strong> or <strong>external</strong> triggering event</strong>, which is called a <strong>transition</strong>.
|
||||
@@ -199,11 +201,9 @@ YYYY-MM-DD: CLASS:<strong>NewFunction( Params )</strong> added</p>
|
||||
<tr>
|
||||
<td class="name" nowrap="nowrap"><a href="#FSM">FSM</a></td>
|
||||
<td class="summary">
|
||||
<h1>1) FSM class, extends <a href="Base.html##(BASE)">Base#BASE</a></h1>
|
||||
<h1>FSM class, extends <a href="Base.html##(BASE)">Base#BASE</a></h1>
|
||||
|
||||
<p><img src="..\Presentations\FSM\Dia3.JPG" alt="Transition Rules and Transition Handlers and Event Triggers"/></p>
|
||||
|
||||
<p>The FSM class is the base class of all FSM_ derived classes.</p>
|
||||
<p>A Finite State Machine (FSM) models a process flow that transitions between various <strong>States</strong> through triggered <strong>Events</strong>.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -726,14 +726,52 @@ YYYY-MM-DD: CLASS:<strong>NewFunction( Params )</strong> added</p>
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<h1>1) FSM class, extends <a href="Base.html##(BASE)">Base#BASE</a></h1>
|
||||
<h1>FSM class, extends <a href="Base.html##(BASE)">Base#BASE</a></h1>
|
||||
|
||||
<p>A Finite State Machine (FSM) models a process flow that transitions between various <strong>States</strong> through triggered <strong>Events</strong>.</p>
|
||||
|
||||
|
||||
|
||||
<p>A FSM can only be in one of a finite number of states.
|
||||
The machine is in only one state at a time; the state it is in at any given time is called the <strong>current state</strong>.
|
||||
It can change from one state to another when initiated by an <strong><strong>internal</strong> or <strong>external</strong> triggering event</strong>, which is called a <strong>transition</strong>.
|
||||
An <strong>FSM implementation</strong> is defined by <strong>a list of its states</strong>, <strong>its initial state</strong>, and <strong>the triggering events</strong> for <strong>each possible transition</strong>.
|
||||
An FSM implementation is composed out of <strong>two parts</strong>, a set of <strong>state transition rules</strong>, and an implementation set of <strong>state transition handlers</strong>, implementing those transitions.</p>
|
||||
|
||||
<p>The FSM class supports a <strong>hierarchical implementation of a Finite State Machine</strong>,
|
||||
that is, it allows to <strong>embed existing FSM implementations in a master FSM</strong>.
|
||||
FSM hierarchies allow for efficient FSM re-use, <strong>not having to re-invent the wheel every time again</strong> when designing complex processes.</p>
|
||||
|
||||
<p><img src="..\Presentations\FSM\Dia2.JPG" alt="Workflow Example"/></p>
|
||||
|
||||
<p>The above diagram shows a graphical representation of a FSM implementation for a <strong>Task</strong>, which guides a Human towards a Zone,
|
||||
orders him to destroy x targets and account the results.
|
||||
Other examples of ready made FSM could be: </p>
|
||||
|
||||
<ul>
|
||||
<li>route a plane to a zone flown by a human</li>
|
||||
<li>detect targets by an AI and report to humans</li>
|
||||
<li>account for destroyed targets by human players</li>
|
||||
<li>handle AI infantry to deploy from or embark to a helicopter or airplane or vehicle </li>
|
||||
<li>let an AI patrol a zone</li>
|
||||
</ul>
|
||||
|
||||
<p>The <strong>MOOSE framework</strong> uses extensively the FSM class and derived FSM_ classes,
|
||||
because <strong>the goal of MOOSE is to simplify mission design complexity for mission building</strong>.
|
||||
By efficiently utilizing the FSM class and derived classes, MOOSE allows mission designers to quickly build processes.
|
||||
<strong>Ready made FSM-based implementations classes</strong> exist within the MOOSE framework that <strong>can easily be re-used,
|
||||
and tailored</strong> by mission designers through <strong>the implementation of Transition Handlers</strong>.
|
||||
Each of these FSM implementation classes start either with:</p>
|
||||
|
||||
<ul>
|
||||
<li>an acronym <strong>AI_</strong>, which indicates an FSM implementation directing <strong>AI controlled</strong> <a href="GROUP.html">GROUP</a> and/or <a href="UNIT.html">UNIT</a>. These AI_ classes derive the <a href="##(FSM_CONTROLLABLE)">#FSM_CONTROLLABLE</a> class.</li>
|
||||
<li>an acronym <strong>TASK_</strong>, which indicates an FSM implementation executing a <a href="TASK.html">TASK</a> executed by Groups of players. These TASK_ classes derive the <a href="##(FSM_TASK)">#FSM_TASK</a> class.</li>
|
||||
<li>an acronym <strong>ACT_</strong>, which indicates an Sub-FSM implementation, directing <strong>Humans actions</strong> that need to be done in a <a href="TASK.html">TASK</a>, seated in a <a href="CLIENT.html">CLIENT</a> (slot) or a <a href="UNIT.html">UNIT</a> (CA join). These ACT_ classes derive the <a href="##(FSM_PROCESS)">#FSM_PROCESS</a> class.</li>
|
||||
</ul>
|
||||
|
||||
<p><img src="..\Presentations\FSM\Dia3.JPG" alt="Transition Rules and Transition Handlers and Event Triggers"/></p>
|
||||
|
||||
<p>The FSM class is the base class of all FSM_ derived classes.</p>
|
||||
|
||||
|
||||
<p>It implements the main functionality to define and execute Finite State Machines.
|
||||
<p>The FSM class is the base class of all FSM_ derived classes. It implements the main functionality to define and execute Finite State Machines.
|
||||
The derived FSM_ classes extend the Finite State Machine functionality to run a workflow process for a specific purpose or component.</p>
|
||||
|
||||
<p>Finite State Machines have <strong>Transition Rules</strong>, <strong>Transition Handlers</strong> and <strong>Event Triggers</strong>.</p>
|
||||
@@ -753,13 +791,13 @@ Most of the time, these Event Triggers are used within the Transition Handler me
|
||||
<p>As explained above, a FSM supports <strong>Linear State Transitions</strong> and <strong>Hierarchical State Transitions</strong>, and both can be mixed to make a comprehensive FSM implementation.
|
||||
The below documentation has a seperate chapter explaining both transition modes, taking into account the <strong>Transition Rules</strong>, <strong>Transition Handlers</strong> and <strong>Event Triggers</strong>.</p>
|
||||
|
||||
<h2>1.1) FSM Linear Transitions</h2>
|
||||
<h2>FSM Linear Transitions</h2>
|
||||
|
||||
<p>Linear Transitions are Transition Rules allowing an FSM to transition from one or multiple possible <strong>From</strong> state(s) towards a <strong>To</strong> state upon a Triggered <strong>Event</strong>.
|
||||
The Lineair transition rule evaluation will always be done from the <strong>current state</strong> of the FSM.
|
||||
If no valid Transition Rule can be found in the FSM, the FSM will log an error and stop.</p>
|
||||
|
||||
<h3>1.1.1) FSM Transition Rules</h3>
|
||||
<h3>FSM Transition Rules</h3>
|
||||
|
||||
<p>The FSM has transition rules that it follows and validates, as it walks the process.
|
||||
These rules define when an FSM can transition from a specific state towards an other specific state upon a triggered event.</p>
|
||||
@@ -787,7 +825,7 @@ These rules define when an FSM can transition from a specific state towards an o
|
||||
<li>Note that once the Switch is <strong>On</strong> or <strong>Middle</strong>, it can only be switched <strong>Off</strong>.</li>
|
||||
</ul>
|
||||
|
||||
<h3>Some additional comments:</h3>
|
||||
<h4>Some additional comments:</h4>
|
||||
|
||||
<p>Note that Linear Transition Rules <strong>can be declared in a few variations</strong>:</p>
|
||||
|
||||
@@ -801,7 +839,7 @@ These rules define when an FSM can transition from a specific state towards an o
|
||||
<pre><code> FsmSwitch:AddTransition( { "On", "Middle" }, "SwitchOff", "Off" )
|
||||
</code></pre>
|
||||
|
||||
<h3>1.1.2) Transition Handling</h3>
|
||||
<h3>Transition Handling</h3>
|
||||
|
||||
<p><img src="..\Presentations\FSM\Dia4.JPG" alt="Transition Handlers"/></p>
|
||||
|
||||
@@ -827,7 +865,7 @@ These parameters are on the correct order: From, Event, To:</p>
|
||||
|
||||
<p>On top, each of these methods can have a variable amount of parameters passed. See the example in section <a href="#1.1.3)-event-triggers">1.1.3</a>.</p>
|
||||
|
||||
<h3>1.1.3) Event Triggers</h3>
|
||||
<h3>Event Triggers</h3>
|
||||
|
||||
<p><img src="..\Presentations\FSM\Dia5.JPG" alt="Event Triggers"/></p>
|
||||
|
||||
@@ -870,7 +908,7 @@ Event will be processed after 5 seconds, and Amount is given as a parameter.</p>
|
||||
|
||||
<p>Because ... When Event was asynchronously processed after 5 seconds, Amount was set to 2. So be careful when processing and passing values and objects in asynchronous processing!</p>
|
||||
|
||||
<h3>1.1.4) Linear Transition Example</h3>
|
||||
<h3>Linear Transition Example</h3>
|
||||
|
||||
<p>This example is fully implemented in the MOOSE test mission on GITHUB: <a href="https://github.com/FlightControl-Master/MOOSE/blob/master/Moose%20Test%20Missions/FSM%20-%20Finite%20State%20Machine/FSM-100%20-%20Transition%20Explanation/FSM-100%20-%20Transition%20Explanation.lua">FSM-100 - Transition Explanation</a></p>
|
||||
|
||||
@@ -960,7 +998,7 @@ The transition for event Stop can be executed if the current state of the FSM is
|
||||
<p>So... When FsmDemo:Stop() is being triggered, the state of FsmDemo will transition from Red or Green to Stopped.
|
||||
And there is no transition handling method defined for that transition, thus, no new event is being triggered causing the FsmDemo process flow to halt.</p>
|
||||
|
||||
<h2>1.5) FSM Hierarchical Transitions</h2>
|
||||
<h2>FSM Hierarchical Transitions</h2>
|
||||
|
||||
<p>Hierarchical Transitions allow to re-use readily available and implemented FSMs.
|
||||
This becomes in very useful for mission building, where mission designers build complex processes and workflows,
|
||||
@@ -1582,7 +1620,7 @@ A string defining the start state.</p>
|
||||
<dl class="function">
|
||||
<dt>
|
||||
|
||||
<em></em>
|
||||
<em>#string</em>
|
||||
<a id="#(FSM)._StartState" >
|
||||
<strong>FSM._StartState</strong>
|
||||
</a>
|
||||
@@ -1881,7 +1919,6 @@ A string defining the start state.</p>
|
||||
<dl class="function">
|
||||
<dt>
|
||||
|
||||
<em></em>
|
||||
<a id="#(FSM).current" >
|
||||
<strong>FSM.current</strong>
|
||||
</a>
|
||||
|
||||
@@ -211,6 +211,7 @@ on defined intervals (currently every minute).</p>
|
||||
<dl class="function">
|
||||
<dt>
|
||||
|
||||
<em>#number</em>
|
||||
<a id="#(MOVEMENT).AliveUnits" >
|
||||
<strong>MOVEMENT.AliveUnits</strong>
|
||||
</a>
|
||||
@@ -219,6 +220,9 @@ on defined intervals (currently every minute).</p>
|
||||
|
||||
|
||||
|
||||
|
||||
<p> Contains the counter how many units are currently alive</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="function">
|
||||
|
||||
@@ -101,33 +101,30 @@
|
||||
|
||||
<hr/>
|
||||
|
||||
<h1>1) <a href="Scheduler.html##(SCHEDULER)">Scheduler#SCHEDULER</a> class, extends <a href="Base.html##(BASE)">Base#BASE</a></h1>
|
||||
|
||||
<p>The <a href="Scheduler.html##(SCHEDULER)">Scheduler#SCHEDULER</a> class creates schedule.</p>
|
||||
|
||||
<h2>1.1) SCHEDULER constructor</h2>
|
||||
|
||||
<p>The SCHEDULER class is quite easy to use, but note that the New constructor has variable parameters:</p>
|
||||
<p>SCHEDULER manages the <strong>scheduling of functions</strong>:</p>
|
||||
|
||||
<ul>
|
||||
<li><a href="Scheduler.html##(SCHEDULER).New">Scheduler#SCHEDULER.New</a>( nil ): Setup a new SCHEDULER object, which is persistently executed after garbage collection.</li>
|
||||
<li><a href="Scheduler.html##(SCHEDULER).New">Scheduler#SCHEDULER.New</a>( Object ): Setup a new SCHEDULER object, which is linked to the Object. When the Object is nillified or destroyed, the SCHEDULER object will also be destroyed and stopped after garbage collection.</li>
|
||||
<li><a href="Scheduler.html##(SCHEDULER).New">Scheduler#SCHEDULER.New</a>( nil, Function, FunctionArguments, Start, ... ): Setup a new persistent SCHEDULER object, and start a new schedule for the Function with the defined FunctionArguments according the Start and sequent parameters.</li>
|
||||
<li><a href="Scheduler.html##(SCHEDULER).New">Scheduler#SCHEDULER.New</a>( Object, Function, FunctionArguments, Start, ... ): Setup a new SCHEDULER object, linked to Object, and start a new schedule for the Function with the defined FunctionArguments according the Start and sequent parameters.</li>
|
||||
<li>optionally in an optional specified time interval, </li>
|
||||
<li>optionally <strong>repeating</strong> with a specified time repeat interval, </li>
|
||||
<li>optionally <strong>randomizing</strong> with a specified time interval randomization factor, </li>
|
||||
<li>optionally <strong>stop</strong> the repeating after a specified time interval. </li>
|
||||
</ul>
|
||||
|
||||
<h2>1.2) SCHEDULER timer stopping and (re-)starting.</h2>
|
||||
<hr/>
|
||||
|
||||
<p>The SCHEDULER can be stopped and restarted with the following methods:</p>
|
||||
<h1>Demo Missions</h1>
|
||||
|
||||
<ul>
|
||||
<li><a href="Scheduler.html##(SCHEDULER).Start">Scheduler#SCHEDULER.Start</a>(): (Re-)Start the schedules within the SCHEDULER object. If a CallID is provided to :Start(), only the schedule referenced by CallID will be (re-)started.</li>
|
||||
<li><a href="Scheduler.html##(SCHEDULER).Stop">Scheduler#SCHEDULER.Stop</a>(): Stop the schedules within the SCHEDULER object. If a CallID is provided to :Stop(), then only the schedule referenced by CallID will be stopped.</li>
|
||||
</ul>
|
||||
<h3><a href="https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master-release/SCH%20-%20Scheduler">SCHEDULER Demo Missions source code</a></h3>
|
||||
|
||||
<h2>1.3) Create a new schedule</h2>
|
||||
<h3><a href="https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/SCH%20-%20Scheduler">SCHEDULER Demo Missions, only for beta testers</a></h3>
|
||||
|
||||
<p>With <a href="Scheduler.html##(SCHEDULER).Schedule">Scheduler#SCHEDULER.Schedule</a>() a new time event can be scheduled. This function is used by the :New() constructor when a new schedule is planned.</p>
|
||||
<h3><a href="https://github.com/FlightControl-Master/MOOSE_MISSIONS/releases">ALL Demo Missions pack of the last release</a></h3>
|
||||
|
||||
<hr/>
|
||||
|
||||
<h1>YouTube Channel</h1>
|
||||
|
||||
<h3><a href="">SCHEDULER YouTube Channel (none)</a></h3>
|
||||
|
||||
<hr/>
|
||||
|
||||
@@ -143,12 +140,6 @@
|
||||
<li>FlightControl : Design & Programming</li>
|
||||
</ul>
|
||||
|
||||
<h3>Test Missions:</h3>
|
||||
|
||||
<ul>
|
||||
<li>SCH - Scheduler</li>
|
||||
</ul>
|
||||
|
||||
<hr/>
|
||||
|
||||
|
||||
@@ -157,19 +148,15 @@
|
||||
<tr>
|
||||
<td class="name" nowrap="nowrap"><a href="#SCHEDULER">SCHEDULER</a></td>
|
||||
<td class="summary">
|
||||
<h1>SCHEDULER class, extends <a href="Base.html##(BASE)">Base#BASE</a></h1>
|
||||
|
||||
<p>The SCHEDULER class creates schedule.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2><a id="#(SCHEDULER)">Type <code>SCHEDULER</code></a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap="nowrap"><a href="##(SCHEDULER).ClassName">SCHEDULER.ClassName</a></td>
|
||||
<td class="summary">
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap="nowrap"><a href="##(SCHEDULER).Clear">SCHEDULER:Clear()</a></td>
|
||||
<td class="summary">
|
||||
<p>Clears all pending schedules.</p>
|
||||
@@ -203,12 +190,6 @@
|
||||
<td class="name" nowrap="nowrap"><a href="##(SCHEDULER).SchedulerObject">SCHEDULER.SchedulerObject</a></td>
|
||||
<td class="summary">
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap="nowrap"><a href="##(SCHEDULER).Schedules">SCHEDULER.Schedules</a></td>
|
||||
<td class="summary">
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -236,6 +217,169 @@
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<h1>SCHEDULER class, extends <a href="Base.html##(BASE)">Base#BASE</a></h1>
|
||||
|
||||
<p>The SCHEDULER class creates schedule.</p>
|
||||
|
||||
|
||||
|
||||
<p>A SCHEDULER can manage <strong>multiple</strong> (repeating) schedules. Each planned or executing schedule has a unique <strong>ScheduleID</strong>.
|
||||
The ScheduleID is returned when the method <a href="##(SCHEDULER).Schedule">SCHEDULER.Schedule</a>() is called.
|
||||
It is recommended to store the ScheduleID in a variable, as it is used in the methods <a href="SCHEDULER.Start.html">SCHEDULER.Start</a>() and <a href="SCHEDULER.Stop.html">SCHEDULER.Stop</a>(),
|
||||
which can start and stop specific repeating schedules respectively within a SCHEDULER object.</p>
|
||||
|
||||
<h2>SCHEDULER constructor</h2>
|
||||
|
||||
<p>The SCHEDULER class is quite easy to use, but note that the New constructor has variable parameters:</p>
|
||||
|
||||
<p>The <a href="##(SCHEDULER).New">SCHEDULER.New</a>() method returns 2 variables:</p>
|
||||
|
||||
<ol>
|
||||
<li>The SCHEDULER object reference.</li>
|
||||
<li>The first schedule planned in the SCHEDULER object.</li>
|
||||
</ol>
|
||||
|
||||
<p>To clarify the different appliances, lets have a look at the following examples: </p>
|
||||
|
||||
<h3>Construct a SCHEDULER object without a persistent schedule.</h3>
|
||||
|
||||
<ul>
|
||||
<li><p><a href="##(SCHEDULER).New">SCHEDULER.New</a>( nil ): Setup a new SCHEDULER object, which is persistently executed after garbage collection.</p>
|
||||
|
||||
<p>SchedulerObject = SCHEDULER:New()
|
||||
SchedulerID = SchedulerObject:Schedule( nil, ScheduleFunction, {} )</p></li>
|
||||
</ul>
|
||||
|
||||
<p>The above example creates a new SchedulerObject, but does not schedule anything.
|
||||
A separate schedule is created by using the SchedulerObject using the method :Schedule..., which returns a ScheduleID</p>
|
||||
|
||||
<h3>Construct a SCHEDULER object without a volatile schedule, but volatile to the Object existence...</h3>
|
||||
|
||||
<ul>
|
||||
<li><p><a href="##(SCHEDULER).New">SCHEDULER.New</a>( Object ): Setup a new SCHEDULER object, which is linked to the Object. When the Object is nillified or destroyed, the SCHEDULER object will also be destroyed and stopped after garbage collection.</p>
|
||||
|
||||
<p>ZoneObject = ZONE:New( "ZoneName" )
|
||||
SchedulerObject = SCHEDULER:New( ZoneObject )
|
||||
SchedulerID = SchedulerObject:Schedule( ZoneObject, ScheduleFunction, {} )
|
||||
...
|
||||
ZoneObject = nil
|
||||
garbagecollect()</p></li>
|
||||
</ul>
|
||||
|
||||
<p>The above example creates a new SchedulerObject, but does not schedule anything, and is bound to the existence of ZoneObject, which is a ZONE.
|
||||
A separate schedule is created by using the SchedulerObject using the method :Schedule()..., which returns a ScheduleID
|
||||
Later in the logic, the ZoneObject is put to nil, and garbage is collected.
|
||||
As a result, the ScheduleObject will cancel any planned schedule.</p>
|
||||
|
||||
<h3>Construct a SCHEDULER object with a persistent schedule.</h3>
|
||||
|
||||
<ul>
|
||||
<li><p><a href="##(SCHEDULER).New">SCHEDULER.New</a>( nil, Function, FunctionArguments, Start, ... ): Setup a new persistent SCHEDULER object, and start a new schedule for the Function with the defined FunctionArguments according the Start and sequent parameters.</p>
|
||||
|
||||
<p>SchedulerObject, SchedulerID = SCHEDULER:New( nil, ScheduleFunction, {} )</p></li>
|
||||
</ul>
|
||||
|
||||
<p>The above example creates a new SchedulerObject, and does schedule the first schedule as part of the call.
|
||||
Note that 2 variables are returned here: SchedulerObject, ScheduleID...</p>
|
||||
|
||||
<h3>Construct a SCHEDULER object without a schedule, but volatile to the Object existence...</h3>
|
||||
|
||||
<ul>
|
||||
<li><p><a href="##(SCHEDULER).New">SCHEDULER.New</a>( Object, Function, FunctionArguments, Start, ... ): Setup a new SCHEDULER object, linked to Object, and start a new schedule for the Function with the defined FunctionArguments according the Start and sequent parameters.</p>
|
||||
|
||||
<p>ZoneObject = ZONE:New( "ZoneName" )
|
||||
SchedulerObject, SchedulerID = SCHEDULER:New( ZoneObject, ScheduleFunction, {} )
|
||||
SchedulerID = SchedulerObject:Schedule( ZoneObject, ScheduleFunction, {} )
|
||||
...
|
||||
ZoneObject = nil
|
||||
garbagecollect()</p></li>
|
||||
</ul>
|
||||
|
||||
<p>The above example creates a new SchedulerObject, and schedules a method call (ScheduleFunction),
|
||||
and is bound to the existence of ZoneObject, which is a ZONE object (ZoneObject).
|
||||
Both a ScheduleObject and a SchedulerID variable are returned.
|
||||
Later in the logic, the ZoneObject is put to nil, and garbage is collected.
|
||||
As a result, the ScheduleObject will cancel the planned schedule.</p>
|
||||
|
||||
<h2>SCHEDULER timer stopping and (re-)starting.</h2>
|
||||
|
||||
<p>The SCHEDULER can be stopped and restarted with the following methods:</p>
|
||||
|
||||
<ul>
|
||||
<li><p><a href="##(SCHEDULER).Start">SCHEDULER.Start</a>(): (Re-)Start the schedules within the SCHEDULER object. If a CallID is provided to :Start(), only the schedule referenced by CallID will be (re-)started.</p></li>
|
||||
<li><p><a href="##(SCHEDULER).Stop">SCHEDULER.Stop</a>(): Stop the schedules within the SCHEDULER object. If a CallID is provided to :Stop(), then only the schedule referenced by CallID will be stopped.</p>
|
||||
|
||||
<p>ZoneObject = ZONE:New( "ZoneName" )
|
||||
SchedulerObject, SchedulerID = SCHEDULER:New( ZoneObject, ScheduleFunction, {} )
|
||||
SchedulerID = SchedulerObject:Schedule( ZoneObject, ScheduleFunction, {}, 10, 10 )
|
||||
...
|
||||
SchedulerObject:Stop( SchedulerID )
|
||||
...
|
||||
SchedulerObject:Start( SchedulerID )</p></li>
|
||||
</ul>
|
||||
|
||||
<p>The above example creates a new SchedulerObject, and does schedule the first schedule as part of the call.
|
||||
Note that 2 variables are returned here: SchedulerObject, ScheduleID... <br/>
|
||||
Later in the logic, the repeating schedule with SchedulerID is stopped. <br/>
|
||||
A bit later, the repeating schedule with SchedulerId is (re)-started. </p>
|
||||
|
||||
<h2>Create a new schedule</h2>
|
||||
|
||||
<p>With the method <a href="##(SCHEDULER).Schedule">SCHEDULER.Schedule</a>() a new time event can be scheduled.
|
||||
This method is used by the :New() constructor when a new schedule is planned.</p>
|
||||
|
||||
<p>Consider the following code fragment of the SCHEDULER object creation.</p>
|
||||
|
||||
<pre><code>ZoneObject = ZONE:New( "ZoneName" )
|
||||
SchedulerObject = SCHEDULER:New( ZoneObject )
|
||||
</code></pre>
|
||||
|
||||
<p>Several parameters can be specified that influence the behaviour of a Schedule.</p>
|
||||
|
||||
<h3>A single schedule, immediately executed</h3>
|
||||
|
||||
<pre><code>SchedulerID = SchedulerObject:Schedule( ZoneObject, ScheduleFunction, {} )
|
||||
</code></pre>
|
||||
|
||||
<p>The above example schedules a new ScheduleFunction call to be executed asynchronously, within milleseconds ...</p>
|
||||
|
||||
<h3>A single schedule, planned over time</h3>
|
||||
|
||||
<pre><code>SchedulerID = SchedulerObject:Schedule( ZoneObject, ScheduleFunction, {}, 10 )
|
||||
</code></pre>
|
||||
|
||||
<p>The above example schedules a new ScheduleFunction call to be executed asynchronously, within 10 seconds ...</p>
|
||||
|
||||
<h3>A schedule with a repeating time interval, planned over time</h3>
|
||||
|
||||
<pre><code>SchedulerID = SchedulerObject:Schedule( ZoneObject, ScheduleFunction, {}, 10, 60 )
|
||||
</code></pre>
|
||||
|
||||
<p>The above example schedules a new ScheduleFunction call to be executed asynchronously, within 10 seconds,
|
||||
and repeating 60 every seconds ...</p>
|
||||
|
||||
<h3>A schedule with a repeating time interval, planned over time, with time interval randomization</h3>
|
||||
|
||||
<pre><code>SchedulerID = SchedulerObject:Schedule( ZoneObject, ScheduleFunction, {}, 10, 60, 0.5 )
|
||||
</code></pre>
|
||||
|
||||
<p>The above example schedules a new ScheduleFunction call to be executed asynchronously, within 10 seconds,
|
||||
and repeating 60 seconds, with a 50% time interval randomization ...
|
||||
So the repeating time interval will be randomized using the <strong>0.5</strong>, <br/>
|
||||
and will calculate between <strong>60 - ( 60 * 0.5 )</strong> and <strong>60 + ( 60 * 0.5 )</strong> for each repeat,
|
||||
which is in this example between <strong>30</strong> and <strong>90</strong> seconds.</p>
|
||||
|
||||
<h3>A schedule with a repeating time interval, planned over time, with time interval randomization, and stop after a time interval</h3>
|
||||
|
||||
<pre><code>SchedulerID = SchedulerObject:Schedule( ZoneObject, ScheduleFunction, {}, 10, 60, 0.5, 300 )
|
||||
</code></pre>
|
||||
|
||||
<p>The above example schedules a new ScheduleFunction call to be executed asynchronously, within 10 seconds,
|
||||
The schedule will repeat every 60 seconds.
|
||||
So the repeating time interval will be randomized using the <strong>0.5</strong>, <br/>
|
||||
and will calculate between <strong>60 - ( 60 * 0.5 )</strong> and <strong>60 + ( 60 * 0.5 )</strong> for each repeat,
|
||||
which is in this example between <strong>30</strong> and <strong>90</strong> seconds.
|
||||
The schedule will stop after <strong>300</strong> seconds.</p>
|
||||
|
||||
|
||||
</dd>
|
||||
@@ -250,20 +394,6 @@
|
||||
<dl class="function">
|
||||
<dt>
|
||||
|
||||
<em>#string</em>
|
||||
<a id="#(SCHEDULER).ClassName" >
|
||||
<strong>SCHEDULER.ClassName</strong>
|
||||
</a>
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="function">
|
||||
<dt>
|
||||
|
||||
<a id="#(SCHEDULER).Clear" >
|
||||
<strong>SCHEDULER:Clear()</strong>
|
||||
</a>
|
||||
@@ -461,20 +591,6 @@ The ScheduleID of the planned schedule.</p>
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="function">
|
||||
<dt>
|
||||
|
||||
<em></em>
|
||||
<a id="#(SCHEDULER).Schedules" >
|
||||
<strong>SCHEDULER.Schedules</strong>
|
||||
</a>
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="function">
|
||||
|
||||
@@ -2967,7 +2967,7 @@ Spawn_BE_KA50 = SPAWN:New( 'BE KA-50@RAMP-Ground Defense' ):Schedule( 600, 0.5 )
|
||||
<dl class="function">
|
||||
<dt>
|
||||
|
||||
<em>#boolean</em>
|
||||
<em></em>
|
||||
<a id="#(SPAWN).SpawnUnControlled" >
|
||||
<strong>SPAWN.SpawnUnControlled</strong>
|
||||
</a>
|
||||
|
||||
@@ -442,7 +442,6 @@ ptional) The name of the new static.</p>
|
||||
<dl class="function">
|
||||
<dt>
|
||||
|
||||
<em>#number</em>
|
||||
<a id="#(SPAWNSTATIC).SpawnIndex" >
|
||||
<strong>SPAWNSTATIC.SpawnIndex</strong>
|
||||
</a>
|
||||
|
||||
@@ -414,12 +414,6 @@
|
||||
<td class="name" nowrap="nowrap"><a href="##(ZONE_GROUP).New">ZONE_GROUP:New(ZoneName, ZoneGROUP, Radius)</a></td>
|
||||
<td class="summary">
|
||||
<p>Constructor to create a ZONE_GROUP instance, taking the zone name, a zone <a href="Group.html##(GROUP)">Group#GROUP</a> and a radius.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap="nowrap"><a href="##(ZONE_GROUP).ZoneGROUP">ZONE_GROUP.ZoneGROUP</a></td>
|
||||
<td class="summary">
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -488,12 +482,6 @@
|
||||
<td class="name" nowrap="nowrap"><a href="##(ZONE_POLYGON_BASE).New">ZONE_POLYGON_BASE:New(ZoneName, PointsArray)</a></td>
|
||||
<td class="summary">
|
||||
<p>Constructor to create a ZONE<em>POLYGON</em>BASE instance, taking the zone name and an array of <a href="DCSTypes.html##(Vec2)">DCSTypes#Vec2</a>, forming a polygon.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap="nowrap"><a href="##(ZONE_POLYGON_BASE).Polygon">ZONE_POLYGON_BASE.Polygon</a></td>
|
||||
<td class="summary">
|
||||
<p>The polygon defined by an array of <a href="DCSTypes.html##(Vec2)">DCSTypes#Vec2</a>.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -690,23 +678,30 @@
|
||||
<h2>Each zone implements two polymorphic functions defined in <a href="Zone.html##(ZONE_BASE)">Zone#ZONE_BASE</a>:</h2>
|
||||
|
||||
<ul>
|
||||
<li><a href="##(ZONE_BASE).IsVec2InZone">ZONE_BASE.IsVec2InZone</a>(): Returns if a Vec2 is within the zone.</li>
|
||||
<li><a href="##(ZONE_BASE).IsVec3InZone">ZONE_BASE.IsVec3InZone</a>(): Returns if a Vec3 is within the zone.</li>
|
||||
<li><a href="##(ZONE_BASE).IsVec2InZone">ZONE_BASE.IsVec2InZone</a>(): Returns if a 2D vector is within the zone.</li>
|
||||
<li><a href="##(ZONE_BASE).IsVec3InZone">ZONE_BASE.IsVec3InZone</a>(): Returns if a 3D vector is within the zone.</li>
|
||||
<li><a href="##(ZONE_BASE).IsPointVec2InZone">ZONE_BASE.IsPointVec2InZone</a>(): Returns if a 2D point vector is within the zone.</li>
|
||||
<li><a href="##(ZONE_BASE).IsPointVec3InZone">ZONE_BASE.IsPointVec3InZone</a>(): Returns if a 3D point vector is within the zone.</li>
|
||||
</ul>
|
||||
|
||||
<h2>A zone has a probability factor that can be set to randomize a selection between zones:</h2>
|
||||
|
||||
<ul>
|
||||
<li><a href="##(ZONE_BASE).SetRandomizeProbability">ZONE_BASE.SetRandomizeProbability</a>(): Set the randomization probability of a zone to be selected, taking a value between 0 and 1 ( 0 = 0%, 1 = 100% )</li>
|
||||
<li><a href="##(ZONE_BASE).GetRandomizeProbability">ZONE_BASE.GetRandomizeProbability</a>(): Get the randomization probability of a zone to be selected, passing a value between 0 and 1 ( 0 = 0%, 1 = 100% )</li>
|
||||
<li><a href="##(ZONE_BASE).SetZoneProbability">ZONE_BASE.SetZoneProbability</a>(): Set the randomization probability of a zone to be selected, taking a value between 0 and 1 ( 0 = 0%, 1 = 100% )</li>
|
||||
<li><a href="##(ZONE_BASE).GetZoneProbability">ZONE_BASE.GetZoneProbability</a>(): Get the randomization probability of a zone to be selected, passing a value between 0 and 1 ( 0 = 0%, 1 = 100% )</li>
|
||||
<li><a href="##(ZONE_BASE).GetZoneMaybe">ZONE_BASE.GetZoneMaybe</a>(): Get the zone taking into account the randomization probability. nil is returned if this zone is not a candidate.</li>
|
||||
</ul>
|
||||
|
||||
<h2>A zone manages Vectors:</h2>
|
||||
<h2>A zone manages vectors:</h2>
|
||||
|
||||
<ul>
|
||||
<li><a href="##(ZONE_BASE).GetVec2">ZONE_BASE.GetVec2</a>(): Returns the <a href="DCSTypes.html##(Vec2)">DCSTypes#Vec2</a> coordinate of the zone.</li>
|
||||
<li><a href="##(ZONE_BASE).GetRandomVec2">ZONE_BASE.GetRandomVec2</a>(): Define a random <a href="DCSTypes.html##(Vec2)">DCSTypes#Vec2</a> within the zone.</li>
|
||||
<li><a href="##(ZONE_BASE).GetVec2">ZONE_BASE.GetVec2</a>(): Returns the 2D vector coordinate of the zone.</li>
|
||||
<li><a href="##(ZONE_BASE).GetVec3">ZONE_BASE.GetVec3</a>(): Returns the 3D vector coordinate of the zone.</li>
|
||||
<li><a href="##(ZONE_BASE).GetPointVec2">ZONE_BASE.GetPointVec2</a>(): Returns the 2D point vector coordinate of the zone.</li>
|
||||
<li><a href="##(ZONE_BASE).GetPointVec3">ZONE_BASE.GetPointVec3</a>(): Returns the 3D point vector coordinate of the zone.</li>
|
||||
<li><a href="##(ZONE_BASE).GetRandomVec2">ZONE_BASE.GetRandomVec2</a>(): Define a random 2D vector within the zone.</li>
|
||||
<li><a href="##(ZONE_BASE).GetRandomPointVec2">ZONE_BASE.GetRandomPointVec2</a>(): Define a random 2D point vector within the zone.</li>
|
||||
<li><a href="##(ZONE_BASE).GetRandomPointVec3">ZONE_BASE.GetRandomPointVec3</a>(): Define a random 3D point vector within the zone.</li>
|
||||
</ul>
|
||||
|
||||
<h2>A zone has a bounding square:</h2>
|
||||
@@ -901,10 +896,7 @@ The name of the zone as defined within the mission editor.</p>
|
||||
</dl>
|
||||
|
||||
<h2><a id="#(ZONE_BASE)" >Type <code>ZONE_BASE</code></a></h2>
|
||||
|
||||
<p>The ZONE_BASE class</p>
|
||||
|
||||
<h3>Field(s)</h3>
|
||||
<h3>Field(s)</h3>
|
||||
<dl class="function">
|
||||
<dt>
|
||||
|
||||
@@ -1498,20 +1490,6 @@ The radius of the zone.</p>
|
||||
<p><em><a href="##(ZONE_GROUP)">#ZONE_GROUP</a>:</em>
|
||||
self</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="function">
|
||||
<dt>
|
||||
|
||||
<em><a href="Wrapper.Group.html##(GROUP)">Wrapper.Group#GROUP</a></em>
|
||||
<a id="#(ZONE_GROUP).ZoneGROUP" >
|
||||
<strong>ZONE_GROUP.ZoneGROUP</strong>
|
||||
</a>
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
@@ -1755,20 +1733,6 @@ An array of <a href="DCSTypes.html##(Vec2)">DCSTypes#Vec2</a>, forming a polygon
|
||||
<p><em><a href="##(ZONE_POLYGON_BASE)">#ZONE<em>POLYGON</em>BASE</a>:</em>
|
||||
self</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="function">
|
||||
<dt>
|
||||
|
||||
<em><a href="##(ZONE_POLYGON_BASE.ListVec2)">#ZONE_POLYGON_BASE.ListVec2</a></em>
|
||||
<a id="#(ZONE_POLYGON_BASE).Polygon" >
|
||||
<strong>ZONE_POLYGON_BASE.Polygon</strong>
|
||||
</a>
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<p>The polygon defined by an array of <a href="DCSTypes.html##(Vec2)">DCSTypes#Vec2</a>.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="function">
|
||||
|
||||
Reference in New Issue
Block a user