State Transition Diagram & UML’s enhancements

Slides:



Advertisements
Similar presentations
State Charts Mehran Najafi. Reactive Systems A reactive, event-driven, object is one whose behavior is best characterized by its response to events dispatched.
Advertisements

Nested state diagrams:Problems with flat state diagram
Behavioral Modeling: State Diagrams CIS 4800 Kannan Mohan Department of CIS Zicklin School of Business, Baruch College Copyright © 2009 John Wiley & Sons,
State Transition Diagrams Chapter 13
UML State chart/machine diagram State machine diagram is a behavior diagram which shows discrete behavior of a part of designed system through finite state.
Models of Concurrency Manna, Pnueli.
C O N T E X T - F R E E LANGUAGES ( use a grammar to describe a language) 1.
Interaction Modeling for Testing We would generate the test cases based on our understanding of the interactions that may happen. The source is, again,
CS 290C: Formal Models for Web Software Lecture 4: Implementing and Verifying Statecharts Specifications Using the Spin Model Checker Instructor: Tevfik.
Software Design Process A Process is a set of related and (sequenced) tasks that transforms a set of input to a set of output. Inputs Outputs Design Process.
CHAPTER 1: AN OVERVIEW OF COMPUTERS AND LOGIC. Objectives 2  Understand computer components and operations  Describe the steps involved in the programming.
 Control structures  Algorithm & flowchart  If statements  While statements.
® IBM Software Group © 2006 IBM Corporation Rational Software France Object-Oriented Analysis and Design with UML2 and Rational Software Modeler 04. Other.
1 Chapter 4 Dynamic Modeling and Analysis (Part I) Object-Oriented Technology From Diagram to Code with Visual Paradigm for UML Curtis H.K. Tsang, Clarence.
1 Chapter 4 Dynamic Modeling and Analysis (Part I) Object-Oriented Technology From Diagram to Code with Visual Paradigm for UML Curtis H.K. Tsang, Clarence.
LAB 3 – Review of the Assignment. -- Clarifications Vikram Murali. TA : CSE 140L Prof. CK Cheng.
THE OBJECT-ORIENTED DESIGN WORKFLOW Statechart Diagrams.
State Change Modelling. Aim: To introduce the concept and techniques for describing the changes in state that may occur to an object in its lifetime.
UML Sequence Diagrams Eileen Kraemer CSE 335 Michigan State University.
C++ for Engineers and Scientists Third Edition
Advanced Behavioral Modeling
UML Sequence Diagrams Michael L. Collard, Ph.D. Department of Computer Science Kent State University.
State and Sequence Diagrams Modelling dynamic information So far we have seen: Use Case Diagrams – requirements capture, interface.
Lecture 4 Finite State Machine CS6133 Software Specification and Verification.
Chapter 10 State Machine Diagrams
1 COMP541 State Machines Montek Singh Feb 8, 2012.
מידול התנהגותי 1. Today’s Session Sequence Diagrams State Machines 2.
1 Object-Oriented Modeling Using UML (2) CS 3331 Fall 2009.
Business Informatics Group Institute of Software Technology and Interactive Systems Vienna University of Technology Favoritenstraße 9-11/188-3, 1040 Vienna,
1 Software Engineering Dr. K. T. Tsang Lecture 8 State modeling
Interaction Modeling Interaction model describes how objects interact to produce useful results. Interactions can be modeled at different levels of abstraction:
1 Chapter 4: Selection Structures. In this chapter, you will learn about: – Selection criteria – The if-else statement – Nested if statements – The switch.
1 Relational Expressions Relational expressions: –Expressions that compare operands –Sometimes called conditions –Evaluated to yield a result –Typically.
Behavioral diagrams Lecture p4 T120B pavasario sem.
Object-Oriented Modeling Using UML CS 3331 Section 2.3 of Jia 2003.
© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1 UML Sequence Diagrams.
CPS120: Introduction to Computer Science Decision Making in Programs.
7 Systems Analysis and Design in a Changing World, Fifth Edition.
University of Toronto at Scarborough © Kersti Wain-Bantin CSCC40 state charts 1 object states an object state is a condition or situation during the life.
1 Version /05/2004 © 2004 Robert Oshana Requirements Engineering Use cases.
1 Kyung Hee University Statecharts Spring Kyung Hee University Specifying Objects’ Behaviour  Interaction diagrams show message-passing behaviour.
UML Discussion on State Machines Perfectly static system is intensely uninteresting Because nothing ever happens.
JavaScript, Fourth Edition
State Modeling. Events An event is an occurrence at a point in time, such as user depresses left button or.
© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1 UML State Diagrams.
Systems Analysis and Design in a Changing World, Fourth Edition
States.
CS3773 Software Engineering Lecture 06 UML State Machines.
A FIRST BOOK OF C++ CHAPTER 5 REPETITION. OBJECTIVES In this chapter, you will learn about: The while Statement Interactive while Loops The for Statement.
A First Book of C++ Chapter 5 Repetition.
Dr Nick Mitchell (Room CM 224)
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 10: Statecharts.
UNIT - I Formal Language and Regular Expressions: Languages Definition regular expressions Regular sets identity rules. Finite Automata: DFA NFA NFA with.
Chapter – 8 Software Tools.
1 7 Systems Analysis and Design in a Changing World, 2 nd Edition, Satzinger, Jackson, & Burd Chapter 7 The Object-Oriented Approach to Requirements.
® IBM Software Group © 2009 IBM Corporation Module 11: Creating State Machine Diagrams Essentials of Modeling with IBM Rational Software Architect V7.5.
C++ for Engineers and Scientists Second Edition Chapter 4 Selection Structures.
© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1 Advanced UML State Diagrams.
Modeling for Testing Interactions
SS 2017 Software Verification Timed Automata
Some Simple Design Modeling Techniques
State Diagram – Advanced Concepts
Marlon Dumas Institute of Computer Science
Model-Based Testing Model the system
UML Sequence Diagrams.
States.
State Machine Design with an HDL
Marlon Dumas Institute of Computer Science
States.
UNIT-II CHAPTER-4 SOFTWARE REQUIREMENT DEFINITION
Presentation transcript:

State Transition Diagram & UML’s enhancements Another “tool” for depicting the Design An integral part of the DeSCRIPTR State Transition

State Transition Diagram A state transition diagram is used to depict: The states of an entity The transitions of states of the entity The trigger or the event that caused the transition of state of the entity The entity may be a physical device such as a light switch or a vending machine; it may be a software system or component such as a word processor or an operating system; it may be a biological system such as a cell or a human; or - - - - This modeling technique came from a more formal area - automata theory and switching theory. State transition diagram depicts a Finite State Machine.

Software Program View The end product of a software development is a program which executes. In depicting the program (or an object) we can consider: Variables which take on different values Control structure and assignment statements (events) in the program that change the values of the variables; but “little” is said about how the control structure or the statements work Combination of values of the data (variables & constants) at any point of the program represent the program state at that point. 2. The change made to the values of the variables through assignment statements represent a transition of state

A very simple example light switch (page 368 of your text) From State (light) To State (light) Alt Event (switch) switch light on turnOff off [l_st=on] TurnOff ( ) off turnOn on [l_st=off] TurnOn ( ) 2. “State transition table” for light with switch events 1. “Sequence diagram” (alternative fragment) for switch and light interaction turnOff light on light off turnOn 3. “State transition diagram” for light with switch events

A little “more” on the light switch turnOff turnOff turnOff on off on off turnOn turnOn turnOn What happens if we turn on a light that is already on? state can “transition” to its current state

Using State Transition Diagram Model the entity at the “abstraction” level where the number of states is “manageable.” List (design) the states (should not be large) List (design) events that will trigger the state transition (should not be big) There must be a starting state There must be a terminating state or states Design the transition rules (the bulk of your design work is thinking through the transition rules) 1.The above is not necessarily performed in sequence; iterate through these. 2. Even with a modest number of states and events, the state transition diagram, which really depicts the transition rules, can be enormous.

Designing the Voice Recorder (similar to example on page 397 of text) For the entity, voice recorder, design the states of this entity: How many states does ( somewhat based on requirement ) a voice recorder have? Set of recorder states = { off, on, play, record, erase, stop, error-msg } What are the initial and terminating states? Initial state = {off} Terminating state = {off} List the events that will change the state of the entity: What are the events that will change the recorder’s states? “Input signals” = { 1, 2, 3, 4, 5, 6 } which corresponds to: {off, on, play, record, erase, stop} Note: no “rewind” “go-back” state

Designing the Voice Recorder (example form page 397 of text) – cont. Design the transition rules for the voice recorder from state events to state off 2 on off 1 off on 1 off More transition rules: 1. Any state transition not described here will transition to error-msg state 2. once in error-msg state, the system “displays a message” and automatically transitions to stop state. on 3 play on 4 record on 5 erase play 6 stop record 6 stop erase 6 stop stop 3 play stop 4 record stop 5 erase stop 1 off Events : {1=off, 2=on, 3=play, 4=record, 5=erase, 6=stop}

State Transition Diagram of Voice Recorder {1=off, 2=on, 3=play, 4=record, 5=erase, 6=stop} 1 1 stop On Off [always true] 1 2 3 Error-msg 4 3 5 5 4 6 play 6 6 erase record Couple things to note: 1. All non-specified events for all the states go to “Error-msg” state - - - is that o.k? 2. What happens when a signal of 6 comes in when in state “ON” - - - error message? 3. How do you specify “display error message” in Error-msg state ? 4. How do you specify “Starting” and “Terminating” state ?

Finite State Machine (more “classical” usage) State Transition diagram of M1 Pseudo code for the design of M1: Read input string; If input string includes non - 0’s or 1’s, error msg; break; if input string length is odd number, error msg; break; Set state = s1; While (the string is non-empty) { ele = first element from the string; delete the first element from the string; if (state = s1 & ele = 0) then state = s2; if (state = s1 & ele = 1) then state = s4; if (state = s2 & ele = 0) then state = s1; if (state = s2 & ele = 1) then state = s3; if (state = s3 & ele = 0) then state = s4; if (state = s3 & ele = 1) then state = s2; if (state = s4 & ele = 0) then state = s3; if (state = s4 & ele = 1) then state = s1; } if (state = s1) string is accepted else error msg ; end S1 S2 1 1 1 1 S4 S3 “Formal” Definition of M1 M1 = {event, States, T, I, Term} where: event = {0, 1} States = {s1, s2, s3, s4} T = {(s1,0)-> s2; (s1,1) -> s4; -----} I = s1 Term = s1 M1 is a string checker that “accepts” all strings that contain even number of 0’s and 1’s

UML’s “improvements” on State Transition Diagrams Event may be expressed with a string: event-signature [guard] / action-expression State symbol may contain several compartments: Name Processing activities in the form of : Action-label / Action-expressions Action-labels: Entry – specifies activities upon state entry Exit – specifies activities upon state exit Do – specifies activities to be performed after entry but before exit Include – names another state diagram to be used for “nested” state transition diagram for further refinement Action-expression specifies the activities to be performed. Instead of include, there may be a “stubbed” state which can be expanded later. The state diagram may contain another state diagram (nested diagram) in its compartment

UML State Transition Composite Diagram Example (cruise control system - similar to page 401 of text) off onBtnclick offBtnclick On Note: 1. the start and terminating states 2. When entering a composite diagram, the start state must be clearly defined. 3. How we exit this composite diagram from the freeSpeed state and actually enter “off” state pedalSpeed entry / spLock:= undefined engage pressBreak setSpeed freeSpeed entry/ spLock := current speed do / lockState := on entry / spLock := undefined do / lockState:= off exit / set offBtnclick

Some Deeper (Advanced) UML State Diagrams Concurrent Composite State Diagram contains two or more composite state diagrams that may be executed in parallel; state diagram is divided up into compartments by parallel doted lines. Concurrent Composite State StateW Event-K StateZ Note: 1. Transition to a concurrent composite state boundary will enter initial states of all the concurrent state diagrams 2. Or one can specify the sub states which will be entered, along with the one specified start state 3. similarly exits can be specified Event-A

More Advanced UML State Transition Diagram with Synchronization Mechanism EW= east-west NS=north-south SignalOperationState after 40 sec after 5 sec EW Green EW Yellow EW Red after 35 sec after 45 sec NS Red after 30 sec NS Green NS Yellow after 5 sec Synch signal used to help regulate transition SynchronizedSignalOperation after 35 sec EW Red Synch signal used to help regulate transition after 40 sec after 5 sec EW Green EW Yellow 1 1 after 45 sec NS Red after 5 sec after 30 sec NS Yellow NS Green

Transition Junction & Compound Transition near_by store [cold=yes] at_home shopping_urge [cold=no] far_away mall [cold=extreme] on-line shopping

Advanced Mechanism to set History RadioOn The history of preset state is “remembered” if the radio is turned on after it is turned off History state, H, says re-enter the state that was last active setFM Preset FM station setAM Preset AM station setCD Preset cd music off turnOn H turnoff

Read at least one example from the text on your own Read at least one example from the text on your own. (Especially the Dialog Map and UI diagram)