Lecture 9 & 10: Finite Machines Anita S. Malik Adapted from Schach (2004) Chapter 11.

Slides:



Advertisements
Similar presentations
Component Oriented Programming 1 Chapter 2 Theory of Components.
Advertisements

Interaction Modeling for Testing We would generate the test cases based on our understanding of the interactions that may happen. The source is, again,
2-Hardware Design of Embedded Processors (cont.) Advanced Approaches.
Classic Analysis CS524 – Software Engineering I Azusa Pacific University Professor Dr. Sheldon X. Liang.
Software Requirements Engineering
Finite state machines.
Informal Specifications BV If the sales for the current month are below the target sales, then a report is to be printed, unless the difference.
Slide 11.1 CHAPTER 11 SPECIFICATION PHASE. Slide 11.2 Overview l The specification document l Informal specifications l Structured systems analysis l.
Slide 11.1 CHAPTER 11 SPECIFICATION PHASE. Slide 11.2 Overview l The specification document l Informal specifications l Structured systems analysis l.
Techniques for Object Discovery from Real Time UML, B.P. Douglass.
Temporal Specification Chris Patel Vinay Viswanathan.
Formal Methods. CS460 - Senior Design Project I (AY2004)2 Why formal methods? Informal methods are open to interpretation and ambiguity, and often incomplete.
CS 425/625 Software Engineering System Models
Slide 10B.1 Copyright © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. An Introduction to Object-Oriented Systems Analysis and Design with.
CSC 402 Requirements Engineering 1 Requirements Techniques, cont. Formal requirements analysis techniques include: – DFD (covered) – ERD (covered) – Finite.
1 CS 501 Spring 2005 CS 501: Software Engineering Lecture 10 Requirements 4.
Slide 11.1 © The McGraw-Hill Companies, 2002 Object-Oriented and Classical Software Engineering Fifth Edition, WCB/McGraw-Hill, 2002 Stephen R. Schach.
Software Engineering, COMP201 Slide 1 Protocol Engineering Protocol Specification using CFSM model Lecture 30.
Requirements Techniques, cont. Brief review Formal Requirements Techniques –Finite State Machines –Petri Nets.
Requirements Specification System Contexts System Models Use Cases System and Acceptance Test Plans.
1 CS1001 Lecture Overview Object Oriented Design Object Oriented Design.
UHD-CMS-CH101 Specification Phase Chapter Ten. UHD-CMS-CH102 SPECIFICATION DOCUMENT The specification document must be Informal enough for client Formal.
[ §4 : 1 ] 4. Requirements Processes II Overview 4.1Fundamentals 4.2Elicitation 4.3Specification 4.4Verification 4.5Validation Software Requirements Specification.
Finite State Machine(FSM)
Chapter 5 – System Modeling
OBJECT-ORIENTED ANALYSIS PHASE
Requirements Expression and Modelling
Slide 16B.51 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering.
CSC 213 – Large Scale Programming Lecture 3: Object-Oriented Analysis.
1 Analysis Extracting from Use Cases to Create Diagrams.
CSC 395 – Software Engineering Lecture 13: Object-Oriented Analysis –or– Let the Pain Begin (At Least I’m Honest!)
Lecture 14 & 15: Object- Oriented Analysis Anita S. Malik Adapted from Schach (2004) Chapter 12.
Formal Methods Formal Methods. Why formal methods?  Informal methods are open to interpretation and ambiguity, and often incomplete and inconsistent.
Reference: Ian Sommerville, Chap 15  Systems which monitor and control their environment.  Sometimes associated with hardware devices ◦ Sensors: Collect.
Slide 11C.104 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005 Stephen R. Schach.
Implementing software in IEC Languages in IEC IEC uses the following languages Instruction List – Assembly level programming using.
CSC 395 – Software Engineering Lecture 28: Classical Analysis -or- Do You Really Want to Do That?
Slide 11.1 © The McGraw-Hill Companies, 2007 CHAPTER 11 CLASSICAL ANALYSIS.
Slide 12.1 Copyright © 2011 by The McGraw-Hill Companies, Inc. All rights reserved. Object-Oriented and Classical Software Engineering Eighth Edition,
Slide 12A.1 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005 Stephen R. Schach.
1 Kyung Hee University Statecharts Spring Kyung Hee University Specifying Objects’ Behaviour  Interaction diagrams show message-passing behaviour.
Petri Nets Invented by Carl Adam Petri in 1962 Concurrent systems with timing problems  Synchronization, race problem, deadlock A petri net consists of.
THE ANALYSIS WORKFLOW  The specification document  Informal specifications  The analysis workflow  Extracting the entity classes  Functional modeling:
CHAPTER 13 OBJECT-ORIENTED ANALYSIS. Overview l The analysis workflow l Extracting the entity classes l The elevator problem case study l The test workflow:
CSCI1600: Embedded and Real Time Software Lecture 7: Modeling II: Discrete Systems Steven Reiss, Fall 2015.
CSCI1600: Embedded and Real Time Software Lecture 8: Modeling III: Hybrid Systems Steven Reiss, Fall 2015.
CSCI1600: Embedded and Real Time Software Lecture 28: Verification I Steven Reiss, Fall 2015.
Finite State Machines (FSM) OR Finite State Automation (FSA) - are models of the behaviors of a system or a complex object, with a limited number of defined.
Digital System Design using VHDL
Event Driven Programming In Non GUI applications Car Jet Wash. List of Events:- Coin operation detection. Timer. Mode selection (rinse, cold high pressure.
4) Design the logic to control the motor on a simple remote control car. There are two buttons on the remote control for the motor. If neither button is.
From requirements to specification Specification is a refinement of requirements Can be included together as Software Requirements Specifications (SRS)
Requirements Specification
Object-Oriented and Classical Software Engineering Eighth Edition, WCB/McGraw-Hill, 2011 Stephen R. Schach 1.
An Overview of Requirements Engineering Tools and Methodologies*
Requirements Techniques, cont.
Formal Techniques (CS340 © John C. Knight 2004)
2-Hardware Design of Embedded Processors (cont.)
Graph Coverage for Specifications CS 4501 / 6501 Software Testing
Object-Oriented and Classical Software Engineering Seventh Edition, WCB/McGraw-Hill, 2007 Stephen R. Schach
Object-Oriented and Classical Software Engineering Eighth Edition, WCB/McGraw-Hill, 2011 Stephen R. Schach.
CHAPTER 12 CLASSICAL ANALYSIS.
Introduction to Software Testing Chapter 3, Sec# 3.5
CS310 Software Engineering Dr.Doaa Sami
Introduction to Sequential Circuits
Graph Coverage for Specifications CS 4501 / 6501 Software Testing
CSCI1600: Embedded and Real Time Software
CSCI1600: Embedded and Real Time Software
CSCI1600: Embedded and Real Time Software
Presentation transcript:

Lecture 9 & 10: Finite Machines Anita S. Malik Adapted from Schach (2004) Chapter 11

CS540 Software Design 2Lecture 9 & 10 Formality versus Informality Informal method Informal method English (or other natural language) English (or other natural language) Semiformal methods Semiformal methods Gane & Sarsen/DeMarco/Yourdon Gane & Sarsen/DeMarco/Yourdon Entity-Relationship Diagrams Entity-Relationship Diagrams Jackson/Orr/Warnier, Jackson/Orr/Warnier, SADT, PSL/PSA, SREM, etc. SADT, PSL/PSA, SREM, etc. Formal methods Formal methods Finite State Machines Finite State Machines Petri Nets Petri Nets Z ANNA, VDM, CSP, etc. ANNA, VDM, CSP, etc.

CS540 Software Design 3Lecture 9 & 10 Finite State Machines Case study Case study A safe has a combination lock that can be in one of three positions, labeled 1, 2, and 3. The dial can be turned left or right (L or R). Thus there are six possible dial movements, namely 1L, 1R, 2L, 2R, 3L, and 3R. The combination to the safe is 1L, 3R, 2L; any other dial movement will cause the alarm to go off

CS540 Software Design 4Lecture 9 & 10 Finite State Machines (contd) Transition table Transition table

CS540 Software Design 5Lecture 9 & 10 Extended Finite State Machines Extend FSM with global predicates Extend FSM with global predicates Transition rules have form Transition rules have form state and event and predicate  new state

CS540 Software Design 6Lecture 9 & 10 Elevator Problem A product is to be installed to control n elevators in a building with m floors. The problem concerns the logic required to move elevators between floors according to the following constraints: 1. Each elevator has a set of m buttons, one for each floor. These illuminate when pressed and cause elevator to visit corresponding floor. Illumination is canceled when corresponding floor is visited by elevator 2. Each floor, except the first and the top floor, has 2 buttons, one to request an up-elevator, one to request a down-elevator. These buttons illuminate when pressed. The illumination is canceled when an elevator visits the floor, then moves in the desired direction 3. If an elevator has no requests, it remains at its current floor with its doors closed

CS540 Software Design 7Lecture 9 & 10 Elevator Problem: FSM Two sets of buttons Two sets of buttons Elevator buttons - in each elevator, one for each floor Elevator buttons - in each elevator, one for each floor Floor buttons - two on each floor, one for up-elevator, one for down-elevator Floor buttons - two on each floor, one for up-elevator, one for down-elevator EB(e, f): Elevator Button in elevator e pressed to request floor f

CS540 Software Design 8Lecture 9 & 10 Elevator Buttons (contd) Two states Two states EBON(e, f):Elevator Button (e,f) ON EBOFF(e,f):Elevator Button (e,f) OFF If button is on and elevator arrives at floor f, then light turned off If button is on and elevator arrives at floor f, then light turned off If light is off and button is pressed, then light comes on If light is off and button is pressed, then light comes on

CS540 Software Design 9Lecture 9 & 10 Elevator Buttons (contd) Two events Two events EBP(e,f):Elevator Button (e,f) Pressed EAF(e,f):Elevator e Arrives at Floor f Global predicate Global predicate V(e,f): Elevator e is Visiting (stopped at) floor f Transition Rules Transition Rules EBOFF(e,f) and EBP(e,f) and not V(e,f)  EBON(e,f) EBON(e,f) and EAF(e,f) Þ EBOFF(e,f)

CS540 Software Design 10Lecture 9 & 10 Floor Buttons Floor buttons Floor buttons FB(d, f): Floor Button on floor f that requests elevator traveling in direction d States States FBON(d, f):Floor Button (d, f) ON FBOFF(d, f):Floor Button (d, f) OFF If floor button is on and an elevator arrives at floor f, traveling in correct direction d, then light is turned off If floor button is on and an elevator arrives at floor f, traveling in correct direction d, then light is turned off If light is off and a button is pressed, then light comes on If light is off and a button is pressed, then light comes on

CS540 Software Design 11Lecture 9 & 10 Floor Buttons (contd) Events Events FBP(d, f):Floor Button (d, f) Pressed EAF(1..n, f):Elevator 1 or … or n Arrives at Floor f Predicate Predicate S(d, e, f):elevator e is visiting floor f Direction of motion is up (d = U), down (d = D), or no requests are pending (d = N) Transition rules Transition rules FBOFF(d, f) and FBP(d, f) and not S(d, 1..n, f)  FBON(d, f) FBON(d, f) and EAF(1..n, f) and S(d, 1..n, f)  FBOFF(d, f), d = U or D d = U or D

CS540 Software Design 12Lecture 9 & 10 Elevator Problem: FSM (contd) State of elevator consists of component substates, including: State of elevator consists of component substates, including: Elevator slowing Elevator slowing Elevator stopping Elevator stopping Door opening Door opening Door open with timer running Door open with timer running Door closing after a timeout Door closing after a timeout

CS540 Software Design 13Lecture 9 & 10 Elevator Problem: FSM (contd) Assume elevator controller moves elevator through substates Assume elevator controller moves elevator through substates Three elevator states Three elevator states M(d, e, f):Moving in direction d (floor f is next) S(d, e, f):Stopped (d-bound) at floor f W(e,f):Waiting at floor f (door closed) For simplicity, three stopped states S(U, e, f), S(N, e, f), and S(D, e, f) are grouped into one larger state For simplicity, three stopped states S(U, e, f), S(N, e, f), and S(D, e, f) are grouped into one larger state

CS540 Software Design 14Lecture 9 & 10 Elevator Problem: FSM (contd)

CS540 Software Design 15Lecture 9 & 10 Elevator Problem: FSM (contd) Events Events DC(e,f):Door Closed for elevator e, floor f ST(e,f):Sensor Triggered as elevator e nears floor f RL:Request Logged (button pressed) Transition Rules Transition Rules If elevator e is in state S(d, e, f) (stopped, d-bound, at floor f), and doors close, then elevator e will move up, down, or go into wait state DC(e,f) and S(U, e, f)  M(U, e, f+1) DC(e,f) and S(D, e, f)  M(D, e, f-1) DC(e,f) and S(N, e, f)  W(e,f)

CS540 Software Design 16Lecture 9 & 10 Power of FSM to Specify Complex Systems No need for complex preconditions and postconditions No need for complex preconditions and postconditions Specifications take the simple form Specifications take the simple form current state and event and predicate  next state

CS540 Software Design 17Lecture 9 & 10 Power of FSM to Specify Complex Systems Using an FSM, a specification is Using an FSM, a specification is Easy to write down Easy to write down Easy to validate Easy to validate Easy to convert into design Easy to convert into design Easy to generate code automatically Easy to generate code automatically More precise than graphical methods More precise than graphical methods Almost as easy to understand Almost as easy to understand Easy to maintain Easy to maintain However However Timing considerations are not handled Timing considerations are not handled

CS540 Software Design 18Lecture 9 & 10 Who is Using FSMs? Commercial products Commercial products Menu driven Menu driven Various states/screens Various states/screens Automatic code generation a major plus Automatic code generation a major plus System software System software Operating system Operating system Word processors Word processors Spreadsheets Spreadsheets Real-time systems Real-time systems Statecharts are a real-time extension of FSMs Statecharts are a real-time extension of FSMs CASE tool: Rhapsody CASE tool: Rhapsody