Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
11 views97 pages

State Machine Diagrams

The document provides an overview of state machine diagrams in UML, focusing on their role in modeling the behavior of systems through states and transitions. It explains key concepts such as states, transitions, events, and types of states, including initial, final, decision, and composite states. Additionally, it discusses the significance of hierarchical state diagrams for managing complexity in behavioral modeling.

Uploaded by

schoolvandongen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views97 pages

State Machine Diagrams

The document provides an overview of state machine diagrams in UML, focusing on their role in modeling the behavior of systems through states and transitions. It explains key concepts such as states, transitions, events, and types of states, including initial, final, decision, and composite states. Additionally, it discusses the significance of hierarchical state diagrams for managing complexity in behavioral modeling.

Uploaded by

schoolvandongen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 97

2IX20 Software Specification

STATE MACHINE DIAGRAMS

Based on the slides provided by M.Seidl,


M.Scholz, C. Huemer and G.Kappel,
authors of the book UML@Classroom
Under the Creative Commons Attribution-
NonCommercial 4.0 International licence.
See http://www.uml.ac.at/en/lernen.

Jeroen Keiren

Mathematics & Computer Science / Formal System Analysis


What is behavior?

Behavior: the way in which something functions or operates.


- Merriam-Webster

Behavioral modelling: discover key operations in problem domain and build


behavioral models for those operations

2 2IX20 Lecture 4
Behavioral design

• How will we build it? (design, not implementation!)


• Focus on how to meet the requirements
• Traceability: ensure that we address all requirements

Often used in, e.g., cyber-physical systems

3 2IX20 Lecture 4
State machine diagrams

Diagram

Structure Behavior
Diagram Diagram

Class Package Profile Object Activity State Machine Interaction Use Case
Diagram Diagram Diagram Diagram Diagram Diagram Diagram Diagram

Deployment Composition Component Sequence Communication Interaction Timing


Diagram Structure Diagram Diagram Diagram Overview Diagram
Diagram Diagram

4 2IX20 Lecture 4
State machine diagrams

• State machine diagrams - a way of modelling behavior in UML


• State machine diagrams focus on possible states of an object and
transitions between them

Example
model of H2O:
• States: liquid, gas (vapour), solid (ice)
• Transitions: melting, freezing, vaporization, condensation

5 2IX20 Lecture 4
State machine diagrams

• Every object takes finite number of different states during its life
• State machine diagram used as follows:
• To model possible states of system or object
• To show how state transitions occur as consequence of events
• To show what behavior system or object exhibits in each state

6 2IX20 Lecture 4
Background: hierarchical state diagrams

• The number of states in a diagram can easily become large


• Make the diagrams more compact: introduce hierarchies of states

David Harel
Weizmann Institute of Science, Israel

State charts (1987)


Also known as hierarchical state diagrams

7 2IX20 Lecture 4
Example: Lecture hall

High-level description of behavior of a lecture hall

Transition State

8 2IX20 Lecture 4
Example: Lecture Hall with Details

class LectureHall {
private boolean free;

public void occupy() {


free=false;
}
public void release() {
free=true;
}
}

9 2IX20 Lecture 4
Example: Digital Clock

10 2IX20 Lecture 4
Summary: state machine diagrams

• Describe states the system can be in


• Shows:
• Which states lead to each other
• What triggers state change

• Main focus on state

[By Mirosamek at English Wikipedia, CC BY-SA 3.0]

11 2IX20 Lecture 4
2IX20 Software Specification
STATE MACHINE DIAGRAMS: STATES AND TRANSITIONS

Based on the slides provided by M.Seidl,


M.Scholz, C. Huemer and G.Kappel,
authors of the book UML@Classroom
Under the Creative Commons Attribution-
NonCommercial 4.0 International licence.
See http://www.uml.ac.at/en/lernen.

Jeroen Keiren

Mathematics & Computer Science / Formal System Analysis


State

• States = nodes of state machine


• When state is active
• Object is in that state
• All internal activities specified in this state can be executed
• An activity can consist of multiple actions
• entry / Activity(...)
• Executed when object enters state
• exit / Activity(...)
• Executed when object exits state
• do / Activity(...)
• Executed while object remains in state

13 2IX20 State machine diagrams: states and transitions


Transition

Change from one state to another


Event Guard Sequence of actions (effect)

Source state Transition Target state

14 2IX20 State machine diagrams: states and transitions


Transition – Syntax

• Event (trigger)
• Exogenous stimulus
• Can trigger state transition

• Activity (effect)
• Sequence of actions executed during state transition

15 2IX20 State machine diagrams: states and transitions


Transition – Syntax

• Guard (condition)
• Boolean expression such as b >= 0
• If event occurs, guard is checked
• If guard is true
• All activities in current state are terminated
• Any relevant exit activity is executed
• Transition takes place
• If guard is false
• No state transition takes place, event is discarded

16 2IX20 State machine diagrams: states and transitions


Transition – Types (1/2)
Internal transition External transition

• If event1 occurs • If event1 occurs


• Object remains in state1 • Object leaves state1 and
• Activity3 is executed Activity2 is executed
• Activity3 is executed
• Object enters state1 and
Activity1 is executed

17 2IX20 State machine diagrams: states and transitions


Transition – Types (2/2)
When do the following transitions take place?
If e1 occurs, A1 is aborted and the object changes to S2

18 2IX20 State machine diagrams: states and transitions


Transition – Types (2/2)
When do the following transitions take place?
If e1 occurs, A1 is aborted and the object changes to S2

If e1 occurs and g1 evaluates to true, A1 is aborted and the


object changes to S2

19 2IX20 State machine diagrams: states and transitions


Transition – Types (2/2)
When do the following transitions take place?
If e1 occurs, A1 is aborted and the object changes to S2

If e1 occurs and g1 evaluates to true, A1 is aborted and the


object changes to S2

As soon as the execution of A1 is finished, a completion event is


generated that initiates the transition to S2

20 2IX20 State machine diagrams: states and transitions


Transition – Types (2/2)
When do the following transitions take place?
If e1 occurs, A1 is aborted and the object changes to S2

If e1 occurs and g1 evaluates to true, A1 is aborted and the


object changes to S2

As soon as the execution of A1 is finished, a completion event is


generated that initiates the transition to S2

As soon as the execution of A1 is finished, a completion event is


generated; if g1 evaluates to true, the transition takes place; If
not, this transition can never happen
21 2IX20 State machine diagrams: states and transitions
Transition – Sequence of Activity Executions

Assume we first initialize S1 … what is the value of x after e occurred?

22 2IX20 State machine diagrams: states and transitions


Transition – Sequence of Activity Executions

Assume we first initialize S1 … what is the value of x after e occurred?


S1 becomes active, x is set to the value 4

23 2IX20 State machine diagrams: states and transitions


Transition – Sequence of Activity Executions

Assume S1 is active … what is the value of x after e occurred?


S1 becomes active, x is set to the value 4
e occurs, the guard is checked and evaluates to true

24 2IX20 State machine diagrams: states and transitions


Transition – Sequence of Activity Executions

Assume S1 is active … what is the value of x after e occurred?


S1 becomes active, x is set to the value 4
e occurs, the guard is checked and evaluates to true
S1 is left, x is set to 5

25 2IX20 State machine diagrams: states and transitions


Transition – Sequence of Activity Executions

Assume S1 is active … what is the value of x after e occurred?


S1 becomes active, x is set to the value 4
e occurs, the guard is checked and evaluates to true
S1 is left, x is set to 5
The transition takes place, x is set to 10

26 2IX20 State machine diagrams: states and transitions


Transition – Sequence of Activity Executions

Assume S1 is active … what is the value of x after e occurred?


S1 becomes active, x is set to the value 4
e occurs, the guard is checked and evaluates to true
S1 is left, x is set to 5
The transition takes place, x is set to 10
S2 is entered, x is set to 11

27 2IX20 State machine diagrams: states and transitions


Example: Registration Status of an Exam

28 2IX20 State machine diagrams: states and transitions


Event – Types (1/2)

Signal event
• Receipt of signal, e.g., rightmousedown, sendSMS(message)
Call event
• Operation call, e.g., occupy(user,lectureHall), register(exam)
Time event
• Time-based state transition
• Relative: based on time of occurrence of event, e.g., after(5 seconds)
• Absolute, e.g, when(time==16:00), when(date==20150101)

29 2IX20 State machine diagrams: states and transitions


Event – Types (2/2)

Any receive event


• Occurs when any event occurs that does not trigger other transition
from active state
• Keyword all basically says: no other transition matches

Completion event
• Generated automatically when everything to be done in current state is
completed
Change event
• Permanently checking whether condition becomes true
• E.g., when(x > y), after(90min)

30 2IX20 State machine diagrams: states and transitions


Change Event vs. Guard
Checked permanently this condition is checked at all times

this condition is only checked


Only checked when event occurs when the lecture has ended

31 2IX20 State machine diagrams: states and transitions


Change Event vs. Guard
Checked permanently

Only checked when event occurs


Question: What if the lecture is shorter than 90min?

32 2IX20 State machine diagrams: states and transitions


33 2IX20 State machine diagrams: states and transitions
2IX20 Software Specification
STATE MACHINE DIAGRAMS: TYPES OF STATES

Based on the slides provided by M.Seidl,


M.Scholz, C. Huemer and G.Kappel,
authors of the book UML@Classroom
Under the Creative Commons Attribution-
NonCommercial 4.0 International licence.
See http://www.uml.ac.at/en/lernen.

Jeroen Keiren

Mathematics & Computer Science / Formal System Analysis


Initial State

• “Start” of state machine diagram


• Pseudostate not a real state of the system
• Transient; system cannot remain in that state
• Rather control structure than real state
• No incoming edges
• If >1 outgoing edges
• Guards must be mutually exclusive and cover all possible cases to ensure that
exactly one target state is reached
• If initial state becomes active, object immediately switches to next state
• No events allowed on outgoing edges (exception: new())

35 2IX20 State machine diagrams: types of states


Final State and Terminate Node

Final State
• Real state
• Marks end of sequence of states However, if it is a nested state or in a sub-state
machine, when it ends up in the final state a
• Object can remain in final state forever completion event is triggered which could potentially
lead to the state machine exiting the final state.

Terminate Node
• Pseudostate
• Terminates state machine
• Modeled object ceases to exist (= is deleted)

36 2IX20 State machine diagrams: types of states


Decision Node

• Pseudostate
• Used to model alternative transitions
equivalent?

37 2IX20 State machine diagrams: types of states


Decision Node

• Pseudostate
• Used to model alternative transitions
equivalent?

38 2IX20 State machine diagrams: types of states


Decision Node

• Pseudostate
• Used to model alternative transitions
equivalent?

=
equivalent?

39 2IX20 State machine diagrams: types of states


Decision Node

• Pseudostate
• Used to model alternative transitions
equivalent?

=
equivalent?
Because the order of


execution of activities
is different here:

40 2IX20 State machine diagrams: types of states


Example: Decision Node
the registration object ceases to exist here

41 2IX20 State machine diagrams: types of states


Parallelization and Synchronization Node

Parallelization node
• Pseudostate
• Splits control flow into multiple concurrent flows => this means we can activate multiple states at
the same time
• 1 incoming edge
• >1 outgoing edges

Synchronization node
• Pseudostate
• Merges multiple concurrent flows
• >1 incoming edges
• 1 outgoing edge
42 2IX20 State machine diagrams: types of states
Composite State

• Synonyms: complex state, nested state


• Contains other states – “substates“
• Only one substate active at any time
• Arbitrary nesting depth of substates
Composite state

Substates

43 2IX20 State machine diagrams: types of states


Configuration

• In hierarchical state machine diagram we can be in multiple states at a time


• Configuration: a valid combination of (sub)states
=> a configuration needs to respect the hierarchy of states.

• Configurations: 𝑆3 , 𝑆1, 𝑆1.1 , 𝑆1, 𝑆1.2 , {𝑆2}

44 2IX20 State machine diagrams: types of states


Entry and Exit Points

Encapsulation mechanism
• Composite state shall be entered or exited via a state other than the initial and final states
• External transition must/need not know structure of composite state
=> so then it is up to the composite state machine to define where this entry/exit point connects internally

External view

45 2IX20 State machine diagrams: types of states


Example: Entry and Exit Points

46 2IX20 State machine diagrams: types of states


Notation Elements (1/2)
Name Notation Description

Description of a specific “time span” in which an


State object finds itself during its “life cycle”. Within a
state, activities can be executed by the object.

Initial state Start of a state machine diagram

Final state End of a state machine diagram

Terminate node Termination of an object’s state machine diagram

47 2IX20 State machine diagrams: types of states


Notation Elements (2/2)
Name Syntax Beschreibung

Node from which multiple alternative


Decision node
transitions can origin

Splitting of a transition into multiple


Parallelization node
parallel transitions

Merging of multiple parallel transitions


Synchronization node
into one transition

48 2IX20 State machine diagrams: types of states


2IX20 Software Specification
STATE MACHINE DIAGRAMS: COMPOSITE STATES AND SEQUENCES OF ACTIONS

Based on the slides provided by M.Seidl,


M.Scholz, C. Huemer and G.Kappel,
authors of the book UML@Classroom
Under the Creative Commons Attribution-
NonCommercial 4.0 International licence.
See http://www.uml.ac.at/en/lernen.

Jeroen Keiren

Mathematics & Computer Science / Formal System Analysis


Entering a Composite State (1/2)
Event Config. Executed
Transition to the boundary Activities
• Initial node of composite state is activated „Beginning“ { S3 }

50 2IX20 State machine diagrams: composite states and sequences of actions


Entering a Composite State (1/2)
Event Config. Executed
Transition to the boundary Activities
• Initial node of composite state is activated „Beginning“ { S3 }

51 2IX20 State machine diagrams: composite states and sequences of actions


Entering a Composite State (1/2)
Event Config. Executed
Transition to the boundary Activities
• Initial node of composite state is activated „Beginning“ { S3 }
e2

Outside-inwards: the entry activity of S1 first


and then the entry activity of S1.1

52 2IX20 State machine diagrams: composite states and sequences of actions


Entering a Composite State (1/2)
Event Config. Executed
Transition to the boundary Activities
• Initial node of composite state is activated „Beginning“ { S3 }
e2

53 2IX20 State machine diagrams: composite states and sequences of actions


Entering a Composite State (1/2)
Event Config. Executed
Transition to the boundary Activities
• Initial node of composite state is activated „Beginning“ { S3 }
e2 a0

54 2IX20 State machine diagrams: composite states and sequences of actions


Entering a Composite State (1/2)
Event Config. Executed
Transition to the boundary Activities
• Initial node of composite state is activated „Beginning“ { S3 }
e2 a0-a2

55 2IX20 State machine diagrams: composite states and sequences of actions


Entering a Composite State (1/2)
Event Config. Executed
Transition to the boundary Activities
• Initial node of composite state is activated „Beginning“ { S3 }
e2 a0-a2-a3

56 2IX20 State machine diagrams: composite states and sequences of actions


Entering a Composite State (1/2)
Event Config. Executed
Transition to the boundary Activities
• Initial node of composite state is activated „Beginning“ { S3 }
e2 a0-a2-a3

57 2IX20 State machine diagrams: composite states and sequences of actions


Entering a Composite State (1/2)
Event Config. Executed
Transition to the boundary Activities
• Initial node of composite state is activated „Beginning“ { S3 }
e2 a0-a2-a3-a4

58 2IX20 State machine diagrams: composite states and sequences of actions


Entering a Composite State (1/2)
Event Config. Executed
Transition to the boundary Activities
• Initial node of composite state is activated „Beginning“ { S3 }
e2 { S1, S1.1 } a0-a2-a3-a4

59 2IX20 State machine diagrams: composite states and sequences of actions


Entering a Composite State (2/2)
Event Config. Executed
Transition to a substate Activities
• Substate is activated „Beginning“ { S3 }

60 2IX20 State machine diagrams: composite states and sequences of actions


23
Entering a Composite State (2/2)
Event Config. Executed
Transition to a substate Activities
• Substate is activated „Beginning“ { S3 }
e1

61 2IX20 State machine diagrams: composite states and sequences of actions


23
Entering a Composite State (2/2)
Event Config. Executed
Transition to a substate Activities
• Substate is activated „Beginning“ { S3 }
e1 a0

62 2IX20 State machine diagrams: composite states and sequences of actions


23
Entering a Composite State (2/2)
Event Config. Executed
Transition to a substate Activities
• Substate is activated „Beginning“ { S3 }
e1 a0-a1

63 2IX20 State machine diagrams: composite states and sequences of actions


23
Entering a Composite State (2/2)
Event Config. Executed
Transition to a substate Activities
• Substate is activated „Beginning“ { S3 }
e1 a0-a1-a3

64 2IX20 State machine diagrams: composite states and sequences of actions


23
Entering a Composite State (2/2)
Event Config. Executed
Transition to a substate Activities
• Substate is activated „Beginning“ { S3 }
e1 a0-a1-a3-a7

65 2IX20 State machine diagrams: composite states and sequences of actions


23
Entering a Composite State (2/2)
Event Config. Executed
Transition to a substate Activities
• Substate is activated „Beginning“ { S3 }
e1 { S1,S1.2 } a0-a1-a3-a7
entry activity of S1 and then entry activity of
S1.2

66 2IX20 State machine diagrams: composite states and sequences of actions


23
Exiting from a Composite State (1/3)
Event Config. Executed
Transition from substate Activities
„Beginning“ { S1,S1.1 } a3-a4
e3

activities from inside-out: exit of S1.1 and


then exit activity of S1, then the activity of
the transition

67 2IX20 State machine diagrams: composite states and sequences of actions


Exiting from a Composite State (1/3)
Event Config. Executed
Transition from substate Activities
„Beginning“ { S1,S1.1} a3-a4
e3 a6

68 2IX20 State machine diagrams: composite states and sequences of actions


Exiting from a Composite State (1/3)
Event Config. Executed
Transition from substate Activities
„Beginning“ { S1,S1.1 } a3-a4
e3 a6-a5

69 2IX20 State machine diagrams: composite states and sequences of actions


Exiting from a Composite State (1/3)
Event Config. Executed
Transition from substate Activities
„Beginning“ { S1,S1.1 } a3-a4
e3 a6-a5-a2

70 2IX20 State machine diagrams: composite states and sequences of actions


Exiting from a Composite State (1/3)
Event Config. Executed
Transition from substate Activities
„Beginning“ { S1,S1.1 } a3-a4
e3 a6-a5-a2-a1

71 2IX20 State machine diagrams: composite states and sequences of actions


Exiting from a Composite State (1/3)
Event Config. Executed
Transition from substate Activities
„Beginning“ { S1,S1.1 } a3-a4
e3 { S2 } a6-a5-a2-a1

activities from inside-out: exit of S1.1


and then exit activity of S1, then the
activity of the transition

72 2IX20 State machine diagrams: composite states and sequences of actions


Exiting from a Composite State (2/3)
Event Config. Executed
Activities
Transition from the composite state „Beginning“ { S1,S1.1 } a3-a4
No matter which e5
substate of S1 is
active, as soon as e5
occurs, the system
changes to S2

73 2IX20 State machine diagrams: composite states and sequences of actions


Exiting from a Composite State (2/3)
Event Config. Executed
Activities
Transition from the composite state „Beginning“ { S1,S1.1 } a3-a4
No matter which e5 a6
substate of S1 is
active, as soon as e5
occurs, the system
changes to S2

74 2IX20 State machine diagrams: composite states and sequences of actions


Exiting from a Composite State (2/3)
Event Config. Executed
Activities
Transition from the composite state „Beginning“ { S1,S1.1 } a3-a4
No matter which e5 a6-a5
substate of S1 is
active, as soon as e5
occurs, the system
changes to S2

75 2IX20 State machine diagrams: composite states and sequences of actions


Exiting from a Composite State (2/3)
Event Config. Executed
Activities
Transition from the composite state „Beginning“ { S1,S1.1 } a3-a4
No matter which e5 a6-a5-a3
substate of S1 is
active, as soon as e5
occurs, the system
changes to S2

76 2IX20 State machine diagrams: composite states and sequences of actions


Exiting from a Composite State (2/3)
Event Config. Executed
Activities
Transition from the composite state „Beginning“ { S1,S1.1 } a3-a4
No matter which e5 a6-a5-a3-a1
substate of S1 is
active, as soon as e5
occurs, the system
changes to S2

77 2IX20 State machine diagrams: composite states and sequences of actions


Exiting from a Composite State (2/3)
Event Config. Executed
Activities
Transition from the composite state „Beginning“ { S1,S1.1 } a3-a4
No matter which e5 { S2 } a6-a5-a3-a1
substate of S1 is
active, as soon as e5
occurs, the system
changes to S2

78 2IX20 State machine diagrams: composite states and sequences of actions


Exiting from a Composite State (3/3)
Event Config. Executed
Activities
Completion transition from the composite state
„Beginning“ { S1,S1.1 } a3-a4
e4

79 2IX20 State machine diagrams: composite states and sequences of actions


Exiting from a Composite State (3/3)
Event Config. Executed
Activities
Completion transition from the composite state
„Beginning“ { S1,S1.1 } a3-a4
e4 a6

80 2IX20 State machine diagrams: composite states and sequences of actions


Exiting from a Composite State (3/3)
Event Config. Executed
Activities
Completion transition from the composite state
„Beginning“ { S1,S1.1 } a3-a4
e4 a6

81 2IX20 State machine diagrams: composite states and sequences of actions


Exiting from a Composite State (3/3)
Event Config. Executed
Activities
Completion transition from the composite state
„Beginning“ { S1,S1.1 } a3-a4
e4 { S1,S1.2 } a6-a7

82 2IX20 State machine diagrams: composite states and sequences of actions


Exiting from a Composite State (3/3)
Event Config. Executed
Activities
Completion transition from the composite state
„Beginning“ { S1,S1.1 } a3-a4
e4 { S1,S1.2 } a6-a7
e4

83 2IX20 State machine diagrams: composite states and sequences of actions


Exiting from a Composite State (3/3)
Event Config. Executed
Activities
Completion transition from the composite state
„Beginning“ { S1,S1.1 } a3-a4
e4 { S1,S1.2 } a6-a7
e4 a8

84 2IX20 State machine diagrams: composite states and sequences of actions


Exiting from a Composite State (3/3)
Event Config. Executed
Activities
Completion transition from the composite state
„Beginning“ { S1,S1.1 } a3-a4
e4 { S1,S1.2 } a6-a7
e4 a8

85 2IX20 State machine diagrams: composite states and sequences of actions


Exiting from a Composite State (3/3)
Event Config. Executed
Activities
Completion transition from the composite state
„Beginning“ { S1,S1.1 } a3-a4
e4 { S1,S1.2 } a6-a7
e4 a8-a5

86 2IX20 State machine diagrams: composite states and sequences of actions


Exiting from a Composite State (3/3)
Event Config. Executed
Activities
Completion transition from the composite state
„Beginning“ { S1,S1.1 } a3-a4
e4 { S1,S1.2 } a6-a7
e4 a8-a5

87 2IX20 State machine diagrams: composite states and sequences of actions


Exiting from a Composite State (3/3)
Event Config. Executed
Activities
Completion transition from the composite state
„Beginning“ { S1,S1.1 } a3-a4
e4 { S1,S1.2 } a6-a7
e4 a8-a5-a1

88 2IX20 State machine diagrams: composite states and sequences of actions


Exiting from a Composite State (3/3)
Event Config. Executed
Activities
Completion transition from the composite state
„Beginning“ { S1,S1.1 } a3-a4
e4 { S1,S1.2 } a6-a7
e4 { S2 } a8-a5-a1

completion transition: has no event

89 2IX20 State machine diagrams: composite states and sequences of actions


Orthogonal State

• Composite state divided into two or more regions separated by dashed line
• One state of each region is active at any point in time: concurrent substates
• Entry: transition to boundary of orthogonal state activates initial states of all
regions
• Exit: final state must be reached in all regions to trigger completion event

Using parallelization and


synchronization node to
enter different substates

90 2IX20 State machine diagrams: composite states and sequences of actions


Submachine State (SMS)

• To reuse parts of state machine diagrams in other state machine diagrams


• Notation: state:submachineState
• When submachine state activated, behavior of submachine is executed
• Corresponds to calling a subroutine in programming languages

Refinement symbol
(optional)

91 2IX20 State machine diagrams: composite states and sequences of actions


History State facilitates memory

• Remembers which substate of composite state was last active


• Activates “old” substate; all entry activities are conducted sequentially from
outside to inside of composite state
• Exactly one outgoing edge of history state points to a substate which is used if
• composite state was never active before : so when no history has been build up yet.
• composite state was exited via final state
• Shallow history state restores state that is on same level of composite state

• Deep history state restores last active substate over the entire nesting depth

92 2IX20 State machine diagrams: composite states and sequences of actions


Example: History State (1/4)

Event Config
„Beginning“ { S5 }
e1 { S4,S1,S1.1 }
e2 { S4,S1,S1.2 }
e10 { S5 }
e9 (H→) {S4, S1,S1.1}

We only remember that when previously when we were in S4, we were in S4. S1, S1.2, we don't remember in what substate of S1, we
initialize in S1.1 (substates not known we're using H, not H*)

93 2IX20 State machine diagrams: composite states and sequences of actions


Example: History State (2/4)

Event Config.
„Beginning“ { S5 }
e1 { S4,S1,S1.1 }
e2 { S4,S1,S1.2 }
e10 { S5 }
e8 (H*→) { S4,S1,S1.2 }

Using H*: we then recall exactly in which configuration below S4 we were: {S4, S1, S1.2}

94 2IX20 State machine diagrams: composite states and sequences of actions


Example: History State (3/4)

Event Config.
„Beginning“ { S5 }
e9 (H→) { S4,S1,S1.1}

When going to H from the beginning, we trigger the initial state: leading us to end up in {S4,
S1, S1.1} as there is no history yet

95 2IX20 State machine diagrams: composite states and sequences of actions


Example: History State (4/4)

Event Config.
„Beginning“ { S5 }
e8 (H*→) { S4,S3,S3.1 }

When going to H* pointing to S3 from the beginning, we trigger the initial state: leading us to end up in {S4, S3, S3.1} as there is
no history yet

96 2IX20 State machine diagrams: composite states and sequences of actions


97 2IX20 State machine diagrams: composite states and sequences of actions

You might also like