Groups of state machine operators
Groups of operators are the conditions that trigger the model’s actions inside states.
Operator groups are used when it is necessary to configure more complex model behavior. For more information about the logic of operator groups, see The logic of finite automata operation.
Operator groups only support operations in the Julia language and can contain several parts that alternate in any order. For example:
during: du1
entry: en1
during: du2
In this case, when the state is activated, the code entry: en1
will be executed. After that, at each subsequent step, while the state remains active, the combined code of the during
operator group will be executed, represented as "du1; du2"
. This means that du1
and du2
are combined and executed sequentially, as if they are connected together within the same during
.
You can use short names for groups of operators — When enumerating, it is important that the same word is not repeated. Example of an incorrect enumeration:
|
The Julia code in the status blocks can be multi-line and continue until the keyword entry
, during
, exit
or on
occurs at the beginning of the line. For example:
during:
if x > 10
y = 1
else
y = 2
end
exit: y = 3
The code in the 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 typical for the entry and during sections, but does not include logic related to deactivating the state (as the exit section does).
|
The entry group
entry' is used to define the actions that are performed when entering the state. The actions specified in the `entry
are performed each time the state becomes active.
The band during
'during` — is used to determine the actions that are performed at each stage of the model calculation step (except the first one) if the state is active. The actions specified in during
are performed while the state is active.
Exit group
exit' is used to determine the actions that are performed when exiting the state. These actions are performed once when the state becomes inactive, and occur after all the actions of the transitions that initiated the exit from this state are completed. After exiting the state, the `during
statements are no longer executed because the state is no longer active. For example, there is the following finite state machine:
Here, the state machine activates state "A" in the first step, and in the second it performs the actions in the following order:
y2 = 2
y1 = 1
y3 = 3
The on group
on
— is performed when the specified action occurs in the active state. The on
operator group allows you to use temporal logic within states. For example:
Here:
-
on after(5, sec)
determines that execution will start from the fifth second (and run after 6, 7, etc. seconds). -
'y = 0` determines that the variable
y
should be set to `0'.
The logic of operator groups
In the state machine, the order of operation with transitions and groups of operators entry
, during
, exit
, and on
is as follows:
Types of logic for executing groups of operators |
entry |
during |
exit |
on |
The order of execution |
|
|
|
|
Activation Features |
entry can be used to initialize variables, configure parameters, or perform any other actions necessary to prepare for operations in the current state. |
'during` can be used to perform periodic checks, update variable values, or perform repetitive calculations. |
|
|
Interaction with traffic |
|
Before executing the |
|
|