0% found this document useful (0 votes)
32 views

3.6 State Diagrams: © J.W. Schmidt, Florian Matthes 1999

A state diagram is a graph consisting of o states simple states composite states (simple states refined by nested state diagrams) a transition connects two states and shows the flow of control. An event is a phenomenon in space and time significant for the modeled system.

Uploaded by

Virendra Sinha
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

3.6 State Diagrams: © J.W. Schmidt, Florian Matthes 1999

A state diagram is a graph consisting of o states simple states composite states (simple states refined by nested state diagrams) a transition connects two states and shows the flow of control. An event is a phenomenon in space and time significant for the modeled system.

Uploaded by

Virendra Sinha
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

J.W.

Schmidt, Florian Matthes 1999

3.6 State Diagrams


Subject/Topic/Focus: o Introduction to State Diagrams Summary: o States o Transitions o Events o Composition o Concurrency o Branch o History Literature: o [Fowler99] o [Booch98]
State Diagrams last change: 18 Januar, 2000 3.6.1

State Machines in UML


A state machine o specifies state changes which an object performs triggered by events or signals received from other objects, o specifies the reactions of the object on events, o specifies actions in states, o defines protocols, i.e., legal sequences of operation calls of a class or interface or of interactions by signals.

o is attached to exactly one class o can be inherited by subclasses (where the concept of the refinement is not defined exactly)

State Diagrams

3.6.2

3.6.1

J.W. Schmidt, Florian Matthes 1999

States and State Diagrams


A state diagram is a graph consisting of o states simple states composite states (simple states refined by nested state diagrams) o state transitions connecting the states.

A state is a constraint or a situation in the life cycle of an object, in which a constraint holds, the object executes an activity or waits for an event.

Notation:

passive

active

state
State Diagrams

name

state transition
3.6.3

Start and Final States


Start state: State transition is executed immediately during the creation of the object. Only possible event: create(parameter) Java: constructor (new)

Notation:

start state

final state

active create(init) destroy / send master.destroyed(self)

State Diagrams

3.6.4

3.6.2

J.W. Schmidt, Florian Matthes 1999

Transitions
A transition connects two states and shows the flow of control. A transition can include a triggering event, a guard and actions to be executed. Transitions without event and guard are executed immediately when an activity is finished respectively all sub states were passed through.

Notation:

event with parameter

guard

login(user) [NumberOfUsers < max] / greet(user) turn off login active self transition action login(user) [NumberOfUsers = max] / deny(user)
State Diagrams 3.6.5

passive

Events
An event is a phenomenon in space and time significant for the modeled system.

An event can appear synchronously or asynchronously. o synchronous events: call event: triggered by call exception event: triggered by called object at return o asynchronous events: signal event: signal sent by other object change event: triggered by side effects on object attributes time event: spontaneously triggered by boolean guard over time

An event can trigger state changes.

State Diagrams

3.6.6

3.6.3

J.W. Schmidt, Florian Matthes 1999

Signal Events and Call Events


Signals are asynchronous, i.e., the sender does not wait until the receiver received the signal or reacted on it. A call event is triggered by a (synchronous) operation call. Call events are synchronous, i.e., the sender waits until the receiver reacted on the event. In the state automaton signals and call events are indistinguishable from each other. The receiver can o ignore the event (the event is lost), o execute its trigger event or o execute an operation.

State Diagrams

3.6.7

Call Events
Notation:

event

parameter

manual control

startAutopilot(goal)

automatic control

state

Name and parameter of the event must be compatible to methods of the class.

State Diagrams

3.6.8

3.6.4

J.W. Schmidt, Florian Matthes 1999

Time and Change Events


A time event appears after the expiration of a time period.

A change event occurs if a specific constraint is fulfilled. The constraint is a boolean expression on the attributes of the actual object. change event

Notation:

when NumberOfUsers = 0 active after 10 minutes backup

time event
State Diagrams 3.6.9

Sending Signals
Signals can be sent to other objects during a transition.

Notation: active alternative after 10 min. / send central.amAlive(self) after 10 min send amAlive(self) active

send signal

receiving object

central

State Diagrams

3.6.10

3.6.5

J.W. Schmidt, Florian Matthes 1999

Triggering Actions
Possible actions: o send signal o perform call o perform access Notation: entry action active exit action intern transition activity delayed event
State Diagrams 3.6.11

entry / startMotor(3000 U/Min) exit / stopMotor() new speed x / speed(x) do / warningLight() turn electricity off / defer

Composite States
A state can be refined hierarchically by composite states. Notation: composite state active card inserted abort inspection [ok] transition from sub state key in the machine ready choice transfer(x) transaction sub state start state

transition from each sub state wait

card inserted

entry / read card exit / eject card

transition in sub state


State Diagrams 3.6.12

3.6.6

J.W. Schmidt, Florian Matthes 1999

Concurrent Sub States


In a state several sequences of sub states described by own state machines can be performed concurrently. installation fork final test hardware test test ports software test test modules test application Alternative: active objects
3.6.13

Notation: finish

error

join

test devices

concurrent sub state


State Diagrams

Concurrent Sub States: Alternative

fork final test hardware test test ports installation software test test modules test application test devices

join

operating

State Diagrams

3.6.14

3.6.7

You might also like