Introduction to State Diagrams State Charts in UML - PowerPoint PPT Presentation

1 / 27
About This Presentation
Title:

Introduction to State Diagrams State Charts in UML

Description:

Automata ... As the automaton changes state it can generate outputs: on. off. Lamp On ... set of final states (if terminating automaton) Introduction to UML. 8. top. Basic ... – PowerPoint PPT presentation

Number of Views:108
Avg rating:3.0/5.0
Slides: 28
Provided by: kosmidi
Category:

less

Transcript and Presenter's Notes

Title: Introduction to State Diagrams State Charts in UML


1
Introduction to State Diagrams / State Charts in
UML
  • CS320 Fundamentals of Software Engineering
  • Slides adapted from Matthias Sand

2
State Machines Overview
  • Basic State Machine Concepts
  • State Diagrams / State Charts and Objects
  • Advanced Modeling Concepts
  • Wrap Up

3
Automata
  • A machine whose output behavior is not only a
    direct consequence of the current input, but of
    some past history of its inputs
  • Characterized by an internal state which
    represents this past experience

4
State Machine (Automaton) Diagram
  • Graphical rendering of automata behavior

Lamp On
Lamp Off
5
Outputs and Actions
  • As the automaton changes state it can generate
    outputs

6
Extended State Machines
  • Addition of variables (extended state)

ctr Integer
7
A Bit of Theory
  • An extended state machine is defined by
  • a set of input signals (input alphabet)
  • a set of output signals (output alphabet)
  • a set of states
  • a set of transitions
  • triggering signal
  • action
  • a set of extended state variables
  • an initial state designation
  • a set of final states (if terminating automaton)

8
Basic UML Statechart
top state
State
Initial pseudostate
Trigger
Ready
Transition
/ctr 0
stop
Done
Final state
Action
9
What Kind of Behavior?
  • In general, state machines are suitable for
    describing event-driven, discrete behavior
  • inappropriate for modeling continuous behavior

10
Event-Driven Behavior
  • Event a type of observable occurrence
  • interactions
  • synchronous object operation invocation (call
    event)
  • asynchronous signal reception (signal event)
  • occurrence of time instants (time event)
  • interval expiry
  • calendar/clock time
  • change in value of some entity (change event)
  • Event Instance an instance of an event (type)
  • occurs at a particular time instant and has no
    duration

11
The Behavior of What?
  • In principle, anything that manifests
    event-driven behavior
  • Guarded Sequence Diagrams are used in UML for
    modeling continuous behavior
  • In practice
  • the behavior of individual objects
  • object interactions
  • The dynamic semantics of UML state machines are
    currently mainly specified for the case of active
    objects

12
Basic State Machine Concepts State Diagrams /
Statecharts and Objects Advanced Modeling
Concepts Wrap Up
13
Object Behavior
  • Simple server model

InitializeObject
Handling depends on specific request type
Wait forRequest
HandleRequest
TerminateObject
14
Object Behavior and State Machines
  • Direct mapping

15
Basic State Machine Concepts Statecharts and
Objects Advanced Modeling Concepts Wrap Up
16
State Entry and Exit Actions
  • A dynamic assertion mechanism

entry/lamp.on()
exit/lamp.off()
17
Order of Actions
  • Exit actions prefix transition actions
  • Entry action postfix transition actions

Resulting action sequence printf(exiting) pr
intf(to off) lamp.off()
printf(exiting) printf(needless) lamp.off()
18
Internal Transitions
  • Self-transitions that bypass entry and exit
    actions

Internal transition triggered by an off event
off/null
19
State (Do) Activities
  • Forks a concurrent thread that executes until
  • the action completes or
  • the state is exited through an outgoing transition

do activity
do/while (true) alarm.ring()
20
Guards
  • Conditional execution of transitions
  • guards (Boolean predicates) must be side-effect
    free

21
Static Conditional Branching
  • Merely a graphical shortcut for convenient
    rendering of decision trees

value gt 200 /sell
value lt 100 /reject
(value gt 100) (value lt 200) /sell
22
Dynamic Conditional Branching
  • Choice pseudostate guards are evaluated at the
    instant when the decision point is reached

bid /gain calculatePotentialGain(value)
gain gt 200 /sell
gain lt 100 /reject
(gain gt 100) (gain lt 200) /sell
Dynamic Choice point
23
Hierarchical State Machines
  • Graduated attack on complexity
  • states decomposed into state machines

LampFlashing
24
Stub Notation
  • Notational shortcut no semantic significance

LampFlashing
flash/
FlashOn
on/
FlashOff
25
Group Transitions
Default transition to the initial pseudostate
  • Higher-level transitions

LampFlashing
Group transition
26
Completion Transitions
  • Triggered by a completion event
  • generated automatically when an immediately
    nested state machine terminates

completion transition (no trigger)
27
Triggering Rules
  • Two or more transitions may have the same event
    trigger
  • innermost transition takes precedence
  • event is discarded whether or not it triggers a
    transition

LampFlashing
FlashOn
off/
FlashOff
Write a Comment
User Comments (0)
About PowerShow.com