5. statechart diagrams - uni-bremen.de · 5. statechart diagrams 163 5.1 examples for statecharts...

55
5. Statechart Diagrams

Upload: vuhuong

Post on 15-Sep-2018

231 views

Category:

Documents


0 download

TRANSCRIPT

5. Statechart Diagrams

5. Statechart Diagrams 163

5.1 Examples for Statecharts

• To follow: examples from the UML notation guide

• plus other examples

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> ::=

5.1 Examples for Statecharts 165

Statechart Diagram (3-71)

5.1 Examples for Statecharts 166

Statechart Diagram (3-72)

5.1 Examples for Statecharts 167

Statechart Diagram (3-73)

5.1 Examples for Statecharts 168

Statechart Diagram (3-74)

5.1 Examples for Statecharts 169

Statechart Diagram (3-75)

5.1 Examples for Statecharts 170

Statechart (3-77)

5.1 Examples for Statecharts 171

Statechart Diagram (3-78)

5.1 Examples for Statecharts 172

Statechart Diagram (3-79)

5.1 Examples for Statecharts 173

Statechart Diagram (3-80)

5.1 Examples for Statecharts 174

Statechart Diagram (3-81)

5.1 Examples for Statecharts 175

Statechart Diagram (3-82)

5.1 Examples for Statecharts 176

Statechart Diagram (3-83)

5.1 Examples for Statecharts 177

Submission Status for Scientific Paper

rejected

published

inPreparation

inRefereeing

refereed

accepted

hopelessinRevision

inPolishingsubmitted

5.1 Examples for Statecharts 178

Education Status for People (1)

atSchool

atUniversity

inEducation

professional

5.1 Examples for Statecharts 179

Education Status for People (2)

atSchool

preSchool primSchool secSchool highSchool

5.1 Examples for Statecharts 180

Education Status for People (3)

atUniversity

student bachelor doctormaster

5.1 Examples for Statecharts 181

Education Status for People (4)

inEducation

apprentice journeyman master

5.1 Examples for Statecharts 182

Education Status for People (5)

professional

employed unemployed

5.1 Examples for Statecharts 183

Civil Status for People

single

non-single

married divorced

widowed

5.1 Examples for Statecharts 184

One-shot State Diagram for Chess Game

5.1 Examples for Statecharts 185

State Diagram with Guarded Transitions

5.1 Examples for Statecharts 186

Actions for Pop-up Menu

5.1 Examples for Statecharts 187

Vending Machine Model

5.1 Examples for Statecharts 188

Dispense Item Activity of Vending Machine

5.1 Examples for Statecharts 189

Select Item Transition of Vending Machine

5.1 Examples for Statecharts 190

An Aggregation and its Concurrent StateDiagrams (1)

5.1 Examples for Statecharts 191

An Aggregation and its Concurrent StateDiagrams (2)

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

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

5.1 Examples for Statecharts 194

Entering a PIN Number (3)

NoInput

ToBeVerified

DigitsIn

0..9 UnDo

OK

Reset

5.1 Examples for Statecharts 195

Traffic Light (1)

yellow YELLOWpushYellow

pushYellow

red REDpushRed

pushRed

green GREENpushGreen

pushGreen

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

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

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)

5.2 Graph Transformation for Statecharts 199

Car Transmission – UML High Level Diagram

upstop upFirst Second

downThird

down

Forward

pushNpushF

Neutral ReversepushN

pushRTransmission-L

5.2 Graph Transformation for Statecharts 200

Car Transmission – High Level Graph

pushF

Forward

Neutral ReversepushN

pushR

pushN

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

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

5.2 Graph Transformation for Statecharts 203

Car Transmission – Explicit Boundaries inthe High Level Graph

pushR

Forward

Neutral Reverse

pushF pushNpushN

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

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

5.2 Graph Transformation for Statecharts 206

Graph Transformation System for Removingthe Boundary Nodes

LL

L

LL

L L

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

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

5.2 Graph Transformation for Statecharts 209

Graph Transformation System forIntroducing the Final Node

5.2 Graph Transformation for Statecharts 210

Graph Transformation System for theStubbed Transitions Example

W

s

F

E

u

t

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

5.2 Graph Transformation for Statecharts 212

Graph Transformation System for Removingthe Stubs

L

LL L L L

L

5.2 Graph Transformation for Statecharts 213

Graph Transformation System for Removingthe Final Node

LL L L L

5.2 Graph Transformation for Statecharts 214

Stubbed Transitions – Resulting Low LevelGraph

EA

B D

Cp

F

u

r t

s

s

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

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