200 likes | 642 Views
State Transition Diagrams. 3.3.1. This presentation covers. What is a State Transition Diagram? Wh y are they used ? How to draw them. Introduction. A system can be defined at any one point as being in a particular state...
E N D
This presentation covers • What is a State Transition Diagram? • Why are they used? • How to draw them.
Introduction • A system can be defined at any one point as being in a particular state... • Whether it is ready to receive an input or processing data ready for it to be output. • State Transition Diagrams (STD) basically map out the state of a system in diagram form. • This type of diagram essentially describes the behaviour of the system.
Door Example • There are only two states for a door...open or closed. • The transitions are opening or closing. Door Opening Door Closed Door Open Door Closing
State Transition Diagrams • States are shown as locations. • Transitions are represented by arrows. • These are the reasons why the state is changing. • For example... The state changes because the door is opening. Door Opening Door Closed Door Open
Filling up a water bottle • An input may have different effects on a state. • Multiple transitions can result from the same state (as in this diagram). 5. Broken B5: Break B3: Not full B5: Break 1. Empty 2. Check bottle 3. Full B1: Squirt (n) B2: Full IF (content + n) >= capacity THEN Go to B2 ELSE Go to B3 B4: Screw on cap 4. Sealed
Filling up a water bottle • First of all we have to squirt water into the bottle at a quantity of n. • We then check the bottle to see if it is full. • If it isn’t full we go through the transition of B3: Not full as the state is still considered to be Empty. B3: Not full 1. Empty 2. Check bottle B1: Squirt (n) IF (content + n) >= capacity THEN Go to B2 ELSE Go to B3
Filling up a water bottle • When we have reached a full state then we can place the cap on the bottle. • The transition is B4: Screwing on a cap. • We then arrive at a state of Sealed. B3: Not full 1. Empty 2. Check bottle 3. Full B1: Squirt (n) B2: Full IF (content + n) >= capacity THEN Go to B2 ELSE Go to B3 B4: Screw on cap 4. Sealed
Filling up a water bottle • The state Broken is reached if the bottle breaks. • If the bottle was full at point 2 and then isn’t at state full you can assume the bottle is broken. 5. Broken B5: Break B3: Not full B5: Break 1. Empty 2. Check bottle 3. Full B1: Squirt (n) B2: Full IF (content + n) >= capacity THEN Go to B2 ELSE Go to B3 B4: Screw on cap 4. Sealed
Your turn to give it a go! • Try drawing an STD which covers the following states: • Filling up a kettle • Boiling the water • Pouring the water into mugs • (note: do not worry about the mugs...I am more concerned with the state of the kettle). • This is the first state... 1. Empty