TP4: S TATE M ACHINE D ESIGN P ATTERN  Definition  Infrastructure  Transition Code  Conclusion.

Slides:



Advertisements
Similar presentations
LabVIEW for Physicists 24 th October 2002 Ben Jeffery.
Advertisements

© 2007 Eaton Corporation. All rights reserved. LabVIEW State Machine Architectures Presented By Scott Sirrine Eaton Corporation.
LabVIEW is a graphical programming development environment for data acquisition and control, data analysis, and data presentation. With LabVIEW you can.
Based on LabVIEW 2011 Student Edition
TE Sessions Supported by: Basic Concepts of Programming November 3, 2012.
1. 2 LabVIEW for FRC Doug Norman National Instruments January 6, 2012.
Describing Process Specifications and Structured Decisions Systems Analysis and Design, 7e Kendall & Kendall 9 © 2008 Pearson Prentice Hall.
Chapter 10 Introduction to Arrays
Loops in LabVIEW (while,for and case)
De la Rosa-Pohl ECE 1100 Introduction to Engineering Intro to LabVIEW: Programming for Symon University of Houston Diana de la Rosa-Pohl Len Trombetta.
Introduction to LabVIEW
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming The software development method algorithms.
CS320n –Visual Programming LabVIEW Foundations. Visual ProgrammingLabVIEW Foundations2 What We Will Do Today Hand back and review the midterm Look at.
National Instruments Confidential. 2 LabVIEW Development Tips and Tricks Revealed Carl Ljungholm - LabVIEW Product Support Engineer Travis Hailey - LabVIEW.
Loops A.About While Loops B.About For Loops C.About Case structures D.Sequence Structures E.Formula Node You Will Learn:
The Composite Pattern.. Composite Pattern Intent –Compose objects into tree structures to represent part-whole hierarchies. –Composite lets clients treat.
Chapter 1 Program Design
Introduction to LabVIEW Seth Price Department of Chemical Engineering New Mexico Tech Rev. 10/5/14.
Recursion Chapter 7. Chapter 7: Recursion2 Chapter Objectives To understand how to think recursively To learn how to trace a recursive method To learn.
TIBCO Designer TIBCO BusinessWorks is a scalable, extensible, and easy to use integration platform that allows you to develop, deploy, and run integration.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Workshop 3 of 7 Welcome!. Today's Topics Review of Workshop 2 Loops While For Auto-indexing Shift registers Case Structure.
Virtual Instrumentation With LabVIEW. Course Goals Understand the components of a Virtual Instrument Introduce LabVIEW and common LabVIEW functions Create.
LabVIEW an Introduction
Introduction to LabVIEW
Developing Workflows with SharePoint Designer David Coe Application Development Consultant Microsoft Corporation.
Each VI has 2 Windows Front Panel User Interface (UI) –Controls = Inputs –Indicators = Outputs Block Diagram Graphical Code –Data travels on wires from.
Design of Bio-Medical Virtual Instrumentation Tutorial 3.
Java Software Solutions Lewis and Loftus Chapter 10 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Graphical User Interfaces --
Recursion Chapter 7. Chapter Objectives  To understand how to think recursively  To learn how to trace a recursive method  To learn how to write recursive.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
Chapter 12: How Long Can This Go On?
LabView instrumentoinnissa, 55492, 3op Labview in instrumentation Lecturer: Heikki Ojala, room C204a
Describing Process Specifications and Structured Decisions Systems Analysis and Design, 7e Kendall & Kendall 9 © 2008 Pearson Prentice Hall.
EET 2259 Unit 7 Case Structures; Sequence Structures  Read Bishop, Sections 5.4 and 5.5.  Lab #7 and Homework #7 due next week.  Quiz #3 next week.
1. 2 LabVIEW Intro, Basics, Tips, Tricks Doug Norman & Stephanie Brierty National Instruments January 8, 2010.
Creating, Editing, & Debugging a VI A.How to Create VIs B.How to Edit VIs C.How to Debug VIs You Will Learn:
SE: CHAPTER 7 Writing The Program
Dale Roberts 1 Program Control - Algorithms Department of Computer and Information Science, School of Science, IUPUI CSCI N305.
Digital Electronics and Computer Interfacing Tim Mewes 4. LabVIEW - Advanced.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns VIII Chain of Responsibility, Strategy, State.
Virtual Instrumentation With LabVIEW. Front Panel Controls = Inputs Indicators = Outputs Block Diagram Accompanying “program” for front panel Components.
Java Programming, 2E Introductory Concepts and Techniques Chapter 4 Decision Making and Repetition with Reusable Objects.
ANDROID AND MODEL / VIEW / CONTROLLER. Slide 2 Design Patters Common solutions to programming problems are called design patterns Design patterns are.
Workshop 2 of 4 Welcome!. Survey While You Wait ni.com/duke >> Recent Documents >> LabVIEW Workshop Participation Survey.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Craps Game Application Introducing Random-Number Generation and Enum.
Lecture 4 Mechanisms & Kernel for NOSs. Mechanisms for Network Operating Systems  Network operating systems provide three basic mechanisms that support.
VHDL Discussion Subprograms IAY 0600 Digital Systems Design Alexander Sudnitson Tallinn University of Technology 1.
Iterations (aka Loops). 2 Loops Loops (iterations) are segments of code that may be executed several times. Fixed-count (definite) loops repeat a fixed.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 13 How Long Can This Go On?
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Student Grades Application Introducing Two-Dimensional Arrays and RadioButton.
Digital Electronics and Computer Interfacing Tim Mewes 2. LabVIEW Basics part II.
Iterations (aka Loops). 2 Loops Loops (iterations) are segments of code (loop body) that may be executed several times. Fixed-count (definite) loops repeat.
Program Design. Simple Program Design, Fourth Edition Chapter 1 2 Objectives In this chapter you will be able to: Describe the steps in the program development.
LabVIEW Course Course 2.
MEH108 - Intro. To Engineering Applications KOU Electronics and Communications Engineering.
How Computers Solve Problems Computers also use Algorithms to solve problems, and change data into information Computers can only perform one simple step.
Wednesday NI Vision Sessions
 Problem Analysis  Coding  Debugging  Testing.
Ni.com/training LabVIEW Basics I National Instruments N. Mopac Expressway Austin, Texas (512)
Lesson 7 Using Sequential and State Machine Algorithms
EET 2259 Unit 3 Editing and Debugging VIs
Chap 7. Building Java Graphical User Interfaces
Course Learning Map Lesson # Lesson Title Lesson 3 Lesson 2 Lesson 1
Introduction to LabVIEW
Graphical User Interfaces -- Introduction
Structures- case, sequence, formula node
Presentation transcript:

TP4: S TATE M ACHINE D ESIGN P ATTERN  Definition  Infrastructure  Transition Code  Conclusion

S TATE M ACHINES You use the state machine design pattern to implement algorithms that can be explicitly described by a state diagram or flow chart. A state machine consists of a set of states and a transition function that maps to the next state.

S TATE M ACHINE I NFRASTRUCTURE 1. While Loop: The follow of the state transition diagram is implemented by the while loop. The while loop allows to execute the various states continually. 2. Case Structure: the individual states are represented by cases in the case structure. It contains a case for each state and the code to execute for each state. 3. Shift Register: A shift register on the while loop keeps track of the current state to the Case structure input 4. State Functionality Code: it is used to implement the function of the state(it is located in the case structure). 5. Transition Code: the transition code determines the next state in the sequence, we usually use the “enum” constant to determine the next state

You use enumerated type constants as case selectors to control the initialization and transition of state machines. The most common obstacle when implementing state machines with enumerated type constants is that if a user attempts to add or delete a state from the enumerated type constant, the remaining wires connected to the copies of this enumerated type constant break. One solution to this problem is to type define the enumerated constant. Creating a type defined enumerated type constant causes all the enumerated type constant copies to automatically update if you add or remove a state. Enumerated Type Constant C ONTROLLING THE S TATE M ACHINE

State Machines A state machine relies on user input or in-state calculation to determine which state to go to next. Many applications require an initialization state and a default state, where many different actions can be performed. State machines are commonly used to create user interfaces where different user actions send the user interface into different processing segments. Each processing segment acts as a state in the state machine. Each segment leads to another segment for further processing or waits for another user action. Click on each button to see how different actions can lead to different states!

T RANSITION C ODE There are several common design patterns used to develop the transition code. You choose the transition code design pattern based on the number of states you need to transition between: Transitioning to another state (Default Transition) Transition between two possible states Transition among two or more possible states

D EFAULT T RANSITION For the default transition, no code is needed to determine the next state, as there is only one possible choice.

T RANSITION B ETWEEN T WO S TATES There are several patterns commonly used to accomplish transition between two states. This method (in the figure) works well if you know that the individual state always moves between two states. But, If you need to modify the state to transition among more than two states, this solution would not work and would require a major modification of the transition. code.

T RANSITION A MONG T WO OR M ORE S TATES You can create a more scalable architecture by using one of the following methods for transition among multiple states: 1. Case Structure: Each case in a Case structure corresponds to an item in the enumerated type control, making it easy to read and understand the code. A Case structure is also scalable and you can add more transitions to a particular state by adding more cases to the Case structure. However, due to the nature of the Case structure, you cannot see the complete functionality of the transition code at a glance.

T RANSITION A MONG T WO OR M ORE S TATES : C ASE S TRUCTURE E XPLICATION This case structure means, In the “Analyzer Case”: If the string “Analysis”= “One” the next state will be “Start” If the string “Analysis”=“Two” the next state will be “Analyzer” If the string “Analysis”=“Three” the nest state will be “Error Handler. Case 1 Case2 Case 3

T RANSITION A MONG T WO OR M ORE S TATES 2. Transition Array: If you need more of the code to be visible than a Case structure allows, you can create a transition array for all the transitions that can take place in the transition code for a state.

S TATE M ACHINE : C ONCLUSION A state machine in LabVIEW consists of a While Loop, a Case structure, a type defined enum constant and a shift register: Each state of the state machine is a separate case in the Case structure. You place VIs and other code that the state should execute within the appropriate case. A shift register stores the state (indicated by the enum constant)that should execute upon the next iteration of the loop. The next state will be either Shut Down or Idle

S TATE M ACHINE : C ONCLUSION For the displayed VI, the possible states are Startup, Idle, Event 1, Event 2, and Shutdown. An enumerated constant stores the states. Each state has its own case in the Case structure. The outcome of one case determines the case that next executes. The shift register stores a value that determines which case runs next.

S TATE M ACHINE D ESIGN P ATTERN An advantage of the state machine architecture is that each case determines the next state, unlike Sequence structures that cannot skip a frame. The state machine design can make the block diagram much smaller, and therefore easier to read and debug.  A disadvantage of the state machine design pattern is that it makes it possible to skip states. If two states in the structure are called at the same time, this model handles only one state, and the other state does not execute.