4 Call Behavior - Basis
This "UML state diagram" sample illustrates the basic calling behavior of the UML state diagram and includes the following UML SC elements:
Sample project: TF1910_UmlSC_Sample4_CallingBehaviour_Basic.zip
Overview
The following sub-aspects illustrate the call behavior of states and composite states. With the help of different programming means the different calling aspects are illustrated (programming tools => calling aspect).
- Counter => Call frequency
- Entering the called state action in an array => Call sequence
- Task cycle IDs => Assignment of the call to the cycle ID
The respective assignment of the programming tools to the call aspect is explained below.
Both use cases are applied for the composite state:
- Grouping/Nesting, in which case the composite state has its own ENTRY/DO/EXIT actions
- Parallel sub-state machines
Counter => Call frequency
Each ENTRY/DO/EXIT action, that is called in a state or a composite state, increments a corresponding counter. This illustrates the call frequency of an action and indicates that:
- the ENTRY action is called once each time the associated (composite) state is activated;
- the EXIT action is called once each time the associated (composite) state is exited;
- the DO action is called permanently as long as the associated (composite) state is active;
- a composite state with a region (use case Grouping/Nesting) is activated if none of the inner states was previously active and as soon as one of the inner states is activated;
- a composite state with a region (use case Grouping/Nesting) remains active as long as one of the inner states is active;
- a composite state with a region (use case Grouping/Nesting) is exited if one of the inner states was previously active and this state is exited so that none of the inner states is now active;
- it depends on the option "Execute DO actions even if inner composite states are active" whether the DO action of an outer composite state (in the sample "CompositeState1") is still called if an inner composite state is active (in the sample project: "CompositeState2").
Entering the called state action in an array => Call sequence
Each ENTRY/DO/EXIT action that is called in a state or in a composite state enters its name (e.g. "State1__Entry") into an array. This illustrates the call sequence of the different actions and indicates that:
- the basic call sequence for a state is: first ENTRY, then DO, then EXIT. In the sample project:
- State1__Entry
- State1__Do
- State1__Exit
- if an inner state of a composite state is activated with a region (use case grouping/nesting) and if this also activates the composite state, the call sequence "from outside to inside" is: outer state EXIT, composite state ENTRY, inner state ENTRY, composite state DO, inner state DO. In the sample project:
- State1__Exit
- Comp1_Entry
- State2__Entry
- Comp1_Do
- State2__Do
- an inner composite state can be exited via a (pseudo) exception transition of the outer composite state (in the sample project via the transitions: eLeaveComp1_ToState1, eLeaveComp1_ToComp3).
- if a composite state is exited e.g. via a (pseudo) exception transition, the calling sequence "from inside to outside" is: inner state EXIT, if necessary inner composite state EXIT, outer composite state EXIT, outer state ENTRY. In the sample project:
- State4__Exit
- Comp2_Exit
- Comp1_Exit
- State1__Entry / State7__Entry
- in a composite state with several regions, the region with the higher priority, i.e. with the lower priority number, is called first. In the sample project:
- State7__Entry
- State7__Do
- State6__Entry
- State6__Do
Task cycle IDs => Assignment of the call to the cycle ID
Each ENTRY/DO/EXIT action that is called in a state or a composite state stores the cycle ID of the first and last call. This illustrates which call takes place in which cycle and indicates that:
- if a state is activated, the ENTRY and DO actions are called within the same cycle.
In the screenshot "Visu_B_CallingOrder_CycleNr" of the ZIP: - State1 / ENTRY-Call: 516 (ID of the cycle in which the call occurred)
- State1 / DO-First Call: 516
- if a state is exited, the EXIT action is called in the following cycle of the last DO call.
In the screenshot "Visu_B_CallingOrder_CycleNr" of the ZIP: - State1 / DO-Last Call: 1415
- State1 / EXIT-Call: 1416
- if a state is exited, the EXIT action of that state is called in the same cycle as the ENTRY and DO actions of the activated state.
In the screenshot "Visu_B_CallingOrder_CycleNr" of the ZIP: - State2 / DO-Last Call: 1762
- State2 / EXIT-Call: 1763
- State3 / ENTRY-Call: 1763
- State3 / DO-First Call: 1763
- if a state is exited and a composite state with a region and its own actions is activated, the EXIT action of the exited state is called in the same cycle as the ENTRY and DO actions of the activated (composite) state.
In the screenshot "Visu_B_CallingOrder_CycleNr" of the ZIP: - State1 / DO-Last Call: 1415
- State1 / EXIT-Call: 1416
- CompositeState1 / ENTRY-Call: 1416
- State2 / ENTRY-Call: 1416
- CompositeState1 / DO-First Call: 1416
- State2 / DO-First Call: 1416
- if a composite state with a region and its own actions is exited via a pseudo exception transition, the EXIT action of the exited (composite) state is called in the same cycle as the ENTRY and DO actions of the activated state.
In the screenshot "Visu_B_CallingOrder_CycleNr" of the ZIP: - CompositeState1 / DO-Last Call: 2367
- CompositeState2 / DO-Last Call: 2367
- State4 / DO-Last Call: 2367
- State4 / EXIT-Call: 2368
- CompositeState2 / EXIT-Call: 2368
- CompositeState1 / EXIT-Call: 2368
- State7 / ENTRY-Call: 2368
- State7 / DO-First Call: 2368
- State6 / ENTRY-Call: 2368
- State6 / DO-First Call: 2368
- if a composite state with a region and its own actions is exited via an exception transition, the EXIT action of the exited (composite) state is called in the same cycle as the last call of the DO action of the exited (composite) state and as the ENTRY and DO actions of the activated state. For example (not shown in the screenshot "Visu_B_CallingOrder_CycleNr" of the ZIP):
- CompositeState1 / DO-Last Call: 1050
- CompositeState2 / DO-Last Call: 1050
- State4 / DO-Last Call: 1050
- State4 / EXIT-Call: 1050
- CompositeState2 / EXIT-Call: 1050
- CompositeState1 / EXIT-Call: 1050
- State1 / ENTRY-Call: 1050
- State1 / DO-First Call: 1050
Visualization
In addition to the convenient online mode of the UML SC diagram, the behavior of the state machine and the values of the counters, the table and the task cycle IDs can be tracked via the visualizations. The visualization also contains switches for switching between the states and for resetting the values.
In order to facilitate familiarization with the sample project, two visualizations with different information content are included:
- Visu_A_CallingOrder contains:
- Counter => Call frequency
- Entering the called state action in an array => Call sequence
- Visu_B_CallingOrder_CycleNr extends Visu_A by:
- Task cycle IDs => Assignment of the call to the cycle ID
The values of the transition conditions can be changed not only via the visualization or the declaration editor of the FB, but also directly via the UML SC diagram. |
If the transition consists of only one transition variable, the value of the variable can be changed for writing or forcing by double-clicking on the monitoring value. If a value was prepared for writing or forcing, this is indicated in the upper right-hand corner of the monitoring area (see also: Online Mode).