Test Stand

February 2, 2021 | Author: Anonymous | Category: N/A
Share Embed Donate


Short Description

Download Test Stand...

Description

TestStand I Fundamentals Course Manual

Course Software Version 2.0 February 2001 Edition Part Number 322317E-01 TestStand I Fundamentals Course Manual

Copyright Copyright © 2001 National Instruments Corporation. All rights reserved. Under the copyright laws, this publication may not be reproduced or transmitted in any form, electronic or mechanical, including photocopying, recording, storing in an information retrievalsyst em,or translating, in whole or in part, without theprior written consent of National Instruments Corporation.

Trademarks CVI™, LabVIEW™, and TestStand™ are trademarks of National Instruments Corporation. Product and company names mentioned herein are trademarks or trade names of their respective companies.

Worldwide Technical Support and Product Information ni.com National Instruments Corporate Headquarters 11500 North Mopac Expressway Austin, Texas 78759-3504

USA Tel: 512 794 0100

Worldwide Offices Australia 03 9879 5166, Austria 0662 45 79 90 0, Belgium 02 757 00 20, Brazil 011 284 5011, Canada (Calgary) 403 274 9391, Canada (Ottawa) 613 233 5949, Canada (Québec) 514 694 8521, China (Shanghai) 021 6555 7838, China (ShenZhen) 0755 3904939, Denmark 45 76 26 00, Finland 09 725 725 11, France 01 48 14 24 24, Germany 089 741 31 30, Greece 30 1 42 96 427, Hong Kong 2645 3186, India 91805275406, Israel 03 6120092, Italy 02 413091, Japan 03 5472 2970, Korea 02 596 7456, Mexico 5 280 7625, Netherlands 0348 433466, New Zealand 09 914 0488, Norway 32 27 73 00, Poland 0 22 528 94 06, Portugal 351 1 726 9011, Singapore 2265886, Spain 91 640 0085, Sweden 08 587 895 00, Switzerland 056 200 51 51, Taiwan 02 2528 7227, United Kingdom 01635 523545

Contents

Introduction

Introduction.................................................................................................................xi Technical Support Options ......................................................................................... xii Course Objectives....................................................................................................... xiii Course Map................................................................................................................. xiv Items You Need for This Course................................................................................xv

Lesson 1 Introduction to TestStand Introduction to TestStand ...........................................................................................1-1 The Role of a Test Executive...................................................................................... 1-2 Our Goal for TestStand............................................................................................... 1-3 What is TestStand? ..................................................................................................... 1-4 The TestStand Architecture ........................................................................................ 1-5 The Sequence Editor...................................................................................................1-6 The Operator Interface................................................................................................1-7 TestStand Engine........................................................................................................1-8 Module Adapters ........................................................................................................1-9 The TestStand Architecture ........................................................................................ 1-10 Summary.....................................................................................................................1-13 Exercise 1-1 Running a Sequence File..................................................................1-14 Exercise 1-2A Running a Sequence File from the LabVIEW Operator Interface ............................................................................1-19 Exercise 1-2B Running a Sequence File from the LabWindows/CVI Operator Interface..............................................1-24

Lesson 2 The TestStand Environment Introduction.................................................................................................................2-1 What is a sequence?.................................................................................................... 2-2 Step Groups ................................................................................................................2-3 TestStand Sequence Files ........................................................................................... 2-4 Debugging Tools ........................................................................................................2-5 The TestStand Process Models...................................................................................2-8 Available TestStand Process Models..........................................................................2-9

©

National InstrumentsCorporation

iii

TestStand I Fundamentals CourseManual

Contents

The Default Process Model: Test UUTs Mode ..........................................................2-10 SequentialModel.seq...................................................................................................2-11 The Role of a Process Model in TestStand.................................................................2-12 Workspaces and Source Control.................................................................................2-14 Workspaces and Projects Demo .................................................................................2-15 Summary.....................................................................................................................2-16 Exercise 2-1 Understanding the Sequence File .....................................................2-17 Exercise 2-2 Running a Sequence File with Breakpoints and Single Stepping..........................................................................2-22 Exercise 2-3 Understanding the Sequential Process Model ..................................2-29

Lesson 3 Creating Sequences Introduction.................................................................................................................3-1 How to Create Test Sequences ...................................................................................3-2 Step 1 : Specify the Adapter ....................................................................................... 3-3 Step 2: Select the Step Type .......................................................................................3-4 Step Types...................................................................................................................3-5 Step 3: Specify the Test Module.................................................................................3-6 Specifying the Module................................................................................................3-7 Specifying the Module: Search Directories ................................................................3-8 Step 4: Configure Step Properties...............................................................................3-9 Step Properties: General Tab ......................................................................................3-10 Step Properties: Preconditions ....................................................................................3-11 Step Properties: Run Options Tab ..............................................................................3-12 Step Properties: Run Options Tab (Continued) ..........................................................3-13 Step Properties: Run Options Tab (Continued) ..........................................................3-14 Step Properties: Post Actions Tab ..............................................................................3-15 Step Properties: Loop Options Tab.............................................................................3-16 Step Properties: Loop Options Tab (Continued) ........................................................3-17 Step Properties: Synchronization Tab.........................................................................3-18 Step Properties: Expressions Tab ...............................................................................3-19 Useful Step Type Features..........................................................................................3-22 Sequence Call Options................................................................................................3-23 IVI Step Type Demo...................................................................................................3-24 Exercise 3-1 Creating Steps in the Sequence Editor .............................................3-28 Exercise 3-2 Configuring Loop Options ...............................................................3-38 Exercise 3-3 Creating a Sequence .........................................................................3-42 Exercise 3-4 Running Sequences in Parallel (Optional) .......................................3-60

TestStandIFundamentalsCourseManual

iv

ni.com

Contents

Lesson 4 TestStand Parameters, Variables, and Expressions Introduction.................................................................................................................4-1 TestStand Variables .................................................................................................... 4-2 Parameters...................................................................................................................4-3 Parameters: Passing data to subsequences..................................................................4-4 Local Variables ........................................................................................................... 4-5 Creating Local Variables ............................................................................................ 4-6 Sequence File Global Variables..................................................................................4-8 Creating Sequence File Global Variables...................................................................4-9 Station Globals............................................................................................................4-10 RunState Property Object ...........................................................................................4-11 RunState Subproperties...............................................................................................4-12 RunState Property Example........................................................................................4-13 The Expression Browser.............................................................................................4-14 Using the Expression Browser....................................................................................4-15 Defining Variables and Parameters ............................................................................4-16 Summary.....................................................................................................................4-21 Exercise 4-1 Using Local Variables ......................................................................4-22 Exercise 4-2 Examine the Uses and Differences between Locals, File Globals, and Station Globals.....................................................4-25 Exercise 4-3 Using Expressions to Change Step Properties..................................4-32 Exercise 4-4 Passing Parameters ...........................................................................4-41 Exercise 4-5 Dynamically Selecting Which Sequence to Run..............................4-53

Lesson 5 Creating Test Modules in External Environments Introduction.................................................................................................................5-1 Creating Tests in External Environments ...................................................................5-2 Data Transfer in TestStand ......................................................................................... 5-3 Using Clusters to Pass Data from LabVIEW..............................................................5-4 Using Structures to Pass Data from LabWindows/CVI..............................................5-6 Method 2—Passing Parameters Directly Without Using Structures .......................... 5-8 Method 3—Using the ActiveX Automation API to Access Properties and Methods .............................................................................................................5-12 What is ActiveX Automation?....................................................................................5-13 Summary of ActiveX Automation..............................................................................5-14 TestStand and ActiveX Automation ...........................................................................5-15 ActiveX Automation in LabVIEW.............................................................................5-16 An Example of ActiveX Automation in LabVIEW....................................................5-17 ActiveX Automation in LabWindows/CVI ................................................................ 5-18 An Example ActiveX Automation in In LabWindows/CVI.......................................5-19 Using TestStand Code Templates...............................................................................5-24 Code Templates ..........................................................................................................5-25 Summary.....................................................................................................................5-26

©

National InstrumentsCorporation

v

TestStand I Fundamentals CourseManual

Contents

Exercise 5-1A Creating Pass/Fail Tests in LabVIEW..............................................5-27 Exercise 5-1B Creating Pass/Fail Tests with LabWindows/CVI............................. 5-38 Exercise 5-1C Creating Pass/Fail Tests for the DLL Flexible Prototype Adapter.............................................................................5-47 Exercise 5-2A Creating Numeric Limit Tests with LabVIEW ................................ 5-55 Exercise 5-2B Creating Numeric Limit Tests with LabWindows/CVI.............................................................................5-66 Exercise 5-2C Creating Numeric Limit Tests for the DLL Flexible Prototype Adapter...............................................................5-73 Exercise 5-3A Debugging Tests Using LabVIEW ................................................... 5-85 Exercise LabWindows/CVI...................................... 5-90 Exercise 5-3B 5-3C Debugging Debugging Tests Tests Using that use the DLL Flexible Prototype Adapter.............................................................................5-94 Exercise 5-4A Using the ActiveX API in Code Modules with LabVIEW .................................................................................5-97 Exercise 5-4B Using the ActiveX API in Code Modules with LabWindows/CVI ....................................................................5-105 Exercise 5-4C Using the ActiveX API in Flexible DLL Code Modules ............................................................................................ 5-114 Exercise 5-5A Creating a Simple Test Using the LabVIEW Standard Prototype Adapter .............................................................5-125 Exercise 5-5B Creating A Simple Test Using The C/CVI Standard Prototype Adapter .............................................................5-127 Exercise 5-6A Passing Parameters from TestStand to LabVIEW using The TestStand API..................................................................5-128 Exercise 5-6B Passing Parameters from TestStand to Exercise 5-7

LabWindows/CVI using The TestStand API ................................... 5-130 Passing Data Between TestStand and a Test Module Using the DLL Flexible Prototype Adapter........................5-132

Lesson 6 User Management Introduction.................................................................................................................6-1 The TestStand User Manager .....................................................................................6-2 Default User Profiles ..................................................................................................6-3 Windows System Users .............................................................................................. 6-5 Summary.....................................................................................................................6-6 Exercise 6-1 Setting User Login Access and Privileges........................................6-7

Lesson 7 Result Collection and Report Generation Introduction.................................................................................................................7-1 When and Where Results are Stored ..........................................................................7-2 What Results are Stored..............................................................................................7-3 View of Actual Results ............................................................................................... 7-4

TestStandIFundamentalsCourseManual

vi

ni.com

Contents

Subsequence Results...................................................................................................7-5 Formatting Results into a Report ................................................................................7-6 Report Configuration Options ....................................................................................7-7 Report Options Dialog Box: Contents Tab.................................................................7-8 Report Options Dialog Box: Report File Pathname Tab ............................................ 7-9 Inserting Message in Report .......................................................................................7-10 Using an External Report Viewer from TestStand ..................................................... 7-11 Summary.....................................................................................................................7-13 Exercise 7-1 Customizing Report Generation............ ...........................................7-14

Lesson 8 Interaction Database Introduction.................................................................................................................8-1 Database Concepts......................................................................................................8-2 Structured Query Language (SQL).............................................................................8-3 Database Interface Technologies ................................................................................8-4 Database and Database Drivers ..................................................................................8-5 Configuring Database Options: Logging Options ...................................................... 8-6 Configuring Database Options: Data Link .................................................................8-7 Configuring Database Options: Schemas ...................................................................8-8 Configuring Database Options: Statements................................................................8-9 Configuring Database Options: Columns/Parameters ................................................ 8-10 Logging Property ........................................................................................................ 8-11 Default Schema: Generic Recordset ...........................................................................8-12 Creating Default Database Tables ..............................................................................8-13 Database Viewer......................................................................................................... 8-14 Open Database Step Type...........................................................................................8-18 Open SQL Statement Step Type.................................................................................8-19 Open SQL Statement: Build SQL Select Statement Dialog Box ...............................8-20 Data Operation Step Type...........................................................................................8-21 Data Operation Step Type (Continued) ......................................................................8-22 Data Operation Step Type (Continued) ......................................................................8-23 Data Operation Step Type (Continued) ......................................................................8-24 Close SQL Statement Step Type ................................................................................8-25 Close Database Step Type ..........................................................................................8-26 Summary.....................................................................................................................8-28 Exercise 8-1 Logging UUT Results to Database...................................................8-29 Exercise 8-2 Using Database Step Types ..............................................................8-42

Lesson 9 The Operator Interface Introduction.................................................................................................................9-1 The Operator Interface................................................................................................9-2 Available Operator Interfaces.....................................................................................9-3 Operator Interface Functionality.................................................................................9-4

©

National Instruments Corporation

vii

TestStand I Fundamentals Course Manual

Contents

Sequence Display........................................................................................................9-5 Execution Display.......................................................................................................9-6 How the Operator Interface Works.............................................................................9-7 What is a UIMessage? ................................................................................................9-8 Summary.....................................................................................................................9-10 Exercise 9-1 Running Tests from the Operator Interface......................................9-11

Lesson 10 Additional Topics Introduction.................................................................................................................10-1 Import/Export Properties ............................................................................................10-2 Import/Export Properties Dialog Box.........................................................................10-3 The Property Loader Step ........................................................................................... 10-4 Importing/Exporting Values Summary.......................................................................10-8 Distributing TestStand ................................................................................................ 10-9 TestStand Run-Time Engine.......................................................................................10-10 Distribute the Operator Interface ................................................................................10-11 Distribute Sequences and Code Modules ...................................................................10-12 Exercise 10-1 Importing and Exporting Properties ................................................. 10-13 Exercise 10-2 Using the Property Loader Step Type............................................... 10-19 Exercise 10-3 Using the Expressions to Load Properties........................................ 10-24

Appendix A Introduction to Interchangeable Virtual Instruments Introduction to Interchangeable Virtual Instruments (IVI).........................................A-1 What is Instrument Driver?....................................................................................A-2 What is an IVI?................................................................................................................A-3 IVI Instrument Drivers................................................................................................A-4 IVI Instrument Drivers (Continued) ...........................................................................A-5 IVI Driver ...................................................................................................................A-6 IVI Attribute Model .................................................................................................... A-7 State Caching .............................................................................................................. A-8 Range Checking..........................................................................................................A-9 Simulation...................................................................................................................A-10 Standardization ...........................................................................................................A-11 Instrument Classes ...................................................................................................... A-12 IVI Class Specification ............................................................................................... A-13 IVI Driver Standard .................................................................................................... A-14 Where Does IVI Fit In? ..............................................................................................A-15 Using IVI Instrument Specific Drivers.......................................................................A-16 Using IVI Instrument Specific Drivers (Continued)...................................................A-17 Types of IVI Drivers...................................................................................................A-18 Interchangeable Drivers..............................................................................................A-19 IVI Architecture..........................................................................................................A-20 IVI Configuration .......................................................................................................A-21

TestStandIFundamentalsCourseManual

viii

ni.com

Contents

IVI Configuration .......................................................................................................A-22 Logical Names ............................................................................................................ A-23 Virtual Instruments ..................................................................................................... A-24 Instrument Driver Configuration ................................................................................A-25 Device Configuration..................................................................................................A-26 Inherent Attributes ...................................................................................................... A-27 Virtual Channel Names...............................................................................................A-28 Default Setup ..............................................................................................................A-29 IVI Foundation Update ............................................................................................... A-30 Instrument Driver Network (IDNet) ...........................................................................A-31

©

National Instruments Corporation

ix

TestStand I Fundamentals CourseManual

Introduction

TestStand I: Fundamentals Course Manual National Instruments 11500 N. MoPac Expressway Austin, Texas 78759 (512) 683-0100

Introduction TestStand is a powerful, flexible, and easy-to-use test executive software program. Built around an intuitive explorer-style interface and able to execute tests created in a variety of test development environments, TestStand enables developers to build sophisticated testing programs customized to their exact needs. This course introduces the TestStand environment and teaches you how to use TestStand for your test executive applications. The main emphasis of this course is to cover the fundamental, off-the-shelf features that TestStand offers. A background knowledge of test executive software and a familiarity with either LabVIEW or C programming is required for this course.

©

National Instruments Corporation

xi

TestStandI Fundamentals Course Manual

Introduction

Technical Support Options Internet Support: NI Web Support Email Support TestStand Support

ni.com ni.com/ask ni.com/support/teststandsupp.htm

The NI Web and TestStand Support pages offer these resources to help you find answers to your measurement and automation questions: • Developer Zone •• • •

TestExec programs List Serverdatabase Example Searchable KnowledgeBase Latest product and event information

Telephone Support (USA): Telephone Support

(512) 795-8248

Technical Support Options National Instruments is dedicated to providing you with the best support options to help you find solutions to your questions in the shortest possible time. For 24-hour accessibility, we offer complete and exhaustive technical information through our NI Web Support, which features an extensive knowledgebase with search capabilities, a variety of support documents (such as user manuals for our products), application notes, driver software, and much more. Use NI Web Support as your first stop if you have any questions about National Instruments products. If our web site does not answer all your questions, we also offer e-mail and phone support.

TestStandIFundamentalsCourseManual

xii

ni.com

Introduction

Course Objectives • Introduce the TestStand architecture • Demonstrate the powerful off-the-shelf capabilities of TestStand In this course, you will learn how to: • Build sequences and tests • Use the operator interfaces • Distribute TestStand and test code Note You can customize many of the topics discussed in this course to integrate further with your testing requirements.

Course Objectives This TestStand course teaches you the fundamentals of the TestStand environment. It begins with a background discussion of the TestStand architecture, including an overview of each constituent part. The course then discusses the TestStand environment and demonstrates how to use TestStand to create a test management program. The course concludes by showing you how to distribute TestStand and your test sequences.

Course Description The course is divided into lessons that teach a topic or a set of topics. Each lesson consists of: •

An introduction that describes the lesson’s objectives and the topics discussed.



A discussion of the topics.



A set of hands-on exercises that reinforce the conceptspresented in the discussion. (Some of the exercises are duplicated for LabVIEW and LabWindows/CVI, so you can work in your preferred programming environment. For duplicate exercises, select one of the exercises to complete during the time allotted.)



A summary that highlights the concepts covered in the lesson.

©

National Instruments Corporation

xiii

TestStandI Fundamentals Course Manual

Introduction

Course Map Day 2

Day 1 TestStand Environment

User Management

Creating Sequences

Operator Interface

Variables, Properties, and Expressions

Report Generation

Result Collection

Database Features

Creating Test Modules in External Environments

Distributing TestStand

Course Map Over the next two days, the course addresses several key concepts of TestStand. Lessons 1 through 4 introduce the TestStand development environment. These lessons present basic operations in opening and creating sequence files and using variables, properties, and expressions. Lesson 5 explains how TestStand communicates with external programming environments and how you can create TestStand-compatible test modules in these environments. Lesson 6 addresses how you can develop multiple user levels. Lessons 7 through 10 address collecting results and generating reports, logging results to a database, using the property loader, and distributing TestStand to other test stations.

TestStandIFundamentalsCourseManual

xiv

ni.com

Introduction

Items You Need for This Course TestStand version 2.0 or later

TestStand I: Fundamentals Course Manual

Computer running Windows 95/NT/98 with an internal PC speaker (Recommended: Pentium II 266 MHz or better and 64MB RAM)

TestStand Development Course disks

Items You Need for This Course •

Computer running Windows 95/NT/98



TestStand version 2.0



TestStand I Fundamentals Course Manual and disks

Install the course software by inserting the course disks and extracting the contents of the self-extracting archives into your C:\Exercises\TestStand I directory. The solutions to all exercises should be installed in the C:\Solutions\TestStand Idirectory. You also need LabVIEW 6.0 or later, LabWindows/CVI 5.5, and Excel 97 or Excel 97 Viewer for some of the exercises.

©

National Instruments Corporation

xv

TestStandI Fundamentals Course Manual

Introduction

Hands-On Exercises • Exercises reinforce the topics presented • Save exercises in the \Exercises\TestStand I directory • Solutions are in the \Solutions\TestStand I directory

TestStandIFundamentalsCourseManual

xvi

ni.com

Lesson 1 Introduction to TestStand

Lesson 1: Introduction to TestStand In this lesson, you will learn: • The role of a test executive • The basic TestStand concepts • The TestStand architecture

Introduction to TestStand This lesson introduces the basic TestStand concepts and the development environment architecture. The first part introduces the role of a test executive in a test environment and the tasks it performs. The second part addresses the issue of“What is TestStand?” The third part describes the TestStand architecture and provides detailed information about its constituent parts. The exercises introduce two of the constituent parts of TestStand, the Sequence Editor and the Operator Interface.

©

National Instruments Corporation

1-1

TestStandI Fundamentals Course Manual

Lesson 1

Introduction to TestStand

The Role of a Test Executive Components of a Test System: Operations different for each product tested:

Operations repeated for each product tested:

• Calibration

• Operator interfaces

• Configuring instruments

• User management

• Data acquisition

tive

u (UUT) tracking • Unit Under cTest e E st results • Archiving Te • Test flowxcontrol

• Measurements • Analyzing results

• Test reports

• Test strategies

The Role of a Test Executive In every testing environment, a wide variety of operations must be performed. These operations can be separated into two distinct groups: operations repeated for each product tested and operations different for each product tested. Test executive programs execute operations that are repeated for each product. Operations such as displaying the user interface, providing user management, performing step branching, archiving results, and creating test reports are similar for each product tested, and are therefore handled by a test executive. The other set of operations, such as calibration and configuration routines, data acquisition and measurement, analysis of results, and developing test strategies, are different for each product. These operations are written in other environments (for example, LabVIEW and/or LabWindows/CVI) and implemented as steps in a test executive program. Thus, a test executive allows test engineers to concentrate on developing tests for their products while providing the basic operations needed for testing environments. This allows test engineers to develop test modules efficiently without redundant code development.

TestStandIFundamentalsCourseManual

1-2

ni.com

Lesson 1

Introduction to TestStand

Our Goal for TestStand To build an off-the-shelf test executive that: • Any user can modify easily • Satisfies a variety of user requirements • Integrates with existing systems (databases, SPC tools, UUT tracking, and so on)

Our Goal for TestStand National Instruments has been designing test executive software for many years and has acquired in-depth experience about the needs of test developers. Test developers need a solution thatsi easy to use and ready to run right out of the box. At the same time, they need to customize the test management software for their own particular testing environments. Furthermore, they need to integrate the test management software with existing systems, including not only the test development environment, but also the additional tools used in the test systems (such as statistical control and database management). The goal of TestStand is to provide a product that is versatile and flexible enough that users can both easily use TestStand for their testing needs and customize TestStand quickly to create their own custom test executive systems. As you proceed with the course, you will see how TestStand meets the first goal and in the advanced course you will see how TestStand meets the second goal.

©

National Instruments Corporation

1-3

TestStandI Fundamentals Course Manual

Lesson 1

Introduction to TestStand

What is TestStand? Two Products in One • Ready-to-run test executive • Development environment for buildinga powerful custom test solution

What is TestStand? You can think of TestStand as two products in one. On the one hand, it is a ready-to-run test executive. Right out of the box, you can use it to develop sophisticated sequences to track UUTs and log and display data. Furthermore, because TestStand can call test modules written in a variety of languages, TestStand sequences can integrate a variety of existing code. TestStand goes beyond just building sequences. The test developer can customize almost every aspect of TestStand itself. So, in effect, TestStand is a tool for building your own test executive.

TestStandIFundamentalsCourseManual

1-4

ni.com

Lesson 1

Introduction to TestStand

The TestStand Architecture Main Components of TestStand • Sequence Editor • Operator Interfaces • TestStand Engine • Module Adapters

The TestStand Architecture To understand TestStand, you must understand its four major components: • Sequence Editor • Operator Interfaces •

TestStand Engine

• Module Adapters It is important to understand how each component fits into the test software design stages: • Sequence Editor —for developing, debugging, and executing sequences • Operator Interfaces —for executing and debugging sequences on the production floor • TestStand Engine —an Active X server that performs the test executive operations • Module Adapters —enable TestStand to interface with external development environments This lesson continues with a detailed discussion of each component.

©

National Instruments Corporation

1-5

TestStandI Fundamentals Course Manual

Lesson 1

Introduction to TestStand

TestStand Architecture: Sequence Editor

The Sequence Editor is: • A separate application • A development environment for: • Building and editing test sequences • Executing sequences for development and debugging • Managing your test code development

The Sequence Editor The Sequence Editor is a Win32-style application for creating, editing, and debugging TestStand sequences. A sequence is a collection of test modules with a controlled execution order. The Sequence Editor supports standard Windows editing tools such as cut and paste, drag and drop, and context-sensitive menus. The Sequence Editor gives you easy access to powerful TestStand features, such as step types and process models (addressed later in this course). You can use debugging tools such as breakpoints, single-stepping, stepping into or over function calls, tracing, variable display, and watch window. From the Sequence Editor, you can execute multiple instances of the same sequence and execute different sequences at the same time. The Sequence Editor is the development environment from which you can build and debug your test sequences. The Sequence Editor also has features like source code control and workspaces that help you manage your test development.

TestStandIFundamentalsCourseManual

1-6

ni.com

Lesson 1

Introduction to TestStand

TestStand Architecture: Operator Interface

The Operator Interface: • Allows you to start multiple concurrent executions, set breakpoints, and single-step, but not modify, sequences • Can be created in several development environments • Contains source code for LabVIE W, LabWindows/CVI, Delphi, and Visual Basic

The Operator Interfac e The Operator Interface is a separate application used for executing TestStand sequences on the production floor. It serves as an interface for the engine through the TestStand application programming interface (API). The run-time Operator Interface allows you to start multiple concurrent executions, set breakpoints, and single-step through a sequence. However, the run-time Operator Interface does not allow you to modify sequences or display sequence variables, sequence parameters, or step properties. TestStand currently includes four operator interfaces in both source code and executable form. Each run-time operator interface is a separate application program, differing primarily with respect to the application development environment (ADE) in which each was developed. TestStand ships with run-time operator interfaces developed in LabVIEW, LabWindows/CVI, Delphi, and Visual Basic. In addition to the these programming environments, you can write the Operator Interface in any programming environment that supports ActiveX client functionality. Although you can use the TestStand Sequence Editor at a production station, the TestStand run-time operator interfaces are simpler and fully customizable, thus making them more suitable applications for deployment. This course explains the operator interfaces in more detail in a later lesson.

©

National Instruments Corporation

1-7

TestStandI Fundamentals Course Manual

Lesson 1

Introduction to TestStand

TestStand Architecture: TestStand Engine

The TestStand Engine is focused on execution, speed, flexibility, and long-term support/compatibility. The TestStand Engine offers: • Multithreaded sequ encing • Flow control (Preconditions, Branching, Looping) • Sequence file creation, modification, saving, and loading • Data collection • Multilevel user access (login)

TestStand Engine At the core of the TestStand architecture is the TestStand Engine. The engine is implemented as a set of 32-bit Dynamic Link Libraries (DLLs) that export an ActiveX API. The TestStand Engine handles test executive tasks such as sequencing, branching, looping, limit checking, data allocation, and user management. The engine is optimized for speed and designed for maximum flexibility and long-term compatibility. The TestStand Sequence Editor and run-time operator interfaces use the engine API for creating, editing, executing, and debugging sequences. You can call the engine API from any programming environment that supports access to ActiveX Automation servers. You can even call the engine API from test modules, including test modules you create in LabVIEW and LabWindows/CVI. ActiveX Automation and the TestStand API are discussed more thoroughly later in the course.

TestStandIFundamentalsCourseManual

1-8

ni.com

Lesson 1

Introduction to TestStand

TestStand Architecture: Module Adapters Module Adapters: • Allow TestStand to integrate with various languages • Execute test modules at run-time • Step into test modules • Generate test module templates

TestStand

LV

CVI

DLL

ActiveX TestStand HT Servers Sequence Basic

Module Adapters To communicate with external code modules, TestStand must know the code module type, how to call it, and how to pass parameters to it. Module adapters integrate TestStand with external environments. The adapters act as an interface between TestStand and external test development environments, supplying the necessary information for communication between the two environments. Module adapters allow TestStand to execute test modules, pass and receive data, generate test module templates, and even debug code written in another programming language. TestStand can call a test written in any language for which it has an adapter. Currently, there are adapters for LabVIEW, LabWindows/CVI, Dynamic Linked Libraries (DLLs), ActiveX Automation servers, sequences, and HTBasic. These adapters can call different types of code modules: TestStand sequences, LabVIEW VIs, HTBasic subroutines, C functions in DLLs, and C functions in source, object, or library modules that you create in LabWindows/CVI or other compilers. Module adapters allow you to integrate your existing test software and tools. Adapters help you benefit from the fully customizable features of TestStand and the investment you have already made in your existing test software infrastructure. Note When creating TestStand sequences, you can usedifferent adapters within the same sequence.

©

National Instruments Corporation

1-9

TestStandI Fundamentals Course Manual

Lesson 1

Introduction to TestStand

TestStand Architecture Samples in Source: LV, CVI, VB

Custom Operator Interface

Sequence Editor

ActiveX Clients

Application Programming Interface

TestStand Engine (ActiveX Server)

LV

CVI

DLL

Process Model

ActiveX TestStand HT Servers Sequence Basic

The TestStand Architecture The TestStand architecture involves using all four main components (Sequence Editor, Operator Interfaces, Engine, and Module Adapters) in the test execution. This slide demonstrates how each component interacts with the TestStand Engine. The engine, an ActiveX server, exports an API that the Sequence Editor and operator interfaces use. The engine performs specific operations (for example, running a sequence) in response to ActiveX method calls. The TestStand Engine runs the sequences, which contain steps that can call external code modules. By using module adapt ers that have a standard adapter interface, the TestStand Engine can load and execute different types of code modules and even call other sequences through the same adapter interface. The TestStand Engine uses a special type of sequence called a process model to direct h t e flow of its operations. The next lesson addresses process models in detail. In Exercise 1-1, you will examine the Sequence Editor and one of the sample operator interfaces.

TestStandIFundamentalsCourseManual

1-10

ni.com

Lesson 1

Introduction to TestStand

Exercise 1-1 Objective: To launch TestStand and run a sequence file from the Sequence Editor

Approximate time to complete: 10 minutes

©

National Instruments Corporation

1-11

TestStand I Fundamentals Course Manual

Lesson 1

Introduction to TestStand

Exercises 1-2A and 1-2B Objective: To run a sequence file from the LabVIEW or LabWindows/CVI Operator Interface Note When there is both an exercise A and B, choose one of the exercises based on your preferred development environment

Approximate time to complete: 10 minutes

TestStandIFundamentalsCourseManual

1-12

ni.com

Lesson 1

Introduction to TestStand

Lesson 1 Summary: Introduction toTestStand

• Test executives perform UUT-independent repetitive operations in testing environments • TestStand is an off-the-shelf, ready-to-run test executive that is fully customizable • TestStand has four main components: • Sequence Editor • Operator Interfaces • TestStand Engine • Module Adapters

Summary A test executive program performs tasks in the testing environment that are repetitive for different products tested. This allows you to focus on creating the test modules and prevents redundant programming. TestStand is a ready-to run test executive software program that is fully customizable so that you can modify TestStand to fit your needs. The TestStand architecture has four main components: • Sequence Editor —for developing, debugging, and executing sequences. • Operator Interfaces —for executing and debugging sequences on the production floor. • TestStand Engine —an ActiveX server that performs the test executive operations. •

Module Adapters—enable TestStand to interface with external development environments .

In the rest of the course, you will learn how to use and develop tests using these key TestStand components.

©

National Instruments Corporation

1-13

TestStand I Fundamentals Course Manual

Lesson 1 Introduction to TestStand Exercises

Exercise 1-1 Running a Sequence File Objective:

To run test sequences from the Sequence Editor and view reports generated by TestStand. The Sequence Editor is the TestStand development environment in which you can create, edit, and execute sequences. It is important to be familiar with this environment, because you will develop all sequence files here. 1. Open the Sequence Editor by clicking the Windows Start menu, and then select Programs»National Instruments TestStand»Sequence Editor . Afterinput the Sequence Editor loads, you are promptedand to the log in. The default for the Login Name isadministrator password is left empty. ClickOK to complete the login.

2. After logging in, select File»Open and navigate to C:\Exercises\ TestStand I. This is the location of all TestStand course exercises. 3. Double-click on Ex 1-1 Computer Test.seq to open the sequence file. This is a simple sequence that simulates testing parts of a computer motherboard (for example, the RAM, ROM, and keyboard). This particular sequence has tests written in LabVIEW; however, you could write the tests in LabWindows/CVI or a variety of other programming environments compiled as DLLs, EXEs, or ActiveX Servers. The TestStand window should appear as shown below.

TestStandIFundamentalsCourseManual

1-14

ni.com

Lesson 1

Introduction to TestStand Exercises

4. To run the sequence, select either Execute»Test UUTs or Execute»Single Pass or click the Run button, as shown in the toolbar below.

Test UUTs is an execution entry point that runs the sequence in a continuous loop. Execution entry points are used to run the sequence in predefined ways. By default, TestStand has only two execution entry points, Test UUT and Single Pass. Lesson 2 describes execution entry points in more detail, and Lesson 7 explores how to create an execution entry point. Before executing the sequence, a UUT Information dialog box prompts you for a serial number. Enter any number for the serial number. After executing the sequence, a Pass/Fail banner indicates the sequence status. To stop the loop and generate a sequence report, click on the Stop button in the UUT Information dialog box. Test UUTs is the execution entry point for running most test systems in TestStand. Single Pass is an execution entry point that executes the sequence once and generates a report. Single Pass is useful for debugging your tests and determining that your sequence execution proceeds as you intended.

©

National Instruments Corporation

1-15

TestStand I Fundamentals Course Manual

Lesson 1 Introduction to TestStand Exercises

Run Main Sequence allows you to execute the sequence without using the process model. (The process model is discussed in future lessons.) This mode can test only how your main sequence proceeds, because no other parts of the process model are executed in this type of execution. For now, the only noticeable difference is that no report is generated, as compared to the Test UUTs or Single Pass entry points. The process model as used by the Test UUTs and Single Pass entry points is explained later in this course. 5. Use the Motherboard Test Simulator dialog box to select the tests you want to fail. To do this, click on the check boxes beside the name of the part you want to set to fail. (An X appears in ht e box when you select it.)

Note Checking the CPU test does not cause a failure, because thatstep is not yet included in the sequence. This dialog box is called in the Setup step group of this test sequence file. Lesson 2 includes an explanation of step groups.

TestStandIFundamentalsCourseManual

1-16

ni.com

Lesson 1

Introduction to TestStand Exercises

6. Notice that another window is created in the Sequence Editor when the sequence begins execution. This is the execution window, while the window that was initially open is the sequence file window.

To stop anfinish execution, clickStop in the UUT Information dialog box. After you execution, the execution window displays the report. You can verify which tests failed by scrolling down the test report generated at the end of execution. SelectExecute»Test UUTs again and run through several UUTs, setting different tests to fail each time, to become familiar with the execution of this sequence. This sequence uses preconditions to determine when tests should execute. For example, if the Powerup Test is set to fail, all other steps are skipped. Also, notice that the steps labeled“Diagnostics” are skipped unless their corresponding test fails. This scenario is common in test systems. If a test fails, you may want to run a diagnostic to determine exactly which component failed. But it would be a waste of time to run a diagnostic if the srcinal test passed. Dependencies for determining which steps execute are called preconditions. Preconditions are discussed in more detail later in this course.

©

National Instruments Corporation

1-17

TestStand I Fundamentals Course Manual

Lesson 1 Introduction to TestStand Exercises

Optional: Discussion of TestStand Search Directories TestStand maintains a list of directories to search for files. To view the current list, select Configure»Search Directories.

TestStand searches for modules specified in a sequencefile beginning at the top of the list and working toward the bottom. You can move directories up or down in the list to specify precedence. If the list contains a directory you do not want TestStand to search, you can uncheck the checkbox next to that directory. See the TestStand User Manual for more information about the Search Directories. The list of search directories is maintained inTestExec.ini in the \cfg\ directory. When the test system is distributed, the Engine Installation Wizard includesTestExec.ini in the files to be distributed. 7. When the exercise is complete, close the execution window and sequence display window by selectingFile»Close.

End of Exercise 1-1

TestStandIFundamentalsCourseManual

1-18

ni.com

Lesson 1

Introduction to TestStand Exercises

Exercise 1-2A Running a Sequence File from the LabVIEW Operator Interface Objective:

To become fam iliar with running test sequences fro m the opera tor interface and viewing reports generated by TestStand. The Sequence Editor used in the previous exercise is not the only application for executing tests. The operator interface used in this exercise is another interface to execute tests. This interface was built with LabVIEW and is the interface the operator uses on the production floor. The operator interface looks similar to the Sequence Editor, because it has most of the same functionality. The two critical differences between the operator interface and the Sequence Editor are: •

Currently, the operator interface cannot modify or create sequence files, unlike the Sequence Editor.

• The Sequence Editor is not provided with source code, and therefore you cannot modify it. On the other hand, the operator interface source code is included with the TestStand installation and is meant to be modified so that every user can create a customized operator interface. The source code for the default operator interfaces included with TestStand is in the following directory:

\Examples\OperatorInterfaces The purpose of this lesson is simply to explore the default LabVIEW operator interface and familiar with some of the differences and similarities between it become and the Sequence Editor. 1. Open the operator interface. From the Windows Start menu, select Programs»National Instruments TestStand»Operator Interfaces»LabVIEW. This launches LabVIEW. The operator interface is an application for opening and running test sequences. As mentioned earlier, the sample operator interfaces included with TestStand are intended to be a starting point for the application that will be installed on the test/production floor. The operator interfaces allow the execution and debugging of multiple sequences.

©

National Instruments Corporation

1-19

TestStand I Fundamentals Course Manual

Lesson 1 Introduction to TestStand Exercises

After the LabVIEW operator interface is loaded, the Login prompt appears.

Log in as administrator; as before, the password should be empty. Click OK to continue. 2. After logging in, select File»Open Sequence File and navigate to C:\Exercises\TestStand I. 3. Open Ex 1-1 Computer Test.seq. This is the same sequence that was run in Exercise 1-1. The window should appear as shown below.

TestStandIFundamentalsCourseManual

1-20

ni.com

Lesson 1

Introduction to TestStand Exercises

4. Execute the sequence by clicking on the Test UUTs button. This displays the UUT Information dialog box (shown below), and opens the execution display window (shown on the next page). Type in any value for the serial number and clickOK . As in the previous exercise, select different tests to fail before stopping the test to view the report.

During execution, the execution display window shows the status of each step and allows you to control the execution using tools such as breakpoints and stepping mechanisms. These tools are covered in Lesson 2, The TestStand Environment. When you stop the execution (remember to click the Stop button instead of entering another serial number and clickingOK ), the execution display window displays the report. In the figure below, the report is displayed using HTML, which is the default display format in the operator interface. However, notice that the operator interfaces do not use a web browser control to display the HTML commands, as the Sequence Editor does.

©

National Instruments Corporation

1-21

TestStand I Fundamentals Course Manual

Lesson 1 Introduction to TestStand Exercises

The sequence display and execution display are separate windows. The sequence display window displays all information related to the sequence file currently loaded into memory. This information includes information such as the sequence filename, the current user logged in, and the steps in the sequence. The execution display window shows all information related to the execution of a sequence file. This information includes the status of each step in the sequence file, which sequence is being run, and the sequence report contents. Click on either window to bring it to the front and view its contents. Note TestStand can run multiple sequence executions in parallel. Switching backto the sequence display window and clicking theTest UUT button again causes the sequence to begin executing a second time in a separate execution display window from the first execution. Additionally, you can load and execute a separate sequence file in parallel instead of executing the same sequence file. Lesson 3 includes an example of executing sequences in parallel.

5. Click the Launch Report Viewer button to launch the application associated with the type of report you are viewing. If the operator interface is still configured to print the report in HTML format, the operating system typically launches Internet Explorer or Netscape to view HTML report files.

TestStandIFundamentalsCourseManual

1-22

ni.com

Lesson 1

Introduction to TestStand Exercises

6. When you finish viewing the report file, close the web browser that TestStand used to display the file. Click on the execution display window to bring it to the front and close it by selectingFile»Close Execution. Next, bring the sequence display window to the front by clicking on it, and close the sequence by selecting File»Close Sequence File. Finally, close the operator interface by selectingFile»Exit from the sequence display window.

End of Exercise 1-2A

©

National Instruments Corporation

1-23

TestStand I Fundamentals Course Manual

Lesson 1 Introduction to TestStand Exercises

Exercise 1-2B Running a Sequence File from the LabWindows/CVI Operator Interface Objective:

To become fam iliar with running test sequences fro m the opera tor interface and viewing reports generated by TestStand. The Sequence Editor used in the previous example is not the only application for executing tests. The operator interface used in this exercise is another interface to execute tests. The interface used in this exercise was built with LabWindows/CVI and is the interface the operator uses on the production floor. The operator interface looks similar to the Sequence Editor, because it has most of the same functionality. The two critical differences between the operator interface and the Sequence Editor are: •

Currently, the operator interface cannot modifyor create sequence files, unlike the Sequence Editor.

• The Sequence Editor is not provided with source code, and therefore you cannot modify it. On the other hand, the operator interface source code is included with the TestStand installation and is meant to be modified so that every user can create a customized operator interface. The source code for the default operator interfaces included with TestStand is in the following directory:

\Examples\OperatorInterfaces The purpose of thisand lesson is tofamiliar explore with the default LabWindows/CVI operator interface become some of the differences and similarities between it and the Sequence Editor. 1. Open the operator interface. From the Windows Start menu, select Programs»National Instruments TestStand»Operator Interfaces»LabWindows/CVI. The operator interface is an application for opening and running test sequences. As mentioned earlier, the sample operator interfaces included with TestStand are intended to be a starting point for the application that will be installed on the test/production floor. The operator interfaces allow the execution and debugging of multiple sequences.

TestStandIFundamentalsCourseManual

1-24

ni.com

Lesson 1

Introduction to TestStand Exercises

After the LabWindows/CVI operator interface is loaded, the Login prompt is displayed.

Log in as administrator; as before, the password should be empty. Click OK to continue. 2. After logging in, select File»Open Sequence file and navigate to C:\Exercises\TestStand I. 3. Open Ex 1-1 Computer Test.seq. This is the same file used in the previous exercise. The sequence display window of the operator interface should resemble the one shown below.

©

National Instruments Corporation

1-25

TestStand I Fundamentals Course Manual

Lesson 1 Introduction to TestStand Exercises

4. Execute the sequence by clicking the Test UUTs button. This displays the UUT Information dialog box (shown below) and the execution display window (shown on the next page). Type in any value for the serial number and clickOK . As in the previous exercise, try setting different tests to fail before stopping the test to view the report.

During execution, the execution display window shows the status of each step and allows you to control the execution using tools such as breakpoints and stepping mechanisms. These tools are covered in Lesson 2, The TestStand Environment. When you stop the execution (remember to click the Stop button instead of entering another serial number and press OK ), the execution display window displays the report. In the figure below, the report is displayed using HTML, which is the default display format in the operator interface. However, notice that the operator interfaces do not use a web browser control to display the HTML commands, as the Sequence Editor does.

TestStandIFundamentalsCourseManual

1-26

ni.com

Lesson 1

Introduction to TestStand Exercises

The sequence display and execution display are separate windows. The sequence display window displays all information related to the sequence file currently loaded into memory. This information includes the sequence file name, the current user logged in, and the steps in the sequence. The execution display window shows all information related to the execution of a sequence file. This information includes the status of each step in the sequence file, which sequence is being run, and the sequence report contents. Click on either window to bring it to the front and view its contents. 5. Click on the Launch Report Viewer button to launch the application associated with the type of report you are viewing. If the operator interface is still configured to print the report in HTML format, the operating system typically launches Internet Explorer or Netscape to view HTML report files. 6. Close the sequence by selecting File»Close Sequence File when the exercise is completed. Then close the operator interface by selecting File»Exit.

End of Exercise 1-2B

©

National Instruments Corporation

1-27

TestStand I Fundamentals Course Manual

Lesson 1 Introduction to TestStand Exercises

Notes

TestStandIFundamentalsCourseManual

1-28

ni.com

Lesson 2 The TestStand Environment

Lesson 2: The TestStand Environment

In this lesson, you will learn about: • TestStand sequences, step groups, and sequence files • The debugging featuresin TestStand and how to use them • The definition of a process model and the default TestStand process models • The features available in the Sequence Editor for managing test development

Introduction This lesson discusses TestStand sequences, their component step groups, and sequence files. It then introduces the debugging tools available in TestStand and explains how to execute them in the Sequence Editor. It also discusses the concept of a process model, and explains how TestStand can use the various default process models to execute tests. Test file management tools are also discussed in this lesson.

©

National Instruments Corporation

2-1

TestStandI Fundamentals Course Manual

Lesson 2

The TestStand Environment

TestStand Sequences What is a sequence? • A test sequence consists of a series of test modules and flow control settings used to test a Unit Under Test (UUT) • Each line of a sequence is called a step

Sequence Step 1 Default Execution Direction

Step 2 Step 3

What is a sequence? Before getting into TestStand sequence files, it helps to examine a sequence at its most basic level. A sequence is a series of TestStand steps combined with the control logic that determines the order in which those steps are executed. Each step performs a particular action that contributes to the overall testing of the UUT. For example, in a step you could execute a LabVIEW VI that performs some type of test. The default operation is such that TestStand begins sequence execution with the topmost step and executes the steps from top to bottom. However, you can control the sequence ’s execution flow; this is addressed in the next lesson.

TestStandIFundamentalsCourseManual

2-2

ni.com

Lesson 2

The TestStand Environment

TestStand Sequences: Step Groups As shown below, all TestStand sequences have three step groups TestStand Sequence Cleanup Setup

Main

Steps

Step Groups Within every TestStand sequence, there are three step groups: setup, main, and cleanup. These step groups are always executed in the same order: setup, main, and cleanup. The step groups organize a series of sequence steps in a logical and sequential manner. For example, the setup group might contain initialize or power-up routines, the main group might contain the actual test routines, and the cleanup group might contain steps to close files or power-down instruments. The default settings for TestStand are such that the cleanup steps are executed even if there is a run-time error.

©

National Instruments Corporation

2-3

TestStandI Fundamentals Course Manual

Lesson 2

The TestStand Environment

TestStand Sequence Files Sequence files include the MainSequence, its subsequences and steps, and all included callbacks Sequence File MainSequence

Subsequence

Setup

Setup

Main Cleanup

Pre-UUT Callback Setup

Main

Main

Cleanup

Cleanup

TestStand Sequence Files TestStand sequence files are comprised of multiple sequences. This may include multiple user-defined sequences and/or any callback sequences used with this sequence file (for now, think of callbacks as essentially predefined sequences; callbacks are discussed later). To illustrate this concept, consider a bar code scanning application. Assume that for a particular product, the serial number is read by scanning a bar code, but for all other products, an operator enters it. The test developer would include the Pre-UUT callback (the callback that includes the serial number inquiry) in the sequence file for that product, and edit it to include the bar code scanning routines. Each time that particular sequence file is loaded, TestStand recognizes that it has its own Pre-UUT callback sequence and uses it. However, when other sequence files are loaded, TestStand still uses the default Pre-UUT callback, which prompts the operator to enter a serial number. Thus, the sequence file is a TestStand application file that contains all information necessary for TestStand to load and execute a particular test application. Note TestStand sequences typically contain asequence namedMainSequence, which is different from the Main step group.

TestStandIFundamentalsCourseManual

2-4

ni.com

Lesson 2

The TestStand Environment

Debugging Sequences Types of debugging tools: • Execution tracing functionality • Breakpoint setting • Single stepping tools Step In

Step Over Step Out

Debugging Tools TestStand has a variety of debugging tools that help you verify the execution of your TestStand applications. The execution tracing option allows you to view the execution flow for the sequence in the execution window. If tracing is enabled, the Sequence Editor displays the progress of an execution by placing a yellow arrow icon to the left of the icon for the currently executing step. You can adjust the speed of tracing by selectingConfigure»Station Options and adjusting the slider on the Execution tab. The Sequence Editor and operator interfaces allow you to set breakpoints, step into, step over, or step out of sequences, and set the next step to execute. You can also view variables and create watch expressions (combination of variables). These tools allow you to control the sequence execution manually and identify potential areas that require further modification. The debugging tools are addressed in greater detail in Exercises 2-1 and 2-2.

©

National Instruments Corporation

2-5

TestStandI Fundamentals Course Manual

Lesson 2

The TestStand Environment

Exercise 2-1 Objective: To understand subsequences, setup and cleanup routines, and execution tracing

Approximate time to complete: 15 minutes

TestStandIFundamentalsCourseManual

2-6

ni.com

Lesson 2

The TestStand Environment

Exercise 2-2 Objective: To become familiar with using breakpoints and debugging tools in the Sequence Editor.

Approximate time to complete: 5 minutes

©

National Instruments Corporation

2-7

TestStandI Fundamentals Course Manual

Lesson 2

The TestStand Environment

TestStand Sequences: The Process Models What is a Process Model? A Process Model is a list of steps that specify the high level flow of execution in a test system

About the Process Models: • There are 3 available process models: – SequentialModel.seq – BatchModel.seq – ParallelModel.seq

• The default model is SequentialModel.seq • The process models have two modes of operation: – Test UUTs – Single pass

The TestStand Process Models A process model is a list of steps that specify the high-level flow of execution in a test system. In other words, the process model is the flow of execution of the test executive. TestStand has three available process models. By default, TestStand uses the sequence file SequentialModel.seq as its process model. The TestStand process models contain sequences that define operations TestStand performs before andafter it tests a UUT. To invoke (or execute) a sequence in a process model, run one of the Execution Entry Point sequences in the model. The TestStand process models have two modes of operation called execution entry points. They appear as the Test UUTs and Single Pass selections in the Execute menu. Single Pass is usually for debugging purposes; it executes the selected sequence file only once and generates a test report. Test UUTs is for testing multiple UUTs. It loops until the operator quits and generates a test report for all UUTs. The Test UUTs mode is discussed next. Note If you modify the process models under \TestStand\Components, notice that there are two subdirectories for the process models:NI and User. Always copy the process models into theUser directory so that you maintain a copy of the srcinals.

TestStandIFundamentalsCourseManual

2-8

ni.com

Lesson 2

The TestStand Environment

The TestStand Process Models • SequentialModel.seq (Default Process Model) – Multi-purpose process model ideal for most testing applications

• BatchModel.seq – Process model used to control a set of test sockets that tests multiple UUTs as a group or “batch”

• ParallelModel.seq – Process model used for handling multiple independent test sockets

Available TestStand Process Models As mentioned in the previous slide, there are three process models in TestStand. The default process model is SequentialModel.seq. This sequence file is a multi-purpose process model that is ideal for most testing applications. The other two process models are designed to make it easier to implement running the same test sequence on multiple UUTs at the same time. They are discussed in more detail below. The Batch process model,BatchModel.seq, can be used for controlling a set of test sockets that test multiple UUTs as a group. For example, you might have a set of circuit boards attached to a common carrier. The Batch model ensures that you start and finish testing all boards at the same time. The Batch model also provides batch synchronization features in which you can indicate that a step applies to the batch as a whole and therefore the step would only run once per batch instead of once for every UUT. Another convenient feature is the ability of the Batch model to generate batch reports that summarize the test results for all UUTs in the batch. The Parallel process model, ParallelModel.seq, can be used for handling multiple independent test sockets. The Parallel model allows you to start and stop testing on any socket at any time. For example, you might have five test sockets for testing radios. The Parallel model allows you to load a new radio into an open socket while the other sockets are busy testing other radios.

©

National Instruments Corporation

2-9

TestStandI Fundamentals Course Manual

Lesson 2

The TestStand Environment

Default ProcessModel Sequential Model: Test UUTs mode Pre-UUT Callback

Pre-UUT Loop

Setup Pre-UUT Main Cleanup

Main Sequence

Main Sequence

Post-UUT

Setup Main

Loop until operator quits

Generate Report

Cleanup Post-UUT Loop

The Default Process Model: Test UUTs Mode The flowchart above depicts the order in whichMainSequence and all the TestStand callback sequences are executed for the Test UUTs mode of the Sequential process model. When the Test UUTs mode is initiated, TestStand executes the Pre-UUT Loop Callback (test system setup operations), followed by the Pre-UUT Callback (UUT setup operations). These callbacks are always part of the process model, unless you modify the process model yourself (discussed in the customization lesson later in the course). The next step is theMainSequence step, which the user creates using the Sequence Editor. TestStand then executes the Post-UUT Callback (UUT clean up operations) and updates a test report. Execution then returns to the Pre-UUT Callback for the next UUT to be tested. On completion of testing, TestStand steps out of the loop, generates a test report, and executes the Post-UUT Loop Callback test (system clean up operations). The Sequential process model contains model callbacks, which are normal TestStand sequences, with the exception that these callbacks perform specific tasks during sequence execution. For example, the Pre-UUT Loop Callback can run setup sequences for testing. The model callbacks MainSequence without can serve as hooks for you to customize the process model for each altering the process model directly.

TestStandIFundamentalsCourseManual

2-10

ni.com

Lesson 2

The TestStand Environment

SequentialModel.seq

SequentialModel.seq Execution entry points in process models, such as Test UUTs and Single Pass, use callbacks to invoke theMainSequence in your sequence file. Each sequence file must then define a sequence by the name of MainSequence. The default process model, SequentialModel.seq, contains a MainSequence callback that is merely a place holder. The MainSequence in your sequence file overrides theMainSequence place holder in the SequentialModel.seq. As shown in the slide above, the default TestStand process model is itself just another sequence file called SequentialModel.seq. Thus, you can completely edit and customize the process model. It includes all the callback sequences (as displayed in the pull down View ring), various steps used for sequencing logic and keeping track of certain TestStand variables, and execution entry points. Exercise 2-3 introduces you to the default process model sequence file in greater detail.

©

National Instruments Corporation

2-11

TestStand I Fundamentals Course Manual

Lesson 2

The TestStand Environment

The Process Model & TestStand Architecture ActiveX Clients

Custom Operator Interface

Sequence Editor

Application Programming Interface

TestStand Engine (ActiveX Server)

PROCESS MODEL Callbacks Callbacks

LV

CVI

DLL

ActiveX TestStand HT Servers Sequence Basic

The Role of a Process Model in TestStand This slide shows the role of a process model and callbacks in the TestStand architecture. Essentially, the TestStand Engine executes a model sequence file using the specified process model to direct the flowof operations in executing sequence files. While xeecuting the process model, the engine initiates callbacks at the appropriate time to perform their predetermined tasks. In this way, you can implement modifications without directly modifying the TestStand Engine. Modifications and customizations are addressed in the Advanced TestStand course.

TestStandIFundamentalsCourseManual

2-12

ni.com

Lesson 2

The TestStand Environment

Exercise 2-3 Objective: To understand the default process model Approximate time to complete: 20 minutes

©

National Instruments Corporation

2-13

TestStand I Fundamentals Course Manual

Lesson 2

The TestStand Environment

Workspaces and Source Control • Workspaces – organize sequence files, code modules, and other files into projects

• Projects – enables you to access related files quickly

• Source Control

– check files and projects in and out of a source code control system

• Differ – graphical tool that enables you to compare and merge differences between two sequence files

Workspaces and Source Control A workspace is a TestStand tool that you can use to organize sequence files, code modules, and other files into projects. Projects enable you to access related files quickly. You can check files and projects in and out of a source code control system from within the TestStand environment. You can also share workspaces with other users by checking a workspace file into source code control. The workspace window displays the contents of a TestStand workspace.tsw ( ) file. A workspace file displays a list of any number of TestStand project.tsp ( ) files. In TestStand, a project file can contain any type of file or folder but a workspace file can contain only projects. TestStand integrates with any source code control system that supports the Microsoft SCC interface. You can check files and projects in and out of your source code control system from a TestStand workspace. TestStand has been tested with the following source code control providers: Microsoft Visual SourceSafe, Perforce, MKS Source Integrity, and Rational ClearCase. The TestStand Differ is a graphical tool in the Sequence Editor that enables you to compare and merge differences between two sequence files. The TestStand Differ compares the sequence files and presents the differences in a new window. For more details on these features, please see theTestStand User Manual .

TestStandIFundamentalsCourseManual

2-14

ni.com

Lesson 2

The TestStand Environment

Workspaces and Projects Demo

Workspaces and Projects Demo This demo illustrates many of the features discussed on the previous slide. To use this demo, select File»Open Workspace File from the Sequence Editor menu. Open the TestStand workspace file C:\TestStand\Examples\Example.tsw. This workspace contains projects consisting of all the shipping examples that install with TestStand. Use the tree view to browse through various projects. Notice that the projects can contain not only sequence files but also the associated code modules. By right-clicking on theExamples property at the top of the tree view, you can add and remove files from the workspace as well as check files in and out of source control. The computer s used for this course do not have source control software installed on them so you will not be able to demo the source control tools within this class. You can use the TestStand Differ tool by opening a sequence file in the Sequence Editor and selecting Edit»Diff Sequence File With from the menu. A graphical window will then be displayed that shows you the differences between the compared sequence files.

©

National Instruments Corporation

2-15

TestStand I Fundamentals Course Manual

Lesson 2

The TestStand Environment

Lesson 2 Summary: The TestStand Environment • A test sequence is a series of test modules and flow control settings used to test a UUT • There are three step groups in a sequence: Setup, Main, and Cleanup • Sequence files contain user-defined main sequences and callback sequences required for sequence execution • A process model defines the high-level flow of execution for a test executive • The TestStand default process model is a sequence file called SequentialModel.seq

• Workspaces, projects, and source code control features help provide ways to better manage your test files and structure • The TestStand Differ enables you to make changes to and compare sequence files

Summary This lesson discussed the basic components of the TestStand environment: sequences, step groups, and process models. In a sense, you canthink of TestStand as providing fully customizable“templates” for every aspect TestStandModel.seq, and of testing. There is a default template available for the process itself, a default order for sequences: setup, main, and cleanup. These templates should work for the majority of test environments, but as you work through the exercises in this course, you will see that you can easily modify each“template” to suit your particular needs. Taking a top down perspective, a process model consists of a particular ordering of sequences and callbacks which match a testing process. The sequences themselves consist of a group of steps. The groups are, in turn, made up of steps configured by test developers. These steps correspond to a wide variety of actions, including testing a UUT, message popup for status, and so on. The next lesson discusses how these individual steps are configured to create sequences.

TestStandIFundamentalsCourseManual

2-16

ni.com

Lesson 2

The TestStand Environment Exercises

Exercise 2-1 Understanding the Sequence File Objective:

To understand subsequences, setup and cleanup routines, and execution tracing. Subsequences allow the test developer to modularize logical portions of the test into smaller sequences that are easier to manage and maintain. Breaking up a sequence file into manageable segments is similar to how a program developer breaks up sections of a program into many separate files. Each smaller segment has a very specific purpose and contributes some basic function to the calling sequence it is a part of. In addition to the sequence it was designed for, many other sequences can use this subsequence. This reusability and modularity make subsequences very useful, and TestStand makes it very easy to create and implement them.

Part A: Calling Subsequences The following example shows how one sequence cancall another sequence. In this sequence file are two sequences called from within the main sequence file. This is how TestStand allows one sequence to call another sequence. 1. In the Sequence Editor, select File»Open and navigate to C:\Exercises\TestStand I\ and open Ex 2-1 Computer Motherboard Test.seq. In this sequence file, the sequences namedCPU Test and CPU Diagnostic Test are subsequences. In TestStand, a sequence can call another sequence in the same sequence file or a different sequence file. In this case, are ina the sequence file.Sequences The light blue icon forthe thesubsequences step type denotes callsame to a subsequence. are discussed in greater detail later in the course.

©

National Instruments Corporation

2-17

TestStand I Fundamentals Course Manual

Lesson 2

The TestStand Environment Exercises

.

2. Execute the sequence by selecting Execute»Single Pass. Notice that in the report, the step results in the subsequences are separated from the step results in the calling sequence. Close the Execution window by selectingFile»Close or clicking the X icon on the window title bar. 3. To open a subsequence, right-click on the blue sequence call icon and select Open Sequence, as shown below. This displays the selected sequence call.

TestStandIFundamentalsCourseManual

2-18

ni.com

Lesson 2

The TestStand Environment Exercises

4. The Sequence Editor and operator interfaces allow several sequence files to be open simultaneously. To toggle between open sequences in different sequence files, use theWindow menu, as shown below. However, these sequences are in the same sequence file.

5. Use the View Ring to toggle between different sequences in the same sequence menu.

6. Close the subsequence window by selecting MainSequence from the View Ring.

Part B: Using Setup and Cleanup Groups The view for an individual sequence has five tabs:Main, Setup, Cleanup, Parameters, and Locals. The Main, Setup, and Cleanup tabs are described below, and the Parameters and Locals are described in Lesson 4. Select a tab to choose which part of the sequence to view.

©

National Instruments Corporation

2-19

TestStand I Fundamentals Course Manual

Lesson 2

The TestStand Environment Exercises

The Main, Setup, and Cleanup tabs each show one step group in the sequence. To view the contents of each tab, click the tab. The steps you insert in each step group have the following purposes: •

Main: Test the UUT.



Setup: Initialize or configure instruments, fixtures, and the UUT.



Cleanup: Power down or reset instruments, fixtures, and the UUT.

The Main group contains the bulk of the steps in a sequence, typically the steps that test the UUT. In this sequence, the Main group contains all steps that test the UUT, such as Powerup Test, ROM Test, RAM Test, and so on. The Setup group contains steps that initialize or configure the test system. In this sequence, the Setup group contains the Simulation Dialog step that displays the dialog box used to select which computer components should fail. It also contains a step to turn on a simulated vacuum table for testing each UUT. The Cleanup group contains steps that power down or deinitialize the instruments, fixtures, and UUT. In this sequence, the Cleanup group contains a step for powering down a simulated vacuum table that was turned on in the Setup group.

Discussion of Execution Tracing Notice that sequence execution is traced. If not, ensure that Execute»Tracing Enabled is checked. If the computer is too fast to view execution tracing, slow down the execution tracing by selectingConfigure»Station Options, which displays the Station Options dialog box.

TestStandIFundamentalsCourseManual

2-20

ni.com

Lesson 2

The TestStand Environment Exercises

Move the Speed slider toward Slow, which introduces a delay while tracing. Enable tracing inside of Setup and Cleanup by checking the appropriate checkbox, as shown above. Click OK to close the dialog box. With theEx 2-1 Computer Motherboard Test.seq sequence file as the active window, start another execution by selecting Execute»Single Pass and notice how tracing is affected. 7. When this execution is finished, close the sequence file and execution windows.

End of Exercise 2-1

©

National Instruments Corporation

2-21

TestStand I Fundamentals Course Manual

Lesson 2

The TestStand Environment Exercises

Exercise 2-2 Objective:

Running a Sequence File with Breakpoints and Single Stepping

To become familiar with using breakpoints and the debugging tools in the Sequence Editor. When creating a sequence file, you may want to observe sequence execution to make sure the sequence behaves as you intend. During debugging, you may want to observe execution in some sections of a sequence but not others. In this case, it is convenient to allow the sequence to execute until it reaches a section that needs analysis. TestStand allows you to insert convenient stopping points, known as breakpoints. Like most modern development systems, TestStand allows you to set and remove multiple breakpoints for every sequence file.

Part A: The Step Debugging Tools

1. In the Sequence Editor, select File»Open, navigate to C:\Exercises\TestStand I\, and open Ex 2-2 Computer.seq. 2. Click on the margin space to the left of the CPU test. A red Stop button appears. This means that a breakpoint has now been placed on that test. This exercise now explores the use of breakpoints. To remove the breakpoints later, click eachStop button.

TestStandIFundamentalsCourseManual

2-22

ni.com

Lesson 2

The TestStand Environment Exercises

3. Click the Run button. This executes the sequence in Test UUTs mode and brings up the familiar UUT information dialog box. Enter any number and click OK . Run button

Step buttonInto

Step buttonOver

Step buttonOut Of

4. The execution pauses at the first breakpoint—in this case, the CPU Test. Notice that the step into, step over, and step out of buttons in the toolbar are activated. Click the step into button. The execution pauses at the first test in the CPU subsequence. Click on thestep over button to stop on the next test. Note Advanced debugging techniques are covered later in this course.

5. The Run button is now the Resume button. Click on the Resume button to continue executing to the next breakpoint. Resume button

Terminate Execution button

6. Click on the Terminate Execution button to terminate. The report displays the results of all steps that executed. Note These same debuggingoptions are available in the operator interfaces. However, these tools will appear under menus rather than as task bar buttons.

End of Part A

©

National Instruments Corporation

2-23

TestStand I Fundamentals Course Manual

Lesson 2

The TestStand Environment Exercises

Part B: The Watch Window 1. Close the report and return to the Sequence Editor. Remove the breakpoint that was set on the CPU Test by clicking on the stop icon to the left of that step. Set a new breakpoint on the Powerup Test by clicking to the left of that step, which should cause a stop icon to appear. Then click on the Run button. Enter an arbitrary value for the UUT serial number and do not check any of the boxes so that all of the tests will pass. 2. In the lower right corner of the execution window is a section for watching variables during the sequence execution. This area, thewatch window, is useful for watching the values of variables and expressions during sequence execution to make sure that values are being set as expected. One way to add a new value to be watched is to right-click in this window and select Add Watch, as shown below.

Note You can invoke the watch windowonly while the execution is running. Therefore, you should place a breakpoint in a sequence file before it begins running if there are variables or expressions to watch while debugging the file.

TestStandIFundamentalsCourseManual

2-24

ni.com

Lesson 2

The TestStand Environment Exercises

3. This launches the expression browser, which is discussed in a later lesson. Click the + sign next toLocals and notice the following list of local variables.

©

National Instruments Corporation

2-25

TestStand I Fundamentals Course Manual

Lesson 2

The TestStand Environment Exercises

4. Click the variable named PowerFail and click the Insert button. Then click OK to insert this variable into the watch window. The watch window should now resemble the following screen.

5. Repeat steps 2 through 4 for the variables CPUFail, ROMFail, RAMFail, KeyboardValue, and VideoValue. The resulting window will resemble this screen.

TestStandIFundamentalsCourseManual

2-26

ni.com

Lesson 2

The TestStand Environment Exercises

6. Click the Resume button to continue the execution of this sequence. When prompted, enter another arbitrary number for the UUT Serial Number. This time, select the Powerup Test to fail and look at the watch window when you click theOK button to allow the sequence to continue. The value for PowerFail will change to True as shown below. This shows that after you select the test and click theOK button, the value of this variable changes.

7. Click Resume again to complete the execution of this sequence. Continue running this sequence and select a different test (or series of tests) to fail and watch how thetime. different change the selections you make each Thisvariables is a simple use in of response the watchto window, but it demonstrates how you can use this debugging tool to examine variables and expressions during sequence execution.

Optional: Another Way to Add Values to the Watch Window With the breakpoint still in place, run the sequence again by selecting Execute»Single Pass. This time, click on the tab labeledContext. The expression browser is helpful for creating expressions and using functions. However, there is another way to add values to the watch window, which involves clicking on another tab in this window called Context. In the context list is the same sequence context information available in the expression browser. However, from this list you can select an expression to watch and drag it into the watch window. For viewing variable values, dragging and dropping expressions from the context menuBoth is easier than produce using thethe expression browser to generate expressions. methods same results.

©

National Instruments Corporation

2-27

TestStand I Fundamentals Course Manual

Lesson 2

The TestStand Environment Exercises

8. Select the same expressions to watch as in steps 2-5 using this drag-and-drop method from theContext list. Repeat steps 6 and 7 and observe the values for the expressions as you select the different tests to pass and fail. 9. When finished with the exercise, select File»Close to close the execution window, then repeat this selection to close the sequence file window also.

End of Part B End of Exercise 2-2

TestStandIFundamentalsCourseManual

2-28

ni.com

Lesson 2

The TestStand Environment Exercises

Exercise 2-3 Understanding the Sequential Process Model Objective:

To become fa miliar with the TestStand Sequential process model by e xecuting a sequence using execution entry points. Testing a Unit Under Test (UUT) requires more than just executing a set of tests. Typically, the test executive must perform a series of operations before and after it executes the sequence that performs the actual tests. Common operations include identifying the UUT, notifying the operator of pass/fail status, generating a test report, and logging results. These operations define the testing process. This set of operations and their flow of execution is called a process model. Having a process model is essential so that you can write different test sequences without repeating standard testing operations in each sequence.

Part A: Running a Sequence Directly First, examine the execution of a sequence without using a process model. 1. Using the Sequence Editor, open Ex 2-3 Computer Motherboard Test.seq. 2. Select Execute»Break at First Step . The Break at First Step option causes the execution to pause on the first step of the sequence for debugging purposes. 3. Select Execute»Run MainSequence. The execution pauses on the first step of the sequence, as shown.

©

National Instruments Corporation

2-29

TestStand I Fundamentals Course Manual

Lesson 2

The TestStand Environment Exercises

4. Single step through the sequence by clicking the Step Over button in the toolbar or selecting Debug»Step Over. Continue to single step until the sequence completes execution. Notice that only the steps in theMainSequence of the Ex 2-3 Computer Motherboard Test.seq were executed. No additional steps were run and no report was generated.

Part B: Running a Sequence Using the Sequential Process Model A process model defines a set of entry points. Each entry point gives the test station operator different ways to invokea main sequence. For example, the default Sequential process model in TestStand provides two entry points: Test UUTs and Single Pass. The Test UUTs entry point initiates a loop that repeatedly identifies and tests UUTs. The Single Pass entry point tests a single UUT without identifying it. Such entry points are calledexecution entry points. Execution entry points appear in theExecute menu of the Sequence Editor or operator interface. Complete the following steps to runEx 2-3 Computer Motherboard Test.seq using the execution entry points. 1. Uncheck Execute»Break at First Step . Select Execute»Single Pass. Select one of the tests to fail in the Simulator dialog box. Notice that after TestStand executes the steps in the main sequence, the Single Pass entry point generates a test report. Examine the test report. It contains information on the results of each step that TestStand executes. The test report feature is examined in more detail in a later lesson. 2. Close the execution window by selecting File»Close or clicking the X icon on the window title bar. 3. Select Execute»Test UUTs. Before executing the steps in the main sequence, the process model displays a UUT Information dialog box requesting a serial number. Enter any number and click theOK button. Again, select a test to fail in the Test Simulator dialog box and observe the execution window as the sequence is executing. After completing the steps in the main sequence, the process model displays a banner that indicates the sequence result. Click theOK button to close the banner prompt. The process model now displays the UUT Information dialog box again. Type in another serial number and click theOK button to loop on the sequence again. Repeat this procedure for several serial numbers and click theStop button to complete the execution. TestStand generates a test report for all UUTs. Examine the test report and verify that it has indeed recorded the results for each UUT. 4. Close the execution window by selecting File»Close or clicking the X icon on the window title bar.

TestStandIFundamentalsCourseManual

2-30

ni.com

Lesson 2

The TestStand Environment Exercises

Part C: Examining the Sequential Process Model The process models are in the form of a sequence file. This means you can edit the process models just like any other sequence. TestStand ships with three fully functional process models. One of these, the Sequential process model, is examined in this exercise. 1. In the Sequence Editor, select File»Open and navigate to \Components\NI\Models\ TestStandModel\ and open SequentialModel.seq, the default TestStand process model sequence file. 2. Select Sequencescontained from the sequence windowView selector. This shows All all sequences in SequentialModel.seq , as shown on the next page. SequentialModel.seqhas several types of sequences, including Execution Entry Points, Configuration Entry Points, and Callback Sequences. You will examine the execution entry points for the Sequential process model in this exercise. Notice that the first two sequences are Test UUTs and Single Pass, denoted by a reddish-orange colored icon. These are the execution entry points you have used to execute the example sequences in this and previous exercises. Having multiple execution entry points gives the operator choices for different ways to invoke a sequence execution. Each execution entry point appears as a menu entry in theExecute menu.

3. Examine the Single Pass sequence by selecting it from the sequence window View selector ring. Notice that after some preliminary configuration steps, this sequence calls a subsequence called MainSequence. This is where the process model executes the test sequence you create in the Sequence Editor. After the MainSequence is called, the process model calls a subsequence called Test Report Callback. The Test Report Callback sequence generates the Test Report for the sequence.

©

National Instruments Corporation

2-31

TestStand I Fundamentals Course Manual

Lesson 2

The TestStand Environment Exercises

4. Set a breakpoint on the first step of the Single Pass sequence by clicking to the left of the step or right-clicking on the step and selectingToggle Breakpoint from the pop-up menu. A small red stop button to the left of the step indicates a breakpoint. 5. Return to the Ex 2-3 Computer Motherboard Test.seq sequence window by clicking on it or selecting it from theWindow menu. Select Execute»Single Pass. The execution window appears and immediately pauses on the Check for Proper Use step of the Single Pass sequence. Click the Step Over button in the toolbar or selectDebug»Step Over until the sequence is paused with the execution pointer on the MainSequence Callback step. Click theStep Into button or select Debug»Step Into to step into the main sequence. Notice that the execution has now proceeded to the steps of theEx 2-3 Computer Motherboard Test.seq sequence. Step over several of the steps and then click the Step Out button or select Debug»Step Out to return to the process model sequence. Notice that the sequence execution has now returned to the steps of the Single Pass sequence. Resume normal execution by clicking on theResume button in the toolbar or selecting Debug»Resume. You may want to remove the breakpoint before continuing with the execution but this is not necessary. 6. Close the execution window and all sequence windows.

End of Exercise 2-3

TestStandIFundamentalsCourseManual

2-32

ni.com

Lesson 2

The TestStand Environment Exercises

Notes

©

National Instruments Corporation

2-33

TestStand I Fundamentals Course Manual

Lesson 2

The TestStand Environment Exercises

Notes

TestStandIFundamentalsCourseManual

2-34

ni.com

Lesson 3 Creating Sequences

Lesson 3: CreatingSequences

In this lesson, you will learn how to: • Add steps to a TestStand sequence • Specify a test module for a step • Configure step properties

Introduction This lesson describes the steps involved in creating a TestStand sequence. You will learn how to create a new TestStand sequence, specify the test modules for each step, and configure the step properties.

©

National Instruments Corporation

3-1

TestStandI Fundamentals Course Manual

Lesson 3

Creating Sequences

How to Create Test Sequences • The Sequence Editor allows you to build test sequences • Build sequences by adding steps for each test or action you want to execute • There are four actions involved in adding each step to the sequence: 1) Specify the adapter 2) Select the step type 3) Specify the test module 4) Configure the step properties

How to Create Test Sequences The TestStand Sequence Editor is the development environment for building test sequences. The Sequence Editor is an intuitive Windows Explorer style interface where steps can be copied, moved, pasted, or created to build a sequence. There are four steps involved in creating each step: 1. Specify the adapter corresponding to the programming environment in which the test module is (or will be) written. 2. Select the step type. 3. Specify the test module the step will call. 4. Configure the various step properties. The following sections examine each step in detail.

TestStandIFundamentalsCourseManual

3-2

ni.com

Lesson 3

Creating Sequences

Adding a Step to a Sequence: Step 1 - Specify the Adapter

Step 1 : Specify the Adapter Before inserting a new step, you must select the appropriate adapter from the Adapter Selection Ring, as shown above. Adapters are the interfaces between TestStand and the external application development environment (ADE) in which you can write test modules. Each external language or type of compiled file supported by TestStand has its own adapter. Currently, T estStand has seven adapters: • DLL Flexible Prototype Adapter —Calls Dynamic Linked Libraries (DLLs) •

C/CVI Standard Prototype Adapter —Calls LabWindows/CVI source and object files



LabVIEW Standard Prototype Adapter —Calls LabVIEW VIs

• Automation Adapter —Calls ActiveX Automation servers • HTBasic Adapter —Calls HTBasic subroutines • Sequence Adapter —Calls subsequences • Adapter —Creates a step that does not call a test module

©

National Instruments Corporation

3-3

TestStandI Fundamentals Course Manual

Lesson 3

Creating Sequences

Adding a Step to a Sequence: Step 2 - Select the Step Type Built-in step types: • Tests - Pass/Fail Test - Numeric Limit Test - MultiNumeric Limit Test - String Value Test

• Action • Sequence Call • • • • • • • •

StatementPopup Message Call Executable Synchronization Property Loader Database Goto Label IVI

Step 2: Select the Step Type The second action in creating a step is to select the step type and insert it in the sequence window by right-clicking and selecting theInsert Step option from the pop-up menu. All defined step types, both built-in and user-defined, appear in the pop-up menu. Select the correct step type for the test module this step calls. TestStand has the following step types: Tests are steps for testing UUTs and making pass/fail determinations. There are four built-in test types in TestStand. Each test type has different associated data and properties. • Pass/Fail Test: The test module passes a Boolean value T ( rue or False) to determine if the step passes or fails. • Numeric Limit Test: The test module passes a numeric value, which is compared to high and low limits in TestStand. •

MultiNumeric Limit Test: The test module passes multiple numeric values, which are compared to sets of high and low limits.



String Value Test: The test module passes a string, which is compared to an expected string in TestStand.

Actions are steps that perform operations (for example, initializing an instrument). They do not pass result data back to TestStand, but instead either execute their operation successfully or generate a run-time error.

TestStandIFundamentalsCourseManual

3-4

ni.com

Lesson 3

Creating Sequences

Step Types Numeric limit test

Property Loader

• Measured value • Limits (H, L)

Database:

String limit test • Returned String

• Open/Close Database • Open/Close SQL Statement • Data Operations

• ComparisonString

Synchronization:

Pass/fail test • Result (T/F)

• Lock • Semaphore • Rendezvous • Queue

Action Sequence call Label

Notification •• Wait • Thread Priority • Batch Synchronization • Batch Specification

Statement

IVI:

Goto

• Dmm • Scope • Fgen • Tools

Message popup

User-defined step type

Step Types • Sequence Call —Calls another sequence (which is considered a subsequence of the calling sequence). •

Statement—Evaluates an expression or sets values of TestStand variables.

• Message Popup —Displays a run-time message in a pop-up dialog box. • Call Executable —Allows .exe files to be executed from TestStand. • Property Loader —Allows for dynamic limit/property loading from a file or database. The property loader step is discussed in more detail in Lesson 10. •

Goto—Branches to another step in the sequence.



Label—For documentation purposes in the sequence and useful as a target for a Goto step.



Database—Enables you to manipulate data in tables.



Synchronization—Enables you to synchronize multiple threads of sequence execution from within a sequence.



IVI—Enables you to easily configure and acquire data from IVI class compliant instruments.

TestStand allows you to copy step types and modify their properties to suit your needs. Modifying and creating custom step types is discussed in the TestStand II course.

©

National Instruments Corporation

3-5

TestStandI Fundamentals Course Manual

Lesson 3

Creating Sequences

Adding a Step to a Sequence: Step 3 - Specify the Test Module • Each step may have an associated test module • Multiple steps can access the same module

Test Modules Sequence Step 1

LabVIEW VI

Step 2 CVI code

Step 3

Step 3: Specify the Test Module The third step in adding a step to a sequence is to specify the test module that the step calls. Although some step types, such as Statement or Message Popup, do not require you to specify a test module, many others, such as Numeric Limit Test, do. A test module can be: •

A LabVIEW VI

• •

A LabWindows/CVI source file An object file



A static library



An HTBasic subroutine



A C DLL



An automation server



A TestStand sequence

Although each step can call only one module, multiple steps can call the same module. A step is a component of a TestStand sequence. Atest module is a software module written in an external application development environment (ADE) that performs a particular task. To specify a test module for a step, right-click on the step and selectSpecify Module from the pop-up menu. In the dialog box that appears, enter information such as where the test module is located or what type of data to pass to it. Each adapter has a separate Specify Module dialog box. The Edit LabVIEW VI Call dialog box is shown on the next slide.

TestStandIFundamentalsCourseManual

3-6

ni.com

Lesson 3

Creating Sequences

Specifying the Module • Selecting Specify Module for a step brings up an Edit LabVIEW VI Call dialog box • TestStand has different dialog boxes for different adapters

Edit LabVIEW VI Call Dialog Box

Specifying the Module Each adapter has its own Specify Module dialog box, because different information is needed to create the link depending on the programming language used to write the test module. For example, a LabVIEW step needs to know the location of the VI it calls, while a DLL test needs not only the DLL location, but also the specific function to call within the DLL, and the parametric data to pass to the function.

©

National Instruments Corporation

3-7

TestStandI Fundamentals Course Manual

Lesson 3

Creating Sequences

Specifying the Module: Search Directories One of these dialog boxes will appear if the module is not located within the configured search directories The module is not within a subdirectory of the configured search directories

The third option shows a path that is relative to one of the configured search directories

Specifying the Module: Search Directories When you select a module and it is not located in one of the configured search directories, you are prompted to resolve the path to the module. To edit your search directory settings, select Configure»Search Directories. Notice that when you add a directory to the list of search directories you have the option of including its subdirectories in the search. If the path to the module is not in a subdirectory of a configured search directory then you are given two options: add the directory of the module to the list of search directories or reference the module in an absolute path. If the module is located in a subdirectory of a configured search directory but the option Search Subdirectories was not enabled for that directory, you are given the additional option to reference the module using a path relative to the search directory.

TestStandIFundamentalsCourseManual

3-8

ni.com

Lesson 3

Creating Sequences

Adding a Step to a Sequence: Step 4 - Configure the Step Properties

• Each step in the sequence has a set of properties • There are six categories of properties associated with each step: – General (includes preconditions) – Run Options – Post Actions – Loop Options – Synchronization – Expressions

Step 4: Configure Step Properties In TestStand, each step has a set of associated properties. The final action in creating a sequence step is to configure these properties so that the step executes correctly in the sequence. The main categories of properties that apply to all step types are preconditions, run options, post actions, loop options, synchronization, and expressions. Access a step’s properties by right-clicking on the step and selectingProperties, which launches the Properties dialog box. The next section introduces each Properties dialog box, which is described in greater detail in Exercise 3-1. The Properties dialog box has the following six tabs: •

General



Run Options

• Post Actions • Loop Options •

Synchronization



Expressions

©

National Instruments Corporation

3-9

TestStandI Fundamentals Course Manual

Lesson 3

Creating Sequences

Step Properties: General Tab

Step Properties: General Tab The Properties dialog box opens with a view ofGeneral tab, which shows the adapter type, the step type, a description of the step, and user-defined comments. The General tab has command buttons that vary according to the step type. For example, a Numeric Limit test has an Edit Limits button to modify the step limits, while a String Value test has anEdit Expected String button to specify the desired string for comparison with the step results.

Use the Specify Module button to launch a dialog box for specifying a code module (or sequence) for the step and values to pass as arguments to the code module. (This dialog box is the same one you see when you right-click on a step and selectSpecify Module.) Each adapter has a unique dialog box to obtain the information the adapter needs. The Preconditions button is addressed in the next slide. The Advanced button is discussed in the TestStand II Course.

TestStandIFundamentalsCourseManual

3-10

ni.com

Lesson 3

Creating Sequences

Step Properties: Preconditions • The precondition property specifies the conditions that must be true for a step to execute • You can set sequence execution logic based on the status of other steps, the value of TestStand variables, and the value of user-defined expressions

Step Properties: Preconditions For most applications, you will want to execute many of the steps in a sequence only under certain conditions. In TestStand, you can set preconditions based on the status of other steps, the value of TestStand variables, or user-defined expressions consisting of one or more of these values. TestStand also can execute different levels of precondition expressions that range from simple to complex, enabling you to create highly flexible sequences. The main window, Preconditions for, displays the conditions that must be true for the current step to execute.You can organize several precondition statements by usingAnyOf or AllOf (Boolean OR and AND statements, respectively). Use the Edit/View Expression section to create your own expressions or to view expressions entered from the main window. Use the Insert Step Status section to build precondition expressions for display in the main window, such as Insert Step Pass (the current step does not execute unless a specified step passes), Insert Step Fail (the current step does not execute unless a specified step fails), Insert Step Error (the current step does not execute unless an error has occurred), and Insert Step Executed (the current step does not execute unless a particular step has run, regardless of whether it passed or failed).

©

National Instruments Corporation

3-11

TestStand I Fundamentals Course Manual

Lesson 3

Creating Sequences

Step Properties: Run Options Tab You can set the following Run Options: • Load/Unload dynamic/static test module • Precondition evaluation • TestStand window activation • Record Results • Step Failure Causes Sequen ce Failur e • Debugging features: – Run mode: normal, skip, force pass, force fail – Breakpoint – Ignore Run-time Errors

Step Properties: Run Options Tab The Run Options tab allows you to configure how TestStand executes the test module called by the step including Load Option, Unload Option, Run Mode , Precondition Evaluation in Interactive Mode, and TestStand Window Activation. The Load Option ring control contains the following items: •

Pre Load when execution begins —Loads the test module into memory when the sequence file is executed (fast executing time, slower startup on execution of sequence file).



PreLoad when opening sequence file —Loads the test module when the sequence file is first opened (fast execution, fast startup when executing sequence file, slower when first loading sequence).

• Load dynamically —Loads the test module right before it is executed (slower execution time, least memory intensive). •

Unload when precondition fails —Unloads the test module if it will not be executed due to a failing precondition (slower execution, less memory intensive).



Unload after step executes —Unloads the test module after completing execution of step (slower execution, least memory intensive).



Unload after sequence executes —Unloads the test module from memory on completion of sequence exeuction (faster execution, slower after completion of sequence).



Unload when sequence file is closed —Unloads the test module closing sequence file (fast execution and completion of sequence, slower when closingwhen sequence). Note Execution time refers hereto the time for the entire test sequence(s) tocomplete.

TestStandIFundamentalsCourseManual

3-12

ni.com

Lesson 3

Creating Sequences

Step Properties: Run Options Tab (Continued)

Step Properties: Run Options Tab (Continued) The Run Mode ring control contains the following items: •

Normal—Runs the step when preconditions are met.



Skip—Does not execute the module but sets the status toSKIPPED.

• Force Pass —Does not execute the module, but sets the step status toPASSED. • Force Fail —Does not execute the module, but sets the step status toFAILED. The Precondition Evaluation in Interactive Mode ring control contains the following items: •

Use Station Option —Uses current station option.Configure»Station Options determines whether to evaluate the precondition in interactive mode.

• Evaluate Precondition —Always evaluates the precondition for the step when running in interactive mode. •

©

DoNot Evaluate Precondition —Does not evaluate the precondition for the step when running in interactive mode.

National Instruments Corporation

3-13

TestStand I Fundamentals Course Manual

Lesson 3

Creating Sequences

Step Properties: Run Options Tab (Continued)

Step Properties: Run Options Tab (Continued) The TestStand Window Activation ring control contains the following items: •

None—Does not specifically activate or deactivate the TestStand window. Activation of windows will depend on prior window state and window activation of step.



Activate When Step Completes —Activates the TestStand window upon step completion.



Does not depend on state of window prior to step executing. If Initially Active, Re-Activate When Step Completes —Specifies the TestStand window should be activated upon completion of step if the TestStand window was previously the active window.

Other Checkboxes on the Options tab control the following items: • Record Results —Specifies whether results are logged in a test report. •

Breakpoint—Sets a breakpoint on the step. Execution of the sequence pauses at the breakpoint for debugging purposes. You also can set breakpoints using theToggle Breakpoint command in the pop-up menu.



St ep Failure Causes Sequence Failure —Specifies whether TestStand sets the sequence status to FAILED when the step status isFAILED.



Ignore Run-Time Errors —Allows any run-time errors generated by this step to be ignored for debugging purposes.

TestStandIFundamentalsCourseManual

3-14

ni.com

Lesson 3

Creating Sequences

Step Properties: Post Actions Tab You can specify various actions to occur based on the result of a test Available Post Actions: – Go to a certain step – Call a callback – Break – Terminate or execute a user-defined expression

Step Properties: Post Actions Tab The Post Actions tab allows you to specify actions to be performed based on whether a step passes or fails. In addition, you can create your own custom conditions. The Post Actions tab contains the following controls: •

Goto the next step —Executes the next step in the sequence.



Goto a destination —Branches to the step in the sequence specified in theDestination pulldown menu (appears if the option is chosen).

• Terminate execution —Terminates the sequence execution. • Call Sequence —Calls a particular sequence specified in theSequence pulldown menu. •

©

Break—Suspends execution at this step. You can then use the debugging tools available to step through the sequence, or use theResume option in the Debug menu to continue the sequence execution.

National Instruments Corporation

3-15

TestStand I Fundamentals Course Manual

Lesson 3

Creating Sequences

Step Properties: Loop Options Tab Allows looping on a step based or a fixed number of iterations, a pass/fail count, or a user-defined condition

Step Properties: Loop Options Tab With this step property, you can configure TestStand for several types of step looping. You can configure a step to loop for a fixed number of iterations or until a given number of pass or fail counts is achieved. In addition, you can use TestStand expressions (discussed in Lesson 4) to define a custom looping condition. The Loop Options tab contains the following controls: • Loop Type —Configures the type of looping required. The available options are: –

None—TestStand does not loop on the step. This is the default value.

– Fixed number of loops —TestStand loops on the step a specific number of times and determines the final pass or fail status of the step based on the percentage of loop iterations in which the step status isPASSED. – Pass/Fail count —TestStand loops on the step until the step passes or fails a specific number of times or until a maximum number of loop iterations complete. TestStand determines the final status of the step based on whether the specific number of passes or failures occur or the number of loop iterations reaches the maximum.

TestStandIFundamentalsCourseManual

3-16

ni.com

Lesson 3

Creating Sequences

Step Properties: Loop Options Tab (Continued)

Step Properties: Loop Options Tab (Continued) •

Custom—Allows you to customize the looping behavior for the step. You specify a Loop Initialization expression, a Loop Increment expression, a Loop While expression, and a final Loop Status expression. TestStand uses the loop expressions in the following order:

Loop_Initialization_Expression; while (Loop_While_Expression == True) { Execute_Step; Loop_Increment_Expression; } Loop_Status_Expression; •

©

Record Result of Each Iteration —Adds the step result to the sequence results list after each loop iteration. TestStand also adds the final result that it computes for the step loop as a whole if the Record Results property for the step is enabled.

National Instruments Corporation

3-17

TestStand I Fundamentals Course Manual

Lesson 3

Creating Sequences

Step Properties: Synchronization Tab Allows the test developer to synchronize the step for batch testing and control the thread accessibility of the step.

Step Properties: Synchronization Tab In addition to the synchronization step types, you also can specify common synchronization properties on any step. The Synchronization tab contains the following controls: •

Use Mutex to Allow Only One Thread to E xecute the Step —Specifies that a step acquires a mutex before it runs and releases it after it completes. A mutex is a synchronization object that guarantees exclusive access to a resource.



BatchSynchronization —Specifies that a step enters a batch synchronization section before it runs and exits the section after it completes. The Batch Synchronization ring control contains the following items:

– Use Sequence File Setting —Uses the setting denoted in the Sequence File Properties. – Use Model Setting —Uses the synchronization specified in the process model that is used. –

Don’t Synchronize—Can be used to avoid having the step synchronized with batch.



Serial—Allows only one thread from the batch to access the step at a time.



Parallel—Allows all batch threads to access the step simultaneously.

– One Thread Only —Allows only one thread in the batch to access the step. All other threads in the batch will be denied access to the step and will skip the step.

TestStandIFundamentalsCourseManual

3-18

ni.com

Lesson 3

Creating Sequences

Step Properties: Expressions Tab Allows the test developer to define arbitrarily complex pre and post expressions

Step Properties: Expressions Tab The Expressions property tab defines expressions that TestStand evaluates before (Pre Expression) or after (Post Expression) a test module executes. For example, you can use the Pre Expression to initialize certain variables required for a particular step, and this can be followed by the Post Expression, which resets the variables to other values in preparation for other steps. TestStand evaluates the Status Expression to determine whether a step passes or fails. For example, for a numeric limit step, the default status expression compares the result returned from the test module with high and low limits to determine whether the step ’s status is “Passed” or “Failed” using the comparison criteria you selected.

©

National Instruments Corporation

3-19

TestStand I Fundamentals Course Manual

Lesson 3

Creating Sequences

Exercise 3-1 Objective: To create steps in the Sequence Editor Approximate time to complete: 20 minutes

TestStandIFundamentalsCourseManual

3-20

ni.com

Lesson 3

Creating Sequences

Exercise 3-2 Objective: To create and edit a new sequence file using step looping Approximate time to complete: 20 minutes

©

National Instruments Corporation

3-21

TestStand I Fundamentals Course Manual

Lesson 3

Creating Sequences

Useful Step Type Features The step types below have features that could be useful in your test sequences

• Sequence Call Step Types – Execute sequence in a new thread – Execute sequence in a new execution – Execute sequence on a remote machine • IVI Step Types – Provide communication with IVI class drivers – Permit simulation mode for prototyping test sequences

Useful Step Type Features TestStand contains many useful step types. For example, the Sequence Call step type enables you to make various types of sequence calls. The IVI step types allow direct communication with IVI class drivers and give you the ability to run sequences in simulation modes.

TestStandIFundamentalsCourseManual

3-22

ni.com

Lesson 3

Creating Sequences

Sequence Call Options •

Multithreading and Remote Execution Options

Sequence Call Options The Sequence Call step type makes it simple to execute parallel and remote sequences in TestStand. Use the Multithreading and Remote Execution section of the sequence call specify module dialog box to execute a subsequence in a new thread within the same execution or in a new local or remote execution. The Multithreading and Remote Execution section contains the following options: • None—Executes the subsequence within the same thread and execution as the calling sequence. •

Run Sequence in New Thread —Executes the subsequence in a new thread within the same execution. This allows the subsequence to run asynchronous to the calling sequence.



Run Sequence in a New Execution —Allows TestStand to launch the subsequence in a new execution that runs in parallel to the calling sequence execution. The subsequence can also be launched in a new execution of an execution entry point, i.e. Test UUTs or Single Pass, within the specifed process model.



Run Sequence on a Remote Computer —Executes the specifed subsequence on a remote computer located on the network. The results of the subsequ ence will be returned to the calling sequence located on the client computer.

©

National Instruments Corporation

3-23

TestStand I Fundamentals Course Manual

Lesson 3

Creating Sequences

IVI Step Type Demo • Using IVI Scope step type

IVI Step Type Demo IVI step types offer a configuration-based approach to instrument control. The following demo will illustrate acquiring a waveform from a scope using the IVI step types. It then displays the waveform and estimates the frequency using LabVIEW. Follow the steps below to run the example. Ensure that you have a logical name“SampleScope” installed on your computer. For more information about logical names and IVI please refer to the Appendix A of this course. 1. Open C:\Exercises\TestStand I\IVIExample.seq. 2. Ensure that your report options are set to “Insert Graph” and report type are set to HTML. 3. Select Execute»Single Pass to execute the sequence. 4. You will see a dialog which displays the waveform as shown above. 5. Close the dialog andyou will see a report which displays thewaveform and also gives you the frequency estimate of the the wave. You will need the complete IVI driver toolset installed on your computer to change the frequency.

TestStandIFundamentalsCourseManual

3-24

ni.com

Lesson 3

Creating Sequences

Exercise 3-3 Objective: To create a sequence using different step types Approximate time to complete: 20 minutes

©

National Instruments Corporation

3-25

TestStand I Fundamentals Course Manual

Lesson 3

Creating Sequences

Optional Exercise 3-4 Objective: To show how TestStand runs multiple sequence s in parallel Approximate time to complete: 10 minutes

TestStandIFundamentalsCourseManual

3-26

ni.com

Lesson 3

Creating Sequences

Lesson 3 Summary: CreatingSequences

• Use the Sequence Editor to edit and build sequences • There are four actions to add a step to a sequence:

1) Specify the adapter 2) Select the step type 3) Specify the test module 4) Configure the step properties

In this lesson, you learned about the basic building blocks for building a sequence: specifying an adapter, selecting a step type, specifying the test module, and configuring the step properties. Your decision for choosing an adapter is based on the programming environment in which you develop your tests. Notice that TestStand provides you with the flexibility of using different adapters for each step. Through this adapter interface, you can quickly port existing test code to TestStand. TestStand provides you with a variety of built-in steps. Remember that there are three step groups in each sequence: setup, main, and cleanup. Specifying the test module allows you to select an existing test module or, as you will later learn, you can build a new module starting from a code template. Finally, after you add a step to a sequence, you configure the step ’s properties. By configuring the step properties, you can specify a wide range of behaviors, such as skipping the step (Run Options), executing the step only under certain conditions (Preconditions), looping on the same step a fixed number of times or until a condition occurs (Loop Options), performing an action after the step completes (Post Action), or initializing or computing a value before or after the step runs (Expressions).

©

National Instruments Corporation

3-27

TestStand I Fundamentals Course Manual

Lesson 3

Creating Sequences Exercises

Exercise 3-1 Creating Steps in the Sequence Editor Objective:

To add new ste ps to a main sequence that will set off an alarm if the ROM Test fails. Earlier lessons defined the Sequence Editor as the GUI interface to TestStand for creating and modifying sequence files. Now that this functionality has been defined, it is important to learn how to add steps to a sequence file to create a testing sequence for a UUT. When a test fails, there should be a way to notify the operator of the failure. Seeing this information in the report may be insufficient, and some other notification method might be appropriate. In this exercise, the sequence file will set off an audible alarm whenever the ROM test fails for any UUT. 1. In the Sequence Editor, select File»Open and select C:Exercises\TestStand I\Ex 3-1 Add Beep Step.seq. 2. Create two steps that set off an alarm if the ROM Test fails. Before inserting a step that calls a code module, you must specify the module adapter that the step uses. Select the adapter in the Adapter Selector Ring to be the DLL Flexible Prototype Adapter. The step uses the DLL Flexible Prototype Adapter to call a function in a DLL.

3. Right-click on ROM Test and select Insert Step»Action. An Action step type calls code modules that perform actions necessary for testing, such as initializing an instrument. By default, action steps do not pass or fail, so they are not used for actual product tests. You will use steps for testing later in this course. Name this stepAlarmStart. You can always rename a step later by right-clicking on it and selecting rename from the context menu.

TestStandIFundamentalsCourseManual

3-28

ni.com

Lesson 3 Creating Sequences Exercises

4. Right-click on the AlarmStart step and choose Properties, as shown below, or double-click on it to open the Step Properties dialog box.

©

National Instruments Corporation

3-29

TestStand I Fundamentals Course Manual

Lesson 3

Creating Sequences Exercises

5. The Step Properties dialog box is shown below.

The Step Properties dialog box contains several options for configuring the step, including:

TestStandIFundamentalsCourseManual



When to load the step



What conditions will cause the step to execute



What information TestStand examines to determine whether a test passes or fails



Whether TestStand executes the step in a loop



Ways to sychronize the step with other executions

3-30

ni.com

Lesson 3 Creating Sequences Exercises

6. Click on the Specify Module button. This brings up the Edit DLL Call dialog box. Click theBrowse button and select the fileDllfuncs.dll from the CVI Project Files directory, for the DLL Pathname. Click OK to select this file.

A dialog box may appear with options for the file path. Choose the option to use a relative path for the file you selected , so that the path to the code source is stored relative to the sequence file. ClickOK to return to the Edit DLL Call dialog box. If the module is not within a subdirectory of the configured search directories, you are prompted to resolve the path by adding the file you selected to the search directories, use an absolute path to the file, or use a relative path for the file.

Select the StartBeep function. All functions exported from the DLL are listed under theStopBeep Functionfunctions Name Control. For(the thisprocess exercise, the a StartBeep and are used foronly adding step for the StopBeep function is described later).

©

National Instruments Corporation

3-31

TestStand I Fundamentals Course Manual

Lesson 3

Creating Sequences Exercises

Select the Edit Prototype option and set the values as shown below. The tone parameter sets the beep frequency, which is 1000 Hz in this case.

Note You must build a DLL with a type library for thefunction prototypes to appear in the Function Prototype tab at the bottom of the dialog box and for all parameters to appear in the Parameter menu ring. To create a type library in LabWindows/CVI, you must create a Function Panel file first.

Do not run the sequence until all the steps in this exercise have been completed. Click OK to close the Edit DLL Call dialog box. 7. Click the Preconditions button to open the Preconditions Editor. A precondition specifies the conditions that must be true for TestStand to execute a step during the normal flow of execution in a sequence. For example, you might want to run a step only if a previous step passes. In this case, this step should execute only if the ROM test fails.

TestStandIFundamentalsCourseManual

3-32

ni.com

Lesson 3 Creating Sequences Exercises

In the Preconditions - MainSequence dialog box shown below, you enter the conditions that control when this particular test executes.

For this exercise, click the ROM Test in the Insert Step Status section. Click the Insert Step Fail button. This inserts the condition that the AlarmStart step executes only if the ROM test fails. Notice that other options for conditions include running the current step only if another test passed, caused an error, or has executed. It is also possible to create expressions that can be evaluated and used as conditions for executing a step. Inserting more than one precondition and the use of TestStand expressions are discussed later in this course. After entering the preconditions, clickOK to finish.

©

National Instruments Corporation

3-33

TestStand I Fundamentals Course Manual

Lesson 3

Creating Sequences Exercises

8. After setting the step’s preconditions, configure and examine other step properties. If the AlarmStart Action Properties dialog box is closed, open it by double-clicking on the Alarm Start step in the sequence window. Click the Run Options tab to examine the run options and ensure thatRun Mode is Normal, with the step results recorded in the report. Examine the other Load, Unload, Run, Precondition Evaluation, and Window Activation options. Ensure that the settings are as shown below before continuing.

Although some options are self-explanatory, it is helpful to understand the various Run Mode options and how to use them to configure TestStand step execution. The options are useful in debugging, to test the various states of each step, and for understanding how the preconditions relate to each other. • Force Pass —TestStand does not execute the step and does not evaluate its preconditions. Instead, TestStand sets the status of the step to PASSED automatically. • Force Failits—TestStand does not execute the step evaluate preconditions. Instead, TestStand setsand thedoes statusnot of the step to FAILED automatically.

TestStandIFundamentalsCourseManual

3-34

ni.com

Lesson 3 Creating Sequences Exercises



Skip—TestStand does not execute the step and does not evaluate its preconditions. Instead, TestStand sets the status of the step to SKIPPED automatically.



Normal—TestStand executes the step normally. This is the default value.

9. Click the Post Actions tab, as shown below.

The Post Actions tab specifies an action that occurs after a step executes. In StartBeep the case of a step that is specified as an Action step such as the step, the only post action option for the step is to use the Custom Condition option since an Action step does not“Pass” or “Fail”. For other types of test steps the post action can be conditional on the pass/fail status of the step or any custom condition expression. For example, you may want to jump to a particular step in the sequence if this step fails. By default, the On Pass and On Fail actions are “goto next step.” Review the other available options, ensuring that the final options are configured as shown above.

©

National Instruments Corporation

3-35

TestStand I Fundamentals Course Manual

Lesson 3

Creating Sequences Exercises

10. Click the Loop Options tab.

You can use the Loop Options tab to configure an individual step to run repeatedly in a loop when it executes. In this case, configure the step to loop 25 times and record the results of each iteration. Ensure that the settings are the same as shown above. Notice that as changes are made in this window, TestStand automatically builds an expression in the Loop While Expression and Loop Status Expression controls. An expression is a formula that TestStand evaluates to obtain a new value from the values of multiple variables or properties. Expressions are discussed further in the next lesson. The step runs 25 times, and the step returns aFAILED status if any iteration fails. This is determined by the loop result, which is Fail if less than 100 percent of the iterations pass. Click OK to close the AlarmStart Properties dialog box. The sequence file should now be the active window.

TestStandIFundamentalsCourseManual

3-36

ni.com

Lesson 3 Creating Sequences Exercises

11. Create another action step by right-clicking on theAlarmStart step and selecting Insert Step»Action. Name the step AlarmStop. Right-click on the AlarmStop step and select Specify Module, repeating the steps given in Step 6 above, but selecting the function as shown below. This step stops the PC speaker from beeping.

12. Save Ex 3-1 Add Beep Step.seq. Execute the sequence by selecting Execute»Test UUTs. You should hear the PC speaker beep if you make the ROM test fail. (Note that some PCs may not have a speaker. If the sound is not enabled on the machine, and this course is being taught at a National Instruments training facility, ask the instructor for assistance.)

End of Exercise 3-1

©

National Instruments Corporation

3-37

TestStand I Fundamentals Course Manual

Lesson 3

Creating Sequences Exercises

Exercise 3-2 Configuring Loop Options Objective:

To build a sequence that loops on a step depending on the step results. One of the many sequence execution options displayed in the last exercise was Loop Options. In TestStand, there are many different ways to chooseto loop on a step, and there are many different results you can set at the end of the loop. This exercise examines some of these loop types and results. 1. In the Sequence Editor, select File»New Sequence File . Then select File»Save As to save the empty sequence file as C:\Exercises\TestStand I\Ex 3-2 Loop Step On

Fail.seq. 2. Set the Adapter Selector Ring to the LabVIEW Standard Prototype Adapter.

3. In this step, random numbers returned from the test module are tested. The random numbers lie between 0 and 1. The test results are limit checked, and if the value is less than 0.5, indicating a failure, the step repeats.

TestStandIFundamentalsCourseManual

3-38

ni.com

Lesson 3 Creating Sequences Exercises

Right-click in the sequence window and selectInsert Step»Tests» Numeric Limit Test. Name it RandomNumber. Right-click on the step and select Specify Module. Click on the Browse button and select the VI, C:\Exercises\TestStand I\VIs\Random number.vi.

The other options in the Specify Module dialog box are discussed later in the course. ClickOK when finished. 4. Right-click on the step again and select Edit Limits. Set the limits as shown below. This indicates a Failure if the returned measurement (random number) is less than 0.5 and a Pass if it is greater than or equal to 0.5.

©

National Instruments Corporation

3-39

TestStand I Fundamentals Course Manual

Lesson 3

Creating Sequences Exercises

5. Set the loop options so that the step loops five times or until the test passes. Right-click on the step again, and this time selectProperties. Click the Loop Options tab and set the loop options as shown below.

6. The sequence is now set up to run as desired. Run the sequence several times and examine the report each time. The report should look similar to the report shown on the next page. Note The report is arranged to display a summary about the execution before displaying information about each loop iteration. If the RandomNumber step had been the third step, it would be the third item listed in the report and would be followed by the results of the fourth step. For example, in the test report shown on the next page, the RandomNumber step eventually passed. Notice that the first“RandomNumber” in the report contains more information than the others, including the number of passes, failures, and the total number of iterations of the step. Because the RandomNumber step had looping options set, the next item in the report is the result of each iteration of the loop. After the results of each iteration of the loop are reported, the report lists the results of the fourth step.

TestStandIFundamentalsCourseManual

3-40

ni.com

Lesson 3 Creating Sequences Exercises

7. Save the finished sequence file before moving on to the next exercise.

End of Exercise 3-2

©

National Instruments Corporation

3-41

TestStand I Fundamentals Course Manual

Lesson 3

Creating Sequences Exercises

Exercise 3-3 Creating a Sequence It is also useful to combine steps of different types in a sequence. This exercise builds on skills you have learned in previous lessons. In the first part, you create a sequence to be used as a subsequence. The second part shows how to use steps created using different adapter types together in the same sequence.

Part A: Creating the CPU Subsequence 1. In the Sequence Editor, select File»Open and open

C:\Exercises\TestStand I\Ex 3-3 Creating a Sequence File.seq. 2. Right-click on the Powerup Test step. Select Insert Step»Sequence Call. Rename the step CPU Test. This step calls a specified sequence file as a subsequence during sequence execution. For this to work, there must be an existing sequence for this step to call. Therefore, the next step is to create the sequence CPU Test, which is called as the subsequence. Note The step and sequence to becalled do not need to have the same name. However, for this exercise it is easier to remember the sequence name if the step name is the same.

TestStandIFundamentalsCourseManual

3-42

ni.com

Lesson 3 Creating Sequences Exercises

3. Click in the View Ring and select the All Sequence view as shown.

4. Notice that there is currently not a sequence named CPU Test in this sequence file. You can create this sequence in this sequence file by right-clicking in the window and selectingInsert Sequence as shown.

5. Rename the sequence CPU Test. 6. Click the View Ring and select the CPU Test sequence. This opens the CPU Test sequence, which does not currently contain any steps. This is the sequence you will create.

©

National Instruments Corporation

3-43

TestStand I Fundamentals Course Manual

Lesson 3

Creating Sequences Exercises

7. Be sure the LabVIEW Standard Prototype Adapter is selected in the Adapter Selector Ring. Click the Setup tab to change to the Setup step group window. The setup for this subsequence requires one function. Right-click in the window and selectInsert Step»Action. Rename the step to Pick Test to Fail.

8. Right-click on this action step and choose Specify Module.

TestStandIFundamentalsCourseManual

3-44

ni.com

Lesson 3 Creating Sequences Exercises

9. Click the Browse button and select the VI, C:\Exercises\TestStand I\VIs\CPU PreTest.vi. Click OK to select this VI as the code module.

10. A dialog box may appear with options for the file path. Choose the option to use a relative path for the file you selected , so that the path to the code source is stored relative to the sequence file. ClickOK to return to the Edit LabVIEW VI Call dialog box. 11. Make sure the Sequence Context ActiveX Pointer checkbox is enabled. When completed, the dialog box will appear as shown below. Click OK to return to the sequence file window.

©

National Instruments Corporation

3-45

TestStand I Fundamentals Course Manual

Lesson 3

Creating Sequences Exercises

12. Click the Main tab to switch from the Setup step group window to the Main step group window. Right-click in the sequence display window and select Insert Step»Tests»Pass/Fail Test. Rename the step Register Test.

13. Repeat step 12 three more times to create theInstruction Set Test, Cache Test, and FPU Test steps, as shown below.

TestStandIFundamentalsCourseManual

3-46

ni.com

Lesson 3 Creating Sequences Exercises

14. Right-click on theRegister Test step. Select Specify Module to bring up the Edit LabVIEW VI Call dialog box. Click the Browse button to select the code module VI,C:\Exercises\TestStand I \VIs\Register Test.vi.

15. Click OK to return to the Edit LabVIEW VI Call dialog box. Choose the option to pass the Sequence Context ActiveX Pointer as a parameter to the VI. The dialog box should resemble the one shown below.

16. Repeat all of steps 14 and 15 for theInstruction Set Test step, except select Instruction Set Test.vi. 17. Cache Repeat Test.vi all of step 14 and 15 for theCache Test step, except select .

©

National Instruments Corporation

3-47

TestStand I Fundamentals Course Manual

Lesson 3

Creating Sequences Exercises

18. Repeat all of step 14 and 15 for theFPU Test step, except selectFPU Test.vi. The finished screen is shown below. The name of the resource being called at each step appears in the Descriptions column in the right window pane.

19. Click on the Parameters tab. Right-click in the right window pane and select Insert Parameter»Boolean to create a Boolean parameter that is passed into this sequence when it is called as a subsequence. Parameters are discussed in greater detail in Lesson 4.

20. Rename this parameterCPUFail. Save the sequence and use theView Ring to select the MainSequence sequence again.

TestStandIFundamentalsCourseManual

3-48

ni.com

Lesson 3 Creating Sequences Exercises

21. Click the Main tab to view the Main step group window of the MainSequence. Right-click on the CPU Test step and select Specify Module to select which sequence should be called at this step. In the resulting dialog box, click theUse Current File option and select the sequence CPU Test from the Sequence Ring as shown.

The CPU Test sequence created during this exercise has been selected as the sequence to be called at this step. Remember that this sequence requires a parameter called CPUFail to be passed to it. Not ice that when you select the CPU Test sequence, the CPUFail parameter is automatically added to the list of parameters to be passed to the sequence. This is because theUse Prototype of Selected Sequence option is checked.

©

National Instruments Corporation

3-49

TestStand I Fundamentals Course Manual

Lesson 3

Creating Sequences Exercises

22. You still need to specify the value for this parameter. Click the Browse button to launch the expression browser. In the expression browser, click the + sign next to “Locals” and then click the CPUFail variable. Click Insert to select that expression as the value to be passed.

TestStandIFundamentalsCourseManual

3-50

ni.com

Lesson 3 Creating Sequences Exercises

23. Click OK to return to the Edit Sequence Call dialog box, which should now resemble the following screen.

24. Click OK to return to the sequence file window. Run the sequence file by clicking the Run button. The report now contains a section to report that the sequence CPU Test was run. Additionally, another section lists the results of each of the four tests created in this exercise. Close the report, but leave the sequence file open for the next part of this exercise.

End of Part A

©

National Instruments Corporation

3-51

TestStand I Fundamentals Course Manual

Lesson 3

Creating Sequences Exercises

Part B: Using Different Adapter Types in the Same Sequence So far, every sequence has been constructed using the same adapter type. However, TestStand allows you to use different adapter types in the same sequence. The rest of this exercise shows how to modify the CPU Test sequence so that it uses different adapter types for some of the steps. Then, you will run the sequence again to show that the changes do not affect how the sequence behaves, other than where it looks for the code resources. 1. Select the CPU Test sequence from the View Ring. Right-click on the Instruction Set Test and Cache Test steps and select Cut to remove these steps. Select theC/CVI Standard Prototype Adapter in the Adapter Selector Ring.

2. Right-click on the Register Test step and select Insert Step» Tests»Pass/Fail Test. Rename the step Instruction Set Test.

TestStandIFundamentalsCourseManual

3-52

ni.com

Lesson 3 Creating Sequences Exercises

3. Select the DLL Flexible Prototype Adapter in the Adapter Selector Ring.

4. Right-click on the Instruction Set Test and select Insert Step» Tests»Pass/Fail Test. Rename the step Cache Test.

©

National Instruments Corporation

3-53

TestStand I Fundamentals Course Manual

Lesson 3

Creating Sequences Exercises

5. Right-click on the Instruction Set Test step and select Specify Module from the menu. Click Browse and select the code module, C:\Exercises\TestStand I\CVI Project Files\Computer cvi.dll. Click OK to proceed to the C/CVI Module Call dialog box.

6. Select the function InstrSetTest from the Function Name Ring.

TestStandIFundamentalsCourseManual

3-54

ni.com

Lesson 3 Creating Sequences Exercises

7. Check the options to Pass Sequence Context and to use Standard Prototype. Click OK to return to the Sequence Editor.

8. Right-click on the Cache Test step and select Specify Module from the menu. Click Browse and select the code module, C:\Exercises\TestStand I\CVI Project Files\Computer dll.dll. Click OK to proceed to the Edit DLL Call dialog box.

9. Select the function Cache Test from the Function Name Ring. 10. Select the first parameter,seqContextCVI, and fill in the following information: Parameter: Value Expression:

©

National Instruments Corporation

seqContextCVI ThisContext

3-55

TestStand I Fundamentals Course Manual

Lesson 3

Creating Sequences Exercises

11. Select the result parameter and fill in the following information: Parameter:

result

Value Expression: Result Action:

Step.Result.PassFail No Action

12. Select the errorOccurred parameter and fill in the following information: Parameter:

errorOccurred

Value Expression:

Step.Result.Error.Occurred

Result Action:

No Action

13. Select the errorCode parameter and fill in the following information: Parameter:

errorCode

Value Expression:

Step.Result.Error.Code

Result Action:

No Action

14. Select the errorMsg parameter and fill in the following information:

TestStandIFundamentalsCourseManual

Parameter:

errorMsg

Value Expression:

Step.Result.Error.Msg

3-56

ni.com

Lesson 3 Creating Sequences Exercises

The resulting dialog box should resemble the one shown below. The Function Call tab at the bottom of the screen contains the actual function call. ClickOK to exit the Edit DLL Call dialog.

15. Select the MainSequence from the View Selector Ring . Save the sequence and run it by clicking theRun button. The sequence file should execute the same as before, and the report should be identical also. The only difference is that two of the steps in the CPU Test subsequence are now calling DLLs using different adapter types, instead of calling LabVIEW VIs using the LabVIEW adapter. When the exercise is complete, close the sequence file.

End of Part B

©

National Instruments Corporation

3-57

TestStand I Fundamentals Course Manual

Lesson 3

Creating Sequences Exercises

Optional Discu ssion on DLL and C/CVI Prototype Adapters What are the differences between the DLL Flexible Prototype Adapter and the C/CVI Standard Prototype Adapter? This exercise introduced the C/CVI Standard Prototype Adapter. Both the C/CVI Standard Prototype Adapter and the DLL Flexible Prototype Adapter can call DLLs, but they use different methods to call these code modules. This discussion compares these two adapter types and describes the benefits of each.

Feature Test functions can have a variety of prototypes

C/CVI Standard DLL Flexible Prototype Prototype No

Yes

Allows you to pass any argument to a test function directly

No

Yes

Automatically passes a predefined set of common arguments to each test function

Yes

No

Allows debugging C source files from TestStand

Yes

Allows debugging DLL functions from TestStand

Yes 1,2

Code modules can be C source files, object files, or static libraries

Yes

No (DLLs only)

Can call DLLs created with MSVC++, Borland C++, Delphi, or another compiler

Yes

Yes

Backward compatible with LabWindows/CVI Test Executive Toolkit

Yes

No

Can create source code from code templates Can use TestStand API within code modules

Yes Yes

1,2

4

No Yes1,3

Yes Yes

1.

Requires LabWindows/CVI 5.0 or later.

2.

You must configure the LabWindows/CVI Standard Prototype Adapter to execute steps in an external instance of LabWindows/CVI.

3.

You must launch the Sequence Editor or operator interface from the DLL development environment.

4.

Creation and editing of source code is integrated with the LabWindows/CVI environment.

When developing new tests, C/C++ users must decide whether to use the C/CVI Standard Prototype Adapter or the DLL Flexible Prototype Adapter. Each adapter has advantages. Use the adapter that best suits your particular needs.

TestStandIFundamentalsCourseManual

3-58

ni.com

Lesson 3 Creating Sequences Exercises

The C/CVI Standard Prototype Adapter uses a standard prototype, while the DLL Flexible Prototype allows a choice of various function prototypes. The DLL Flexible Prototype Adapter gives you more flexibility when you define your test functions. You can pass any number of arguments directly to a test function. This makes it convenient to access TestStand variables or properties in the function. Of course, you can always use the TestStand API to access TestStand variables and properties from test functions that you call with either adapter. The C/CVI Standard Prototype Adapter allows you to step into C source files and DLLs from TestStand using an external instance of LabWindows/CVI. However, you can always debug a DLL from your C/C++ development environment by launching the Sequence Editor or operator interface as an external process from the development environment. The C/CVI Standard Prototype Adapter makes debugging more convenient for LabWindows/CVI users by allowing them to step into their C source or DLL directly from TestStand. The C/CVI Standard Prototype Adapter also allows you to use object files, static libraries, and C source files (in LabWindows/CVI). In addition, the C/CVI Standard Prototype Adapter has tighter integration with the LabWindows/CVI environment for creating and editing code. Finally, the C/CVI Standard Prototype Adapter uses a fixed prototype to which it passes a predefined set of parameters. You do not need to specify the argument values to pass to your test functions. When making your decision, keep in mind that it might be difficult to switch from one adapter to the other once you start test and sequence development.

End of Exercise 3-3

©

National Instruments Corporation

3-59

TestStand I Fundamentals Course Manual

Lesson 3

Creating Sequences Exercises

Exercise 3-4 Running Sequences in Parallel (Optional) TestStand can run multiple sequences in parallel. Each sequence is given a separate thread to run in when executed. This exercise demonstrates a simple example of multithreading by showing how to run the same sequence multiple times in both the Sequence Editor and one of the operator interfaces. You will learn that it is possible to run different sequences at the same time instead of running the same sequence many times simultaneously. Additional multithreading features in TestStand are discussed in the TestStand II course. Note For this exercise, be sure to select the Execute»Tracing Enabled option or select Configure»Station Options and adjust the slider on the Execution tab. When this option is enabled, the sequence execution includes yellow arrows indicating the current sequence execution step. When this option is not enabled, there are no visible markers to indicate the current step being executed in any sequence execution window.

1. In the Sequence Editor, open the sequence file, C:\TestStand\Examples\Demo\Misc\RunForever.seq. This example ships with TestStand. This sequence file runs a series of steps and then loops back to the beginning of the sequence and runs the steps again. This process continues until the sequence is terminated manually.

TestStandIFundamentalsCourseManual

3-60

ni.com

Lesson 3 Creating Sequences Exercises

2. Set the sequence display window so that multiple windows are viewable in the Sequence Editor.

©

National Instruments Corporation

3-61

TestStand I Fundamentals Course Manual

Lesson 3

Creating Sequences Exercises

3. Click the Run button and notice that the sequence begins executing and continues running when it reaches the end of the sequence file.

TestStandIFundamentalsCourseManual

3-62

ni.com

Lesson 3 Creating Sequences Exercises

4. Click onthe runforever.seq [Executing] window. The execution window continues running. Notice that with this window as the active window, theRun button is once again enabled.

©

National Instruments Corporation

3-63

TestStand I Fundamentals Course Manual

Lesson 3

Creating Sequences Exercises

5. Click the Run button again and notice that a second execution window opens. Notice that the two sequence executions are both running and are executing independently from one another. Click the Run button several more times and notice that you can run many executions simultaneously and independently from one another.

6. Because this sequence has no built-in way to stop itself, you may stop the sequence execution by clicking theX button in the top right corner of the execution window or selectingTermi nate All Executions under the debug menu. When you click this button, the following dialog box appears. Select the option toTerminate Execution. This allows TestStand to halt the execution cleanly and run any cleanup steps for the executing sequence. Repeat this process for each sequence execution.

TestStandIFundamentalsCourseManual

3-64

ni.com

Lesson 3 Creating Sequences Exercises

7. When finished closing all sequence execution windows, close the sequence file to complete the exercise.

End of Exercise 3-4

©

National Instruments Corporation

3-65

TestStand I Fundamentals Course Manual

Lesson 3

Creating Sequences Exercises

Notes

TestStandIFundamentalsCourseManual

3-66

ni.com

Lesson 4 TestStand Parameters, Variables, and Expressions

Lesson 4: TestStand Parameters, Variables, and Expressions

In this lesson, you will learn about: • Parameters • Local Variables • Sequence File Global Variables • Station Global Variables • RunState Properties • The Expression Browser (to view variablesand build complex expressions)

Introduction One of the most powerful TestStand features is its flexible framework for sharing data. In this lesson, you will learn about TestStand parameters and the three types of TestStand variables: locals, sequence file globals, and station globals. You will also learn about runstate properties and how to utilize the TestStand Expression Browser to use variables and propert ies in expressions throughout the TestStand environment.

©

National Instruments Corporation

4-1

TestStandI Fundamentals Course Manual

Lesson 4

TestStand Parameters, Variables, and Expressions

TestStand Parameters and Variables • Used to share data between steps of a sequence or among several sequences • Different methods for sharing data: – Parameters – Local Variables – Sequence File Global Variables – Station Globals

TestStand Variables One of the most important functions that test executive software provides is a method for sharing data among tests and sequences. In TestStand, there are three different types of variables for sharing data collected by tests. The three variable types differ only in their scope, or where they can be accessed. •

Parameters—Used only within a sequence to pass data between subsequences and the calling sequence. A subsequence is a sequence called as a step from within another sequence (that is, the calling sequence).

• Local Variables —Share data within a single sequence file between the steps of a sequence. •

File Global Variables —Share data between multiple sequences within a single sequence file; share data between steps of the sequences within that sequence file.

• Station Globals —Share data between multiple sequence files. Station globals are defined for a particular installation of TestStand, and any sequence files running on the station can access them.

TestStandIFundamentalsCourseManual

4-2

ni.com

Lesson 4

TestStand Parameters, Variables, and Expressions

TestStand Parameters • Directly pass data between calling sequence and subsequence • Define in Parameters tab of sequence display window Sequence File Subsequence 1 Calling Sequence

Parameter 1 Parameter 2

Data 1 Data 2

Subsequence 2 Parameter 1 Parameter 2

Parameters Sequences may have parameters for passing data from one sequence to another. In LabVIEW, using parameters with sequences in TestStand is analogous to passing data between VIs using connectors in the block diagram of the top level VI. For LabWindows/CVI, using parameters in TestStand is analogous to passing data through function parameters. To create parameters in the sequence display window, use theParameters tab and select the desired data type. Any step within the sequence can then access (read or write) the parameters. Parameters are typically used to pass data between top-level sequences and subsequences. Identify subsequence parameters and specify their values in the Edit Sequence Call dialog box, which appears when you insert a Sequence Call step into a sequence and specify the module. The Edit Sequence Call dialog box is shown on the next slide.

©

National Instruments Corporation

4-3

TestStandI Fundamentals Course Manual

Lesson 4

TestStand Parameters, Variables, and Expressions

Parameters: Passing data to subsequences

Parameters: Passing data to subsequences As shown in the slide above,SequenceFile2.seq is the sequence file and MainSequence is the sequence to be called as a subsequence. The first parameter in the subsequence is passed a constant numeric value of10, while the second parameter is passed the value of a parameter in the calling sequence. Under theHow Passed column, the by reference setting indicates that the parameter being passed is a reference to an argument, instead of a copy of its value. Passing a parameter by reference allows the subsequence to change the actual value of the argument (affecting the calling sequence), hence allowing the parameter value to be updated during ru n time.

TestStandIFundamentalsCourseManual

4-4

ni.com

Lesson 4

TestStand Parameters, Variables, and Expressions

Local Variables • Share data among all steps in a sequence • Access using expressions and/or test modules Sequence A Step 1

Step 2

Seq A Locals

Local Variables Local variables are shared within a single sequence. All sequence steps can get (read) or set (write) the value of the local variables defined for a sequence. The value of a local variable can be read or written in any TestStand expression associated with steps in that sequence, or in any of the test modules called by those steps. Thus, each sequence has its own set of local variables. For example, you can store a local variable called Serial Number at the beginning of the sequence, and then retrieve this serial number in subsequent tests to help you decide which specific tests to run.

©

National Instruments Corporation

4-5

TestStandI Fundamentals Course Manual

Lesson 4

TestStand Parameters, Variables, and Expressions

Creating Local Variables • Each sequence has a local variables tab • Create a new local variable by right-clicking in this window and selecting the appropriate data type

Creating Local Variables Each sequence has a Locals tab, which shows all local variables defined for that particular sequence. To add a new local variable to the sequence, right-click inside the right pane of the Locals window, select Insert Local, choose the variable type, and name the variable accordingly. The variable types available in TestStand are Number, String, Boolean, ActiveX references, and arrays of these data types. In addition, you can create your own custom data types. The lesson on TestStand types explains how to create custom data types.

TestStandIFundamentalsCourseManual

4-6

ni.com

Lesson 4

TestStand Parameters, Variables, and Expressions

Exercise 4-1 Objective: To add a local variable to a sequence and pass data between steps

Approximate time to complete: 20 minutes

©

National Instruments Corporation

4-7

TestStandI Fundamentals Course Manual

Lesson 4

TestStand Parameters, Variables, and Expressions

Sequence File Global Variables Share data between all sequences of a sequence file Sequence File

Sequence A Step 1

Seq A Locals

Step 2

Sequence File Globals Sequence B Step 1 Step 2

Seq B Locals

Sequence File Global Variabl es Sequence file global variables are similar to local variables, except that they have a larger scope of usability. Besides being accessible from all steps in a given sequence (like local variables), any other sequence in the sequence file can access file global variables. Thus, each es quence file has its own unique set of global variables.

TestStandIFundamentalsCourseManual

4-8

ni.com

Lesson 4

TestStand Parameters, Variables, and Expressions

Creating Sequen ce File Globals • Select sequence file globals from the view selector ring to display globals • Create a new global variable by right-clicking, choosing Insert Global, and selecting the appropriate data type

Creating Sequence File Global Variabl es Sequence File Globals Creating a global variable is similar to creating a local variable. Choose View:). This displays from the view selector ring control of a sequence file window (indicated by the Globals window, which displays all global variables defined for the sequence file. Right-click in the right pane of the Globals window, selectInsert Global, select the variable type, and rename it to create a new sequence file global.

©

National Instruments Corporation

4-9

TestStandI Fundamentals Course Manual

Lesson 4

TestStand Parameters, Variables, and Expressions

Station Globals Station globals have the largest scope: they share data between multiple sequence files

Sequence File A Sequence A Step 1

Step 2

Seq A Locals

Sequence B Step 1

Step 2

Seq File Globals

Seq B Locals

Station Globals

Sequence File B Sequence A Step 1

Step 2

Seq A Locals

Sequence B Step 1

Step 2

Seq File Globals

Seq B Locals

Station Globals Station globals have a larger usability scope than either locals or sequence file globals. They pass data between different sequence files. Station globals are defined for a particular test station and their values are written toStationGlobals.ini each time the Sequence Editor is closed. This enables TestStand to keep track of data values even when it is shut down. Thi s allows users to save state information, such as the last operator to run a test. The values of station global variables are persistent across different executions and even across different invocations of the Sequence Editor or run-time operator interfaces. In addition, the StationGlobals.ini TestStand API includes an ActiveX method that may be called to update explicitly.

TestStandIFundamentalsCourseManual

4-10

ni.com

Lesson 4

TestStand Parameters, Variables, and Expressions

RunState Property Object • Contains all the property objects that describe the state of execution in the sequence invocation • Some of the RunState properties are shown below

RunState Property Object The RunState property object contains all the property objects that describe the state of execution in the sequence invocation. The RunState property object contains many subproperties. Some of these are listed below with a brief description: •

Engine—Engine object in which the sequence invocation executes



Root—Sequence context for the root sequence invocation



Main—Sequence context for the least nested sequence that is not in a process model



ThisContext—Reference to the current sequence context



Caller—Sequence context for the sequence that called the current sequence



Report—Report object for the execution



Execution—Execution object in which the sequence invocation runs



Sequence—Run-time copy of the Sequence object for the sequence invocation



Thread—Thread object in which the sequence invocation executes

©

National Instruments Corporation

4-11

TestStand I Fundamentals Course Manual

Lesson 4

TestStand Parameters, Variables, and Expressions

RunState Subproperties • Some subproperties are not filled until run time since their contents depend on the invoked sequence

Empty

Filled

RunState Subproperti es It is important to note that some of the properties listed under theRunState property object are empty when a sequence is not being executed. To find which subproperties are available when a sequence is not being executed, selectView»Browse Sequence Context from the menu and expand the RunState property object. The majority of theRunState subproperties will be listed at this time. However, some of the subproperties that are containers will not contain any information, such as theRoot, Main, Caller, and Execution properties. To view whichRunState subproperties are available during a sequence execution and what information is contained in these properties, place a breakpoint on a step within the sequence. Execute the sequence and when TestStand reaches the breakpoint, select the Context tab from the execution display. Expand theRunState property object to view the available properties according to the current sequence invocation.

TestStandIFundamentalsCourseManual

4-12

ni.com

Lesson 4

TestStand Parameters, Variables, and Expressions

RunState Property Example How to access UUT Serial Number: • Set Breakpoint • Execute Sequence (Execute»Test UUTs) • Browse RunState to UUT Serial Number (RunState.Root.Locals.UUT.SerialNumber) • Copy Property Path

RunState Property Example This example illustrates how to use the RunState property object to obtain the UUT serial number in a test sequence. The UUT serial number can be accessed from theRunState property in different ways. Thisexample obtains theUUT serial number from theRoot subproperty. Since the Root subproperty only contains information when the sequence is executing, the UUT serial number will only be visible via theRoot subproperty at run-time. Follow the steps below to find the UUT serial number in theRunState property and incorporate using the serial number in your test sequence. 1. Place a breakpoint on a step in your sequence where you want to access the UUT serial number. 2. To execute the test sequence, select Execute»Test UUTs. 3. When the execution pauses on the breakpoint, select the Context tab. 4. Browse to the RunState.Root.Locals.UUT.SerialNumber property. 5. Right-click on the serial number property and select Copy Property Path to copy the above path to your clipboard. 6. Finish executing the sequence and return to the main sequence display. 7. Paste the path of the property into the expression window in your sequence where you need to use the UUT serial number.

©

National Instruments Corporation

4-13

TestStand I Fundamentals Course Manual

Lesson 4

TestStand Parameters, Variables, and Expressions

The Expression Browser • Simplifies building complex expressions • Launch from the Browsebutton next to any expression window • Includes two tabs: – Variables/Properties – Operators/Functions

The Expression Browser The TestStand Expression Browser allows you to use theTestStand variables you create within the Sequence Editor. An expression is a formula that calculates a new value from the values of multiple variables or properties. You can use TestStand expressions to evaluate a value in place of hardcoding a value for a simple variable or property value. Throughout the Sequence Editor, there are locations (input controls) where you can create a custom expression for evaluation purposes during sequence execution. This is possible from many locations such as the Post Actions, Loop Options, and Expressions property tabs, and also from within the Statement, Limit Loader, and Message Popup steps. You can enter an expression in any TestStand control that has aBrowse button beside it. Clicking on this button brings up the expression browser, which is a tool for building your expressions, and is especially useful for the novice user. You can also launch the Variable Browser by selecting View»Browse Sequence Context. This browser is similar to the expression browser, except the functions and operators do not appear. Although it is not necessary to use the expression browser to enter an expression, it is useful for locating variables and functions when building complex statements. The next slide shows how to use the expression browser features.

TestStandIFundamentalsCourseManual

4-14

ni.com

Lesson 4

TestStand Parameters, Variables, and Expressions

Using the Expression Browser

Using the Expression Browser The expression browser includes two tabs:Variables/Properties and Operators/Functions. The Variables/Properties tab displays all variables and properties accessible to the current context. The Operators/Functions tab includes all valid TestStand operators (such as those used for comparison, addition, and so on) and functions (mathematical, string handling, and so on). Using these two sections in conjunction allows you to build complex expressions quickly and easily. The expression browser also includes aCheck Syntax button that determines whether the expression syntax is correct. You can then insert the expression into the appropriate context of the current window. There are terms you should understand as you develop more complex TestStand sequences using the Expression Browser: •

SequenceContext—Contains references to all global variables, local variables, and step properties in active sequences. The sequence context contents change depending on the currently executing sequence and step.



ThisContext—Refers to the current sequence context. You usually use this property to pass the entire sequence context as an argument to another sequence or a step module. Sequence contexts are ActiveX Automation reference handles you can use in conjunction with test modules.



RunState—Contains properties that describe the state of execution in the sequence invocation.

©

National Instruments Corporation

4-15

TestStand I Fundamentals Course Manual

Lesson 4

TestStand Parameters, Variables, and Expressions

Defining Variables and Parameters • Expression Browser allows you to add and remove variables and parameters in your test sequences

Defining Variables and Parameters Often times when creating expressions in the Expression Browser you will realize that it would be better to use an additional variable or parameter that you have not previously defined in the Sequence Editor. In order to prevent you from leaving the Expression Browser to define the new variable or parameter in the tab or window mentioned previously in this lesson, the Expression Browser allows you to define variables and parametersfrom within it. You can declare new locals, parameters, file globals, and station globals from within the Expression Browser. When you right-click on the variable type or parameter in the Expression Browser, a pop-up menu appears that allows you to select the data type of the new variable or parameter you wish to define. This pop-up menu offers the same declaration choices as the other variable editing views in the Sequence Editor. Once the variable or parameter has been defined from within the Expression Browser it appears in the respective tab or window within the Sequence Editor as if you had defined it there srcinally.

TestStandIFundamentalsCourseManual

4-16

ni.com

Lesson 4

TestStand Parameters, Variables, and Expressions

Exercise 4-2 Objective: To create locals, file globals, and station globals and use the expression browser to understand the scope of variables

Approximate time to complete: 15 minutes

©

National Instruments Corporation

4-17

TestStand I Fundamentals Course Manual

Lesson 4

TestStand Parameters, Variables, and Expressions

Exercise 4-3 Objective: To modify the limit properties of a Numeric Limit Step

Approximate time to complete: 25 minutes

TestStandIFundamentalsCourseManual

4-18

ni.com

Lesson 4

TestStand Parameters, Variables, and Expressions

Exercise 4-4 Objective: To use expressions and parameters in subsequence executions

Approximate time to complete: 25 minutes

©

National Instruments Corporation

4-19

TestStand I Fundamentals Course Manual

Lesson 4

TestStand Parameters, Variables, and Expressions

Exercise 4-5 Objective: To create a test which dynamically selects which sequence to run Approximate time to complete: 20 minutes

TestStandIFundamentalsCourseManual

4-20

ni.com

Lesson 4

TestStand Parameters, Variables, and Expressions

Lesson 4 Summary: Parameters, Variables, & Expressions • TestStand has different scopes for data sharing – Parameters share data between calling sequences and subsequences – Local variables share data between steps in a sequence – Global variables share data between all sequences within a sequence file – Station globals share data between all sequence files within the TestStandenvironment

• RunState Properties describe the state of execution • The Expression Browser is a tool for building expressions and can also be used to define variables and parameters

Summary In this lesson, you learned how to share data within the TestStand environment. Each method for sharing data serves a particular purpose. You may want to think about which situations would require the use of parameters, locals, sequence file globals, or station globals. For example, as you begin deployment onto the production floor, what information on the test station is needed across shifts? If you have a DLL, should all the data manipulation be internalized or shared using sequence locals? As you access and modify variables, you may also want to make use of the RunStat e properties for information such as the UUT serial number, the UUT loop index, and the next step index. Using multiple variables and properties in your expression can create complex statements. TestStand eases this task by allowing you to create arbitrarily complex expressions through the Expression Browser. It also improves programming efficiency by allowing you to define variables and parameters from within the Expression Browser. Now that you have learned the basics of the T estStand sequence editor, the next lesson will discuss how test programs from external development environments interact with TestStand.

©

National Instruments Corporation

4-21

TestStand I Fundamentals Course Manual

Lesson 4 TestStand Parameters, Variables, and Expressions Exercises

Exercise 4-1 Using Local Variables Objective:

To add a local variable to a sequence to share data between steps. Local variables share data between steps in the same sequence. This type of variable has the smallest scope, but is used most often. This lesson demonstrates how to use local variables to change the frequency of the alarm configured in a previous exercise. 1. In the Sequence Editor, open the sequence file, C:\Exercises\TestStand I\Ex 4-1 Local Variables.seq. This file is the same as the solution for exercise 3-1. The solutions for the exercises are in theC:\Solutions\TestStand I directory. In this exercise you will add a local variable to the sequence. Click on the Locals tab and right-click in the right pane of the window. Select Insert Local»Number, as shown.

2. Name the local variable Frequency. This variable sets the audible alarm tone when the ROM Test fails.

TestStandIFundamentalsCourseManual

4-22

ni.com

Lesson 4 TestStand Parameters, Variables, and Expressions Exercises

3. Click on the Main tab. You must change the module called during the ROM Test step at this point. Right-click on theROM Test and select Specify Module. Click on the Browse button to select the VI, C:\Exercises\TestStand I\VIs\ROM Test - Local Variable.vi. Remember to select arelative path when TestStand prompts for how the path should be stored. Select theShow VI front panel when called and Sequence Context ActiveX Pointer options. The screen should appear as shown below.

Note Failing to select the Show VI Front Panel When Called option may lead to an infinite loop running in the VI. Note If you are not familiar with NationalInstruments LabVIEW programming environment, skip to step 4.

Click the Edit VI button on this screen to edit the VI. Observe that the front panel has a frequency control for entering the frequency value. Go to the block diagram and observe that the frequency value is passed to TestStand using the TestStand Automation VIs. The main VI to notice in this diagram is TestStand - Set Property Value(number).vi, because it passes the numeric value into TestStand. These VIs and their functions are covered in greater detail later in the course. Close the VI.

©

National Instruments Corporation

4-23

TestStand I Fundamentals Course Manual

Lesson 4 TestStand Parameters, Variables, and Expressions Exercises

4. Edit the StartBeep step to set the tone using theFrequency local variable. Right-click on the StartBeep step and select Specify Module. In the Parameters section, delete the constant value of1000 in the Value Expression control. Press the Browse button and choose Locals.Frequency. Click Insert and then OK . The Edit DLL Call dialog box should now haveLocals.Frequency set as the value for the parameter Tone. Select OK to return to the sequence display window.

5. Save the sequence file Ex 4-1 Local Variables.seq. Select Execute»Test UUTs and try varying the frequency for several different tests. Remember that the ROM Test must be set to fail for the alarm to sound. The alarm will sound with a tone proportional to the frequency.

End of Exercise 4-1

TestStandIFundamentalsCourseManual

4-24

ni.com

Lesson 4 TestStand Parameters, Variables, and Expressions Exercises

Exercise 4-2 Examine the Uses and Differences between Locals, File Globals, and Station Globals Objective:

To create lo cal variables, file global variables, and stat ion global variables and understand the difference in their scope. It is important to understand the differences between the three different types of variables in TestStand. A good rule of thumb to follow is that local variables are for sharing data between steps in the same sequence, as demonstrated in the previous exercise; file global variables are for sharing data between a step in one sequence and a step in another sequence in the same sequence file; and station global variables are for sharing data between steps in two sequences in different sequence files. This exercise demonstrates how to create each type of variable and emphasizes the differences between them.

Part A: Local Variable s 1. In the Sequence Editor, select File»New Sequence File to open a new sequence file. 2. A local variable is for sharing information between different steps in a single sequence. Click on theLocals tab to view the local variable window. Right-click on the right pane and select Insert Local»Number as shown below.

This creates a numeric local variable. Name the local variableLocalA.

©

National Instruments Corporation

4-25

TestStand I Fundamentals Course Manual

Lesson 4 TestStand Parameters, Variables, and Expressions Exercises

3. Select the menu option View»Browse Sequence Context to view the variables and properties in the TestStand environment relative to the current sequence. This launches the variable browser. Remember that this is different from the expression browser because it is missing the functions and operators found in the expression browser. In any location that can accept an expression, there is abrowse button that launches the expression browser. The expression browser displays the hierarchy of properties and variables for the sequence context from which it is invoked. This browser will be increasingly useful later in the course as more advanced topics are discussed. Click on the + box to expand the list of local variables and notice that the LocalA variable created in the previous step is listed, as shown below. ClickClose to return to the sequence file and continue with the exercise.

4. Select File»Save As to save the sequence file as C:\Exercises\TestStand I\Ex 4-2 All Variables1.seq.

TestStandIFundamentalsCourseManual

4-26

ni.com

Lesson 4 TestStand Parameters, Variables, and Expressions Exercises

5. Select File»New Sequence File to create a new sequence file and create another local variable by repeating steps 1 through 4 above. Name this local variable LocalB and the sequence fileEx 4-2 All Variables2.seq. You should see the panel shown below.

Select the menu option View»Browse Sequence Context, and notice that only the local variable created in this sequence is visible. This is because the variable LocalA, created in the first sequence, is not accessible. The scope of local variables is limited to a single sequence; they can be accessed only from within the sequence in which they were created. Click Close to exit the dialog. 6. Click on the View ring (as shown below) and selectAll Sequences to see all the sequences in this sequence file.

Notice that there is only one sequence, namedMainSequence, in this sequence file.

©

National Instruments Corporation

4-27

TestStand I Fundamentals Course Manual

Lesson 4 TestStand Parameters, Variables, and Expressions Exercises

7. To create another sequence, right-click in an empty space within the All Sequences view and select Insert Sequence from the popup menu. Name this sequence TestSequence. The final result should appear as shown below.

8. Click on the View ring and select TestSequence to view the contents of this sequence. 9. Select the menu option View»Browse Sequence Context. Notice that LocalB is not available for use in this sequence, as shown. This is because LocalB was defined in the MainSequence and not in the TestSequence. Note Although the two sequences are in the same sequence file, the local variables are not shared between them.

TestStandIFundamentalsCourseManual

4-28

ni.com

Lesson 4 TestStand Parameters, Variables, and Expressions Exercises

Click Close to exit the dialog. Leave this sequence file open for the next part of this exercise.

End of Part A Part B: Sequence File Globals A file global variable is for passing data between different sequences in the same sequence file. 1. Use the View Selector to select Sequence File Globals. Right-click in the right pane of the File Globals window and selectInsert Global»Number. Name this variable TestFileGlobalA. Save the sequence file by selectingFile»Save. 2. Click on the View Selector and select TestSequence to view the contents of this sequence. 3. Select the View»Browse Sequence Context. Notice that the TestFileGlobalA variable is available for use in this sequence, as shown.

4. Click Close to return to the Sequence Editor. Use theView Selector to select the MainSequence. Select View»Browse Sequence Context and notice that the TestFileGlobalA variable is available for use in this sequence also. Therefore, the data in the file global you created inMainSequence is available for use in all other sequences in theEx 4-2 All Variables2.seq sequence file. In this way, you can use sequence file

©

National Instruments Corporation

4-29

TestStand I Fundamentals Course Manual

Lesson 4 TestStand Parameters, Variables, and Expressions Exercises

globals to pass data between the different sequences in the same sequence file. This should help to distinguish the difference between local variables and file global variables in TestStand. The last part of this exercise describes station global variables.

End of Part B Part C: Station Globals Station globals are for sharing data between different sequence files. In this part of the exercise, you will create a station global variable and examine its scope. 1. Create a station global and examine its scope. Click on the globe icon beside the Adapter Ring. This opens the Station Global palette. Right-click on the right pane and selectInsert Global»Number as shown below. Name this station global variable StationGlobal1.

2. Select Window»Ex 4-2 All Variables2.seq. Next, select View»Browse Sequence Context…. Click the + sign beside Station Globals and notice that StationGlobal1 is available for use. ClickClose when finished to return to the sequence file. 3. Select File»Save to save Ex 4-2 All Variables2.seq and then close it by selecting File»Close. 4. Open Ex 4-2 All Variables1.seq if it is not already open and select View»Browse Sequence Context . Click the + sign beside Station Globals and notice that StationGlobal1 is available for use. In fact, any sequence executed on this test station can use station globals. In addition, station globals are persistent; that is, they keep their value in a.ini file from one TestStand session to the next. Click the + sign

TestStandIFundamentalsCourseManual

4-30

ni.com

Lesson 4 TestStand Parameters, Variables, and Expressions Exercises

beside the station global calledTS and notice that this container holds a value called LastUserName. This variable is the name of the last user that logged into TestStand and it is being stored as a station global variable. LastUserName is stored in a station global variable because when the Sequence Editor is launched, the user name from the previous session is displayed in theLogin dialog box. The last user to log in is stored in a station global variable

5. Click Close to return to the sequence file when finished. 6. Select File»Close to close the sequence file to continue with the next lesson.

End of Part C End of Exercise 4-2

©

National Instruments Corporation

4-31

TestStand I Fundamentals Course Manual

Lesson 4 TestStand Parameters, Variables, and Expressions Exercises

Exercise 4-3 Objective:

Using Expressions to Change Step Properties

To modify the limit properties of a Numeric Limit step. This exercise demonstrates how to modify properties of steps programmatically. The property loader step type (which is covered in a later exercise) is designed to load limits and properties from files and databases. However, for illustrative purposes in this exercise, the limits are changed manually using TestStand expressions.

Part A 1. Open and run Ex 4-3 Using Expressions to Change Step Properties.seq. Notice that the Video Test always fails. This step fails because the returned Measurement is outside the specified limits of 15 and 19. Observe the report as shown below.

The measurement and limits are merely properties of each step. Different types of steps have different properties. For example, Numeric Limit steps such as the Video Test have measurement, high limit, and low limit properties. As the sequence executes, the value of some of these properties changes depending on what is passed back from code modules. 2. Return to the sequence file window and right-click on the Video Test step. Select Edit Limits from the menu. Observe the dialog box as shown below, but do not change the limit settings. This is the dialog box

TestStandIFundamentalsCourseManual

4-32

ni.com

Lesson 4 TestStand Parameters, Variables, and Expressions Exercises

used to set the desired comparison type and the input limits used in the comparison.

Click OK to close the Edit Numeric Limit Test dialog box. 3. Double-click on the Video Test step and select the Expressions tab. The Expressions tab allows you to modify expressions before (Pre) and after (Post) the step executes. This dialog box is shown below.

©

National Instruments Corporation

4-33

TestStand I Fundamentals Course Manual

Lesson 4 TestStand Parameters, Variables, and Expressions Exercises

4. Place your cursor in the Pre Expression control. Click the Browse button for the Pre Expression control (the top button). This opens the expression browser, as shown below.

5. Click the + sign beside Step and notice that all Video Test step properties are displayed. As shown below, you can use the expression Step.Limits.Low to access the low limit of theVideo Test step. Click the + sign beside Limits to display the Low and High limit properties as shown below. After selecting theLow property, click the Insert button.

TestStandIFundamentalsCourseManual

4-34

ni.com

Lesson 4 TestStand Parameters, Variables, and Expressions Exercises

Place the cursor after Step.Limits.Low and enter = 2, to set the low limit to a value of 2. Next you will specify the value for the high limit. A comma is needed to separate multiple expressions, so be sure to include it in the expression box after the first expression.

©

National Instruments Corporation

4-35

TestStand I Fundamentals Course Manual

Lesson 4 TestStand Parameters, Variables, and Expressions Exercises

6. Click High and the Insert button again. Place your cursor after Step.Limits.High and enter = 12 to set the high limits, as shown below. ClickOK to close the Expression Browser.

TestStandIFundamentalsCourseManual

4-36

ni.com

Lesson 4 TestStand Parameters, Variables, and Expressions Exercises

7. This expression is inserted in the Pre Expression box of the Step Properties dialog box. Verify that it appears as shown below.

Click OK to return to the sequence file window. Run this sequence using Single Pass again and notice that the Video Test step passes this time because the limits are now set to 2 and 12.

End of Part A Part B: Modifying Step Properties from Another Step This section demonstrates how to change a step ’s properties from another step by modifying the Video Test step limits. 1. Double-click on the Video Test step and click on the Expressions tab. Delete the entry Step.Limits.Low = 2, Step.Limits.High = 12 from the Pre Expression that was created in Part A. 2. Click OK to return to the sequence file. Run this sequence to ensure that it fails as it did before.

©

National Instruments Corporation

4-37

TestStand I Fundamentals Course Manual

Lesson 4 TestStand Parameters, Variables, and Expressions Exercises

3. Right-click on the RAM Test step and insert a new Statement step. Statement steps are useful for manipulating expressions. Name this step Modify Video Limits, as shown below.

4. Right-click on the Modify Video Limits step and select Edit Expression from the menu. Click on theBrowse button in the Edit Statement Step dialog box that appears. Browse for RunState.Sequence.Main [“Video Test”].Limits.Low and click the Insert button. Place your cursorTest”]. after RunState.Sequence.Main[“Video Limits.Low and enter = 2, to set the low limit, as shown below. Note Be sure to place the comma at the end of the input.

TestStandIFundamentalsCourseManual

4-38

ni.com

Lesson 4 TestStand Parameters, Variables, and Expressions Exercises

5. Go to RunState.Sequence.Main[“Video Test”]. Limits.High and click on Insert again. Place your cursor at the end of that line and enter= 12. Click Check Syntax to make sure there are no syntax errors and then clickOK to return to the Edit Statement Step dialog box and ensure that it appears as shown below.

©

National Instruments Corporation

4-39

TestStand I Fundamentals Course Manual

Lesson 4 TestStand Parameters, Variables, and Expressions Exercises

Click OK to return to the Sequence File. Run the sequence file using Single Pass to make sure that it works correctly. Close the sequence file when finished with the exercise.

End of Part B End of Exercise 4-3

TestStandIFundamentalsCourseManual

4-40

ni.com

Lesson 4 TestStand Parameters, Variables, and Expressions Exercises

Exercise 4-4 Passing Parameters Objective:

To use expressions and parameters in subsequence execution. This exercise demonstrates two important ideas: how to use parameters for passing information between calling sequences and subsequences, and how to develop a sequence that executes subsequences according to user inputs during run time. The sequence created involves steps that prompt an operator for a CPU type and the number of CPUs to test. The CPU type is then used during the sequence execution to execute one of two different subsequences, and the number of CPUs is passed to the subsequence as a parameter to set the number of times the test must be repeated.

Part A: Adding Steps to the Sequence 1. Navigate to C:\Exercises\TestStand I and open Ex 4-4 Passing Parameters.seq . 2. Before continuing with the exercise, click the Parameters tab. Use the View Ring to select the AMDProcessor and INTELProcessor sequences. Notice that the AMDProcessor sequence has two parameters, and the INTELProcessor sequence has three parameters. This exercise describes how to share data with these subsequences using parameters and how TestStand uses default values if no dat a is specified for a given parameter. 3. Right-click on the Powerup Test step and select Insert Step»Message Popup from the context menu. 4. Rename the new step Select CPU Type. 5. Right-click on the new step and select Edit Message Settings from the context menu. 6. Change the following control values on the Configure Message Box Step dialog box:

©

Title Expression

"Select CPU"

Message Expression

"Please select the CPU Type for the UUT."

Button 1

"INTEL CPU"

Button 2

"AMD CPU"

Cancel Button

None

National Instruments Corporation

4-41

TestStand I Fundamentals Course Manual

Lesson 4 TestStand Parameters, Variables, and Expressions Exercises

The Configure Message Box Setup dialog box should resemble the following screen.

7. Click OK to close the Configure Message Box Step dialog box. 8. Right-click on the Select CPU Type step and select Properties from the context menu. 9. Click the Expressions tab.

TestStandIFundamentalsCourseManual

4-42

ni.com

Lesson 4 TestStand Parameters, Variables, and Expressions Exercises

10. Click on the Browse button in the Post Expression. In the Variables/Properties tab, right-click on Locals and selectInsert String as shown. Name the new variableCPUType.

11. Enter the remainder of the expression in the Post Expression control by either using the Expression Browser or typing in directly:

Locals.CPUType = ((Step.Result.ButtonHit == 2)? "AMD": "INTEL")

©

National Instruments Corporation

4-43

TestStand I Fundamentals Course Manual

Lesson 4 TestStand Parameters, Variables, and Expressions Exercises

This expression assigns the string value"AMD" or "INTEL" to the local variable, depending on which button the user clicks.

12. Click OK to close the properties dialog box. 13. Right-click on Select CPU Type step and select the Insert Step»Message Popup command from the context menu. 14. Rename the new step Specify Number of CPUs. 15. Right-click on the new step and select theEdit Message Settings command from the context menu. 16. Change the following control values on the Configure Message Box Step dialog box as shown below: Title Expression

"Number of CPUs"

Message Expression

"Please select the number of CPUs installed for the UUT."

Button 1

"1"

Button 2

"2"

Button 3

"3"

TestStandIFundamentalsCourseManual

4-44

ni.com

Lesson 4 TestStand Parameters, Variables, and Expressions Exercises

Button 4

"4"

Cancel Button

None

17. Click OK to close the Configure Message Box Step dialog box. 18. Right-click on theSpecify Number of CPUs step and select the Insert Step»Sequence Call command in the context menu. 19. Rename the step CPU Test.

©

National Instruments Corporation

4-45

TestStand I Fundamentals Course Manual

Lesson 4 TestStand Parameters, Variables, and Expressions Exercises

20. Right-click on the new CPU Test step and select Specify Module from the context menu.

21. Enable the Specify Expressions for Pathname and Sequence option. This option allows an expression to determine the name of the seq uence file to be called. By default, TestStand expects the name and path of the sequence file to be typed in, but by enabling this option, TestStand evaluates an expression to determine the path and filename for the sequence to be called at this step. Also, enable the Use Current File option. This option specifies the current sequence file as the location for the subsequence call to look. Because both subsequences that can be called are in the same sequence file as “MainSequence,” you should select this option. The only thing that needs to be selected is the name of the Sequence to be called within the sequence file. 22. Enter the following value for the Sequence Expression control: Sequence Expression

Locals.CPUType + "Processor"

23. Select the prototype for the sequence call by clicking theLoad Prototype button. This option allows TestStand to look at the sequence file to be called and determine whether any parameters must be passed into the sequence. If there are parameters, using this option allows TestStand to determine

TestStandIFundamentalsCourseManual

4-46

ni.com

Lesson 4 TestStand Parameters, Variables, and Expressions Exercises

the number of parameters and their names. Exercise 3-3 demonstrated how to create the parameter manually to pass into the subsequence call, and this exercise uses the prototype to save time and prevent typing mistakes. 24. Click the Browse button in the Load Sequence Prototype dialog box. 25. Navigate to C:\Exercises\TestStand I and open Ex 4-4 Passing Parameters. 26. Click OK to close the Select Sequence File dialog box. 27. Select the AMDProcessor sequence from the Load Sequence Prototype dialog box for the Sequence Ring. Click OK to close this dialog box. Notice that TestStand populates the Parameters section with the parameter list for the sequence. This sequence requires two parameters named CPUsInstalled and CPUFail. Now the location of the values to be passed as parameters must be constructed. 28. Click on the CPUsInstalled parameter. 29. Select the Enter Expression option. 30. Enter the following expression into its string control or clickBrowse and use the expression browser to create the expression:

RunState.Sequence.Main["Specify Number of CPUs"] .Result.ButtonHit

©

National Instruments Corporation

4-47

TestStand I Fundamentals Course Manual

Lesson 4 TestStand Parameters, Variables, and Expressions Exercises

31. Click on the CPUFail parameter. 32. Select the Enter Expression option. 33. Enter the following expression into its string control or clickBrowse and use the expression browser to create the expression: Locals.CPUFail

TestStandIFundamentalsCourseManual

4-48

ni.com

Lesson 4 TestStand Parameters, Variables, and Expressions Exercises

34. Click OK to close the dialog box. The value to be passed to the subsequence has been assigned. The sequence can now decide which subsequence to call and what values to pass to the subsequence as parameters. Notice that because the value is passed using a parameter, there is no need to create a file global or station global variable. 35. The finished sequence file should resemble the following screen. Select File»Save to save the Ex 4-4 Passing Parameters.seq sequence file.

©

National Instruments Corporation

4-49

TestStand I Fundamentals Course Manual

Lesson 4 TestStand Parameters, Variables, and Expressions Exercises

End of Part A Part B: Running a Sequence Complete the following steps to run the sequence created in Part A. 1. Place a breakpoint on the CPU Test step by clicking to the left of the step icon or by right-clicking on the step and selectingToggle Breakpoint from the context menu. 2. Select Execute»Single Pass. 3. Click Done in the Test Simulator prompt. 4. Click the INTEL CPU button in the Select CPU prompt. 5. Click the 2 button in the Number of CPUs prompt. 6. After the execution pauses at the breakpoint on the CPU Test step, single-step into the subsequence by selectingDebug»Step Into. Notice that the Call Stack pane listsINTELProcessor sequence at the bottom of the sequence call stack, as shown below. The Call Stack shows the sequences that have been called, with the most recently executed sequence at the bottom.

TestStandIFundamentalsCourseManual

4-50

ni.com

Lesson 4 TestStand Parameters, Variables, and Expressions Exercises

7. Click on the Context tab and notice the values of the two parameters for the sequence, as shown below.

The value of the CPUsInstalled parameter is equal to the value on the button you clicked in the Specify Number of CPUs prompt. Notice that MainSequence in the INTELProcessor.seq sequence file also requires a ModelName parameter. The sequence call step that was created did not specify this parameter, so the engine initializes the parameter value to its default value. 8. Complete the execution by selecting Debug»Resume. 9. When execution completes, review the report to confirm that the correct sequence file was called, but do not close the execution window. 10. Restart the execution by selectingExecute»Restart.

©

National Instruments Corporation

4-51

TestStand I Fundamentals Course Manual

Lesson 4 TestStand Parameters, Variables, and Expressions Exercises

11. Click Done in the Test Simulator prompt. 12. Click the AMD CPU button in the Select CPU prompt. 13. Click the 3 button in the Number of CPUs prompt. 14. When the execution pauses at the breakpoint on the CPU Test step, step into the subsequence by selectingDebug»Step Into. Notice that the Call Stack pane listsAMDProcessor sequence at the bottom of the call stack. 15. Complete the execution by selectingDebug»Resume, and review the report. 16. Run the example a few more times and select other options. Each time, notice that the parameter values are passed to the dynamically called sequence file. Close the execution window and the sequence file window when finished.

End of Part B End of Exercise 4-4

TestStandIFundamentalsCourseManual

4-52

ni.com

Lesson 4 TestStand Parameters, Variables, and Expressions Exercises

Exercise 4-5 Dynamically Selecting Which Sequence to Run Objective:

To create a test that dynamically selects which sequence to run. You will learn how to dynamically select a sequence file to run. Open the sequence file C:\Exercises\TestStand I\Ex 4-5 Dynamically Selecting Which Sequence to Run.seq. The MainSequence contains three steps:Generic Processor, Intel Processor, and AMD Processor. In this exercise your goals are to: 1. Add a step that asks the user to select the type of processor to test. 2. Make the necessary changes to ensure that the selected processor is tested.

Hints: Use a Message Popup step to ask the user which type of processor to test. The Message Popup step stores the selected button in: RunState.Sequence.Main[ Name of the Message Popup step].Result.ButtonHit.

As shown below, use thePreconditions expression of each step to determine which step will execute.

©

National Instruments Corporation

4-53

TestStand I Fundamentals Course Manual

Lesson 4 TestStand Parameters, Variables, and Expressions Exercises

Save and close the sequence.

End of Exercise 4-5

TestStandIFundamentalsCourseManual

4-54

ni.com

Lesson 4 TestStand Parameters, Variables, and Expressions Exercises

Notes

©

National Instruments Corporation

4-55

TestStand I Fundamentals Course Manual

Lesson 4 TestStand Parameters, Variables, and Expressions Exercises

Notes

TestStandIFundamentalsCourseManual

4-56

ni.com

Lesson 5 Creating Test Modules in External Environments

Lesson 5:Creating Test Modu les in External Environments

In this lesson, you will learn how: • Data is passed between TestStand and external test modules • To create test modules in LabVIEW and LabWindows/CVI • To debug an external LabVIEW or LabWindows/CVI code module from TestStand • To modify code templates

Introduction In this lesson, you will learn how to create test modules in external environments for use in TestStand, and how data is transferred from TestStand to other environments. You will also examine the LabVIEW and LabWindows/CVI test development environments, learn how to pass data to TestStand from these environments, and debug these code modules directl y from TestStand.

©

National Instruments Corporation

5-1

TestStandI Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments

Creating Tests in External Environments • You can create tests in: – LabVIEW – LabWindows/CVI – Any environment capable of creating a DLL, EXE, ActiveX Automation server, or subroutine

• Each e ofas test a different adapter whichtyp acts anuses interface between TestStand and another environment to: – Execute test modules – Step into test modules – Generate code modules using templates

Creating Tests in External Environments TestStand is a flexible testing environment that can call tests written in a wide variety of languages. TestStand can call any test for which it has an adapter. An adapter is an interface that allows the TestStand Engine to communicate with a specific programming language or file format. Currently, TestStand has adapters for LabVIEW, LabWindows/CVI, Windows Dynamic Linked Libraries (DLLs), ActiveX Automation servers and HTBasic subroutines. Additionally, you can call Windows executable (.exe) files using a built-in step type. The following sections discuss how you can create tests in LabVIEW and LabWindows/CVI.

TestStandIFundamentalsCourseManual

5-2

ni.com

Lesson 5 Creating Test Modules in External Environments

Data Transfer in TestStand There are three ways to pass data from a test module to TestStand Method 1—Passing parameters directly using predefined structures TestStand

Data Space

Engine Test Module Error Data

• LabVIEW Adapter

Test Data

• LabWindows/CVI Adapter

Data Transfer in TestStand There are three ways to pass data between an external test module and TestStand: •

Pass parameters directly usingpredefined structures using LabVIEW and C/CVI Standard Prototype Adapters



Pass an arbitrary number of parameters using DLL Flexible Prototype Adapter, ActiveX



Automation Prototype Adapter, and Sequence Adapter Use ActiveX Automation API

Method 1—Passing Parameters Directly Using Predefined Structures This method uses structures, which appear as either clusters in LabVIEW or structures in text-based languages such as LabWindows/CVI. The most common structures are Test Data and Test Error. From the test module, data is passed into these structures. TestStand uses this information to perform operations such as error handling or result collection. This is the same method used in prior versions of the Test Executive Toolkits, making it possible for TestStand to call tests written for either LabVIEW or LabWindows/CVI Test Executives with no modification. If you want to pass additional parameters, you must use the ActiveX Automation API. The next few slides discuss Method 1, followed by a quick discussion of Method 2, and concluding with a discussion of Method 3.

©

National Instruments Corporation

5-3

TestStandI Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments

Using Clusters to Pass Data from LabVIEW Use LabVIEW type definitions • Input buffer • Invoke info • Sequence context • Test data

Using Clusters to Pass Data from LabVIEW The basic method for passing data is the same method used in previous versions of the Test Executive Toolkits. TestStand automatically installs a set of type definitions in the LabVIEW controls palette. These type definitions pass data between TestStand and the test VI. TestStand automatically looks for these data structures (called clusters in LabVIEW) in the VI connector pane when a step’s module is defined. Thus, passing data into or out of one of the type definitions makes it available to the TestStand Engine. The TestStand type definitions are explained below:

Input Buffer Type: String Control Purpose: To pass data into a VI. Data can be flattened into a string and then unflattened within LabVIEW for compatibility with LabVIEW data types.

TestStandIFundamentalsCourseManual

5-4

ni.com

Lesson 5 Creating Test Modules in External Environments

LabVIEW Type Definitions (Continued)

Invoke Info Type: Cluster of Five Controls



UUT Number: Integer



Loop Number: Integer



UUT Info: String



Test Name: String



Sequence Path: Path

Purpose: To provide basic information about the sequence and UUT to the test module.

Test Data Type: Cluster of Four Indicators



Pass/Fail Flag: Boolean



Numeric Measurement: Double



String Measurement: String



Report Text: String

Purpose: To pass data from the test to the TestStand Engine. TestStand also automatically reads data from a standard LabVIEW error cluster.

©

National Instruments Corporation

5-5

TestStandI Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments

Using Structures to Pass Data from LabWindows/CVI Data is passed from LabWindows/CVI to TestStand using a structure for Test Data and Test Error TestData

TestError

Result

Flag

Measurement InBuffer

Location Code

OutBuffer

Message

ModPath ModFile SeqContextCVI AdditionalData

Using Structures to Pass Data from LabWindows/CVI This method uses TestStand-defined structures to pass data between the TestStand Engine and LabWindows/CVI. The TestData structure contains the following parameters: •

Result—Pass/Fail Flag



Measurement—Numeric datatype of type double used for numeric tests



InBuffer—String passed in from TestStand (for compatibility)



OutBuffer—String passed out by test function to TestStand (appears in the report)



ModPath—Test module path



ModFile—Test module filename



SeqContextCVI—LabWindows/CVI Automation handle to the current context for the current sequence

TestStandIFundamentalsCourseManual

5-6

ni.com

Lesson 5 Creating Test Modules in External Environments

LabWindows/CVI Test Structures (Continued)

The TestError structure contains the following parameters: •

Flag—Pass/Fail flag



Code—Integer error code



Message—Error message string

Bear in mind the UUT. above structure is for reporting errors with the test system itself, not for test failures relatedthat to the In the following exercises, you will create a test in either LabVIEW or LabWindows/CVI using structures to pass results to TestStand, and you will learn how to debug and step into the test directly from TestStand.

©

National Instruments Corporation

5-7

TestStandI Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments

Data Transfer inTestStand Method 2—Passing parameters directly without using structures TestStand Engine

Data Space Data 1 Data 2

Test Module

• Flexible DLL Adapter • ActiveX Automation Adapter

Data Space Data 1 Data 2

• Sequence Adapter

Method 2—Passing Parameters Directly Without Using Structures Method 2 also passes information into TestStand using parameters. Unlike the LabVIEW and C/CVI Standard Prototype adapters, the DLL Flexible Prototype Adapter, ActiveX Automation Prototype Adapter, and Sequence Adapter do not rely on structures to pass these parameters. These three adapters can specify an arbitrary number of parameters that should be passed from the code module back into TestStand. Although parameters are still being used to pass the data between code modules and TestStand, this ability to specify an arbitrary number of parameters sets Method 2 apart from the process described in Method 1.

TestStandIFundamentalsCourseManual

5-8

ni.com

Lesson 5 Creating Test Modules in External Environments

Exercise 5-1A, 5-1B, or 5-1C 5-1A Objective: To create a pass/fail test in LabVIEW and pass the test results to a TestStand step using structures 5-1B Objective: To create a pass/fail test in LabWindows/CVI and pass the test results to a TestStand step using structures 5-1C Objective: To create a pass/fail test in a DLL and pass the result to a TestStand step using the DLL Flexible Prototype Adapter Approximate time to complete: 35 minutes

©

National Instruments Corporation

5-9

TestStandI Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments

Exercise 5-2A, 5-2B, or 5-2C 5-2A Objective: To create a numeric test in LabVIEW and pass the test results to a TestStand step using structures 5-2B Objective: To create a numeric test in LabWindows/CVI and pass the test results to a TestStand step using structures 52-C Objective: To create a numeric test in a DLL called with the DLL Flexible Prototype Adapter Approximate time to complete: 15 minutes

TestStandIFundamentalsCourseManual

5-10

ni.com

Lesson 5 Creating Test Modules in External Environments

Exercise 5-3A, 5-3B, or 5-3C 5-3A Objective: To debug a LabVIEW test 5-3B Objective: To debug a LabWindows/CVI test 5-3C Objective: To debug a DLL test that is called with the DLL Flexible Prototype Adapter Approximate time to complete: 10 minutes

©

National Instruments Corporation

5-11

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments

Data Transfer in TestStand Method 3—Using the ActiveX Automation API to access properties and methods •Property: An attribute of the object that can be set •Method: An action on the object that can be invoked

Test Module TestStand Engine

TestStand ActiveX Object

Step Properties

Test Program

TestStand Variables

•Any programm ing language thatsupports ActiveX

Method 3—Using the ActiveX Automation API to Access Properties and Methods Another method to pass data between a test module and TestStand is to use ActiveX Automation. ActiveX Automation is a standard method for passing data between Windows applications. It allows one application to pass data to or control another application by changing its properties and calling its methods. An ActiveX application can be thought of as an object used within another environment. A property is an attribute of the object that you can set or change. A method is a function of the object that can be invoked. Using ActiveX, an object of the sequence context can reside in the test module. When executing sequences, TestStand maintains a sequence context that contains references to all global variables, local variables, and step properties in active sequences. The contents of the sequence context change depending on the currently executing sequence and step. If you pass a sequence context object reference to the code module, you can use the TestStand ActiveX API to access the variables and properties in the sequence context. By setting properties and invoking methods, you can pass data between the test module and the TestStand sequence, and set or change various TestStand attributes from within the test module itself.

TestStandIFundamentalsCourseManual

5-12

ni.com

Lesson 5 Creating Test Modules in External Environments

What is ActiveX Automation? • Microsoft technology for inter-application communication • Evolution of Object Linking and Embedding (OLE) and part of Component Object Model (COM) strategy • Allows one application to control or pass data to another application

What is ActiveX Automation? ActiveX is a set of Microsoft technologies widely used for interapplication communication. ActiveX gives you the freedom to share data between applications or control one application from another, programmatically. It provides a standard interface and framework for communicating between different applications. Rather than developing a particular functionality within an application, you use ActiveX to leverage that functionality from another application. In TestStand, the ActiveX API uses the Sequence Context object reference to pass the following data: •

Type: ActiveX Automation reference handle.



Purpose: You can wire this reference into a Set Property or Invoke Node to access TestStand properties and methods pertaining to the sequence being executed (this topic is addressed in greater detail later).

©

National Instruments Corporation

5-13

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments

Summary of ActiveX Automation • ActiveX servers export a set of properties (variables) and methods (functions) • ActiveX clients can access the properties and methods from any server Ac tiveX Client

ActiveX Client Properties, Methods

ActiveX Server

Summary of ActiveX Automation ActiveX applications can be either an ActiveX server or an ActiveX client. ActiveX servers are applications that export an Application Programming Interface (API) or a set of properties and methods to other applications. Think of properties as variables —their values can be read or set. Methods are like functions—they perform a certain action when invoked. ActiveX clients are programs capable of getting/setting properties and invoking methods of a server. Hence, ActiveX clients can control the behavior and update the variables of the ActiveX server.

TestStandIFundamentalsCourseManual

5-14

ni.com

Lesson 5 Creating Test Modules in External Environments

TestStand and ActiveX Automation • The TestStand Engine itself is an ActiveX server

Sequence Editor

Operator Interface

(ActiveX Clients)

• The Sequence Editor and operator interfaces are ActiveX clients • In addition, test modules can also be ActiveX clients (to access properties and methods of the engine)

TestStand Engine (ActiveX Server)

LV Test

CVI Test

VB Test

(ActiveX Clients)

TestStand and ActiveX Automation The TestStand Engine is an ActiveX server, which exports an ActiveX Application Programming Interface (API). The Sequence Editor and operator interfaces can create, edit, execute, and debug sequences. In addition, test modules can also access the TestStand Engine ActiveX API to get/set the values of TestStand variables or to invoke certain methods. An example of a TestStand property is the value of a local or global variable. These values are maintained by the TestStand Engine, but can be accessed by an Operator Interface, Sequence Editor, or code module. Some examples of TestStand methods are (DisplayLoginDialog) and (UnloadAllModules), which ActiveX clients can call the TestStand Engine to execute.

©

National Instruments Corporation

5-15

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments

ActiveX Automation in LabVIEW • TestStand installs a palette of ActiveX VIs • These VIs access common TestStand properties • For all other properties and methods (used for creating advanced applications or a custom user interface), use the LabVIEW property and invoke nodes

ActiveX Automation in LabVIEW TestStand installs a palette of VIs for accessing common TestStand properties, including getting or setting the value of any TestStand numeric, string, Boolean, or array. All other TestStand properties and methods are accessible using the LabVIEW Invoke Node and Property Node, in the Communication»ActiveX subpalette. You can find additional information on the LabVIEW ActiveX capability in theG Programming Reference Manual. Note To use TestStand 2.0 VIs with LabVIEW, you must have LabVIEW 5.1 or later.

TestStandIFundamentalsCourseManual

5-16

ni.com

Lesson 5 Creating Test Modules in External Environments

An Example of ActiveX Automation in LabVIEW

An Example of ActiveX Automation in LabVIEW This slide is an example of using ActiveX Automation within LabVIEW to get an d set the value of TestStand variables. The ActiveX Automation handle, Sequence Context, is a refnum passed to the VI from TestStand. It gives the VI a reference to the TestStand sequence that called it. The first subVI, Get Property Value, gets the value of a TestStand local variable, in this case a Boolean variable named Instrument State. The second subVI,Set Property Value, sets the value of a subproperty of the step that called this code module. The subproperty in this case is a numeric value named Numeric.

©

National Instruments Corporation

5-17

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments

ActiveX Automation in LabWindows/CVI TestStand API instrument driver • TestStand provides a LabWindows/CVI instrument driver to access TestStand properties and methods • The instrument driver is a LabWindows/CVI function panel • TestStand properties and methods are set by calling the appropriate functions from within LabWindows/CVI

ActiveX Automation in LabWindows/CVI The instrument driver is a set of function panels and modules containing functions for accessing all TestStand properties and methods. Remember that when you are in the LabWindows/CVI environment, you may need functions from the LabWindows/CVI ActiveX Automation library to convert data types returned from the TestStand instrument driver. It is also important to remember that by using ActiveX Automation, you have access to not only the data relevant to the specific code contained within a test, but also to many of the TestStand environment attributes and functions, thereby allowing changes to sequence information during run-time.

TestStandIFundamentalsCourseManual

5-18

ni.com

Lesson 5 Creating Test Modules in External Environments

An Example of ActiveX Automation in LabWindows/CVI

An Example ActiveX Automation in In LabWindows/CVI This slide shows an example of a LabWindows/CVI function panel for the PropertySetValNumber function. It takes in a LabWindows/CVI sequence context (passed by the TestStand step that calls the module), a Lookup String, and a New Numeric Value. This example sets the value of the local variableNum1 to 5.0. In the next set of exercises, you will use ActiveX to pass data within either LabVIEW or LabWindows/CVI.

©

National Instruments Corporation

5-19

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments

Exercise 5-4A, 5-4B, or 5-4C 5-4A Objective: To use ActiveX in LabVIEW test modules to pass data to TestStand 5-4B Objective: To use ActiveX in LabWindows/CVI test modules to pass data to TestStand 5-4C Objective: To use the ActiveX API to pass data from DLLs called with the DLL Flexible Prototype Adapter to TestStand Approximate time to complete: 20 minutes

TestStandIFundamentalsCourseManual

5-20

ni.com

Lesson 5 Creating Test Modules in External Environments

Exercise 5-5A or 5-5B 5-5A Objective: To write a simple Numeric Limit Test that uses the LabVIEW Standard Prototype Adapter

5-5Buses Objective: To write a simple Numeric Limit Test that the C/CVI Standard Prototype Adapter Approximate time to complete: 20 minutes

©

National Instruments Corporation

5-21

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments

Exercise 5-6A or 5-6B 5-6A Objective: To use the TestStand API to pass data between TestStand andLabVIEW 5-6B Objective: To use the TestStand API to pass data between TestStandand LabWindows/CVI Approximate time to complete: 35 minutes

TestStandIFundamentalsCourseManual

5-22

ni.com

Lesson 5 Creating Test Modules in External Environments

Exercise 5-7 5-7 Objective: To pass data between TestStand and your test module using the DLL Flexible Prototype Adapter Approximate time to complete: 35 minutes

©

National Instruments Corporation

5-23

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments

Using TestStand Code Templates • TestStand allows test developers to create code in an externalenvironment from within the Sequence Editor • Each adapter and step type has an associated code template:

– Use the code template to create default test code – Use TestStand’s Create Code feature to eliminate redundantprogramming

Using TestStand Code Templates Another powerful feature of TestStand is the ability to create tests in LabVIEW or Create Code option LabWindows/CVI from within the TestStand Sequence Editor. Selecting the in the Specify Module dialog box creates code using a default code template for the respective programming environment. TestStand even allows you to customize this template to include any necessary code for each test of a certain type, or you might associate a number of templates with each step type. If you define more than one template for a step type, TestStand prompts you to choose one from a list when you selectCreate Code. This feature allows you to develop your test sequences in an efficient and consistent way.

TestStandIFundamentalsCourseManual

5-24

ni.com

Lesson 5 Creating Test Modules in External Environments

Code Templates • Code templates are configured through the step type properties found in the Type Palette • Code template code is stored in the TestStand\Code Templates directory

Code Templates Code templates are created and configured from theCode Templates tab of the step type properties dialog box in the TestStand Type Palette. The lesson on TestStand types later in this course discusses customizing step types and the Type Palette in detail. The actual code for each template is in the TestStand\Code Templates directory.

©

National Instruments Corporation

5-25

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments

Lesson 5 Summary:Creating Test Modules in External Environments • There are three ways to pass data between the TestStand Engine and test modules: – Using predefined structures – Passing arbitrary number of parameters – Using the ActiveX Automation API exported by the TestStand Engine

• TestStand eliminates redundant programming by allowing users to specify default code based on code templates

Summary In the previous lesson, you learned how to share data between sequence steps (locals), multiple sequences (sequence globals), and sequence files (station globals). In this lesson, you learned how to share data between TestStand and test modules developed in another programming environment. You can use structures, as used in National Instruments Test Executive Toolkits, you can use an arbitrary number of parameters, or you can leverage the ActiveX capabilities of the engine (server) and development environments such as LabVIEW, LabWindows/CVI, or Visual Basic (clients). The first two options are dependent on which Adapter you chose to call the code module. The last option depends upon how you write the code module itself. TestStand also includes a method to reduce redundant programming. Using code templates, test module developers can duplicate common components used throughout their test modules. Note If you are using either LabWindows/CVI or LabVIEW, you can use National Instruments IVI driver technology to perform test software development without requiring instrumentation hardware. This instrument driver technology provides features such as state caching, simulation, and an attribute model for convenient test development. For more information about IVI, refer to Appendix A.

TestStandIFundamentalsCourseManual

5-26

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

Exercise 5-1A Creating Pass/Fail Tests in LabVIEW Objective:

To create a pa ss/fail test in LabVIEW and pass the re sults to a TestStand step. It is important to understand the different types of tests you can create in TestStand. Previous lessons have shown how to link specific code modules to each step and create steps that call different types of code modules. This exercise shows how to create one particular type of test called a Pass/Fail test. You will create a VI that simulates the Keyboard Diagnostic test. The VI displays a message popup when it executes. This exercise also demonstrates another of TestStand’s powerful and unique abilities. Previous exercises have shown that TestStand can use code modules written in a variety of languages. However, this exercise shows that TestStand can create some of the code for these code modules using templates. Currently, TestStand can create code in LabVIEW and LabWindows/CVI. This code contains only the minimum code required for TestStand to interact successfully with the code module. The generated code modules serve as starting points for users to add their specific code when generating their customized test modules.

Part A: Creating the LabVIEW Test 1. Select File»Open from the Sequence Editor and open C:Exercises\TestStand I\Ex 5-1A Creating PassFail Tests with LabVIEW.seq. This sequence is similar to the one used in previous exercises, except that it is missing theKeyboard Diagnostics step. The rest of this exercise describes how to create this step. 2. Be sure the LabVIEW Standard Prototype Adapter is selected in the Adapter Selector Ring, as shown below.

In the sequence window, right-click below the existing steps and select Insert Step»Tests»Pass/Fail Test. This inserts a Pass/Fail step for the LabVIEW Adapter at the bottom of the sequence. Name the test

Keyboard Diagnostics. 3. Right-click on the step and select Specify Module. This brings up the LabVIEW Step Module Information dialog box. For the VI Pathname, click the Browse button, type in the VI nameEx 5-1A Keyboard

©

National Instruments Corporation

5-27

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

Diagnostics.vi, and select the C:\Exercises\TestStand I \VIs directory. Notice that the search returnsFile not found . This is because the VI for this module is not yet created. The resulting screen should appear as shown.

4. Check Show VI Front Panel When Called . Click the Create VI… button. When prompted for the pathname, be sure that the

C:\Exercises\TestStand I\VIs\ directory is selected and then click OK to confirm that the VI should be created in theVIs subdirectory.

TestStandIFundamentalsCourseManual

5-28

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

A useful method to store the paths to code resources is relative to the sequence file. Relative paths are preferred so that if the files are ever moved, the code modules can still be found as long as they are all moved together. For example, this situation happens frequently when the test sequence is moved from the development machine to the testing machine, where drive names and directory structures could be completely different. At this point, LabVIEW is launched and a VI created using the code template for the Pass/Fail step type. The VI is namedEx 5-1A Keyboard Diagnostics.vi. Ex 5-1A Keyboard Diagnostics.vi outputs a standard error cluster containing runtime error information.

The Test Data cluster returns information about the test status itself. If the test module passes or fails, this information is returned in the Boolean element of the Test Data cluster. The Test Data cluster contains a Boolean value, a numeric value, and a string value. One of these three values is used to check the results of this test, depending on what step type is used to call this code module. In this case, the Pass/Fail step type was chosen so that the Boolean value is checked. The block diagram on the following page shows how to wire the Boolean value into this cluster. The last control in this cluster is theReport Text. A string can be passed out of this control for information to be displayed in the report. This information can be helpful in the report to help the operator determine why a test passed or failed. 5. These controls are also wired to the connector pane when using the Create VI option. Test Data is wired to the upper terminal and error out is wired to the lower terminal, as shown.

©

National Instruments Corporation

5-29

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

6. Build the block diagram as shown. The One button Dialog VI is in the Functions»Time and Dialog subpalette. Create a string constant and type in the message as displayed. TestStand - Create Test Data Cluster.vi should already be in the diagram; if not, it is in theFunctions»User Libraries»TestStand subpalette.

TestStandIFundamentalsCourseManual

5-30

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

7. Save the VI as Ex 5-1A KeyBoard Diagnostics.vi.

End of Part A Part B: Configuring the Step Properties 1. Now that you have created the step and added the code, all that remains is to add the proper precondition to this step. The Keyboard Diagnostics step should execute only if the Keyboard step fails and the Powerup and CPU test have passed. Double-click on the Keyboard Diagnostics step to open the Keyboard Diagnostics Pass Fail Test Properties dialog box. Click the Preconditions button. Set the preconditions as shown below. a. Click Powerup Test in the Insert Step Status section. b. Click Insert Step Pass. c. Click CPU Test. d. Click Insert Step Pass again. e. When prompted to insert AllOf or AnyOf, choose AllOf. f. Click Keyboard Test. g. Click Insert Step Fail.

©

National Instruments Corporation

5-31

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

h. Click OK to complete setting the precondition for this new step. 2. Execute the sequence by selecting Execute»Test UUTs or clicking the Test UUTs button in the toolbar. When you select the Keyboard Test to Fail, a dialog box appears. ClickOK to continue with the execution. 3. When finished with the exercise, save the sequence file and close the sequence file window.

End of Part B Part C: Using LabVIEW DLL You have just finished configuring a Pass/Fail step that uses a VI as the code module. LabVIEW provides the added capability of building a VI into a dynamic link library (DLL). In Part C, you will make use of this capability and use TestStand’s DLL Flexible Prototype Adapter to call that DLL. Recall that previously in this exercise you were using theLabVIEW Standard Prototype Adapter to call VIs from TestStand. 1. You will use the VI that you have created earlier in this exercise and build it into a DLL. Open a new VI in LabVIEW. SelectTools»Build Application or Shared Library (DLL)… to open the Build Application or Shared Library (DLL) - New script dialog box.

TestStandIFundamentalsCourseManual

5-32

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

2. On the Target tab within the New script dialog box, specify the name to give to the DLL and its location. a. Change the Build target to Shared Library (DLL). b. Change Target file name to Ex 5-1A Keyboard Diag.dll. c. Rename Destination directory to C:\Exercises\Teststand I \VIs. When you build the DLL, it will be placed in this directory. Note that when you change directories, theSupport file directory field is automatically updated toC:Exercises\Teststand I \VIs\data. d. Leave other options set to default. Note that under Build Options, the default selection is to createSingle target file containing all VIs. 3. The resulting New script dialog box should resemble the following image.

©

National Instruments Corporation

5-33

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

4. Select the Source Files tab in the New script dialog box. Here, you need to specify the name of the VI that is to be used to build the DLL. Click on Add Exported VI to bring up the file selection dialog window. Browse to C:\Exercises\Teststand I\VIs directory and select Ex 5-1A Keyboard Diagnostics.vi. Note that as soon as you make the selection by clickingOpen from the file dialog window, LabVIEW brings up the Define VI Prototype dialog box. 5. In the Function Name text field, enter KeyboardDiagnostics. This is the name that will be given to the function that will contain the code for Ex 5-1A Keyboard Diagnostics.vi in the DLL. 6. Note that the default calling convention is set to C Calling Conventions. The VI does not have any input parameters but it does have output values. To specify the error out and TestData outputs, click the “+” button next to the Parameters listbox. Select error out from the VI Output selector for the first output parameter. Click the“+” button again to add the TestData output parameter. The Define VI Prototype dialog should now appear as shown.

TestStandIFundamentalsCourseManual

5-34

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

7. Select OK to complete defining the function prototype. This takes you back to the the Source Files tab in the New script dialog box. 8. You are now ready to build the DLL. SelectBuild. This shows the progress bar and when complete it will indicateBuild finished! Three files are created: Ex 5-1A Keyboard Diag.dll, Ex 5-1A Keyboard Diag.h, and Ex 5-1A Keyboard Diag.lib. Note If this is the second time you are creating a DLL in the same location, you will

receive a message indicating that you the previously created DLLs and its supporting filesor will be overwritten. At this point can either continue and overwrite existing files cancel the build operation. 9. Launch the TestStand Sequence Editor. Select File»Open to open the following sequence file:C:\Exercises\Teststand I\Ex 5-1A Creating PassFail Tests with LabVIEW (Part C).seq . This sequence file already contains the Keyboard Diagnostics Pass/Fail step using the DLL Flexible Prototype Adapter. You are now going to configure the Keyboard Diagnostics step so that it calls the DLL function that we have just built using LabVIEW. 10. Right-click on the Keyboard Diagnostics step and selectSpecify Module… to display the Edit DLL Call dialog box. a. For DLL Pathname, browse and select C:\Exercises\Teststand I\VIs\Ex 5-1A Keyboard Diag.dll. b. For Function Name, select KeyboardDiagnostics from the pull down list.

©

National Instruments Corporation

5-35

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

c. Select C(cdec1) for the Calling Convention. d. Add the error out parameter by selecting the New button. Type Error Out for the parameter name, SpecifyLocals.Error for the Value Expression. Choose C Struct for the Category. Select CustomError for the Struct Type. The dialog should appear as follows.

e. Add the TestData parameter by selecting the New button. Type in testData for the parameter name. SpecifyLocals.TestData for the Value Expression. Choose C Struct for the Category. Select TestData for the Struct Type. The dialog box should appear as follows.

TestStandIFundamentalsCourseManual

5-36

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

Note When using the C Struct category you must have the corresponding datastructure defined within the TestStand environment and have theAllow Objects of This Type to be Passed as Structs data type property enabled. This was already taken care of for this exercise. For more information regarding C Structs as parameters, please see the TestStand User Manual.

11. Select OK . Execute the sequence by selectingExecute»Test UUTs. When you select the Keyboard Test to Fail, a dialog box should appear. Select OK to continue with the execution. 12. When finished with the exercise, save the sequence file and close the sequence file window.

End of Part C End of Exercise 5-1A

©

National Instruments Corporation

5-37

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

Exercise 5-1B Creating Pass/Fail Tests with LabWindows/CVI Objective:

To create a pass/fail test in LabWindows/CVI and pass the results to a TestStand step. It is important to understand the different types of tests you can create in TestStand. Previous lessons have shown how to link specific code modules to each step and create steps that call different types of code modules. This exercise shows how to create one particular type of test called a pass/fail test. You will create a function that simulates the Keyboard Diagnostic test. The function displays a message popup when it executes. This exercise also demonstrates another of TestStand’s powerful and unique abilities. Previous exercises have shown that TestStand can use code modules written in a variety of languages. However, this exercise shows that TestStand can create some of the code for these code modules using templates. Currently, TestStand can create code in LabVIEW and LabWindows/CVI. This code contains only the minimum code required for TestStand to interact successfully with the code module. The generated code modules serve as starting points for users to add their specific code when generating their customized test modules.

Part A: Creating the LabWindows/CVI Test Module 1. Launch the Sequence Editor. Select File»Open and select the sequence file C:Exercises\TestStand I\Ex 5-1B Creating PassFail Tests with CVI.seq. This sequence is the same as one that has been used in previous exercises, except that it is missing theKeyboard Diagnostics step. In the rest of this exercise, you will create this step. 2. Add a new step to the bottom of Main Sequence. Make sure the C/CVI Standard Prototype Adapter is selected in the Adapter Selection Ring.

TestStandIFundamentalsCourseManual

5-38

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

Right-click below the steps of the sequence and selectInsert Step»Tests»Pass/Fail Test. This inserts a Pass/Fail test for the LabWindows/CVI Standard Prototype Adapter with the default name Pass/Fail Test at the bottom of the sequence. 3. Name the step Keyboard Diagnostics. Right-click on the step and select Specify Module. This brings up the LabWindows/CVI Step Module Information dialog box, as shown below. Notice that you can call code module types compiled into DLLs, static libraries, or object files. In addition, you can specify*.c files that use a special LabWindows/CVI project file to compile the code dynamically for use by TestStand. Set theModule Type ring to Object File (*.obj). For the Module Pathname, type in CVI Project Files\Keyboard Diagnostics.obj. For the Function Name, type in KeyboardDiagnostics. Make sure that Standard Prototype is selected. Notice that the search returnsFile not Found . This is because the code for this module is not created yet. The resulting screen should appear as shown below.

4. Click on the Source Code tab. For the Pathname of Source File Containing Function, type in CVI Project Files\Keyboard Diagnostics.c. For the Pathname of CVI Project File to Open , type in CVI Project Files\Keyboard Diagnostics.prj. Notice that the source code file and project file do not yet exist. This exercise will show how to create these files. Click onCreate Code.

©

National Instruments Corporation

5-39

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

When prompted, clickOK to confirm that the project file should be created in the C:\Exercises\TestStand I\CVI Project Files subdirectory. Make sure this subdirectory is selected; if not, select this directory before clickingOK .

TestStandIFundamentalsCourseManual

5-40

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

5. Save the source code file in the \CVI Project Files\ directory where the Keyboard Diagnostics.prj is located.

This launches LabWindows/CVI and creates a source file .c ( ) named Keyboard Diagnostics.c. Inside this source file is the template for the function that must be created, calledKeyboardDiagnostics.

6. Make a simulation for the keyboard diagnostic. For this exercise, create a test with a Message Popup that displays the message “This is the Keyboard Diagnostic Test” when this test runs. You created most of this code earlier by clicking on theCreate Code button.

©

National Instruments Corporation

5-41

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

After the line int error = 0; add the KeyboardDiagnostic test using the MessagePopup function panel and the parameters shown below: MessagePopup ("Message Popup", "This is the keyboard diagnostic test");

After the line Error:, type in the error information as shown below: testError->errorFlag=FALSE; testData->result = PASS;

The C/CVI test functions use two pointers to structures to pass data between TestStand and the test functions. In the KeyboardDiagnostics test, testError->errorFlag is set, which indicates whether a run-time error occurred. The other structure,testData->result, indicates whether the Unit Under Test passed or failed the test. The resulting screen should appear as shown below.

Save the source file. The nameKeyboard Diagnostics.c should already be selected. 7. The source code file should have been added to the project file automatically. If not, add Keyboard Diagnostics.c to the project by selecting File»Add File to Project from the Keyboard Diagnostics.c window.

TestStandIFundamentalsCourseManual

5-42

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

8. Create an object file from Keyboard Diagnostics.c by selecting Options»Create Object File from the Keyboard Diagnostics.c window. Click OK to create the object file for the Current Compatibility Mode. 9. Save and close the source and project file and exit LabWindows/CVI.

End of Part A Part B: Configuring the Step Properties 1. In the TestStand Sequence Module Call dialog box. Editor, click OK to exit the Edit C/CVI 2. Remember that the Keyboard Diagnostics step should execute only if the Keyboard Test step fails and the Powerup Test and CPU Test steps have passed. Double-click on theKeyboard Diagnostics step to open the Keyboard Diagnostics PassFailTest Properties dialog box. Click thePreconditions button. Set the preconditions as shown below. a. Click Powerup Test in the Insert Step Status section. b. Click Insert Step Pass. c. Click CPU Test. d. Click Insert Step Pass again. e. When prompted to insert AllOf or AnyOf, choose Insert AllOf.

©

National Instruments Corporation

5-43

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

f. Click Keyboard Test. g. Click Insert Step Fail.

3. Click OK to exit the Preconditions dialog box. Then, clickOK to exit the Properties window. 4. Save the sequence as C:\Exercises\TestStand I\Ex 5-1B Creating PassFail Tests in CVI.seq. Execute the sequence by selecting Execute»Test UUTs or by pressing the Test UUTs button in the toolbar. Notice that when the Keyboard Test is selected to fail, a message popup is displayed. ClickOK to continue with the execution.

End of Part B Part C: Create a DLL Code Module for the Keyboard Diagnostic Test 1. National Instruments recommends using DLL files rather than object files for test modules. Using LabWindows/CVI, open C:\Exercises\TestStand I\CVI Project Files\Keyboard Diagnostics.prj if you closed it before. 2. From the LabWindows/CVI project window, ensure that the project target is set for Dynamic Link Library under theBuild»Target Type menu.

TestStandIFundamentalsCourseManual

5-44

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

3. Ensure that the DLL to be built is configured as a release version of the DLL by selecting Build»Configuration»Release. 4. Confirm the DLL target settings by selecting Build»Target Settings. Make certain the settings match those in the figure below.

5. Verify which functions LabWindows/CVI exports by clicking the Change button in the Exports area. Be sure to selectSymbols Marked for Export, as shown.

6. The KeyboardDiagnostics function is marked for export with the dllexport definition. ClickOK to close the DLL Export Options window. To close the Target Settings window, clickOK again. 7. Create a DLL by selecting Build»Create Release Dynamic Link Library.

8. In the Sequence Editor, right-click on the Keyboard Diagnostics step and select Specify Module. Change the Module Type ring to

©

National Instruments Corporation

5-45

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

Dynamic Link Library (*.dll). Notice that the extension is changed automatically, and TestStand also finds the newly createdKeyboard Diagnostics.dll.

9. Click OK to leave the Edit C/CVI Module Call dialog box. Execute the sequence to verify that it behaves the same as when using an object file. 10. Note that if you try to rebuild the DLL while an application such as the Sequence Editor is using it, you will get a“file access permission denied” error. In the Sequence Editor, selectFile»Unload All Modules to unload the DLL, allowing you to rebuild it if necessary. 11. When finished with the exercise, save and close the sequence file. Save all files and quit LabWindows/CVI.

End of Part C End of Exercise 5-1B

TestStandIFundamentalsCourseManual

5-46

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

Exercise 5-1C Creating Pass/Fail Tests for the DLL Flexible Prototype Adapter Objective:

To create a p ass/fail test in a DLL and pa ss the result to a TestStand step usi ng the DLL Flexible Prototype Adapter. It is important to understand the different types of tests you can create in TestStand. Previous lessons have shown you how to link specific code modules to each step and create steps that call different types of code modules. This exercise shows you how to create one particular type of test called a pass/fail test. You will create a function that simulates the Keyboard Diagnostic test. The function displays a message popup when it executes. This exercise also demonstrates another of TestStand’s powerful and unique abilities. Previous exercises have shown that TestStand can use code modules written in a variety of languages. This exercise shows that TestStand can create some of the code for these code modules using templates. Currently, TestStand can create code in LabVIEW and LabWindows/CVI. The code that TestStand creates contains only the minimum code required for TestStand to interact successfully with the code module. The generated code modules serve as starting points for users to add their specific code to when they create their customized test modules.

Part A: Creating the Test Module 1. Launch the Sequence Editor. Select File»Open and select the sequence file C:\Exercises\TestStand I\Ex 5-1C Creating PassFail Tests with DLL Adapter.seq. This sequence is the same as one that has been used in previous exercises, except that it is missing the Keyboard Diagnostics step. In the rest of this exercise, you will create this step. 2. Select the DLL Flexible Prototype Adapter and insert a new step at the bottom of the MainSequence. Right-click below the steps of the sequence and selectInsert Step»Tests»Pass/Fail Test as shown below. This inserts a Pass/Fail Test that uses the DLL Flexible Prototype Adapter with the default name Pass/Fail Test at the bottom of the sequence. 3. Name the step Keyboard Diagnostics. Right-click the step and select Specify Module. This displays the Edit DLL Call dialog box, as shown below. For DLL Pathname, type in CVI Project Files\Ex 5-1C Keyboard Diagnostics.dll. For the Function Name, type in KeyboardDiagnostics. Notice that the search for DLL Pathname returns File not found . This is because the code for this module is not created yet. The resulting screen should appear as shown.

©

National Instruments Corporation

5-47

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

4. Click the Source Code tab. For the Pathname of Source File Containing Function, type in CVI Project Files\Ex 5-1C Keyboard Diagnostics.c. Notice that the source code file does not yet exist. To create the source code file, clickCreate Code. The following dialog box appears.

TestStandIFundamentalsCourseManual

5-48

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

Click OK to confirm that the source file should be created in the C:\Exercises\TestStand I\CVI Project Files\ subdirectory. If this directory is not selected, navigate to this directory before clicking OK . You may be prompted to set the path reference. A useful method to store the paths to code resources is relative to the sequence file, so select the option Use a relative path for the file you selected. Relative paths are preferred so that if the files are ever moved, the code modules can still be found as long as the files are moved together. For example, this situation happens frequently when the test sequence is moved from the development machine to the testing machine, where drive names and directory structures could be completely different. 5. TestStand will prompt you to choose a code template. Select TestStand pass/fail template and press OK. A code template is a source file that contains skeleton code. The skeleton code serves as a starting point for the development of code modules for steps that use the step type.

This launches LabWindows/CVI and creates a source file .c ( ) named Ex 5-1C Keyboard Diagnostics.c. The source file contains the Keyboard Diagnostics function that you created. If you get a dialog box asking you to open the created file in Notepad, click No . 6. Open LabWindows/CVI if it is not already open. Select File»Open» Project and open the project file C:\Exercises\TestStand I\CVI Project Files\Ex 5-1C Keyboard Diagnostics.prj. If prompted, clickYes to unload the current project andOK to transfer the project options. 7. In the Ex 5-1C Keyboard Diagnostics.prj window, you should see that Ex 5-1C Keyboard Diagnostics.c is already included in the project. If it displays File not found, highlight Ex 5-1C Keyboard Diagnostics.c and select, Edit»Remove File. Then select

©

National Instruments Corporation

5-49

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

Edit»Add Files to Project »Source and add the source file C:\Exercises\TestStand I\CVI Project Files\Ex 5-1C Keyboard Diagnostics.c. Click the OK button to add this file to the project.

8. In the LabWindows/CVI Project window, double-click Ex 5-1C Keyboard Diagnostics.c to open the source code window as shown below.

9. Make a simulation for the keyboard diagnostic. For this exercise, create a test with a Message Popup that displays the message “This is the Keyboard Diagnostic Test” when this test runs. You created most of this code earlier by clicking on the Create Code button. After the line int error = 0; use the MessagePopup function panel to insert the following code: MessagePopup ("Message Popup", "This is the keyboard diagnostic test"); *result = PASS;

After the line Error: type in the error information as shown below: *errorOccurred = FALSE;

TestStandIFundamentalsCourseManual

5-50

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

The DLL test function uses pointers to pass data between TestStand and the test function. In theKeyboardDiagnostics test, *errorOccurred is set, which indicates whether a run-time error occurred. The other pointer, *result, indicates whether the Unit Under Test passed or failed the test. The resulting screen should appear as shown below.

10. Save the source code file then close it. 11. In the project window, ensure that the project target is set for Dynamic Link Library under the Build»Target Type menu. 12. Ensure that the DLL to be built is configured as a release version of the DLL by selecting Build»Configuration»Release.

©

National Instruments Corporation

5-51

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

13. Confirm the DLL target settings by selectingBuild»Target Settings. Make certain the settings match those in the figure below.

14. Verify which functions LabWindows/CVI exports by clicking the Change button in the Exports area. Be sure to selectSymbols Marked for Export, as shown below.

15. The KeyboardDiagnostics function is marked for export with the dllexport definition. ClickOK to close the DLL Export Options window. To close the Target Settings window, clickOK again. 16. Create a DLL by selectingBuild»Create Release Dynamic Link Library.

TestStandIFundamentalsCourseManual

5-52

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

End of Part A Part B: Configuring the Step Properties 1. Return to the sequence editor. Notice that in all of the pathname dialogs, the modules are now found in the proper directories, because they have been created. Click OK to exit the Edit DLL Module Call dialog box. 2. The Keyboard Diagnostics step should execute only if the Keyboard Test step fails and the Powerup Test and CPU Test steps have passed. Double-click on theKeyboard Diagnostics step. Click the Preconditions button. Set the preconditions as shown below. a. Click Powerup Test in the Insert Step Status section. b. Click Insert Step Pass. c. Click CPU Test. d. Click Insert Step Pass again. e. When prompted to insert AllOf or AnyOf, choose Insert AllOf.

©

National Instruments Corporation

5-53

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

f. Click Keyboard Test. g. Click Insert Step Fail.

3. Click OK to exit the Preconditions dialog box. ClickOK again to exit the Step Properties dialog box. 4. Save the sequence as C:\Exercises\TestStand I\Ex 5-1C Creating PassFail Tests with DLL Adapter.seq. Execute the sequence by selectingExecute»Test UUTs or by pressing the Test UUTs button in the toolbar. Notice that when the Keyboard Test is selected to fail, a message popup is displayed. ClickOK to continue. Click Stop to end the execution.

End of Part B End of Exercise 5-1C

TestStandIFundamentalsCourseManual

5-54

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

Exercise 5-2A Creating Numeric Limit Tests with LabVIEW Objective:

To create a code module for a numeric limit test that simulates a video diagnostic test. This exercise shows how to create another type of test in TestStand called a numeric limit test. Additionally, it demonstrates one way to add information to the test report. The code module passes numeric data and a Report Text string back to TestStand. TestStand compares the numeric data to predefined limits and determines whether the test passed or failed. The Report Text string is displayed in the report.

Part A: Creating the LabVIEW Test 1. Launch the Sequence Editor. Select File»Open from the Sequence Editor and navigate to C:Exercises\TestStand I\. Open Ex 5-2A Creating Numeric Limits Tests with LabVIEW.seq. This sequence file is the same as ones used in previous exercises, except it is missing the Video Diagnostics step. The rest of this lesson describes the procedure to create this step. 2. Make sure the LabVIEW Standard Prototype Adapter is selected in the Adapter Selector Ring.

3. Right-click on the RAM Diagnostics step and select Insert Step»Tests»Numeric Limit Test. This inserts a Numeric Limit Test for the LabVIEW Standard Prototype Adapter between the RAM Diagnostics step and the Keyboard Diagnostics step. Name this step Video Diagnostics. 4. This exercise describes how to create a LabVIEW test that returns a random numeric value and a Report Text string. The default limits of 0 for minimum and 10 for maximum are used to evaluate the pass/fail conditions based on the numeric measurement returned from the test. To

©

National Instruments Corporation

5-55

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

view the limits, right-click on the step and select the Edit Limits option. Click OK to return to the sequence file.

5. Right-click on the new Video Diagnostics step and select Specify Module. Type in VIs\VideoDiagnostics.vi. The screen should appear as follows.

TestStandIFundamentalsCourseManual

5-56

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

6. You must create the code for this VI, so click on Create VI. When prompted for the directory to save in, selectC:\Exercises\ TestStand I\VIs (if not already selected) and clickOK to continue. Then select a relative path when TestStand asks how to store the path, just as in Exercise 5-1A. VideoDiagnostics.vi already contains the TestData and Error Out clusters. These clusters contain information that TestStand passes to the step properties, so you can now build the block diagram for this module.

©

National Instruments Corporation

5-57

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

Open the block diagram and build the diagram as shown.

The False case of the case structure appears as shown below.

7. This simulated test generates a random number between 0 and 30 by multiplying the output of the random number generator (which produces a number between 0 and 1) by 30. The random number is then passed into the Numeric Measurement terminal of theTestData Cluster VI. In TestStand, this value is compared to 10; if it is greater than 10, a string is sent to the Report Text terminal in theTest Data Cluster VI. 8. Save the VI in C:\Exercises\TestStand I\Vis as VideoDiagnostics.vi. 9. Close the VI to return to the Sequence Editor and click OK to exit the Specify Module dialog box.

End of Part A Part B: Configuring the Step Properties 1. The Video Diagnostics step should now appear in the sequence between the RAM Diagnostics step and the Keyboard Diagnostics step. 2. The Video Diagnostics step should execute only if the Video step fails and the Powerup Test and CPU Test have passed. Double-click on the

TestStandIFundamentalsCourseManual

5-58

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

Video Diagnostics step to open the Video Diagnostics NumericLimitTest Properties dialog box. Click thePreconditions button. Set the preconditions as shown below. a. Click Powerup Test in the Insert Step Status section. b. Click Insert Step Pass. c. Click CPU Test. d. Click Insert Step Pass again. e. When prompted to insert AllOf or AnyOf, choose AllOf. f. Click Video Test. g. Click Insert Step Fail.

3. Save the sequence in the C:\Exercises\TestStand I directory as Ex 5-2A Creating Numeric Limit Tests with LabVIEW.seq. Execute the sequence by selectingExecute»Single Pass. Select the video test to fail.

©

National Instruments Corporation

5-59

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

4. When the report is generated, scroll down the report and observe that the video test is reported as having failed (as you have selected). Continue scrolling down and note the status of the Video Diagnostics step. Notice the measurement value returned— it should fall between 0 and 30. Observe the Report Text string returned from the code module if the value is greater than 10.

End of Part B Part C: Using LabVIEW DLL (Optional) You have just finished configuring a Pass/Fail step that uses a VI as the code module. LabVIEW provides the added capability of building a VI into a dynamic link library (DLL). In Part C, you will make use of this capability and use TestStand’s DLL Flexible Prototype Adapter to call that DLL. Recall that previously in this exercise you were using theLabVIEW Standard Prototype Adapter to call VIs from TestStand. 1. You will use the VI that you have created earlier in this exercise and build it into a DLL. Open a new VI in LabVIEW. SelectTools»Build Application or Shared Library (DLL) to open the ‘Build Application or Shared Library (DLL) - New script’ window.

2. On the Target tab within the New script dialog box, specify the name to give to the DLL and its location. a. Change the Build target to Shared Library (DLL). b. Change Target file name to Ex 5-2A Video Diag.dll.

TestStandIFundamentalsCourseManual

5-60

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

c. Rename Destination directory to C:\Exercises\Teststand I \VIs. When you build the DLL, it will be placed in this directory. Note that when you change the directory, the Support file directory field is automatically updated toC:\Exercises\Teststand I \VIs\data. d. Leave other options set to default. Note that under Build Options, the default selection is to createSingle target file containing all VIs. 3. The resulting New script dialog box should resemble the following image.

4. Select the Source Files tab in the New script dialog box. Here, you need to specify the name of the VI that is to be used to build the DLL. Select Add Exported VI to bring up the file selection dialog window. Browse to C:\Exercises\Teststand I\VIs directory and select VideoDiagnostics.vi. Note that as soon as you make the selection by clicking Open from the file dialog window, LabVIEW brings up Define VI Prototype dialog box. 5. In the Function Name text field, enter VideoDiagnostics. This is the name that will be given to the function that will contain the code for Video Diagnostics.vi in the DLL. 6. Note that the default calling convention is set to C Calling Conventions. The VI does not have any input parameters but it does have output values. To specify the error out and TestData outputs, click the “+” button next to the Parameters listbox. Select error out from the VI Output selector for the first output parameter. Click the“+” button

©

National Instruments Corporation

5-61

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

again to add the TestData output parameter. The Define VI Prototype dialog should now appear as shown.

7. Select OK to complete defining the function prototype. This takes you back to the Source Files tab in the New script dialog box. 8. You are now ready to build the DLL. SelectBuild. This shows the progress bar and when complete it will indicateBuild finished! Three files are created: Ex 5-2A Video Diag.dll, Ex 5-2A Video Diag.h, and Ex 5-2A Video Diag.lib. Note If this is the second time you are creating a DLL in the same location, you will receive a message indicating that the previously created DLLs and its supporting files will be overwritten. At this point you can either continue and overwrite existing files or cancel the build operation.

9. Launch TestStand Sequence Editor. Select File»Open to open the following sequence file:C:\Exercises\Teststand I\ Ex 5-2A Creating Numeric Limits Tests with LabVIEW (Part C).seq. This sequence file already contains the Video Diagnostics Numeric Limit Test step using theDLL Flexible Prototype Adapter. You are now going to configure the Video Diagnostics step so that is calls the DLL function that we have just built using LabVIEW. 10. Right-click on theVideo Diagnostics step and select Specify Module to display the Edit DLL Call dialog box. a. For DLL Pathname, click on browse button to select C:\Exercises\Teststand I\VIs\Ex 5-2A Video Diag.dll.

TestStandIFundamentalsCourseManual

5-62

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

b. For Function Name, select VideoDiagnostics from the pull down list. c. Select C(cdecl) for the Calling Convention.

d. Add the error out parameter by selecting the New button. Type Error Out for the parameter name, SpecifyLocals.Error for the Value Expression. Choose C Struct for the Category. Select CustomError for the Struct Type. The dialog should appear as follows.

©

National Instruments Corporation

5-63

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

Note When using the C Struct category youmust have the corresponding data structure defined within the TestStand environment and have theAllow Objects of This Type to be Passed as Structs data type property enabled. This was already taken care of for this exercise. For more information regarding C Structs as parameters, please see the TestStand User Manual.

e. Select OK. Execute the sequence by selecting Execute»Test UUTs. When the report is generated, scroll down the report and observe that the video test is reported to have failed (as you have selected). Continue scrolling down and note the status of the Video Diagnostics step. Notice the measurement value returned—it should fall between 0 and 30. Observe the Report Text string returned from the code module if the value is greater than 10. f. When finished with the exercise, save the sequence file and close the sequence file window.

TestStandIFundamentalsCourseManual

5-64

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

End of Part C End of Exercise 5-2A

©

National Instruments Corporation

5-65

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

Exercise 5-2B Creating Numeric Limit Tests with LabWindows/CVI Objective:

To create a code module for a numeric limit test that simulates a video diagnostic test. This exercise shows how to create another type of test in TestStand called a numeric limit test. Additionally, it demonstrates one way to add information to the Test Report. The code modulepasses numeric data and a Report Text string back to TestStand. TestStand compares the numeric data to predefined limits and determines whether the test passed or failed. The Report Text string is displayed in the report.

Part A: Creating the LabWindows/CVI Test 1. Launch the Sequence Editor. Select File»Open and select the sequence file C:Exercises\TestStand I\Ex 5-2B Creating Numeric Limit Tests with CVI.seq. This sequence file is the same as those used in previous exercises, except it is missing theVideo Diagnostics step. The rest of this lesson describes the procedure to create this step. 2. Make sure the C/CVI Standard Prototype Adapter is selected in the Adapter Selection Ring. 3. Right-click on the RAM Diagnostics step and select Insert Step»Tests»Numeric Limit Test. This inserts a Numeric Limit Test using the C/CVIstep Standard between step. theRAM Diagnostics KeyboardAdapter Diagnostics and thePrototype Name this step Video Diagnostics. 4. In the following steps you will create a DLL test module that returns a random numeric measurement and a Report Text string. Use the default limits of 0 for minimum and 10 for maximum to evaluate the pass/fail conditions based on the numeric measurement returned from the test. To view the limits, right-click on the test and select theEdit Limits option. Click OK to return to the sequence file.

TestStandIFundamentalsCourseManual

5-66

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

5. Right-click on the new Video Diagnostics step and select Specify Module. Fill in the Edit C/CVI Module Call dialog box as shown below.

6. You will do the same for the Pathname of CVI Project File to Open text box located on the Source Code tab. For the pathname of the project file enter CVI Project Files\Video Diagnostics.prj. Repeat this process for the Source Code file. ClickOK to return to the C/CVI Edit Module dialog box, which should now appear as shown below.

©

National Instruments Corporation

5-67

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

Click on Create Code. When prompted, clickOK to confirm that the project file should be created in theC:\Exercises\TestStand I\CVI Project Files subdirectory. Make sure this subdirectory is selected; if not, select this directory before clickingOK. This step is the same as in Exercise 5-1B, so the dialog boxes should be familiar. 7. This launches LabWindows/CVI and creates a.c source file named Video Diagnostics.c. Inside this source file is the template for the function that must be created, calledVideoDiagnostics.

8. The comments are placeholders for developers to insert their code. Modify this function to generate a random number and pass it to the measurement parameter via thetestData structure. Also, use replaceStringFuncPtr to provide a string to theoutBuffer string. Make sure your code appears exactly as shown.

TestStandIFundamentalsCourseManual

5-68

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

Save the source file asVideo Diagnostics.c. 9. Ensure that the project target is set for Dynamic Link Library under the Build»Target menu. 10. Ensure that the DLL to bebuilt is configured tobe a debug version of the DLL by selectingBuild»Configuration»Debug. 11. Confirm the DLL target setting by selecting Build»Target Settings. Make certain the settings match those in the figure below.

©

National Instruments Corporation

5-69

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

12. Verify which functions LabWindows/CVI exports by clicking the Change button in the Exports area. Be sure to selectSymbols Marked for Export, as shown below.

13. The VideoDiagnostics function is marked for export with the dllexport definition. ClickOK . Then, click OK again to close the Target Settings window. 14. Create a DLL by selecting Build»Create Debuggable Dynamic Link Library.

TestStandIFundamentalsCourseManual

5-70

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

End of Part A Part B: Configuring the Step Properties 1. Return to the Sequence Editor. Notice that in all of the pathname dialogs, the modules are now found in the proper directories, because they have been created. ClickOK to exit the Edit C/CVI Module Call dialog box. 2. The Video Diagnostics step should execute only if theVideo Test step fails and the Powerup Test and CPU Test steps have passed. Double-click Video Diagnostics step. Click the Preconditions button.on Setthe the preconditions as shown below. a. Click Powerup Test in the Insert Step Status section. b. Click Insert Step Pass. c. Click CPU Test. d. Click Insert Step Pass again. e. When prompted to insert AllOf or AnyOf, choose Insert AllOf. f. Click Video Test. g. Click Insert Step Fail.

©

National Instruments Corporation

5-71

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

3. Click OK to exit the Preconditions dialog box. ClickOK again to exit the Step Properties dialog box. 4. Save the sequence as C:\Exercises\TestStand I\Ex 5-2B Creating Numeric Limit Tests Using CVI.seq. Execute the sequence by selectingExecute»Single Pass. Select the video test to fail. 5. When the report is generated, observe the Video Diagnostics step report. Notice the measurement value returned—it should fall between the values of 5 and 15 as the code above specifies. Observe theoutBuffer string returned from the code module. It should contain the string message inserted into the LabWindows/CVI code in Part A.

End of Part B End of Exercise 5-2B

TestStandIFundamentalsCourseManual

5-72

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

Exercise 5-2C Objective:

Creating Numeric Limit Tests for the DLL Flexible Prototype Adapter

To create a code module for a numeric limit test that simulates a Video Diagnostic test. This exercise shows how to create another type of test in TestStand called a numeric limit test. Additionally, it demonstrates one way to add information to the test report. The code module passes numeric data and a report text string back to TestStand. TestStand compares the numeric data to predefined limits and determines whether the test passed or failed. The report text string is displayed in the report.

Part A: Creating the DLL Flexible Prototype Adapter Test Module 1. Launch the sequence editor. Select File»Open and select the sequence file C:\Exercises\TestStand I\Ex 5-2C Creating Numeric Limit Tests with the DLL Adapter.seq. This sequence file is the same as that used in previous exercises, except that it is missing the Video Diagnostics step. The rest of this lesson describes the procedure to create this step. 2. Make sure the DLL Flexible Prototype Adapter is selected in the Adapter Selection Ring. 3. Right-click the RAM Diagnostics step and select Insert Step»Tests»Numeric Limit Test. This inserts a Numeric Limit Test for the DLL Flexible Prototype Adapter between theRAM Diagnostics step and the Keyboard Diagnostics step. Rename this step to Video Diagnostics. 4. To view the limits, right-click the step and select the Edit Limits option. Click OK to return to the sequence file. Use the default limits of 0 for minimum and 10 for maximum to evaluate the pass/fail conditions based on the numeric measurement returned from the test. 5. Right-click the new Video Diagnostics step and select Specify Module. Under the Module tab enter the control values as shown in the dialog box. Note The file, Ex 5-2C Video Diagnostics.dll does not yet exist. You will be creating it later in this exercise.

©

National Instruments Corporation

5-73

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

6. In the Edit DLL Call dialog box, click the Source Code tab. Click the Create Code button. Navigate to theC:\Exercises\TestStand I\CVI Project Files\ directory and enter the filenameEx 5-2C Video Diagnostics.c as shown.

TestStandIFundamentalsCourseManual

5-74

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

TestStand may then ask how to store the path to this code resource.

The preferred method to store paths to code resources is relative to the sequence file, so select the last option, as shown above. Relative paths are preferred so that if the files are ever moved, the code modules can still be found as long as they are all moved together. For example, this situation happens frequently when the test sequence is moved from the development machine to the test machine, where the drive names and directory structures could be completely different.

7. Next, you will be prompted for the code template that you would like to use. Select, TestStand numeric limit template as shown below. Click OK to create the source code. Note Upon clicking on OK above, you may get a message saying that you don ’t have an application associated with files of this type and asks if you want to launch Notepad to view the file. ClickNo .

8. Notice that the fields in the Source Code tab of the Edit DLL Call dialog box are now filled in. In the Edit DLL Call dialog box, click the Module tab. Notice that the parameters in the ring are now filled in.

©

National Instruments Corporation

5-75

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

9. Before you can implement your test, you need to add another parameter to the function. You will pass a string parameter that will be displayed in the report. The new parameter will be created after measurement. Under the Module tab, in the Parameter ring, select Measurement. Click the New button to insert a new parameter.

10. Rename the arg3 parameter to reportText. Select String for the Category. For the Pass ring, select C String Buffer. Use C String when you do not intend to modify the string andC String Buffer when you intend to modify the string. For theValue Expression, click the Browse button and insert, Step.Result.ReportText.

TestStandIFundamentalsCourseManual

5-76

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

Notice that the Function Prototype and Function Call fields at the bottom of the window are updated as you fill in the fields. TheModule tab should now appear as shown below.

11. The skeleton code previously created with the template in step 7 must be modified to reflect the new parameter. Click theSource Code tab and then on the Verify Prototype button. When the Prototype Conflict dialog box appears, click Use the Prototype from the Module Tab and click OK . This displays a dialog box to replace the step code.

©

National Instruments Corporation

5-77

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

12. Click the Replace button to replace the existing function prototype with the new prototype. ClickOK and then OK again in the Edit DLL Call dialog box. 13. Launch LabWindows/CVI and selectFile»Open»Project. Open the project file C:\Exercises\TestStand I\CVI Project Files\Ex 5-2C Video Diagnostics.prj. If prompted, clickYes to unload the current project andOK to transfer the project options.

TestStandIFundamentalsCourseManual

5-78

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

14. In the Ex 5-2C Video Diagnostics.prj window, you should see that Ex 5-2C Video Diagnostics.c is already included in the project. If it displaysFile Not Found , select, Edit»Add Files to Project»Source (*.c) . Then double-click Ex 5-2C Video Diagnostics.c, which you just created. Click theOK button to add this to the project. 15. In the LabWindows/CVI Project window, double-clickEx 5-2C Video Diagnostics.c to open the source code window as shown below.

This code was created from a template file. 16. If the source code window was already open, you will be prompted to Update the Window from Disk. After selecting Update Window from Disk, you are prompted to save a copy of the existing contents. Select No . 17. For this exercise, create a DLL test module that returns a random numeric value and a report text string. Replace the source code with the following: Note The code shown is for illustration only, besure to use proper syntaxin your code.

©

National Instruments Corporation

5-79

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

void __declspec(dllexport) __stdcall VideoDiagnostics( CAObjHandle seqContextCVI, double *measurement, char reportText[1024], short *errorOccurred, long *errorCode, char errorMsg[1024]) { int error = 0; ErrMsg errMsg = {'\0'}; ERRORINFO errorInfo; *measurement = Random(0,20); /* Random value from 0 to 20. Since the step limits are 0 and 10, it gives almost 50% of chance for either pass or fail */ strcpy(reportText, "no adapter present"); Error: // FREE RESOURCES // If an error occurred, set the error flag to // cause a run-time error in TestStand. if (error < 0) { *errorOccurred = TRUE; // *errorCode = error; // strcpy(errorMsg, errMsg); } return;

} 18. Save the source file. 19. In LABWINDOWS/CVI, select the project window by selecting Window»Project. 20. Ensure that the project target is set for Dynamic Link Library under the Build»Target Type menu.

21. Ensure that the DLL to be built is configured to be a debug version of the DLL by selectingBuild»Configuration»Debug.

TestStandIFundamentalsCourseManual

5-80

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

22. Confirm the DLL target settings by selectingBuild»Target Settings. Make certain the settings match those in the figure below.

23. Ensure the Ex 5-2C Video Diagnostics.dll will be built in C:\Exercises\TestStand I\CVI Project Files. 24. VideoDiagnostics.fp was already created for this exercise. You will use this function panel file to create a type library. A type library is a component of a DLL that can be used by TestStand to look up the function prototype when a function call is specified. 25. Click the Type Library button. Click the Add type library

resource to DLL checkbox . SelectProject the function panel file C:\Exercises\TestStand I\CVI Files\VideoDiagnostics.fp.

26. Click OK to return to the Target Settings dialog box. Click OK to close the Target Settings window. 27. Finally, create theEx 5-2C Video Diagnostics.dll by selecting Build»Create Debuggable Dynamic Link Library.

©

National Instruments Corporation

5-81

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

28. Return to the sequence editor. In the Edit DLL Call dialog box, click the Browse button for the DLL Pathname control and select theEx 5-2C Video Diagnostics.dll that you just created. When asked how you resolve the path to this code module, selectUse a Relative Path and click OK . Click OK to close the Edit DLL Call dialog box.

End of Part A Part B: Configuring the step properties 1. Return to the sequence editor. Notice that in all of the pathname dialogs, the modules are now found in the proper directories, because they have been created. Click OK to exit the Edit DLL Module Call dialog box. 2. The Video Diagnostics step executes only if theVideo Test step fails and the Powerup Test and the CPU Test steps have passed. Double-click the Video Diagnostics step. Click the Preconditions button. Set the preconditions as shown below. a. Click Powerup Test in the Insert Step Status section. b. Click Insert Step Pass. c. Click CPU Test. d. Click Insert Step Pass again. e. When prompted to insert AllOf or AnyOf, choose Insert AllOf. f. Click Video Test.

TestStandIFundamentalsCourseManual

5-82

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

g. Click Insert Step Fail.

3. Click OK to exit the Preconditions dialog box. ClickOK again to exit the Step Properties dialog box. 4. Save the sequence as C:\Exercises\TestStand I\Ex 5-2C Creating Numeric Limit Tests With DLL Adapter.seq. Execute the sequence by selectingExecute»Single Pass. Select the Video Test to fail. 5. When the report is generated, observe the Video Diagnostics step result in the report. Notice the measurement value returned —it should fall between the values of 0 and 20. Observe theoutBuffer string returned from the code module. It should contain the string“no adapter present.”

©

National Instruments Corporation

5-83

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

6. When finished, save and close the sequence file.

End of Part B End of Exercise 5-2C

TestStandIFundamentalsCourseManual

5-84

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

Exercise 5-3A Debugging Tests Using LabVIEW Objective:

To debug code modules compiled with LabVIEW. While debugging a TestStand sequence, the sequence developer can step into specific code modules and use the debugging tools that are part of that development environment. TestStand can step directly into LabVIEW and LabWindows/CVI code modules. This exercise demonstrates how to step into a LabVIEW code module and use LabVIEW debugging tools to step through the LabVIEW code. 1. In the Sequence Editor, select File»Open and select the sequence file

C:\Exercises\TestStand I\Ex 5-3A Debugging Tests Using LabVIEW.seq. Notice that this sequence is the solution created for Exercise 5-2A. Remember that a copy of the solution for each exercise is in the C:\Solutions\TestStand I directory. 2. Place a breakpoint at the Video Diagnostics step by clicking to the left of the step. A STOP icon appears as shown below.

©

National Instruments Corporation

5-85

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

3. Execute the sequence, check the video test to fail, and the execution pauses at the breakpoint. Use the watch window, as described in Exercise 2-2, to watch the result for this step. The value to watch is RunState.Sequence.Main["Video Diagnostics"].Result.Numeric, and the hierarchy for selecting it in the Context window is shown below.

4. Click on the Step Into button in the toolbar, which steps into the LabVIEW code module.

TestStandIFundamentalsCourseManual

5-86

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

5. From the Video Diagnostics VI front panel, selectWindows»Show Diagram. Select Windows»Show Tools Palette. In the Tools palette, click on the Breakpoint tool (the stop sign).

©

National Instruments Corporation

5-87

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

6. With the Breakpoint tool, click on any wire to set a breakpoint. Run the VI bytoclicking the code. Run button. You can use the LabVIEW tools debug the Click the Pause/Continue button todebugging finish execution. 7. Click the Return to Caller button to return execution to TestStand. The value in the watch window should now contain the random number generated in the test. This value changes only when the LabVIEW code has finished executing and the return values from theTest Data cluster have been passed back into TestStand. 8.

In TestStand, click the Resume button to finish the execution.

Note It is also possible to debuga LabVIEW DLL. However, because you can only debug a LabVIEW DLL from within the same process, you must debug the LabVIEW DLL using the LabVIEW Operator Interface and notthe Sequence Editor. To debug a VI that was compiled into a function in a LabVIEW DLL, you can perform the following steps:

a. Within LabVIEW, open the VI that was used to build the function you wish to debug in the LabVIEW DLL. b. Place a breakpoint within this VI.

TestStandIFundamentalsCourseManual

5-88

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

c. Within LabVIEW, open and run the top level VI for your LabVIEW Operator Interface. d. Within your LabVIEW Operator Interface, select the test sequence that is calling the function in the LabVIEW DLL that you wish to debug. e. Execute the test sequence from within the LabVIEW Operator Interface. f. The execution will automatically stop for debugging at the breakpoint that you placed within the VI in step a, above.

End of Exercise 5-3A

©

National Instruments Corporation

5-89

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

Exercise 5-3B Debugging Tests Using LabWindows/CVI Objective:

To debug code modules compiled with LabWindows/CVI. While debugging a TestStand sequence, the sequence developer can step into specific code modules and use the debugging tools that are part of that development environment. TestStand can step directly into LabVIEW and LabWindows/CVI code modules. This exercise shows how to step into a LabWindows/CVI code module and use LabWindows/CVI debugging tools to step through the code. 1. In the Sequence Editor, select File»Open and select the sequence file

C:\Exercises\TestStand I\Ex 5-3B Debugging Tests with CVI.seq. Notice that this sequence is the solution to Exercise 5-2B. Remember that the solutions for each exercise can be found in the C:\Solutions\TestStand I directory. 2. First, you will enable the C/CVI Standard Prototype Adapter to execute steps in an external instance of LabWindows/CVI. TestStand must execute the LabWindows/CVI code externally, within the LabWindows/CVI IDE, to allow debugging of the LabWindows/CVI test code. When you finish debugging test code, you can set TestStand to run the code in process if it is compiled as an object file or DLL, for optimum performance. Select Configure»Adapters. In the Adapter Configuration dialog box that appears, ensure that theC/CVI Standard Prototype Adapter is selected. Click the Configure button. In the C/CVI Standard Adapter Configuration dialog box, click the Execute Steps in an External Instance of CVI radio button as shown below.

TestStandIFundamentalsCourseManual

5-90

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

Execute Steps in an External Instanc e of CVI tells TestStand to launch LabWindows/CVI and load all support files into it when LabWindows/CVI steps are called. This option allows the TestStand debugger to step into the step code when the Step Into option is selected

for a LabWindows/CVI step with a specified file. Execute Steps In-Process tells TestStand not C tosource launchcode an external LabWindows/CVI process. This means you cannot step into a LabWindows/CVI step even if the C source code file is specified. Most of the time, the second option will be chosen, so that an external instance of LabWindows/CVI is not launched during execution of the sequence. However, during the debugging of a sequence it is often advantageous to step directly into the code module to verify that parameters and other environment settings are being configured properly. 3. Click OK to close the C/CVI Standard Adapter Configuration display. Click OK to unload all modules. ClickDone in the Adapter Configuration dialog box.

©

National Instruments Corporation

5-91

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

4. Place a breakpoint at the Video Diagnostics step by clicking along the edge as shown below. Run the sequence, check the video test to fail, and the execution pauses at the breakpoint.

5. Step into the code module by clicking on the Step Into button in the toolbar.

TestStandIFundamentalsCourseManual

5-92

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

6. This launches the LabWindows/CVI debugging window, where you can use the LabWindows/CVI stepping tools, watch window, and variable window to debug the code.

7. When finished with the LabWindows/CVI debugging window, press the Go button to finish executing this function and return execution to TestStand. 8. Finally, reset the adapter configurationoption to run LabWindows/CVI Tests In Process. SelectConfigure»Adapters.... In the Adapter Configuration dialog box, select C/CVI Standard Prototype Adapter, and click on Configure.... Click on Execute Steps In Process and click OK. Click OK to unload all modules. ClickDone in the Adapter Configuration dialog box. To stop the LabWindows/CVI projecttscvirun.prj, which is used for debugging, press to terminate execution. Finally, close the LabWindows/CVI IDE. When finished with the exercise, save and close the sequence file.

End of Exercise 5-3B

©

National Instruments Corporation

5-93

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

Exercise 5-3C Objective:

Debugging Tests that use the DLL Flexible Prototype Adapter

To debug code modules that use the DLL Flexible Prototype Adapter. Exercise 5-3B shows how to step into code modules called with theC/CVI Standard Prototype Adapter. In contrast, you cannot step into code modules that are called with theDLL Flexible Prototype Adapter. However, this exercise demonstrates how to debug your test code rom f your C development environment. 1. In the Sequence Editor, select File»Open and select the sequence file C:\Exercises\TestStand I\Ex 5-3C Debugging Tests with DLL Adapter.seq. Notice that this sequence is the solution to Exercise 5-2C except that theVideo Diagnostics step calls Ex 5-3C Video Diagnostics.dll. Remember that the solutions for each exercise can be found in theC:\Solutions\TestStand I directory. 2. Exit the sequence editor. 3. In LabWindows/CVI, select File»Open»Project. Open the project file C:\Exercises\TestStand I\CVI Project Files\Ex 5-3C Video Diagnostics.prj. 4. Open the source file by double-clicking on Ex 5-3C Video Diagnostics.c listed in the project window. Place a breakpoint on line 11 which has the following statement: *measurement = 10 + (rand()%11);

TestStandIFundamentalsCourseManual

5-94

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

This is shown in the following figure:

Note Place a breakpoint by clicking on the Line Icons column or by pressing F9 while your cursor is on that particular line.

5. Select the project window by selecting Window»Project. 6. In the project window, select Run »Select External Process. Click the Browse button and select C:\TestStand\bin\SeqEdit.exe.

7. Click OK to return to the LabWindows/CVI Project window. Select Run»Run SeqEdit.exe to launchtothe sequence editor from LabWindows/CVI. If prompted save changes, select Yes .

©

National Instruments Corporation

5-95

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

8. In the Sequence Editor, open the sequence file C:\Exercises\ TestStand I\Ex 5-3C Debugging Tests with DLL Adapter.seq. Run the sequence, check theVideo Test to fail, and you will see that execution will stop at the breakpoint you set in the source code when the Video Diagnostics step executes.

9. In the LabWindows/CVI debugging window, you can use the LabWindows/CVI stepping tools, watch window, and variable window to debug the code. 10. When finished with the LabWindows/CVI debugging window, press the Go button to finish this function and return execution to TestStand. Using this technique, you can debug your test code, which is compiled into a DLL. This technique also applies to steps that call theC/CVI Standard Prototype Adapter. 11. Finally, close Ex 5-3C Debugging Tests with DLL Adapter.seq and exit the sequence editor.

End Of Exercise 5-3C

TestStandIFundamentalsCourseManual

5-96

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

Exercise 5-4A Using the ActiveX API in Code Modules with LabVIEW Objective:

To pass numeric data and a Report Text string from a code module to TestStand using the ActiveX API. This exercise produces the same results as Exercise 5-2A, but it uses the ActiveX Application Programming Interface (API) to pass result data to TestStand. Although in this step you will pass the step ’s result data, the ActiveX method for passing data is very useful because it enables you to get or set anyTestStand property or variable, including local or global variables.

Part A: Passing the Sequence Context ActiveX Object Handle 1. In the Sequence Editor, select File»Open and open the sequence file C:Exercises\TestStand I\Ex 5-4A Using the ActiveX API with LabVIEW.seq. For this exercise, a LabVIEW test will be created that returns a random numeric measurement value and a report text string. Use the default limits of 0 for minimum and 10 for maximum to evaluate the pass/fail status based on the numeric measurement returned from the test. To view the limits for this numeric limit test step, right-click on the test step and select Edit Limits. 2. Right-click on the Video Diagnostics step and select Specify Module. Click on the Browse button, navigate to the C:\Exercises\TestStand I\VIs directory, and type in

VideoDiagnosticsActiveX.vi for the VI name. Check the Sequence Context ActiveX Pointer box as shown below. This instructs TestStand to pass the sequence context handle to the code module to allow ActiveX API functions to access step and sequence properties or variables. Click on Create VI to have TestStand create a new VI that can be called as a step from TestStand.

©

National Instruments Corporation

5-97

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

When prompted for the directory to save in, selectC:\Exercises\ TestStand I\VIs (if not already selected) and clickOK to continue. Select a relative path when TestStand asks how to store the path, just as in the first exercise. 3. A VI is created with the name VideoDiagnosticsActiveX.vi, which contains the TestData and Error Out clusters. In addition, the VI has a Sequence Context control on the front panel. This is an ActiveX Automation Refnum.

TestStandIFundamentalsCourseManual

5-98

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

Optional Reading (You May Skip to Part B Below) If you need to add the Sequence Context refnum to the front panel manually, right-click and select theSequence Context control from the TestStand subpalette as shown below.

©

National Instruments Corporation

5-99

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

You may also need to connect the Sequence Context refnum to the VI connector pane. Right-click in the icon area of the VI and selectShow Connector. (See the arrow below.)

With the Wiring tool, click on the upper-left terminal of the connector. In the figure above, this is the blacked-out terminal. With the same Wiring tool, click on the Sequence Context refnum to associate the front panel object with the terminal in the connector.

End of Part A

TestStandIFundamentalsCourseManual

5-100

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

Part B: Creating the Code in the Diagram 1. Build the diagram as shown in the figure below.

Typically, ActiveX calls pass data into and out of TestStand that cannot be passed using the TestStand Data Cluster. However, to demonstrate passing some simple information, in this exercise, the values passed are the same values that could be passed using the TestStand Data Cluster. In this exercise, you pass a random number to theStep.Result.Numeric property of the step that calls this code module. You also pass a string to the Step.Result.ReportText property of the same step. You will use two ActiveX VIs to set these step properties: • Set Property Value (Number).vi sets the numeric value of the SequenceContext property the Lookup String control specifies. •

©

National Instruments Corporation

Set Property Value (String).vi sets the string value of the SequenceContext property the Lookup String control specifies.

5-101

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

The TestStand ActiveX API functions are in theTestStand subpalette as shown.

In this exercise, a random number is passed into theNew Value terminal of Set Property Value (Number).vi, which passes that value to the property specified by the Lookup String. The random number is also compared to 10; if it is greater than 10, a text message is passed to theNew Value terminal of Set Property Value (String).vi. In the false case of the case structure, pass an empty string. 2. Save the VI as C:\Exercises\TestStand I\

VIs\VideoDiagnosticsActiveX.vi. 3. Return to the Sequence Editor.

End of Part B

TestStandIFundamentalsCourseManual

5-102

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

Part C: Configuring the Step Properties Notice that the VI is now found. ClickOK to leave the Edit LabVIEW VI Call dialog box. TheVideo Diagnostic step should appear between the RAM Diagnostics step and the Keyboard Diagnostics step. 1. The Video Diagnostics step should execute only if theVideo Test step fails and the Powerup Test and CPU Test steps have passed. Double-click on theVideo Diagnostics step. Click the Preconditions button. Set the preconditions as shown below.

2. Save the sequence as C:\Exercises\TestStand I\Ex 5-4A Using the ActiveX API with LabVIEW.seq. Execute the sequence by selectingExecute»Single Pass. Select the video test to fail. 3. Use the watch window as described in Exercise 5-2A to watch the TestStand expressions: RunState.Sequence.Main["Video Diagnostics"].Result.Numeric and RunState.Sequence. Main["Video Diagnostics"].Result.ReportText. When the LabVIEW code finishes executing and the code module has returned its values to TestStand, the values in the watch window should display theresults for this test.

©

National Instruments Corporation

5-103

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

4. When the report is generated, scroll down the report and observe the status of the Video Diagnostics step. Notice the measurement value returned—it should fall between 0 and 30. Observe theReport Text string returned from the code module if the value is greater than 10.

End of Exercise 5-4A

TestStandIFundamentalsCourseManual

5-104

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

Exercise 5-4B Using the ActiveX API in Code Modules with LabWindows/CVI Objective:

To pass numer ic data and a st ring from a code m odule to TestStand using Ac tiveX. This exercise produces the same results as Exercise 5-2B, but it uses the ActiveX Application Programming Interface (API) to pass result data to TestStand. Although in this step you will pass the step ’s result data, the ActiveX method for passing data is veryuseful because you can use itto get or set any TestStand data, including local or global variables. 1. In the Sequence Editor, open Ex 5-4B Using the ActiveX API with CVI.seq. The rest of this lesson describes how to create the code module to be used by this step using ActiveX calls. 2. Right-click on the Video Diagnostics step and select Specify Module. Fill in the resulting dialog boxes as shown below. After you complete the dialog boxes, theVideo Diagnostics step calls the VideoDiagnostics function created in Exercise 5-2B. Remember that the solutions for all exercises are in theC:\Solutions\TestStand I\ CVI Project Files directory. Copy all the Video Diagnostic files to the C:\Exercises\TestStand I\CVI Project Files directory before continuing if Exercise 5-2B was not completed.

©

National Instruments Corporation

5-105

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

Warning This exercise modifies the behavior of the code for the Video Diagnostics step. These changes may affect Exercise 5-2B, so be sure to complete that exercise before completing this one. You can always recreate Exercise 5-2B by repeating it.

3. Right-click on the Video Diagnostics step and select Edit Code from the menu. This launchesLabWindows/CVI and opens the Video Diagnostics project and source code containing the VideoDiagnostics function. These files are in the C:\Exercises\TestStand I\CVI Project Files\ directory. In Video Diagnostics.c, you will replace the following code with the ActiveX API equivalent. testData->measurement = measurement; if(!testData->replaceStringFuncPtr(&testData->outBuffer, "Unstable VSS readings at video controller")) { error = TS_Err_OutOfMemory; goto Error; }

4. Delete the above code and place your cursor below the following line: measurement = 5 + (rand()%11);

5. Under the Instrument menu, you should find the TestStand API 2.0 instrument driver. If you do not, loadTSAPICVI.fp from the \API\CVI\ directory by selecting Instrument»Load. 6. In the TestStand API instrument driver, go to the Property Object»Values tree and select Set Numeric Value.

TestStandIFundamentalsCourseManual

5-106

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

Fill in the boxes as shown below. Notice that the function call is filled in at the bottom of the Function Panel window as you type in the boxes. Use the function call information to see how to fill in the boxes, because the screen limitations do not allow all text to be displayed.

©

National Instruments Corporation

5-107

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

7. Right-click in the Function Panel window to see the help for this function. You can right-click on each control to get help on each parameter. 8. Some of the parameters used include: Object Handle: This is a handle to the Sequence Context object in TestStand and is passed through thetTestData struct. Later in this exercise, you will see how TestStand actually passes this handle. Error Info: This is the returned error information. A C-macro handles this error information and the returned status value. Notice that there are

several error status codes defined in the online help. Lookup String: To specify the property, pass a string that defines a path from the object on which you call the method to the specific property you want to access. To specify the object itself, pass an empty string (""). To specify a subproperty, pass the name of the subproperty. To specify a subproperty of a subproperty, pass a string containing both names separated by a period (.). Later in this exercise, you will see how to browse for this parameter. Options: Refer to the online help for a list of available options. New Numeric Value: The value to set to the property specified by the Lookup String. You will use“measurement” for this exercise.

9. Close the help window. From the function panel window, select Code»Set Target File. Be sure the Target File is set to the Video Diagnostics.c file. 10. cursor Select Code »Insert Call to insert thisfile. function where your Video Diagnostics.c last was in theFunction 11. Now, you will insert the TS_PropertySetValString() function call into the source file. Select this function from the same tree,Property Object»Values, in the TestStand API instrument driver and selectSet String Value. Fill in the parameters as shown below and insert this function call in the Video Diagnostics.c file.

TestStandIFundamentalsCourseManual

5-108

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

12. Return to the Video Diagnostics.c file and be sure that you filled in the function calls as shown. Note The code shown is for illustration only, besure to use proper syntaxin your code. TS_PropertySetValNumber (testData->seqContextCVI, &errorInfo, "Step.Result.Numeric", 0, measurement); TS_PropertySetValString (testData->seqContextCVI, &errorInfo, "Step.Result.ReportText", 0, "Unstable VSS readings at video controller");

13. Return to TestStand and clickOK to close the Edit C/CVI Module Call dialog box. 14. Switch to the Sequence Editor and right-click on theVideo Diagnostics step in the sequence file. SelectBrowse Sequence Context from the context menu. In this tree, select Step.Result.Numeric as shown below. This is the same Lookup String passed into theTS_PropertySetValNumber function call. Notice that you could have copied this variable/property with theCopy Property Path button and pasted it into the function call.

©

National Instruments Corporation

5-109

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

Notice also that any property or variable could be referenced with similar Lookup Strings. 15. Finally, check the error status with a macro defined intsutil.h. tsErrChkMsgPopup() displays the error description and jumps to Error: with the error variable set. 16. Enter the macro as shown in bold and underlined below. Make sure that the code appears exactly as shown. Note The code shown is for illustration only, besure to use proper syntaxin your code. #include "stdtst.h" #include "tsutil.h" void __declspec(dllexport) TX__TEST VideoDiagnostics(tTestData *testData, tTestError *testError) { int error = 0; ErrMsg errMsg; ERRORINFO errorInfo; double measurement; measurement = 5 + (rand()%11); /* value from 5 to 15 */ tsErrChkMsgPopup (TS_PropertySetValNumber (testData->seqContextCVI, &errorInfo, "Step.Result.Numeric",

TestStandIFundamentalsCourseManual

5-110

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

0, measurement)); if (measurement >10) { tsErrChkMsgPopup (TS_PropertySetValString (testData->seqContextCVI, &errorInfo, "Step.Result.ReportText", 0, "Unstable VSS readings at video controller")); } Error: // If an error occurred, set the error flag to cause a run-time if (error < 0) { testError->errorFlag = TRUE; // OPTIONALLY SET THE ERROR CODE AND STRING testError->errorCode = error; } return; }

The final screen should resemble the following.

17. Save Video Diagnostics.c. 18. Ensure that the project target is set for Dynamic Link Library under Build»Target Type. 19. Ensure that the DLL to be built is configured to be a debuggable version of the DLL by selectingBuild»Configuration»Debug. 20. Create the DLL by selecting Build»Create Debuggable Dynamic Link Library. If LabWindows/CVI says access is denied to overwrite the

©

National Instruments Corporation

5-111

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

DLL, you need to selectFile»Unload All Modules in the Sequence Editor so that the DLL can be overwritten. 21. Return to the Sequence Editor and right-click on the Video Diagnostics step, selecting Specify Module. Be sure the Pass Sequence Context checkbox is checked as shown below. This checkbox instructs TestStand to pass the ActiveX handle to theSequence Context object in the tTestData structure of the function being called.

22. Notice that in all pathname dialogs, the modules are now in the proper directories. Click OK to exit the C/CVI Edit Module dialog box. 23. The Video Diagnostics step should execute only if theVideo Test step fails and the Powerup Test and CPU Test steps have passed. Double-click on theVideo Diagnostics step. Click the Preconditions button. Set the preconditions as shown below. a. Click Powerup Test in the Insert Step Status section. b. Click Insert Step Pass. c. Click CPU Test. d. Click Insert Step Pass again. e. When prompted to insert AllOf or AnyOf, choose Insert AllOf. f. Click Video Test.

TestStandIFundamentalsCourseManual

5-112

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

g. Click Insert Step Fail.

24. Save and run Ex 5-4B Using the ActiveX API with CVI.seq to verify that it works correctly. When this sequence is run, make sure that the video test is selected to fail. In the test report, verify that the correct data is returned.

End of Exercise 5-4B

©

National Instruments Corporation

5-113

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

Exercise 5-4C Using the ActiveX API in Flexible DLL Code Modules Objective:

To return numeric data and a st ring from a code mod ule to TestStand using the TestStand ActiveX API. This exercise produces the same results as Exercise 5-2C, but it uses the TestStand ActiveX Application Programming Interface (API) to return result data to TestStand. Although in this step, you will pass the result data for the step, the ActiveX method for passing data is very useful because you can use it to get or set any TestStand data, including local or global variables. 1. In the sequence editor, open Ex 5-4C Using the ActiveX API with the DLL Adapter.seq. The rest of this lesson describes how to create the code module. 2. Right-click the Video Diagnostics step and select Specify Module. Fill in the resulting dialog boxes as shown below. After you complete the dialog boxes, the Video Diagnostics step calls the VideoDiagnostics_API function. Remember that the solutions for all exercises can be found in theC:\Solutions\TestStand I\CVI Project Files\ directory.

TestStandIFundamentalsCourseManual

5-114

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

©

National Instruments Corporation

5-115

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

3. Click OK to close the Edit DLL Call dialog box. 4. In LabWindows/CVI open the project file C:\Exercises\TestStand I\CVI Project Files\Ex 5-4C Video Diagnostics.prj project in the directory. Open the

VideoD_API.c source code file, which contains the VideoDiagnostics_API function. You will now add the necessary code to communicate with TestStand using the API. 5. Place your cursor on line 12 (if line numbers are not visible, go to View»Line Numbers). 6.

Under the Instrument menu, you should find theTestStand API 2.0 instrument driver. If you do not, loadTSAPICVI.fp from the C:\TestStand\API\CVI\ directory by selectingInstrument»Load.

7. In the TestStand API instrument driver, go to the Property Object»Values tree and select Set Numeric Value.

TestStandIFundamentalsCourseManual

5-116

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

8. Fill in the boxes as shown below. Notice that the function call is filled in at the bottom of the Function Panel window as you type into the boxes. Use the function call information to see how to fill in the boxes.

©

National Instruments Corporation

Parameter

Value

Object Handle Error Info Lookup String Options New String Value

seqContextCVI &errorInfo "Step.Result.Numeric" 0 10 + (rand()%11)

5-117

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

9. Right-click in the function panel window to see the help for this function. You can right-click each control to get help on each parameter. 10. Some of the parameters include: • Object Handle —This is a handle to theSequence Context object in TestStand. Later in this exercise, we will see how TestStand actually passes this handle. • Error Info —This is the returned error information. A C-macro handles this error information and the returned status value. Notice that there are several error status codes defined in the online help. • Lookup String —To specify the property, pass a string that defines a path from the object on which you call the method to the specific property you want to access. To specify the object itself, pass an empty string (""). To specify a subproperty, pass the name of the subproperty. To specify a subproperty of a subproperty, pass a string containing both names separated by a period(.). Later in this exercise, we will see how to browse for this parameter. •

Options—Refer to the online help for a list of available options.



NewNumeric Value —The value to set to the property specified by the Lookup String. You will use a random number for this exercise.

11. Close the help window if open. From the function panel window, select Code»Set Target File. Be sure the target file is set to the VideoD_API.c file. 12. Select Code»Insert Function Call to insert this function where your cursor was in the VideoD_API.c file. 13. Now, you will insert the TS_PropertySetValString() function call into the source file. Select this function from the same tree:Property Object»Values, in the TestStand API instrument driver. Fill in the parameters as shown below and insert this function call in the VideoD_API.c file.

TestStandIFundamentalsCourseManual

Parameter

Value

Object Handle Error Info Lookup String Options New String Value

seqContextCVI &errorInfo "Step.Result.ReportText" 0 "Unstable VSS readings at video controller"

5-118

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

14. Return to the VideoD_API.c file and be sure that you filled in the function calls as shown. Note The code shown is for illustration only, besure to use proper syntaxin your code. TS_PropertySetValNumber (seqContextCVI, &errorInfo, "Step.Result.Numeric", 0, 10 + (rand()%11)); TS_PropertySetValString (seqContextCVI, &errorInfo, "Step.Result.ReportText", 0,"Unstable VSS readings at video controller");

15. Switch to the TestStand Sequence editor and clickOK to close the Edit DLL Call dialog box. ClickOK to close the Video Diagnostics Properties dialog box. 16. Right-click the Video Diagnostics step in the sequence file. Select Browse Sequence Context from the context menu. In this tree, select Step.Result.Numeric as shown below. This is the same Lookup String that we passed in to theTS_PropertySetValNumber function call. Notice that we could have copied this variable/property with the Copy Property Path button and pasted it into our function call. Close this dialog box when finished looking at it.

©

National Instruments Corporation

5-119

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

Note All properties and variables could be referenced with similar lookupstrings.

17. Return to LabWindows/CVI. Finally, check the error status with a macro that is defined in tsutil.h. tsErrChkMsgPopup() displays the error description and jumps to the labelError:. Enter the macro as shown in bold below. Make sure that the code appears exactly as shown below. Note The code shown is for illustration only, besure to use proper syntaxin your code. #include "stdtst.h" #include "tsutil.h" void __declspec(dllexport) __stdcall VideoDiagnostics_API(CAObjHandle seqContextCVI, short *errorOccurred, long *errorCode, char errorMsg[1024]) { int ErrMsg ERRORINFO

TestStandIFundamentalsCourseManual

error = 0; errMsg = {'\0'}; errorInfo;

5-120

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

tsErrChkMsgPopup(TS_PropertySetValNumber,(seqContextCVI, &errorInfo, "Step.Result.Numeric", 0, 10 +(rand()%11)));

tsErrChkMsgPopup(TS_PropertySetValString (seqCotextCVI, &errorInfo, "Step.Result.ReportText", 0, "Unstable VSS readings at video controller")); Error: // FREE RESOURCES // If an error occurred, set the error flag to // cause a run-time // error in TestStand. if (error < 0) { *errorOccurred = TRUE; *errorCode = error; strcpy(errorMsg, errMsg); } return; }

18. Save VideoD_API.c. 19. VideoD_API.fp was already created for you. We will use this function panel file to create a type library. A type library is a component of a DLL that can be used by TestStand to look up the function prototype when a function call is specified. The type library exposes the functions and arguments to the user of the DLL. This allows the user to view from TestStand the parameters of a function in a DLL. indows/CVI please refer tothe Note For more information on type libraries for LabW LabWindows/CVI User Manual. For information on how to create type libraries in VC++ please refer to the knowledge base document Creating a Type Library Using Visual C++ in our web site at ni.com 20. From the project file, ensure that the target is set for Dynamic Link Library under Build»Target Type. Ensure that the DLL to be built is configured to be a release version of the DLL by selecting Build»Configuration»Release. 21. Confirm the DLL target settings by selectingBuild»Target Settings. Make certain the settings match those in the figure below.

©

National Instruments Corporation

5-121

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

Click Type Library and check the box next toAdd Type Library Resource to DLL. Click the Browse button and choose the file VideoD_API.fp. The window should resemble the one shown below.

22. Click OK to close the Type Library Window. ClickOK to close the Target Settings window. 23. Create the DLL by selecting Build»Create Release Dynamic Link Library from the menu. You should get a message notifying that the files were successfully created. 24. Return to TestStand’s Sequence Editor and right-click theVideo Diagnostics step, then select Specify Module. From the function ring select VideoDiagnostics_API. Select No if you get the following window:

TestStandIFundamentalsCourseManual

5-122

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

Notice that now you can browse the parameters of VideoDiagnostics_API function. This is due to the DLL’s type library.

25. Click OK to close the Edit DLL Call dialog box. 26. The Video Diagnostics step should execute only if theVideo Test step fails and the Powerup Test and the CPU Test steps have passed. Double-click theVideo Diagnostics step. Click the Preconditions button. Set the preconditions as shown below: a. Click Powerup Test in the Insert Step Status section. b. Click Insert Step Pass.

©

National Instruments Corporation

5-123

TestStand I Fundamentals Course Manual

Lesson 5 Creating Test Modules in External Environments Exercises

c. Click CPU Test. d. Click Insert Step Pass again. e. When prompted to insert AllOf or AnyOf, choose Insert AllOf. f. Click Video Test. g. Click Insert Step Fail.

27. Save and run Ex 5-4C Using the ActiveX API with the DLL Adapter.seq to verify that it works correctly. When this sequence is run, make sure that the Video Test is selected to fail. In the test report, verify that the correct data is returned.

End of Exercise 5-4C

TestStandIFundamentalsCourseManual

5-124

ni.com

Lesson 5 Creating Test Modules in External Environments Exercises

Exercise 5-5A Creating a Simple Test Using the LabVIEW Standard Prototype Adapter Objective:

To write a simp le Numeric Limit Test that uses th e LabVIEW St andard Pr ototype Adapter. Write a test function that generates and plots a sine wave. Measure the estimated AC content of the sine wave and return this value as the numeric measurement to TestStand. This AC value will be compared with user defined limits within TestStand. For this step use the following limits: • •

0
View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF