0411 ch 5+6 state+advanced

Upload: kokigokul

Post on 06-Apr-2018

224 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/3/2019 0411 CH 5+6 State+Advanced

    1/22

    State Modeling &Advanced State Modeling

    2006. 4. 11

    Seok-Joong Woo

    Object-Oriented Modeling and Design with UML;

    Michael Blaha, James Rumbaugh

  • 8/3/2019 0411 CH 5+6 State+Advanced

    2/22

    2/222006-04-11

    Contents

    Introduction

    State diagrams

    Events States

    Transitions and conditions

    State diagram behavior

    Concurrency

    Summary

  • 8/3/2019 0411 CH 5+6 State+Advanced

    3/22

    3/222006-04-11

    Introduction (1/ 2)

    State model

    Describes sequences of operations that occur inresponse to external stimuli

    Consists of multiple state diagrams, one for eachclass with behavior

    State diagram

    Graphical representation of finite state machinesrelates events and states

  • 8/3/2019 0411 CH 5+6 State+Advanced

    4/22

    4/222006-04-11

    Introduction (2/ 2)

    Finite state machine Model of behavior composed of states, transitions and actions

  • 8/3/2019 0411 CH 5+6 State+Advanced

    5/22

    5/222006-04-11

    State diagrams (1/ 2)

    Definition

    Graph that consists of nodes are states andtransitions between states

    Specification the state sequences by eventsequence

    Representation Continuous loops

    Idle

    DialTone

    Dialing

    Warning

    Timeout

    RecordedMessage

    Connecting

    validNumber

    timeout

    onHook

    invalidNumber

    offHook

    digit(n)

    timeout

  • 8/3/2019 0411 CH 5+6 State+Advanced

    6/22

    6/222006-04-11

    State diagrams (2/ 2)

    Representation (contd)

    One-shot life cycle

    Whites turn

    Blacks turn

    stalemate

    checkmate

    blackmoves

    whitemoves

    Chess

    checkmate

    Whites turn

    Blacks turn

    stalemate

    checkmate

    blackmoves

    whitemoves

    checkmate

    Start

    Black wins

    Draw

    White

    wins

    Chess

    Objects withfinite lives

    Using entry&

    Exit points

  • 8/3/2019 0411 CH 5+6 State+Advanced

    7/22

    7/222006-04-11

    Events (1/ 4)

    Definition

    Occurrence at a point in time

    Following another event

    Two events related or unrelated

    Inclusion error condition and normal occurrences

    Several kinds of events

    Signal event

    Change event

    Time event

  • 8/3/2019 0411 CH 5+6 State+Advanced

    8/22

    8/222006-04-11

    Events (2/ 4)

    Signal Event

    Event of sending or receiving a signal

    Attributes indicating the values

    Signals generalization

    Hierarchy with inheritance of signal attributes

    FlightDeparture

    MouseButtonPushed

    flightNumbercity

    date

    button

    location

  • 8/3/2019 0411 CH 5+6 State+Advanced

    9/22

    9/222006-04-11

    Events (3/ 4)

    Signal Event

    Event of sending or receiving a signal

    Attributes indicating the values

    Signals generalization

    Hierarchy with inheritance of signal attributes

    FlightDeparture

    MouseButtonPushed

    flightNumbercity

    date

    button

    location

    FightDeparture

    MouseButtonPushed

    flightNumbercitydate

    buttonlocation

    U se r I n p u t

    device

    M o u s e B u t t o n

    location

    K e y b o a r d C h a r a c t e r

    character

    Control

    Graphic

    Space

    Alphanumeric

    Punctuation

    MouseButtonDown

    MouseButUp

    Signals generalization

  • 8/3/2019 0411 CH 5+6 State+Advanced

    10/22

    10/222006-04-11

    Events (4/ 4)

    Change Event

    Satisfaction of a boolean expression

    Time Event

    Satisfaction of a time expression

    When (room temperature

  • 8/3/2019 0411 CH 5+6 State+Advanced

    11/22

    11/222006-04-11

    States (1/ 3)

    Definition

    Abstraction of the value and links of an object

    Response of object to input event

    Kinds of states

    Simple state

    Composite state

    Submachine state

    Solvent Insolvent Dial tone Dialing Powered

  • 8/3/2019 0411 CH 5+6 State+Advanced

    12/22

    12/222006-04-11

    States (2/ 3)

    Simple state

    No nested substates

    Composite state

    One or more region One or more nested substates

    Waiting Dialing Powered

  • 8/3/2019 0411 CH 5+6 State+Advanced

    13/22

    13/222006-04-11

    States (3/ 3)

    Submachine state

    Reference a submachine another state machine

    IdleCollecting money

    coins in(amount) / add to balance

    do/ test item and compute change

    do/ make changedispense: Dispenseitem

    do/ move arm to correct row do/move arm to correct column

    do/ push item off shelf

    Dispenseltem

    Submachine

    state

    Submachine

  • 8/3/2019 0411 CH 5+6 State+Advanced

    14/22

    14/222006-04-11

    Transitions and conditions (1/ 3)

    Transitions

    Relationship between two states

    Indicates the way an object in a state responds to event

    Structures of transitionsSource state target state

    Ringing ConnectedCalled phone

    event

    SelectMode SelectMode

    SelectMode

    double-click[self.selection exists] / launch(self.selection)

    click(point) / select(point)

    trigger effect

    guard condition

  • 8/3/2019 0411 CH 5+6 State+Advanced

    15/22

    15/222006-04-11

    Transitions and conditions (2/ 3)

    Completion transition

    Transition of source states activity completion

    Idle

    Choose

    Selected

    cancel /

    eject card

    Insert card

    Selecting

    /reset election pushdone

    pick date/add to selection

    completion transition

  • 8/3/2019 0411 CH 5+6 State+Advanced

    16/22

    16/222006-04-11

    Transitions and conditions (3/ 3)

    Conditions

    Boolean expression

    Occurrence of transition

    North/ southMay go straight

    East/ westMay turn left

    East/ westMay go straight

    North/ southMay turn left

    timeout[cars in N/S left lanes]

    timeout[no cars

    in N/S left lanes]

    timeout[cars in E/W left lanes]

    timeouttimeout timeout[no cars

    in E/W left lanes]

    S di b h i (1/ 2)

  • 8/3/2019 0411 CH 5+6 State+Advanced

    17/22

    17/222006-04-11

    State diagram behavior (1/ 2)

    Activity effects

    Activity is invoked by any number of effects

    Effect is executed in response to an event

    Do-activities

    Activity that continues for an extended time

    Idle Menu visible

    Right button down/ display pop-up menu

    Right button up/ erase pop-up menu Cursor moved/

    highlight menu item

    Paper jamdo/ flash warning light

    event activity

    St t di b h i (2/ 2)

  • 8/3/2019 0411 CH 5+6 State+Advanced

    18/22

    18/222006-04-11

    State diagram behavior (2/ 2)

    Activities on transition or entry to state

    Opening

    Closed Open

    Closing

    depress/ motor up door open/ motor off

    depress/ motor downdoor closed/ motor off

    depress/ motor up

    Openingentry/motor up

    Closedentry/motor up Openentry/motor off

    Closingentry/motor down

    depress door open

    depressdoor closed

    depress

    Activities on transition

    Activities on entry to states

    C (1/ 3)

  • 8/3/2019 0411 CH 5+6 State+Advanced

    19/22

    19/222006-04-11

    Concurrency (1/ 3)

    Definition Performance of two or more activities

    Aggregation concurrency State diagram for an assembly of state diagram, one

    for each part

    Car

    Ignition Transmission Accelerator Brake

    Off Starting On

    turn key to start[Transmission in Neutral]

    turn key off

    release keyIgnition

    11 1 1 1

    C (2/ 3)

  • 8/3/2019 0411 CH 5+6 State+Advanced

    20/22

    20/222006-04-11

    Concurrency (2/ 3)

    Concurrency within an object

    Partition some object into subsets of attributes or links,

    each of which has its own subdiagram

    Not vulnerable

    Not vulnerable

    vulnerable

    vulnerable

    N-S w ins rubber

    E-W w ins rubber

    P laying rubber

    Bridge

    N-S vulnerability

    E-W vulnerability

    N-S game

    E-W game

    N-S game

    E-W game

    Concurrency (3/ 3)

  • 8/3/2019 0411 CH 5+6 State+Advanced

    21/22

    21/222006-04-11

    Concurrency (3/ 3)

    Synchronization of concurrent activities

    Complete both activities before it can progress to

    its next state Control can split into concurrent activities that

    subsequently merge

    do/ dispense cash

    do/ eject card

    Ready to resetSetting up

    Emitting

    ready

    CashDispenser

    Summary

  • 8/3/2019 0411 CH 5+6 State+Advanced

    22/22

    22/222006-04-11

    Summary

    State diagram consists of

    States

    Events

    Guard conditions

    Activities

    Advanced State Modeling using

    Expanding, Nested states

    Signal Generalization

    Concurrency