5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1....

55
5. Statechart Diagrams

Transcript of 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1....

Page 1: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5. Statechart Diagrams

Page 2: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5. Statechart Diagrams 163

5.1 Examples for Statecharts

• To follow: examples from the UML notation guide

• plus other examples

Page 3: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.1 Examples for Statecharts 164

Statechart Syntax – Overview

01

01

01

0*

01

01

<state-name>

<state> <state>

<state>

<state>

{ <event> } { [ <guard> ] } { / <action> }01

<state-name>

{ entry / <action> }

{ do / <action> }

{ <event> / <action> }

{ exit / <action> }

<state> <state>

<state-name>

<state> <state>

pseudo states: initial, final, synchronisation, deep history, shallow history, stub

<transition> ::= <state> ::=

<state-with-sequential-substates> ::= <state-with-concurrent-substates> ::=

Page 4: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.1 Examples for Statecharts 165

Statechart Diagram (3-71)

Page 5: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.1 Examples for Statecharts 166

Statechart Diagram (3-72)

Page 6: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.1 Examples for Statecharts 167

Statechart Diagram (3-73)

Page 7: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.1 Examples for Statecharts 168

Statechart Diagram (3-74)

Page 8: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.1 Examples for Statecharts 169

Statechart Diagram (3-75)

Page 9: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.1 Examples for Statecharts 170

Statechart (3-77)

Page 10: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.1 Examples for Statecharts 171

Statechart Diagram (3-78)

Page 11: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.1 Examples for Statecharts 172

Statechart Diagram (3-79)

Page 12: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.1 Examples for Statecharts 173

Statechart Diagram (3-80)

Page 13: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.1 Examples for Statecharts 174

Statechart Diagram (3-81)

Page 14: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.1 Examples for Statecharts 175

Statechart Diagram (3-82)

Page 15: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.1 Examples for Statecharts 176

Statechart Diagram (3-83)

Page 16: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.1 Examples for Statecharts 177

Submission Status for Scientific Paper

rejected

published

inPreparation

inRefereeing

refereed

accepted

hopelessinRevision

inPolishingsubmitted

Page 17: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.1 Examples for Statecharts 178

Education Status for People (1)

atSchool

atUniversity

inEducation

professional

Page 18: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.1 Examples for Statecharts 179

Education Status for People (2)

atSchool

preSchool primSchool secSchool highSchool

Page 19: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.1 Examples for Statecharts 180

Education Status for People (3)

atUniversity

student bachelor doctormaster

Page 20: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.1 Examples for Statecharts 181

Education Status for People (4)

inEducation

apprentice journeyman master

Page 21: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.1 Examples for Statecharts 182

Education Status for People (5)

professional

employed unemployed

Page 22: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.1 Examples for Statecharts 183

Civil Status for People

single

non-single

married divorced

widowed

Page 23: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.1 Examples for Statecharts 184

One-shot State Diagram for Chess Game

Page 24: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.1 Examples for Statecharts 185

State Diagram with Guarded Transitions

Page 25: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.1 Examples for Statecharts 186

Actions for Pop-up Menu

Page 26: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.1 Examples for Statecharts 187

Vending Machine Model

Page 27: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.1 Examples for Statecharts 188

Dispense Item Activity of Vending Machine

Page 28: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.1 Examples for Statecharts 189

Select Item Transition of Vending Machine

Page 29: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.1 Examples for Statecharts 190

An Aggregation and its Concurrent StateDiagrams (1)

Page 30: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.1 Examples for Statecharts 191

An Aggregation and its Concurrent StateDiagrams (2)

Page 31: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.1 Examples for Statecharts 192

Entering a PIN Number (1)

Reset

Reset

Reset

Reset

UnDo

UnDo

UnDo

UnDo

OK

NoInput

2DigitsIn

3DigitsIn

4DigitsIn

ToBeVerified

1DigitIn

0..9

0..9

0..9

0..9

Page 32: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.1 Examples for Statecharts 193

Entering a PIN Number (2)

DigitsIn

ToBeVerified

NoInput

UnDo

UnDo

UnDo

UnDo

OK

2DigitsIn

3DigitsIn

4DigitsIn

1DigitIn

0..9

0..9

0..9

0..9

Reset

Page 33: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.1 Examples for Statecharts 194

Entering a PIN Number (3)

NoInput

ToBeVerified

DigitsIn

0..9 UnDo

OK

Reset

Page 34: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.1 Examples for Statecharts 195

Traffic Light (1)

yellow YELLOWpushYellow

pushYellow

red REDpushRed

pushRed

green GREENpushGreen

pushGreen

Page 35: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.2 Examples for Statecharts 196

Traffic Light (2)

pushYellow pushYellow pushYellowpushYellow

RED-YELLOW-green

RED-yellow-GREEN

red-YELLOW-GREEN

red-yellow-GREEN

red-YELLOW-green

RED-YELLOW-GREEN

RED-yellow-greenred-yellow-green

pushRed

pushRed

pushRed

pushRed

pushRed

pushRed

pushRed

pushRed

pushGreen

pushGreen

pushGreen

pushGreen

pushGreen

pushGreen

pushGreen

pushGreen

pushYellow pushYellow pushYellow pushYellow

Page 36: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.2 Examples for Statecharts 197

5.2 Graph Transformation for Statecharts

Explanation 1 (SC Diagram Semantics)• explain state expansion in nested UML state diagrams

1. adding boundary nodes introducing a preciseinterface for the state to be expanded

2. expanding the state3. removing the boundary nodes

• our approach: intermediate step between original UMLdiagrams and a general comprehensive semanticalframework

Page 37: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.2 Examples for Statecharts 198

Explanation (Cont’d SC Diagram Semantics)• graph notation: as close as possible to original UML

representation, but a representation forcing anunambiguous interpretation

• resulting graphs (in the view of this section, thesemantics of the UML state diagrams) can betranslated into various semantical frameworks liketemporal logics, streams, or (again) graphtransformation systems (among other approaches)

Page 38: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.2 Graph Transformation for Statecharts 199

Car Transmission – UML High Level Diagram

upstop upFirst Second

downThird

down

Forward

pushNpushF

Neutral ReversepushN

pushRTransmission-L

Page 39: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.2 Graph Transformation for Statecharts 200

Car Transmission – High Level Graph

pushF

Forward

Neutral ReversepushN

pushR

pushN

Page 40: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.2 Graph Transformation for Statecharts 201

Resulting Low Level Graph

up

Neutral ReversepushN

pushR

First

Second

Third

stop

stop

stop pushN

pushN

pushF pushN

up down

down

Page 41: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.2 Graph Transformation for Statecharts 202

Graph Transformation System forIntroducing the Boundary Nodes

Conventions for graph production layout

• nodes in the top of a production represent nodesoutside the part to be expanded

• nodes in the bottom of a production represent nodesinside the part to be expanded

LL

L

L

Page 42: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.2 Graph Transformation for Statecharts 203

Car Transmission – Explicit Boundaries inthe High Level Graph

pushR

Forward

Neutral Reverse

pushF pushNpushN

Page 43: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.2 Graph Transformation for Statecharts 204

Graph Transformation System for the CarTransmission Example

Forward

Second

Third

stop

up

up

down

down

stop

stop

First

Page 44: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.2 Graph Transformation for Statecharts 205

Applying the Rule in the High Level Graph

down

Neutral Reverse

pushF pushNpushN

pushR

First

Second

Third

stop

stop

stop

up

up

down

Page 45: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.2 Graph Transformation for Statecharts 206

Graph Transformation System for Removingthe Boundary Nodes

LL

L

LL

L L

Page 46: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.2 Graph Transformation for Statecharts 207

Stubbed Transitions – UML High and LowLevel Diagram

s

A

B D

C

StubbedTransitions-H

W

r

p

sA

B

StubbedTransitions-L

D

CE

F

W

u

tr

p

s

Page 47: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.2 Graph Transformation for Statecharts 208

Stubbed Transitions - Explicit Stubs andBoundaries in the High Level Graph

s

A

B

W

D

Cp

r

s

A

B

W

D

C

r

p

Page 48: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.2 Graph Transformation for Statecharts 209

Graph Transformation System forIntroducing the Final Node

Page 49: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.2 Graph Transformation for Statecharts 210

Graph Transformation System for theStubbed Transitions Example

W

s

F

E

u

t

Page 50: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.2 Graph Transformation for Statecharts 211

Stubbed Transitions – Applying the Rule inthe High Level Graph

Es

F

u

B

A C

D

p

r

s

t

Page 51: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.2 Graph Transformation for Statecharts 212

Graph Transformation System for Removingthe Stubs

L

LL L L L

L

Page 52: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.2 Graph Transformation for Statecharts 213

Graph Transformation System for Removingthe Final Node

LL L L L

Page 53: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.2 Graph Transformation for Statecharts 214

Stubbed Transitions – Resulting Low LevelGraph

EA

B D

Cp

F

u

r t

s

s

Page 54: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.2 Graph Transformation for Statecharts 215

General Steps for Statechart DiagramSemantics

General steps

• Step 0: Consider productions for boundary and stubnode insertion and deletion

• Step 1: Make explicit part to be expanded byintroducing boundary nodes

• (Step 1∗): If needed, make explicit stub nodes

• Step 2: Define graph transformation production for stateexpansion

Page 55: 5. Statechart Diagrams - uni-bremen.de• explain state expansion in nested UML state diagrams 1. adding boundary nodes introducing a precise interface for the state to be expanded

5.2 Graph Transformation for Statecharts 216

General Steps for Statechart DiagramSemantics (cont’d)

• Step 3: Apply graph transformation production

• (Step 4∗): If needed, remove stub nodes

• Step 4: Remove boundary nodes