Groups of state machine operators
Operator groups are conditions that initiate model actions within states.
Operator groups are used when more complex model behaviour needs to be configured. For more information on the logic behind operator groups, see Logic of finite automata.
Operator groups support only Julia language operations and can contain multiple parts that are interleaved in any order. For example:
during: du1
entry: en1
during: du2
In this case, the code entry: en1
will be executed when the state is activated. Thereafter, at each subsequent step while the state remains active, the combined code of the during
operator group, represented as du1; du2
, will be executed. This means that du1
and du2
are combined and executed sequentially as if they were joined together within a single during
.
You can use short names for operator groups — When enumerating, it is important that the same word is not repeated. An example of an incorrect enumeration:
|
Julia code in status blocks can be multi-line and continue until the entry
, during
, exit
or on
keyword is encountered at the beginning of the line. For example:
during:
if x > 10
y = 1
else
y = 2
end
exit: y = 3
Code in a state without operator groups is executed both when the state is activated and at each step while the state remains active. Thus, it combines the actions characteristic of the entry and during sections, but does not include the logic associated with deactivating the state (as the exit section does).
|
Entry group
entry
is used to define the actions that are performed when a state is entered. The actions specified in entry
are performed each time the state becomes active.
The during
during
- used to define the actions that are performed at each step of the model calculation step (except the first step) if the state is active. The actions specified in during
are performed while the state is active.
Group exit
exit
- used to define the actions that are performed when a state is exited. These actions are performed once when the state becomes inactive, and occur after all the actions of the transitions that initiated the exit from that state have completed. After exiting a state, the during
operators are no longer executed because the state is no longer active. For example, there is the following finite automaton:
Here, the finite automaton will activate the state "A" in the first step and perform the actions in the following order in the second step:
y2 = 2
y1 = 1
y3 = 3
Group on
on
- executed when the specified action occurs in an active state. The on
operator group allows to use temporal logic inside states. For example:
Here:
-
on after(5, sec)
specifies that execution will start at the fifth second (it will also be executed after 6, 7, etc. seconds). -
y = 0
specifies that the variabley
should be set to0
.
Logic of operation of operator groups
In a state machine, the order of operation of transitions and the entry
, during
, exit
, and on
operator groups is as follows:
Types of operator group execution logic |
entry |
during |
exit |
on |
Execution order |
|
|
|
|
Activation features |
|
|
|
|
Interaction with transitions |
|
Prior to executing the |
|
|