©Katz-2004CS236368 formal SpecificationsLecture--State machines 1 State Machines and Statecharts Formal Specifications CS236368 Spring 2004 Shmuel Katz.

Slides:



Advertisements
Similar presentations
© 2005 by Prentice Hall Appendix 3 Object-Oriented Analysis and Design Modern Systems Analysis and Design Fourth Edition Jeffrey A. Hoffer Joey F. George.
Advertisements

State Charts Mehran Najafi. Reactive Systems A reactive, event-driven, object is one whose behavior is best characterized by its response to events dispatched.
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.
Systems Analysis Requirements structuring Process Modeling
Chapter 7 Structuring System Process Requirements
ESE Einführung in Software Engineering 7. Modeling Behaviour Prof. O. Nierstrasz.
Introduction to Software Engineering 7. Modeling Behaviour.
© 2006 ITT Educational Services Inc. SE350 System Analysis for Software Engineers: Unit 9 Slide 1 Appendix 3 Object-Oriented Analysis and Design.
What is Software Design?  Introduction  Software design consists of two components, modular design and packaging.  Modular design is the decomposition.
Software Design Deriving a solution which satisfies software requirements.
Objectives Detailed Object-Oriented Requirements Definitions
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming The software development method algorithms.
Winter 2007SEG2101 Chapter 41 Chapter 4 SDL – Structure and Behavior.
© Katz, 2003 Formal Specifications of Complex Systems-- Real-time 1 Adding Real-time to Formal Specifications Formal Specifications of Complex Systems.
Temporal Specification Chris Patel Vinay Viswanathan.
Copyright W. Howden1 Lecture 3: Elaboration and System Architecture.
State charts in SysML. Announcements 15 July 2004 – I-Logix announce that BAe systems are standardising on Statemate for development of Eurofighter TyphoonI-Logix.
Advanced Behavioral Modeling
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.
© 2005 by Prentice Hall Chapter 9 Structuring System Requirements: Logic Modeling Modern Systems Analysis and Design Fourth Edition.
Chapter 2: Algorithm Discovery and Design
Chapter 2: Algorithm Discovery and Design
SE-565 Software System Requirements More UML Diagrams.
Chapter 7 Structuring System Process Requirements
USE Case Model.
Ch.2 Part A: Requirements, State Charts EECE **** Embedded System Design.
Lecture 4 Finite State Machine CS6133 Software Specification and Verification.
Chapter 10 State Machine Diagrams
SOFTWARE ENGINEERING BIT-8 APRIL, 16,2008 Introduction to UML.
程建群 博士(Dr. Jason Cheng) 年03月
Chapter 7 Structuring System Process Requirements
1 Object-Oriented Modeling Using UML (2) CS 3331 Fall 2009.
Enhancing Understanding of Model Behavior Through Collaborative Interactions: Explaining Why C. M. Overstreet I.B. Levinstein Computer Science Dept. Old.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 4 – Wage Calculator Application: Introducing.
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 9: Interaction.
Behavioral diagrams Lecture p4 T120B pavasario sem.
CSC 395 – Software Engineering Lecture 13: Object-Oriented Analysis –or– Let the Pain Begin (At Least I’m Honest!)
UML-1 3. Capturing Requirements and Use Case Model.
Activity diagrams. Introduction ● Activity diagrams are a behavioural model that represent the dynamics of the system. ● An activity diagram is essentially.
7 Systems Analysis and Design in a Changing World, Fifth Edition.
11/4/2015COSC , Lecture 201 Real-Time Systems, COSC , Lecture 20 Stefan Andrei.
Discovering object interaction. Use case realisation The USE CASE diagram presents an outside view of the system. The functionality of the use case is.
Course Instructor: Kashif Ihsan 1. Chapter # 3 2.
Sept Tracing Status Update - Sept Montreal - Timothy Lethbridge Trace-Directed Modelling Status Update Timothy C. Lethbridge University.
1 Kyung Hee University Statecharts Spring Kyung Hee University Specifying Objects’ Behaviour  Interaction diagrams show message-passing behaviour.
SOFTWARE DESIGN. INTRODUCTION There are 3 distinct types of activities in design 1.External design 2.Architectural design 3.Detailed design Architectural.
System Testing Beyond unit testing. 2 System Testing Of the three levels of testing, system level testing is closest to everyday experience We evaluate.
Object Oriented Analysis & Design & UML (Unified Modeling Language)1 Part VI: Design Continuous Activity Diagams State Diagrams.
CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram.
Systems Analysis and Design in a Changing World, Fourth Edition
States.
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.
© 2005 by Prentice Hall Chapter 9 Structuring System Requirements: Logic Modeling Modern Systems Analysis and Design Fourth Edition Jeffrey A. Hoffer Joey.
©Katz-2009CS formal SpecificationsLecture--State machines 1 State Machines and Statecharts Formal Specifications CS Shmuel Katz The Technion.
2/25/2016COSC , Lecture 191 Real-Time Systems, COSC , Lecture 19 Stefan Andrei.
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 6: Restaurant.
CSCI 383 Object-Oriented Programming & Design Lecture 7 Martin van Bommel.
7 Systems Analysis – ITEC 3155 The Object Oriented Approach – Use Cases.
© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1 Advanced UML State Diagrams.
State Machine Model.
States.
Object Oriented System Design
Chapter 9 Structuring System Requirements: Logic Modeling
Chapter 10 Object States and The Statechart Diagram
Dynamic Modeling Lecture # 37.
States.
Chapter 7: Data Flow Diagram Structuring System Process Requirements
Abstraction.
Chapter 9 Structuring System Requirements: Logic Modeling
Appendix 3 Object-Oriented Analysis and Design
Presentation transcript:

©Katz-2004CS formal SpecificationsLecture--State machines 1 State Machines and Statecharts Formal Specifications CS Spring 2004 Shmuel Katz The Technion

©Katz-2004CS formal SpecificationsLecture--State machines 2 What is a State? A snapshot of the system Set of values for variables Control location(s) Contents of channels May be written as a tuple

©Katz-2004CS formal SpecificationsLecture--State machines 3 A Simple State Machine An abstract watch: time date battery-off p p rem insert

©Katz-2004CS formal SpecificationsLecture--State machines 4 What if the state is complex? Write values of variables in the state For every possible combination of values, there is a different state Alternative terms: >State Machine Graph >State Transition Graph >Explicit State Graph Paths in the graph = Traces = Executions

©Katz-2004CS formal SpecificationsLecture--State machines 5 Execution sequences State view: Transition view:

©Katz-2004CS formal SpecificationsLecture--State machines 6 Formal Definition A state machine is a 4-tuple (S, A, I, T) with >S : set of possible states >A: set of possible labels on transitions >I : set of initial states (subset of S) > T : transition relation over S x A x S (s1, a, s2) is in T when there is an arrow from s1 to s2 labeled a T is a relation because of nondeterminism (two arrows from the same source and with the same label, to different targets)

©Katz-2004CS formal SpecificationsLecture--State machines 7 Example S = { time, date, bat-off } A = { p, rem, insert } I = { time } T = { (time, p, date), (date, p, time), (time, rem, bat-off),(date, rem, bat-off), (bat-off, insert, time) }

©Katz-2004CS formal SpecificationsLecture--State machines 8 State Machines Are Used! When it is easy to abstract away irrelevant details, leaving only a small number of states When we want to precisely examine every possibility using model checking For communication protocols and complex distributed algorithms (EFT,....)

©Katz-2004CS formal SpecificationsLecture--State machines 9 The State Explosion Problem State can get huge for very simple systems Need a more compact representation! Describe the set of states from which a transition appears through a predicate Describe the `target’ through the changes from the source Use text and not pictures

©Katz-2004CS formal SpecificationsLecture--State machines 10 Z describes State machines! A collection of operation schemas, with explicit preconditions, can be seen as a state machine representation There are many other notations, that mainly treat concurrency To generate explicit version, start from initial states, apply relevant operations. Repeat until nothing is added (a fixedpoint is reached).

©Katz-2004CS formal SpecificationsLecture--State machines 11 A Z State Machine P == [ st, st’ | st = time or st = date and (st = time) => st’ = date and (st = date) => st’ = time ] rem ==[ st, st’ | (st = time or st = date ) and (st’ = bat-off) ] insert ==[ st, st’ | st = bat-off and (st’ = time) ] new == [st’ | st’ = time ]

©Katz-2004CS formal SpecificationsLecture--State machines 12 Hints on translating Can do one-to one translation, > gather the arrows that correspond to a single label into schemas >preconditions are union of the source states >predicate has source => target’ for each arrow Can often combine into general predicates and state transformations Explicit graph means a different state for every possible combination of values

©Katz-2004CS formal SpecificationsLecture--State machines 13 Statecharts Graphic state machine representation Compact--- avoids state explosion Uses zoom-in, zoom-out Separates concerns By David Harel, while consulting for industry (avionics)

©Katz-2004CS formal SpecificationsLecture--State machines 14 Causes of clutter Pulling eject lever leads to a special situation (many arrows, can double the number of states) Changing gears and adjusting the lights are independent of each other (multiplies the number of states describing gears by the number describing light settings) There is a time display updated every 0.1 second, and a similar stopwatch display

©Katz-2004CS formal SpecificationsLecture--State machines 15 Overcoming the Problems Group states into Superstates that can be entered or left under uniform conditions Keep independent parts separate-- do not take the cross product Hide and separate out most values of variables Keep `activities’ and data manipulation outside the statecharts

©Katz-2004CS formal SpecificationsLecture--State machines 16 Superstate (without parallel) Composed of a lower level statechart in S == in time or in date In any superstate => in one of its substates Arrow from boundary = arrow from each (top level) interior state Still can have direct exit from a state time date p p battery-off rem insert

©Katz-2004CS formal SpecificationsLecture--State machines 17 How to Enter Arrow to the boundary, and enter the default state (denoted by a short arrow) Direct to an inner state Unspecified at this level

©Katz-2004CS formal SpecificationsLecture--State machines 18 Parallel Processes For describing independent components Dotted lines between statecharts, each with a default in S == in each component of S arrow to boundary = enter each default Arrow from boundary = leave all components Can have multi-headed or -tailed arrows

©Katz-2004CS formal SpecificationsLecture--State machines 19 Transitions in Parallel Components Transitions are used to `coordinate’ components when needed Form: name [ cond ] / action Actions can include > Updating a variable >sending a message >starting or stopping an activity >output >activating a transition in a parallel component

©Katz-2004CS formal SpecificationsLecture--State machines 20 Joint Transitions If in A and in C, s is a joint transition to (B,D), but if in A and in D, s just does A->B If in E and in B, t does E->F, otherwise nothing happens when t ‘occurs’ A B s C D s E F t [in B]

©Katz-2004CS formal SpecificationsLecture--State machines 21 Mini-steps in Transitions An action can be to activate another transition (from a parallel component). e / f could mean that transition e activates f, so both occur in the same step.... In UML version: f in the next step only--avoids problems (`chain-reactions’ or even cycles) If only f occurs, there is no influence in the other direction.

©Katz-2004CS formal SpecificationsLecture--State machines 22 History H (in a circle) means the state from which the superstate was last exited is `remembered’, and an arrow from outside to the H returns the superstate to the one last left (on the uppermost level) H* as above, but to lowest level of nesting

©Katz-2004CS formal SpecificationsLecture--State machines 23 More details clh = `clear history’ A special action that erases the history, so the default is used for the next entry. Conditional entrance to substates --> C (and the alternatives have predicates) selection --> S (and the alternatives have values from an enumerated set, like a case statement)

©Katz-2004CS formal SpecificationsLecture--State machines 24 Tools Statemate, from I-Logix, uses statecharts as the basic design/specification notation, adds activities and module decomposition separately, emphasizes simulation Rhapsody, from I-Logix, and Rose, from Rational, incoporate statecharts into UML tools, for design level of specifying `reusable objects’

©Katz-2004CS formal SpecificationsLecture--State machines 25 Scenarios Statemate gives feedback to clients through its simulation facility. >When can a beep occur? >If in states....we press d and then b without letting go, what will happen? >Where does an action have an effect? Can `test’ use-case scenarios and `debug’ the specification relative to client needs

©Katz-2004CS formal SpecificationsLecture--State machines 26 Activities of Statemate Defined outside statecharts, ongoing and sustained over time. Each activity A has associated actions: > start(A) >stop(A) >suspend(A) >resume(A) and a condition active(A) and events that can trigger transitions: >started(A) >stopped(A) Can also link an activity to being in a state

©Katz-2004CS formal SpecificationsLecture--State machines 27 Fuzzy parts Real-time will be treated later Updating the variables is `behind the scenes’ and not handled very well in Statemate Connections to other notations (module charts, data flow, informal UML parts) is so-so Some work is being done on combining with Z or other data-level notation, and connecting to the rest of UML