Memory node
Page in progress. |
A History Junction (History Junction) is an element of finite state machine Engee that captures the state of children states
within the parent state, so that it returns to the last active state when reactivated.
Read more about parent and child states in the article State machine hierarchy. |
A memory node can only be located inside states. Incorrect location will generate an error: |
The memory node records the activity of child states within the parent state. When the parent state becomes active for the first time, the finite automaton uses default transition to determine which child state becomes active. However, if the parent state becomes inactive and then becomes re-activated, the memory node allows the memory node to return to the last active child state, bypassing the default transition.
For example, there is an automatic door that has only two possible child states, Open and Closed. The parent state will be the "Door_Activity" state, which is common to the child states. We obtain the following finite automaton model:
-
When the finite automaton first enters the Door_Activity state, the Closed state is activated by default;
-
If the door is opened (Open) and then the system is temporarily switched off (transition to an "inactive" state - i.e. the parent Door_Activity state will no longer be active), the memory node remembers the Open state;
-
When the Door_Activity state is reactivated, the door automatically returns to the Open state, not Closed as it would have been without the memory node.
Memory node as an internal transition
A memory node can be used as an internal transition.
Internal transition is a mechanism in the state hierarchy of a finite automaton that allows to move from the current state to one of its child states without going to the level above. Such a transition is performed automatically when the parent state is activated and can be either unconditional or dependent on certain conditions.
An internal transition is created from the parent state frame to the child state, but in our case it will go to the memory node:
Such a transition works as a loop (self-loop) for each child state. When the internal transition condition is fulfilled, the finite automaton temporarily leaves the active child state and then immediately returns to it. This allows the state to be reactivated by performing all associated actions (e.g., operator groups during
and on
). Hence, a memory node as an internal transition helps to manage transitions while maintaining the current state of the system.
Let us consider how an internal transition to a memory node works. To do this, let us imagine the following model with a parent state A and two child states - A1 and A2. There will be no memory node in the model and no condition on the internal transition:
The internal transition from state A to A1 is unconditional, that is, every time state A is activated. This makes the state A2 unreachable without the use of a memory node. Such a finite automaton model will work according to the following logic:
Logic of finite automaton operation in a model without a memory node and conditions.
-
Activation of the Chart block, starting the finite automaton of the model:
-
1. Transition to state A;
-
2. Activation of the A state;
-
3. Transition to state A1;
-
4. Activation of the A1 state;
-
5. Chart and states A, A1 fall asleep.
-
-
Chart and the active state A wake up:
-
1. The
during
andon
operator groups (if any) are executed;
-
2. Deactivation of the A1 state;
-
3. Activation of the A1 state;
-
4. The Chart block and the A, A1 states fall asleep.
-
-
Return to point 2, repeat the cycle.
Now let’s add a condition (temporal logic operator every) on the internal transition:
After adding the condition, the transition from state A to A1 will be performed only at every second awakening of state A. At odd awakenings the transition A1 → A2 takes place, and at even awakenings the transition A2 → A1 takes place. Hence, the model will work according to the following logic:
Logic of finite automaton operation in a model without a memory node with condition.
-
Activation of Chart block, starting the finite automaton of the model:
-
1. Transition to state A;
-
2. Activation of the A state;
-
3. Transition to state A1;
-
4. Activation of the A1 state;
-
5. Chart and states A, A1 fall asleep.
-
-
Block Chart and active state A wake up (wake-up no. 1, 3, 5… of state A):
-
1. The transition A1→A2 is executed;
-
2. Deactivation of the A1 state;
-
3. Activation of the A2 state;
-
4. The Chart block and the A, A2 states fall asleep.
-
-
The Chart block and the active state A wake up (wake-up No. 2, 4, 6… of the A state):
-
1. The
during
andon
operator groups (if any) are executed;
-
2. The internal transition condition is triggered (waking is even), and it is fulfilled;
-
3. Deactivation of the A2 state;
-
4. Activation of the A1 state;
-
5. Chart and states A, A1 fall asleep.
-
-
Return to point 2, repeat the cycle.
Now consider a model with a memory node on an internal transition. Additionally, let’s add the temporal logic operator after and another external state as shown in the figure:
Recall that the task of the memory node at the internal transition is to remember the last active child state and return to it when the conditions are met. Then the model will work according to the following logic:
Logic of finite automaton operation in a model with a memory node and a condition.
-
Activation of the Chart block, starting the finite automaton of the model:
-
1. Transition to state A;
-
2. Activation of the A state;
-
3. Transition to state A1;
-
4. Activation of the A1 state;
-
5. Chart and states A, A1 fall asleep.
-
-
Chart and active state A wake up (first wake-up of state A):
-
1. The transition A1→A2 is executed;
-
2. Deactivation of the A1 state;
-
3. Activation of the A2 state;
-
4. The memory node remembers the A2 state;
-
5. Chart and states A, A2 fall asleep.
-
-
Chart and active state A wake up (second awakening of state A):
-
1. The
during
andon
operator groups (if any) are executed;
-
2. The internal transition condition to the memory node is triggered, and it is executed to the remembered state A2;
-
3. Deactivation of the A2 state;
-
4. Activation of the A2 state;
-
5. The memory node remembers the A2 state;
-
6. Chart and the states A, A2 fall asleep.
-
-
Chart wakes up (third awakening of state A):
-
1. The transition condition A→B is triggered, and it is fulfilled;
-
2. Deactivation of the A2 state;
-
3. Deactivation of the A state;
-
4. Activation of the B state;
-
5. Chart and B state asleep.
-
-
Chart wakes up:
-
1. The unconditional transition B→A is executed;
-
2. Activation of the A state;
-
3. Activation of the memorised state A2;
-
4. The memory node remembers the A2 state;
-
5. Chart and states A, A2 fall asleep.
-
-
Chart, A and A2 wake up (first awakening of A):
-
1. The memory node remembers the A2 state;
-
2. Chart, A and A2 fall asleep.
-
-
Return to point 3, repeat the cycle.
Thus, an internal transition to a memory node allows you to temporarily exit the current child state and return to it if the transition condition is met. This happens immediately after the during
and on
groups of operators of the parent state are executed. The memory node remembers the last active child state, helping in transition management.
The main differences between a memory node with and without an internal transition are as follows:
|