Top Banner
UML2.0 State Machines WeiBin Liang School of Computer Science McGill University Feb.20, 2004
23

UML2.0 State Machines - McGill Universitymsdl.cs.mcgill.ca/people/hv/teaching/MSBDesign/COMP762B2004/... · Overview • Recap of Harel statecharts • State machines • New modeling

Sep 16, 2018

Download

Documents

votuyen
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: UML2.0 State Machines - McGill Universitymsdl.cs.mcgill.ca/people/hv/teaching/MSBDesign/COMP762B2004/... · Overview • Recap of Harel statecharts • State machines • New modeling

UML2.0 State Machines

WeiBin LiangSchool of Computer Science

McGill UniversityFeb.20, 2004

Page 2: UML2.0 State Machines - McGill Universitymsdl.cs.mcgill.ca/people/hv/teaching/MSBDesign/COMP762B2004/... · Overview • Recap of Harel statecharts • State machines • New modeling

Overview

• Recap of Harel statecharts• State machines• New modeling constructs in UML2.0

state machines

Page 3: UML2.0 State Machines - McGill Universitymsdl.cs.mcgill.ca/people/hv/teaching/MSBDesign/COMP762B2004/... · Overview • Recap of Harel statecharts • State machines • New modeling

Harel state charts

• State diagramsA

B

a/

Figure 1

Page 4: UML2.0 State Machines - McGill Universitymsdl.cs.mcgill.ca/people/hv/teaching/MSBDesign/COMP762B2004/... · Overview • Recap of Harel statecharts • State machines • New modeling

Harel state charts (2)

• State diagrams

• DepthA

B

a/

C Db/

Figure 2

Page 5: UML2.0 State Machines - McGill Universitymsdl.cs.mcgill.ca/people/hv/teaching/MSBDesign/COMP762B2004/... · Overview • Recap of Harel statecharts • State machines • New modeling

Harel state charts (3)

• State diagrams

• Depth• Orthogonality

A

B

a/

C Db/

c/

d/

E F

G I

Figure 3

Page 6: UML2.0 State Machines - McGill Universitymsdl.cs.mcgill.ca/people/hv/teaching/MSBDesign/COMP762B2004/... · Overview • Recap of Harel statecharts • State machines • New modeling

Harel state charts (4)

• State diagrams

• Depth• Orthogonality• Broadcast

A

B

a/

C Db/

c/

d/e

E F

G I

Figure 4

Page 7: UML2.0 State Machines - McGill Universitymsdl.cs.mcgill.ca/people/hv/teaching/MSBDesign/COMP762B2004/... · Overview • Recap of Harel statecharts • State machines • New modeling

Harel state charts (5)

• State diagrams

• Depth• Orthogonality• Broadcast• History

A

B

a/

C Db/

c/

d/e

E F

G I

H

e/

Figure 5

Page 8: UML2.0 State Machines - McGill Universitymsdl.cs.mcgill.ca/people/hv/teaching/MSBDesign/COMP762B2004/... · Overview • Recap of Harel statecharts • State machines • New modeling

State machines

• A behavioral formalism

Figure 6 from [3]

Page 9: UML2.0 State Machines - McGill Universitymsdl.cs.mcgill.ca/people/hv/teaching/MSBDesign/COMP762B2004/... · Overview • Recap of Harel statecharts • State machines • New modeling

State machines (2)

• Behavior state machines– Express behavior of various model elements

(e.g., class instances)– Object-based variant of Harel state charts

• Protocol state machines– Express usage protocols– A convenient way to define a lifecycle for objects,

or an order of the invocation of its operation

Page 10: UML2.0 State Machines - McGill Universitymsdl.cs.mcgill.ca/people/hv/teaching/MSBDesign/COMP762B2004/... · Overview • Recap of Harel statecharts • State machines • New modeling

Abstract syntax

Figure 7 from [1]

Page 11: UML2.0 State Machines - McGill Universitymsdl.cs.mcgill.ca/people/hv/teaching/MSBDesign/COMP762B2004/... · Overview • Recap of Harel statecharts • State machines • New modeling

New modeling constructs

• State machine extension• Modularized state machine• State machine termination• Protocol state machines

Page 12: UML2.0 State Machines - McGill Universitymsdl.cs.mcgill.ca/people/hv/teaching/MSBDesign/COMP762B2004/... · Overview • Recap of Harel statecharts • State machines • New modeling

State machine extension

• A state machine is generalizable. A specialized state machine is an extension of the general state machine.

• In a specialized state machine, all elements of the general state machine will be inherited, regions, vertices and transitions can be added/redefined.

• Rationale: Corresponds to classifier generalization. “It should be possible to define the redefined behavior of a special classifier as an extension of the behavior of the general classifier.” [1]

Page 13: UML2.0 State Machines - McGill Universitymsdl.cs.mcgill.ca/people/hv/teaching/MSBDesign/COMP762B2004/... · Overview • Recap of Harel statecharts • State machines • New modeling

State machine extension (2)

ATM

acceptCard()releaseCard()outOfService()amount()

FlexibleATM

otherAmount()rejectTransaction()

<<extend>>

Statemachine

Statemachine

Behavior

Behavior

Figure 8 from [3]

Page 14: UML2.0 State Machines - McGill Universitymsdl.cs.mcgill.ca/people/hv/teaching/MSBDesign/COMP762B2004/... · Overview • Recap of Harel statecharts • State machines • New modeling

State machine extension (3)• The general state machine

for ATM• The specialized state

machine for FlexibleATM

ATM {extended}

OutOfService{final} OutOfService

VerifyCard{final}

acceptCard

amount

ReleaseCard

releaseCard

{final}{final}

Figure 9 from [3] Figure 10

Page 15: UML2.0 State Machines - McGill Universitymsdl.cs.mcgill.ca/people/hv/teaching/MSBDesign/COMP762B2004/... · Overview • Recap of Harel statecharts • State machines • New modeling

Modular Submachines

• Defines a state machine for the submachine.

• Adds entry/exit points (i.e. pseudostates).

ReadAmountSM

selectAmount

enterAmount

abort

abort

otherAmount

ok

amount

aborted

againFigure 11 from [3]

Page 16: UML2.0 State Machines - McGill Universitymsdl.cs.mcgill.ca/people/hv/teaching/MSBDesign/COMP762B2004/... · Overview • Recap of Harel statecharts • State machines • New modeling

Modular Submachines (2)

• Inserts the submachine into a state machine as a submachine state.

rejectTransaction

again

Figure 12 from [3]

Page 17: UML2.0 State Machines - McGill Universitymsdl.cs.mcgill.ca/people/hv/teaching/MSBDesign/COMP762B2004/... · Overview • Recap of Harel statecharts • State machines • New modeling

State machine termination

• When the final state is entered, its containing region is completed.

• If the region is contained in a state machine and all other regions contained in the state machine are also completed, the entire state machine terminates, which implies the termination of the context object of the state machine.

Page 18: UML2.0 State Machines - McGill Universitymsdl.cs.mcgill.ca/people/hv/teaching/MSBDesign/COMP762B2004/... · Overview • Recap of Harel statecharts • State machines • New modeling

Protocol state machines

• Abstract syntax

Figure 13 from [1]

Page 19: UML2.0 State Machines - McGill Universitymsdl.cs.mcgill.ca/people/hv/teaching/MSBDesign/COMP762B2004/... · Overview • Recap of Harel statecharts • State machines • New modeling

Protocol state machines (2)• Interface

– Specifies conformance characteristics.

– May own a protocol state machine to specify the legal sequence of the invocation of the behavior features described in the interface.

• Port– Represents an interaction point

between a classifier instance and its environment or between a classifier instance and instances it may contains

– Provided/required interfaces– Encapsulation

<<interface>>Caller

<<interface>>Operator

<<interface>>Callee

ClassX

Operator assisted call

<<requires>>

<<requires>>

<<provides>>

Caller Operator Calleecallack

numbercallack

transfer

talk

Figure 14 from [3]

Page 20: UML2.0 State Machines - McGill Universitymsdl.cs.mcgill.ca/people/hv/teaching/MSBDesign/COMP762B2004/... · Overview • Recap of Harel statecharts • State machines • New modeling

More Usages on Ports• Connector: Model the

communication channel

• Models a structured class that contains parts and connectors

sender: Fax receiver:Faxremote

remote

sender:Fax receiver:Faxremote

remote

sendCtrl

c

receiveCtrl

c

Figure 15 from [3]

Page 21: UML2.0 State Machines - McGill Universitymsdl.cs.mcgill.ca/people/hv/teaching/MSBDesign/COMP762B2004/... · Overview • Recap of Harel statecharts • State machines • New modeling

Protocol state machines (3)• Protocol state machines

– Specify which operations of the classifier can be called in which state and under which condition, thus specifying the allowed call sequences on the classifier’s operations.

– Provide a global view of the classifier protocol usage.

• Protocol transition– Pre/post condition and trigger.– No effect action.

Figure 16 from [1]

Page 22: UML2.0 State Machines - McGill Universitymsdl.cs.mcgill.ca/people/hv/teaching/MSBDesign/COMP762B2004/... · Overview • Recap of Harel statecharts • State machines • New modeling

Protocol state machines (4)

• ProtocolConformanceUsed in the protocol state machine redefinition. Protocol state machines can be redefined into more specific protocol state machines, or into behavior state machines.– specificMachine: StateMachine

Specifies the state machine that conforms to the general protocol state machine.

– generalMachine: ProtocolStateMachineSpecifies the protocol state machine to which the general state machine conforms.

Page 23: UML2.0 State Machines - McGill Universitymsdl.cs.mcgill.ca/people/hv/teaching/MSBDesign/COMP762B2004/... · Overview • Recap of Harel statecharts • State machines • New modeling

References[1] OMG: UML 2.0: Superstructure - Final Adopted Specification,

http://www.omg.org/uml/[2] OMG: UML 2.0: Infrastructure - Final Adopted Specification,

http://www.omg.org/uml/[3] Bran Selic's presentation, Preview of UML 2.0 and MDA,

March 7, 2003.