Presentation is loading. Please wait.

Presentation is loading. Please wait.

State Diagram – Advanced Concepts

Similar presentations


Presentation on theme: "State Diagram – Advanced Concepts"— Presentation transcript:

1 State Diagram – Advanced Concepts

2 Communications between objects
Objects communicate by sending messages to each other. Messages are realized by events and transitions in state diagram. The object that sends a message is said to generate an event. Modeled by the action associated with the transition The object that receives the message is said to realize / accept that event.

3 Communication between three state machines
GUI object Open / generateAccountNumber(act) ^ Account.open(); Database.openAccount(act) Some State Some other State Account object open Initial Database object openAccount (act) / addAccount(act) Some State Communication between three state machines

4 Expanded syntax for transition
A transition is specified using the following syntax in order to show the communication between the objects event-name (parameters) [guard] / action-sequence ^ send-clause where ‘send-clause’ is specified as object.event-name (parameters);

5 Messages shown in state diagrams
Remote Control On Off On Off On() Play Stop Off() Play() Stop() CD Player On Play On & Play Off On & Stop Off Stop Off

6 Simple and composite states
A state is composite, in contrast to a simple state, if it has a decomposition UML Manual version 1.5 A composite state includes nested substates A diagram for a composite state has two or more sub-diagrams connected by simple and/or concurrent transitions The entry point of a substate is connected to the initial state of the substate The exit point of a substate is connected to all final states of the substate

7 Composite state with or-substates
Running Forward Backward The states of a running car

8 Or-substates Also called orthogonal states in UML 2.0
The composite state has two or more mutually exclusive substates When the object is in the composite state, only one of the substates is active In the previous diagram, the running car will be in ‘forward’ state or in ‘backward’ state at any time but not in both Each substate can be explained by a separate state diagram

9 Composite state with and-substates
Running Forward Backward Low Speed High Speed The states of a running car

10 And-substates Also called non-orthogonal states in UML 2.0
The composite state has two or more concurrent substates When the object is in the composite state, every one of the concurrent substates is active In the previous diagram, the running car will be in one of the four states: ‘forward & low speed’, ‘forward & high speed’, backward & low speed’ and ‘backward & high speed’ Each substate can be explained by a separate state diagram

11 Or-substates – Another Example
Eject No CD loaded Power ON [no CD] Eject [CD in] Power OFF Power ON [CD in] CD loaded

12 Expanded state diagram
No CD Loaded Eject CD drawer closed CD drawer open Power OFF Power ON [no CD] Eject [no CD] Eject Eject [CD in] CD loaded Power ON [CD in] CD playing Pause CD paused Pause or Play Power OFF Stop Stop CD stopped Play

13 And-substates – another example
Student attending a course Incomplete Lab done Lab done Complete Lab 1 Complete Lab 2 passed Project done Complete Project Complete Final exam pass fail failed

14 Observation If there is a transition from any one of the substates that lead to a state outside the composite state, then all the other concurrent substates terminate prematurely The transition “fail” in the third substate illustrates this situation

15 State diagrams and specialization
Inheritance mechanism allows to redefine only behaviors of a superclass and not the structure of the superclass The structure of a subclass must be the same or a superset of the structure of the superclass Every state of a superclass object is also a valid state of the subclass object The state diagram of a superclass can be inherited into the state diagram of a subclass

16 Composite State - Exercise
Draw a composite state diagram indicating the states of two phones when both of them are in use. Hint: First identify the various values for the status of a single phone


Download ppt "State Diagram – Advanced Concepts"

Similar presentations


Ads by Google