Introduction to LabVIEW Design Patterns



Similar documents
Software Engineering Best Practices. Christian Hartshorne Field Engineer Daniel Thomas Internal Sales Engineer

and Certification What Does It Take To Get Certified? Steven Hoenig NJ Business Unit Manager

Software Engineering for LabVIEW Applications. Elijah Kerry LabVIEW Product Manager

The Essentials of File Management with LabVIEW

Hands-On: Introduction to Object-Oriented Programming in LabVIEW

TestStand Certification Overview

LabVIEW Advanced Programming Techniques

LabVIEW Day 1 Basics. Vern Lindberg. 1 The Look of LabVIEW

Introduction to LabVIEW

Getting Started with the LabVIEW Mobile Module Version 2009

Testing high-power hydraulic pumps with NI LabVIEW (RT) and the StateChart module. Jeffrey Habets & Roger Custers

Exercise 10: Basic LabVIEW Programming

Getting Started with the LabVIEW Mobile Module

: provid.ir

LABVIEW DSP TEST TOOLKIT FOR TI DSP

Distance-Learning Remote Laboratories using LabVIEW

Software Life-Cycle Management

Chapter 2: Getting Started

Real Time Programming: Concepts

Learning Remote Control Framework ADD-ON for LabVIEW

Chapter 6, The Operating System Machine Level

EET 310 Programming Tools

vcenter Orchestrator Developer's Guide

Presentation Reporting Quick Start

Mutual Exclusion using Monitors

Fundamentals of Java Programming

Sample. LabVIEW TM Core 1 Course Manual. Course Software Version 2010 August 2010 Edition Part Number B-01

Manage Software Development in LabVIEW with Professional Tools

User guide for the Error & Warning LabVIEW toolset

ARIS Education Package Process Design & Analysis

GETTING STARTED WITH LABVIEW POINT-BY-POINT VIS

LabVIEW DSP Test Integration Toolkit for TI DSP

Design and Functional Specification

MuleSoft Blueprint: Load Balancing Mule for Scalability and Availability

First Bytes Programming Lab 2

Multicore Programming with LabVIEW Technical Resource Guide

MA-WA1920: Enterprise iphone and ipad Programming

LabVIEW Tutorial Manual

DSP Laboratory: Analog to Digital and Digital to Analog Conversion

GE Fanuc Automation CIMPLICITY

Automate Your BI Administration to Save Millions with Command Manager and System Manager

Debugging Java Applications

Assignment # 2: Design Patterns and GUIs

LabVIEW Day 6: Saving Files and Making Sub vis

Synthesis for Developing Apps on Mobile Platforms

OpenACC 2.0 and the PGI Accelerator Compilers

Architecture. Reda Bendraou

BUSINESS RULES CONCEPTS... 2 BUSINESS RULE ENGINE ARCHITECTURE By using the RETE Algorithm Benefits of RETE Algorithm...

Data Acquisition Using NI-DAQmx

Oracle Service Bus Examples and Tutorials

Data processing goes big

CA Data Protection. Content Provider Development Guide. Release 15.0

Source Code Control and Software Reuse

fakultät für informatik informatik 12 technische universität dortmund Data flow models Peter Marwedel Informatik 12 TU Dortmund Germany

Sage Intelligence Financial Reporting for Sage ERP X3 Version 6.5 Installation Guide

Microsoft PowerPoint Exercises 4

M a r k B o o k C Y, M a r k B o o k A M, v e r s i o n, e d i t i o n. MarkBook for Windows on a Mac 1

ERserver. iseries. Work management

Using MCC GPIB Products with LabVIEW

Parallel and Distributed Computing Programming Assignment 1

Configuring, Customizing, and Troubleshooting Outlook Express

Microsoft Access is an outstanding environment for both database users and professional. Introduction to Microsoft Access and Programming SESSION

Lab View with crio Tutorial. Control System Design Feb. 14, 2006

What is OneDrive for Business at University of Greenwich? Accessing OneDrive from Office 365

A standards-based approach to application integration

Introduction to Embedded Systems. Software Update Problem

Enterprise Service Bus

Lab 4 - Data Acquisition

Handout: Word 2010 Tips and Shortcuts

Tips Tricks and Techniques for Efficient LabVIEW Development

EVALUATION. WA1844 WebSphere Process Server 7.0 Programming Using WebSphere Integration COPY. Developer

Object Technology Toolsets for LabVIEW

PROFESSIONAL. Node.js BUILDING JAVASCRIPT-BASED SCALABLE SOFTWARE. Pedro Teixeira WILEY. John Wiley & Sons, Inc.

A Guide to Getting Started with Successful Load Testing

LabVIEW Lesson 5 Clusters

Automating Business Processes Using SharePoint Designer

VX Search File Search Solution. VX Search FILE SEARCH SOLUTION. User Manual. Version 8.2. Jan Flexense Ltd.

University of Pennsylvania Department of Electrical and Systems Engineering Digital Audio Basics

SOACertifiedProfessional.Braindumps.S90-03A.v by.JANET.100q. Exam Code: S90-03A. Exam Name: SOA Design & Architecture

STEPfwd Quick Start Guide

Chapter 11 I/O Management and Disk Scheduling

MSU Tier 3 Usage and Troubleshooting. James Koll

Adobe Summit 2015 Lab 718: Managing Mobile Apps: A PhoneGap Enterprise Introduction for Marketers

ni.com Remote Connectivity with LabVIEW

NS DISCOVER 4.0 ADMINISTRATOR S GUIDE. July, Version 4.0

OPC and Real-Time Systems in LabVIEW

Debugging with TotalView

IBM WebSphere Message Broker Message Monitoring, Auditing, Record and Replay. Tim Kimber WebSphere Message Broker Development IBM Hursley Park, UK

Modeling Guidelines Manual

IRIS Payroll Business. Getting Started Guide. The Payroll Cycle

Up and Running with LabVIEW Web Services

Computing Concepts with Java Essentials

DEPLOYMENT GUIDE DEPLOYING F5 AUTOMATED NETWORK PROVISIONING FOR VMWARE INFRASTRUCTURE

Auditing manual. Archive Manager. Publication Date: November, 2015

An Introduction to LoadRunner A Powerful Performance Testing Tool by HP. An Introduction to LoadRunner. A Powerful Performance Testing Tool by HP

Information Systems Analysis and Design CSC John Mylopoulos. Software Architectures Information Systems Analysis and Design CSC340

Storing Measurement Data

Transcription:

Introduction to LabVIEW Design Patterns

What is a Design Pattern? Definition: A well-established solution to a common problem. Why Should I Use One? Save time and improve the longevity and readability of your code. or else 2

3

Examples of Software Engineering Debt (just some of the most common LabVIEW development mistakes) No source code control (or Project) Flat file hierarchy Stop isn t tested regularly Wait until the end of a project to build an application Few specifications / documentation / requirements No buddying or code reviews Poor planning (Lack of consideration for SMoRES) No test plans Poor error handling No consistent style Tight coupling, poor cohesion ni.com/largeapps 4

Designing for SMoRES Criteria for a well designed software application: Scalable: how simple is N + 1? Modular: is the application broken up into welldefined components that stand on their own? Reusable: is the code de-coupled from the current application well-enough such that it could be reused in a future project? Extensible: how painful is it to add new functionality? Simple: what is the simplest solution that satisfies all of the listed criteria and the requirements of the application? 5

You Should Already Be Familiar With.. Loops Shift Registers Case Structures Enumerated Constants Event Structures LabVIEW Classes 6

Design Patterns Functional Global Variable State Machine / Statecharts Event Driven User Interface Producer / Consumer Queued State Machine Producer / Consumer 7

Functional Global Variables How do I share data across a application without using Global or Local Variables?

Background: Global and Local Variables Can cause race conditions Create copies of data in memory Cannot perform actions on data Cannot handle error wires 9

Breaking Down the Design Pattern While loop Uninitialized shift registers have memory Case structure Enumerated control 10

Uninitialized Shift Registers DEMO 11

Basic Actions Set the value of the shift register INITIALIZE INITIALIZE 12

Basic Actions Get the value currently stored in the shift register GET GET 13

Action Engine Perform an operation upon stored value and save result You can also output the new value ACTION ACTION 14

How It Works 1. Functional Global Variable is a Non-Reentrant SubVI 2. Actions can be performed upon data 3. Enumerator selects action 4. Stores result in uninitialized shift register 5. Loop only executes once 15

Uninitialized shift register has memory Loop only executes once Only used in Initialize case Action determines which case is executed Functional Global Variables Examples of other actions DEMO 16

Benefits: Comparison Functional Global Variables Prevent race conditions No copies of data Can behave like action engines Can handle error wires Take time to make Global and Local Variables Can cause race conditions Create copies of data in memory Cannot perform actions on data Cannot handle error wires Drag and drop 17

Recommendations Use Cases Communicate data between code without connecting wires Perform custom actions upon data while in storage Considerations All owning VIs must stay in memory Use clusters to reduce connector pane Using stacked shift registers will track multiple iterations 18

State Machine I need to execute a sequence of events, but the order is determined programmatically

Soda Machine Initialize No input Change Requested Change Quarter Deposited Total < 50 Quarter Total >= 50 Total > 50 Wait Nickel Deposited Dime Deposited Total < 50 Total < 50 Dime Vend Nickel Total >= 50 Total >= 50 Soda costs $0.50 Exit Total = 50 20

Background Static Sequence Dynamic Sequence: Allows distinct states to operate in a programmatically determined sequence 21

Breaking Down the Design Pattern Case Structure inside of a While Loop Each case is a state Current state has decision making code that determines next state Use enumerators to pass value of next state to shift registers 22

The Anatomy of a State Machine Case structure has a case for every state Transition code determines next state based on results of step execution FIRST STATE Step Execution Shift registers used to carry state? Transition Code FIRST STATE NEXT STATE 23

Transition Code Options Step Execution Step Execution Step Execution 24

State Machine DEMO 25

Recommendations Use Cases User interfaces Data determines next routine Considerations Creating an effective State Machine requires the designer to make a table of possible states. 26

Event Driven User Interface I m polling for user actions, which is slowing my application down, and sometimes I don t detect them!

Background Procedural-driven programming Set of instructions are performed in sequence Requires polling to capture events Cannot determine order of multiple events Event-driven programming Execution determined at run-time Waits for events to occur without consuming CPU Remembers order of multiple events 28

Breaking Down the Design Pattern Event structure nested within loop Blocking function until event registered or timeout Events that can be registered: Notify events are only for interactions with the front panel Dynamic events allows programmatic registration Filter events allow you to screen events before they re processed 29

How It Works 1. Operating system broadcasts system events (mouse click, keyboard, etc..) to applications 2. Registered events are captured by event structure and executes appropriate case 3. Event structure returns information about event to case 4. Event structure enqueues events that occur while it s busy 30

How It Works: Static Binding Browse controls Browse events per control Green arrow: notify Red arrow: filter 31

Event Driven User Interface DEMO 32

Recommendations Use Cases UI: Conserve CPU usage UI: Ensure you never miss an event Drive slave processes Considerations Avoid placing two Event structures in one loop Remember to read the terminal of a latched Boolean control in its Value Change event case When using subpanel controls, the top-level VI containing the subpanel control handles the event 33

Producer / Consumer I have two processes that need to execute at the same time, and I need to make sure one can t slow the other down

Background I want to execute code in parallel and at asynchronous rates, but I need to communicate between them! I have two processes that need to execute at the same time, but I want them to be independent of one another, and I need to make sure one can t slow the other down 35

Breaking Down the Design Pattern Data independent loops Master / slave relationship Communication and synchronization between loops 36

How It Works One or more slave loops are told by a master loop when they can run Allows for a-synchronous execution of loops Data-independence breaks dataflow and allows multi-threading De-couples processes 37

Master / Slave: Loop Communication Variables Occurrences Notifier Queues Semaphores Rendezvous 38

Queues Adding Elements to the Queue Select the data-type the queue will hold Reference to existing queue in memory De-queueing Elements Dequeue will wait for data or timeout (defaults to -1) 39

Producer / Consumer 40

Producer / Consumer DEMO 41

Recommendations Use cases Handling multiple processes simultaneously Asynchronous operation of loops Considerations Multiple producers One consumer One queue per consumer If order of execution of parallel loop is critical, use occurrences 42

Queued State Machine & Event-Driven Producer / Consumer I need to enqueue events from a user that control the sequence of events in a consumer loop

Breaking Down the Design Pattern Event-driven user interface design pattern State machine design pattern Producer consumer design pattern Queued communication between loops 44

How It Works 1. Events are captured by producer 2. Producer places data on the queue 3. State machine in consumer executes on dequeued data 4. Parallel SubVIs communicate using queue references 45

Queues Recommendations Use a cluster containing an enum and variant as data-type Refer to queues by name for communication across VIs 46

47

Master Queue 48

Event-Driven Producer Loop 49

State and Data are Enqueued 50

State Machine Consumer 51

Additional Queues (Q1 and Q2) 52

States Produce to Additional Queues 53

SubVIs Consume Data from Q1 and Q2 55

Queued State Machine Producer/Consumer DEMO 56

Recommendations Use Cases Popular design pattern for mid to large size applications Highly responsive user interfaces Multithreaded applications De-coupling of processes Considerations Complex design 57

Adding Your Own Design Patterns C:\Program Files\National Instruments\LabVIEW 8.5\templates\Frameworks\DesignPatterns 58

Resources Example Finder New >> Frameworks Ni.com/labview/power Training LabVIEW Intermediate I & II White Paper on LabVIEW Queued State Machine Architecture Expressionflow.com 59

NI Certifications Align with Training Developer Senior Developer Software Architect / Project Manager LabVIEW Core 1 LabVIEW Core 2 Certified LabVIEW Associate Developer Exam LabVIEW Core 3 Certified LabVIEW Developer Exam Advanced Architectures for LabVIEW Managing Software Engineering in LabVIEW Certified LabVIEW Architect Exam "Certification is an absolute must for anyone serious about calling himself a LabVIEW expert... At our organization, we require that every LabVIEW developer be on a professional path to become a Certified LabVIEW Architect." - President, JKI Software, Inc.

Download Examples and Slides ni.com/largeapps Software Engineering Tools Development Practices LargeApp Community