The State Diagrams - PowerPoint PPT Presentation

1 / 21
About This Presentation
Title:

The State Diagrams

Description:

Represents all states an object can have and the transitions between them ... substates, which are active at the same time when the composite state is active! ... – PowerPoint PPT presentation

Number of Views:26
Avg rating:3.0/5.0
Slides: 22
Provided by: EPG6
Category:

less

Transcript and Presenter's Notes

Title: The State Diagrams


1
The State Diagrams
  • Presentation prepared by
  • Daniel Sadowski
  • Jarek Socha
  • Tutor Mariusz Trzaska, PhD
  • PJWSTK 2006

2
The State Diagram
  • Addition to the Class Diagram
  • Represents all states an object can have and the
    transitions between them
  • Relates to the finite automat
  • Created for classes, which have well defined
    states that influence their behaviour

3
The State Diagram II
  • Complete diagram is a set of subdiagrams, which
    communicate with each other using events
  • One classs state diagram can refer to another
    classs state
  • Useful for showing the life cycle of a class

4
State Diagram in UML
  • UML State representation

entry/ action/ action/ ... do/ activity/
activity/... exit/ action/ action/ ...
State Name
5
State Diagrams in UML
  • Action an operation which cannot be stopped
  • List of actions treated as a single action
  • Activity an operation which can be stopped
  • List of activities treated as a single activity
  • Entry keyword defining operations taking place
    after entering the state
  • Do operations happening when the state is
    active
  • Exit keyword defining operations taking place
    when exiting the state

6
State types
  • Simple a state without a substructure
  • Sequential composite state consists of one or
    more substates. Only one of them is active when
    the compisite state is active

7
State types II
  • Concurent composite state divided into at least
    two concurent substates, which are active at the
    same time when the composite state is active!

8
State types III
  • Initial state pseudostate used to indicate the
    starting point of an objects life cycle!
  • Final state pseudostate used to indicate the
    final point of an objects life cycle!

9
State types IV
  • Junction state pseudostate connecting chain of
    transitions into one.
  • History state pseudostate, which activates a
    previously active state.

H
10
State types V
  • Submachine reference state pseudostate to which
    there is a reference on the diagram, switched by
    a state specified in the reference

include S
11
State types VI
  • Stub state (PNIOK) pseudostate to which theres
    a reference on a diagram, which is a part of
    another composite state.

S
12
Events 0001
  • Happen in one point in time
  • Worth analysing from the project designs
    perspective
  • Can be sorted in time

13
Events 0010
  • Calling object receives a synchronized
    operation execution order. Most basic kind of
    event.
  • op(a T)
  • Change satisfies a boolean condition. Such an
    event is useful for modelling situations when an
    object changes its state after receiving an
    answer to a message it sent.
  • when(expression)

14
Events 0011
  • Signal an asynchronic operation execution
    order. Useful in modelling events coming from
    outside of the system
  • name_sig(a T)
  • Time ammount of time elapsed
  • after (time)

15
Actions 0xf6660001
  • Assigment assigns a value to a variable
  • variable expression
  • Call calls an operation on an object. Can
    return a value.
  • name (argh1, argh2, ...)
  • Create creates a new object (surprise!)
  • new name_of_class (argh1, ...)

16
Actions 0xf6660002
  • Destroy deletion of an object
  • destroy()
  • Send creates a signal and sends it to the
    object(s)
  • name_signal(argh1, argh2, ...)
  • Terminate objects so-called suicide
  • terminate

17
Actions 0xf6660003
  • Return specifies a return value
  • return value

18
Transitions
  • Can be defined by an event that called it,
    condition and action, which is called before the
    state change.
  • Therere four types of transitions.

19
Types of transitions
  • External transition
  • Internal transition
  • Selftransition
  • Completion transition

event condition /action
condition /action
State 1
state 2
20
Examples class GUARD
Getting bored
RUNNING TOWARDS MOVEMENT
Friend detection
Movement detection
CHATTING
Detecting enemy / attacking
Finishing looting nothing to loot cant hold
anything more / setting the body on fire
Killing enemy
LOOTING BODY
FIGHTING
WALKING AROUND
Feeling safe again
Losing battle healthlt10
RUNNING AWAY
DYING PAINFULLY
Failing to run away health0
21
EXAMPLE concurent composite state
replacment of oil filter
Oil change
Changing the tires
Checking the tires
Write a Comment
User Comments (0)
About PowerShow.com