State Machines March 18, 2013 1. Compositional Systems | Summary Composition is a powerful way to build complex systems. PCAP framework to manage complexity.

Slides:



Advertisements
Similar presentations
TWO STEP EQUATIONS 1. SOLVE FOR X 2. DO THE ADDITION STEP FIRST
Advertisements

LEUCEMIA MIELOIDE AGUDA TIPO 0
Slide 1 Insert your own content. Slide 2 Insert your own content.
Chapter 26 Legacy Systems.
1 Copyright © 2013 Elsevier Inc. All rights reserved. Chapter 1 Embedded Computing.
1 Copyright © 2013 Elsevier Inc. All rights reserved. Chapter 7 System Design Techniques.
1 Copyright © 2010, Elsevier Inc. All rights Reserved Fig 2.1 Chapter 2.
1 Copyright © 2013 Elsevier Inc. All rights reserved. Chapter 38.
1 Chapter 40 - Physiology and Pathophysiology of Diuretic Action Copyright © 2013 Elsevier Inc. All rights reserved.
By D. Fisher Geometric Transformations. Reflection, Rotation, or Translation 1.
Business Transaction Management Software for Application Coordination 1 Business Processes and Coordination.
S-100 PORTRAYAL MODEL DIPWG-2 May 2010
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Title Subtitle.
0 - 0.
ALGEBRAIC EXPRESSIONS
DIVIDING INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
MULTIPLYING MONOMIALS TIMES POLYNOMIALS (DISTRIBUTIVE PROPERTY)
ADDING INTEGERS 1. POS. + POS. = POS. 2. NEG. + NEG. = NEG. 3. POS. + NEG. OR NEG. + POS. SUBTRACT TAKE SIGN OF BIGGER ABSOLUTE VALUE.
MULTIPLICATION EQUATIONS 1. SOLVE FOR X 3. WHAT EVER YOU DO TO ONE SIDE YOU HAVE TO DO TO THE OTHER 2. DIVIDE BY THE NUMBER IN FRONT OF THE VARIABLE.
SUBTRACTING INTEGERS 1. CHANGE THE SUBTRACTION SIGN TO ADDITION
MULT. INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
Addition Facts
Year 6 mental test 10 second questions Numbers and number system Numbers and the number system, fractions, decimals, proportion & probability.
1 9 Moving to Design Lecture Analysis Objectives to Design Objectives Figure 9-2.
Automata Theory Part 1: Introduction & NFA November 2002.
BALANCING 2 AIM: To solve equations with variables on both sides.
ZMQS ZMQS
Photo Composition Study Guide Label each photo with the category that applies to that image.
Richmond House, Liverpool (1) 26 th January 2004.
Report Card P Only 4 files are exported in SAMS, but there are at least 7 tables could be exported in WebSAMS. Report Card P contains 4 functions: Extract,
Lilian Blot Announcements Teaching Evaluation Form week 9 practical session Formative Assessment week 10 during usual practical sessions group 1 Friday.
©2004 Brooks/Cole FIGURES FOR CHAPTER 16 SEQUENTIAL CIRCUIT DESIGN Click the mouse to move to the next page. Use the ESC key to exit this chapter. This.
Test on Input, Output, Processing, & Storage Devices
© 2011 TIBCO Software Inc. All Rights Reserved. Confidential and Proprietary. Towards a Model-Based Characterization of Data and Services Integration Paul.
ADTs unsorted List and Sorted List
Chapter 4 Gates and Circuits.
1 Computer Programming Boolean Logic Copyright © Texas Education Agency, 2013.
CS105 Introduction to Computer Concepts GATES and CIRCUITS
Signals & Systems Predicting System Performance February 27, 2013.
© S Haughton more than 3?
Chapter 4 Gates and Circuits.
1 Directed Depth First Search Adjacency Lists A: F G B: A H C: A D D: C F E: C D G F: E: G: : H: B: I: H: F A B C G D E H I.
Twenty Questions Subject: Twenty Questions
Linking Verb? Action Verb or. Question 1 Define the term: action verb.
© 2007 Lawrenceville Press Slide 1 Chapter 3 Margins.
Energy & Green Urbanism Markku Lappalainen Aalto University.
Database System Concepts and Architecture
Past Tense Probe. Past Tense Probe Past Tense Probe – Practice 1.
This, that, these, those Number your paper from 1-10.
Executional Architecture
Chapter 5 Test Review Sections 5-1 through 5-4.
1 First EMRAS II Technical Meeting IAEA Headquarters, Vienna, 19–23 January 2009.
Addition 1’s to 20.
25 seconds left…...
Test B, 100 Subtraction Facts
Week 1.
Chapter 10: The Traditional Approach to Design
Systems Analysis and Design in a Changing World, Fifth Edition
We will resume in: 25 Minutes.
©2004 Brooks/Cole FIGURES FOR CHAPTER 12 REGISTERS AND COUNTERS Click the mouse to move to the next page. Use the ESC key to exit this chapter. This chapter.
1 Unit 1 Kinematics Chapter 1 Day
CHAPTER 11 FILE INPUT & OUTPUT Introduction to Computer Science Using Ruby (c) 2012 Ophir Frieder et al.
Chapter 13 – Introduction to Classes
©2004 Brooks/Cole FIGURES FOR CHAPTER 13 ANALYSIS OF CLOCKED SEQUENTIAL CIRCUITS Click the mouse to move to the next page. Use the ESC key to exit this.
©2004 Brooks/Cole FIGURES FOR CHAPTER 14 DERIVATION OF STATE GRAPHS AND TABLES Click the mouse to move to the next page. Use the ESC key to exit this chapter.
Modeling Main issues: What do we want to build How do we write this down.
Signals and Systems March 25, Summary thus far: software engineering Focused on abstraction and modularity in software engineering. Topics: procedures,
Signals and Systems March 25, Summary thus far: software engineering Focused on abstraction and modularity in software engineering. Topics: procedures,
Presentation transcript:

State Machines March 18,

Compositional Systems | Summary Composition is a powerful way to build complex systems. PCAP framework to manage complexity. We will develop compositional representations throughout Digital World. software systems signals and systems circuits probability and planning 2

PCAP Framework for Managing Complexity Python has features that facilitate modular programming. def combines operations into a procedure and binds a name to it lists provide flexible and hierarchical structures for data variables associate names with data classes associate data (attributes) and procedures (methods) 3

Controlling Processes Programs that control the evolution of processes are different. Examples: bank accounts graphical user interfaces controllers (robotic steering) We need a different kind of abstraction. 4

State Machines Organizing computations that evolve with time. On the step, the system gets input generates output and moves to a new state Output and next state depend on input and current state Explicit representation of stepwise nature of required computation. 5

Example: Turnstile 6 State Machines

State-transition Diagram Graphical representation of process. Nodes represent states Arcs represent transitions: label is input / output 7

Turn Table Transition table. 8

State Machines The state machine representation for controlling processes is simple and concise separates system specification from looping structures over time is modular We will use this approach in controlling our robots. 9

Modular Design with State Machines Break complicated problems into parts. 10

State Machines in Python Represent common features of all state machines in the SM class. Represent kinds of state machines as subclasses of SM. Represent particular state machines as instances. Example of hierarchical structure SM Class: All state machines share some methods: start(self) - initialize the instance step(self, input) - receive and process new input transduce(self, inputs) - make repeated calls to step Turnstile Class: All turnstiles share some methods and attributes: startState - initial contents of state getNextValues(self, state, inp) - method to process input Turnstile Instance: Attributes of this particular turnstile: state - current state of this turnstile 11

SM Class The generic methods of the SM class use startState to initialize the instance variable state. Then getNextValues is used to process inputs, so that step can update state. class SM: def start(self): self.state = self.startState def step(self, inp): (s, o) = self.getNextValues(self.state, inp) self.state = s return o def transduce(self, inputs): self.start() return [self.step(inp) for inp in inputs] Note that getNextValues should not change state. The state is managed by start and step. 12

Turnstile Class All turnstiles share the same startState and getNextValues. class Turnstile(SM): startState = locked def getNextValues(self, state, inp): if inp == coin: return (unlocked, enter) elif inp == turn: return (locked, pay) elif state == locked: return (locked, pay) else: return (unlocked, enter) 13

Turn, Turn, Turn A particular turnstyle ts is represented by an instance. testInput = [None, coin, None, turn, turn, coin, coin] ts = Turnstile() ts.transduce (testInput) Start state: locked In: None Out: pay Next State: locked In: coin Out: enter Next State: unlocked In: None Out: enter Next State: unlocked In: turn Out: pay Next State: locked In: coin Out: enter Next State: unlocked [pay, enter, enter, pay, pay, enter, enter] 14

Accumulator class Accumulator (SM): startState = 0 def getNextValues (self, state, inp): return (state + inp, state + inp) 15

Cohort Question 1 16

Classes and Instances for Accumulator a = Accumulator() a.start() a.step(7) b = Accumulator() b.start() b.step(10) a.step(-2) 17

State Machine Combinators State machines can be combined for more complicated tasks. 18

19 Cohort Question 2

Readings: Chapter 4 of Digital World Notes (mandatory!) Cohort Exercises & Homework: Practice with simple state machines & OOP (note the due dates & times) Cohort Session 2 & 3: Controlling robots with state machines 20 This Week