diff --git a/Moose Development/Moose/Core/Fsm.lua b/Moose Development/Moose/Core/Fsm.lua index 24f62dcbd..0edf2d5b3 100644 --- a/Moose Development/Moose/Core/Fsm.lua +++ b/Moose Development/Moose/Core/Fsm.lua @@ -8,14 +8,18 @@ -- -- === -- +-- ![Banner Image](..\Presentations\FSM\Dia1.jpg) +-- -- # 1) @{Core.Fsm#FSM} class, extends @{Core.Base#BASE} -- -- A Finite State Machine (FSM) defines the rules of transitioning between various States triggered by Events. -- -- * A **State** defines a moment in the process. --- * An **Event** describes an action, that can be triggered both internally as externally in the FSM. An Event can be triggered Embedded or Delayed over time. +-- * An **Event** describes an action, that can be triggered both internally as externally in the FSM. -- --- ![Test Image](..\Presentations\FSM\Dia1.jpg) +-- ## 1.1) Event Handling +-- +-- ![Event Handlers](..\Presentations\FSM\Dia3.jpg) -- -- An FSM transitions in **4 moments** when an Event is being handled. -- Each moment can be catched by handling methods defined by the mission designer, @@ -27,24 +31,33 @@ -- -- ** The OnLeave and OnBefore transition methods may return false to cancel the transition.** -- --- ![Test Image](..\Presentations\FSM\Dia3.jpg) +-- ## 1.2) Event Triggers -- --- The FSM creates for each Event **two Event trigger methods**. +-- ![Event Triggers](..\Presentations\FSM\Dia4.jpg) +-- +-- The FSM creates for each Event **two Event Trigger methods**. -- There are two modes how Events can be triggered, which is **embedded** and **delayed**: -- -- * The method **FSM:Event()** triggers an Event that will be processed **embedded** or **immediately**. -- * The method **FSM:__Event( seconds )** triggers an Event that will be processed **delayed** over time, waiting x seconds. -- --- ![Test Image](..\Presentations\FSM\Dia4.jpg) +-- ## 1.3) FSM Transition Rules -- --- 1.1) Define the FSM Rules --- ------------------------- +-- 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. -- --- The FSM can be defined by using 3 methods: +-- The method @{#FSM.AddTransition}() specifies a new possible Transition Rule for the FSM. -- --- * @{#FSM.SetStartState}(): Define the **Start State** of the FSM. This is the State the FSM will have when nothing is processed yet. --- * @{#FSM.AddTransition}(): Adds a new possible Transition Rule to the FSM. A Transition will change the State of the FSM upon the defined triggered Event. --- * @{#FSM.AddProcess}(): Adds a new Sub-Process FSM to the FSM. A Sub-Process will start the Sub-Process of the FSM upon the defined triggered Event, with multiple possible States as a result. +-- The initial state can be defined using the method @{#FSM.SetStartState}(). The default start state of an FSM is "None". +-- +-- ## 1.4) FSM Process Rules +-- +-- The FSM can implement sub-processes that will execute and return multiple possible states. +-- Depending upon which state is returned, the main FSM can continue tiggering different events. +-- +-- The method @{#FSM.AddProcess}() adds a new Sub-Process FSM to the FSM. +-- A Sub-Process will start the Sub-Process of the FSM upon the defined triggered Event, +-- with multiple possible States as a result. -- -- ==== -- @@ -115,6 +128,9 @@ do -- FSM end + --- Sets the start state of the FSM. + -- @param #FSM self + -- @param #string State A string defining the start state. function FSM:SetStartState( State ) self._StartState = State @@ -122,11 +138,20 @@ do -- FSM end + --- Returns the start state of the FSM. + -- @param #FSM self + -- @return #string A string containing the start state. function FSM:GetStartState() return self._StartState or {} end + --- Add a new transition rule to the FSM. + -- A transition rule defines when and if the FSM can transition from a state towards another state upon a triggered event. + -- @param #FSM self + -- @param #table From Can contain a string indicating the From state or a table of strings containing multiple From states. + -- @param #string Event The Event name. + -- @param #string To The To state. function FSM:AddTransition( From, Event, To ) local Transition = {} @@ -139,14 +164,22 @@ do -- FSM self._Transitions[Transition] = Transition self:_eventmap( self.Events, Transition ) end + + --- Returns a table of the transition rules defined within the FSM. + -- @return #table function FSM:GetTransitions() return self._Transitions or {} end --- Set the default @{Process} template with key ProcessName providing the ProcessClass and the process object when it is assigned to a @{Controllable} by the task. - -- @return Core.Fsm#FSM_PROCESS + -- @param #FSM self + -- @param #table From Can contain a string indicating the From state or a table of strings containing multiple From states. + -- @param #string Event The Event name. + -- @param Core.Fsm#FSM_PROCESS Process An sub-process FSM. + -- @param #table ReturnEvents A table indicating for which returned events of the SubFSM which Event must be triggered in the FSM. + -- @return Core.Fsm#FSM_PROCESS The SubFSM. function FSM:AddProcess( From, Event, Process, ReturnEvents ) self:E( { From, Event, Process, ReturnEvents } ) @@ -166,6 +199,9 @@ do -- FSM return Process end + + --- Returns a table of the SubFSM rules defined within the FSM. + -- @return #table function FSM:GetProcesses() return self._Processes or {} @@ -183,12 +219,14 @@ do -- FSM error( "Sub-Process from state " .. From .. " with event " .. Event .. " not found!" ) end + --- Adds an End state. function FSM:AddEndState( State ) self._EndStates[State] = State self.endstates[State] = State end + --- Returns the End states. function FSM:GetEndStates() return self._EndStates or {} @@ -232,12 +270,13 @@ do -- FSM return Process end + --- Returns a table with the scores defined. function FSM:GetScores() return self._Scores or {} end - + --- Returns a table with the Subs defined. function FSM:GetSubs() return self.options.subs diff --git a/docs/Documentation/Cargo.html b/docs/Documentation/Cargo.html index c03fa6ee7..0319727b8 100644 --- a/docs/Documentation/Cargo.html +++ b/docs/Documentation/Cargo.html @@ -2411,6 +2411,7 @@ The UNIT carrying the package.

+ AI_CARGO_UNIT.CargoCarrier diff --git a/docs/Documentation/Fsm.html b/docs/Documentation/Fsm.html index 41b3a958e..59c678e7b 100644 --- a/docs/Documentation/Fsm.html +++ b/docs/Documentation/Fsm.html @@ -80,16 +80,20 @@ It is a fantastic development, this module.


+

Banner Image

+

1) Core.Fsm#FSM class, extends Core.Base#BASE

A Finite State Machine (FSM) defines the rules of transitioning between various States triggered by Events.

-

Test Image

+

1.1) Event Handling

+ +

Event Handlers

An FSM transitions in 4 moments when an Event is being handled.
Each moment can be catched by handling methods defined by the mission designer,
@@ -103,9 +107,11 @@ These methods define the flow of the FSM process; because in those methods the F

* The OnLeave and OnBefore transition methods may return false to cancel the transition.*

-

Test Image

+

1.2) Event Triggers

-

The FSM creates for each Event two Event trigger methods.
+

Event Triggers

+ +

The FSM creates for each Event two Event Trigger methods.
There are two modes how Events can be triggered, which is embedded and delayed:

-

Test Image

+

1.3) FSM Transition Rules

-

1.1) Define the FSM Rules

+

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.

-

The FSM can be defined by using 3 methods:

+

The method FSM.AddTransition() specifies a new possible Transition Rule for the FSM.

-
    -
  • FSM.SetStartState(): Define the Start State of the FSM. This is the State the FSM will have when nothing is processed yet.
  • -
  • FSM.AddTransition(): Adds a new possible Transition Rule to the FSM. A Transition will change the State of the FSM upon the defined triggered Event.
  • -
  • FSM.AddProcess(): Adds a new Sub-Process FSM to the FSM. A Sub-Process will start the Sub-Process of the FSM upon the defined triggered Event, with multiple possible States as a result.
  • -
+

The initial state can be defined using the method FSM.SetStartState(). The default start state of an FSM is "None".

+ +

1.4) FSM Process Rules

+ +

The FSM can implement sub-processes that will execute and return multiple possible states.
+Depending upon which state is returned, the main FSM can continue tiggering different events.

+ +

The method FSM.AddProcess() adds a new Sub-Process FSM to the FSM.
+A Sub-Process will start the Sub-Process of the FSM upon the defined triggered Event, +with multiple possible States as a result.


@@ -200,7 +212,7 @@ YYYY-MM-DD: CLASS:NewFunction( Params ) added

FSM:AddEndState(State) - +

Adds an End state.

@@ -224,7 +236,7 @@ YYYY-MM-DD: CLASS:NewFunction( Params ) added

FSM:AddTransition(From, Event, To) - +

Add a new transition rule to the FSM.

@@ -236,7 +248,7 @@ YYYY-MM-DD: CLASS:NewFunction( Params ) added

FSM:GetEndStates() - +

Returns the End states.

@@ -248,19 +260,19 @@ YYYY-MM-DD: CLASS:NewFunction( Params ) added

FSM:GetProcesses() - +

Returns a table of the SubFSM rules defined within the FSM.

FSM:GetScores() - +

Returns a table with the scores defined.

FSM:GetStartState() - +

Returns the start state of the FSM.

@@ -272,13 +284,13 @@ YYYY-MM-DD: CLASS:NewFunction( Params ) added

FSM:GetSubs() - +

Returns a table with the Subs defined.

FSM:GetTransitions() - +

Returns a table of the transition rules defined within the FSM.

@@ -302,6 +314,12 @@ YYYY-MM-DD: CLASS:NewFunction( Params ) added

FSM:SetStartState(State) +

Sets the start state of the FSM.

+ + + + FSM._StartState + @@ -369,6 +387,12 @@ YYYY-MM-DD: CLASS:NewFunction( Params ) added

FSM:cannot(e) + + + + FSM.current + + @@ -668,7 +692,7 @@ YYYY-MM-DD: CLASS:NewFunction( Params ) added

- +

Adds an End state.

Parameter

    @@ -695,29 +719,33 @@ YYYY-MM-DD: CLASS:NewFunction( Params ) added

    • -

      From :

      +

      #table From : +Can contain a string indicating the From state or a table of strings containing multiple From states.

    • -

      Event :

      +

      #string Event : +The Event name.

    • -

      Process :

      +

      Core.Fsm#FSM_PROCESS Process : +An sub-process FSM.

    • -

      ReturnEvents :

      +

      #table ReturnEvents : +A table indicating for which returned events of the SubFSM which Event must be triggered in the FSM.

    Return value

    -

    Core.Fsm#FSM_PROCESS:

    - +

    Core.Fsm#FSM_PROCESS: +The SubFSM.

@@ -820,23 +848,29 @@ self

+

Add a new transition rule to the FSM.

+ +

A transition rule defines when and if the FSM can transition from a state towards another state upon a triggered event.

Parameters

@@ -865,7 +899,7 @@ self

- +

Returns the End states.

@@ -904,6 +938,11 @@ self

+

Returns a table of the SubFSM rules defined within the FSM.

+ +

Return value

+ +

#table:

@@ -917,7 +956,7 @@ self

- +

Returns a table with the scores defined.

@@ -930,7 +969,12 @@ self

+

Returns the start state of the FSM.

+

Return value

+ +

#string: +A string containing the start state.

@@ -956,7 +1000,7 @@ self

- +

Returns a table with the Subs defined.

@@ -969,6 +1013,11 @@ self

+

Returns a table of the transition rules defined within the FSM.

+ +

Return value

+ +

#table:

@@ -1050,16 +1099,31 @@ self

- +

Sets the start state of the FSM.

Parameter

+
+ +
+
+ + + +FSM._StartState + +
+
+ + +
@@ -1326,6 +1390,20 @@ self

+ +
+
+
+ + + +FSM.current + +
+
+ + +
diff --git a/docs/Documentation/Spawn.html b/docs/Documentation/Spawn.html index 6d06e2aaa..1116db12a 100644 --- a/docs/Documentation/Spawn.html +++ b/docs/Documentation/Spawn.html @@ -1692,6 +1692,9 @@ The group that was spawned. You can use this group for further actions.

+ +

Don't repeat the group from Take-Off till Landing and back Take-Off by ReSpawning.

+
@@ -2166,7 +2169,7 @@ when nothing was spawned.

- + #number SPAWN.SpawnMaxGroups @@ -2183,7 +2186,7 @@ when nothing was spawned.

- + #number SPAWN.SpawnMaxUnitsAlive diff --git a/docs/Presentations/FSM/Dia1.jpg b/docs/Presentations/FSM/Dia1.jpg index 61217a2e1..6931dccfd 100644 Binary files a/docs/Presentations/FSM/Dia1.jpg and b/docs/Presentations/FSM/Dia1.jpg differ diff --git a/docs/Presentations/FSM/Dia2.jpg b/docs/Presentations/FSM/Dia2.jpg index 6aac8cbc0..2a5a26ccf 100644 Binary files a/docs/Presentations/FSM/Dia2.jpg and b/docs/Presentations/FSM/Dia2.jpg differ diff --git a/docs/Presentations/FSM/Dia3.jpg b/docs/Presentations/FSM/Dia3.jpg index fad41b923..9d3441f5b 100644 Binary files a/docs/Presentations/FSM/Dia3.jpg and b/docs/Presentations/FSM/Dia3.jpg differ diff --git a/docs/Presentations/FSM/Dia4.jpg b/docs/Presentations/FSM/Dia4.jpg index 80b7c1fab..f1aa9df9f 100644 Binary files a/docs/Presentations/FSM/Dia4.jpg and b/docs/Presentations/FSM/Dia4.jpg differ