1 / 47

UML 2.0 State Diagrams

Concepts & Notations. UML 2.0 State Diagrams. Acknowledgements. The material in this tutorial is based in part on: Concurrency: State Models & Java Programming , by Jeff Magee and Jeff Kramer

luke
Download Presentation

UML 2.0 State Diagrams

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Concepts & Notations UML 2.0 State Diagrams

  2. Acknowledgements • The material in this tutorial is based in part on: • Concurrency: State Models & Java Programming, by Jeff Magee and Jeff Kramer • The Unified Modeling Language Reference Manual, 2nd edition, by James Rumbaugh, Ivar Jacobson, and Grady Booch

  3. Finite-state Models State Machine View Events, Transitions, and States Examples UML State Diagram

  4. Finite-state Models • Represent the behavior of a system over time • Specify control • In terms of states, events, and transitions • Transitions occur only when they are enabled • Many variants exist • Graphical: State charts, UML state diagrams • Textual: FSP

  5. State Machine View • Describes dynamic behavior of objects over time • Describes states that objects may hold, and how they will react to events when in those states • Describes classes and corresponding instances • Also behaviors, use cases, collaborations • A localized view • External influences summarized as events

  6. Event, Transition & State • Event • occurrence at a point in time • Instantaneous • verbs of past tense • onset of a condition • Transition • State

  7. Kinds of Events

  8. Kinds of Events

  9. Kinds of Events

  10. Kinds of Events

  11. Kinds of Events

  12. Event, Transition & State • Event • Transition • Instantaneous change in state • 4 key elements • event trigger • guard condition • effect • target state • State

  13. Kinds of Transitions

  14. Kinds of Transitions

  15. Transition event(attributes)[guard condition] / effect S T

  16. Transition event(attributes)[guard condition] / effect S T

  17. Transition event(attributes)[guard condition] / effect S T

  18. Transition event(attributes)[guard condition] / effect S T

  19. Effects • An effect may be an action or an activity. • action: a primitive computation • x = 3 • z = x+1 • sending a signal • calling an operation • new Widget(x,3) • widg.getValue() • widg.setValue(5);

  20. Effects • An effect may be an action or an activity. • activity : a list of simpler actions or activities • the specification of executable behavior as the coordinated sequential and concurrent execution of subordinate units.

  21. Transition event(attributes)[guard condition] / effect S T

  22. Multiple transitions • Multiple transitions from the same state may specify the same event trigger • only one transition may fire in response to one event occurrence • each transition with same event must have a different guard condition • Often, conditions together cover all possibilities • If an uncovered possibility occurs, the event is ignored

  23. Not allowed … State 3 done State 1 .... State 4 done

  24. Uncovered possibilities … done [ x > 20] State 3 State 1 ... State 4 done [ x < 10] CSE 335: Software Design

  25. Completion transition • A transition that lacks an explicit trigger event • is triggered by the completion of activity in the state that it leaves • May have a guard condition • takes priority over ordinary events • State 1 State 2

  26. Kinds of Transitions

  27. Kinds of Transitions

  28. Kinds of Transitions

  29. Examples Opening entry / motor up exit / motor off figure 1 Copying entry / light up and scan exit / light off Copying entry / light up and scan exit / light off Print 10 copies Print 10 copies figure 3 figure 2

  30. Order of activities • activities on incoming transition • entry activities • do-activities • execution of behavior within a state machine that is based on holding a given state • starts when the state is entered • continues until the activity completes on its own or the state is exited • not terminated by the firing of an internal transition • exit activities • activities on outgoing transition

  31. Event, State & Transition • Event • Transition • State • behavioral condition that persists in time • corresponds to verbs with suffix of “-ing” • an abstraction of values of attributes and configuration of objects • a set of object with similar values • object waits for events • object performs ongoing activity

  32. Kinds of States • simple state • notation: S

  33. Kinds of States • initial state • notation:

  34. Kinds of States • final state • notation: S

  35. Example Chess game start state White’s turn checkmate stalemate black moves white moves stalemate Black’s turn Default final state checkmate simple state

  36. Example Chess game Black wins start state checkmate White’s turn Final states stalemate black moves white moves Draw stalemate Black’s turn White wins checkmate

  37. Kinds of States • entry point • notation: a T

  38. Kinds of States • exit point • notation: b U

  39. Example Chess game entry point exit point checkmate White’s turn Black wins Draw White wins stalemate black moves white moves stalemate Black’s turn checkmate

  40. Kinds of States • submachine state • notation: s:M

  41. Examples submachine Help Main machine CommandWait entry / display help screen exit / remove help screen quit run command help command run:Run help:Help query / show answer This submachine can be used many times submachine state submachine state

  42. Composite State • Introduces an abstract “super state” • decomposed into multiple sub-states • when the super state is active, exactly one of its sub-states is active

  43. Composite State • nonorthogonal state S

  44. Composite State • orthogonal state S

  45. Examples Thread Runnable Ready suspend start Created Waiting yield dispatch Running resume stop end stop stop Terminated

  46. Examples Automobile Temperature control TempOn pushAir Cooling pushTCOff TempOff pushHeat pushAir Heating pushHeat Rear defroster Radio control pushRD pushRad RDOff RDOn RadOff RadOn pushRD pushRad

  47. Review • States, Events, Transitions • Firing rules • Effects: actions and activities • Ordering of activities • Simple, submachine, and composite states • orthogonal • non-orthogonal

More Related