Beruflich Dokumente
Kultur Dokumente
© BIG / TU Wien 2
Content
Introduction
States
Transitions
Types of events
Types of states
Entry and exit points
© BIG / TU Wien 3
Introduction
Every object takes a finite number of different states during its life
State machine diagram is used as follows:
To model the possible states of a system or object
To show how state transitions occur as a consequence of events
To show what behavior the system or object exhibits in each state
© BIG / TU Wien 4
Example: Lecture Hall with Details
class LectureHall {
private boolean free;
© BIG / TU Wien 5
Example: Digital Clock
© BIG / TU Wien 6
State
entry / Activity(...)
Executed when the object enters the state
exit / Activity(...)
Executed when the object exits the state
do / Activity(...)
Executed while the object remains in this state
© BIG / TU Wien 7
Transition
© BIG / TU Wien 8
Transition – Syntax
Event (trigger)
Exogenous stimulus
Can trigger a state transition
Guard (condition)
Boolean expression
If the event occurs, the guard is checked
If the guard is true
All activities in the current state are terminated
Any relevant exit activity is executed
The transition takes place
If the guard is false
No state transition takes place, the event is discarded
Activity (effect)
9
Sequence of actions executed during the state transition
Transition – Types (1/2)
© BIG / TU Wien 10
Transition – Types (2/2)
© BIG / TU Wien 11
Transition – Sequence of Activity Executions
S1 is left, x is set to 5
© BIG / TU Wien 12
Example: Registration Status of an Exam
© BIG / TU Wien 13
Event – Types (1/2)
Signal event
Receipt of a 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 the time of the occurrence of the event
E.g., after(5 seconds)
Absolute
E.g., when(time==16:00), when(date==20150101)
© BIG / TU Wien 14
Event – Types (2/2)
© BIG / TU Wien 15
Change Event vs. Guard
Checked permanently
© BIG / TU Wien 17
Final State and Terminate Node
Final State
Real state
Marks the end of the sequence of states
Object can remain in a final state forever
Terminate Node
Pseudostate
Terminates the state machine
The modeled object ceases to exist (= is deleted)
© BIG / TU Wien 18
Decision Node
Pseudostate
Used to model alternative transitions
equivalent?
equivalent?
≠
© BIG / TU Wien 19
Example: Decision Node
© BIG / TU Wien 20
Parallelization and Synchronization Node
Parallelization node
Pseudostate
Splits the control flow into multiple concurrent flows
1 incoming edge
>1 outgoing edges
Synchronization node
Pseudostate
Merges multiple concurrent flows
>1 incoming edges
1 outgoing edge
© BIG / TU Wien 21
Composite State
Substates
© BIG / TU Wien 22
Entering a Composite State (1/2)
e2 S1/S1.1 a0-a2-a3-a4
© BIG / TU Wien 23
Entering a Composite State (2/2)
e1 S1/S1.2 a0-a1-a3-a7
© BIG / TU Wien 24
23
Exiting from a Composite State (1/3)
e3 S2 a6-a5-a2-a1
© BIG / TU Wien 25
Exiting from a Composite State (2/3)
© BIG / TU Wien 26
Exiting from a Composite State (3/3)
e4 S1/S1.2 a6-a7
e4 S2 a8-a5-a1
© BIG / TU Wien 27
Orthogonal State
© BIG / TU Wien 28
Submachine State (SMS)
Refinement symbol
(optional)
© BIG / TU Wien 29
History State
Deep history state restores the last active substate over the entire
nesting depth
© BIG / TU Wien 30
Example: History State (1/4)
Event State
„Beginning“ S5
e1 S4/S1/S1.1
e2 S1.2
e10 S5
e9 (H→) S1/S1.1
© BIG / TU Wien 31
Example: History State (2/4)
Event State
„Beginning“ S5
e1 S4/S1/S1.1
e2 S1.2
e10 S5
e8 (H*→) S1.2
© BIG / TU Wien 32
Example: History State (3/4)
Event State
„Beginning“ S5
e9 (H→) S1/S1.1
© BIG / TU Wien 33
Example: History State (4/4)
Event State
„Beginning“ S5
e8 (H*→) S3/S3.1
© BIG / TU Wien 34
Entry and Exit Points
Encapsulation mechanism
A composite state shall be entered or exited via a state other than the
initial and final states
The external transition must/need not know the structure of the composite
state
External view
© BIG / TU Wien 35
Example: Entry and Exit Points
© BIG / TU Wien 36
Notation Elements (1/2)
Name Notation Description
© BIG / TU Wien 37
Notation Elements (2/2)
Name Syntax Beschreibung
© BIG / TU Wien 38